Skip to content

Commit

Permalink
Refs #6347. SliceViewer now works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Jan 10, 2013
1 parent 300758f commit 567515f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected slots:
void checkSliceClicked(int axisIndex, double sliceOffsetOnAxis,
int button, int modifier);
/// Launch SliceViewer with the specified cut.
void showCutInSliceViewer(const QString &name);
void showCutInSliceViewer(int axisIndex, double sliceOffsetOnAxis);

private:
Q_DISABLE_COPY(MultiSliceView)
Expand Down
35 changes: 21 additions & 14 deletions Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MultisliceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,17 @@ void MultiSliceView::resetCamera()
* This function checks the signal coming from the MultiSliceView when a slice
* indicator is clicked.
* @param axisIndex : index for the axis on which the clicked indicator resides
* @param sliceOffsetOnAxis :
* @param sliceOffsetOnAxis : location of slice along axis
* @param button : which mouse button is being used
* @param modifier : which modifier key is being used
*/
void MultiSliceView::checkSliceClicked(int axisIndex, double sliceOffsetOnAxis,
int button, int modifier)
{
UNUSED_ARG(sliceOffsetOnAxis);
if (modifier == vtkContextMouseEvent::CONTROL_MODIFIER &&
button == vtkContextMouseEvent::LEFT_BUTTON)
{
std::cout << "Right combination present." << std::endl;
this->showCutInSliceViewer(axisIndex);
this->showCutInSliceViewer(axisIndex, sliceOffsetOnAxis);
}
}

Expand All @@ -133,9 +131,10 @@ void MultiSliceView::checkSliceViewCompat()
* It will gather all of the necessary information and create an XML
* representation of the current dataset and cut parameters. That will then
* be handed to the SliceViewer.
* @param name the slice to be opened in SliceViewer
* @param axisIndex the index of the slice to be opened in SliceViewer
*/
void MultiSliceView::showCutInSliceViewer(const QString &name)
void MultiSliceView::showCutInSliceViewer(int axisIndex,
double sliceOffsetOnAxis)
{
// Get the associated workspace name
QString wsName = this->getWorkspaceName();
Expand Down Expand Up @@ -173,13 +172,21 @@ void MultiSliceView::showCutInSliceViewer(const QString &name)
}

// Get the necessary information from the cut
pqPipelineSource *cut = smModel->findItem<pqPipelineSource *>(name);
vtkSMProxy *plane = vtkSMPropertyHelper(cut->getProxy(),
"CutFunction").GetAsProxy();
// 10/01/2013 Cannot use the GetSliceOrigin due to bug in ParaView
// which only returns (0, 0, 0) from the function call.
/*
const double *origin = this->mainView->GetSliceOrigin(axisIndex);
std::cout << "(" << origin[0] << ", " << origin[1] << ", ";
std::cout << origin[2] << ")" << std::endl;
*/

const double *orient = this->mainView->GetSliceNormal(axisIndex);

// Construct origin vector from orientation vector due to ParaView bug
double origin[3];
vtkSMPropertyHelper(plane, "Origin").Get(origin, 3);
double orient[3];
vtkSMPropertyHelper(plane, "Normal").Get(orient, 3);
origin[0] = sliceOffsetOnAxis * orient[0];
origin[1] = sliceOffsetOnAxis * orient[1];
origin[2] = sliceOffsetOnAxis * orient[2];

// Create the XML holder
VATES::RebinningKnowledgeSerializer rks(VATES::LocationNotRequired);
Expand All @@ -188,8 +195,8 @@ void MultiSliceView::showCutInSliceViewer(const QString &name)

MDImplicitFunction_sptr impplane(new MDPlaneImplicitFunction(3, orient,
origin));
rks.setImplicitFunction(impplane);;
QString titleAddition = name;
rks.setImplicitFunction(impplane);
QString titleAddition = "";

// Use the WidgetFactory to create the slice viewer window
SliceViewerWindow *w = MantidQt::Factory::WidgetFactory::Instance()->createSliceViewerWindow(wsName, titleAddition);
Expand Down

0 comments on commit 567515f

Please sign in to comment.