Add reset MPR View.

This commit is contained in:
Krad
2023-01-09 17:49:57 +08:00
parent 6f51e1e7f5
commit 6ccc7ac6bd
4 changed files with 57 additions and 37 deletions

View File

@@ -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.};

View File

@@ -80,6 +80,8 @@ public:
void GetWindowLevel(double* windowLeveL);
void SetWindowLevel(double* windowLeveL);
void InitOrthogonalCursor() const;
protected:
ResliceImageViewer();

View File

@@ -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);
}

View File

@@ -34,6 +34,7 @@ public:
void loadData(SeriesImageSet* series);
void SetDefaultWindowLevel(double * windowLevel);
void setRenderWindowLayout(LayoutType type);
void Reset();
private:
QVTKOpenGLNativeWidget *mWidgetAxial;
QVTKOpenGLNativeWidget *mWidgetSagittal;