Skip to content

Commit 711b121

Browse files
Merge pull request #3029 from SunBlack/modernize-use-nullptr_visualization
Use nullptr in module visualization
2 parents 9e92799 + 73db0e1 commit 711b121

14 files changed

+112
-112
lines changed

visualization/include/pcl/visualization/cloud_viewer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace pcl
136136
* \return connection object that allows to disconnect the callback function.
137137
*/
138138
inline boost::signals2::connection
139-
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = NULL)
139+
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = nullptr)
140140
{
141141
return (registerKeyboardCallback (boost::bind (callback, _1, cookie)));
142142
}
@@ -148,7 +148,7 @@ namespace pcl
148148
* \return connection object that allows to disconnect the callback function.
149149
*/
150150
template<typename T> inline boost::signals2::connection
151-
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = NULL)
151+
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = nullptr)
152152
{
153153
return (registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
154154
}
@@ -159,7 +159,7 @@ namespace pcl
159159
* \return connection object that allows to disconnect the callback function.
160160
*/
161161
inline boost::signals2::connection
162-
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = NULL)
162+
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = nullptr)
163163
{
164164
return (registerMouseCallback (boost::bind (callback, _1, cookie)));
165165
}
@@ -171,7 +171,7 @@ namespace pcl
171171
* \return connection object that allows to disconnect the callback function.
172172
*/
173173
template<typename T> inline boost::signals2::connection
174-
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = NULL)
174+
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = nullptr)
175175
{
176176
return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
177177
}
@@ -183,7 +183,7 @@ namespace pcl
183183
* \return connection object that allows to disconnect the callback function.
184184
*/
185185
inline boost::signals2::connection
186-
registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = NULL)
186+
registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = nullptr)
187187
{
188188
return (registerPointPickingCallback (boost::bind (callback, _1, cookie)));
189189
}
@@ -195,7 +195,7 @@ namespace pcl
195195
* \return connection object that allows to disconnect the callback function.
196196
*/
197197
template<typename T> inline boost::signals2::connection
198-
registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = NULL)
198+
registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = nullptr)
199199
{
200200
return (registerPointPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
201201
}

visualization/include/pcl/visualization/image_viewer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ namespace pcl
477477
*/
478478
boost::signals2::connection
479479
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*),
480-
void* cookie = NULL)
480+
void* cookie = nullptr)
481481
{
482482
return (registerKeyboardCallback (boost::bind (callback, _1, cookie)));
483483
}
@@ -490,7 +490,7 @@ namespace pcl
490490
*/
491491
template<typename T> boost::signals2::connection
492492
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*),
493-
T& instance, void* cookie = NULL)
493+
T& instance, void* cookie = nullptr)
494494
{
495495
return (registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
496496
}
@@ -509,7 +509,7 @@ namespace pcl
509509
*/
510510
boost::signals2::connection
511511
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*),
512-
void* cookie = NULL)
512+
void* cookie = nullptr)
513513
{
514514
return (registerMouseCallback (boost::bind (callback, _1, cookie)));
515515
}
@@ -522,7 +522,7 @@ namespace pcl
522522
*/
523523
template<typename T> boost::signals2::connection
524524
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*),
525-
T& instance, void* cookie = NULL)
525+
T& instance, void* cookie = nullptr)
526526
{
527527
return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
528528
}

visualization/include/pcl/visualization/impl/pcl_visualizer.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pcl::visualization::PCLVisualizer::addText3D (
658658

659659
// check all or an individual viewport for a similar id
660660
rens_->InitTraversal ();
661-
for (size_t i = viewport; rens_->GetNextItem () != NULL; ++i)
661+
for (size_t i = viewport; rens_->GetNextItem (); ++i)
662662
{
663663
const std::string uid = tid + std::string (i, '*');
664664
if (contains (uid))
@@ -685,7 +685,7 @@ pcl::visualization::PCLVisualizer::addText3D (
685685
rens_->InitTraversal ();
686686
vtkRenderer* renderer;
687687
int i = 0;
688-
while ((renderer = rens_->GetNextItem ()) != NULL)
688+
while ((renderer = rens_->GetNextItem ()))
689689
{
690690
// Should we add the actor to all renderers or just to i-nth renderer?
691691
if (viewport == 0 || viewport == i)
@@ -745,7 +745,7 @@ pcl::visualization::PCLVisualizer::addText3D (
745745

746746
// check all or an individual viewport for a similar id
747747
rens_->InitTraversal ();
748-
for (size_t i = viewport; rens_->GetNextItem () != NULL; ++i)
748+
for (size_t i = viewport; rens_->GetNextItem (); ++i)
749749
{
750750
const std::string uid = tid + std::string (i, '*');
751751
if (contains (uid))
@@ -779,7 +779,7 @@ pcl::visualization::PCLVisualizer::addText3D (
779779
rens_->InitTraversal ();
780780
int i = 0;
781781
for ( vtkRenderer* renderer = rens_->GetNextItem ();
782-
renderer != NULL;
782+
renderer;
783783
renderer = rens_->GetNextItem (), ++i)
784784
{
785785
if (viewport == 0 || viewport == i)
@@ -837,7 +837,7 @@ pcl::visualization::PCLVisualizer::addPointCloudNormals (
837837

838838

839839
vtkIdType nr_normals = 0;
840-
float* pts = 0;
840+
float* pts = nullptr;
841841

842842
// If the cloud is organized, then distribute the normal step in both directions
843843
if (cloud->isOrganized () && normals->isOrganized ())

visualization/include/pcl/visualization/pcl_plotter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace pcl
109109
unsigned long size,
110110
char const * name = "Y Axis",
111111
int type = vtkChart::LINE ,
112-
char const *color=NULL);
112+
char const *color=nullptr);
113113

114114
/** \brief Adds a plot with correspondences in vectors arrayX and arrayY. This is the vector version of the addPlotData function.
115115
* \param[in] array_x X coordinates of point correspondence array

visualization/include/pcl/visualization/pcl_visualizer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ namespace pcl
172172
* \return a connection object that allows to disconnect the callback function.
173173
*/
174174
inline boost::signals2::connection
175-
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = NULL)
175+
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = nullptr)
176176
{
177177
return (registerKeyboardCallback (boost::bind (callback, _1, cookie)));
178178
}
@@ -184,7 +184,7 @@ namespace pcl
184184
* \return a connection object that allows to disconnect the callback function.
185185
*/
186186
template<typename T> inline boost::signals2::connection
187-
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = NULL)
187+
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = nullptr)
188188
{
189189
return (registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
190190
}
@@ -202,7 +202,7 @@ namespace pcl
202202
* \return a connection object that allows to disconnect the callback function.
203203
*/
204204
inline boost::signals2::connection
205-
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = NULL)
205+
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = nullptr)
206206
{
207207
return (registerMouseCallback (boost::bind (callback, _1, cookie)));
208208
}
@@ -214,7 +214,7 @@ namespace pcl
214214
* \return a connection object that allows to disconnect the callback function.
215215
*/
216216
template<typename T> inline boost::signals2::connection
217-
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = NULL)
217+
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = nullptr)
218218
{
219219
return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
220220
}
@@ -232,7 +232,7 @@ namespace pcl
232232
* \return a connection object that allows to disconnect the callback function.
233233
*/
234234
boost::signals2::connection
235-
registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = NULL);
235+
registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = nullptr);
236236

237237
/** \brief Register a callback function for point picking events
238238
* \param[in] callback the member function that will be registered as a callback for a point picking event
@@ -241,7 +241,7 @@ namespace pcl
241241
* \return a connection object that allows to disconnect the callback function.
242242
*/
243243
template<typename T> inline boost::signals2::connection
244-
registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = NULL)
244+
registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = nullptr)
245245
{
246246
return (registerPointPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
247247
}
@@ -259,7 +259,7 @@ namespace pcl
259259
* \return a connection object that allows to disconnect the callback function.
260260
*/
261261
boost::signals2::connection
262-
registerAreaPickingCallback (void (*callback) (const pcl::visualization::AreaPickingEvent&, void*), void* cookie = NULL);
262+
registerAreaPickingCallback (void (*callback) (const pcl::visualization::AreaPickingEvent&, void*), void* cookie = nullptr);
263263

264264
/** \brief Register a callback function for area picking events
265265
* \param[in] callback the member function that will be registered as a callback for an area picking event
@@ -268,7 +268,7 @@ namespace pcl
268268
* \return a connection object that allows to disconnect the callback function.
269269
*/
270270
template<typename T> inline boost::signals2::connection
271-
registerAreaPickingCallback (void (T::*callback) (const pcl::visualization::AreaPickingEvent&, void*), T& instance, void* cookie = NULL)
271+
registerAreaPickingCallback (void (T::*callback) (const pcl::visualization::AreaPickingEvent&, void*), T& instance, void* cookie = nullptr)
272272
{
273273
return (registerAreaPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
274274
}

visualization/include/pcl/visualization/window.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace pcl
9191
*/
9292
boost::signals2::connection
9393
registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*),
94-
void* cookie = NULL)
94+
void* cookie = nullptr)
9595
{
9696
return registerKeyboardCallback (boost::bind (callback, _1, cookie));
9797
}
@@ -105,7 +105,7 @@ namespace pcl
105105
*/
106106
template<typename T> boost::signals2::connection
107107
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*),
108-
T& instance, void* cookie = NULL)
108+
T& instance, void* cookie = nullptr)
109109
{
110110
return registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie));
111111
}
@@ -118,7 +118,7 @@ namespace pcl
118118
*/
119119
boost::signals2::connection
120120
registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*),
121-
void* cookie = NULL)
121+
void* cookie = nullptr)
122122
{
123123
return registerMouseCallback (boost::bind (callback, _1, cookie));
124124
}
@@ -132,7 +132,7 @@ namespace pcl
132132
*/
133133
template<typename T> boost::signals2::connection
134134
registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*),
135-
T& instance, void* cookie = NULL)
135+
T& instance, void* cookie = nullptr)
136136
{
137137
return registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie));
138138
}

visualization/src/image_viewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ pcl::visualization::ImageViewerInteractorStyle::OnLeftButtonDown ()
962962
int y = Interactor->GetEventPosition ()[1];
963963

964964
FindPokedRenderer (x, y);
965-
if (CurrentRenderer == NULL)
965+
if (!CurrentRenderer)
966966
return;
967967

968968
// Redefine this button to handle window/level

visualization/src/interactor_style.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ void
165165
pcl::visualization::PCLVisualizerInteractorStyle::getCameraParameters (pcl::visualization::Camera &camera, int viewport) const
166166
{
167167
rens_->InitTraversal ();
168-
vtkRenderer* renderer = NULL;
168+
vtkRenderer* renderer = nullptr;
169169
int i = 0;
170-
while ((renderer = rens_->GetNextItem ()) != NULL)
170+
while (renderer = rens_->GetNextItem ())
171171
{
172172
if (viewport++ == i)
173173
{
@@ -241,9 +241,9 @@ pcl::visualization::PCLVisualizerInteractorStyle::setCameraParameters (const Eig
241241

242242

243243
rens_->InitTraversal ();
244-
vtkRenderer* renderer = NULL;
244+
vtkRenderer* renderer = nullptr;
245245
int i = 0;
246-
while ((renderer = rens_->GetNextItem ()) != NULL)
246+
while (renderer = rens_->GetNextItem ())
247247
{
248248
// Modify all renderer's cameras
249249
if (viewport == 0 || viewport == i)
@@ -267,9 +267,9 @@ void
267267
pcl::visualization::PCLVisualizerInteractorStyle::setCameraParameters (const pcl::visualization::Camera &camera, int viewport)
268268
{
269269
rens_->InitTraversal ();
270-
vtkRenderer* renderer = NULL;
270+
vtkRenderer* renderer = nullptr;
271271
int i = 0;
272-
while ((renderer = rens_->GetNextItem ()) != NULL)
272+
while (renderer = rens_->GetNextItem ())
273273
{
274274
// Modify all renderer's cameras
275275
if (viewport == 0 || viewport == i)
@@ -527,7 +527,7 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
527527

528528
FindPokedRenderer (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
529529

530-
if (wif_->GetInput () == NULL)
530+
if (!wif_->GetInput ())
531531
{
532532
wif_->SetInput (Interactor->GetRenderWindow ());
533533
wif_->Modified ();
@@ -854,7 +854,7 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
854854
case 'j': case 'J':
855855
{
856856
char cam_fn[80], snapshot_fn[80];
857-
unsigned t = static_cast<unsigned> (time (0));
857+
unsigned t = static_cast<unsigned> (time (nullptr));
858858
sprintf (snapshot_fn, "screenshot-%d.png" , t);
859859
saveScreenshot (snapshot_fn);
860860

@@ -969,12 +969,12 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
969969
else
970970
{
971971
AnimState = VTKIS_ANIM_ON;
972-
vtkAssemblyPath *path = NULL;
972+
vtkAssemblyPath *path = nullptr;
973973
Interactor->GetPicker ()->Pick (Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1], 0.0, CurrentRenderer);
974974
vtkAbstractPropPicker *picker;
975975
if ((picker = vtkAbstractPropPicker::SafeDownCast (Interactor->GetPicker ())))
976976
path = picker->GetPath ();
977-
if (path != NULL)
977+
if (path)
978978
Interactor->FlyTo (CurrentRenderer, picker->GetPickPosition ());
979979
AnimState = VTKIS_ANIM_OFF;
980980
}
@@ -1061,7 +1061,7 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
10611061
if (!keymod)
10621062
{
10631063
FindPokedRenderer(Interactor->GetEventPosition ()[0], Interactor->GetEventPosition ()[1]);
1064-
if(CurrentRenderer != 0)
1064+
if(CurrentRenderer)
10651065
CurrentRenderer->ResetCamera ();
10661066
else
10671067
PCL_WARN ("no current renderer on the interactor style.");

visualization/src/pcl_plotter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pcl::visualization::PCLPlotter::addPlotData (
126126
line->SetInputData (table, 0, 1);
127127
line->SetWidth (1);
128128

129-
if (color == NULL) //color automatically based on the ColorScheme
129+
if (!color) //color automatically based on the ColorScheme
130130
{
131131
vtkColor3ub vcolor = color_series_->GetColorRepeating (current_plot_);
132132
line->SetColor (vcolor[0], vcolor[1], vcolor[2], 255);
@@ -144,7 +144,7 @@ pcl::visualization::PCLPlotter::addPlotData (
144144
int type /* = vtkChart::LINE */,
145145
std::vector<char> const &color)
146146
{
147-
this->addPlotData (&array_X[0], &array_Y[0], static_cast<unsigned long> (array_X.size ()), name, type, (color.empty ()) ? NULL : &color[0]);
147+
this->addPlotData (&array_X[0], &array_Y[0], static_cast<unsigned long> (array_X.size ()), name, type, (color.empty ()) ? nullptr : &color[0]);
148148
}
149149

150150
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -163,7 +163,7 @@ pcl::visualization::PCLPlotter::addPlotData (
163163
array_x[i] = plot_data[i].first;
164164
array_y[i] = plot_data[i].second;
165165
}
166-
this->addPlotData (array_x, array_y, static_cast<unsigned long> (plot_data.size ()), name, type, (color.empty ()) ? NULL : &color[0]);
166+
this->addPlotData (array_x, array_y, static_cast<unsigned long> (plot_data.size ()), name, type, (color.empty ()) ? nullptr : &color[0]);
167167
}
168168

169169
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -653,7 +653,7 @@ pcl::visualization::PCLPlotter::setViewInteractor (
653653
bool
654654
pcl::visualization::PCLPlotter::wasStopped () const
655655
{
656-
if (view_->GetInteractor() != NULL)
656+
if (view_->GetInteractor())
657657
return (stopped_);
658658
else
659659
return (true);

0 commit comments

Comments
 (0)