Add orientation marker size and position logic.

This commit is contained in:
Krad
2022-10-25 14:50:28 +08:00
parent 356ea373ed
commit 9899b982a7
2 changed files with 15 additions and 16 deletions

View File

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

View File

@@ -127,6 +127,7 @@ private:
int a;
return GetDirectionChar(directionVector, a);
}
void resizeOrientationMarker();
};