Commit 9d9c9505 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

BUG: Fixed the memory leaks reported, removed the set view extents function.

parent 734016af
......@@ -56,7 +56,7 @@ class vtkChartXYPrivate
};
//-----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkChartXY, "1.8");
vtkCxxRevisionMacro(vtkChartXY, "1.9");
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkChartXY);
......@@ -172,11 +172,9 @@ bool vtkChartXY::Paint(vtkContext2D *painter)
transform->Scale(1.0 / xScale, 1.0 / yScale);
transform->Translate(-this->XAxis->GetMinimum(), -this->YAxis->GetMinimum());
// Pop the matrix and use the transform we just calculated
// Push the matrix and use the transform we just calculated
painter->GetDevice()->PushMatrix();
//painter->SetTransform(transform);
painter->GetDevice()->SetMatrix(transform->GetMatrix());
transform->GetMatrix()->Print(cout);
// Now iterate through the plots
size_t n = this->ChartPrivate->plots.size();
......@@ -196,16 +194,16 @@ bool vtkChartXY::Paint(vtkContext2D *painter)
this->XAxis->Paint(painter);
this->YAxis->Paint(painter);
transform->Delete();
transform = NULL;
return true;
}
//-----------------------------------------------------------------------------
void vtkChartXY::RenderPlots(vtkContext2D *painter)
void vtkChartXY::RenderPlots(vtkContext2D *)
{
// This function ensures that the correct view transforms are in place for
// the plot functions before calling paint on each one.
float x[] = { -0.1, -0.1, 10.0, 2.1 };
painter->GetDevice()->SetViewExtents(&x[0]);
}
//-----------------------------------------------------------------------------
......
......@@ -92,11 +92,6 @@ public:
// Get the width of the device in pixels.
virtual int GetHeight() { return this->Geometry[1]; }
// Description:
// Supply a float array of length 4 with x1, y1, x2, y2 specifying the extents.
// of the display
virtual void SetViewExtents(float *x) = 0;
// Description:
// Set the model view matrix for the display
virtual void SetMatrix(vtkMatrix3x3 *m) = 0;
......
......@@ -45,11 +45,19 @@ public:
if (this->Target)
{
vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(caller);
vtkRenderWindowInteractor *interactor =
vtkRenderWindowInteractor::SafeDownCast(style->GetInteractor());
vtkRenderWindowInteractor *interactor;
if (style)
{
interactor = vtkRenderWindowInteractor::SafeDownCast(style->GetInteractor());
}
int x = interactor->GetEventPosition()[0];
int y = interactor->GetEventPosition()[1];
int x = -1;
int y = -1;
if (interactor)
{
x = interactor->GetEventPosition()[0];
y = interactor->GetEventPosition()[1];
}
switch (eventId)
{
......@@ -100,7 +108,7 @@ public:
};
//-----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkContextScene, "1.5");
vtkCxxRevisionMacro(vtkContextScene, "1.6");
vtkStandardNewMacro(vtkContextScene);
vtkCxxSetObjectMacro(vtkContextScene, AnnotationLink, vtkAnnotationLink);
vtkCxxSetObjectMacro(vtkContextScene, Window, vtkRenderWindow);
......@@ -123,6 +131,7 @@ vtkContextScene::~vtkContextScene()
{
this->Observer->Delete();
this->Observer = NULL;
this->SetWindow(NULL);
size_t size = this->Storage->items.size();
for (size_t i = 0; i < size; ++i)
{
......@@ -175,7 +184,7 @@ vtkContextItem * vtkContextScene::GetItem(int index)
//-----------------------------------------------------------------------------
void vtkContextScene::SetInteractorStyle(vtkInteractorStyle *interactor)
{
cout << "Interactor style " << interactor << " " << interactor->GetClassName() << endl;
//cout << "Interactor style " << interactor << " " << interactor->GetClassName() << endl;
interactor->AddObserver(vtkCommand::SelectionChangedEvent, this->Observer);
interactor->AddObserver(vtkCommand::AnyEvent, this->Observer);
}
......
......@@ -27,7 +27,7 @@
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkContextView, "1.1");
vtkCxxRevisionMacro(vtkContextView, "1.2");
vtkStandardNewMacro(vtkContextView);
vtkCxxSetObjectMacro(vtkContextView, Context, vtkContext2D);
......@@ -39,10 +39,13 @@ vtkContextView::vtkContextView()
this->Context = vtkContext2D::New();
vtkOpenGLContextDevice2D *pd = vtkOpenGLContextDevice2D::New();
this->Context->Begin(pd);
pd->Delete();
vtkContextActor *actor = vtkContextActor::New();
this->Renderer->AddActor(actor);
this->Scene = actor->GetScene();
actor->Delete();
this->Scene = actor->GetScene(); // We keep a pointer to this for convenience
this->Scene->Register(this);
// Should not need to do this...
this->Scene->SetWindow(this->RenderWindow);
......@@ -61,13 +64,13 @@ vtkContextView::~vtkContextView()
{
if (this->Context)
{
this->Context->GetDevice()->Delete();
this->Context->Delete();
this->Context = NULL;
}
// The scene is owned by the context actor
if (this->Scene)
{
this->Scene->SetWindow(NULL);
this->Scene->Delete();
this->Scene = NULL;
}
......
......@@ -48,7 +48,7 @@ class vtkOpenGLContextDevice2D::Private
public:
Private()
{
this->texture = 0;
this->texture = NULL;
this->lightingEnabled = GL_TRUE;
this->depthTestEnabled = GL_TRUE;
}
......@@ -57,6 +57,7 @@ public:
if (this->texture)
{
this->texture->Delete();
this->texture = NULL;
}
}
......@@ -67,7 +68,7 @@ public:
};
//-----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkOpenGLContextDevice2D, "1.9");
vtkCxxRevisionMacro(vtkOpenGLContextDevice2D, "1.10");
vtkStandardNewMacro(vtkOpenGLContextDevice2D);
//-----------------------------------------------------------------------------
......@@ -303,15 +304,6 @@ void vtkOpenGLContextDevice2D::SetLineWidth(float width)
glLineWidth(width);
}
//-----------------------------------------------------------------------------
void vtkOpenGLContextDevice2D::SetViewExtents(float *x)
{
glLoadIdentity();
glOrtho( x[0], x[2],
x[1], x[3],
-1, 0);
}
//-----------------------------------------------------------------------------
void vtkOpenGLContextDevice2D::SetMatrix(vtkMatrix3x3 *m)
{
......
......@@ -87,11 +87,6 @@ public:
// Set the line width for glyphs/sprites.
virtual void SetLineWidth(float width);
// Description:
// Supply a float array of length 4 with x1, y1, x2, y2 specifying the extents
// of the display
virtual void SetViewExtents(float *x);
// Description:
// Set the model view matrix for the display
virtual void SetMatrix(vtkMatrix3x3 *m);
......
......@@ -30,7 +30,7 @@
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkPlotLine, "1.2");
vtkCxxRevisionMacro(vtkPlotLine, "1.3");
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotLine);
......@@ -45,7 +45,12 @@ vtkPlotLine::vtkPlotLine()
//-----------------------------------------------------------------------------
vtkPlotLine::~vtkPlotLine()
{
delete this->Label;
this->SetLabel(NULL);
if (this->Points)
{
this->Points->Delete();
this->Points = NULL;
}
}
//-----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment