Commit 2023685b authored by Cory Quammen's avatar Cory Quammen
Browse files

pqAxesToolbar: keep toolbar buttons up to date with view properties

A couple checkable toolbar buttons were not always reflecting the
state of the axes visibility properties.
parent 78e4aad1
Pipeline #185642 running with stages
......@@ -34,13 +34,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqActiveObjects.h"
#include "pqDataRepresentation.h"
#include "pqPropertyLinks.h"
#include "pqRenderView.h"
#include "pqRenderViewSelectionReaction.h"
#include "pqView.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMTrace.h"
class pqAxesToolbar::pqInternals : public Ui::pqAxesToolbar
{
public:
pqView* View = nullptr;
pqPropertyLinks Links;
};
//-----------------------------------------------------------------------------
......@@ -49,6 +54,8 @@ void pqAxesToolbar::constructor()
this->Internals = new pqInternals();
this->Internals->setupUi(this);
QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this,
SLOT(setView(pqView*)), Qt::QueuedConnection);
QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this,
SLOT(updateEnabledState()), Qt::QueuedConnection);
......@@ -83,22 +90,35 @@ pqAxesToolbar::~pqAxesToolbar()
this->Internals = 0;
}
//-----------------------------------------------------------------------------
void pqAxesToolbar::setView(pqView* view)
{
if (this->Internals->View == view)
{
return;
}
this->Internals->View = view;
this->Internals->Links.removeAllPropertyLinks();
if (!(view && view->getProxy()->GetProperty("OrientationAxesVisibility")))
{
return;
}
this->Internals->Links.addPropertyLink(this->Internals->actionShowOrientationAxes, "checked",
SIGNAL(toggled(bool)), view->getProxy(),
view->getProxy()->GetProperty("OrientationAxesVisibility"));
this->Internals->Links.addPropertyLink(this->Internals->actionShowCenterAxes, "checked",
SIGNAL(toggled(bool)), view->getProxy(), view->getProxy()->GetProperty("CenterAxesVisibility"));
}
//-----------------------------------------------------------------------------
void pqAxesToolbar::updateEnabledState()
{
pqRenderView* renderView = qobject_cast<pqRenderView*>(pqActiveObjects::instance().activeView());
this->Internals->actionShowOrientationAxes->setEnabled(renderView != NULL);
this->Internals->actionShowOrientationAxes->blockSignals(true);
this->Internals->actionShowOrientationAxes->setChecked(
renderView ? renderView->getOrientationAxesVisibility() : false);
this->Internals->actionShowOrientationAxes->blockSignals(false);
this->Internals->actionShowCenterAxes->setEnabled(renderView != NULL);
this->Internals->actionShowCenterAxes->blockSignals(true);
this->Internals->actionShowCenterAxes->setChecked(
renderView ? renderView->getCenterAxesVisibility() : false);
this->Internals->actionShowCenterAxes->blockSignals(false);
this->Internals->actionResetCenter->setEnabled(
pqActiveObjects::instance().activeRepresentation() != NULL);
}
......
......@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqApplicationComponentsModule.h"
#include <QToolBar>
class pqView;
/**
* pqAxesToolbar is the toolbar that has buttons for setting the center
* rotation axes, toggling its visibility etc.
......@@ -58,6 +60,7 @@ public:
~pqAxesToolbar() override;
protected Q_SLOTS:
void setView(pqView* view);
void updateEnabledState();
void showCenterAxes(bool);
void showOrientationAxes(bool);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment