diff --git a/Core/Code/Testing/CMakeLists.txt b/Core/Code/Testing/CMakeLists.txt index 462e16b4a2..c570145ba0 100644 --- a/Core/Code/Testing/CMakeLists.txt +++ b/Core/Code/Testing/CMakeLists.txt @@ -1,14 +1,17 @@ MITK_CREATE_MODULE_TESTS(LABELS MITK-Core) # MITK_INSTALL_TARGETS(EXECUTABLES MitkTestDriver) ADD_TEST(mitkPicFileReaderTest_emptyFile ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkPicFileReaderTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/emptyFile.pic) SET_PROPERTY(TEST mitkPicFileReaderTest_emptyFile PROPERTY LABELS MITK-Core) ADD_TEST(mitkPicFileReaderTest_emptyGzipFile ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkPicFileReaderTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/emptyFile.pic.gz) SET_PROPERTY(TEST mitkPicFileReaderTest_emptyGzipFile PROPERTY LABELS MITK-Core) ADD_TEST(mitkDICOMLocaleTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkDICOMLocaleTest ${MITK_DATA_DIR}/spacing-ok.dcm) SET_PROPERTY(TEST mitkDICOMLocaleTest PROPERTY LABELS MITK-Core) ADD_TEST(mitkEventMapperTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkEventMapperTest ${MITK_DATA_DIR}/TestStateMachine1.xml ${MITK_DATA_DIR}/TestStateMachine2.xml) SET_PROPERTY(TEST mitkEventMapperTest PROPERTY LABELS MITK-Core) + +ADD_TEST(mitkNodeDependentPointSetInteractorTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkNodeDependentPointSetInteractorTest ${MITK_DATA_DIR}/Pic3D.pic.gz ${MITK_DATA_DIR}/BallBinary30x30x30.pic.gz) +SET_PROPERTY(TEST mitkNodeDependentPointSetInteractorTest PROPERTY LABELS MITK-Core) diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index 38f2e00af6..1200fc6914 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,92 +1,92 @@ # tests with no extra command line parameter SET(MODULE_TESTS mitkCoreObjectFactoryTest.cpp mitkPointSetWriterTest.cpp mitkMaterialTest.cpp mitkDataNodeTest.cpp mitkActionTest.cpp mitkDataStorageTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkInteractorTest.cpp mitkITKThreadingTest.cpp # mitkLevelWindowManagerTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetInteractorTest.cpp - mitkNodeDependentPointSetInteractorTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateMachineFactoryTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp #mitkPicFileIOTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkPointSetLocaleTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp ) # test with image filename as an extra command line parameter SET(MODULE_IMAGE_TESTS mitkSurfaceVtkWriterTest.cpp mitkPicFileWriterTest.cpp mitkImageWriterTest.cpp #mitkImageSliceSelectorTest.cpp mitkImageTimeSelectorTest.cpp mitkPicFileReaderTest.cpp # mitkVtkPropRendererTest.cpp mitkDataNodeFactoryTest.cpp #mitkSTLFileReaderTest.cpp ) # list of images for which the tests are run SET(MODULE_TESTIMAGES US4DCyl.pic.gz Pic3D.pic.gz Pic2DplusT.pic.gz BallBinary30x30x30.pic.gz binary.stl ball.stl ) SET(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp + mitkNodeDependentPointSetInteractorTest.cpp ) diff --git a/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp b/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp index 26d7e1c24a..a56cc4bbdb 100644 --- a/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp +++ b/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp @@ -1,208 +1,206 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-05-03 12:55:29 +0200 (Mo, 03 Mai 2010) $ Version: $Revision: 22655 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkNodeDepententPointSetInteractor.h" #include "mitkPointSet.h" #include "mitkPositionEvent.h" #include "mitkVtkPropRenderer.h" #include "mitkStateEvent.h" #include "mitkInteractionConst.h" #include "mitkGlobalInteraction.h" #include "mitkPointOperation.h" #include "mitkTestingMacros.h" #include "mitkStandaloneDataStorage.h" #include "mitkDataNodeFactory.h" #include "mitkStandardFileLocations.h" #include "mitkNodePredicateDataType.h" void SendPositionEvent(mitk::BaseRenderer* sender, int type, int button, int buttonState, int key, const mitk::Point2D& displPosition, const mitk::Point3D& worldPosition) { mitk::Event *posEvent = new mitk::PositionEvent(sender, type, button, buttonState, key, displPosition, worldPosition); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(posEvent); delete posEvent; } //test related to tutorial Step5.cpp -int mitkNodeDependentPointSetInteractorTest(int /*argc*/, char* /*argv*/[]) +int mitkNodeDependentPointSetInteractorTest(int argc, char* argv[]) { MITK_TEST_BEGIN("NodeDependentPointSetInteractor"); // Global interaction must(!) be initialized if used mitk::GlobalInteraction::GetInstance()->Initialize("global"); // Create a DataStorage mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); MITK_TEST_CONDITION_REQUIRED(ds.IsNotNull(),"Instantiating DataStorage"); //read two images and store to datastorage //these two images are used as node the interactors depend on. If the visibility property of one node if false, the //associated interactor may not change the data mitk::DataNode::Pointer node1, node2; mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - mitk::StandardFileLocations::Pointer locator = mitk::StandardFileLocations::GetInstance(); - MITK_TEST_CONDITION_REQUIRED(locator.IsNotNull(),"Instantiating StandardFileLocations"); MITK_TEST_CONDITION_REQUIRED(argc >= 3, "Test if a files to load has been specified"); try { //file 1 // const std::string filename1 = locator->FindFile("Pic3D.pic.gz", "Core/Code/Testing/Data"); const std::string filename1 = argv[1]; nodeReader->SetFileName(filename1); nodeReader->Update(); node1 = nodeReader->GetOutput(); ds->Add(node1); //file 2 // const std::string filename2 = locator->FindFile("BallBinary30x30x30.pic.gz", "Core/Code/Testing/Data"); const std::string filename2 = argv[2]; nodeReader->SetFileName(filename2); nodeReader->Update(); node2 = nodeReader->GetOutput(); ds->Add(node2); } catch(...) { MITK_TEST_FAILED_MSG(<< "Could not read file for testing"); return NULL; } //check for the two images mitk::NodePredicateDataType::Pointer predicate(mitk::NodePredicateDataType::New("Image")); mitk::DataStorage::SetOfObjects::ConstPointer allImagesInDS = ds->GetSubset(predicate); MITK_TEST_CONDITION_REQUIRED(allImagesInDS->Size()==2,"load images to data storage"); // Create PointSet and a node for it mitk::PointSet::Pointer pointSet1 = mitk::PointSet::New(); mitk::DataNode::Pointer pointSetNode1 = mitk::DataNode::New(); pointSetNode1->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 1.0f, 0.0f)); pointSetNode1->SetData(pointSet1); mitk::NodeDepententPointSetInteractor::Pointer interactor1 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode1, node1); MITK_TEST_CONDITION_REQUIRED(interactor1.IsNotNull(),"Instanciating NodeDependentPointSetInteractor"); // Add the node to the tree ds->Add(pointSetNode1); mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor1); mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New(); mitk::DataNode::Pointer pointSetNode2 = mitk::DataNode::New(); pointSetNode2->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 0.0f, 1.0f)); pointSetNode2->SetData(pointSet2); mitk::NodeDepententPointSetInteractor::Pointer interactor2 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode2, node2); MITK_TEST_CONDITION_REQUIRED(interactor2.IsNotNull(),"Instanciating NodeDependentPointSetInteractor"); // Add the node to the tree ds->Add(pointSetNode2); mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor2); //check for the two pointsets mitk::NodePredicateDataType::Pointer predicatePS(mitk::NodePredicateDataType::New("PointSet")); mitk::DataStorage::SetOfObjects::ConstPointer allImagesInDSPS = ds->GetSubset(predicatePS); MITK_TEST_CONDITION_REQUIRED(allImagesInDSPS->Size()==2,"create associated pointsets to data storage"); //create two RenderWindows mitk::RenderingManager::Pointer myRenderingManager = mitk::RenderingManager::New(); vtkRenderWindow* vtkRenWin1 = vtkRenderWindow::New(); mitk::VtkPropRenderer::Pointer br1 = mitk::VtkPropRenderer::New("testingBR", vtkRenWin1, myRenderingManager); mitk::BaseRenderer::AddInstance(vtkRenWin1,br1); myRenderingManager->AddRenderWindow(vtkRenWin1); mitk::BaseRenderer::Pointer renderer1 = mitk::BaseRenderer::GetInstance(vtkRenWin1); vtkRenderWindow* vtkRenWin2 = vtkRenderWindow::New(); mitk::VtkPropRenderer::Pointer br2 = mitk::VtkPropRenderer::New("testingBR", vtkRenWin2, myRenderingManager); mitk::BaseRenderer::AddInstance(vtkRenWin2,br2); myRenderingManager->AddRenderWindow(vtkRenWin2); mitk::BaseRenderer::Pointer renderer2 = mitk::BaseRenderer::GetInstance(vtkRenWin2); //set properties for renderWindow 1 and 2 //1: node1->SetBoolProperty("visible", true, renderer1); node2->SetBoolProperty("visible", false, renderer1); //2: node1->SetBoolProperty("visible", false, renderer2); node2->SetBoolProperty("visible", true, renderer2); //*************************************************** //now start to test if only an event send from renderwindow 1 can interact with interactor 1 and vice versa MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==0,"Checking empty pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==0,"Checking empty pointset 2."); //sending an event to interactor1 mitk::Point3D pos3D; mitk::Point2D pos2D; pos3D[0]= 10.0; pos3D[1]= 20.0; pos3D[2]= 30.0; pos2D[0]= 100; pos2D[0]= 200; //add to pointset 1 SendPositionEvent(renderer1, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"1 Checking addition of point to pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==0,"2 Checking empty pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"3 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==1,"4 Checking addition of point to pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"5 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"6 Checking addition of point to pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"7 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==3,"8 Checking addition of point to pointset 2"); //add to pointset 1 SendPositionEvent(renderer1, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==2,"9 Checking addition of point to pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==3,"10 Checking untouched state of pointset 2"); //trying to delete points mitk::Event* delEvent1 = new mitk::Event(renderer1, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::Event* delEvent2 = new mitk::Event(renderer2, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent2); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==2,"11 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"12 Checking detected point in pointset 2"); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent1); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"11 Checking deleted point in pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"12 Checking untouched state of pointset 2"); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent2); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"13 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==1,"14 Checking detected point in pointset 2"); mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor1); mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor2); delete delEvent1; delete delEvent2; myRenderingManager->RemoveRenderWindow(vtkRenWin1); myRenderingManager->RemoveRenderWindow(vtkRenWin2); vtkRenWin1->Delete(); vtkRenWin2->Delete(); //destroy RenderingManager myRenderingManager = NULL; MITK_TEST_END() }