Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLCoreTestingUtilities.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17  and was partially funded by NIH grant 1U24CA194354-01
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkMRMLCoreTestingUtilities_h
22 #define __vtkMRMLCoreTestingUtilities_h
23 
24 // MRML/Core includes
25 #include <vtkMRML.h>
26 
27 // VTK includes
28 #include <vtkCallbackCommand.h>
29 
30 // STD includes
31 #include <sstream>
32 #include <vector>
33 #include <map>
34 
35 class vtkMRMLNode;
36 class vtkMRMLScene;
38 class vtkMRMLDisplayNode;
40 class vtkMRMLStorageNode;
43 
48 
50 {
51 
52 VTK_MRML_EXPORT
53 bool CheckNodeInSceneByID(int line, vtkMRMLScene* scene,
54  const char* nodeID, vtkMRMLNode* expected);
55 
56 VTK_MRML_EXPORT
57 bool CheckNodeIdAndName(int line, vtkMRMLNode* node,
58  const char* expectedID, const char* expectedName);
59 
60 template<typename Type>
61 std::string ToString(Type value);
62 
64 VTK_MRML_EXPORT
66  const char * sceneFilePath, std::vector<std::string>& expectedNodeAddedClassNames);
67 
69 VTK_MRML_EXPORT
70 int ExerciseBasicObjectMethods(vtkObject* object);
71 
75 VTK_MRML_EXPORT
77 
79 VTK_MRML_EXPORT
81 
84 VTK_MRML_EXPORT
86 
89 VTK_MRML_EXPORT
91 
94 VTK_MRML_EXPORT
96 
99 VTK_MRML_EXPORT
101 
104 VTK_MRML_EXPORT
106 
109 VTK_MRML_EXPORT
111 
117 VTK_MRML_EXPORT
118 int ExerciseSceneLoadingMethods(const char * sceneFilePath, vtkMRMLScene* inputScene = nullptr);
119 
120 //---------------------------------------------------------------------------
121 class VTK_MRML_EXPORT vtkMRMLNodeCallback : public vtkCallbackCommand
122 {
123 public:
125  void PrintSelf(ostream& os, vtkIndent indent) override;
126 
127  void Execute(vtkObject* caller, unsigned long eid, void *callData) override;
128  virtual void ResetNumberOfEvents();
129 
130  void SetMRMLNode(vtkMRMLNode*);
131  std::string GetErrorString();
132 
134  int CheckStatus();
135 
136  int GetNumberOfModified();
137  int GetNumberOfEvents(unsigned long event);
138  int GetTotalNumberOfEvents();
139  std::vector<unsigned long> GetReceivedEvents();
140 
141 protected:
143  ~vtkMRMLNodeCallback() override;
144 
145  void SetErrorString(const char* error);
146 
147  void SetErrorString(int line, const char* error);
148 
149  vtkMRMLNode* Node{nullptr};
150  std::string ErrorString;
151  std::map<unsigned long, unsigned int> ReceivedEvents;
152 };
153 
154 } // namespace vtkMRMLCoreTestingUtilities
155 
156 #include "vtkMRMLCoreTestingUtilities.txx"
157 
158 #endif
VTK_MRML_EXPORT int ExerciseSceneLoadingMethods(const char *sceneFilePath, vtkMRMLScene *inputScene=nullptr)
VTK_MRML_EXPORT int ExerciseBasicTransformableMRMLMethods(vtkMRMLTransformableNode *node)
MRML node for representing a transformation between this node space and a parent node space...
std::string ToString(Type value)
VTK_MRML_EXPORT int ExerciseBasicMRMLMethods(vtkMRMLNode *node)
Slicer Libs/MRML/vtkMRMLNode exercises.
VTK_MRML_EXPORT int ExerciseAllBasicMRMLMethods(vtkMRMLNode *object)
VTK_MRML_EXPORT int ExerciseBasicStorageMRMLMethods(vtkMRMLStorageNode *node)
VTK_MRML_EXPORT int ExerciseBasicTransformMRMLMethods(vtkMRMLTransformNode *node)
VTK_MRML_EXPORT int ExerciseBasicStorableMRMLMethods(vtkMRMLStorableNode *node)
VTK_MRML_EXPORT int ExerciseBasicDisplayableMRMLMethods(vtkMRMLDisplayableNode *node)
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
std::map< unsigned long, unsigned int > ReceivedEvents
A superclass for other storage nodes.
VTK_MRML_EXPORT int GetExpectedNodeAddedClassNames(const char *sceneFilePath, std::vector< std::string > &expectedNodeAddedClassNames)
Return list of node that should be added to the scene.
Abstract class that contains graphical display properties for displayable nodes.
VTK_MRML_EXPORT int ExerciseBasicDisplayMRMLMethods(vtkMRMLDisplayNode *node)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
VTK_MRML_EXPORT int ExerciseBasicObjectMethods(vtkObject *object)
Test basic VTK object methods (print, superclass, etc.)
VTK_MRML_EXPORT bool CheckNodeIdAndName(int line, vtkMRMLNode *node, const char *expectedID, const char *expectedName)
VTK_MRML_EXPORT bool CheckNodeInSceneByID(int line, vtkMRMLScene *scene, const char *nodeID, vtkMRMLNode *expected)
MRML node for representing a node with a transform.