Commit 508d36d7 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

ENH: Use SP ivars to simplify object management.

parent 5e4acfdf
...@@ -93,15 +93,13 @@ vtkChartXY::vtkChartXY() ...@@ -93,15 +93,13 @@ vtkChartXY::vtkChartXY()
this->HiddenAxisBorder = 20; this->HiddenAxisBorder = 20;
// The grid is drawn first. // The grid is drawn first.
this->Grid = vtkPlotGrid::New(); vtkPlotGrid *grid1 = vtkPlotGrid::New();
this->AddItem(this->Grid); this->AddItem(grid1);
this->Grid->Delete(); grid1->Delete();
vtkPlotGrid *grid1 = this->Grid;
// The second grid for the far side/top axis // The second grid for the far side/top axis
this->Grid = vtkPlotGrid::New(); vtkPlotGrid *grid2 = vtkPlotGrid::New();
this->AddItem(this->Grid); this->AddItem(grid2);
vtkPlotGrid *grid2 = this->Grid;
// The plots are drawn on top of the grid, in a clipped, transformed area. // The plots are drawn on top of the grid, in a clipped, transformed area.
this->AddItem(this->ChartPrivate->Clip); this->AddItem(this->ChartPrivate->Clip);
...@@ -135,7 +133,7 @@ vtkChartXY::vtkChartXY() ...@@ -135,7 +133,7 @@ vtkChartXY::vtkChartXY()
grid2->SetYAxis(this->ChartPrivate->axes[vtkAxis::RIGHT]); grid2->SetYAxis(this->ChartPrivate->axes[vtkAxis::RIGHT]);
// Then the legend is drawn // Then the legend is drawn
this->Legend = vtkChartLegend::New(); this->Legend = vtkSmartPointer<vtkChartLegend>::New();
this->Legend->SetChart(this); this->Legend->SetChart(this);
this->Legend->SetVisible(false); this->Legend->SetVisible(false);
this->AddItem(this->Legend); this->AddItem(this->Legend);
...@@ -149,10 +147,9 @@ vtkChartXY::vtkChartXY() ...@@ -149,10 +147,9 @@ vtkChartXY::vtkChartXY()
this->DrawAxesAtOrigin = false; this->DrawAxesAtOrigin = false;
this->BarWidthFraction = 0.8f; this->BarWidthFraction = 0.8f;
this->Tooltip = vtkTooltipItem::New(); this->Tooltip = vtkSmartPointer<vtkTooltipItem>::New();
this->Tooltip->SetVisible(false); this->Tooltip->SetVisible(false);
this->AddItem(this->Tooltip); this->AddItem(this->Tooltip);
this->Tooltip->Delete();
this->LayoutChanged = true; this->LayoutChanged = true;
} }
...@@ -169,11 +166,6 @@ vtkChartXY::~vtkChartXY() ...@@ -169,11 +166,6 @@ vtkChartXY::~vtkChartXY()
} }
delete this->ChartPrivate; delete this->ChartPrivate;
this->ChartPrivate = 0; this->ChartPrivate = 0;
this->Grid->Delete();
this->Grid = 0;
this->Legend->Delete();
this->Legend = 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define __vtkChartXY_h #define __vtkChartXY_h
#include "vtkChart.h" #include "vtkChart.h"
#include "vtkSmartPointer.h" // For SP ivars
class vtkPlot; class vtkPlot;
class vtkAxis; class vtkAxis;
...@@ -204,17 +205,13 @@ protected: ...@@ -204,17 +205,13 @@ protected:
// legend, depends upon its alignment. // legend, depends upon its alignment.
virtual void SetLegendPosition(const vtkRectf& rect); virtual void SetLegendPosition(const vtkRectf& rect);
// Description:
// The grid for the chart.
vtkPlotGrid *Grid;
// Description: // Description:
// The legend for the chart. // The legend for the chart.
vtkChartLegend *Legend; vtkSmartPointer<vtkChartLegend> Legend;
// Description: // Description:
// The tooltip item for the chart - can be used to display extra information. // The tooltip item for the chart - can be used to display extra information.
vtkTooltipItem *Tooltip; vtkSmartPointer<vtkTooltipItem> Tooltip;
// Description: // Description:
// Does the plot area transform need to be recalculated? // Does the plot area transform need to be recalculated?
......
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