fix: fix a measure class memory leak bug
This commit is contained in:
@@ -15,8 +15,7 @@
|
|||||||
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);
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ 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:
|
||||||
@@ -39,7 +37,6 @@ protected:
|
|||||||
~ControlPointActor() override;
|
~ControlPointActor() override;
|
||||||
|
|
||||||
vtkPolyData *shadowData;
|
vtkPolyData *shadowData;
|
||||||
DraggableActor * controlledActor;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,11 @@
|
|||||||
vtkStandardNewMacro(DraggableActor)
|
vtkStandardNewMacro(DraggableActor)
|
||||||
|
|
||||||
DraggableActor::DraggableActor()
|
DraggableActor::DraggableActor()
|
||||||
: BaseDataPoints(vtkPoints::New()), renderPoints(vtkPoints::New()), tempStorePoints(nullptr),
|
: BaseDataPoints(vtkPoints::New()), renderPoints(vtkPoints::New()), tempStorePoints(nullptr),
|
||||||
renderData(vtkPolyData::New()), actor2D(vtkActor2D::New()), shadow2D(vtkActor2D::New()),
|
renderData(vtkPolyData::New()), actor2D(vtkActor2D::New()), shadow2D(vtkActor2D::New()),
|
||||||
senseArea(vtkActor2D::New()), text(nullptr), Renderer(nullptr), OnDrag(nullptr), OnDragEnd(nullptr) {
|
senseArea(vtkActor2D::New()), text(nullptr), Renderer(nullptr), OnDrag(nullptr), OnDragEnd(nullptr),
|
||||||
|
controlledActor(nullptr)
|
||||||
|
{
|
||||||
//if (Renderer) Renderer->RemoveViewProp(this);
|
//if (Renderer) Renderer->RemoveViewProp(this);
|
||||||
vtkNew<vtkPolyDataMapper2D> mapper;
|
vtkNew<vtkPolyDataMapper2D> mapper;
|
||||||
mapper->SetInputData(renderData);
|
mapper->SetInputData(renderData);
|
||||||
@@ -251,3 +253,5 @@ void DraggableActor::Show() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ public:
|
|||||||
void Show();
|
void Show();
|
||||||
|
|
||||||
vtkSetClampMacro(MapMode,PointMapMode,MapToSlice,MapToWorld);
|
vtkSetClampMacro(MapMode,PointMapMode,MapToSlice,MapToWorld);
|
||||||
|
|
||||||
|
vtkSetObjectMacro(controlledActor,DraggableActor);
|
||||||
|
vtkGetObjectMacro(controlledActor,DraggableActor);
|
||||||
protected:
|
protected:
|
||||||
DraggableActor();
|
DraggableActor();
|
||||||
|
|
||||||
@@ -168,6 +171,8 @@ private:
|
|||||||
DragCallBack OnDrag = nullptr;
|
DragCallBack OnDrag = nullptr;
|
||||||
|
|
||||||
DragCallBack OnDragEnd = nullptr;
|
DragCallBack OnDragEnd = nullptr;
|
||||||
|
|
||||||
|
DraggableActor * controlledActor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,10 @@
|
|||||||
|
|
||||||
#include "Rendering/Core/ControlPointActor.h"
|
#include "Rendering/Core/ControlPointActor.h"
|
||||||
|
|
||||||
|
|
||||||
vtkStandardNewMacro(AngleAnnotationActor)
|
vtkStandardNewMacro(AngleAnnotationActor)
|
||||||
|
|
||||||
AngleAnnotationActor::AngleAnnotationActor()
|
AngleAnnotationActor::AngleAnnotationActor()
|
||||||
: DraggableActor()
|
: DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New()), controlP3(ControlPointActor::New()), textProperty(nullptr), placedPointCount(0)
|
||||||
, controlP1(ControlPointActor::New())
|
|
||||||
, controlP2(ControlPointActor::New())
|
|
||||||
, controlP3(ControlPointActor::New())
|
|
||||||
, textProperty(nullptr)
|
|
||||||
, placedPointCount(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
text = vtkActor2D::New();
|
text = vtkActor2D::New();
|
||||||
@@ -227,3 +221,12 @@ void AngleAnnotationActor::selfDragCb(vtkObject *, unsigned long, void *data) {
|
|||||||
MapScreenPointToWorld(pos[0], pos[1], this->Renderer, result);
|
MapScreenPointToWorld(pos[0], pos[1], this->Renderer, result);
|
||||||
controlP3->SetWorldPosition(result);
|
controlP3->SetWorldPosition(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AngleAnnotationActor::ForceDelete()
|
||||||
|
{
|
||||||
|
controlP1->SetcontrolledActor(nullptr);
|
||||||
|
controlP2->SetcontrolledActor(nullptr);
|
||||||
|
controlP3->SetcontrolledActor(nullptr);
|
||||||
|
this->SetRenderer(nullptr);
|
||||||
|
Delete();
|
||||||
|
}
|
||||||
@@ -53,10 +53,7 @@ vtkTypeMacro(AngleAnnotationActor, DraggableActor);
|
|||||||
|
|
||||||
NextMeasureMacro(AngleAnnotationActor);
|
NextMeasureMacro(AngleAnnotationActor);
|
||||||
|
|
||||||
void ForceDelete() override {
|
void ForceDelete() override;
|
||||||
this->SetRenderer(nullptr);
|
|
||||||
DraggableActor::Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AngleAnnotationActor();
|
AngleAnnotationActor();
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ ArrowAnnotationActor::ArrowAnnotationActor()
|
|||||||
shadow2D->GetProperty()->SetLineWidth(5.0);
|
shadow2D->GetProperty()->SetLineWidth(5.0);
|
||||||
|
|
||||||
arrowRenderPoints->SetNumberOfPoints(2);
|
arrowRenderPoints->SetNumberOfPoints(2);
|
||||||
|
controlP1->SetcontrolledActor(nullptr);
|
||||||
controlP1->Delete();
|
controlP1->Delete();
|
||||||
|
controlP2->SetcontrolledActor(nullptr);
|
||||||
controlP2->Delete();
|
controlP2->Delete();
|
||||||
controlP1 = ControlPointRActor::New();
|
controlP1 = ControlPointRActor::New();
|
||||||
controlP2 = ControlPointRActor::New();
|
controlP2 = ControlPointRActor::New();
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ void EllipseAnnotationActor::drawCircle(double *p1, double *p2) {
|
|||||||
}
|
}
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
while (angle <= 2.0 * vtkMath::Pi() + (2.0 * vtkMath::Pi() / (GRANULARITY * 1.0))) {
|
while (id<=GRANULARITY) {
|
||||||
double p[3]={0};
|
double p[3]={0};
|
||||||
p[0] = p1[0];
|
p[0] = p1[0];
|
||||||
p[1] = p1[1];
|
p[1] = p1[1];
|
||||||
@@ -656,6 +656,16 @@ bool EllipseAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *ir
|
|||||||
return false;
|
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) {
|
void EllipseAnnotationActor::Transform(float x, float y) {
|
||||||
DraggableActor::Transform(x, y);
|
DraggableActor::Transform(x, y);
|
||||||
this->controlPointsTransform(x, y);
|
this->controlPointsTransform(x, y);
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
|
|
||||||
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
||||||
|
|
||||||
|
void ForceDelete() override;
|
||||||
|
|
||||||
NextMeasureMacro(EllipseAnnotationActor);
|
NextMeasureMacro(EllipseAnnotationActor);
|
||||||
protected:
|
protected:
|
||||||
EllipseAnnotationActor();
|
EllipseAnnotationActor();
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
vtkStandardNewMacro(LineAnnotationActor)
|
vtkStandardNewMacro(LineAnnotationActor)
|
||||||
|
|
||||||
LineAnnotationActor::LineAnnotationActor()
|
LineAnnotationActor::LineAnnotationActor()
|
||||||
: DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New()) {
|
: DraggableActor(), controlP1(ControlPointActor::New()), controlP2(ControlPointActor::New())
|
||||||
|
{
|
||||||
BaseDataPoints->SetNumberOfPoints(2);
|
BaseDataPoints->SetNumberOfPoints(2);
|
||||||
BaseDataPoints->SetPoint(0, 0, 0, 0);
|
BaseDataPoints->SetPoint(0, 0, 0, 0);
|
||||||
BaseDataPoints->SetPoint(1, 512, 512, 0);
|
BaseDataPoints->SetPoint(1, 512, 512, 0);
|
||||||
@@ -31,7 +32,6 @@ LineAnnotationActor::~LineAnnotationActor() {
|
|||||||
controlP1 = nullptr;
|
controlP1 = nullptr;
|
||||||
controlP2->Delete();
|
controlP2->Delete();
|
||||||
controlP2 = nullptr;
|
controlP2 = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineAnnotationActor::SetWorldPosition1(double x, double y, double z) {
|
void LineAnnotationActor::SetWorldPosition1(double x, double y, double z) {
|
||||||
@@ -120,3 +120,11 @@ bool LineAnnotationActor::onMeasureLeftButtonDown(vtkRenderWindowInteractor *ire
|
|||||||
bool LineAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *iren) {
|
bool LineAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *iren) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineAnnotationActor::ForceDelete()
|
||||||
|
{
|
||||||
|
controlP1->SetcontrolledActor(nullptr);
|
||||||
|
controlP2->SetcontrolledActor(nullptr);
|
||||||
|
SetRenderer(nullptr);
|
||||||
|
Delete();
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,10 +42,7 @@ public:
|
|||||||
|
|
||||||
NextMeasureMacro(LineAnnotationActor);
|
NextMeasureMacro(LineAnnotationActor);
|
||||||
|
|
||||||
void ForceDelete() override {
|
void ForceDelete() override;
|
||||||
this->SetRenderer(nullptr);
|
|
||||||
DraggableActor::Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LineAnnotationActor();
|
LineAnnotationActor();
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public:
|
|||||||
|
|
||||||
void ForceDelete() override {
|
void ForceDelete() override {
|
||||||
this->SetRenderer(nullptr);
|
this->SetRenderer(nullptr);
|
||||||
printf("OpenPolyAnnotationActor delete \r\n");
|
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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_rt = ControlPointActor::New();
|
||||||
controlP_lb = ControlPointActor::New();
|
controlP_lb = ControlPointActor::New();
|
||||||
controlP_rb = ControlPointActor::New();
|
controlP_rb = ControlPointActor::New();
|
||||||
@@ -279,7 +290,7 @@ void RoundAnnotationActor::drawCircle(double *p1, double *p2) {
|
|||||||
|
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
while (angle <= 2.0 * vtkMath::Pi() + (2.0 * vtkMath::Pi() / (GRANULARITY * 1.0))) {
|
while (id<=GRANULARITY) {
|
||||||
double p[3]={0};
|
double p[3]={0};
|
||||||
p[0] = p1[0];
|
p[0] = p1[0];
|
||||||
p[1] = p1[1];
|
p[1] = p1[1];
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
||||||
|
|
||||||
NextMeasureMacro(RoundAnnotationActor);
|
NextMeasureMacro(RoundAnnotationActor);
|
||||||
|
|
||||||
|
void ForceDelete() override;
|
||||||
protected:
|
protected:
|
||||||
RoundAnnotationActor();
|
RoundAnnotationActor();
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,14 @@ void TextAnnotationActor::ResetTextProp() {
|
|||||||
mTextProperty->SetBackgroundOpacity(0.0);
|
mTextProperty->SetBackgroundOpacity(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAnnotationActor::TextAnnotationActor() {
|
void TextAnnotationActor::ForceDelete()
|
||||||
|
{
|
||||||
|
SetRenderer(nullptr);
|
||||||
|
Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextAnnotationActor::TextAnnotationActor()
|
||||||
|
{
|
||||||
BaseDataPoints->SetNumberOfPoints(2);
|
BaseDataPoints->SetNumberOfPoints(2);
|
||||||
BaseDataPoints->SetPoint(0, 0, 0, 0);
|
BaseDataPoints->SetPoint(0, 0, 0, 0);
|
||||||
BaseDataPoints->SetPoint(1, 512, 512, 0);
|
BaseDataPoints->SetPoint(1, 512, 512, 0);
|
||||||
@@ -86,7 +93,6 @@ TextAnnotationActor::TextAnnotationActor() {
|
|||||||
ResetTextProp();
|
ResetTextProp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextAnnotationActor::~TextAnnotationActor() {
|
TextAnnotationActor::~TextAnnotationActor() {
|
||||||
mTextProperty = nullptr;
|
mTextProperty = nullptr;
|
||||||
text->Delete();
|
text->Delete();
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ vtkTypeMacro(TextAnnotationActor, DraggableActor);
|
|||||||
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
bool onMeasureLeftButtonUp(vtkRenderWindowInteractor *) override;
|
||||||
|
|
||||||
NextMeasureMacro(TextAnnotationActor);
|
NextMeasureMacro(TextAnnotationActor);
|
||||||
|
|
||||||
|
void ForceDelete() override;
|
||||||
protected:
|
protected:
|
||||||
TextAnnotationActor();
|
TextAnnotationActor();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user