diff --git a/CMakeExternals/PatchSOFA-rev10669.cmake b/CMakeExternals/PatchSOFA-386a3a7.cmake similarity index 77% rename from CMakeExternals/PatchSOFA-rev10669.cmake rename to CMakeExternals/PatchSOFA-386a3a7.cmake index 04b536b10d..5b5a246580 100644 --- a/CMakeExternals/PatchSOFA-rev10669.cmake +++ b/CMakeExternals/PatchSOFA-386a3a7.cmake @@ -1,189 +1,188 @@ # Changes of cmake/dependencies.cmake are commented separately below set(path "cmake/dependencies.cmake") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) # Comment out add_subdirectory() commands that reference the SOFA applications # directory string(REPLACE "add_subdirectory(\"\${SOFA_A" "#add_subdirectory(\"\${SOFA_A" CONTENTS ${CONTENTS}) # Rename tinyxml to SofaTinyXml since MITK has its own version of tinyxml and # the same name lead to linker or runtime errors in the past string(REPLACE "\"tinyxml\"" "\"SofaTinyXml\"" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) # Adjust tinyxml references (see above) +set(path "framework/sofa/helper/CMakeLists.txt") +file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) +string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) +configure_file(${TEMPLATE_FILE} ${path} @ONLY) + set(path "modules/sofa/component/SofaBaseVisual/CMakeLists.txt") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) set(path "modules/sofa/component/SofaLoader/CMakeLists.txt") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) set(path "modules/sofa/simulation/common/CMakeLists.txt") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) -# Allow setting SOFA_APPLICATIONS_PLUGINS_DIR from outside +# Changes of cmake/environment.cmake are commented separately below set(path "cmake/environment.cmake") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) + +# Allow setting SOFA_APPLICATIONS_PLUGINS_DIR from outside + string(REPLACE "S_DIR}/plugins\" CACHE INTERNAL" "S_DIR}/plugins\" CACHE PATH" CONTENTS ${CONTENTS}) + +# Place binaries and libraries in different subfolders according to the build +# configuration + +string(REPLACE "DEBUG \"\${directory}" "DEBUG \"\${directory}/Debug" CONTENTS ${CONTENTS}) +string(REPLACE "RELEASE \"\${directory}" "RELEASE \"\${directory}/Release" CONTENTS ${CONTENTS}) +string(REPLACE "RELWITHDEBINFO \"\${directory}" "RELWITHDEBINFO \"\${directory}/RelWithDebInfo" CONTENTS ${CONTENTS}) +string(REPLACE "MINSIZEREL \"\${directory}" "MINSIZEREL \"\${directory}/MinSizeRel" CONTENTS ${CONTENTS}) + configure_file(${TEMPLATE_FILE} ${path} @ONLY) # Binary directories in add_subdirectory() regarding external plugins have to be explicitly specified set(path "cmake/functions.cmake") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) string(REPLACE "add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\")" "if(\${GLOBAL_PROJECT_PATH_\${projectName}} MATCHES ^\${CMAKE_SOURCE_DIR}.*) add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\") else() string(LENGTH \"\${SOFA_APPLICATIONS_PLUGINS_DIR}\" begin) string(SUBSTRING \"\${GLOBAL_PROJECT_PATH_\${projectName}}\" \${begin} -1 subdir) add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\" \"\${CMAKE_BINARY_DIR}/applications/plugins\${subdir}\") endif()" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) -# Add -fPIC compiler flag for static libraries also if Clang is used - -set(path "extlibs/csparse/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "\${CMAKE_COMPILER_IS_GNUCC}" "\"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\" OR \"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "extlibs/metis-5.1.0/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "\${CMAKE_COMPILER_IS_GNUCC}" "\"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\" OR \"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "extlibs/miniFlowVR/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "\${CMAKE_COMPILER_IS_GNUCC}" "\"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\" OR \"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "extlibs/newmat/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "\${CMAKE_COMPILER_IS_GNUCC}" "\"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\" OR \"\${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - # Remove SOFA's FindGLEW.cmake since we need the official FindGLEW.cmake to # inject the MITK superbuild version of GLEW into SOFA file(REMOVE "cmake/Modules/FindGLEW.cmake") # Changes of cmake/externals.cmake are commented separately below set(path "cmake/externals.cmake") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) # Enhance GLUT and GLEW finding routine to regard externally injected GLUT and # GLEW libraries string(REPLACE "set(GLUT_LIBRARIES \"freeglut\")" "find_package(GLUT REQUIRED)" CONTENTS ${CONTENTS}) string(REPLACE "set(GLEW_LIBRARIES \"glew32\")" "find_package(GLEW REQUIRED)" CONTENTS ${CONTENTS}) string(REPLACE "else()\n set(O" " list(APPEND GLOBAL_INCLUDE_DIRECTORIES \"\${GLUT_INCLUDE_DIRS}\" \"\${GLEW_INCLUDE_DIRS}\")\nelse()\n set(O" CONTENTS ${CONTENTS}) string(REPLACE "GLUT REQUIRED" "GLUT REQUIRED CONFIG" CONTENTS ${CONTENTS}) string(REPLACE "GLEW REQUIRED" "GLEW REQUIRED CONFIG" CONTENTS ${CONTENTS}) # Remove Boost binary graph dependency because it is not straight forward to # compile on all plattforms and its header-only part is enough string(REPLACE "graph " "" CONTENTS ${CONTENTS}) configure_file(${TEMPLATE_FILE} ${path} @ONLY) -# Place binaries and libraries in different subfolders according to the build -# configuration +# Changes of CMakeLists.txt are commented separately below -set(path "cmake/preProject.cmake") +set(path "CMakeLists.txt") file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "DEBUG \"\${SOFA_BIN_DIR}" "DEBUG \"\${SOFA_BIN_DIR}/Debug" CONTENTS ${CONTENTS}) -string(REPLACE "RELEASE \"\${SOFA_BIN_DIR}" "RELEASE \"\${SOFA_BIN_DIR}/Release" CONTENTS ${CONTENTS}) -string(REPLACE "RELWITHDEBINFO \"\${SOFA_BIN_DIR}" "RELWITHDEBINFO \"\${SOFA_BIN_DIR}/RelWithDebInfo" CONTENTS ${CONTENTS}) -string(REPLACE "MINSIZEREL \"\${SOFA_BIN_DIR}" "MINSIZEREL \"\${SOFA_BIN_DIR}/MinSizeRel" CONTENTS ${CONTENTS}) -string(REPLACE "DEBUG \"\${SOFA_LIB_DIR}" "DEBUG \"\${SOFA_LIB_DIR}/Debug" CONTENTS ${CONTENTS}) -string(REPLACE "RELEASE \"\${SOFA_LIB_DIR}" "RELEASE \"\${SOFA_LIB_DIR}/Release" CONTENTS ${CONTENTS}) -string(REPLACE "RELWITHDEBINFO \"\${SOFA_LIB_DIR}" "RELWITHDEBINFO \"\${SOFA_LIB_DIR}/RelWithDebInfo" CONTENTS ${CONTENTS}) -string(REPLACE "MINSIZEREL \"\${SOFA_LIB_DIR}" "MINSIZEREL \"\${SOFA_LIB_DIR}/MinSizeRel" CONTENTS ${CONTENTS}) + +# Set CMake policies to prevent configure warnings + +string(REPLACE "set(SOLUTION_NAME" "cmake_policy(SET CMP0039 OLD) +cmake_policy(SET CMP0043 OLD) +cmake_policy(SET CMP0054 OLD) + +set(SOLUTION_NAME" +CONTENTS ${CONTENTS}) + +# Use configure file (see below) + +string(REPLACE "\nendif()" "\nendif()\n\nconfigure_file(SOFAConfig.cmake.in SOFAConfig.cmake @ONLY)" CONTENTS ${CONTENTS}) + configure_file(${TEMPLATE_FILE} ${path} @ONLY) # Create SOFAConfig.cmake.in file to make SOFA findable through the config mode # of find_package() -file(APPEND "CMakeLists.txt" "\nconfigure_file(SOFAConfig.cmake.in SOFAConfig.cmake @ONLY)\n") - file(WRITE "SOFAConfig.cmake.in" -"add_definitions(-DSOFA_XML_PARSER_TINYXML;-DTIXML_USE_STL;-DMINI_FLOWVR;-DSOFA_HAVE_BOOST;-DSOFA_HAVE_CSPARSE;-DSOFA_HAVE_EIGEN2;-DSOFA_HAVE_FREEGLUT;-DSOFA_HAVE_GLEW;-DSOFA_HAVE_METIS) +"add_definitions(-DSOFA_XML_PARSER_TINYXML;-DTIXML_USE_STL;-DMINI_FLOWVR;-DSOFA_HAVE_BOOST;-DSOFA_HAVE_CSPARSE;-DSOFA_HAVE_DAG;-DSOFA_HAVE_EIGEN2;-DSOFA_HAVE_FREEGLUT;-DSOFA_HAVE_GLEW;-DSOFA_HAVE_METIS) -set(SOFA_INCLUDE_DIRS \"@SOFA_EXTLIBS_DIR@/csparse;@SOFA_EXTLIBS_DIR@/eigen-3.2.0;@SOFA_EXTLIBS_DIR@/metis-5.1.0/include;@SOFA_EXTLIBS_DIR@/miniFlowVR/include;@SOFA_EXTLIBS_DIR@/newmat;@SOFA_EXTLIBS_DIR@/tinyxml;@SOFA_SRC_DIR@/framework;@SOFA_SRC_DIR@/modules\") +set(SOFA_INCLUDE_DIRS \"@SOFA_EXTLIBS_DIR@/csparse;@SOFA_EXTLIBS_DIR@/eigen-3.2.1;@SOFA_EXTLIBS_DIR@/metis-5.1.0/include;@SOFA_EXTLIBS_DIR@/miniFlowVR/include;@SOFA_EXTLIBS_DIR@/newmat;@SOFA_EXTLIBS_DIR@/tinyxml;@SOFA_SRC_DIR@/framework;@SOFA_SRC_DIR@/modules\") if(WIN32) set(SOFA_LIBRARY_DIRS \"@SOFA_LIB_DIR@\") set(version \"_1_0\") else() set(SOFA_LIBRARY_DIRS \"@SOFA_LIB_DIR@/@CMAKE_BUILD_TYPE@\") set(version \"\") endif() set(SOFA_LIBRARIES debug SofaBaseAnimationLoop\${version}d optimized SofaBaseAnimationLoop\${version} debug SofaBaseCollision\${version}d optimized SofaBaseCollision\${version} debug SofaBaseLinearSolver\${version}d optimized SofaBaseLinearSolver\${version} debug SofaBaseMechanics\${version}d optimized SofaBaseMechanics\${version} debug SofaBaseTopology\${version}d optimized SofaBaseTopology\${version} debug SofaBaseVisual\${version}d optimized SofaBaseVisual\${version} debug SofaBoundaryCondition\${version}d optimized SofaBoundaryCondition\${version} debug SofaComponentAdvanced\${version}d optimized SofaComponentAdvanced\${version} debug SofaComponentBase\${version}d optimized SofaComponentBase\${version} debug SofaComponentCommon\${version}d optimized SofaComponentCommon\${version} debug SofaComponentGeneral\${version}d optimized SofaComponentGeneral\${version} debug SofaComponentMain\${version}d optimized SofaComponentMain\${version} debug SofaComponentMisc\${version}d optimized SofaComponentMisc\${version} debug SofaConstraint\${version}d optimized SofaConstraint\${version} debug SofaCore\${version}d optimized SofaCore\${version} debug SofaDefaultType\${version}d optimized SofaDefaultType\${version} debug SofaDeformable\${version}d optimized SofaDeformable\${version} debug SofaDenseSolver\${version}d optimized SofaDenseSolver\${version} debug SofaEigen2Solver\${version}d optimized SofaEigen2Solver\${version} debug SofaEngine\${version}d optimized SofaEngine\${version} debug SofaEulerianFluid\${version}d optimized SofaEulerianFluid\${version} debug SofaExplicitOdeSolver\${version}d optimized SofaExplicitOdeSolver\${version} debug SofaExporter\${version}d optimized SofaExporter\${version} debug SofaGraphComponent\${version}d optimized SofaGraphComponent\${version} debug SofaHaptics\${version}d optimized SofaHaptics\${version} debug SofaHelper\${version}d optimized SofaHelper\${version} debug SofaImplicitOdeSolver\${version}d optimized SofaImplicitOdeSolver\${version} debug SofaLoader\${version}d optimized SofaLoader\${version} debug SofaMeshCollision\${version}d optimized SofaMeshCollision\${version} debug SofaMisc\${version}d optimized SofaMisc\${version} debug SofaMiscCollision\${version}d optimized SofaMiscCollision\${version} debug SofaMiscEngine\${version}d optimized SofaMiscEngine\${version} debug SofaMiscFem\${version}d optimized SofaMiscFem\${version} debug SofaMiscForceField\${version}d optimized SofaMiscForceField\${version} debug SofaMiscMapping\${version}d optimized SofaMiscMapping\${version} debug SofaMiscSolver\${version}d optimized SofaMiscSolver\${version} debug SofaMiscTopology\${version}d optimized SofaMiscTopology\${version} debug SofaNonUniformFem\${version}d optimized SofaNonUniformFem\${version} debug SofaObjectInteraction\${version}d optimized SofaObjectInteraction\${version} debug SofaOpenglVisual\${version}d optimized SofaOpenglVisual\${version} debug SofaPreconditioner\${version}d optimized SofaPreconditioner\${version} debug SofaRigid\${version}d optimized SofaRigid\${version} debug SofaSimpleFem\${version}d optimized SofaSimpleFem\${version} debug SofaSimulationCommon\${version}d optimized SofaSimulationCommon\${version} + debug SofaSimulationGraph\${version}d optimized SofaSimulationGraph\${version} debug SofaSimulationTree\${version}d optimized SofaSimulationTree\${version} debug SofaSparseSolver\${version}d optimized SofaSparseSolver\${version} debug SofaSphFluid\${version}d optimized SofaSphFluid\${version} debug SofaTopologyMapping\${version}d optimized SofaTopologyMapping\${version} debug SofaUserInteraction\${version}d optimized SofaUserInteraction\${version} debug SofaValidation\${version}d optimized SofaValidation\${version} debug SofaVolumetricData\${version}d optimized SofaVolumetricData\${version} debug SofaTinyXml\${version}d optimized SofaTinyXml\${version} )") diff --git a/CMakeExternals/SOFA.cmake b/CMakeExternals/SOFA.cmake index 78974ecf1a..f34f4e4b14 100644 --- a/CMakeExternals/SOFA.cmake +++ b/CMakeExternals/SOFA.cmake @@ -1,100 +1,99 @@ #----------------------------------------------------------------------------- # SOFA #----------------------------------------------------------------------------- if(MITK_USE_SOFA) # Sanity checks if(DEFINED SOFA_DIR AND NOT EXISTS ${SOFA_DIR}) message(FATAL_ERROR "SOFA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj SOFA) set(proj_DEPENDENCIES Boost GLEW) set(SOFA_DEPENDS ${proj}) set(preconfigure_cmake_args -DGLEW_DIR:PATH=${GLEW_DIR} + -DSOFA-APPLICATION_GENERATERIGID:BOOL=OFF -DSOFA-APPLICATION_MODELER:BOOL=OFF -DSOFA-APPLICATION_RUNSOFA:BOOL=OFF - -DSOFA-APPLICATION_SOFABATCH:BOOL=OFF -DSOFA-EXTERNAL_BOOST:BOOL=ON -DSOFA-EXTERNAL_BOOST_PATH:PATH=${CMAKE_BINARY_DIR}/Boost-install/lib -DSOFA-EXTERNAL_CSPARSE:BOOL=ON -DSOFA-EXTERNAL_GLEW:BOOL=ON -DSOFA-EXTERNAL_PNG:BOOL=OFF -DSOFA-EXTERNAL_ZLIB:BOOL=OFF -DSOFA-LIB_COMPONENT_SPARSE_SOLVER:BOOL=ON -DSOFA-LIB_GUI_GLUT:BOOL=OFF -DSOFA-LIB_GUI_QT:BOOL=OFF -DSOFA-LIB_GUI_QTVIEWER:BOOL=OFF - -DSOFA-TUTORIAL_CHAIN_HYBRID:BOOL=OFF -DSOFA-TUTORIAL_COMPOSITE_OBJECT:BOOL=OFF -DSOFA-TUTORIAL_MIXED_PENDULUM:BOOL=OFF -DSOFA-TUTORIAL_ONE_PARTICLE:BOOL=OFF -DSOFA-TUTORIAL_ONE_TETRAHEDRON:BOOL=OFF ) if(NOT APPLE) list(APPEND proj_DEPENDENCIES GLUT) list(APPEND preconfigure_cmake_args -DSOFA-EXTERNAL_FREEGLUT:BOOL=ON -DGLUT_DIR:PATH=${GLUT_DIR} ) endif() if(NOT MITK_USE_SYSTEM_Boost) list(APPEND preconfigure_cmake_args -DBoost_NO_SYSTEM_PATHS:BOOL=ON -DBOOST_INCLUDEDIR:PATH=${CMAKE_BINARY_DIR}/Boost-install/include -DBOOST_LIBRARYDIR:PATH=${CMAKE_BINARY_DIR}/Boost-install/lib -DBoost_ADDITIONAL_VERSIONS:STRING=1.56 ) endif() if(MITK_USE_SOFA_PLUGINS_DIR) list(APPEND preconfigure_cmake_args -DSOFA_APPLICATIONS_PLUGINS_DIR:PATH=${MITK_USE_SOFA_PLUGINS_DIR} ) foreach(plugin ${MITK_USE_SOFA_PLUGINS}) string(TOUPPER ${plugin} plugin) list(APPEND preconfigure_cmake_args -DSOFA-PLUGIN_${plugin}:BOOL=ON ) endforeach() endif() - set(rev "10669") + set(rev "386a3a7") - set(SOFA_PATCH_COMMAND ${CMAKE_COMMAND} -DTEMPLATE_FILE:FILEPATH=${MITK_SOURCE_DIR}/CMakeExternals/EmptyFileForPatching.dummy -P ${MITK_SOURCE_DIR}/CMakeExternals/PatchSOFA-rev${rev}.cmake) + set(SOFA_PATCH_COMMAND ${CMAKE_COMMAND} -DTEMPLATE_FILE:FILEPATH=${MITK_SOURCE_DIR}/CMakeExternals/EmptyFileForPatching.dummy -P ${MITK_SOURCE_DIR}/CMakeExternals/PatchSOFA-${rev}.cmake) set(SOFA_PRECONFIGURE_COMMAND ${CMAKE_COMMAND} -G${gen} ${ep_common_args} ${preconfigure_cmake_args} ${boost_cmake_args} ${CMAKE_BINARY_DIR}/${proj}-src) if(NOT DEFINED SOFA_DIR) ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake - URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/SOFA-rev${rev}.tar.gz - URL_MD5 d01a194f54b933f4cdfdfc75b2f81a2f + URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/SOFA-${rev}.tar.gz + URL_MD5 31ca701e985331e96bd52d9e58842a86 PATCH_COMMAND ${SOFA_PATCH_COMMAND} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} DEPENDS ${proj_DEPENDENCIES} ) ExternalProject_Add_Step(${proj} preconfigure COMMAND ${SOFA_PRECONFIGURE_COMMAND} WORKING_DIRECTORY ${proj}-build DEPENDEES patch DEPENDERS configure LOG 1 ) set(SOFA_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/Modules/Simulation/CMakeLists.txt b/Modules/Simulation/CMakeLists.txt index 78ebb99392..f21ba24403 100644 --- a/Modules/Simulation/CMakeLists.txt +++ b/Modules/Simulation/CMakeLists.txt @@ -1,11 +1,8 @@ -if(MITK_USE_SOFA) - MITK_CREATE_MODULE( - DEPENDS MitkSceneSerializationBase - PACKAGE_DEPENDS Boost GLUT GLEW SOFA - ) +MITK_CREATE_MODULE( + DEPENDS MitkLegacyGL MitkSceneSerializationBase + PACKAGE_DEPENDS Boost GLUT GLEW SOFA +) - if(MSVC) - list(APPEND module_compile_flags /wd4250 4251 4267 4275) - set_target_properties(${MODULE_TARGET} PROPERTIES COMPILE_FLAGS "${module_compile_flags}") - endif() +if(MITK_USE_SOFA AND MSVC) + set_property(TARGET ${MODULE_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4068 /wd4250 /wd4251 /wd4267 /wd4275") endif() diff --git a/Modules/Simulation/files.cmake b/Modules/Simulation/files.cmake index 7f49b08378..21cf69321b 100644 --- a/Modules/Simulation/files.cmake +++ b/Modules/Simulation/files.cmake @@ -1,30 +1,32 @@ set(CPP_FILES mitkGetSimulationService.cpp mitkExportMitkVisitor.cpp mitkIndexROI.cpp mitkISimulationService.cpp + mitkPlaneIntersectionVisitor.cpp mitkRoundRobinSchedulingAlgorithm.cpp mitkSetVtkRendererVisitor.cpp mitkSchedulableProcess.cpp mitkScheduler.cpp mitkSchedulingAlgorithmBase.cpp mitkSimulation.cpp mitkSimulationActivator.cpp + mitkSimulationGLMapper2D.cpp mitkSimulationInteractor.cpp mitkSimulationIOFactory.cpp mitkSimulationObjectFactory.cpp mitkSimulationReader.cpp mitkSimulationSerializer.cpp mitkSimulationService.cpp mitkSimulationVtkMapper3D.cpp mitkSimulationWriter.cpp mitkSimulationWriterFactory.cpp mitkVtkModel.cpp mitkVtkSimulationPolyDataMapper.cpp mitkWeightedRoundRobinSchedulingAlgorithm.cpp ) set(RESOURCE_FILES Interactions/Simulation.xml Interactions/SimulationConfig.xml ) diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp b/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp new file mode 100644 index 0000000000..8dda8304bd --- /dev/null +++ b/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp @@ -0,0 +1,203 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkPlaneIntersectionVisitor.h" +#include + +mitk::PlaneIntersectionVisitor::PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params) + : Visitor(params), + m_Point(point), + m_Normal(normal) +{ +} + +mitk::PlaneIntersectionVisitor::~PlaneIntersectionVisitor() +{ +} + +const std::vector& mitk::PlaneIntersectionVisitor::GetIntersections() const +{ + return m_Intersections; +} + +sofa::simulation::Visitor::Result mitk::PlaneIntersectionVisitor::processNodeTopDown(sofa::simulation::Node* node) +{ + for_each(this, node, node->visualModel, &PlaneIntersectionVisitor::processVisualModel); + return RESULT_CONTINUE; +} + +void mitk::PlaneIntersectionVisitor::processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel) +{ + using sofa::component::visualmodel::VisualModelImpl; + using sofa::core::topology::Triangle; + using sofa::core::topology::Quad; + using sofa::defaulttype::ResizableExtVector; + + typedef VisualModelImpl::VecCoord VecCoord; + + VisualModelImpl* visualModelImpl = dynamic_cast(visualModel); + + if (visualModelImpl == NULL) + return; + + const sofa::core::loader::Material& material = visualModelImpl->material.getValue(); + + if (!material.useDiffuse) + return; + + const VecCoord& verts = visualModelImpl->getVertices(); + const ResizableExtVector& tris = visualModelImpl->getTriangles(); + const ResizableExtVector& quads = visualModelImpl->getQuads(); + + float n[3] = { static_cast(m_Normal[0]), static_cast(m_Normal[1]), static_cast(m_Normal[2]) }; + float p[3] = { static_cast(m_Point[0]), static_cast(m_Point[1]), static_cast(m_Point[2]) }; + float d[4]; + int j; + const float* t0; + const float* t1; + const float* t2; + float s; + Edge edge; + Intersection intersection; + + const size_t numTriangles = tris.size(); + + for (size_t i = 0; i < numTriangles; ++i) + { + t0 = verts[tris[i][0]].data(); + t1 = verts[tris[i][1]].data(); + t2 = verts[tris[i][2]].data(); + + d[0] = n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2]); + d[1] = n[0] * (p[0] - t1[0]) + n[1] * (p[1] - t1[1]) + n[2] * (p[2] - t1[2]); + d[2] = n[0] * (p[0] - t2[0]) + n[1] * (p[1] - t2[1]) + n[2] * (p[2] - t2[2]); + + if (d[0] * d[1] < 0.0f) + { + j = d[0] * d[2] < 0.0f + ? 0 + : 1; + } + else if (d[0] * d[2] < 0.0f) + { + j = 2; + } + else + { + continue; + } + + t0 = verts[tris[i][j]].data(); + t1 = verts[tris[i][(j + 1) % 3]].data(); + t2 = verts[tris[i][(j + 2) % 3]].data(); + + s = (n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2])) / (n[0] * (t1[0] - t0[0]) + n[1] * (t1[1] - t0[1]) + n[2] * (t1[2] - t0[2])); + + edge.v0[0] = static_cast(t0[0] + s * (t1[0] - t0[0])); + edge.v0[1] = static_cast(t0[1] + s * (t1[1] - t0[1])); + edge.v0[2] = static_cast(t0[2] + s * (t1[2] - t0[2])); + + s = (n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2])) / (n[0] * (t2[0] - t0[0]) + n[1] * (t2[1] - t0[1]) + n[2] * (t2[2] - t0[2])); + + edge.v1[0] = static_cast(t0[0] + s * (t2[0] - t0[0])); + edge.v1[1] = static_cast(t0[1] + s * (t2[1] - t0[1])); + edge.v1[2] = static_cast(t0[2] + s * (t2[2] - t0[2])); + + intersection.edges.push_back(edge); + } + + const float* q0; + const float* q1; + const float* q2; + const float* q3; + + const size_t numQuads = quads.size(); + + for (size_t i = 0; i < numQuads; ++i) + { + q0 = verts[quads[i][0]].data(); + q1 = verts[quads[i][1]].data(); + q2 = verts[quads[i][2]].data(); + q3 = verts[quads[i][3]].data(); + + d[0] = n[0] * (p[0] - q0[0]) + n[1] * (p[1] - q0[1]) + n[2] * (p[2] - q0[2]); + d[1] = n[0] * (p[0] - q1[0]) + n[1] * (p[1] - q1[1]) + n[2] * (p[2] - q1[2]); + d[2] = n[0] * (p[0] - q2[0]) + n[1] * (p[1] - q2[1]) + n[2] * (p[2] - q2[2]); + d[3] = n[0] * (p[0] - q3[0]) + n[1] * (p[1] - q3[1]) + n[2] * (p[2] - q3[2]); + + if (d[0] * d[2] < 0.0f) + { + if (d[0] * d[3] < 0.0f) + { + if (d[0] * d[1] < 0.0f) + { + q2 = q0; + } + else + { + const float* q = q0; + q0 = q1; + q1 = q2; + q2 = q; + } + } + else if (d[0] * d[1] >= 0.0f) + { + q0 = q1; + q1 = q2; + } + } + else if (d[1] * d[3] < 0.0f) + { + if (d[1] * d[0] < 0.0f) + { + q3 = q2; + q2 = q1; + } + else + { + q1 = q3; + } + } + else + { + continue; + } + + s = (n[0] * (p[0] - q0[0]) + n[1] * (p[1] - q0[1]) + n[2] * (p[2] - q0[2])) / (n[0] * (q1[0] - q0[0]) + n[1] * (q1[1] - q0[1]) + n[2] * (q1[2] - q0[2])); + + edge.v0[0] = static_cast(q0[0] + s * (q1[0] - q0[0])); + edge.v0[1] = static_cast(q0[1] + s * (q1[1] - q0[1])); + edge.v0[2] = static_cast(q0[2] + s * (q1[2] - q0[2])); + + s = (n[0] * (p[0] - q2[0]) + n[1] * (p[1] - q2[1]) + n[2] * (p[2] - q2[2])) / (n[0] * (q3[0] - q2[0]) + n[1] * (q3[1] - q2[1]) + n[2] * (q3[2] - q2[2])); + + edge.v1[0] = static_cast(q2[0] + s * (q3[0] - q2[0])); + edge.v1[1] = static_cast(q2[1] + s * (q3[1] - q2[1])); + edge.v1[2] = static_cast(q2[2] + s * (q3[2] - q2[2])); + + intersection.edges.push_back(edge); + } + + if (!intersection.edges.empty()) + { + intersection.color[0] = static_cast(material.diffuse[0]); + intersection.color[1] = static_cast(material.diffuse[1]); + intersection.color[2] = static_cast(material.diffuse[2]); + + m_Intersections.push_back(intersection); + } +} diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.h b/Modules/Simulation/mitkPlaneIntersectionVisitor.h new file mode 100644 index 0000000000..52ff75e1e3 --- /dev/null +++ b/Modules/Simulation/mitkPlaneIntersectionVisitor.h @@ -0,0 +1,62 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef mitkPlaneIntersectionVisitor_h +#define mitkPlaneIntersectionVisitor_h + +#include +#include +#include +#include + +namespace mitk +{ + class MitkSimulation_EXPORT PlaneIntersectionVisitor : public sofa::simulation::Visitor + { + public: + struct Edge + { + Point3D v0; + Point3D v1; + }; + + struct Intersection + { + ScalarType color[3]; + std::vector edges; + }; + + PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); + ~PlaneIntersectionVisitor(); + + const std::vector& GetIntersections() const; + + Result processNodeTopDown(sofa::simulation::Node* node); + + private: + PlaneIntersectionVisitor(const PlaneIntersectionVisitor&); + PlaneIntersectionVisitor& operator=(const PlaneIntersectionVisitor&); + + void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); + + Point3D m_Point; + Vector3D m_Normal; + + std::vector m_Intersections; + }; +} + +#endif diff --git a/Modules/Simulation/mitkSimulation.cpp b/Modules/Simulation/mitkSimulation.cpp index 99f7518c1c..3c815459f6 100644 --- a/Modules/Simulation/mitkSimulation.cpp +++ b/Modules/Simulation/mitkSimulation.cpp @@ -1,169 +1,169 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSimulation.h" -#include +#include #include "mitkGeometry3D.h" static sofa::simulation::Simulation::SPtr CreateSimulation() { const std::string key = "MultiMappingObject"; if (sofa::simulation::xml::BaseElement::NodeFactory::HasKey(key)) sofa::simulation::xml::BaseElement::NodeFactory::ResetEntry(key); - return sofa::core::objectmodel::New(); + return sofa::core::objectmodel::New(); } mitk::Simulation::Simulation() : m_SOFASimulation(CreateSimulation()) { } mitk::Simulation::~Simulation() { if (m_RootNode) { if (m_SOFASimulation) m_SOFASimulation->unload(m_RootNode); } } void mitk::Simulation::Animate() { if (!m_RootNode || !m_SOFASimulation) return; boost::chrono::high_resolution_clock::time_point t0 = boost::chrono::high_resolution_clock::now(); m_SOFASimulation->animate(m_RootNode.get(), m_RootNode->getDt()); this->SetElapsedTime(boost::chrono::high_resolution_clock::now() - t0); this->UpdateOutputInformation(); } sofa::core::visual::DrawTool* mitk::Simulation::GetDrawTool() { return &m_DrawTool; } sofa::simulation::Node::SPtr mitk::Simulation::GetRootNode() const { return m_RootNode; } sofa::simulation::Simulation::SPtr mitk::Simulation::GetSOFASimulation() const { return m_SOFASimulation; } void mitk::Simulation::Reset() { if (!m_RootNode || !m_SOFASimulation) return; m_SOFASimulation->reset(m_RootNode.get()); m_RootNode->setTime(0.0); m_SOFASimulation->updateContext(m_RootNode.get()); } bool mitk::Simulation::GetAnimationFlag() const { return m_RootNode ? m_RootNode->getContext()->getAnimate() : false; } void mitk::Simulation::SetAnimationFlag(bool animate) { if (m_RootNode) m_RootNode->getContext()->setAnimate(animate); } void mitk::Simulation::SetDt(double dt) { if (m_RootNode) m_RootNode->setDt(dt); } void mitk::Simulation::SetRootNode(sofa::simulation::Node::SPtr rootNode) { m_RootNode = rootNode; } bool mitk::Simulation::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } void mitk::Simulation::SetRequestedRegion(const itk::DataObject*) { } void mitk::Simulation::SetRequestedRegionToLargestPossibleRegion() { } void mitk::Simulation::UpdateOutputInformation() { using sofa::defaulttype::BoundingBox; using sofa::defaulttype::Vector3; if (this->GetSource().IsNotNull()) this->GetSource()->UpdateOutputInformation(); if (m_RootNode) { const BoundingBox& boundingBox = m_RootNode->f_bbox.getValue(); mitk::Geometry3D::BoundsArrayType bounds; if (boundingBox.isValid()) { const Vector3& min = boundingBox.minBBox(); const Vector3& max = boundingBox.maxBBox(); bounds[0] = static_cast(min.x()); bounds[1] = static_cast(max.x()); bounds[2] = static_cast(min.y()); bounds[3] = static_cast(max.y()); bounds[4] = static_cast(min.z()); bounds[5] = static_cast(max.z()); } else { bounds.Fill(0.0f); } mitk::BaseGeometry::Pointer geometry = this->GetGeometry(); if (geometry.IsNull()) { geometry = Geometry3D::New(); geometry->SetBounds(bounds); this->SetGeometry(geometry); } else { geometry->SetBounds(bounds); } } this->GetTimeGeometry()->Update(); } bool mitk::Simulation::VerifyRequestedRegion() { return true; } diff --git a/Modules/Simulation/mitkSimulationGLMapper2D.cpp b/Modules/Simulation/mitkSimulationGLMapper2D.cpp new file mode 100644 index 0000000000..c5cb00d347 --- /dev/null +++ b/Modules/Simulation/mitkSimulationGLMapper2D.cpp @@ -0,0 +1,102 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include +#include "mitkPlaneIntersectionVisitor.h" +#include "mitkSimulation.h" +#include "mitkSimulationGLMapper2D.h" + +void mitk::SimulationGLMapper2D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) +{ + if (node != NULL) + { + Superclass::SetDefaultProperties(node, renderer, overwrite); + } +} + +mitk::SimulationGLMapper2D::SimulationGLMapper2D() +{ +} + +mitk::SimulationGLMapper2D::~SimulationGLMapper2D() +{ +} + +void mitk::SimulationGLMapper2D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) +{ +} + +void mitk::SimulationGLMapper2D::Paint(BaseRenderer* renderer) +{ + typedef PlaneIntersectionVisitor::Edge Edge; + typedef PlaneIntersectionVisitor::Intersection Intersection; + + if (renderer == NULL) + return; + + SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController(); + + if (sliceNavigationController == NULL) + return; + + const PlaneGeometry* planeGeometry = sliceNavigationController->GetCurrentPlaneGeometry(); + + if (planeGeometry == NULL) + return; + + DataNode* node = this->GetDataNode(); + + if (node == NULL) + return; + + Simulation* simulation = static_cast(node->GetData()); + + if (simulation == NULL) + return; + + PlaneIntersectionVisitor planeIntersectionVisitor(planeGeometry->GetOrigin(), planeGeometry->GetNormal()); + simulation->GetRootNode()->executeVisitor(&planeIntersectionVisitor); + + mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); + Point2D point2D; + + const std::vector& intersections = planeIntersectionVisitor.GetIntersections(); + std::vector::const_iterator intersectionsEnd = intersections.end(); + + for (std::vector::const_iterator intersectionIt = intersections.begin(); intersectionIt != intersectionsEnd; ++intersectionIt) + { + const std::vector& edges = intersectionIt->edges; + std::vector::const_iterator edgesEnd = edges.end(); + + glColor3dv(intersectionIt->color); + glBegin(GL_LINES); + + for (std::vector::const_iterator edgeIt = edges.begin(); edgeIt != edgesEnd; ++edgeIt) + { + displayGeometry->Map(edgeIt->v0, point2D); + displayGeometry->WorldToDisplay(point2D, point2D); + + glVertex2dv(point2D.GetDataPointer()); + + displayGeometry->Map(edgeIt->v1, point2D); + displayGeometry->WorldToDisplay(point2D, point2D); + + glVertex2dv(point2D.GetDataPointer()); + } + + glEnd(); + } +} diff --git a/Modules/Simulation/mitkSimulationGLMapper2D.h b/Modules/Simulation/mitkSimulationGLMapper2D.h new file mode 100644 index 0000000000..b58d72974e --- /dev/null +++ b/Modules/Simulation/mitkSimulationGLMapper2D.h @@ -0,0 +1,46 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef mitkSimulationGLMapper2D_h +#define mitkSimulationGLMapper2D_h + +#include +#include + +namespace mitk +{ + class MitkSimulation_EXPORT SimulationGLMapper2D : public GLMapper + { + public: + static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false); + + mitkClassMacro(SimulationGLMapper2D, GLMapper); + itkFactorylessNewMacro(Self) + itkCloneMacro(Self) + + void ApplyColorAndOpacityProperties(BaseRenderer* renderer, vtkActor* actor = NULL); + void Paint(BaseRenderer* renderer); + + private: + SimulationGLMapper2D(); + ~SimulationGLMapper2D(); + + SimulationGLMapper2D(const Self&); + Self& operator=(const Self&); + }; +} + +#endif diff --git a/Modules/Simulation/mitkSimulationObjectFactory.cpp b/Modules/Simulation/mitkSimulationObjectFactory.cpp index 320009f7bc..630d9f1672 100644 --- a/Modules/Simulation/mitkSimulationObjectFactory.cpp +++ b/Modules/Simulation/mitkSimulationObjectFactory.cpp @@ -1,143 +1,154 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkIndexROI.h" #include "mitkSimulation.h" +#include "mitkSimulationGLMapper2D.h" #include "mitkSimulationObjectFactory.h" #include "mitkSimulationVtkMapper3D.h" #include "mitkSimulationWriter.h" #include "mitkVtkModel.h" #include +#include #include #include #include #include #include static void InitializeSofa() { int argc = 0; glutInit(&argc, NULL); sofa::component::init(); sofa::simulation::xml::initXml(); sofa::core::visual::VisualParams::defaultInstance()->setSupported(sofa::core::visual::API_OpenGL); } static void RegisterSofaClasses() { using sofa::core::ObjectFactory; using sofa::core::RegisterObject; int IndexROIClass = RegisterObject("").add(); int VtkModelClass = RegisterObject("").add(); ObjectFactory::AddAlias("VisualModel", "VtkModel", true); ObjectFactory::AddAlias("OglModel", "VtkModel", true); } mitk::SimulationObjectFactory::SimulationObjectFactory() : m_SimulationIOFactory(SimulationIOFactory::New()), m_SimulationWriterFactory(SimulationWriterFactory::New()) { itk::ObjectFactoryBase::RegisterFactory(m_SimulationIOFactory); itk::ObjectFactoryBase::RegisterFactory(m_SimulationWriterFactory); m_FileWriters.push_back(SimulationWriter::New().GetPointer()); std::string description = "SOFA Scene Files"; m_FileExtensionsMap.insert(std::pair("*.scn", description)); InitializeSofa(); RegisterSofaClasses(); } mitk::SimulationObjectFactory::~SimulationObjectFactory() { itk::ObjectFactoryBase::UnRegisterFactory(m_SimulationWriterFactory); itk::ObjectFactoryBase::UnRegisterFactory(m_SimulationIOFactory); } mitk::Mapper::Pointer mitk::SimulationObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId slotId) { Mapper::Pointer mapper; if (dynamic_cast(node->GetData()) != NULL) { - if (slotId == BaseRenderer::Standard3D) - mapper = mitk::SimulationVtkMapper3D::New(); + if (slotId == BaseRenderer::Standard2D) + { + mapper = VtkGLMapperWrapper::New(SimulationGLMapper2D::New().GetPointer()); + } + else if (slotId == BaseRenderer::Standard3D) + { + mapper = SimulationVtkMapper3D::New(); + } if (mapper.IsNotNull()) mapper->SetDataNode(node); } return mapper; } const char* mitk::SimulationObjectFactory::GetDescription() const { return "Simulation Object Factory"; } const char* mitk::SimulationObjectFactory::GetFileExtensions() { std::string fileExtensions; this->CreateFileExtensions(m_FileExtensionsMap, fileExtensions); return fileExtensions.c_str(); } mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::SimulationObjectFactory::GetITKSourceVersion() const { return ITK_SOURCE_VERSION; } const char* mitk::SimulationObjectFactory::GetSaveFileExtensions() { std::string saveFileExtensions; this->CreateFileExtensions(m_FileExtensionsMap, saveFileExtensions); return saveFileExtensions.c_str(); } mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::SimulationObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if (node == NULL) return; if (dynamic_cast(node->GetData()) != NULL) + { + SimulationGLMapper2D::SetDefaultProperties(node); SimulationVtkMapper3D::SetDefaultProperties(node); + } } void mitk::RegisterSimulationObjectFactory() { static bool alreadyRegistered = false; if (!alreadyRegistered) { - mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::SimulationObjectFactory::New()); + CoreObjectFactory::GetInstance()->RegisterExtraFactory(SimulationObjectFactory::New()); alreadyRegistered = true; } } diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp index 718e58a7ba..70ed74fbc5 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp +++ b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp @@ -1,159 +1,164 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSetVtkRendererVisitor.h" #include "mitkSimulation.h" #include "mitkSimulationVtkMapper3D.h" #include "mitkVtkSimulationPolyDataMapper.h" #include #include mitk::SimulationVtkMapper3D::LocalStorage::LocalStorage() : m_Actor(vtkSmartPointer::New()) { } mitk::SimulationVtkMapper3D::LocalStorage::~LocalStorage() { } void mitk::SimulationVtkMapper3D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) { if (node != NULL) { Simulation* simulation = dynamic_cast(node->GetData()); if (simulation != NULL) { sofa::simulation::Node::SPtr rootNode = simulation->GetRootNode(); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; rootNode->get(visualStyle); if (!visualStyle) { visualStyle = sofa::core::objectmodel::New(); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowVisualModels(); visualStyle->displayFlags.endEdit(); rootNode->addObject(visualStyle); } const sofa::core::visual::DisplayFlags& displayFlags = visualStyle->displayFlags.getValue(); node->AddProperty("Simulation.Behavior.Behavior Models", BoolProperty::New(displayFlags.getShowBehaviorModels()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Force Fields", BoolProperty::New(displayFlags.getShowForceFields()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Interactions", BoolProperty::New(displayFlags.getShowInteractionForceFields()), renderer, overwrite); node->AddProperty("Simulation.Collision.Bounding Trees", BoolProperty::New(displayFlags.getShowBoundingCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Collision.Collision Models", BoolProperty::New(displayFlags.getShowCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Mechanical Mappings", BoolProperty::New(displayFlags.getShowMechanicalMappings()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Visual Mappings", BoolProperty::New(displayFlags.getShowMappings()), renderer, overwrite); node->AddProperty("Simulation.Options.Normals", BoolProperty::New(displayFlags.getShowNormals()), renderer, overwrite); node->AddProperty("Simulation.Options.Wire Frame", BoolProperty::New(displayFlags.getShowWireFrame()), renderer, overwrite); node->AddProperty("Simulation.Visual.Visual Models", BoolProperty::New(displayFlags.getShowVisualModels() != sofa::core::visual::tristate::false_value), renderer, overwrite); } Superclass::SetDefaultProperties(node, renderer, overwrite); } } mitk::SimulationVtkMapper3D::SimulationVtkMapper3D() { } mitk::SimulationVtkMapper3D::~SimulationVtkMapper3D() { } void mitk::SimulationVtkMapper3D::ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*) { } void mitk::SimulationVtkMapper3D::ApplySimulationProperties(BaseRenderer* renderer) { DataNode* node = this->GetDataNode(); bool showBehaviorModels; bool showForceFields; bool showInteractionForceFields; bool showBoundingCollisionModels; bool showCollisionModels; bool showMechanicalMappings; bool showMappings; bool showNormals; bool showWireFrame; bool showVisualModels; node->GetBoolProperty("Simulation.Behavior.Behavior Models", showBehaviorModels, renderer); node->GetBoolProperty("Simulation.Behavior.Force Fields", showForceFields, renderer); node->GetBoolProperty("Simulation.Behavior.Interactions", showInteractionForceFields, renderer); node->GetBoolProperty("Simulation.Collision.Bounding Trees", showBoundingCollisionModels, renderer); node->GetBoolProperty("Simulation.Collision.Collision Models", showCollisionModels, renderer); node->GetBoolProperty("Simulation.Mapping.Mechanical Mappings", showMechanicalMappings, renderer); node->GetBoolProperty("Simulation.Mapping.Visual Mappings", showMappings, renderer); node->GetBoolProperty("Simulation.Options.Normals", showNormals, renderer); node->GetBoolProperty("Simulation.Options.Wire Frame", showWireFrame, renderer); node->GetBoolProperty("Simulation.Visual.Visual Models", showVisualModels, renderer); Simulation* simulation = static_cast(this->GetData()); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; simulation->GetRootNode()->get(visualStyle); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowBehaviorModels(showBehaviorModels); displayFlags->setShowForceFields(showForceFields); displayFlags->setShowInteractionForceFields(showInteractionForceFields); displayFlags->setShowBoundingCollisionModels(showBoundingCollisionModels); displayFlags->setShowCollisionModels(showCollisionModels); displayFlags->setShowMechanicalMappings(showMechanicalMappings); displayFlags->setShowMappings(showMappings); displayFlags->setShowNormals(showNormals); displayFlags->setShowWireFrame(showWireFrame); displayFlags->setShowVisualModels(showVisualModels); visualStyle->displayFlags.endEdit(); } void mitk::SimulationVtkMapper3D::GenerateDataForRenderer(BaseRenderer* renderer) { - Simulation* simulation = static_cast(this->GetData()); + DataNode* dataNode = this->GetDataNode(); - if (simulation != NULL) - { - LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); + if (dataNode == NULL) + return; - if (localStorage->m_Mapper == NULL) - { - localStorage->m_Mapper = vtkSmartPointer::New(); - localStorage->m_Mapper->SetSimulation(simulation); + Simulation* simulation = dynamic_cast(dataNode->GetData()); - localStorage->m_Actor->SetMapper(localStorage->m_Mapper); + if (simulation == NULL) + return; - SetVtkRendererVisitor initVisitor(renderer->GetVtkRenderer()); - simulation->GetRootNode()->executeVisitor(&initVisitor); - } + LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); - this->ApplySimulationProperties(renderer); + if (localStorage->m_Mapper == NULL) + { + localStorage->m_Mapper = vtkSmartPointer::New(); + localStorage->m_Mapper->SetSimulation(simulation); + + localStorage->m_Actor->SetMapper(localStorage->m_Mapper); + + SetVtkRendererVisitor setVtkRendererVisitor(renderer->GetVtkRenderer()); + simulation->GetRootNode()->executeVisitor(&setVtkRendererVisitor); } + + this->ApplySimulationProperties(renderer); } vtkProp* mitk::SimulationVtkMapper3D::GetVtkProp(BaseRenderer* renderer) { return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; } diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.h b/Modules/Simulation/mitkSimulationVtkMapper3D.h index 980c69ec1e..cf570eca70 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.h +++ b/Modules/Simulation/mitkSimulationVtkMapper3D.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkSimulationVtkMapper3D_h #define mitkSimulationVtkMapper3D_h #include #include #include namespace mitk { class vtkSimulationPolyDataMapper; class MitkSimulation_EXPORT SimulationVtkMapper3D : public VtkMapper { - class LocalStorage + class LocalStorage : public Mapper::BaseLocalStorage { public: LocalStorage(); ~LocalStorage(); vtkSmartPointer m_Mapper; vtkSmartPointer m_Actor; private: LocalStorage(const LocalStorage&); LocalStorage& operator=(const LocalStorage&); }; public: static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false); mitkClassMacro(SimulationVtkMapper3D, VtkMapper); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*); void ApplySimulationProperties(BaseRenderer* renderer); vtkProp* GetVtkProp(BaseRenderer* renderer); protected: void GenerateDataForRenderer(BaseRenderer* renderer); private: SimulationVtkMapper3D(); ~SimulationVtkMapper3D(); SimulationVtkMapper3D(const Self&); Self& operator=(const Self&); LocalStorageHandler m_LocalStorageHandler; }; } #endif diff --git a/Modules/Simulation/mitkVtkModel.h b/Modules/Simulation/mitkVtkModel.h index 277602e9af..ebac847699 100644 --- a/Modules/Simulation/mitkVtkModel.h +++ b/Modules/Simulation/mitkVtkModel.h @@ -1,70 +1,72 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkVtkModel_h #define mitkVtkModel_h +#include +#include #include #include #include #include class vtkOpenGLTexture; class vtkRenderer; namespace mitk { class MitkSimulation_EXPORT VtkModel : public sofa::component::visualmodel::VisualModelImpl { public: SOFA_CLASS(VtkModel, sofa::component::visualmodel::VisualModelImpl); void internalDraw(const sofa::core::visual::VisualParams* vparams, bool transparent); bool loadTextures(); void SetVtkRenderer(vtkRenderer* renderer); void updateBuffers(); private: static bool IsGlewInitialized; VtkModel(); ~VtkModel(); VtkModel(MyType&); MyType& operator=(const MyType&); void CreateIndexBuffer(); void CreateVertexBuffer(); void DrawGroup(int group, bool); void DrawGroups(bool transparent); void DrawNormals(); void InitIndexBuffer(); void InitVertexBuffer(); void UpdateIndexBuffer(); void UpdateVertexBuffer(); bool m_BuffersCreated; size_t m_LastNumberOfVertices; size_t m_LastNumberOfTriangles; size_t m_LastNumberOfQuads; GLuint m_VertexBuffer; GLuint m_IndexBuffer; std::map > m_Textures; vtkRenderer* m_VtkRenderer; }; } #endif diff --git a/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt b/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt index 12c8c7349f..7eef273ffb 100644 --- a/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt @@ -1,11 +1,11 @@ project(org_mitk_gui_qt_simulation) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE SIMULATION_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDS MitkQtWidgets MitkSimulation ) if(MSVC) - set_property(TARGET ${PLUGIN_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4250 /wd4251 /wd4267 /wd4275") -endif() \ No newline at end of file + set_property(TARGET ${PLUGIN_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4068 /wd4250 /wd4251 /wd4267 /wd4275") +endif() diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp index 07b79e9e8b..b211057ad4 100644 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp +++ b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp @@ -1,301 +1,267 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "org_mitk_gui_qt_simulation_Activator.h" #include "QmitkBaseItemDelegate.h" #include "QmitkNoEditItemDelegate.h" #include "QmitkSimulationView.h" #include #include #include #include #include template static T* GetService() { ctkPluginContext* context = mitk::org_mitk_gui_qt_simulation_Activator::GetContext(); if (context == NULL) return NULL; ctkServiceReference serviceReference = context->getServiceReference(); return serviceReference ? context->getService(serviceReference) : NULL; } static mitk::SimulationInteractor::Pointer CreateSimulationInteractor() { const us::Module* simulationModule = us::ModuleRegistry::GetModule("MitkSimulation"); mitk::SimulationInteractor::Pointer interactor = mitk::SimulationInteractor::New(); interactor->LoadStateMachine("Simulation.xml", simulationModule); interactor->SetEventConfig("SimulationConfig.xml", simulationModule); return interactor; } QmitkSimulationView::QmitkSimulationView() : m_SimulationService(GetService()), m_Interactor(CreateSimulationInteractor()), m_Timer(this) { this->GetDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1(this, &QmitkSimulationView::OnNodeRemovedFromDataStorage)); connect(&m_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout())); } QmitkSimulationView::~QmitkSimulationView() { this->GetDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1(this, &QmitkSimulationView::OnNodeRemovedFromDataStorage)); } void QmitkSimulationView::CreateQtPartControl(QWidget* parent) { m_Controls.setupUi(parent); m_Controls.simulationComboBox->SetDataStorage(this->GetDataStorage()); m_Controls.simulationComboBox->SetPredicate(mitk::NodePredicateDataType::New("Simulation")); connect(m_Controls.simulationComboBox, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnSelectedSimulationChanged(const mitk::DataNode*))); connect(m_Controls.animateButton, SIGNAL(toggled(bool)), this, SLOT(OnAnimateButtonToggled(bool))); connect(m_Controls.stepButton, SIGNAL(clicked()), this, SLOT(OnStepButtonClicked())); connect(m_Controls.resetButton, SIGNAL(clicked()), this, SLOT(OnResetButtonClicked())); connect(m_Controls.dtSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnDtChanged(double))); connect(m_Controls.sceneTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnSelectedBaseChanged())); - connect(m_Controls.pushButton, SIGNAL(clicked()), this, SLOT(OnButtonClicked())); if (m_Controls.simulationComboBox->GetSelectedNode().IsNotNull()) { this->OnSelectedSimulationChanged(m_Controls.simulationComboBox->GetSelectedNode()); } else { this->SetSimulationControlsEnabled(false); } } void QmitkSimulationView::OnAnimateButtonToggled(bool toggled) { mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); if (toggled) { mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); simulation->SetAnimationFlag(true); scheduler->AddProcess(simulation); m_Controls.stepButton->setEnabled(false); } else if (m_Selection.IsNotNull()) { mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); scheduler->RemoveProcess(simulation); simulation->SetAnimationFlag(false); m_Controls.stepButton->setEnabled(true); } if (!scheduler->IsEmpty()) { if (!m_Timer.isActive()) m_Timer.start(0); } else { m_Timer.stop(); } } void QmitkSimulationView::OnDtChanged(double dt) { if (m_Selection.IsNull()) return; mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); simulation->SetDt(std::max(0.0, dt)); } void QmitkSimulationView::OnNodeRemovedFromDataStorage(const mitk::DataNode* node) { mitk::Simulation::Pointer simulation = dynamic_cast(node->GetData()); if (simulation.IsNotNull()) { mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); scheduler->RemoveProcess(simulation); if (scheduler->IsEmpty() && m_Timer.isActive()) m_Timer.stop(); if (m_SimulationService->GetActiveSimulation() == simulation) m_SimulationService->SetActiveSimulation(NULL); } } void QmitkSimulationView::OnResetButtonClicked() { mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); m_SimulationService->SetActiveSimulation(simulation); m_Controls.dtSpinBox->setValue(simulation->GetRootNode()->getDt()); simulation->Reset(); - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS); + this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); } void QmitkSimulationView::OnSelectedSimulationChanged(const mitk::DataNode* node) { if (node != NULL) { m_Selection = m_Controls.simulationComboBox->GetSelectedNode(); mitk::Simulation* simulation = static_cast(m_Selection->GetData()); m_Controls.animateButton->setChecked(simulation->GetAnimationFlag()); m_Controls.dtSpinBox->setValue(simulation->GetRootNode()->getDt()); this->SetSimulationControlsEnabled(true); } else { m_Selection = NULL; this->SetSimulationControlsEnabled(false); m_Controls.animateButton->setChecked(false); m_Controls.dtSpinBox->setValue(0.0); } m_Interactor->SetDataNode(m_Selection); this->ResetSceneTreeWidget(); } void QmitkSimulationView::OnSelectedBaseChanged() { QList selectedBaseItems = m_Controls.sceneTreeWidget->selectedItems(); m_Controls.baseTreeWidget->OnSelectedBaseChanged(!selectedBaseItems.isEmpty() ? m_Controls.sceneTreeWidget->GetBaseFromItem(selectedBaseItems[0]) : NULL); } void QmitkSimulationView::OnStep(bool renderWindowUpdate) { mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); mitk::Simulation::Pointer simulation = dynamic_cast(scheduler->GetNextProcess()); m_SimulationService->SetActiveSimulation(simulation); if (simulation.IsNotNull()) simulation->Animate(); if (renderWindowUpdate) - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS); + this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); } void QmitkSimulationView::OnStepButtonClicked() { if (m_Selection.IsNull()) return; mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); m_SimulationService->SetActiveSimulation(simulation); simulation->Animate(); - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS); + this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); } void QmitkSimulationView::OnTimeout() { QTime currentTime = QTime::currentTime(); if (currentTime.msecsTo(m_NextRenderWindowUpdate) > 0) { this->OnStep(false); } else { m_NextRenderWindowUpdate = currentTime.addMSecs(MSecsPerFrame); this->OnStep(true); } } void QmitkSimulationView::ResetSceneTreeWidget() { m_Controls.sceneTreeWidget->clear(); if (m_Selection.IsNull()) return; mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); m_Controls.sceneTreeWidget->addChild(NULL, simulation->GetRootNode().get()); m_Controls.sceneTreeWidget->expandItem(m_Controls.sceneTreeWidget->topLevelItem(0)); } void QmitkSimulationView::SetSimulationControlsEnabled(bool enabled) { m_Controls.animateButton->setEnabled(enabled); m_Controls.stepButton->setEnabled(enabled); m_Controls.resetButton->setEnabled(enabled); m_Controls.dtLabel->setEnabled(enabled); m_Controls.dtSpinBox->setEnabled(enabled); } void QmitkSimulationView::SetFocus() { m_Controls.animateButton->setFocus(); } - -void QmitkSimulationView::OnButtonClicked() -{ -} - -/*#include -#include -#include -#include -#include - -void QmitkSimulationView::OnButtonClicked() -{ - vtkRenderWindow* renderWindow = this->GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetVtkRenderWindow(); - - vtkSmartPointer windowToImageFilter = vtkSmartPointer::New(); - - windowToImageFilter->SetInput(renderWindow); - windowToImageFilter->SetInputBufferTypeToZBuffer(); - - vtkSmartPointer imageShiftScaleFilter = vtkSmartPointer::New(); - - imageShiftScaleFilter->SetInputConnection(windowToImageFilter->GetOutputPort()); - imageShiftScaleFilter->SetOutputScalarTypeToUnsignedChar(); - imageShiftScaleFilter->SetShift(0); - imageShiftScaleFilter->SetScale(-255); - - vtkSmartPointer pngWriter = vtkSmartPointer::New(); - - pngWriter->SetInputConnection(imageShiftScaleFilter->GetOutputPort()); - pngWriter->SetFileName("C:\\Users\\Stefan\\Desktop\\DepthBuffer.png"); - pngWriter->Write(); -}*/ diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h index 3eb8d7c803..b8d082f9ce 100644 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h +++ b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h @@ -1,68 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSimulationView_h #define QmitkSimulationView_h #include #include #include #include #include namespace mitk { class ISimulationService; } class QmitkSimulationView : public QmitkAbstractView { Q_OBJECT public: QmitkSimulationView(); ~QmitkSimulationView(); void CreateQtPartControl(QWidget* parent); void SetFocus(); private slots: void OnAnimateButtonToggled(bool toggled); void OnDtChanged(double dt); void OnResetButtonClicked(); void OnSelectedSimulationChanged(const mitk::DataNode* node); void OnSelectedBaseChanged(); void OnStep(bool renderWindowUpdate); void OnStepButtonClicked(); void OnTimeout(); - void OnButtonClicked(); private: void OnNodeRemovedFromDataStorage(const mitk::DataNode* node); void ResetSceneTreeWidget(); void SetSimulationControlsEnabled(bool enabled); static const int MSecsPerFrame = 17; Ui::QmitkSimulationViewControls m_Controls; mitk::ISimulationService* m_SimulationService; mitk::DataNode::Pointer m_Selection; mitk::SimulationInteractor::Pointer m_Interactor; QTimer m_Timer; QTime m_NextRenderWindowUpdate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui index 6f7a23289c..193bdd1550 100644 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui +++ b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui @@ -1,186 +1,179 @@ QmitkSimulationViewControls true 0 0 248 751 Simulation 0 0 0 0 Animate true false 0 0 Step 0 0 Reset 0 0 dt 0 0 s 3 0.010000000000000 Qt::Vertical QAbstractItemView::NoEditTriggers true false 1 false Name true 120 Property Value - - - - - - - QmitkDataStorageComboBox QComboBox
QmitkDataStorageComboBox.h
QmitkSceneTreeWidget QTreeWidget
internal/QmitkSceneTreeWidget.h
QmitkBaseTreeWidget QTreeWidget
internal/QmitkBaseTreeWidget.h
diff --git a/Plugins/org.mitk.simulation/CMakeLists.txt b/Plugins/org.mitk.simulation/CMakeLists.txt index b9da98b89c..0aeea0060e 100644 --- a/Plugins/org.mitk.simulation/CMakeLists.txt +++ b/Plugins/org.mitk.simulation/CMakeLists.txt @@ -1,7 +1,11 @@ project(org_mitk_simulation) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE SIMULATION_INIT_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDS MitkQtWidgets MitkSimulation ) + +if(MSVC) + set_property(TARGET ${PLUGIN_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4068 /wd4250 /wd4251 /wd4267 /wd4275") +endif()