From fffa3de3586de69f88f806dd91aca3d2a9451930 Mon Sep 17 00:00:00 2001 From: kradchen Date: Mon, 7 Jul 2025 10:17:49 +0800 Subject: [PATCH] feat: add mouse right button gesture --- .../ActorDraggableInteractorStyle.cpp | 35 +++++++++++++++++++ .../ActorDraggableInteractorStyle.h | 3 ++ 2 files changed, 38 insertions(+) diff --git a/src/src/Interaction/ActorDraggableInteractorStyle.cpp b/src/src/Interaction/ActorDraggableInteractorStyle.cpp index 45d1446..037159d 100644 --- a/src/src/Interaction/ActorDraggableInteractorStyle.cpp +++ b/src/src/Interaction/ActorDraggableInteractorStyle.cpp @@ -204,6 +204,41 @@ void ActorDraggableInteractorStyle::OnRightButtonDown() { if (dragProp) { dragProp->InvokeEvent(DraggableStyleEvents::RightButtonClickEvent, this->Interactor); } + if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) { + this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale(); + this->StartDolly(); + } else if (this->InteractionMode == VTKIS_IMAGE_ZOOM) { + this->StartPan(); + } else if (this->InteractionMode == VTKIS_IMAGE_PAN) { + this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale(); + this->StartDolly(); + } else if (this->InteractionMode == VTKIS_IMAGE_SLICING) { + this->WindowLevelStartPosition[0] = x; + this->WindowLevelStartPosition[1] = y; + this->StartWindowLevel(); + } + else if(this->InteractionMode == VTKIS_SYNCPOINT){ + this->WindowLevelStartPosition[0] = x; + this->WindowLevelStartPosition[1] = y; + this->StartWindowLevel(); + } +} + +void ActorDraggableInteractorStyle::OnRightButtonUp() { + switch (this->State) { + case VTKIS_IMAGE_WINDOWLEVEL: + case VTKIS_IMAGE_PAN: + this->EndDolly(); + break; + case VTKIS_IMAGE_ZOOM: + this->EndPan(); + break; + case VTKIS_IMAGE_SLICING: + case VTKIS_SYNCPOINT: + this->EndWindowLevel(); + break; + } + vtkInteractorStyleImage::OnLeftButtonUp(); } void ActorDraggableInteractorStyle::OnMouseMove() { diff --git a/src/src/Interaction/ActorDraggableInteractorStyle.h b/src/src/Interaction/ActorDraggableInteractorStyle.h index bcefbef..d25c4ce 100644 --- a/src/src/Interaction/ActorDraggableInteractorStyle.h +++ b/src/src/Interaction/ActorDraggableInteractorStyle.h @@ -42,6 +42,9 @@ vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage); */ void OnRightButtonDown() override; + void OnRightButtonUp() override; + + #if VTK_MAJOR_VERSION>=9 void OnLeftButtonDoubleClick() override; #endif