Skip to content

Commit

Permalink
Refs #6347. Initial cut at using new view.
Browse files Browse the repository at this point in the history
This was incredibly easy to get going. Need to do lots of clean up and then
hook up the slice viewer.
  • Loading branch information
Michael Reuter committed Jan 9, 2013
1 parent 572366b commit 259b2dc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,11 @@
<property name="windowTitle">
<string>MultiSliceView</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1" columnstretch="0,1,0" rowminimumheight="1,0" columnminimumwidth="1,0,1">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="Mantid::Vates::SimpleGui::AxisInteractor" name="yAxisWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Mantid::Vates::SimpleGui::AxisInteractor" name="xAxisWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<item>
<widget class="QFrame" name="renderFrame">
<property name="enabled">
<bool>true</bool>
Expand All @@ -95,33 +48,9 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Mantid::Vates::SimpleGui::AxisInteractor" name="zAxisWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>Mantid::Vates::SimpleGui::AxisInteractor</class>
<extends>QWidget</extends>
<header>MantidVatesSimpleGuiQtWidgets/AxisInteractor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
/// Correct post-accept visibility issues.
virtual void correctVisibility(pqPipelineBrowserWidget *pbw);
/// Creates a single view instance.
virtual pqRenderView *createRenderView(QWidget *container);
virtual pqRenderView *createRenderView(QWidget *container,
QString viewName=QString(""));
/// Remove all filters of a given name: i.e. Slice.
virtual void destroyFilter(pqObjectBuilder *builder, const QString &name);
/// Destroy sources and view relevant to mode switching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,6 @@ void MdViewerWidget::setParaViewComponentsForView()
SIGNAL(applied()),
this, SLOT(checkForUpdates()));

if (this->currentView->inherits("MultiSliceView"))
{
QObject::connect(this->ui.pipelineBrowser,
SIGNAL(clicked(const QModelIndex &)),
static_cast<MultiSliceView *>(this->currentView),
SLOT(selectIndicator()));
QObject::connect(this->ui.propertiesPanel,
SIGNAL(applied()),
static_cast<MultiSliceView *>(this->currentView),
SLOT(updateSelectedIndicator()));
}
QObject::connect(this->currentView, SIGNAL(setViewsStatus(bool)),
this->ui.modeControlWidget, SLOT(enableViewButtons(bool)));
QObject::connect(this->currentView,
Expand Down
184 changes: 7 additions & 177 deletions Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MultisliceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,85 +53,10 @@ MultiSliceView::MultiSliceView(QWidget *parent) : ViewBase(parent)
{
this->isOrigSrc = false;
this->ui.setupUi(this);
this->ui.xAxisWidget->setScalePosition(AxisInteractor::LeftScale);
this->ui.yAxisWidget->setScalePosition(AxisInteractor::TopScale);
this->ui.zAxisWidget->setScalePosition(AxisInteractor::RightScale);

this->mainView = this->createRenderView(this->ui.renderFrame);

QObject::connect(this->ui.xAxisWidget->getScalePicker(),
SIGNAL(clicked(double)), this, SLOT(makeXcut(double)));
QObject::connect(this->ui.yAxisWidget->getScalePicker(),
SIGNAL(clicked(double)), this, SLOT(makeYcut(double)));
QObject::connect(this->ui.zAxisWidget->getScalePicker(),
SIGNAL(clicked(double)), this, SLOT(makeZcut(double)));

QObject::connect(this->ui.xAxisWidget->getScalePicker(),
SIGNAL(moved(double)), this,
SLOT(updateCutPosition(double)));
QObject::connect(this->ui.yAxisWidget->getScalePicker(),
SIGNAL(moved(double)), this,
SLOT(updateCutPosition(double)));
QObject::connect(this->ui.zAxisWidget->getScalePicker(),
SIGNAL(moved(double)), this,
SLOT(updateCutPosition(double)));

QObject::connect(this->ui.xAxisWidget,
SIGNAL(indicatorSelected(const QString &)), this,
SLOT(indicatorSelected(const QString &)));
QObject::connect(this->ui.yAxisWidget,
SIGNAL(indicatorSelected(const QString &)), this,
SLOT(indicatorSelected(const QString &)));
QObject::connect(this->ui.zAxisWidget,
SIGNAL(indicatorSelected(const QString &)), this,
SLOT(indicatorSelected(const QString &)));

QObject::connect(this, SIGNAL(sliceNamed(const QString &)),
this->ui.xAxisWidget,
SLOT(setIndicatorName(const QString &)));
QObject::connect(this, SIGNAL(sliceNamed(const QString &)),
this->ui.yAxisWidget,
SLOT(setIndicatorName(const QString &)));
QObject::connect(this, SIGNAL(sliceNamed(const QString &)),
this->ui.zAxisWidget,
SLOT(setIndicatorName(const QString &)));

QObject::connect(this->ui.xAxisWidget,
SIGNAL(deleteIndicator(const QString &)), this,
SLOT(deleteCut(const QString &)));
QObject::connect(this->ui.yAxisWidget,
SIGNAL(deleteIndicator(const QString &)), this,
SLOT(deleteCut(const QString &)));
QObject::connect(this->ui.zAxisWidget,
SIGNAL(deleteIndicator(const QString &)), this,
SLOT(deleteCut(const QString &)));

QObject::connect(this->ui.xAxisWidget,
SIGNAL(showOrHideIndicator(bool, const QString &)),
this, SLOT(cutVisibility(bool, const QString &)));
QObject::connect(this->ui.yAxisWidget,
SIGNAL(showOrHideIndicator(bool, const QString &)),
this, SLOT(cutVisibility(bool, const QString &)));
QObject::connect(this->ui.zAxisWidget,
SIGNAL(showOrHideIndicator(bool, const QString &)),
this, SLOT(cutVisibility(bool, const QString &)));

QObject::connect(this->ui.xAxisWidget,
SIGNAL(showInSliceView(const QString &)),
this,
SLOT(showCutInSliceViewer(const QString &)));
QObject::connect(this->ui.yAxisWidget,
SIGNAL(showInSliceView(const QString &)),
this,
SLOT(showCutInSliceViewer(const QString &)));
QObject::connect(this->ui.zAxisWidget,
SIGNAL(showInSliceView(const QString &)),
this,
SLOT(showCutInSliceViewer(const QString &)));

this->ui.xAxisWidget->installEventFilter(this);
this->ui.yAxisWidget->installEventFilter(this);
this->ui.zAxisWidget->installEventFilter(this);

this->mainView = this->createRenderView(this->ui.renderFrame,
QString("MultiSlice"));

}

MultiSliceView::~MultiSliceView()
Expand Down Expand Up @@ -176,7 +101,7 @@ bool MultiSliceView::eventFilter(QObject *ob, QEvent *ev)
void MultiSliceView::destroyView()
{
pqObjectBuilder *builder = pqApplicationCore::instance()->getObjectBuilder();
this->destroyFilter(builder, QString("Slice"));
//this->destroyFilter(builder, QString("Slice"));
builder->destroy(this->mainView);
}

Expand All @@ -187,9 +112,6 @@ pqRenderView* MultiSliceView::getView()

void MultiSliceView::clearIndicatorSelections()
{
this->ui.xAxisWidget->clearSelections();
this->ui.yAxisWidget->clearSelections();
this->ui.zAxisWidget->clearSelections();
}

void MultiSliceView::setupData()
Expand All @@ -198,11 +120,11 @@ void MultiSliceView::setupData()

pqDataRepresentation *drep = builder->createDataRepresentation(\
this->origSrc->getOutputPort(0), this->mainView);
vtkSMPropertyHelper(drep->getProxy(), "Representation").Set("Surface");
vtkSMPropertyHelper(drep->getProxy(), "Representation").Set("Slices");
drep->getProxy()->UpdateVTKObjects();
this->origRep = qobject_cast<pqPipelineRepresentation*>(drep);
this->origRep->colorByArray("signal",
vtkDataObject::FIELD_ASSOCIATION_CELLS);
vtkDataObject::FIELD_ASSOCIATION_CELLS);
}

void MultiSliceView::setupAxisInfo()
Expand All @@ -215,10 +137,6 @@ void MultiSliceView::setupAxisInfo()
AxisInformation *yinfo = parser.getAxisInfo("YDimension");
AxisInformation *zinfo = parser.getAxisInfo("ZDimension");

this->ui.xAxisWidget->setInformation(xinfo);
this->ui.yAxisWidget->setInformation(yinfo);
this->ui.zAxisWidget->setInformation(zinfo);

delete xinfo;
delete yinfo;
delete zinfo;
Expand Down Expand Up @@ -309,9 +227,6 @@ void MultiSliceView::selectIndicator()
vtkSMProxy* smProxy = selection->GetSelectedProxy(0);
pqPipelineSource *source = pqModel->findItem<pqPipelineSource*>(smProxy);
QString name = source->getSMName();
this->ui.xAxisWidget->selectIndicator(name);
this->ui.yAxisWidget->selectIndicator(name);
this->ui.zAxisWidget->selectIndicator(name);
}

void MultiSliceView::updateSelectedIndicator()
Expand All @@ -325,18 +240,6 @@ void MultiSliceView::updateSelectedIndicator()
vtkSMProxy *plane = vtkSMPropertyHelper(smProxy, "CutFunction").GetAsProxy();
double origin[3];
vtkSMPropertyHelper(plane, "Origin").Get(origin, 3);
if (this->ui.xAxisWidget->hasIndicator())
{
this->ui.xAxisWidget->updateIndicator(origin[0]);
}
if (this->ui.yAxisWidget->hasIndicator())
{
this->ui.yAxisWidget->updateIndicator(origin[1]);
}
if (this->ui.zAxisWidget->hasIndicator())
{
this->ui.zAxisWidget->updateIndicator(origin[2]);
}
}
}

Expand All @@ -360,23 +263,6 @@ void MultiSliceView::updateCutPosition(double position)
// Something went wrong retrieving the selection
return;
}

vtkSMProxy *plane = vtkSMPropertyHelper(smProxy, "CutFunction").GetAsProxy();
double origin[3] = {0.0, 0.0, 0.0};
if (this->ui.xAxisWidget->hasIndicator())
{
origin[0] = position;
}
if (this->ui.yAxisWidget->hasIndicator())
{
origin[1] = position;
}
if (this->ui.zAxisWidget->hasIndicator())
{
origin[2] = position;
}
vtkSMPropertyHelper(plane, "Origin").Set(origin, 3);
plane->UpdateVTKObjects();
}

void MultiSliceView::deleteCut(const QString &name)
Expand All @@ -401,9 +287,6 @@ void MultiSliceView::cutVisibility(bool isVisible, const QString &name)
bool MultiSliceView::noIndicatorsLeft()
{
int count = 0;
count += this->ui.xAxisWidget->numIndicators();
count += this->ui.yAxisWidget->numIndicators();
count += this->ui.zAxisWidget->numIndicators();
return count == 0;
}

Expand All @@ -424,56 +307,6 @@ void MultiSliceView::setAxisScales()
AxisInformation *yinfo = parser.getAxisInfo("YDimension");
AxisInformation *zinfo = parser.getAxisInfo("ZDimension");

// Check to see if axis mapping has changed and update if necessary.
bool isXChanged = this->checkTitles(xinfo, this->ui.xAxisWidget);
bool isYChanged = this->checkTitles(yinfo, this->ui.yAxisWidget);
bool isZChanged = this->checkTitles(zinfo, this->ui.zAxisWidget);
bool haveAxesChanged = isXChanged || isYChanged || isZChanged;

if (haveAxesChanged)
{
if (isXChanged)
{
this->ui.xAxisWidget->deleteAllIndicators();
this->ui.xAxisWidget->setInformation(xinfo, true);
}
if (isYChanged)
{
this->ui.yAxisWidget->deleteAllIndicators();
this->ui.yAxisWidget->setInformation(yinfo, true);
}
if (isZChanged)
{
this->ui.zAxisWidget->deleteAllIndicators();
this->ui.zAxisWidget->setInformation(zinfo, true);
}
}

// Axis mapping not changed, so check if boundaries changed.
bool xBoundsChanged = this->checkBounds(xinfo, this->ui.xAxisWidget);
bool yBoundsChanged = this->checkBounds(yinfo, this->ui.yAxisWidget);
bool zBoundsChanged = this->checkBounds(zinfo, this->ui.zAxisWidget);
bool haveBoundsChanged = xBoundsChanged || yBoundsChanged || zBoundsChanged;

if (haveBoundsChanged)
{
if (xBoundsChanged)
{
this->ui.xAxisWidget->setBounds(xinfo, true);
this->resetOrDeleteIndicators(this->ui.xAxisWidget, 0);
}
if (yBoundsChanged)
{
this->ui.yAxisWidget->setBounds(yinfo, true);
this->resetOrDeleteIndicators(this->ui.yAxisWidget, 1);
}
if (zBoundsChanged)
{
this->ui.zAxisWidget->setBounds(zinfo, true);
this->resetOrDeleteIndicators(this->ui.zAxisWidget, 2);
}
}

delete xinfo;
delete yinfo;
delete zinfo;
Expand Down Expand Up @@ -556,9 +389,6 @@ void MultiSliceView::checkSliceViewCompat()
QString wsName = this->getWorkspaceName();
if (!wsName.isEmpty())
{
this->ui.xAxisWidget->setShowSliceView(true);
this->ui.yAxisWidget->setShowSliceView(true);
this->ui.zAxisWidget->setShowSliceView(true);
}
}

Expand Down

0 comments on commit 259b2dc

Please sign in to comment.