From 60306767fff554e9297af5805baf90cef84c7ed5 Mon Sep 17 00:00:00 2001 From: kradchen Date: Mon, 14 Jul 2025 16:42:20 +0800 Subject: [PATCH] feat: add volume measure mode to draggable style --- .../ActorDraggableInteractorStyle.cpp | 29 ++++++++++++++++++- .../ActorDraggableInteractorStyle.h | 7 ++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/src/Interaction/ActorDraggableInteractorStyle.cpp b/src/src/Interaction/ActorDraggableInteractorStyle.cpp index 6d07fdd..6b401ca 100644 --- a/src/src/Interaction/ActorDraggableInteractorStyle.cpp +++ b/src/src/Interaction/ActorDraggableInteractorStyle.cpp @@ -23,6 +23,7 @@ #include "Rendering/Core/DraggableActor.h" #include "Rendering/Measure/CrossCursorAnnotationActor.h" +#include "Rendering/Measure/EllipsoidVolumeAnnotationActor.h" #include "Common/QGlobals.h" vtkStandardNewMacro(ActorDraggableInteractorStyle) @@ -121,6 +122,10 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() { return; } } + if(this->InteractionMode == VTKIS_VOLUMEMEASURE){ + EllipsoidVolumeAnnotationActor::Default()->onMeasureLeftButtonDown(Interactor); + this->StartState(VTKIS_VOLUMEMEASURE); + } if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) { this->WindowLevelStartPosition[0] = x; this->WindowLevelStartPosition[1] = y; @@ -188,6 +193,10 @@ void ActorDraggableInteractorStyle::OnLeftButtonUp() { case VTKIS_SYNCPOINT: this->EndSyncSlicePoint(); break; + case VTKIS_VOLUMEMEASURE: + EllipsoidVolumeAnnotationActor::Default()->onMeasureLeftButtonUp(Interactor); + this->StopState(); + break; } vtkInteractorStyleImage::OnLeftButtonUp(); } @@ -271,7 +280,10 @@ void ActorDraggableInteractorStyle::OnMouseMove() { this->SyncSlicePoint(); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); break; - + case VTKIS_VOLUMEMEASURE: + VolumeMeasure(); + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; } vtkInteractorStyleImage::OnMouseMove(); } @@ -372,6 +384,11 @@ void ActorDraggableInteractorStyle::MeasurePlace() { measure->onMeasureMouseMove(this->Interactor); } +void ActorDraggableInteractorStyle::VolumeMeasure() +{ + EllipsoidVolumeAnnotationActor::Default()->onMeasureMouseMove(Interactor); +} + void ActorDraggableInteractorStyle::Drag() { int *pos = this->Interactor->GetEventPosition(); this->FindPokedRenderer(pos[0], pos[1]); @@ -688,6 +705,16 @@ void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i) { } } +void ActorDraggableInteractorStyle::SetInteractionModeFromEnum(int InteractionMode) +{ + this->UnActiveMeasure(); + if (this->InteractionMode == 39 && InteractionMode != 39){ + EllipsoidVolumeAnnotationActor::Default()->ClearRenderingState(); + this->Interactor->Render(); + } + this->InteractionMode = InteractionMode; +} + void ActorDraggableInteractorStyle::DispatchEvent() { } diff --git a/src/src/Interaction/ActorDraggableInteractorStyle.h b/src/src/Interaction/ActorDraggableInteractorStyle.h index d25c4ce..d15d2d8 100644 --- a/src/src/Interaction/ActorDraggableInteractorStyle.h +++ b/src/src/Interaction/ActorDraggableInteractorStyle.h @@ -72,10 +72,7 @@ vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage); void SetCurrentImageNumber(int i) override; - void SetInteractionModeFromEnum(int InteractionMode) { - this->UnActiveMeasure(); - this->InteractionMode = InteractionMode; - } + void SetInteractionModeFromEnum(int InteractionMode); //void SetInteractionModeToImageSlicing() { // this->UnActiveMeasure(); @@ -172,6 +169,8 @@ protected: void MeasurePlace(); + void VolumeMeasure(); + void NoneStatePick(); void StartSyncSlicePoint();