From 6c4b5754a07dff46f0fa5114c863faa1bff95f0f Mon Sep 17 00:00:00 2001 From: Krad Date: Wed, 16 Nov 2022 11:33:31 +0800 Subject: [PATCH] Simple measure drag for volume rendering. --- src/src/Interaction/VolumeInteractorStyle.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/src/Interaction/VolumeInteractorStyle.cpp b/src/src/Interaction/VolumeInteractorStyle.cpp index 8a745e1..edd44a7 100644 --- a/src/src/Interaction/VolumeInteractorStyle.cpp +++ b/src/src/Interaction/VolumeInteractorStyle.cpp @@ -45,8 +45,10 @@ void VolumeInteractorStyle::OnLeftButtonDown() { this->GrabFocus(this->EventCallbackCommand); // un select last selected prop if (CurrentProp) { - CurrentProp->InvokeEvent(DraggableActor::DraggableActorEvents::UnSelectedEvent); - CurrentProp = nullptr; + DragStartOrigin[0] = x; + DragStartOrigin[1] = y; + this->StartDrag(); + return; } if (measure) { measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor)); @@ -157,6 +159,10 @@ void VolumeInteractorStyle::OnMouseMove() { this->WindowLevel(); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); break; + case VTKIS_DRAG: + Drag(); + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; case VTKIS_MEASURE: MeasurePlace(); // this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); @@ -321,7 +327,7 @@ void VolumeInteractorStyle::GetCurrentVolumeProperty() { void VolumeInteractorStyle::Drag() { int *pos = this->Interactor->GetEventPosition(); this->FindPokedRenderer(pos[0], pos[1]); - DraggableActor::SafeDownCast(dragProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]); + DraggableActor::SafeDownCast(CurrentProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]); this->Interactor->Render(); }