SwitchViewDirection will remove volume measure.

This commit is contained in:
Krad
2022-11-16 11:21:05 +08:00
parent 01105d0c66
commit 6d70e5d309
4 changed files with 16 additions and 9 deletions

View File

@@ -329,12 +329,12 @@ void VolumeInteractorStyle::MeasurePlace() {
} }
void VolumeInteractorStyle::ClearMeasure() { void VolumeInteractorStyle::ClearMeasure() {
ActiveMeasure(nullptr);
EndMeasure();
std::for_each(measureStore.begin(), measureStore.end(),[=](Measure* m){ std::for_each(measureStore.begin(), measureStore.end(),[=](Measure* m){
picker->DeletePickList(m->GetProp()); picker->DeletePickList(m->GetProp());
m->ForceDelete(); m->ForceDelete();
}); });
measureStore.clear(); measureStore.clear();
} }

View File

@@ -300,7 +300,7 @@ void VolumeRenderingViewer::Render() {
firstRender = false; firstRender = false;
RenderWindow->SetDesiredUpdateRate(Interactor->GetDesiredUpdateRate()); RenderWindow->SetDesiredUpdateRate(Interactor->GetDesiredUpdateRate());
Interactor->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); Interactor->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr);
SetViewDirection(0); SwitchViewDirection(0);
this->OrientationMarker->RemoveAllObservers(); this->OrientationMarker->RemoveAllObservers();
this->OrientationMarker->SetInteractor(this->Interactor); this->OrientationMarker->SetInteractor(this->Interactor);
this->OrientationMarker->EnabledOn(); this->OrientationMarker->EnabledOn();
@@ -483,7 +483,7 @@ void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImagePropertie
OrientationMatrix->Invert(); OrientationMatrix->Invert();
} }
void VolumeRenderingViewer::SetViewDirection(int direction) { void VolumeRenderingViewer::SwitchViewDirection(int direction) {
double position[4] = {.0, .0, .0, 1.}; double position[4] = {.0, .0, .0, 1.};
double ViewUp[4] = {.0, .0, .0, 1.}; double ViewUp[4] = {.0, .0, .0, 1.};
switch (direction){ switch (direction){
@@ -525,6 +525,10 @@ void VolumeRenderingViewer::SetViewDirection(int direction) {
camera->SetPosition(position); camera->SetPosition(position);
camera->SetViewUp(ViewUp); camera->SetViewUp(ViewUp);
Renderer->ResetCamera(); Renderer->ResetCamera();
auto style = VolumeInteractorStyle::SafeDownCast(InteractorStyle);
if (style){
style->ClearMeasure();
}
} }
void VolumeRenderingViewer::ResetZoomFitWindow() { void VolumeRenderingViewer::ResetZoomFitWindow() {
@@ -572,7 +576,10 @@ void VolumeRenderingViewer::ResetZoomFitWindow() {
//use 0.99 to avoid border out of screen //use 0.99 to avoid border out of screen
camera->Dolly(0.99/halfDisY); camera->Dolly(0.99/halfDisY);
} }
auto style = VolumeInteractorStyle::SafeDownCast(InteractorStyle);
if (style){
style->ClearMeasure();
}
Renderer->ResetCameraClippingRange(); Renderer->ResetCameraClippingRange();
} }
@@ -601,7 +608,7 @@ void VolumeRenderingViewer::pressedOrientationMarker(vtkObject* sender, unsigned
auto cube = vtkAnnotatedCubeActor::SafeDownCast(OrientationMarker->GetOrientationMarker()); auto cube = vtkAnnotatedCubeActor::SafeDownCast(OrientationMarker->GetOrientationMarker());
if (cube){ if (cube){
int v = GetViewDirection(cube,var->ToInt()); int v = GetViewDirection(cube,var->ToInt());
SetViewDirection(v); SwitchViewDirection(v);
Render(); Render();
} }
} }

View File

@@ -78,10 +78,10 @@ public:
void SetInteractorStyleMode(int mode); void SetInteractorStyleMode(int mode);
void SetViewDirection(int direction); void SwitchViewDirection(int direction);
void ResetViewDirection(){ void ResetViewDirection(){
SetViewDirection(0); SwitchViewDirection(0);
} }
void ResetView(){ void ResetView(){

View File

@@ -54,7 +54,7 @@ VolumeRenderingWindow::VolumeRenderingWindow(QWidget *parent , Qt::WindowFlags f
}); });
connect(toolBar, &VolumeRenderingToolBar::viewDirectionChanged, [=](int direction){ connect(toolBar, &VolumeRenderingToolBar::viewDirectionChanged, [=](int direction){
mViewer->SetViewDirection(direction); mViewer->SwitchViewDirection(direction);
mViewer->Render(); mViewer->Render();
}); });
} }