Fix interactor style double click bug(cause by VTK update)

This commit is contained in:
Krad
2022-11-24 14:05:00 +08:00
parent d6733694b1
commit 741f3210fb
2 changed files with 37 additions and 2 deletions

View File

@@ -74,14 +74,17 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
if (dragProp) { if (dragProp) {
selectedProp = dragProp; selectedProp = dragProp;
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent); selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent);
#if VTK_MAJOR_VERSION<9
if (this->Interactor->GetRepeatCount()) { if (this->Interactor->GetRepeatCount()) {
dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr); dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr);
} }
#endif
DragStartOrigin[0] = x; DragStartOrigin[0] = x;
DragStartOrigin[1] = y; DragStartOrigin[1] = y;
this->StartDrag(); this->StartDrag();
return; return;
} }
#if VTK_MAJOR_VERSION<9
if (Interactor->GetRepeatCount()) { if (Interactor->GetRepeatCount()) {
if (measure) { if (measure) {
measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor)); measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor));
@@ -101,6 +104,7 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
return; return;
} }
} }
#endif
if (measure) { if (measure) {
measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor)); measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor));
if (this->State != VTKIS_MEASURE) this->StartMeasure(); if (this->State != VTKIS_MEASURE) this->StartMeasure();
@@ -113,8 +117,6 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
this->StartColorMapping(); this->StartColorMapping();
return; return;
} }
if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) { if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) {
this->WindowLevelStartPosition[0] = x; this->WindowLevelStartPosition[0] = x;
this->WindowLevelStartPosition[1] = y; this->WindowLevelStartPosition[1] = y;
@@ -130,6 +132,31 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
} }
#if VTK_MAJOR_VERSION>=9
void ActorDraggableInteractorStyle::OnLeftButtonDoubleClick() {
if (dragProp) {
dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr);
}
if (measure) {
measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor));
if (!measure->isMeasurePlacing()) {
this->EndMeasure();
auto temp = measure;
measure = measure->GetNextMeasure();
if (!temp->Valid()) {
temp->ForceDelete();
temp = nullptr;
}
}
return;
}
if (!scalarProp) {
this->InvokeEvent(DraggableStyleEvents::DoubleClickEvent, nullptr);
return;
}
}
#endif
void ActorDraggableInteractorStyle::OnLeftButtonUp() { void ActorDraggableInteractorStyle::OnLeftButtonUp() {
switch (this->State) { switch (this->State) {
case VTKIS_DRAG: case VTKIS_DRAG:
@@ -544,3 +571,4 @@ void ActorDraggableInteractorStyle::DispatchEvent() {
} }

View File

@@ -13,8 +13,11 @@
#include "functional" #include "functional"
#include "vtkCornerAnnotation.h" #include "vtkCornerAnnotation.h"
#include "vtkCommand.h" #include "vtkCommand.h"
#include <vtkVersion.h>
#include "Rendering/Core/RenderingDefines.h" #include "Rendering/Core/RenderingDefines.h"
class vtkProp; class vtkProp;
class Measure; class Measure;
@@ -41,6 +44,10 @@ vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage);
*/ */
void OnRightButtonDown() override; void OnRightButtonDown() override;
#if VTK_MAJOR_VERSION>=9
void OnLeftButtonDoubleClick() override;
#endif
void OnLeftButtonDown() override; void OnLeftButtonDown() override;
/** /**