fix: fix measure delete bug when measure select by control point

This commit is contained in:
kradchen
2025-04-29 10:39:21 +08:00
parent 558cf3cde1
commit 2c4d70a166
7 changed files with 40 additions and 2 deletions

View File

@@ -15,7 +15,8 @@
vtkStandardNewMacro(ControlPointActor) vtkStandardNewMacro(ControlPointActor)
ControlPointActor::ControlPointActor() ControlPointActor::ControlPointActor()
: shadowData(vtkPolyData::New()) { : shadowData(vtkPolyData::New())
, controlledActor(nullptr) {
BaseDataPoints->SetNumberOfPoints(1); BaseDataPoints->SetNumberOfPoints(1);
renderPoints->SetNumberOfPoints(1); renderPoints->SetNumberOfPoints(1);
renderPoints->SetPoint(0, 0, 0, 0); renderPoints->SetPoint(0, 0, 0, 0);

View File

@@ -27,6 +27,9 @@ public:
void SetWorldPosition(double *pos) { void SetWorldPosition(double *pos) {
SetWorldPosition(pos[0], pos[1], pos[2]); SetWorldPosition(pos[0], pos[1], pos[2]);
} }
vtkSetObjectMacro(controlledActor,DraggableActor);
vtkGetObjectMacro(controlledActor,DraggableActor);
protected: protected:
ControlPointActor(); ControlPointActor();
@@ -34,6 +37,7 @@ protected:
~ControlPointActor() override; ~ControlPointActor() override;
vtkPolyData *shadowData; vtkPolyData *shadowData;
DraggableActor * controlledActor;
}; };

View File

@@ -47,6 +47,10 @@ AngleAnnotationActor::AngleAnnotationActor()
controlP1->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb); controlP1->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb);
controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb); controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb);
controlP3->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb); controlP3->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::controlPointCb);
controlP1->SetcontrolledActor(this);
controlP2->SetcontrolledActor(this);
controlP3->SetcontrolledActor(this);
this->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::selfDragCb); this->AddObserver(DraggableActorEvents::DragEvent, this, &AngleAnnotationActor::selfDragCb);
} }

View File

@@ -33,6 +33,9 @@ ArrowAnnotationActor::ArrowAnnotationActor()
controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &ArrowAnnotationActor::controlPointCb); controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &ArrowAnnotationActor::controlPointCb);
controlP2->AddObserver(vtkCommand::EnterEvent, this, &ArrowAnnotationActor::HighlightOn); controlP2->AddObserver(vtkCommand::EnterEvent, this, &ArrowAnnotationActor::HighlightOn);
controlP2->AddObserver(vtkCommand::LeaveEvent, this, &ArrowAnnotationActor::HighlightOff); controlP2->AddObserver(vtkCommand::LeaveEvent, this, &ArrowAnnotationActor::HighlightOff);
controlP1->SetcontrolledActor(this);
controlP2->SetcontrolledActor(this);
this->AddObserver(DraggableActorEvents::DragEvent, this, &ArrowAnnotationActor::selfDragCb); this->AddObserver(DraggableActorEvents::DragEvent, this, &ArrowAnnotationActor::selfDragCb);
} }

View File

@@ -80,6 +80,12 @@ EllipseAnnotationActor::EllipseAnnotationActor() {
controlP_lb->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::controlPointCb); controlP_lb->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::controlPointCb);
controlP_rb->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::controlPointCb); controlP_rb->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::controlPointCb);
controlP_lt->SetcontrolledActor(this);
controlP_rt->SetcontrolledActor(this);
controlP_lb->SetcontrolledActor(this);
controlP_rb->SetcontrolledActor(this);
//this->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::selfDragCb); //this->AddObserver(DraggableActorEvents::DragEvent, this, &EllipseAnnotationActor::selfDragCb);

View File

@@ -21,6 +21,8 @@ LineAnnotationActor::LineAnnotationActor()
renderPoints->SetNumberOfPoints(2); renderPoints->SetNumberOfPoints(2);
controlP1->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::controlPointCb); controlP1->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::controlPointCb);
controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::controlPointCb); controlP2->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::controlPointCb);
controlP1->SetcontrolledActor(this);
controlP2->SetcontrolledActor(this);
this->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::selfDragCb); this->AddObserver(DraggableActorEvents::DragEvent, this, &LineAnnotationActor::selfDragCb);
} }

View File

@@ -22,11 +22,12 @@
#include <vtkTextActor.h> #include <vtkTextActor.h>
#include <vtkTextProperty.h> #include <vtkTextProperty.h>
#include "Rendering/Core/ControlPointActor.h"
#include "Rendering/Core/MarginCornerAnnotation.h"
#include "Rendering/Measure/MeasureStore.h" #include "Rendering/Measure/MeasureStore.h"
#include "Rendering/Legend/FastCornerAnnotationActor.h" #include "Rendering/Legend/FastCornerAnnotationActor.h"
#include "IO/General/ColorMapReader.h" #include "IO/General/ColorMapReader.h"
#include "Interaction/ActorDraggableInteractorStyle.h" #include "Interaction/ActorDraggableInteractorStyle.h"
#include "Rendering/Core/MarginCornerAnnotation.h"
namespace { namespace {
//扭转存在偏转的坐标轴 //扭转存在偏转的坐标轴
@@ -1022,13 +1023,30 @@ void DICOMImageViewer::AddMeasures(vtkObject *, unsigned long eventid, void *cal
void DICOMImageViewer::RemoveMeasures(vtkObject *, unsigned long eventid, void *calldata) { void DICOMImageViewer::RemoveMeasures(vtkObject *, unsigned long eventid, void *calldata) {
auto p = static_cast<vtkProp *>(calldata); auto p = static_cast<vtkProp *>(calldata);
auto da = DraggableActor::SafeDownCast(p); auto da = DraggableActor::SafeDownCast(p);
auto m = dynamic_cast<Measure *>(da); if (da->IsA("ControlPointActor"))
{
auto controlP = ControlPointActor::SafeDownCast(da);
if (nullptr == controlP) return;
if (nullptr == controlP->GetcontrolledActor()) return;
auto m = dynamic_cast<Measure *>(controlP->GetcontrolledActor());
if (m == nullptr) return;
ClearCurrentSliceMeasure(); ClearCurrentSliceMeasure();
measureStore->Remove(m); measureStore->Remove(m);
this->InteractorStyle->ClearSelectedProp(); this->InteractorStyle->ClearSelectedProp();
ReloadCurrentSliceMeasure(); ReloadCurrentSliceMeasure();
this->Render(); this->Render();
} }
else{
auto m = dynamic_cast<Measure *>(da);
if (m == nullptr) return;
ClearCurrentSliceMeasure();
measureStore->Remove(m);
this->InteractorStyle->ClearSelectedProp();
ReloadCurrentSliceMeasure();
this->Render();
}
}
void DICOMImageViewer::DeleteSelectedMeasure() { void DICOMImageViewer::DeleteSelectedMeasure() {
if (this->InteractorStyle->GetSelectedProp()) { if (this->InteractorStyle->GetSelectedProp()) {