Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build against Slicer 5.x and Qt 5.15 #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
COMP: Use nullptr instead of 0 or NULL
This commit converts the usage of null pointer constants (eg. NULL, 0) to
use the new C++11 nullptr keyword.

Updates were performed following these steps:

(1) Reconfigure with CMAKE_EXPORT_COMPILE_COMMANDS

  cd /tmp/Slicer-CameraPath-
  cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON .

(2) Run run-clang-tidy

  cd /tmp/Slicer-CameraPath-build
  run-clang-tidy-10 -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix


References:

* https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide#C.2B.2B11:_Update_source_code_to_use_nullptr
jcfr committed May 16, 2022

Verified

This commit was signed with the committer’s verified signature.
raimund-schluessler Raimund Schlüßler
commit 468d513ab8fbadc0322120786c505d3a5d402be1
14 changes: 7 additions & 7 deletions Modules/Loadable/CameraPath/Logic/vtkSlicerCameraPathLogic.cxx
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ void vtkSlicerCameraPathLogic::UpdateFromMRMLScene()
//---------------------------------------------------------------------------
void vtkSlicerCameraPathLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)
{
if (node==NULL)
if (node == nullptr)
{
vtkErrorMacro("An invalid node is attempted to be added");
return;
@@ -104,7 +104,7 @@ void vtkSlicerCameraPathLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)
//---------------------------------------------------------------------------
void vtkSlicerCameraPathLogic::OnMRMLSceneNodeRemoved(vtkMRMLNode* node)
{
if (node==NULL)
if (node == nullptr)
{
vtkErrorMacro("An invalid node is attempted to be removed");
return;
@@ -124,23 +124,23 @@ void vtkSlicerCameraPathLogic::OnMRMLSceneNodeRemoved(vtkMRMLNode* node)
//---------------------------------------------------------------------------
char* vtkSlicerCameraPathLogic::LoadCameraPath(const char *fileName, const char *nodeName)
{
char *nodeIDs = NULL;
char *nodeIDs = nullptr;
std::string idList;

if (!fileName)
{
vtkErrorMacro("LoadCameraPath: null file name, cannot load");
return NULL;
return nullptr;
}
if (fileName[0] == '\0')
{
vtkErrorMacro("LoadCameraPath: empty file name, cannot load");
return NULL;
return nullptr;
}
if (!this->GetMRMLScene())
{
vtkErrorMacro("LoadCameraPath: no MRML scene, cannot load");
return NULL;
return nullptr;
}

// turn on batch processing
@@ -180,7 +180,7 @@ char* vtkSlicerCameraPathLogic::LoadCameraPath(const char *fileName, const char
vtkErrorMacro("LoadCameraPath: coud not read data");
this->GetMRMLScene()->RemoveNode(cameraPathNode.GetPointer());
this->GetMRMLScene()->RemoveNode(storageNode.GetPointer());
return NULL;
return nullptr;
}

// adding camera nodes to scene
14 changes: 7 additions & 7 deletions Modules/Loadable/CameraPath/MRML/vtkMRMLCameraPathNode.h
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ struct KeyFrame
//bool Locked;
//bool Visibility;

KeyFrame(vtkMRMLCameraNode* camera = NULL,
KeyFrame(vtkMRMLCameraNode* camera = nullptr,
double time = 0.0):
Camera(camera),
Time(time)
@@ -104,9 +104,9 @@ class VTK_SLICER_CAMERAPATH_MODULE_MRML_EXPORT vtkMRMLCameraPathNode:
KeyFrame GetKeyFrame(vtkIdType index);
double GetKeyFrameTime(vtkIdType index);
vtkMRMLCameraNode* GetKeyFrameCamera(vtkIdType index);
void GetKeyFramePosition(vtkIdType index, double position[3] = 0);
void GetKeyFrameFocalPoint(vtkIdType index, double focalPoint[3] = 0);
void GetKeyFrameViewUp(vtkIdType index, double viewUp[3] = 0);
void GetKeyFramePosition(vtkIdType index, double position[3] = nullptr);
void GetKeyFrameFocalPoint(vtkIdType index, double focalPoint[3] = nullptr);
void GetKeyFrameViewUp(vtkIdType index, double viewUp[3] = nullptr);

void SetKeyFrames(KeyFrameVector keyFrames);
void SetKeyFrame(vtkIdType index, KeyFrame keyFrame);
@@ -140,9 +140,9 @@ class VTK_SLICER_CAMERAPATH_MODULE_MRML_EXPORT vtkMRMLCameraPathNode:
vtkMRMLPointSplineNode* viewUps);

void GetCameraAt(double t, vtkMRMLCameraNode* camera);
void GetPositionAt(double t, double position[3] = 0);
void GetFocalPointAt(double t, double focalPoint[3] = 0);
void GetViewUpAt(double t, double viewUp[3] = 0);
void GetPositionAt(double t, double position[3] = nullptr);
void GetFocalPointAt(double t, double focalPoint[3] = nullptr);
void GetViewUpAt(double t, double viewUp[3] = nullptr);
double ClampTime(double t);

protected:
4 changes: 2 additions & 2 deletions Modules/Loadable/CameraPath/MRML/vtkMRMLPointSplineNode.cxx
Original file line number Diff line number Diff line change
@@ -115,12 +115,12 @@ void vtkMRMLPointSplineNode::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
void vtkMRMLPointSplineNode::CreateDefaultDisplayNodes()
{
if (vtkMRMLModelDisplayNode::SafeDownCast(this->GetDisplayNode())!=NULL)
if (vtkMRMLModelDisplayNode::SafeDownCast(this->GetDisplayNode()) != nullptr)
{
// display node already exists
return;
}
if (this->GetScene()==NULL)
if (this->GetScene() == nullptr)
{
vtkErrorMacro("vtkMRMLPointSplineNode::CreateDefaultDisplayNodes failed: scene is invalid");
return;
2 changes: 1 addition & 1 deletion Modules/Loadable/CameraPath/MRML/vtkMRMLPointSplineNode.h
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ class VTK_SLICER_CAMERAPATH_MODULE_MRML_EXPORT vtkMRMLPointSplineNode :
void AddPoint(double t, double point[3]);
void RemovePoint(double t);
void UpdatePolyData(int framerate);
void Evaluate(double t, double point[3]=0);
void Evaluate(double t, double point[3]=nullptr);

protected:
vtkMRMLPointSplineNode();
2 changes: 1 addition & 1 deletion Modules/Loadable/CameraPath/qSlicerCameraPathModule.h
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ qSlicerCameraPathModule
public:

typedef qSlicerLoadableModule Superclass;
explicit qSlicerCameraPathModule(QObject *parent=0);
explicit qSlicerCameraPathModule(QObject *parent=nullptr);
virtual ~qSlicerCameraPathModule();

qSlicerGetTitleMacro(QTMODULE_TITLE);
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ qSlicerCameraPathModuleWidgetPrivate::logic() const
Q_Q(const qSlicerCameraPathModuleWidget);

vtkSlicerCameraPathLogic* logic=vtkSlicerCameraPathLogic::SafeDownCast(q->logic());
if (logic==NULL)
if (logic == nullptr)
{
qCritical() << "Camera path logic is invalid";
}
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ class Q_SLICER_QTMODULES_CAMERAPATH_EXPORT qSlicerCameraPathModuleWidget :
public:

typedef qSlicerAbstractModuleWidget Superclass;
qSlicerCameraPathModuleWidget(QWidget *parent=0);
qSlicerCameraPathModuleWidget(QWidget *parent=nullptr);
virtual ~qSlicerCameraPathModuleWidget();

void travelToTime(double t);
6 changes: 3 additions & 3 deletions Modules/Loadable/CameraPath/qSlicerCameraPathReader.cxx
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ bool qSlicerCameraPathReader::load(const IOProperties& properties)
name = properties["name"].toString();
}

if (d->CameraPathLogic.GetPointer() == 0)
if (d->CameraPathLogic.GetPointer() == nullptr)
{
return false;
}
@@ -125,7 +125,7 @@ bool qSlicerCameraPathReader::load(const IOProperties& properties)
while (ptr)
{
nodeIDList.append(ptr);
ptr = strtok(NULL, ",");
ptr = strtok(nullptr, ",");
}
this->setLoadedNodes(nodeIDList);
}
@@ -135,5 +135,5 @@ bool qSlicerCameraPathReader::load(const IOProperties& properties)
return false;
}

return nodeIDs != 0;
return nodeIDs != nullptr;
}
4 changes: 2 additions & 2 deletions Modules/Loadable/CameraPath/qSlicerCameraPathReader.h
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ class qSlicerCameraPathReader
Q_OBJECT
public:
typedef qSlicerFileReader Superclass;
qSlicerCameraPathReader(QObject* parent = 0);
qSlicerCameraPathReader(vtkSlicerCameraPathLogic* logic, QObject* parent = 0);
qSlicerCameraPathReader(QObject* parent = nullptr);
qSlicerCameraPathReader(vtkSlicerCameraPathLogic* logic, QObject* parent = nullptr);
virtual ~qSlicerCameraPathReader();

vtkSlicerCameraPathLogic* CameraPathLogic()const;