Commit a855cab0 authored by Kitware Robot's avatar Kitware Robot Committed by Ken Martin
Browse files

Replace many NULL and 0 occurances with nullptr

This topic is the result of running clang-tidy to
modernize our usage of NULL and 0 to nullptr. It also
includes some manual and semi manual changes where
clang-tidy would not be expected to work (such as in
comments, or classes not compiled on this build)

There are definitely many comments and occurances that
this topic misses that we will need to fix over time.
parent 113ef091
......@@ -56,7 +56,7 @@ int TestAxes(int , char * [])
axis->SetPoint1(vtkVector2f(i * 69 + 30, 10));
axis->SetPoint2(vtkVector2f(i * 69 + 30, 290));
axis->SetPosition((i % 2) ? vtkAxis::LEFT : vtkAxis::RIGHT);
axis->SetRange(NULL); // check that NULL pointers don't cause trouble
axis->SetRange(nullptr); // check that null pointers don't cause trouble
axis->SetRange(-1, 50);
view->GetScene()->AddItem(axis);
......@@ -169,7 +169,7 @@ int TestAxes(int , char * [])
logAxis->SetScene(view->GetScene());
logAxis->SetUnscaledRange(plainRange);
logAxis->LogScaleOn();
logAxis->GetUnscaledRange(NULL); // Insure NULL pointers are ignored.
logAxis->GetUnscaledRange(nullptr); // Insure null pointers are ignored.
logAxis->GetUnscaledRange(logRange);
if ((logRange[0] != plainRange[0]) || (logRange[1] != plainRange[1]))
{
......
......@@ -553,7 +553,7 @@ public:
* must be of the same length. Returns true on success, false on failure.
*/
virtual bool SetCustomTickPositions(vtkDoubleArray* positions,
vtkStringArray* labels = 0);
vtkStringArray* labels = nullptr);
/**
* Request the space the axes require to be drawn. This is returned as a
......
......@@ -31,8 +31,8 @@ vtkCategoryLegend::vtkCategoryLegend()
this->SetHorizontalAlignment(vtkChartLegend::RIGHT);
this->SetVerticalAlignment(vtkChartLegend::BOTTOM);
this->ScalarsToColors = NULL;
this->Values = NULL;
this->ScalarsToColors = nullptr;
this->Values = nullptr;
this->TitleProperties->SetColor(this->LabelProperties->GetColor());
this->TitleProperties->SetFontSize(this->LabelProperties->GetFontSize());
......@@ -54,7 +54,7 @@ vtkCategoryLegend::~vtkCategoryLegend()
//-----------------------------------------------------------------------------
bool vtkCategoryLegend::Paint(vtkContext2D* painter)
{
if (!this->Visible || this->ScalarsToColors == NULL || this->Values == NULL)
if (!this->Visible || this->ScalarsToColors == nullptr || this->Values == nullptr)
{
return true;
}
......
......@@ -60,7 +60,7 @@ vtkChart::vtkChart()
this->TitleProperties->SetColor(0.0, 0.0, 0.0);
this->TitleProperties->SetFontSize(12);
this->TitleProperties->SetFontFamilyToArial();
this->AnnotationLink = NULL;
this->AnnotationLink = nullptr;
this->LayoutStrategy = vtkChart::FILL_SCENE;
this->RenderEmpty = false;
this->BackgroundBrush = vtkSmartPointer<vtkBrush>::New();
......@@ -89,7 +89,7 @@ vtkChart::~vtkChart()
//-----------------------------------------------------------------------------
vtkPlot * vtkChart::AddPlot(int)
{
return NULL;
return nullptr;
}
//-----------------------------------------------------------------------------
......@@ -129,7 +129,7 @@ void vtkChart::ClearPlots()
//-----------------------------------------------------------------------------
vtkPlot* vtkChart::GetPlot(vtkIdType)
{
return NULL;
return nullptr;
}
//-----------------------------------------------------------------------------
......@@ -141,7 +141,7 @@ vtkIdType vtkChart::GetNumberOfPlots()
//-----------------------------------------------------------------------------
vtkAxis* vtkChart::GetAxis(int)
{
return NULL;
return nullptr;
}
//-----------------------------------------------------------------------------
......@@ -190,7 +190,7 @@ bool vtkChart::GetShowLegend()
vtkChartLegend * vtkChart::GetLegend()
{
return 0;
return nullptr;
}
//-----------------------------------------------------------------------------
......@@ -403,7 +403,7 @@ int vtkChart::GetClickActionToButton(int action)
//-----------------------------------------------------------------------------
void vtkChart::SetBackgroundBrush(vtkBrush *brush)
{
if(brush == NULL)
if(brush == nullptr)
{
// set to transparent white if brush is null
this->BackgroundBrush->SetColorF(1, 1, 1, 0);
......
......@@ -218,7 +218,7 @@ public:
//@}
/**
* Get the legend for the chart, if available. Can return NULL if there is no
* Get the legend for the chart, if available. Can return null if there is no
* legend.
*/
virtual vtkChartLegend * GetLegend();
......
......@@ -95,7 +95,7 @@ vtkChartBox::vtkChartBox()
//-----------------------------------------------------------------------------
vtkChartBox::~vtkChartBox()
{
this->Storage->Plot->SetSelection(NULL);
this->Storage->Plot->SetSelection(nullptr);
delete this->Storage;
this->Selection->Delete();
this->VisibleColumns->Delete();
......@@ -165,7 +165,7 @@ bool vtkChartBox::Paint(vtkContext2D *painter)
this->UpdateGeometry(painter);
// Handle selections
vtkIdTypeArray *idArray = 0;
vtkIdTypeArray *idArray = nullptr;
if (this->AnnotationLink)
{
vtkSelection *selection = this->AnnotationLink->GetCurrentSelection();
......
......@@ -117,7 +117,7 @@ vtkPlot* vtkChartHistogram2D::GetPlot(vtkIdType index)
return this->Histogram;
}
return 0;
return nullptr;
}
//-----------------------------------------------------------------------------
......
......@@ -82,8 +82,8 @@ vtkChartLegend::vtkChartLegend()
vtkChartLegend::~vtkChartLegend()
{
delete this->Storage;
this->Storage = NULL;
this->Point = NULL;
this->Storage = nullptr;
this->Point = nullptr;
}
//-----------------------------------------------------------------------------
......
......@@ -245,7 +245,7 @@ vtkChart* vtkChartMatrix::GetChart(const vtkVector2i &position)
if (position.GetX() < this->Size.GetX() && position.GetY() < this->Size.GetY())
{
size_t index = position.GetY() * this->Size.GetX() + position.GetX();
if (this->Private->Charts[index] == NULL)
if (this->Private->Charts[index] == nullptr)
{
vtkNew<vtkChartXY> chart;
this->Private->Charts[index] = chart.GetPointer();
......@@ -256,7 +256,7 @@ vtkChart* vtkChartMatrix::GetChart(const vtkVector2i &position)
}
else
{
return NULL;
return nullptr;
}
}
......
......@@ -122,7 +122,7 @@ public:
virtual bool SetChart(const vtkVector2i& position, vtkChart* chart);
/**
* Get the specified chart element, if the element does not exist NULL will be
* Get the specified chart element, if the element does not exist nullptr will be
* returned. If the chart element has not yet been allocated it will be at
* this point.
*/
......
......@@ -88,7 +88,7 @@ vtkChartParallelCoordinates::vtkChartParallelCoordinates()
//-----------------------------------------------------------------------------
vtkChartParallelCoordinates::~vtkChartParallelCoordinates()
{
this->Storage->Plot->SetSelection(NULL);
this->Storage->Plot->SetSelection(nullptr);
delete this->Storage;
this->Selection->Delete();
}
......@@ -172,16 +172,16 @@ bool vtkChartParallelCoordinates::Paint(vtkContext2D *painter)
this->UpdateGeometry();
// Handle selections
vtkIdTypeArray *idArray = 0;
vtkIdTypeArray *idArray = nullptr;
if (this->AnnotationLink)
{
vtkSelection *selection = this->AnnotationLink->GetCurrentSelection();
if (this->AnnotationLink->GetMTime() > this->Storage->Plot->GetMTime())
{
vtkSelectionNode *node = selection->GetNumberOfNodes() > 0?
selection->GetNode(0) : NULL;
selection->GetNode(0) : nullptr;
idArray = node? vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList())
: NULL;
: nullptr;
this->Storage->Plot->SetSelection(idArray);
}
}
......@@ -362,7 +362,7 @@ vtkAxis* vtkChartParallelCoordinates::GetAxis(int index)
}
else
{
return NULL;
return nullptr;
}
}
......@@ -507,11 +507,11 @@ bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mou
vtkAxis* leftAxis = this->Storage->CurrentAxis > 0 ?
this->Storage->Axes[this->Storage->CurrentAxis-1] :
NULL;
nullptr;
vtkAxis* rightAxis =
this->Storage->CurrentAxis < static_cast<int>(this->Storage->Axes.size())-1 ?
this->Storage->Axes[this->Storage->CurrentAxis+1] : NULL;
this->Storage->Axes[this->Storage->CurrentAxis+1] : nullptr;
if (leftAxis && axis->GetPoint1()[0] < leftAxis->GetPoint1()[0])
{
......
......@@ -159,7 +159,7 @@ vtkPlot* vtkChartPie::GetPlot(vtkIdType index)
return this->Private->Plot;
}
return 0;
return nullptr;
}
//-----------------------------------------------------------------------------
......
......@@ -81,7 +81,7 @@ public:
void SetShowLegend(bool visible) VTK_OVERRIDE;
/**
* Get the legend for the chart, if available. Can return NULL if there is no
* Get the legend for the chart, if available. Can return nullptr if there is no
* legend.
*/
vtkChartLegend * GetLegend() VTK_OVERRIDE;
......
......@@ -51,7 +51,7 @@ namespace vtkChartSelectionHelper
static void MakeSelection(vtkAnnotationLink *link, vtkIdTypeArray *selectionIds,
vtkPlot *plot)
{
assert(link != NULL && selectionIds != NULL);
assert(link != nullptr && selectionIds != nullptr);
if (plot)
{
......@@ -216,7 +216,7 @@ static void ToggleSelection(vtkIdTypeArray *selection, vtkIdTypeArray *oldSelect
/*
* Build a selection based on the supplied selectionMode using the new
* plotSelection and combining it with the oldSelection. If link is not NULL
* plotSelection and combining it with the oldSelection. If link is not nullptr
* then the resulting selection will be set on the link.
*/
static void BuildSelection(vtkAnnotationLink *link, int selectionMode,
......
......@@ -95,7 +95,7 @@ public:
return plot;
}
}
return 0;
return nullptr;
}
std::vector<vtkPlot*> plots; // Charts can contain multiple plots of data
......@@ -194,7 +194,7 @@ vtkChartXY::~vtkChartXY()
this->ChartPrivate->axes[i]->Delete();
}
delete this->ChartPrivate;
this->ChartPrivate = 0;
this->ChartPrivate = nullptr;
}
//-----------------------------------------------------------------------------
......@@ -217,9 +217,9 @@ void vtkChartXY::Update()
// Two major selection methods - row based or plot based.
if (this->SelectionMethod == vtkChart::SELECTION_ROWS)
{
vtkSelectionNode* node = selection->GetNumberOfNodes() > 0 ? selection->GetNode(0) : NULL;
vtkSelectionNode* node = selection->GetNumberOfNodes() > 0 ? selection->GetNode(0) : nullptr;
vtkIdTypeArray* idArray =
node ? vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()) : NULL;
node ? vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()) : nullptr;
std::vector<vtkPlot*>::iterator it = this->ChartPrivate->plots.begin();
for (; it != this->ChartPrivate->plots.end(); ++it)
{
......@@ -270,7 +270,7 @@ void vtkChartXY::Update()
for (; it != this->ChartPrivate->plots.end(); ++it)
{
vtkPlot* plot = *it;
vtkIdTypeArray* plotSelection = 0;
vtkIdTypeArray* plotSelection = nullptr;
bool ownPlotSelection = false;
bool isSelected =
std::find(selectedPlots.begin(), selectedPlots.end(), plot) != selectedPlots.end();
......@@ -537,8 +537,8 @@ void vtkChartXY::RecalculatePlotTransforms()
{
if (this->ChartPrivate->PlotCorners[i]->GetNumberOfItems())
{
vtkAxis* xAxis = 0;
vtkAxis* yAxis = 0;
vtkAxis* xAxis = nullptr;
vtkAxis* yAxis = nullptr;
// Get the appropriate axes, and recalculate the transform.
switch (i)
{
......@@ -772,7 +772,7 @@ void vtkChartXY::RecalculatePlotBounds()
for (int i = 0; i < 4; ++i)
{
vtkAxis* axis = this->ChartPrivate->axes[i];
double* range = 0;
double* range = nullptr;
switch (i)
{
case 0:
......@@ -1090,11 +1090,11 @@ void vtkChartXY::SetLegendPosition(const vtkRectf& rect)
//-----------------------------------------------------------------------------
vtkPlot* vtkChartXY::AddPlot(int type)
{
// Use a variable to return the object created (or NULL), this is necessary
// Use a variable to return the object created (or nullptr), this is necessary
// as the HP compiler is broken (thinks this function does not return) and
// the MS compiler generates a warning about unreachable code if a redundant
// return is added at the end.
vtkPlot* plot = NULL;
vtkPlot* plot = nullptr;
vtkColor3ub color = this->ChartPrivate->Colors->GetColorRepeating(
static_cast<int>(this->ChartPrivate->plots.size()));
switch (type)
......@@ -1154,7 +1154,7 @@ vtkPlot* vtkChartXY::AddPlot(int type)
}
default:
plot = NULL;
plot = nullptr;
}
if (plot)
{
......@@ -1167,7 +1167,7 @@ vtkPlot* vtkChartXY::AddPlot(int type)
//-----------------------------------------------------------------------------
vtkIdType vtkChartXY::AddPlot(vtkPlot* plot)
{
if (plot == NULL)
if (plot == nullptr)
{
return -1;
}
......@@ -1246,7 +1246,7 @@ vtkPlot* vtkChartXY::GetPlot(vtkIdType index)
}
else
{
return NULL;
return nullptr;
}
}
......@@ -1366,7 +1366,7 @@ vtkAxis* vtkChartXY::GetAxis(int axisIndex)
}
else
{
return NULL;
return nullptr;
}
}
......@@ -1402,7 +1402,7 @@ void vtkChartXY::SetSelectionMethod(int method)
std::vector<vtkPlot*>::iterator it = this->ChartPrivate->plots.begin();
for (; it != this->ChartPrivate->plots.end(); ++it)
{
(*it)->SetSelection(NULL);
(*it)->SetSelection(nullptr);
}
}
Superclass::SetSelectionMethod(method);
......@@ -1909,15 +1909,15 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse)
}
// Accumulate the selection in each plot.
vtkChartSelectionHelper::BuildSelection(0, vtkContextScene::SELECTION_ADDITION,
accumulateSelection.GetPointer(), plot->GetSelection(), 0);
vtkChartSelectionHelper::BuildSelection(nullptr, vtkContextScene::SELECTION_ADDITION,
accumulateSelection.GetPointer(), plot->GetSelection(), nullptr);
}
}
}
}
// Now add the accumulated selection to the old selection.
vtkChartSelectionHelper::BuildSelection(this->AnnotationLink, selectionMode,
accumulateSelection.GetPointer(), oldSelection.GetPointer(), 0);
accumulateSelection.GetPointer(), oldSelection.GetPointer(), nullptr);
}
else if (this->SelectionMethod == vtkChart::SELECTION_PLOTS)
{
......@@ -1964,7 +1964,7 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse)
this->AnnotationLink->Update();
vtkSelection* selection =
vtkSelection::SafeDownCast(this->AnnotationLink->GetOutputDataObject(2));
vtkSelectionNode* node = selection->GetNumberOfNodes() > 0 ? selection->GetNode(0) : NULL;
vtkSelectionNode* node = selection->GetNumberOfNodes() > 0 ? selection->GetNode(0) : nullptr;
if (node)
{
oldSelection->DeepCopy(vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()));
......@@ -2026,7 +2026,7 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse)
std::sort(ptrSelection, ptrSelection + accumulateSelection->GetNumberOfTuples());
// Now add the accumulated selection to the old selection
vtkChartSelectionHelper::BuildSelection(this->AnnotationLink, selectionMode,
accumulateSelection.GetPointer(), oldSelection.GetPointer(), 0);
accumulateSelection.GetPointer(), oldSelection.GetPointer(), nullptr);
}
this->InvokeEvent(vtkCommand::SelectionChangedEvent);
this->MouseBox.SetWidth(0.0);
......
......@@ -1594,7 +1594,7 @@ bool vtkChartXYZ::CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z,
//-----------------------------------------------------------------------------
vtkIdType vtkChartXYZ::AddPlot(vtkPlot3D * plot)
{
if (plot == NULL)
if (plot == nullptr)
{
return -1;
}
......
......@@ -46,7 +46,7 @@ vtkColorLegend::vtkColorLegend()
this->Callback->SetClientData(this);
this->Callback->SetCallback(vtkColorLegend::OnScalarsToColorsModified);
this->TransferFunction = NULL;
this->TransferFunction = nullptr;
this->Orientation = vtkColorLegend::VERTICAL;
......@@ -87,7 +87,7 @@ void vtkColorLegend::GetBounds(double bounds[4])
//-----------------------------------------------------------------------------
void vtkColorLegend::Update()
{
if (this->ImageData == 0 ||
if (this->ImageData == nullptr ||
this->ImageData->GetMTime() < this->GetMTime())
{
this->ComputeTexture();
......@@ -116,7 +116,7 @@ void vtkColorLegend::Update()
//-----------------------------------------------------------------------------
bool vtkColorLegend::Paint(vtkContext2D* painter)
{
if (this->TransferFunction == NULL)
if (this->TransferFunction == nullptr)
{
return true;
}
......@@ -264,7 +264,7 @@ vtkRectf vtkColorLegend::GetBoundingRect(vtkContext2D *painter)
//-----------------------------------------------------------------------------
void vtkColorLegend::ComputeTexture()
{
if (this->TransferFunction == NULL)
if (this->TransferFunction == nullptr)
{
return;
}
......
......@@ -37,7 +37,7 @@ vtkStandardNewMacro(vtkColorTransferControlPointsItem);
//-----------------------------------------------------------------------------
vtkColorTransferControlPointsItem::vtkColorTransferControlPointsItem()
{
this->ColorTransferFunction = 0;
this->ColorTransferFunction = nullptr;
this->ColorFill = false;
}
......@@ -48,7 +48,7 @@ vtkColorTransferControlPointsItem::~vtkColorTransferControlPointsItem()
{
this->ColorTransferFunction->RemoveObserver(this->Callback);
this->ColorTransferFunction->Delete();
this->ColorTransferFunction = 0;
this->ColorTransferFunction = nullptr;
}
}
......
......@@ -32,7 +32,7 @@ vtkStandardNewMacro(vtkColorTransferFunctionItem);
//-----------------------------------------------------------------------------
vtkColorTransferFunctionItem::vtkColorTransferFunctionItem()
{
this->ColorTransferFunction = 0;
this->ColorTransferFunction = nullptr;
}
//-----------------------------------------------------------------------------
......@@ -42,7 +42,7 @@ vtkColorTransferFunctionItem::~vtkColorTransferFunctionItem()
{
this->ColorTransferFunction->RemoveObserver(this->Callback);
this->ColorTransferFunction->Delete();
this->ColorTransferFunction = 0;
this->ColorTransferFunction = nullptr;
}
}
......@@ -90,7 +90,7 @@ void vtkColorTransferFunctionItem::SetColorTransferFunction(vtkColorTransferFunc
{
t->AddObserver(vtkCommand::ModifiedEvent, this->Callback);
}
this->ScalarsToColorsModified(t, vtkCommand::ModifiedEvent, 0);
this->ScalarsToColorsModified(t, vtkCommand::ModifiedEvent, nullptr);
}
//-----------------------------------------------------------------------------
......@@ -103,7 +103,7 @@ void vtkColorTransferFunctionItem::ComputeTexture()
{
return;
}
if (this->Texture == 0)
if (this->Texture == nullptr)
{
this->Texture = vtkImageData::New();
}
......
......@@ -40,9 +40,9 @@ vtkStandardNewMacro(vtkCompositeControlPointsItem);
vtkCompositeControlPointsItem::vtkCompositeControlPointsItem()
{
this->PointsFunction = ColorAndOpacityPointsFunction;
this->OpacityFunction = 0;
this->OpacityFunction = nullptr;
this->ColorFill = true;
this->OpacityPointHandle = NULL;
this->OpacityPointHandle = nullptr;
this->UseOpacityPointHandles = false;
}
......@@ -53,12 +53,12 @@ vtkCompositeControlPointsItem::~vtkCompositeControlPointsItem()
{
this->OpacityFunction->RemoveObserver(this->Callback);
this->OpacityFunction->Delete();
this->OpacityFunction = 0;
this->OpacityFunction = nullptr;
}
if (this->OpacityPointHandle)
{
this->OpacityPointHandle->Delete();
this->OpacityPointHandle = 0;
this->OpacityPointHandle = nullptr;
}
}
......
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