diff --git a/src/src/Rendering/Viewer/ResliceImageViewer.cpp b/src/src/Rendering/Viewer/ResliceImageViewer.cpp index a174fd0..24863b2 100644 --- a/src/src/Rendering/Viewer/ResliceImageViewer.cpp +++ b/src/src/Rendering/Viewer/ResliceImageViewer.cpp @@ -189,43 +189,7 @@ void ResliceImageViewer::Render() { MeasureRenderer->AddActor2D(cursor1); MeasureRenderer->AddActor2D(cursor2); - cursor1->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint()); - cursor2->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint()); - cursor1->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection()); - cursor2->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection()); - double sliceDirection1[4]{.0, .0, .0, 1.}; - double sliceDirection2[4]{.0, .0, .0, 1.}; - switch (DefaultOrientation) { - case 0:{ - sliceDirection1[2] = 1.0; - cursor1->GetProperty()->SetColor(0,0,1); - sliceDirection2[1] = 1.0; - cursor2->GetProperty()->SetColor(0,1,0); - Square->GetProperty()->SetColor(1,0,0); - break; - } - case 1:{ - sliceDirection1[0] = 1.0; - cursor1->GetProperty()->SetColor(1,0,0); - sliceDirection2[2] = 1.0; - cursor2->GetProperty()->SetColor(0,0,1); - Square->GetProperty()->SetColor(0,1,0); - - break; - } - case 2:{ - sliceDirection1[0] = 1.0; - cursor1->GetProperty()->SetColor(1,0,0); - sliceDirection2[1] = 1.0; - cursor2->GetProperty()->SetColor(0,1,0); - Square->GetProperty()->SetColor(0,0,1); - break; - } - } - OrientationMatrix->MultiplyPoint(sliceDirection1,sliceDirection1); - OrientationMatrix->MultiplyPoint(sliceDirection2,sliceDirection2); - cursor1->SetSliceDirectionVector(sliceDirection1); - cursor2->SetSliceDirectionVector(sliceDirection2); + InitOrthogonalCursor(); this->InteractorStyle->AddObserver(ResliceCursorLegendActor::MOUSE_FREE_MOVE,this,&ResliceImageViewer::updateHandle); this->InteractorStyle->AddObserver(ResliceCursorLegendActor::IMAGE_INTERACT_ON,cursor1,&ResliceCursorLegendActor::ActiveControlPointOff); this->InteractorStyle->AddObserver(ResliceCursorLegendActor::IMAGE_INTERACT_ON,this,&ResliceImageViewer::InvokeClick); @@ -250,6 +214,46 @@ void ResliceImageViewer::Render() { } } +void ResliceImageViewer::InitOrthogonalCursor() const { + cursor1->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint()); + cursor2->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint()); + cursor1->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection()); + cursor2->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection()); + double sliceDirection1[4]{.0, .0, .0, 1.}; + double sliceDirection2[4]{.0, .0, .0, 1.}; + switch (DefaultOrientation) { + case 0:{ + sliceDirection1[2] = 1.0; + cursor1->GetProperty()->SetColor(0, 0, 1); + sliceDirection2[1] = 1.0; + cursor2->GetProperty()->SetColor(0, 1, 0); + Square->GetProperty()->SetColor(1, 0, 0); + break; + } + case 1:{ + sliceDirection1[0] = 1.0; + cursor1->GetProperty()->SetColor(1, 0, 0); + sliceDirection2[2] = 1.0; + cursor2->GetProperty()->SetColor(0, 0, 1); + Square->GetProperty()->SetColor(0, 1, 0); + + break; + } + case 2:{ + sliceDirection1[0] = 1.0; + cursor1->GetProperty()->SetColor(1, 0, 0); + sliceDirection2[1] = 1.0; + cursor2->GetProperty()->SetColor(0, 1, 0); + Square->GetProperty()->SetColor(0, 0, 1); + break; + } + } + OrientationMatrix->MultiplyPoint(sliceDirection1, sliceDirection1); + OrientationMatrix->MultiplyPoint(sliceDirection2, sliceDirection2); + cursor1->SetSliceDirectionVector(sliceDirection1); + cursor2->SetSliceDirectionVector(sliceDirection2); +} + void ResliceImageViewer::SetDefaultSliceOrientation(int orientation) { double position[4] = {.0, .0, .0, 1.}; double ViewUp[4] = {.0, .0, .0, 1.}; diff --git a/src/src/Rendering/Viewer/ResliceImageViewer.h b/src/src/Rendering/Viewer/ResliceImageViewer.h index 00a44c7..557fc4c 100644 --- a/src/src/Rendering/Viewer/ResliceImageViewer.h +++ b/src/src/Rendering/Viewer/ResliceImageViewer.h @@ -80,6 +80,8 @@ public: void GetWindowLevel(double* windowLeveL); void SetWindowLevel(double* windowLeveL); + + void InitOrthogonalCursor() const; protected: ResliceImageViewer(); diff --git a/src/src/UI/Window/MPRResliceWindow.cpp b/src/src/UI/Window/MPRResliceWindow.cpp index 7b35633..3160ec8 100644 --- a/src/src/UI/Window/MPRResliceWindow.cpp +++ b/src/src/UI/Window/MPRResliceWindow.cpp @@ -70,6 +70,7 @@ MPRResliceWindow::MPRResliceWindow(QWidget *parent, Qt::WindowFlags f) : QDialog manager->InitEvents(); connect(toolBar, &ResliceMPRToolBar::modeButtonClicked,manager,&ResliceImageManager::SetMode); + connect(toolBar, &ResliceMPRToolBar::resetView,this,&MPRResliceWindow::Reset); } MPRResliceWindow::~MPRResliceWindow() { @@ -235,3 +236,15 @@ void MPRResliceWindow::SetDefaultWindowLevel(double* windowLevel) { mWindowLevel[1] = windowLevel[1]; } } + +void MPRResliceWindow::Reset() { + mViewerC->SetDefaultSliceOrientation(2); + mViewerC->InitOrthogonalCursor(); + mViewerC->SetWindowLevel(mWindowLevel); + mViewerS->SetDefaultSliceOrientation(1); + mViewerS->InitOrthogonalCursor(); + mViewerS->SetWindowLevel(mWindowLevel); + mViewerA->SetDefaultSliceOrientation(0); + mViewerA->InitOrthogonalCursor(); + mViewerA->SetWindowLevel(mWindowLevel); +} diff --git a/src/src/UI/Window/MPRResliceWindow.h b/src/src/UI/Window/MPRResliceWindow.h index 726a6c2..aa067de 100644 --- a/src/src/UI/Window/MPRResliceWindow.h +++ b/src/src/UI/Window/MPRResliceWindow.h @@ -34,6 +34,7 @@ public: void loadData(SeriesImageSet* series); void SetDefaultWindowLevel(double * windowLevel); void setRenderWindowLayout(LayoutType type); + void Reset(); private: QVTKOpenGLNativeWidget *mWidgetAxial; QVTKOpenGLNativeWidget *mWidgetSagittal;