Commit 70a5e984 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

ENH: Use vtkNew instead of vtkSmartPointer.

Change-Id: Ib156c5d50f78680a1fb0473c807697ea009f2e88
parent a89a71d9
......@@ -15,11 +15,12 @@
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkSmartPointer.h"
#include "vtkNew.h"
#include "vtkChartXY.h"
#include "vtkPlotPoints.h"
#include "vtkTable.h"
#include "vtkFloatArray.h"
#include "vtkStringArray.h"
#include "vtkContextView.h"
#include "vtkContextScene.h"
#include "vtkRenderWindowInteractor.h"
......@@ -28,28 +29,28 @@
int TestScatterPlot(int , char * [])
{
// Set up a 2D scene, add an XY chart to it
vtkSmartPointer<vtkContextView> view =
vtkSmartPointer<vtkContextView>::New();
vtkNew<vtkContextView> view;
view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
view->GetRenderWindow()->SetSize(400, 300);
vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
view->GetScene()->AddItem(chart);
vtkNew<vtkChartXY> chart;
view->GetScene()->AddItem(chart.GetPointer());
chart->SetShowLegend(true);
// Create a table with some points in it...
vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
vtkNew<vtkTable> table;
vtkNew<vtkFloatArray> arrX;
arrX->SetName("X Axis");
table->AddColumn(arrX);
vtkSmartPointer<vtkFloatArray> arrC = vtkSmartPointer<vtkFloatArray>::New();
table->AddColumn(arrX.GetPointer());
vtkNew<vtkFloatArray> arrC;
arrC->SetName("Cosine");
table->AddColumn(arrC);
vtkSmartPointer<vtkFloatArray> arrS = vtkSmartPointer<vtkFloatArray>::New();
table->AddColumn(arrC.GetPointer());
vtkNew<vtkFloatArray> arrS;
arrS->SetName("Sine");
table->AddColumn(arrS);
vtkSmartPointer<vtkFloatArray> arrT = vtkSmartPointer<vtkFloatArray>::New();
table->AddColumn(arrS.GetPointer());
vtkNew<vtkFloatArray> arrT;
arrT->SetName("Tan");
table->AddColumn(arrT);
table->AddColumn(arrT.GetPointer());
// Test charting with a few more points...
int numPoints = 40;
float inc = 7.5 / (numPoints-1);
......@@ -64,17 +65,17 @@ int TestScatterPlot(int , char * [])
// Add multiple line plots, setting the colors etc
vtkPlot *points = chart->AddPlot(vtkChart::POINTS);
points->SetInput(table, 0, 1);
points->SetInput(table.GetPointer(), 0, 1);
points->SetColor(0, 0, 0, 255);
points->SetWidth(1.0);
vtkPlotPoints::SafeDownCast(points)->SetMarkerStyle(vtkPlotPoints::CROSS);
points = chart->AddPlot(vtkChart::POINTS);
points->SetInput(table, 0, 2);
points->SetInput(table.GetPointer(), 0, 2);
points->SetColor(0, 0, 0, 255);
points->SetWidth(1.0);
vtkPlotPoints::SafeDownCast(points)->SetMarkerStyle(vtkPlotPoints::PLUS);
points = chart->AddPlot(vtkChart::POINTS);
points->SetInput(table, 0, 3);
points->SetInput(table.GetPointer(), 0, 3);
points->SetColor(0, 0, 255, 255);
points->SetWidth(4.0);
......
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