From 9899b982a7e95d669a46f06c22b829035f57f741 Mon Sep 17 00:00:00 2001 From: Krad Date: Tue, 25 Oct 2022 14:50:28 +0800 Subject: [PATCH] Add orientation marker size and position logic. --- .../Viewer/VolumeRenderingViewer.cpp | 30 +++++++++---------- .../Rendering/Viewer/VolumeRenderingViewer.h | 1 + 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/src/Rendering/Viewer/VolumeRenderingViewer.cpp b/src/src/Rendering/Viewer/VolumeRenderingViewer.cpp index bfd3bc0..2f86ff9 100644 --- a/src/src/Rendering/Viewer/VolumeRenderingViewer.cpp +++ b/src/src/Rendering/Viewer/VolumeRenderingViewer.cpp @@ -131,6 +131,10 @@ VolumeRenderingViewer::~VolumeRenderingViewer() { this->InteractorStyle->Delete(); this->InteractorStyle = nullptr; } + if (this->OrientationMarker) { + this->OrientationMarker->Delete(); + this->OrientationMarker = nullptr; + } } void VolumeRenderingViewer::InstallPipeline() { @@ -159,11 +163,6 @@ void VolumeRenderingViewer::InstallPipeline() { Renderer->AddObserver(vtkCommand::EndEvent,this, &VolumeRenderingViewer::renderAnnotation); this->Renderer->SetBackground(0.0, 0.0, 0.0); } - if (this->OrientationMarker && this->OrientationMarker->GetOrientationMarker()){ - this->OrientationMarker->SetInteractor(this->Interactor); - this->OrientationMarker->EnabledOn(); - this->OrientationMarker->InteractiveOn(); - } } void VolumeRenderingViewer::UnInstallPipeline() { @@ -188,11 +187,6 @@ void VolumeRenderingViewer::UnInstallPipeline() { this->Interactor->SetInteractorStyle(nullptr); this->Interactor->SetRenderWindow(nullptr); } - if (this->OrientationMarker){ - this->OrientationMarker->SetInteractor(nullptr); - this->OrientationMarker->EnabledOff(); - this->OrientationMarker->InteractiveOff(); - } } void VolumeRenderingViewer::SetupInteractor(vtkRenderWindowInteractor * arg) { @@ -264,6 +258,11 @@ void VolumeRenderingViewer::Render() { RenderWindow->SetDesiredUpdateRate(Interactor->GetDesiredUpdateRate()); Interactor->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); SetViewDirection(0); + this->OrientationMarker->RemoveAllObservers(); + this->OrientationMarker->SetInteractor(this->Interactor); + this->OrientationMarker->EnabledOn(); + this->OrientationMarker->InteractiveOff(); + this->RenderWindow->AddObserver(vtkCommand::WindowResizeEvent, this, &VolumeRenderingViewer::resizeOrientationMarker); Render(); } Interactor->Render(); @@ -401,7 +400,6 @@ void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImagePropertie //冠状面 case 1: { - vtkErrorMacro("coronal") cube->SetZFaceTextRotation(-90); cube->SetXFaceTextRotation(90); cube->SetYFaceTextRotation(180); @@ -410,7 +408,6 @@ void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImagePropertie //矢状面 case 0: { - vtkErrorMacro("sagittal") cube->SetZFaceTextRotation(-90); cube->SetXFaceTextRotation(90); cube->SetYFaceTextRotation(-90); @@ -419,7 +416,6 @@ void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImagePropertie case 2: default: { - vtkErrorMacro("transverse") cube->SetZFaceTextRotation(-90); } } @@ -428,9 +424,6 @@ void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImagePropertie cube->GetTextEdgesProperty()->SetLineWidth(2.0); cube->GetCubeProperty()->SetColor(.0,.0,1.0); OrientationMarker->SetOrientationMarker(cube); - this->OrientationMarker->SetInteractor(this->Interactor); - this->OrientationMarker->EnabledOn(); - this->OrientationMarker->InteractiveOn(); } //change to WToM OrientationMatrix->Invert(); @@ -542,3 +535,8 @@ void VolumeRenderingViewer::ResetMaximumImageSampleDistance() { mapper->SetMaximumImageSampleDistance(4.0); } } + +void VolumeRenderingViewer::resizeOrientationMarker() { + int *size = this->Renderer->GetSize(); + this->OrientationMarker->SetViewport(1.0-(80.0/(double)size[0]),1.0-(80.0/(double)size[1]),1.0,1.0); +} diff --git a/src/src/Rendering/Viewer/VolumeRenderingViewer.h b/src/src/Rendering/Viewer/VolumeRenderingViewer.h index 3db8cee..9125d48 100644 --- a/src/src/Rendering/Viewer/VolumeRenderingViewer.h +++ b/src/src/Rendering/Viewer/VolumeRenderingViewer.h @@ -127,6 +127,7 @@ private: int a; return GetDirectionChar(directionVector, a); } + void resizeOrientationMarker(); };