20 #include <vtkWindow.h>
58 class mitkDataNodeTestClass
66 dataNode->SetData(baseData);
67 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a NULL pointer was set correctly")
70 dataNode->SetData(baseData);
71 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a GeometryData object was set correctly")
74 dataNode->SetData(baseData);
75 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a PlaneGeometryData object was set correctly")
78 dataNode->SetData(baseData);
79 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a ManufacturerLogo object was set correctly")
82 dataNode->SetData(baseData);
83 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a PointSet object was set correctly")
86 dataNode->SetData(baseData);
87 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a Image object was set correctly")
90 dataNode->SetData(baseData);
91 MITK_TEST_CONDITION(baseData == dataNode->GetData(),
"Testing if a Surface object was set correctly")
93 dataNode->SetData(
nullptr);
95 "Testing if base data (already set) was replaced by a NULL pointer")
105 dataNode->SetMapper(0, mapper);
106 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(0),
"Testing if a NULL pointer was set correctly")
109 dataNode->SetMapper(1, mapper);
110 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a PlaneGeometryDataMapper2D was set correctly")
111 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
114 dataNode->SetMapper(1, mapper);
115 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a ImageVtkMapper2D was set correctly")
116 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
119 dataNode->SetMapper(1, mapper);
120 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a PointSetVtkMapper2D was set correctly")
121 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
124 dataNode->SetMapper(1, mapper);
125 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a SurfaceGLMapper2D was set correctly")
126 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
129 dataNode->SetMapper(1, mapper);
130 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a PlaneGeometryDataVtkMapper3D was set correctly")
131 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
134 dataNode->SetMapper(1, mapper);
135 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a PointSetVtkMapper3D was set correctly")
136 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
139 dataNode->SetMapper(1, mapper);
140 MITK_TEST_CONDITION(mapper == dataNode->GetMapper(1),
"Testing if a SurfaceVtkMapper3D was set correctly")
141 MITK_TEST_CONDITION(dataNode == mapper->GetDataNode(),
"Testing if the mapper returns the right DataNode")
152 "Testing if a NULL pointer was set correctly (DataInteractor)")
155 interactor->SetEventConfig(
"PointSetConfig.xml");
156 interactor->SetDataNode(dataNode);
158 "Testing if a PointSetDataInteractor was set correctly")
161 dataNode->SetDataInteractor(interactor);
163 "Testing if a PointSetDataInteractor was set correctly")
169 MITK_TEST_CONDITION(dataNode->GetPropertyList() != NULL,
"Testing if the constructor set the propertylist")
171 dataNode->SetIntProperty(
"int", -31337);
173 dataNode->GetIntProperty(
"int", x);
176 dataNode->SetBoolProperty(
"bool",
true);
178 dataNode->GetBoolProperty(
"bool", b);
180 dataNode->SetFloatProperty(
"float", -31.337);
182 dataNode->GetFloatProperty(
"float", y);
185 dataNode->GetDoubleProperty(
"float", yd);
188 double d = sqrt(2.0);
189 dataNode->SetDoubleProperty(
"double", d);
191 MITK_TEST_CONDITION(dataNode->GetDoubleProperty(
"double", read_d),
"Testing GetDoubleProperty");
193 dataNode->SetStringProperty(
"string",
"MITK");
194 std::string s =
"GANZVIELPLATZ";
195 dataNode->GetStringProperty(
"string", s);
198 std::string name =
"MyTestName";
199 dataNode->SetName(name.c_str());
201 name =
"MySecondTestName";
202 dataNode->SetName(name);
206 "Testing if the propertylist has changed during the last tests")
217 MITK_TEST_CONDITION(!dataNode->IsSelected(),
"Testing if this node is not set as selected")
219 dataNode->SetSelected(
true);
221 dataNode->SetSelected(
false);
223 dataNode->SetSelected(
true, base);
225 MITK_TEST_CONDITION(dataNode->IsSelected(base),
"Testing if this node with right base renderer is set as selected")
228 renderWindow->Delete();
233 time = dataNode->GetMTime();
236 dataNode->SetData(pointSet);
238 "Testing if the node timestamp is updated after adding data to the node")
242 pointSet->SetPoint(0, point);
246 "Testing if the node timestamp is updated after base data was modified")
249 unsigned long lastModified = dataNode->GetMTime();
250 dataNode->SetIntProperty(
"testIntProp", 2344);
252 "Testing if the node timestamp is updated after property list was modified")
254 static void TestSetDataUnderPropertyChange(
void)
261 image = mitk::ImageGenerator::GenerateRandomImage<unsigned char>(3u, 3u);
263 dataNode->SetData(image);
265 const float defaultOutlineWidth = 1.0;
266 float outlineWidth = 0;
267 dataNode->GetPropertyValue(
"outline width", outlineWidth);
270 "Testing if the SetData set the default property list")
272 dataNode->SetProperty("outline width",
mitk::FloatProperty::
New(42.0));
273 dataNode->SetData(image);
274 dataNode->GetPropertyValue("outline width", outlineWidth);
277 "Testing if the SetData does not set anything if image data is identical")
279 dataNode->SetData(additionalImage);
280 dataNode->GetPropertyValue("outline width", outlineWidth);
283 "Testing if the SetData does not set the default property list if image data is already set")
286 dataNode->SetData(surface);
289 "Testing if SetData cleared previous property list and set the default property list if data "
290 "of different type has been set")
307 mitkDataNodeTestClass::TestDataSetting(myDataNode);
308 mitkDataNodeTestClass::TestMapperSetting(myDataNode);
311 mitkDataNodeTestClass::TestInteractorSetting(myDataNode);
312 mitkDataNodeTestClass::TestPropertyList(myDataNode);
313 mitkDataNodeTestClass::TestSelected(myDataNode);
314 mitkDataNodeTestClass::TestGetMTime(myDataNode);
315 mitkDataNodeTestClass::TestSetDataUnderPropertyChange();
itk::SmartPointer< Self > Pointer
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
DataCollection - Class to facilitate loading/accessing structured data.
int mitkDataNodeTest(int, char *[])
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_CONDITION(COND, MSG)
static RenderingManager * GetInstance()
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
static Pointer New(const char *_arga, vtkRenderWindow *_argb, mitk::RenderingManager *_argc)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.