31 #include <itkCommand.h>
33 struct PropertyModifiedListener
35 typedef itk::SimpleMemberCommand<PropertyModifiedListener> CmdType;
37 PropertyModifiedListener() : m_Modified(false), m_Cmd(CmdType::
New())
39 m_Cmd->SetCallbackFunction(
this, &PropertyModifiedListener::Modified);
42 void Modified() { m_Modified =
true; }
66 PropertyModifiedListener l;
67 unsigned long tag = prop->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer());
72 std::string msg = std::string(
"Test assignment [") + prop->GetValueAsString() +
" == " + strProp +
"]";
78 prop->RemoveObserver(tag);
86 PropertyModifiedListener l;
87 unsigned long tag = baseProp->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer());
92 std::string(
"Test polymorphic assignment [") + baseProp->GetValueAsString() +
" == " + strProp +
"]";
98 baseProp->RemoveObserver(tag);
104 T prop2 = prop->Clone();
112 const std::string &strV1,
113 const std::string &strV2)
115 PropertyModifiedListener l;
121 std::string msg = std::string(
"Test GetValueAsString() [") + prop->GetValueAsString() +
" == " + strV1 +
"]";
127 prop2->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer());
145 TestProperty<mitk::BoolProperty>(
false,
true,
"0",
"1");
146 TestProperty<mitk::IntProperty>(3, 5,
"3",
"5");
147 TestProperty<mitk::FloatProperty>(0.3f, -23.5f,
"0.3",
"-23.5");
148 TestProperty<mitk::DoubleProperty>(64.1f, 2.34f,
"64.1",
"2.34");
159 TestProperty<mitk::Vector3DProperty>(p1, p2,
"[2, 3, 4]",
"[-1, 2, 3]");
171 TestProperty<mitk::Point3dProperty>(p1, p2,
"[2, 3, 4]",
"[-1, 2, 3]");
185 TestProperty<mitk::Point4dProperty>(p1, p2,
"[2, 3, 4, -2]",
"[-1, 2, 3, 5]");
197 TestProperty<mitk::Point3iProperty>(p1, p2,
"[2, 3, 4]",
"[8, 7, 6]");
209 TestProperty<mitk::FloatLookupTableProperty>(lut1, lut2,
"[1 -> 0.3, 4 -> 323.7]",
"[2 -> 25.7, 6 -> -0.3]");
220 TestProperty<mitk::BoolLookupTableProperty>(lut1, lut2,
"[3 -> 0, 5 -> 1]",
"[1 -> 0, 2 -> 0]");
232 TestProperty<mitk::IntLookupTableProperty>(lut1, lut2,
"[5 -> -12, 7 -> 3]",
"[4 -> -6, 8 -> -45]");
244 TestProperty<mitk::StringLookupTableProperty>(lut1, lut2,
"[0 -> a, 2 -> b]",
"[0 -> a, 2 -> c]");
250 PropertyModifiedListener l;
252 std::string label1(
"Label1");
257 std::string str1 =
"Label1[3, 5, -4]";
259 std::string label2(
"Label2");
264 std::string str2 =
"Label2[-2, 8, -4]";
270 std::string msg = std::string(
"Test GetValueAsString() [") + prop->GetValueAsString() +
" == " + str1 +
"]";
274 prop2->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer());
276 prop2->SetLabel(label2);
278 prop2->SetPosition(point2);
282 prop2->SetLabel(label2);
284 prop2->SetPosition(point2);
290 prop->SetLabel(label1);
291 prop->SetPosition(point1);
297 PropertyModifiedListener l;
299 bool enabled1 =
true;
308 std::string str1 =
"1[3, 5, -4][0, 2, -1]";
310 bool enabled2 =
false;
319 std::string str2 =
"0[-2, 8, -4][0, 2, 4]";
325 prop->GetClippingEnabled() == enabled1 && prop->GetOrigin() == point1 && prop->GetNormal() == vec1,
327 std::string msg = std::string(
"Test GetValueAsString() [") + prop->GetValueAsString() +
" == " + str1 +
"]";
331 prop2->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer());
333 prop2->SetClippingEnabled(enabled2);
335 prop2->SetOrigin(point2);
337 prop2->SetNormal(vec2);
341 prop2->GetClippingEnabled() == enabled2 && prop2->GetOrigin() == point2 && prop2->GetNormal() == vec2,
344 prop2->SetClippingEnabled(enabled2);
346 prop2->SetOrigin(point2);
348 prop2->SetNormal(vec2);
354 prop->SetClippingEnabled(enabled1);
355 prop->SetOrigin(point1);
356 prop->SetNormal(vec1);
377 TestProperty<mitk::ColorProperty>(c1, c2,
"0.2 0.6 0.8",
"0.2 0.4 0.1");
381 TestProperty<mitk::LevelWindowProperty>(lw1, lw2,
"L:50 W:100",
"L:120 W:30");
390 TestProperty<mitk::SmartPointerProperty>(sp1, sp2, spp1->GetReferenceUIDFor(sp1), spp2->GetReferenceUIDFor(sp2));
393 TestProperty<mitk::StringProperty>(
"1",
"2",
"1",
"2");
398 tf2->AddScalarOpacityPoint(0.4, 0.8);
399 std::stringstream ss;
401 std::string strTF1 = ss.str();
404 std::string strTF2 = ss.str();
405 TestProperty<mitk::TransferFunctionProperty>(tf1, tf2, strTF1, strTF2);
413 std::stringstream ss;
414 ss << sp1.GetPointer();
415 std::string str1 = ss.str();
417 ss << sp2.GetPointer();
418 std::string str2 = ss.str();
420 TestProperty<mitk::WeakPointerProperty>(wp1, wp2, str1, str2);
425 lut1->GetVtkLookupTable()->SetTableValue(0, 0.2, 0.3, 0.4);
427 lut2->GetVtkLookupTable()->SetTableValue(0, 0.2, 0.4, 0.4);
428 std::stringstream ss;
430 std::string strLUT1 = ss.str();
433 std::string strLUT2 = ss.str();
434 TestProperty<mitk::LookupTableProperty>(lut1, lut2, strLUT1, strLUT2);
void TestProperty(const typename T::ValueType &v1, const typename T::ValueType &v2, const std::string &strV1, const std::string &strV2)
void TestPropPolymorphicAssignment(T prop, T prop2, const std::string &strProp)
itk::SmartPointer< Self > Pointer
void SetTableValue(IdentifierType id, ValueType value)
void TestPropInequality(T prop, T prop2)
void TestPropAssignment(T prop, T prop2, const std::string &strProp)
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_OUTPUT(x)
Output some text.
The LevelWindow class Class to store level/window values.
void TestPropCloning(T prop)
void TestClippingProperty()
ValueType
Type of the value held by a Value object.
itk::WeakPointer< itk::Object > ValueType
void TestAnnotationProperty()
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
void TestGenericProperties()
specializations of GenericLookupTable
int mitkPropertyTest(int, char *[])
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.