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) {
selectedProp = dragProp;
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent);
#if VTK_MAJOR_VERSION<9
if (this->Interactor->GetRepeatCount()) {
dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr);
}
#endif
DragStartOrigin[0] = x;
DragStartOrigin[1] = y;
this->StartDrag();
return;
}
#if VTK_MAJOR_VERSION<9
if (Interactor->GetRepeatCount()) {
if (measure) {
measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor));
@@ -101,6 +104,7 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
return;
}
}
#endif
if (measure) {
measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor));
if (this->State != VTKIS_MEASURE) this->StartMeasure();
@@ -113,8 +117,6 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
this->StartColorMapping();
return;
}
if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) {
this->WindowLevelStartPosition[0] = x;
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() {
switch (this->State) {
case VTKIS_DRAG:
@@ -544,3 +571,4 @@ void ActorDraggableInteractorStyle::DispatchEvent() {
}

View File

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