diff --git a/src/src/Rendering/Core/ControlPointActor.cpp b/src/src/Rendering/Core/ControlPointActor.cpp index b9419b8..770175a 100644 --- a/src/src/Rendering/Core/ControlPointActor.cpp +++ b/src/src/Rendering/Core/ControlPointActor.cpp @@ -15,8 +15,7 @@ vtkStandardNewMacro(ControlPointActor) ControlPointActor::ControlPointActor() - : shadowData(vtkPolyData::New()) - , controlledActor(nullptr) { + : shadowData(vtkPolyData::New()) { BaseDataPoints->SetNumberOfPoints(1); renderPoints->SetNumberOfPoints(1); renderPoints->SetPoint(0, 0, 0, 0); diff --git a/src/src/Rendering/Core/ControlPointActor.h b/src/src/Rendering/Core/ControlPointActor.h index a5dd561..52a2ff7 100644 --- a/src/src/Rendering/Core/ControlPointActor.h +++ b/src/src/Rendering/Core/ControlPointActor.h @@ -29,8 +29,6 @@ public: void SetWorldPosition(double *pos) { SetWorldPosition(pos[0], pos[1], pos[2]); } - vtkSetObjectMacro(controlledActor,DraggableActor); - vtkGetObjectMacro(controlledActor,DraggableActor); protected: @@ -39,7 +37,6 @@ protected: ~ControlPointActor() override; vtkPolyData *shadowData; - DraggableActor * controlledActor; }; diff --git a/src/src/Rendering/Core/DraggableActor.cpp b/src/src/Rendering/Core/DraggableActor.cpp index e27776f..ac4ffb1 100644 --- a/src/src/Rendering/Core/DraggableActor.cpp +++ b/src/src/Rendering/Core/DraggableActor.cpp @@ -19,9 +19,11 @@ vtkStandardNewMacro(DraggableActor) DraggableActor::DraggableActor() - : BaseDataPoints(vtkPoints::New()), renderPoints(vtkPoints::New()), tempStorePoints(nullptr), - renderData(vtkPolyData::New()), actor2D(vtkActor2D::New()), shadow2D(vtkActor2D::New()), - senseArea(vtkActor2D::New()), text(nullptr), Renderer(nullptr), OnDrag(nullptr), OnDragEnd(nullptr) { + : BaseDataPoints(vtkPoints::New()), renderPoints(vtkPoints::New()), tempStorePoints(nullptr), + renderData(vtkPolyData::New()), actor2D(vtkActor2D::New()), shadow2D(vtkActor2D::New()), + senseArea(vtkActor2D::New()), text(nullptr), Renderer(nullptr), OnDrag(nullptr), OnDragEnd(nullptr), + controlledActor(nullptr) +{ //if (Renderer) Renderer->RemoveViewProp(this); vtkNew mapper; mapper->SetInputData(renderData); @@ -251,3 +253,5 @@ void DraggableActor::Show() { + + diff --git a/src/src/Rendering/Core/DraggableActor.h b/src/src/Rendering/Core/DraggableActor.h index 82eabba..dc2178b 100644 --- a/src/src/Rendering/Core/DraggableActor.h +++ b/src/src/Rendering/Core/DraggableActor.h @@ -135,6 +135,9 @@ public: void Show(); vtkSetClampMacro(MapMode,PointMapMode,MapToSlice,MapToWorld); + + vtkSetObjectMacro(controlledActor,DraggableActor); + vtkGetObjectMacro(controlledActor,DraggableActor); protected: DraggableActor(); @@ -168,6 +171,8 @@ private: DragCallBack OnDrag = nullptr; DragCallBack OnDragEnd = nullptr; + + DraggableActor * controlledActor; }; diff --git a/src/src/Rendering/Measure/AngleAnnotationActor.cpp b/src/src/Rendering/Measure/AngleAnnotationActor.cpp index ca1b707..f45be10 100644 --- a/src/src/Rendering/Measure/AngleAnnotationActor.cpp +++ b/src/src/Rendering/Measure/AngleAnnotationActor.cpp @@ -14,16 +14,10 @@ #include "Rendering/Core/ControlPointActor.h" - vtkStandardNewMacro(AngleAnnotationActor) AngleAnnotationActor::AngleAnnotationActor() -: DraggableActor() -, controlP1(ControlPointActor::New()) -, controlP2(ControlPointActor::New()) -, controlP3(ControlPointActor::New()) -, textProperty(nullptr) -, placedPointCount(0) + : DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New()), controlP3(ControlPointActor::New()), textProperty(nullptr), placedPointCount(0) { text = vtkActor2D::New(); @@ -226,4 +220,13 @@ void AngleAnnotationActor::selfDragCb(vtkObject *, unsigned long, void *data) { pos = pts->GetPoint(2); MapScreenPointToWorld(pos[0], pos[1], this->Renderer, result); controlP3->SetWorldPosition(result); +} + +void AngleAnnotationActor::ForceDelete() +{ + controlP1->SetcontrolledActor(nullptr); + controlP2->SetcontrolledActor(nullptr); + controlP3->SetcontrolledActor(nullptr); + this->SetRenderer(nullptr); + Delete(); } \ No newline at end of file diff --git a/src/src/Rendering/Measure/AngleAnnotationActor.h b/src/src/Rendering/Measure/AngleAnnotationActor.h index 8a5b647..a62dbf4 100644 --- a/src/src/Rendering/Measure/AngleAnnotationActor.h +++ b/src/src/Rendering/Measure/AngleAnnotationActor.h @@ -53,10 +53,7 @@ vtkTypeMacro(AngleAnnotationActor, DraggableActor); NextMeasureMacro(AngleAnnotationActor); - void ForceDelete() override { - this->SetRenderer(nullptr); - DraggableActor::Delete(); - } + void ForceDelete() override; protected: AngleAnnotationActor(); diff --git a/src/src/Rendering/Measure/ArrowAnnotationActor.cpp b/src/src/Rendering/Measure/ArrowAnnotationActor.cpp index dc73654..3f8d6af 100644 --- a/src/src/Rendering/Measure/ArrowAnnotationActor.cpp +++ b/src/src/Rendering/Measure/ArrowAnnotationActor.cpp @@ -21,7 +21,9 @@ ArrowAnnotationActor::ArrowAnnotationActor() shadow2D->GetProperty()->SetLineWidth(5.0); arrowRenderPoints->SetNumberOfPoints(2); + controlP1->SetcontrolledActor(nullptr); controlP1->Delete(); + controlP2->SetcontrolledActor(nullptr); controlP2->Delete(); controlP1 = ControlPointRActor::New(); controlP2 = ControlPointRActor::New(); diff --git a/src/src/Rendering/Measure/EllipseAnnotationActor.cpp b/src/src/Rendering/Measure/EllipseAnnotationActor.cpp index 66efba4..7428cb1 100644 --- a/src/src/Rendering/Measure/EllipseAnnotationActor.cpp +++ b/src/src/Rendering/Measure/EllipseAnnotationActor.cpp @@ -293,7 +293,7 @@ void EllipseAnnotationActor::drawCircle(double *p1, double *p2) { } double angle = 0; int id = 0; - while (angle <= 2.0 * vtkMath::Pi() + (2.0 * vtkMath::Pi() / (GRANULARITY * 1.0))) { + while (id<=GRANULARITY) { double p[3]={0}; p[0] = p1[0]; p[1] = p1[1]; @@ -656,6 +656,16 @@ bool EllipseAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *ir return false; } +void EllipseAnnotationActor::ForceDelete() +{ + controlP_lt->SetcontrolledActor(nullptr); + controlP_rt->SetcontrolledActor(nullptr); + controlP_lb->SetcontrolledActor(nullptr); + controlP_rb->SetcontrolledActor(nullptr); + SetRenderer(nullptr); + Delete(); +} + void EllipseAnnotationActor::Transform(float x, float y) { DraggableActor::Transform(x, y); this->controlPointsTransform(x, y); diff --git a/src/src/Rendering/Measure/EllipseAnnotationActor.h b/src/src/Rendering/Measure/EllipseAnnotationActor.h index 3586e69..a8dcab3 100644 --- a/src/src/Rendering/Measure/EllipseAnnotationActor.h +++ b/src/src/Rendering/Measure/EllipseAnnotationActor.h @@ -40,6 +40,8 @@ public: bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override; + void ForceDelete() override; + NextMeasureMacro(EllipseAnnotationActor); protected: EllipseAnnotationActor(); diff --git a/src/src/Rendering/Measure/LineAnnotationActor.cpp b/src/src/Rendering/Measure/LineAnnotationActor.cpp index 634158f..9956a2d 100644 --- a/src/src/Rendering/Measure/LineAnnotationActor.cpp +++ b/src/src/Rendering/Measure/LineAnnotationActor.cpp @@ -12,7 +12,8 @@ vtkStandardNewMacro(LineAnnotationActor) LineAnnotationActor::LineAnnotationActor() - : DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New()) { + : DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New()) +{ BaseDataPoints->SetNumberOfPoints(2); BaseDataPoints->SetPoint(0, 0, 0, 0); BaseDataPoints->SetPoint(1, 512, 512, 0); @@ -31,7 +32,6 @@ LineAnnotationActor::~LineAnnotationActor() { controlP1 = nullptr; controlP2->Delete(); controlP2 = nullptr; - } void LineAnnotationActor::SetWorldPosition1(double x, double y, double z) { @@ -120,3 +120,11 @@ bool LineAnnotationActor::onMeasureLeftButtonDown(vtkRenderWindowInteractor *ire bool LineAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *iren) { return false; } + +void LineAnnotationActor::ForceDelete() +{ + controlP1->SetcontrolledActor(nullptr); + controlP2->SetcontrolledActor(nullptr); + SetRenderer(nullptr); + Delete(); +} diff --git a/src/src/Rendering/Measure/LineAnnotationActor.h b/src/src/Rendering/Measure/LineAnnotationActor.h index 980e11d..52c4770 100644 --- a/src/src/Rendering/Measure/LineAnnotationActor.h +++ b/src/src/Rendering/Measure/LineAnnotationActor.h @@ -42,10 +42,7 @@ public: NextMeasureMacro(LineAnnotationActor); - void ForceDelete() override { - this->SetRenderer(nullptr); - DraggableActor::Delete(); - } + void ForceDelete() override; protected: LineAnnotationActor(); diff --git a/src/src/Rendering/Measure/OpenPolyAnnotationActor.h b/src/src/Rendering/Measure/OpenPolyAnnotationActor.h index a960cab..b2ab578 100644 --- a/src/src/Rendering/Measure/OpenPolyAnnotationActor.h +++ b/src/src/Rendering/Measure/OpenPolyAnnotationActor.h @@ -47,7 +47,6 @@ public: void ForceDelete() override { this->SetRenderer(nullptr); - printf("OpenPolyAnnotationActor delete \r\n"); Delete(); } diff --git a/src/src/Rendering/Measure/RoundAnnotationActor.cpp b/src/src/Rendering/Measure/RoundAnnotationActor.cpp index 1844a85..b3cf534 100644 --- a/src/src/Rendering/Measure/RoundAnnotationActor.cpp +++ b/src/src/Rendering/Measure/RoundAnnotationActor.cpp @@ -76,7 +76,18 @@ void RoundAnnotationActor::BuildShape() { } } -RoundAnnotationActor::RoundAnnotationActor() { +void RoundAnnotationActor::ForceDelete() +{ + controlP_lt->SetcontrolledActor(nullptr); + controlP_rt->SetcontrolledActor(nullptr); + controlP_lb->SetcontrolledActor(nullptr); + controlP_rb->SetcontrolledActor(nullptr); + SetRenderer(nullptr); + Delete(); +} + +RoundAnnotationActor::RoundAnnotationActor() +{ controlP_rt = ControlPointActor::New(); controlP_lb = ControlPointActor::New(); controlP_rb = ControlPointActor::New(); @@ -279,7 +290,7 @@ void RoundAnnotationActor::drawCircle(double *p1, double *p2) { double angle = 0; int id = 0; - while (angle <= 2.0 * vtkMath::Pi() + (2.0 * vtkMath::Pi() / (GRANULARITY * 1.0))) { + while (id<=GRANULARITY) { double p[3]={0}; p[0] = p1[0]; p[1] = p1[1]; diff --git a/src/src/Rendering/Measure/RoundAnnotationActor.h b/src/src/Rendering/Measure/RoundAnnotationActor.h index 90b692b..078c422 100644 --- a/src/src/Rendering/Measure/RoundAnnotationActor.h +++ b/src/src/Rendering/Measure/RoundAnnotationActor.h @@ -38,6 +38,8 @@ public: bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override; NextMeasureMacro(RoundAnnotationActor); + + void ForceDelete() override; protected: RoundAnnotationActor(); diff --git a/src/src/Rendering/Measure/TextAnnotationActor.cpp b/src/src/Rendering/Measure/TextAnnotationActor.cpp index ec2cd45..3e6d1f8 100644 --- a/src/src/Rendering/Measure/TextAnnotationActor.cpp +++ b/src/src/Rendering/Measure/TextAnnotationActor.cpp @@ -69,7 +69,14 @@ void TextAnnotationActor::ResetTextProp() { mTextProperty->SetBackgroundOpacity(0.0); } -TextAnnotationActor::TextAnnotationActor() { +void TextAnnotationActor::ForceDelete() +{ + SetRenderer(nullptr); + Delete(); +} + +TextAnnotationActor::TextAnnotationActor() +{ BaseDataPoints->SetNumberOfPoints(2); BaseDataPoints->SetPoint(0, 0, 0, 0); BaseDataPoints->SetPoint(1, 512, 512, 0); @@ -86,7 +93,6 @@ TextAnnotationActor::TextAnnotationActor() { ResetTextProp(); } - TextAnnotationActor::~TextAnnotationActor() { mTextProperty = nullptr; text->Delete(); diff --git a/src/src/Rendering/Measure/TextAnnotationActor.h b/src/src/Rendering/Measure/TextAnnotationActor.h index abf9f3d..8c5f385 100644 --- a/src/src/Rendering/Measure/TextAnnotationActor.h +++ b/src/src/Rendering/Measure/TextAnnotationActor.h @@ -59,6 +59,8 @@ vtkTypeMacro(TextAnnotationActor, DraggableActor); bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override; NextMeasureMacro(TextAnnotationActor); + + void ForceDelete() override; protected: TextAnnotationActor();