diff --git a/Modules/Core/files.cmake b/Modules/Core/files.cmake index b41ba81c8c..afbfa67ef6 100644 --- a/Modules/Core/files.cmake +++ b/Modules/Core/files.cmake @@ -1,313 +1,311 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES mitkCoreActivator.cpp mitkCoreObjectFactoryBase.cpp mitkCoreObjectFactory.cpp mitkCoreServices.cpp mitkException.cpp Algorithms/mitkBaseDataSource.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkCompositePixelValueToString.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkPlaneGeometryDataToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAnatomicalStructureColorPresets.cpp DataManagement/mitkArbitraryTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkApplyTransformMatrixOperation.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseGeometry.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataStorage.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGeometryTransformHolder.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageReadAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageVtkReadAccessor.cpp DataManagement/mitkImageVtkWriteAccessor.cpp DataManagement/mitkImageWriteAccessor.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkIPersistenceService.cpp DataManagement/mitkIPropertyAliases.cpp DataManagement/mitkIPropertyDescriptions.cpp DataManagement/mitkIPropertyExtensions.cpp DataManagement/mitkIPropertyFilters.cpp DataManagement/mitkIPropertyPersistence.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLine.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTableProperty.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMaterial.cpp DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModifiedLock.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateGeometry.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateDataProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkNumericConstants.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneGeometryData.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyFilters.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkPropertyListReplacedObserver.cpp DataManagement/mitkPropertyNameHelper.cpp DataManagement/mitkPropertyObserver.cpp DataManagement/mitkPropertyPersistence.cpp DataManagement/mitkPropertyPersistenceInfo.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkScaleOperation.cpp - DataManagement/mitkShaderProperty.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTemporoSpatialStringProperty.cpp DataManagement/mitkVector.cpp DataManagement/mitkVectorProperty.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp Interactions/mitkAction.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCrosshairPositionEvent.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventFactory.cpp Interactions/mitkEventRecorder.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkInteractionEventObserver.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkSinglePointDataInteractor.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkXML2EventParser.cpp IO/mitkAbstractFileIO.cpp IO/mitkAbstractFileReader.cpp IO/mitkAbstractFileWriter.cpp IO/mitkCustomMimeType.cpp IO/mitkDicomSeriesReader.cpp IO/mitkDicomSeriesReaderService.cpp IO/mitkDicomSR_GantryTiltInformation.cpp IO/mitkDicomSR_ImageBlockDescriptor.cpp IO/mitkDicomSR_LoadDICOMRGBPixel4D.cpp IO/mitkDicomSR_LoadDICOMRGBPixel.cpp IO/mitkDicomSR_LoadDICOMScalar4D.cpp IO/mitkDicomSR_LoadDICOMScalar.cpp IO/mitkDicomSR_SliceGroupingResult.cpp IO/mitkFileReader.cpp IO/mitkFileReaderRegistry.cpp IO/mitkFileReaderSelector.cpp IO/mitkFileReaderWriterBase.cpp IO/mitkFileWriter.cpp IO/mitkFileWriterRegistry.cpp IO/mitkFileWriterSelector.cpp IO/mitkGeometry3DToXML.cpp IO/mitkIFileIO.cpp IO/mitkIFileReader.cpp IO/mitkIFileWriter.cpp IO/mitkGeometryDataReaderService.cpp IO/mitkGeometryDataWriterService.cpp IO/mitkImageGenerator.cpp IO/mitkImageVtkLegacyIO.cpp IO/mitkImageVtkXmlIO.cpp IO/mitkIMimeTypeProvider.cpp IO/mitkIOConstants.cpp IO/mitkIOMimeTypes.cpp IO/mitkIOUtil.cpp IO/mitkItkImageIO.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkLegacyFileReaderService.cpp IO/mitkLegacyFileWriterService.cpp IO/mitkLocaleSwitch.cpp IO/mitkLog.cpp IO/mitkMimeType.cpp IO/mitkMimeTypeProvider.cpp IO/mitkOperation.cpp IO/mitkPixelType.cpp IO/mitkPointSetReaderService.cpp IO/mitkPointSetWriterService.cpp IO/mitkProportionalTimeGeometryToXML.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSurfaceStlIO.cpp IO/mitkSurfaceVtkIO.cpp IO/mitkSurfaceVtkLegacyIO.cpp IO/mitkSurfaceVtkXmlIO.cpp IO/mitkVtkLoggingAdapter.cpp Rendering/mitkAbstractAnnotationRenderer.cpp Rendering/mitkAnnotationUtils.cpp Rendering/mitkBaseRenderer.cpp #Rendering/mitkGLMapper.cpp Moved to deprecated LegacyGL Module Rendering/mitkGradientBackground.cpp Rendering/mitkImageVtkMapper2D.cpp - Rendering/mitkIShaderRepository.cpp Rendering/mitkMapper.cpp Rendering/mitkAnnotation.cpp Rendering/mitkPlaneGeometryDataMapper2D.cpp Rendering/mitkPlaneGeometryDataVtkMapper3D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowFrame.cpp #Rendering/mitkSurfaceGLMapper2D.cpp Moved to deprecated LegacyGL Module Rendering/mitkSurfaceVtkMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp ) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/DisplayConfigMITKNoCrosshair.xml Interactions/DisplayConfigMITKRotation.xml Interactions/DisplayConfigMITKRotationUnCoupled.xml Interactions/DisplayConfigMITKSwivel.xml Interactions/DisplayConfigMITKLimited.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml mitkLevelWindowPresets.xml mitkAnatomicalStructureColorPresets.xml ) diff --git a/Modules/Core/include/mitkCoreServices.h b/Modules/Core/include/mitkCoreServices.h index 7d619823d4..8db1bf79b7 100644 --- a/Modules/Core/include/mitkCoreServices.h +++ b/Modules/Core/include/mitkCoreServices.h @@ -1,173 +1,166 @@ /*=================================================================== 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 MITKCORESERVICES_H #define MITKCORESERVICES_H #include "MitkCoreExports.h" #include #include #include #include #include #include #include namespace mitk { struct IMimeTypeProvider; - struct IShaderRepository; class IPropertyAliases; class IPropertyDescriptions; class IPropertyExtensions; class IPropertyFilters; class IPropertyPersistence; /** * @brief Access MITK core services. * * This class can be used to conveniently access common * MITK Core service objects. Some getter methods where implementations * exist in the core library are guaranteed to return a non-NULL service object. * * To ensure that CoreServices::Unget() is called after the caller * has finished using a service object, you should use the CoreServicePointer * helper class which calls Unget() when it goes out of scope: * * \code * CoreServicePointer shaderRepo(CoreServices::GetShaderRepository()); * // Do something with shaderRepo * \endcode * * @see CoreServicePointer */ class MITKCORE_EXPORT CoreServices { public: - /** - * @brief Get an IShaderRepository instance. - * @param context The module context of the module getting the service. - * @return A IShaderRepository instance which can be NULL. - */ - static IShaderRepository *GetShaderRepository(); /** * @brief Get an IPropertyAliases instance. * @param context The module context of the module getting the service. * @return A non-NULL IPropertyAliases instance. */ static IPropertyAliases *GetPropertyAliases(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Get an IPropertyDescriptions instance. * @param context The module context of the module getting the service. * @return A non-NULL IPropertyDescriptions instance. */ static IPropertyDescriptions *GetPropertyDescriptions(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Get an IPropertyExtensions instance. * @param context The module context of the module getting the service. * @return A non-NULL IPropertyExtensions instance. */ static IPropertyExtensions *GetPropertyExtensions(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Get an IPropertyFilters instance. * @param context The module context of the module getting the service. * @return A non-NULL IPropertyFilters instance. */ static IPropertyFilters *GetPropertyFilters(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Get an IPropertyPersistence instance. * @param context The module context of the module getting the service. * @return A non-NULL IPropertyPersistence instance. */ static IPropertyPersistence *GetPropertyPersistence(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Get an IMimeTypeProvider instance. * @param context The module context of the module getting the service. * @return A non-NULL IMimeTypeProvider instance. */ static IMimeTypeProvider *GetMimeTypeProvider(us::ModuleContext *context = us::GetModuleContext()); /** * @brief Unget a previously acquired service instance. * @param service The service instance to be released. * @return \c true if ungetting the service was successful, \c false otherwise. */ template static bool Unget(S *service, us::ModuleContext *context = us::GetModuleContext()) { return Unget(context, us_service_interface_iid(), service); } private: static bool Unget(us::ModuleContext *context, const std::string &interfaceId, void *service); // purposely not implemented CoreServices(); CoreServices(const CoreServices &); CoreServices &operator=(const CoreServices &); }; /** * @brief A RAII helper class for core service objects. * * This is class is intended for usage in local scopes; it calls * CoreServices::Unget(S*) in its destructor. You should not construct * multiple CoreServicePointer instances using the same service pointer, * unless it is retrieved by a new call to a CoreServices getter method. * * @see CoreServices */ template class MITK_LOCAL CoreServicePointer { public: explicit CoreServicePointer(S *service) : m_service(service) { assert(m_service); } ~CoreServicePointer() { try { CoreServices::Unget(m_service); } catch (const std::exception &e) { MITK_ERROR << e.what(); } catch (...) { MITK_ERROR << "Ungetting core service failed."; } } S *operator->() const { return m_service; } private: // purposely not implemented CoreServicePointer(const CoreServicePointer &); CoreServicePointer &operator=(const CoreServicePointer &); S *const m_service; }; } #endif // MITKCORESERVICES_H diff --git a/Modules/Core/include/mitkIShaderRepository.h b/Modules/Core/include/mitkIShaderRepository.h deleted file mode 100644 index e79cc0797b..0000000000 --- a/Modules/Core/include/mitkIShaderRepository.h +++ /dev/null @@ -1,138 +0,0 @@ -/*=================================================================== - -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 MITKISHADERREPOSITORY_H -#define MITKISHADERREPOSITORY_H - -#include - -#include "mitkCommon.h" -#include "mitkServiceInterface.h" - -#include - -class vtkActor; -class vtkShaderProgram; - -namespace mitk -{ - class DataNode; - class BaseRenderer; - - /** - * \ingroup MicroServices_Interfaces - * \brief Management class for vtkShader XML descriptions. - * - * Loads XML shader files from std::istream objects and adds default properties - * for each shader object (shader uniforms) to the specified mitk::DataNode. - * - * Additionally, it provides a utility function for applying properties for shaders - * in mappers. - */ - struct MITKCORE_EXPORT IShaderRepository - - { - struct ShaderPrivate; - - class MITKCORE_EXPORT Shader : public itk::LightObject - - { - public: - mitkClassMacroItkParent(Shader, itk::LightObject) itkFactorylessNewMacro(Self) - - ~Shader(); - - int GetId() const; - std::string GetName() const; - std::string GetMaterialXml() const; - - protected: - Shader(); - - void SetId(int id); - void SetName(const std::string &name); - void SetMaterialXml(const std::string &xml); - - private: - // not implemented - Shader(const Shader &); - Shader &operator=(const Shader &); - - ShaderPrivate *d; - }; - - class MITKCORE_EXPORT ShaderProgram : public itk::LightObject - { - public: - virtual void Activate() = 0; - virtual void Deactivate() = 0; - mitkClassMacroItkParent(ShaderProgram, itk::LightObject) - }; - - virtual ~IShaderRepository(); - - virtual std::list GetShaders() const = 0; - - /** - * \brief Return the named shader. - * - * \param name The shader name. - * \return A Shader object. - * - * Names might not be unique. Use the shader id to uniquely identify a shader. - */ - virtual Shader::Pointer GetShader(const std::string &name) const = 0; - - virtual ShaderProgram::Pointer CreateShaderProgram() = 0; - - /** - * \brief Return the shader identified by the given id. - * @param id The shader id. - * @return The shader object or null if the id is unknown. - */ - virtual Shader::Pointer GetShader(int id) const = 0; - - /** \brief Adds all parsed shader uniforms to property list of the given DataNode; - * used by mappers. - */ - virtual void AddDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) const = 0; - - /** \brief Applies shader and shader specific variables of the specified DataNode - * to the VTK object by updating the shader variables of its vtkProperty. - */ - virtual void UpdateShaderProgram(mitk::IShaderRepository::ShaderProgram *shaderProgram, - mitk::DataNode *node, - mitk::BaseRenderer *renderer) const = 0; - - /** \brief Loads a shader from a given file. Make sure that this stream is in the XML shader format. - * - * \return A unique id for the loaded shader which can be used to unload it. - */ - virtual int LoadShader(std::istream &stream, const std::string &name) = 0; - - /** - * \brief Unload a previously loaded shader. - * \param id The unique shader id returned by LoadShader. - * \return \c true if the shader id was found and the shader was successfully unloaded, - * \c false otherwise. - */ - virtual bool UnloadShader(int id) = 0; - }; -} - -MITK_DECLARE_SERVICE_INTERFACE(mitk::IShaderRepository, "org.mitk.services.IShaderRepository/1.0") - -#endif // MITKISHADERREPOSITORY_H diff --git a/Modules/Core/include/mitkShaderProperty.h b/Modules/Core/include/mitkShaderProperty.h deleted file mode 100644 index 0d82ee1d2f..0000000000 --- a/Modules/Core/include/mitkShaderProperty.h +++ /dev/null @@ -1,111 +0,0 @@ -/*=================================================================== - -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 __MITKSHADERENUMPROPERTY_H -#define __MITKSHADERENUMPROPERTY_H - -#include "mitkEnumerationProperty.h" - -namespace mitk -{ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4522) -#endif - - /** - * Encapsulates the shader enumeration - */ - class MITKCORE_EXPORT ShaderProperty : public EnumerationProperty - { - public: - class Element - { - public: - std::string name; - }; - - mitkClassMacro(ShaderProperty, EnumerationProperty); - - itkFactorylessNewMacro(Self) itkCloneMacro(Self) - - mitkNewMacro1Param(ShaderProperty, const IdType &); - - mitkNewMacro1Param(ShaderProperty, const std::string &); - - /** - * Returns the current scalar mode value as defined by VTK constants. - * @returns the current scalar mode as VTK constant. - */ - IdType GetShaderId(); - std::string GetShaderName(); - void SetShader(const IdType &i); - void SetShader(const std::string &i); - - using BaseProperty::operator=; - - protected: - std::list shaderList; - - /** - * Constructor. Sets the representation to a default value of surface(2) - */ - ShaderProperty(); - - ShaderProperty(const ShaderProperty &other); - - /** - * \brief Sets the scalar mode to the given value. If it is not - * valid, the scalar mode is set to default (0). - * @param value the integer representation of the scalar mode - */ - ShaderProperty(const IdType &value); - - /** - * \brief Sets the scalar mode to the given value. If it is not - * valid, the representation is set to default (0). - * @param value the string representation of the scalar mode - */ - ShaderProperty(const std::string &value); - - /** - * this function is overridden as protected, so that the user may not add - * additional invalid scalar mode types. - */ - bool AddEnum(const std::string &name, const IdType &id = 0) override; - - /** - * Adds the enumeration types as defined by vtk to the list of known - * enumeration values. - */ - void AddShaderTypes(); - - private: - // purposely not implemented - ShaderProperty &operator=(const ShaderProperty &); - - virtual itk::LightObject::Pointer InternalClone() const override; - - virtual bool Assign(const BaseProperty &property) override; - }; - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -} // end of namespace mitk - -#endif //_MITK_VTK_SCALARMODE_PROPERTY__H_ diff --git a/Modules/Core/include/mitkVtkMapper.h b/Modules/Core/include/mitkVtkMapper.h index 15cd86b0d3..7d494b662d 100644 --- a/Modules/Core/include/mitkVtkMapper.h +++ b/Modules/Core/include/mitkVtkMapper.h @@ -1,177 +1,170 @@ /*=================================================================== 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. ===================================================================*/ // change number #ifndef VTKMAPPER_H_HEADER_INCLUDED_C1C5453B #define VTKMAPPER_H_HEADER_INCLUDED_C1C5453B #include "mitkBaseRenderer.h" #include "mitkDataNode.h" -#include "mitkIShaderRepository.h" #include "mitkLocalStorageHandler.h" #include "mitkMapper.h" #include "mitkVtkPropRenderer.h" #include #include #include #include #include #include #include #include #include #include class vtkProp; class vtkProp3D; class vtkActor; namespace mitk { /** \brief Base class of all Vtk Mappers in order to display primitives * by exploiting Vtk functionality. * * Rendering of opaque, translucent or volumetric geometry and overlays * is done in consecutive render passes. * * \ingroup Mapper */ class MITKCORE_EXPORT VtkMapper : public Mapper { public: mitkClassMacro(VtkMapper, Mapper); virtual vtkProp *GetVtkProp(mitk::BaseRenderer *renderer) = 0; /** \brief Re-issues all drawing commands required to describe * the entire scene each time a new frame is required, * regardless of actual changes. */ static void SetVtkMapperImmediateModeRendering(vtkMapper *mapper); /** * \brief Returns whether this is an vtk-based mapper * \deprecatedSince{2013_03} All mappers of superclass VTKMapper are vtk based, use a dynamic_cast instead */ DEPRECATED(virtual bool IsVtkBased() const override); /** \brief Determines which geometry should be rendered * (opaque, translucent, volumetric, overlay) * and calls the appropriate function. * * Called by mitk::VtkPropRenderer::Render */ void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override; /** \brief Checks visibility and renders the overlay */ virtual void MitkRenderOverlay(BaseRenderer *renderer); /** \brief Checks visibility and renders untransparent geometry */ virtual void MitkRenderOpaqueGeometry(BaseRenderer *renderer); /** \brief Checks visiblity and renders transparent geometry */ virtual void MitkRenderTranslucentGeometry(BaseRenderer *renderer); /** \brief Checks visibility and renders volumes */ virtual void MitkRenderVolumetricGeometry(BaseRenderer *renderer); /** \brief Returns true if this mapper owns the specified vtkProp for * the given BaseRenderer. * * Note: returns false by default; should be implemented for VTK-based * Mapper subclasses. */ virtual bool HasVtkProp(const vtkProp *prop, BaseRenderer *renderer); /** \brief Set the vtkTransform of the m_Prop3D for * the current time step of \a renderer * * Called by mitk::VtkPropRenderer::Update before rendering. This * method will transform all actors (e.g. of an vtkAssembly) according * the geometry. * * \warning This method transforms only props which derive * from vtkProp3D. Make sure to use vtkAssembly, if you have * multiple props. vtkPropAssembly does not work, since it derives * from vtkProp. */ virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer); /** * \brief Apply color and opacity properties read from the PropertyList * \deprecatedSince{2013_03} Use ApplyColorAndOpacityProperties(mitk::BaseRenderer* renderer, vtkActor * actor) * instead */ DEPRECATED(inline virtual void ApplyProperties(vtkActor *actor, mitk::BaseRenderer *renderer)) { ApplyColorAndOpacityProperties(renderer, actor); } /** * \brief SHADERTODO */ - void ApplyShaderProperties(mitk::BaseRenderer *renderer); + void ApplyShaderProperties(mitk::BaseRenderer *); /** * \brief Apply color and opacity properties read from the PropertyList. * Called by mapper subclasses. */ virtual void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor) override; /** * \brief Release vtk-based graphics resources that are being consumed by this mapper. * * Method called by mitk::VtkPropRenderer. The parameter renderer could be used to * determine which graphic resources to release. The local storage is accessible * by the parameter renderer. Should be overwritten in subclasses. */ virtual void ReleaseGraphicsResources(mitk::BaseRenderer * /*renderer*/) {} class VtkMapperLocalStorage : public mitk::Mapper::BaseLocalStorage { public: - mitk::IShaderRepository::ShaderProgram::Pointer m_ShaderProgram; itk::TimeStamp m_ModifiedTimeStamp; VtkMapperLocalStorage() { - IShaderRepository *shaderRepo = CoreServices::GetShaderRepository(); - if (shaderRepo) - { - m_ShaderProgram = shaderRepo->CreateShaderProgram(); - } } ~VtkMapperLocalStorage() {} }; mitk::LocalStorageHandler m_VtkMapperLSH; protected: /** constructor */ VtkMapper(); /** virtual destructor in order to derive from this class */ virtual ~VtkMapper(); private: /** copy constructor */ VtkMapper(const VtkMapper &); /** assignment operator */ VtkMapper &operator=(const VtkMapper &); }; } // namespace mitk #endif /* VTKMAPPER_H_HEADER_INCLUDED_C1C5453B */ diff --git a/Modules/Core/src/DataManagement/mitkShaderProperty.cpp b/Modules/Core/src/DataManagement/mitkShaderProperty.cpp deleted file mode 100644 index 8c54e8584d..0000000000 --- a/Modules/Core/src/DataManagement/mitkShaderProperty.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/*=================================================================== - -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 "mitkShaderProperty.h" -#include - -#include "mitkCoreServices.h" -#include "mitkIShaderRepository.h" - -#include -#include - -mitk::ShaderProperty::ShaderProperty() -{ - AddShaderTypes(); - SetShader((IdType)0); -} - -mitk::ShaderProperty::ShaderProperty(const ShaderProperty &other) - : mitk::EnumerationProperty(other), shaderList(other.shaderList) -{ -} - -mitk::ShaderProperty::ShaderProperty(const IdType &value) -{ - AddShaderTypes(); - SetShader(value); -} - -mitk::ShaderProperty::ShaderProperty(const std::string &value) -{ - AddShaderTypes(); - SetShader(value); -} - -void mitk::ShaderProperty::SetShader(const IdType &value) -{ - if (IsValidEnumerationValue(value)) - SetValue(value); - else - SetValue((IdType)0); -} - -void mitk::ShaderProperty::SetShader(const std::string &value) -{ - if (IsValidEnumerationValue(value)) - SetValue(value); - else - SetValue((IdType)0); -} - -mitk::EnumerationProperty::IdType mitk::ShaderProperty::GetShaderId() -{ - return GetValueAsId(); -} - -std::string mitk::ShaderProperty::GetShaderName() -{ - return GetValueAsString(); -} - -void mitk::ShaderProperty::AddShaderTypes() -{ - AddEnum("fixed"); - - IShaderRepository *shaderRepo = CoreServices::GetShaderRepository(); - if (shaderRepo == NULL) - return; - - std::list l = shaderRepo->GetShaders(); - std::list::const_iterator i = l.begin(); - - while (i != l.end()) - { - AddEnum((*i)->GetName()); - ++i; - } -} - -bool mitk::ShaderProperty::AddEnum(const std::string &name, const IdType & /*id*/) -{ - Element e; - - e.name = name; - - bool success = Superclass::AddEnum(e.name, (IdType)shaderList.size()); - - shaderList.push_back(e); - - return success; -} - -bool mitk::ShaderProperty::Assign(const BaseProperty &property) -{ - Superclass::Assign(property); - this->shaderList = static_cast(property).shaderList; - return true; -} - -itk::LightObject::Pointer mitk::ShaderProperty::InternalClone() const -{ - itk::LightObject::Pointer result(new Self(*this)); - result->UnRegister(); - return result; -} diff --git a/Modules/Core/src/Rendering/mitkIShaderRepository.cpp b/Modules/Core/src/Rendering/mitkIShaderRepository.cpp deleted file mode 100644 index 7e9e8b92ff..0000000000 --- a/Modules/Core/src/Rendering/mitkIShaderRepository.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*=================================================================== - -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 "mitkIShaderRepository.h" - -namespace mitk -{ - IShaderRepository::~IShaderRepository() {} - struct IShaderRepository::ShaderPrivate - { - ShaderPrivate() : id(-1) {} - int id; - std::string name; - std::string materialXml; - }; - - IShaderRepository::Shader::Shader() : d(new ShaderPrivate) {} - void IShaderRepository::Shader::SetId(int id) { d->id = id; } - IShaderRepository::Shader::~Shader() { delete d; } - int IShaderRepository::Shader::GetId() const { return d->id; } - std::string IShaderRepository::Shader::GetName() const { return d->name; } - std::string IShaderRepository::Shader::GetMaterialXml() const { return d->materialXml; } - void IShaderRepository::Shader::SetName(const std::string &name) { d->name = name; } - void IShaderRepository::Shader::SetMaterialXml(const std::string &xml) { d->materialXml = xml; } -} diff --git a/Modules/Core/src/Rendering/mitkSurfaceVtkMapper3D.cpp b/Modules/Core/src/Rendering/mitkSurfaceVtkMapper3D.cpp index 0480d76937..84f8bfb18f 100644 --- a/Modules/Core/src/Rendering/mitkSurfaceVtkMapper3D.cpp +++ b/Modules/Core/src/Rendering/mitkSurfaceVtkMapper3D.cpp @@ -1,532 +1,531 @@ /*=================================================================== 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 "mitkSurfaceVtkMapper3D.h" #include #include #include #include #include #include #include -#include #include #include #include #include #include #include #include #include // VTK #include #include #include #include #include #include #include #include const mitk::Surface *mitk::SurfaceVtkMapper3D::GetInput() { return static_cast(GetDataNode()->GetData()); } mitk::SurfaceVtkMapper3D::SurfaceVtkMapper3D() { m_GenerateNormals = false; } mitk::SurfaceVtkMapper3D::~SurfaceVtkMapper3D() { } void mitk::SurfaceVtkMapper3D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) { ls->m_Actor->VisibilityOff(); return; } // // set the input-object at time t for the mapper // mitk::Surface::Pointer input = const_cast(this->GetInput()); vtkSmartPointer polydata = input->GetVtkPolyData(this->GetTimestep()); if (polydata == NULL) { ls->m_Actor->VisibilityOff(); return; } if (m_GenerateNormals) { ls->m_VtkPolyDataNormals->SetInputData(polydata); ls->m_VtkPolyDataMapper->SetInputConnection(ls->m_VtkPolyDataNormals->GetOutputPort()); } else { bool depthsorting = false; GetDataNode()->GetBoolProperty("Depth Sorting", depthsorting); if (depthsorting) { ls->m_DepthSort->SetInputData(polydata); ls->m_DepthSort->SetCamera(renderer->GetVtkRenderer()->GetActiveCamera()); ls->m_DepthSort->SetDirectionToBackToFront(); ls->m_DepthSort->Update(); ls->m_VtkPolyDataMapper->SetInputConnection(ls->m_DepthSort->GetOutputPort()); } else { ls->m_VtkPolyDataMapper->SetInputData(polydata); } } // // apply properties read from the PropertyList // ApplyAllProperties(renderer, ls->m_Actor); if (visible) ls->m_Actor->VisibilityOn(); } void mitk::SurfaceVtkMapper3D::ResetMapper(BaseRenderer *renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); ls->m_Actor->VisibilityOff(); } void mitk::SurfaceVtkMapper3D::ApplyMitkPropertiesToVtkProperty(mitk::DataNode *node, vtkProperty *property, mitk::BaseRenderer *renderer) { // Backface culling { mitk::BoolProperty::Pointer p; node->GetProperty(p, "Backface Culling", renderer); bool useCulling = false; if (p.IsNotNull()) useCulling = p->GetValue(); property->SetBackfaceCulling(useCulling); } // Colors { double ambient[3] = {0.5, 0.5, 0.0}; double diffuse[3] = {0.5, 0.5, 0.0}; double specular[3] = {1.0, 1.0, 1.0}; float coeff_ambient = 0.5f; float coeff_diffuse = 0.5f; float coeff_specular = 0.5f; float power_specular = 10.0f; // Color { mitk::ColorProperty::Pointer p; node->GetProperty(p, "color", renderer); if (p.IsNotNull()) { mitk::Color c = p->GetColor(); ambient[0] = c.GetRed(); ambient[1] = c.GetGreen(); ambient[2] = c.GetBlue(); diffuse[0] = c.GetRed(); diffuse[1] = c.GetGreen(); diffuse[2] = c.GetBlue(); // Setting specular color to the same, make physically no real sense, however vtk rendering slows down, if these // colors are different. specular[0] = c.GetRed(); specular[1] = c.GetGreen(); specular[2] = c.GetBlue(); } } // Ambient { mitk::ColorProperty::Pointer p; node->GetProperty(p, "material.ambientColor", renderer); if (p.IsNotNull()) { mitk::Color c = p->GetColor(); ambient[0] = c.GetRed(); ambient[1] = c.GetGreen(); ambient[2] = c.GetBlue(); } } // Diffuse { mitk::ColorProperty::Pointer p; node->GetProperty(p, "material.diffuseColor", renderer); if (p.IsNotNull()) { mitk::Color c = p->GetColor(); diffuse[0] = c.GetRed(); diffuse[1] = c.GetGreen(); diffuse[2] = c.GetBlue(); } } // Specular { mitk::ColorProperty::Pointer p; node->GetProperty(p, "material.specularColor", renderer); if (p.IsNotNull()) { mitk::Color c = p->GetColor(); specular[0] = c.GetRed(); specular[1] = c.GetGreen(); specular[2] = c.GetBlue(); } } // Ambient coeff { node->GetFloatProperty("material.ambientCoefficient", coeff_ambient, renderer); } // Diffuse coeff { node->GetFloatProperty("material.diffuseCoefficient", coeff_diffuse, renderer); } // Specular coeff { node->GetFloatProperty("material.specularCoefficient", coeff_specular, renderer); } // Specular power { node->GetFloatProperty("material.specularPower", power_specular, renderer); } property->SetAmbient(coeff_ambient); property->SetDiffuse(coeff_diffuse); property->SetSpecular(coeff_specular); property->SetSpecularPower(power_specular); property->SetAmbientColor(ambient); property->SetDiffuseColor(diffuse); property->SetSpecularColor(specular); } // Render mode { // Opacity { float opacity = 1.0f; if (node->GetOpacity(opacity, renderer)) property->SetOpacity(opacity); } // Wireframe line width { float lineWidth = 1; node->GetFloatProperty("material.wireframeLineWidth", lineWidth, renderer); property->SetLineWidth(lineWidth); } // Point size { float pointSize = 1.0f; node->GetFloatProperty("material.pointSize", pointSize, renderer); property->SetPointSize(pointSize); } // Representation { mitk::VtkRepresentationProperty::Pointer p; node->GetProperty(p, "material.representation", renderer); if (p.IsNotNull()) property->SetRepresentation(p->GetVtkRepresentation()); } // Interpolation { mitk::VtkInterpolationProperty::Pointer p; node->GetProperty(p, "material.interpolation", renderer); if (p.IsNotNull()) property->SetInterpolation(p->GetVtkInterpolation()); } } } void mitk::SurfaceVtkMapper3D::ApplyAllProperties(mitk::BaseRenderer *renderer, vtkActor * /*actor*/) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); // Applying shading properties Superclass::ApplyColorAndOpacityProperties(renderer, ls->m_Actor); this->ApplyShaderProperties(renderer); // VTK Properties ApplyMitkPropertiesToVtkProperty(this->GetDataNode(), ls->m_Actor->GetProperty(), renderer); mitk::TransferFunctionProperty::Pointer transferFuncProp; this->GetDataNode()->GetProperty(transferFuncProp, "Surface.TransferFunction", renderer); if (transferFuncProp.IsNotNull()) { ls->m_VtkPolyDataMapper->SetLookupTable(transferFuncProp->GetValue()->GetColorTransferFunction()); } mitk::LookupTableProperty::Pointer lookupTableProp; this->GetDataNode()->GetProperty(lookupTableProp, "LookupTable", renderer); if (lookupTableProp.IsNotNull()) { ls->m_VtkPolyDataMapper->SetLookupTable(lookupTableProp->GetLookupTable()->GetVtkLookupTable()); } mitk::LevelWindow levelWindow; if (this->GetDataNode()->GetLevelWindow(levelWindow, renderer, "levelWindow")) { ls->m_VtkPolyDataMapper->SetScalarRange(levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound()); } else if (this->GetDataNode()->GetLevelWindow(levelWindow, renderer)) { ls->m_VtkPolyDataMapper->SetScalarRange(levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound()); } bool scalarVisibility = false; this->GetDataNode()->GetBoolProperty("scalar visibility", scalarVisibility); ls->m_VtkPolyDataMapper->SetScalarVisibility((scalarVisibility ? 1 : 0)); if (scalarVisibility) { mitk::VtkScalarModeProperty *scalarMode; if (this->GetDataNode()->GetProperty(scalarMode, "scalar mode", renderer)) ls->m_VtkPolyDataMapper->SetScalarMode(scalarMode->GetVtkScalarMode()); else ls->m_VtkPolyDataMapper->SetScalarModeToDefault(); bool colorMode = false; this->GetDataNode()->GetBoolProperty("color mode", colorMode); ls->m_VtkPolyDataMapper->SetColorMode((colorMode ? 1 : 0)); double scalarsMin = 0; this->GetDataNode()->GetDoubleProperty("ScalarsRangeMinimum", scalarsMin, renderer); double scalarsMax = 1.0; this->GetDataNode()->GetDoubleProperty("ScalarsRangeMaximum", scalarsMax, renderer); ls->m_VtkPolyDataMapper->SetScalarRange(scalarsMin, scalarsMax); } mitk::SmartPointerProperty::Pointer imagetextureProp = dynamic_cast(GetDataNode()->GetProperty("Surface.Texture", renderer)); if (imagetextureProp.IsNotNull()) { mitk::Image *miktTexture = dynamic_cast(imagetextureProp->GetSmartPointer().GetPointer()); vtkSmartPointer vtkTxture = vtkSmartPointer::New(); // Either select the first slice of a volume if (miktTexture->GetDimension(2) > 1) { MITK_WARN << "3D Textures are not supported by VTK and MITK. The first slice of the volume will be used instead!"; mitk::ImageSliceSelector::Pointer sliceselector = mitk::ImageSliceSelector::New(); sliceselector->SetSliceNr(0); sliceselector->SetChannelNr(0); sliceselector->SetTimeNr(0); sliceselector->SetInput(miktTexture); sliceselector->Update(); vtkTxture->SetInputData(sliceselector->GetOutput()->GetVtkImageData()); } else // or just use the 2D image { vtkTxture->SetInputData(miktTexture->GetVtkImageData()); } // pass the texture to the actor ls->m_Actor->SetTexture(vtkTxture); if (ls->m_VtkPolyDataMapper->GetInput()->GetPointData()->GetTCoords() == NULL) { MITK_ERROR << "Surface.Texture property was set, but there are no texture coordinates. Please provide texture " "coordinates for the vtkPolyData via vtkPolyData->GetPointData()->SetTCoords()."; } // if no texture is set, this will also remove a previously used texture // and reset the actor to it's default behaviour } else { ls->m_Actor->SetTexture(0); } // deprecated settings bool deprecatedUseCellData = false; this->GetDataNode()->GetBoolProperty("deprecated useCellDataForColouring", deprecatedUseCellData); bool deprecatedUsePointData = false; this->GetDataNode()->GetBoolProperty("deprecated usePointDataForColouring", deprecatedUsePointData); if (deprecatedUseCellData) { ls->m_VtkPolyDataMapper->SetColorModeToDefault(); ls->m_VtkPolyDataMapper->SetScalarRange(0, 255); ls->m_VtkPolyDataMapper->ScalarVisibilityOn(); ls->m_VtkPolyDataMapper->SetScalarModeToUseCellData(); ls->m_Actor->GetProperty()->SetSpecular(1); ls->m_Actor->GetProperty()->SetSpecularPower(50); ls->m_Actor->GetProperty()->SetInterpolationToPhong(); } else if (deprecatedUsePointData) { float scalarsMin = 0; if (dynamic_cast(this->GetDataNode()->GetProperty("ScalarsRangeMinimum")) != NULL) scalarsMin = dynamic_cast(this->GetDataNode()->GetProperty("ScalarsRangeMinimum"))->GetValue(); float scalarsMax = 0.1; if (dynamic_cast(this->GetDataNode()->GetProperty("ScalarsRangeMaximum")) != NULL) scalarsMax = dynamic_cast(this->GetDataNode()->GetProperty("ScalarsRangeMaximum"))->GetValue(); ls->m_VtkPolyDataMapper->SetScalarRange(scalarsMin, scalarsMax); ls->m_VtkPolyDataMapper->SetColorModeToMapScalars(); ls->m_VtkPolyDataMapper->ScalarVisibilityOn(); ls->m_Actor->GetProperty()->SetSpecular(1); ls->m_Actor->GetProperty()->SetSpecularPower(50); ls->m_Actor->GetProperty()->SetInterpolationToPhong(); } int deprecatedScalarMode = VTK_COLOR_MODE_DEFAULT; if (this->GetDataNode()->GetIntProperty("deprecated scalar mode", deprecatedScalarMode, renderer)) { ls->m_VtkPolyDataMapper->SetScalarMode(deprecatedScalarMode); ls->m_VtkPolyDataMapper->ScalarVisibilityOn(); ls->m_Actor->GetProperty()->SetSpecular(1); ls->m_Actor->GetProperty()->SetSpecularPower(50); } // Check whether one or more ClippingProperty objects have been defined for // this node. Check both renderer specific and global property lists, since // properties in both should be considered. const PropertyList::PropertyMap *rendererProperties = this->GetDataNode()->GetPropertyList(renderer)->GetMap(); const PropertyList::PropertyMap *globalProperties = this->GetDataNode()->GetPropertyList(NULL)->GetMap(); // Add clipping planes (if any) ls->m_ClippingPlaneCollection->RemoveAllItems(); PropertyList::PropertyMap::const_iterator it; for (it = rendererProperties->begin(); it != rendererProperties->end(); ++it) { this->CheckForClippingProperty(renderer, (*it).second.GetPointer()); } for (it = globalProperties->begin(); it != globalProperties->end(); ++it) { this->CheckForClippingProperty(renderer, (*it).second.GetPointer()); } if (ls->m_ClippingPlaneCollection->GetNumberOfItems() > 0) { ls->m_VtkPolyDataMapper->SetClippingPlanes(ls->m_ClippingPlaneCollection); } else { ls->m_VtkPolyDataMapper->RemoveAllClippingPlanes(); } } vtkProp *mitk::SurfaceVtkMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); return ls->m_Actor; } void mitk::SurfaceVtkMapper3D::CheckForClippingProperty(mitk::BaseRenderer *renderer, mitk::BaseProperty *property) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); ClippingProperty *clippingProperty = dynamic_cast(property); if ((clippingProperty != NULL) && (clippingProperty->GetClippingEnabled())) { const Point3D &origin = clippingProperty->GetOrigin(); const Vector3D &normal = clippingProperty->GetNormal(); vtkSmartPointer clippingPlane = vtkSmartPointer::New(); clippingPlane->SetOrigin(origin[0], origin[1], origin[2]); clippingPlane->SetNormal(normal[0], normal[1], normal[2]); ls->m_ClippingPlaneCollection->AddItem(clippingPlane); } } void mitk::SurfaceVtkMapper3D::SetDefaultPropertiesForVtkProperty(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) { // Shading { node->AddProperty("material.wireframeLineWidth", mitk::FloatProperty::New(1.0f), renderer, overwrite); node->AddProperty("material.pointSize", mitk::FloatProperty::New(1.0f), renderer, overwrite); node->AddProperty("material.ambientCoefficient", mitk::FloatProperty::New(0.05f), renderer, overwrite); node->AddProperty("material.diffuseCoefficient", mitk::FloatProperty::New(0.9f), renderer, overwrite); node->AddProperty("material.specularCoefficient", mitk::FloatProperty::New(1.0f), renderer, overwrite); node->AddProperty("material.specularPower", mitk::FloatProperty::New(16.0f), renderer, overwrite); node->AddProperty("material.representation", mitk::VtkRepresentationProperty::New(), renderer, overwrite); node->AddProperty("material.interpolation", mitk::VtkInterpolationProperty::New(), renderer, overwrite); } - // Shaders - IShaderRepository *shaderRepo = CoreServices::GetShaderRepository(); - if (shaderRepo) - { - shaderRepo->AddDefaultProperties(node, renderer, overwrite); - } +// // Shaders +// IShaderRepository *shaderRepo = CoreServices::GetShaderRepository(); +// if (shaderRepo) +// { +// shaderRepo->AddDefaultProperties(node, renderer, overwrite); +// } } void mitk::SurfaceVtkMapper3D::SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) { node->AddProperty("color", mitk::ColorProperty::New(1.0f, 1.0f, 1.0f), renderer, overwrite); node->AddProperty("opacity", mitk::FloatProperty::New(1.0), renderer, overwrite); mitk::SurfaceVtkMapper3D::SetDefaultPropertiesForVtkProperty(node, renderer, overwrite); // Shading node->AddProperty("scalar visibility", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("color mode", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("scalar mode", mitk::VtkScalarModeProperty::New(), renderer, overwrite); mitk::Surface::Pointer surface = dynamic_cast(node->GetData()); if (surface.IsNotNull()) { if ((surface->GetVtkPolyData() != 0) && (surface->GetVtkPolyData()->GetPointData() != NULL) && (surface->GetVtkPolyData()->GetPointData()->GetScalars() != 0)) { node->AddProperty("scalar visibility", mitk::BoolProperty::New(true), renderer, overwrite); node->AddProperty("color mode", mitk::BoolProperty::New(true), renderer, overwrite); } } // Backface culling node->AddProperty("Backface Culling", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("Depth Sorting", mitk::BoolProperty::New(false), renderer, overwrite); mitk::CoreServices::GetPropertyDescriptions()->AddDescription( "Depth Sorting", "Enables correct rendering for transparent objects by ordering polygons according to the distance " "to the camera. It is not recommended to enable this property for large surfaces (rendering might " "be slow)."); Superclass::SetDefaultProperties(node, renderer, overwrite); } diff --git a/Modules/Core/src/Rendering/mitkVtkMapper.cpp b/Modules/Core/src/Rendering/mitkVtkMapper.cpp index 5003e99123..83a9107331 100644 --- a/Modules/Core/src/Rendering/mitkVtkMapper.cpp +++ b/Modules/Core/src/Rendering/mitkVtkMapper.cpp @@ -1,161 +1,145 @@ /*=================================================================== 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 "mitkVtkMapper.h" mitk::VtkMapper::VtkMapper() { } mitk::VtkMapper::~VtkMapper() { } void mitk::VtkMapper::MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) { - VtkMapperLocalStorage *ls = m_VtkMapperLSH.GetLocalStorage(renderer); - if (ls->m_ShaderProgram) - { - ls->m_ShaderProgram->Activate(); - } - switch (type) { case mitk::VtkPropRenderer::Opaque: this->MitkRenderOpaqueGeometry(renderer); break; case mitk::VtkPropRenderer::Translucent: this->MitkRenderTranslucentGeometry(renderer); break; case mitk::VtkPropRenderer::Overlay: this->MitkRenderOverlay(renderer); break; case mitk::VtkPropRenderer::Volumetric: this->MitkRenderVolumetricGeometry(renderer); break; } - - if (ls->m_ShaderProgram) - { - ls->m_ShaderProgram->Deactivate(); - } } bool mitk::VtkMapper::IsVtkBased() const { return true; } void mitk::VtkMapper::MitkRenderOverlay(BaseRenderer *renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) return; if (this->GetVtkProp(renderer)->GetVisibility()) { GetVtkProp(renderer)->RenderOverlay(renderer->GetVtkRenderer()); } } void mitk::VtkMapper::MitkRenderOpaqueGeometry(BaseRenderer *renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) return; if (this->GetVtkProp(renderer)->GetVisibility()) { GetVtkProp(renderer)->RenderOpaqueGeometry(renderer->GetVtkRenderer()); } } void mitk::VtkMapper::MitkRenderTranslucentGeometry(BaseRenderer *renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) return; if (this->GetVtkProp(renderer)->GetVisibility()) { GetVtkProp(renderer)->RenderTranslucentPolygonalGeometry(renderer->GetVtkRenderer()); } } -void mitk::VtkMapper::ApplyShaderProperties(mitk::BaseRenderer *renderer) +void mitk::VtkMapper::ApplyShaderProperties(mitk::BaseRenderer */*renderer*/) { - IShaderRepository *shaderRepo = CoreServices::GetShaderRepository(); - if (shaderRepo) - { - VtkMapperLocalStorage *ls = m_VtkMapperLSH.GetLocalStorage(renderer); - shaderRepo->UpdateShaderProgram(ls->m_ShaderProgram, this->GetDataNode(), renderer); - } + } void mitk::VtkMapper::MitkRenderVolumetricGeometry(BaseRenderer *renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) return; if (GetVtkProp(renderer)->GetVisibility()) { GetVtkProp(renderer)->RenderVolumetricGeometry(renderer->GetVtkRenderer()); } } bool mitk::VtkMapper::HasVtkProp(const vtkProp *prop, BaseRenderer *renderer) { vtkProp *myProp = this->GetVtkProp(renderer); // TODO: check if myProp is a vtkAssembly and if so, check if prop is contained in its leafs return (prop == myProp); } void mitk::VtkMapper::SetVtkMapperImmediateModeRendering(vtkMapper *mapper) { if (mapper) mapper->SetImmediateModeRendering(mitk::VtkPropRenderer::useImmediateModeRendering()); } void mitk::VtkMapper::UpdateVtkTransform(mitk::BaseRenderer *renderer) { vtkLinearTransform *vtktransform = GetDataNode()->GetVtkTransform(this->GetTimestep()); vtkProp3D *prop = dynamic_cast(GetVtkProp(renderer)); if (prop) prop->SetUserTransform(vtktransform); } void mitk::VtkMapper::ApplyColorAndOpacityProperties(BaseRenderer *renderer, vtkActor *actor) { float rgba[4] = {1.0f, 1.0f, 1.0f, 1.0f}; DataNode *node = GetDataNode(); // check for color prop and use it for rendering if it exists node->GetColor(rgba, renderer, "color"); // check for opacity prop and use it for rendering if it exists node->GetOpacity(rgba[3], renderer, "opacity"); double drgba[4] = {rgba[0], rgba[1], rgba[2], rgba[3]}; actor->GetProperty()->SetColor(drgba); actor->GetProperty()->SetOpacity(drgba[3]); } diff --git a/Modules/Core/src/mitkCoreActivator.cpp b/Modules/Core/src/mitkCoreActivator.cpp index ac2a072d41..785e45b8e9 100644 --- a/Modules/Core/src/mitkCoreActivator.cpp +++ b/Modules/Core/src/mitkCoreActivator.cpp @@ -1,457 +1,324 @@ /*=================================================================== 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 "mitkCoreActivator.h" // File IO #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkDicomSeriesReaderService.h" #include "mitkLegacyFileWriterService.h" #include #include #include // Micro Services #include #include #include #include #include #include #include #include #include #include // ITK "injects" static initialization code for IO factories // via the itkImageIOFactoryRegisterManager.h header (which // is generated in the application library build directory). // To ensure that the code is called *before* the CppMicroServices // static initialization code (which triggers the Activator::Start // method), we include the ITK header here. #include void HandleMicroServicesMessages(us::MsgType type, const char *msg) { switch (type) { case us::DebugMsg: MITK_DEBUG << msg; break; case us::InfoMsg: MITK_INFO << msg; break; case us::WarningMsg: MITK_WARN << msg; break; case us::ErrorMsg: MITK_ERROR << msg; break; } } void AddMitkAutoLoadPaths(const std::string &programPath) { us::ModuleSettings::AddAutoLoadPath(programPath); #ifdef __APPLE__ // Walk up three directories since that is where the .dylib files are located // for build trees. std::string additionalPath = programPath; bool addPath = true; for (int i = 0; i < 3; ++i) { std::size_t index = additionalPath.find_last_of('/'); if (index != std::string::npos) { additionalPath = additionalPath.substr(0, index); } else { addPath = false; break; } } if (addPath) { us::ModuleSettings::AddAutoLoadPath(additionalPath); } #endif } -class ShaderRepositoryTracker : public us::ServiceTracker -{ -public: - ShaderRepositoryTracker() : Superclass(us::GetModuleContext()) {} - virtual void Close() override - { - us::GetModuleContext()->RemoveModuleListener(this, &ShaderRepositoryTracker::HandleModuleEvent); - Superclass::Close(); - } - - virtual void Open() override - { - us::GetModuleContext()->AddModuleListener(this, &ShaderRepositoryTracker::HandleModuleEvent); - Superclass::Open(); - } - -private: - typedef us::ServiceTracker Superclass; - - TrackedType AddingService(const ServiceReferenceType &reference) override - { - mitk::IShaderRepository *shaderRepo = Superclass::AddingService(reference); - if (shaderRepo) - { - // Add all existing shaders from modules to the new shader repository. - // If the shader repository is registered in a modules activator, the - // GetLoadedModules() function call below will also return the module - // which is currently registering the repository. The HandleModuleEvent - // method contains code to avoid double registrations due to a fired - // ModuleEvent::LOADED event after the activators Load() method finished. - std::vector modules = us::ModuleRegistry::GetLoadedModules(); - for (std::vector::const_iterator iter = modules.begin(), endIter = modules.end(); iter != endIter; - ++iter) - { - this->AddModuleShaderToRepository(*iter, shaderRepo); - } - - m_ShaderRepositories.push_back(shaderRepo); - } - return shaderRepo; - } - - void RemovedService(const ServiceReferenceType & /*reference*/, TrackedType tracked) override - { - m_ShaderRepositories.erase(std::remove(m_ShaderRepositories.begin(), m_ShaderRepositories.end(), tracked), - m_ShaderRepositories.end()); - } - - void HandleModuleEvent(const us::ModuleEvent moduleEvent) - { - if (moduleEvent.GetType() == us::ModuleEvent::LOADED) - { - std::vector shaderRepos; - for (std::map>>::const_iterator - shaderMapIter = m_ModuleIdToShaderIds.begin(), - shaderMapEndIter = m_ModuleIdToShaderIds.end(); - shaderMapIter != shaderMapEndIter; - ++shaderMapIter) - { - if (shaderMapIter->second.find(moduleEvent.GetModule()->GetModuleId()) == shaderMapIter->second.end()) - { - shaderRepos.push_back(shaderMapIter->first); - } - } - AddModuleShadersToRepositories(moduleEvent.GetModule(), shaderRepos); - } - else if (moduleEvent.GetType() == us::ModuleEvent::UNLOADED) - { - RemoveModuleShadersFromRepositories(moduleEvent.GetModule(), m_ShaderRepositories); - } - } - - void AddModuleShadersToRepositories(us::Module *module, const std::vector &shaderRepos) - { - // search and load shader files - std::vector shaderResources = module->FindResources("Shaders", "*.xml", true); - for (std::vector::iterator i = shaderResources.begin(); i != shaderResources.end(); ++i) - { - if (*i) - { - us::ModuleResourceStream rs(*i); - for (const auto &shaderRepo : shaderRepos) - { - int id = (shaderRepo)->LoadShader(rs, i->GetBaseName()); - if (id >= 0) - { - m_ModuleIdToShaderIds[shaderRepo][module->GetModuleId()].push_back(id); - } - } - rs.seekg(0, std::ios_base::beg); - } - } - } - - void AddModuleShaderToRepository(us::Module *module, mitk::IShaderRepository *shaderRepo) - { - std::vector shaderRepos; - shaderRepos.push_back(shaderRepo); - this->AddModuleShadersToRepositories(module, shaderRepos); - } - - void RemoveModuleShadersFromRepositories(us::Module *module, - const std::vector &shaderRepos) - { - for (const auto &shaderRepo : shaderRepos) - { - std::map> &moduleIdToShaderIds = m_ModuleIdToShaderIds[shaderRepo]; - std::map>::iterator shaderIdsIter = moduleIdToShaderIds.find(module->GetModuleId()); - if (shaderIdsIter != moduleIdToShaderIds.end()) - { - for (std::vector::iterator idIter = shaderIdsIter->second.begin(); idIter != shaderIdsIter->second.end(); - ++idIter) - { - (shaderRepo)->UnloadShader(*idIter); - } - moduleIdToShaderIds.erase(shaderIdsIter); - } - } - } - -private: - // Maps to each shader repository a map containing module ids and related - // shader registration ids - std::map>> m_ModuleIdToShaderIds; - std::vector m_ShaderRepositories; -}; - class FixedNiftiImageIO : public itk::NiftiImageIO { public: /** Standard class typedefs. */ typedef FixedNiftiImageIO Self; typedef itk::NiftiImageIO Superclass; typedef itk::SmartPointer Pointer; /** Method for creation through the object factory. */ itkNewMacro(Self) /** Run-time type information (and related methods). */ itkTypeMacro(FixedNiftiImageIO, Superclass) virtual bool SupportsDimension(unsigned long dim) override { return dim > 1 && dim < 5; } }; void MitkCoreActivator::Load(us::ModuleContext *context) { // Handle messages from CppMicroServices us::installMsgHandler(HandleMicroServicesMessages); this->m_Context = context; // Add the current application directory to the auto-load paths. // This is useful for third-party executables. std::string programPath = mitk::IOUtil::GetProgramPath(); if (programPath.empty()) { MITK_WARN << "Could not get the program path."; } else { AddMitkAutoLoadPaths(programPath); } - m_ShaderRepositoryTracker.reset(new ShaderRepositoryTracker); - // m_RenderingManager = mitk::RenderingManager::New(); // context->RegisterService(renderingManager.GetPointer()); m_PlanePositionManager.reset(new mitk::PlanePositionManagerService); context->RegisterService(m_PlanePositionManager.get()); m_PropertyAliases.reset(new mitk::PropertyAliases); context->RegisterService(m_PropertyAliases.get()); m_PropertyDescriptions.reset(new mitk::PropertyDescriptions); context->RegisterService(m_PropertyDescriptions.get()); m_PropertyExtensions.reset(new mitk::PropertyExtensions); context->RegisterService(m_PropertyExtensions.get()); m_PropertyFilters.reset(new mitk::PropertyFilters); context->RegisterService(m_PropertyFilters.get()); m_PropertyPersistence.reset(new mitk::PropertyPersistence); context->RegisterService(m_PropertyPersistence.get()); m_MimeTypeProvider.reset(new mitk::MimeTypeProvider); m_MimeTypeProvider->Start(); m_MimeTypeProviderReg = context->RegisterService(m_MimeTypeProvider.get()); this->RegisterDefaultMimeTypes(); this->RegisterItkReaderWriter(); this->RegisterVtkReaderWriter(); // Add custom Reader / Writer Services m_FileReaders.push_back(new mitk::PointSetReaderService()); m_FileWriters.push_back(new mitk::PointSetWriterService()); m_FileReaders.push_back(new mitk::GeometryDataReaderService()); m_FileWriters.push_back(new mitk::GeometryDataWriterService()); m_FileReaders.push_back(new mitk::DicomSeriesReaderService()); m_FileReaders.push_back(new mitk::RawImageFileReaderService()); - m_ShaderRepositoryTracker->Open(); - /* There IS an option to exchange ALL vtkTexture instances against vtkNeverTranslucentTextureFactory. This code is left here as a reminder, just in case we might need to do that some time. vtkNeverTranslucentTextureFactory* textureFactory = vtkNeverTranslucentTextureFactory::New(); vtkObjectFactory::RegisterFactory( textureFactory ); textureFactory->Delete(); */ this->RegisterLegacyWriter(); } void MitkCoreActivator::Unload(us::ModuleContext *) { for (auto &elem : m_FileReaders) { delete elem; } for (auto &elem : m_FileWriters) { delete elem; } for (auto &elem : m_FileIOs) { delete elem; } for (auto &elem : m_LegacyWriters) { delete elem; } // The mitk::ModuleContext* argument of the Unload() method // will always be 0 for the Mitk library. It makes no sense // to use it at this stage anyway, since all libraries which // know about the module system have already been unloaded. // we need to close the internal service tracker of the // MimeTypeProvider class here. Otherwise it // would hold on to the ModuleContext longer than it is // actually valid. m_MimeTypeProviderReg.Unregister(); m_MimeTypeProvider->Stop(); for (std::vector::const_iterator mimeTypeIter = m_DefaultMimeTypes.begin(), iterEnd = m_DefaultMimeTypes.end(); mimeTypeIter != iterEnd; ++mimeTypeIter) { delete *mimeTypeIter; } - - m_ShaderRepositoryTracker->Close(); } void MitkCoreActivator::RegisterDefaultMimeTypes() { // Register some default mime-types std::vector mimeTypes = mitk::IOMimeTypes::Get(); for (std::vector::const_iterator mimeTypeIter = mimeTypes.begin(), iterEnd = mimeTypes.end(); mimeTypeIter != iterEnd; ++mimeTypeIter) { m_DefaultMimeTypes.push_back(*mimeTypeIter); m_Context->RegisterService(m_DefaultMimeTypes.back()); } } void MitkCoreActivator::RegisterItkReaderWriter() { std::list allobjects = itk::ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); for (auto &allobject : allobjects) { itk::ImageIOBase *io = dynamic_cast(allobject.GetPointer()); // NiftiImageIO does not provide a correct "SupportsDimension()" methods // and the supported read/write extensions are not ordered correctly if (dynamic_cast(io)) continue; // Use a custom mime-type for GDCMImageIO below if (dynamic_cast(allobject.GetPointer())) { // MITK provides its own DICOM reader (which internally uses GDCMImageIO). continue; } if (io) { m_FileIOs.push_back(new mitk::ItkImageIO(io)); } else { MITK_WARN << "Error ImageIO factory did not return an ImageIOBase: " << (allobject)->GetNameOfClass(); } } FixedNiftiImageIO::Pointer itkNiftiIO = FixedNiftiImageIO::New(); mitk::ItkImageIO *niftiIO = new mitk::ItkImageIO(mitk::IOMimeTypes::NIFTI_MIMETYPE(), itkNiftiIO.GetPointer(), 0); m_FileIOs.push_back(niftiIO); } void MitkCoreActivator::RegisterVtkReaderWriter() { m_FileIOs.push_back(new mitk::SurfaceVtkXmlIO()); m_FileIOs.push_back(new mitk::SurfaceStlIO()); m_FileIOs.push_back(new mitk::SurfaceVtkLegacyIO()); m_FileIOs.push_back(new mitk::ImageVtkXmlIO()); m_FileIOs.push_back(new mitk::ImageVtkLegacyIO()); } void MitkCoreActivator::RegisterLegacyWriter() { std::list allobjects = itk::ObjectFactoryBase::CreateAllInstance("IOWriter"); for (std::list::iterator i = allobjects.begin(); i != allobjects.end(); ++i) { mitk::FileWriter::Pointer io = dynamic_cast(i->GetPointer()); if (io) { std::string description = std::string("Legacy ") + io->GetNameOfClass() + " Writer"; mitk::IFileWriter *writer = new mitk::LegacyFileWriterService(io, description); m_LegacyWriters.push_back(writer); } else { MITK_ERROR << "Error IOWriter override is not of type mitk::FileWriter: " << (*i)->GetNameOfClass() << std::endl; } } } US_EXPORT_MODULE_ACTIVATOR(MitkCoreActivator) // Call CppMicroservices initialization code at the end of the file. // This especially ensures that VTK object factories have already // been registered (VTK initialization code is injected by implicitly // include VTK header files at the top of this file). US_INITIALIZE_MODULE diff --git a/Modules/Core/src/mitkCoreActivator.h b/Modules/Core/src/mitkCoreActivator.h index a6c274a997..7cdbce2b57 100644 --- a/Modules/Core/src/mitkCoreActivator.h +++ b/Modules/Core/src/mitkCoreActivator.h @@ -1,86 +1,82 @@ /*=================================================================== 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 MITKCOREACTIVATOR_H_ #define MITKCOREACTIVATOR_H_ // File IO #include #include #include -#include - #include #include #include #include #include #include #include // Micro Services #include #include #include #include #include /* * This is the module activator for the "Mitk" module. It registers core services * like ... */ class MitkCoreActivator : public us::ModuleActivator { public: void Load(us::ModuleContext *context) override; void Unload(us::ModuleContext *) override; private: void HandleModuleEvent(const us::ModuleEvent moduleEvent); void RegisterDefaultMimeTypes(); void RegisterItkReaderWriter(); void RegisterVtkReaderWriter(); void RegisterLegacyWriter(); - std::unique_ptr> m_ShaderRepositoryTracker; - // mitk::RenderingManager::Pointer m_RenderingManager; std::unique_ptr m_PlanePositionManager; std::unique_ptr m_PropertyAliases; std::unique_ptr m_PropertyDescriptions; std::unique_ptr m_PropertyExtensions; std::unique_ptr m_PropertyFilters; std::unique_ptr m_PropertyPersistence; std::unique_ptr m_MimeTypeProvider; // File IO std::vector m_FileReaders; std::vector m_FileWriters; std::vector m_FileIOs; std::vector m_LegacyWriters; std::vector m_DefaultMimeTypes; us::ServiceRegistration m_MimeTypeProviderReg; us::ModuleContext *m_Context; }; #endif // MITKCOREACTIVATOR_H_ diff --git a/Modules/Core/src/mitkCoreServices.cpp b/Modules/Core/src/mitkCoreServices.cpp index 747be918c1..a3c74ee199 100644 --- a/Modules/Core/src/mitkCoreServices.cpp +++ b/Modules/Core/src/mitkCoreServices.cpp @@ -1,134 +1,126 @@ /*=================================================================== 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 "mitkCoreServices.h" #include #include #include #include #include #include -#include #include #include #include #include #include #include namespace mitk { itk::SimpleFastMutexLock &s_ContextToServicesMapMutex() { static itk::SimpleFastMutexLock mutex; return mutex; } std::map> &s_ContextToServicesMap() { static std::map> serviceMap; return serviceMap; } template static S *GetCoreService(us::ModuleContext *context) { if (context == NULL) context = us::GetModuleContext(); S *coreService = NULL; us::ServiceReference serviceRef = context->GetServiceReference(); if (serviceRef) { coreService = context->GetService(serviceRef); } assert(coreService && "Asserting non-NULL MITK core service"); { itk::MutexLockHolder l(s_ContextToServicesMapMutex()); s_ContextToServicesMap()[context].insert(std::make_pair(coreService, serviceRef)); } return coreService; } - IShaderRepository *CoreServices::GetShaderRepository() - { - static us::ServiceTracker tracker(us::GetModuleContext()); - tracker.Open(); - return tracker.GetService(); - } - IPropertyAliases *CoreServices::GetPropertyAliases(us::ModuleContext *context) { return GetCoreService(context); } IPropertyDescriptions *CoreServices::GetPropertyDescriptions(us::ModuleContext *context) { return GetCoreService(context); } IPropertyExtensions *CoreServices::GetPropertyExtensions(us::ModuleContext *context) { return GetCoreService(context); } IPropertyFilters *CoreServices::GetPropertyFilters(us::ModuleContext *context) { return GetCoreService(context); } IPropertyPersistence *CoreServices::GetPropertyPersistence(us::ModuleContext *context) { return GetCoreService(context); } IMimeTypeProvider *CoreServices::GetMimeTypeProvider(us::ModuleContext *context) { return GetCoreService(context); } bool CoreServices::Unget(us::ModuleContext *context, const std::string & /*interfaceId*/, void *service) { bool success = false; itk::MutexLockHolder l(s_ContextToServicesMapMutex()); std::map>::iterator iter = s_ContextToServicesMap().find(context); if (iter != s_ContextToServicesMap().end()) { std::map::iterator iter2 = iter->second.find(service); if (iter2 != iter->second.end()) { us::ServiceReferenceU serviceRef = iter2->second; if (serviceRef) { success = context->UngetService(serviceRef); if (success) { iter->second.erase(iter2); } } } } return success; } } diff --git a/Modules/Core/test/files.cmake b/Modules/Core/test/files.cmake index 37ef8dbfe7..173f2c8bd3 100644 --- a/Modules/Core/test/files.cmake +++ b/Modules/Core/test/files.cmake @@ -1,199 +1,198 @@ # tests with no extra command line parameter set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## DISABLED TESTS ################################################# #mitkAbstractTransformGeometryTest.cpp #seems as tested class mitkExternAbstractTransformGeometry doesnt exist any more #mitkStateMachineContainerTest.cpp #rewrite test, indirect since no longer exported Bug 14529 #mitkRegistrationBaseTest.cpp #tested class mitkRegistrationBase doesn't exist any more #mitkSegmentationInterpolationTest.cpp #file doesn't exist! #mitkPipelineSmartPointerCorrectnessTest.cpp #file doesn't exist! #mitkITKThreadingTest.cpp #test outdated because itk::Semaphore was removed from ITK #mitkAbstractTransformPlaneGeometryTest.cpp #mitkVtkAbstractTransformPlaneGeometry doesn't exist any more #mitkTestUtilSharedLibrary.cpp #Linker problem with this test... #mitkTextOverlay2DSymbolsRenderingTest.cpp #Implementation of the tested feature is not finished yet. Ask Christoph or see bug 15104 for details. ################# RUNNING TESTS ################################################### mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkDataNodeTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkFileReaderRegistryTest.cpp #mitkFileWriterRegistryTest.cpp mitkFloatToStringTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometry3DEqualTest.cpp mitkGeometryDataIOTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkImageCastTest.cpp mitkImageEqualTest.cpp mitkImageDataItemTest.cpp mitkImageGeneratorTest.cpp mitkIOUtilTest.cpp mitkBaseDataTest.cpp mitkImportItkImageTest.cpp mitkGrabItkImageMemoryTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetTest.cpp mitkPointSetEqualTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetOnEmptyTest.cpp mitkPointSetLocaleTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetPointOperationsTest.cpp mitkProgressBarTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp mitkPropertyPersistenceTest.cpp mitkPropertyPersistenceInfoTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkSurfaceTest.cpp mitkSurfaceEqualTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeGeometryTest.cpp mitkProportionalTimeGeometryTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp mitkStepperTest.cpp mitkRenderingManagerTest.cpp mitkCompositePixelValueToStringTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkNodePredicateDataPropertyTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp - mitkShaderRepositoryTest.cpp mitkPlanePositionManagerTest.cpp mitkAffineTransformBaseTest.cpp mitkPropertyAliasesTest.cpp mitkPropertyDescriptionsTest.cpp mitkPropertyExtensionsTest.cpp mitkPropertyFiltersTest.cpp mitkTinyXMLTest.cpp mitkRawImageFileReaderTest.cpp mitkInteractionEventTest.cpp mitkLookupTableTest.cpp mitkSTLFileReaderTest.cpp mitkPointTypeConversionTest.cpp mitkVectorTypeConversionTest.cpp mitkMatrixTypeConversionTest.cpp mitkArrayTypeConversionTest.cpp mitkSurfaceToImageFilterTest.cpp mitkBaseGeometryTest.cpp mitkImageToSurfaceFilterTest.cpp mitkEqualTest.cpp mitkLineTest.cpp mitkArbitraryTimeGeometryTest mitkItkImageIOTest.cpp mitkRotatedSlice4DTest.cpp mitkLevelWindowManagerCppUnitTest.cpp mitkVectorPropertyTest.cpp mitkTemporoSpatialStringPropertyTest.cpp mitkPropertyNameHelperTest.cpp mitkNodePredicateGeometryTest.cpp ) if(MITK_ENABLE_RENDERING_TESTING) set(MODULE_TESTS ${MODULE_TESTS} mitkPlaneGeometryDataMapper2DTest.cpp mitkPointSetDataInteractorTest.cpp #since mitkInteractionTestHelper is currently creating a vtkRenderWindow mitkSurfaceVtkMapper2DTest.cpp #new rendering test in CppUnit style mitkSurfaceVtkMapper2D3DTest.cpp # comparisons/consistency 2D/3D ) endif() # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkImageTimeSelectorTest.cpp #only runs on images mitkImageAccessorTest.cpp #only runs on images ) set(MODULE_SURFACE_TESTS mitkSurfaceVtkWriterTest.cpp #only runs on surfaces ) # list of images for which the tests are run set(MODULE_TESTIMAGE US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd Png2D-bw.png ) set(MODULE_TESTSURFACE binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS mitkDataStorageTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkDataNodeTest.cpp mitkEventConfigTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkImageVtkMapper2DTransferFunctionTest.cpp mitkImageVtkMapper2DOpacityTransferFunctionTest.cpp mitkImageVtkMapper2DLookupTableTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp mitkPointSetVtkMapper2DTest.cpp mitkPointSetVtkMapper2DImageTest.cpp mitkPointSetVtkMapper2DGlyphTypeTest.cpp mitkPointSetVtkMapper2DTransformedPointsTest.cpp mitkVTKRenderWindowSizeTest.cpp mitkMultiComponentImageDataComparisonFilterTest.cpp mitkImageToItkTest.cpp mitkImageSliceSelectorTest.cpp mitkSurfaceDepthPeelingTest.cpp ) # Currently not working on windows because of a rendering timing issue # see bug 18083 for details if(NOT WIN32) set(MODULE_CUSTOM_TESTS ${MODULE_CUSTOM_TESTS} mitkSurfaceDepthSortingTest.cpp) endif() set(RESOURCE_FILES Interactions/AddAndRemovePoints.xml Interactions/globalConfig.xml Interactions/StatemachineTest.xml Interactions/StatemachineConfigTest.xml ) diff --git a/Modules/Core/test/mitkShaderRepositoryTest.cpp b/Modules/Core/test/mitkShaderRepositoryTest.cpp deleted file mode 100644 index 2a9ec98641..0000000000 --- a/Modules/Core/test/mitkShaderRepositoryTest.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*=================================================================== - -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 "mitkIShaderRepository.h" - -#include "usGetModuleContext.h" -#include "usModuleContext.h" -#include "usServiceReference.h" - -#include "mitkTestingMacros.h" - -#include - -int mitkShaderRepositoryTest(int /*argc*/, char * /*argv*/ []) -{ - MITK_TEST_BEGIN("ShaderRepository") - - us::ModuleContext *context = us::GetModuleContext(); - us::ServiceReference serviceRef = context->GetServiceReference(); - MITK_TEST_CONDITION_REQUIRED(serviceRef, "IShaderRepository service ref") - - mitk::IShaderRepository *shaderRepo = context->GetService(serviceRef); - MITK_TEST_CONDITION_REQUIRED(shaderRepo, "Check non-empty IShaderRepositry") - - mitk::IShaderRepository::Shader::Pointer shader = shaderRepo->GetShader("mitkShaderLighting"); - MITK_TEST_CONDITION_REQUIRED(shader.IsNotNull(), "Non-null mitkShaderLighting shader") - - MITK_TEST_CONDITION(shader->GetName() == "mitkShaderLighting", "Shader name") - MITK_TEST_CONDITION(!shader->GetMaterialXml().empty(), "Shader content") - - const std::string testShader = - "" - "" - "" - "" - ""; - - const std::size_t shaderCount = shaderRepo->GetShaders().size(); - - std::stringstream testShaderStream(testShader); - const std::string testShaderName = "SmoothPlastic"; - int id = shaderRepo->LoadShader(testShaderStream, testShaderName); - MITK_TEST_CONDITION_REQUIRED(id > -1, "New shader id") - MITK_TEST_CONDITION(shaderRepo->GetShaders().size() == shaderCount + 1, "Shader count") - mitk::IShaderRepository::Shader::Pointer shader2 = shaderRepo->GetShader(testShaderName); - MITK_TEST_CONDITION_REQUIRED(shader2.IsNotNull(), "Non-null shader") - MITK_TEST_CONDITION(shader2->GetId() == id, "Shader id") - MITK_TEST_CONDITION(shader2->GetName() == testShaderName, "Shader name") - mitk::IShaderRepository::Shader::Pointer shader3 = shaderRepo->GetShader(id); - MITK_TEST_CONDITION_REQUIRED(shader3.IsNotNull(), "Non-null shader") - MITK_TEST_CONDITION(shader3->GetId() == id, "Shader id") - MITK_TEST_CONDITION(shader3->GetName() == testShaderName, "Shader name") - - MITK_TEST_CONDITION_REQUIRED(shaderRepo->UnloadShader(id), "Unload shader") - MITK_TEST_CONDITION(shaderRepo->GetShader(testShaderName).IsNull(), "Null shader") - MITK_TEST_CONDITION(shaderRepo->GetShader(id).IsNull(), "Null shader") - - MITK_TEST_END() -} diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp index 696ea71023..c69115d703 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp @@ -1,198 +1,189 @@ /*=================================================================== 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 "mitkFiberBundleMapper2D.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include -#include #include mitk::FiberBundleMapper2D::FiberBundleMapper2D() : m_LineWidth(1) { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::FiberBundleMapper2D::~FiberBundleMapper2D() { } mitk::FiberBundle* mitk::FiberBundleMapper2D::GetInput() { return dynamic_cast< mitk::FiberBundle * > ( GetDataNode()->GetData() ); } void mitk::FiberBundleMapper2D::Update(mitk::BaseRenderer * renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; // Calculate time step of the input data for the specified renderer (integer value) // this method is implemented in mitkMapper this->CalculateTimeStep( renderer ); //check if updates occured in the node or on the display FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); //set renderer independent shader properties const DataNode::Pointer node = this->GetDataNode(); float thickness = 2.0; if(!this->GetDataNode()->GetPropertyValue("Fiber2DSliceThickness",thickness)) MITK_INFO << "FIBER2D SLICE THICKNESS PROPERTY ERROR"; bool fiberfading = false; if(!this->GetDataNode()->GetPropertyValue("Fiber2DfadeEFX",fiberfading)) MITK_INFO << "FIBER2D SLICE FADE EFX PROPERTY ERROR"; float fiberOpacity; this->GetDataNode()->GetOpacity(fiberOpacity, NULL); node->SetFloatProperty("shader.mitkShaderFiberClipping.fiberThickness",thickness); node->SetIntProperty("shader.mitkShaderFiberClipping.fiberFadingON",fiberfading); node->SetFloatProperty("shader.mitkShaderFiberClipping.fiberOpacity",fiberOpacity); mitk::FiberBundle* fiberBundle = this->GetInput(); if (fiberBundle==NULL) return; int lineWidth = 0; node->GetIntProperty("LineWidth", lineWidth); if (m_LineWidth!=lineWidth) { m_LineWidth = lineWidth; fiberBundle->RequestUpdate2D(); } if ( localStorage->m_LastUpdateTimeGetCurrentWorldPlaneGeometryUpdateTime() || localStorage->m_LastUpdateTimeGetUpdateTime2D() ) { this->UpdateShaderParameter(renderer); this->GenerateDataForRenderer( renderer ); } } void mitk::FiberBundleMapper2D::UpdateShaderParameter(mitk::BaseRenderer * renderer) { //get information about current position of views mitk::SliceNavigationController::Pointer sliceContr = renderer->GetSliceNavigationController(); mitk::PlaneGeometry::ConstPointer planeGeo = sliceContr->GetCurrentPlaneGeometry(); //generate according cutting planes based on the view position float planeNormal[3]; planeNormal[0] = planeGeo->GetNormal()[0]; planeNormal[1] = planeGeo->GetNormal()[1]; planeNormal[2] = planeGeo->GetNormal()[2]; float tmp1 = planeGeo->GetOrigin()[0] * planeNormal[0]; float tmp2 = planeGeo->GetOrigin()[1] * planeNormal[1]; float tmp3 = planeGeo->GetOrigin()[2] * planeNormal[2]; float thickness = tmp1 + tmp2 + tmp3; //attention, correct normalvector DataNode::Pointer node = this->GetDataNode(); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.w",thickness,renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.x",planeNormal[0],renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.y",planeNormal[1],renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.z",planeNormal[2],renderer); } // vtkActors and Mappers are feeded here void mitk::FiberBundleMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) { mitk::FiberBundle* fiberBundle = this->GetInput(); //the handler of local storage gets feeded in this method with requested data for related renderwindow FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); mitk::DataNode* node = this->GetDataNode(); if ( node == NULL ) return; vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); if (fiberPolyData == NULL) return; fiberPolyData->GetPointData()->AddArray(fiberBundle->GetFiberColors()); localStorage->m_FiberMapper->ScalarVisibilityOn(); localStorage->m_FiberMapper->SetScalarModeToUsePointFieldData(); localStorage->m_FiberMapper->SetLookupTable(m_lut); //apply the properties after the slice was set localStorage->m_PointActor->GetProperty()->SetOpacity(0.999); localStorage->m_FiberMapper->SelectColorArray("FIBER_COLORS"); localStorage->m_FiberMapper->SetInputData(fiberPolyData); localStorage->m_PointActor->SetMapper(localStorage->m_FiberMapper); localStorage->m_PointActor->GetProperty()->ShadingOn(); localStorage->m_PointActor->GetProperty()->SetLineWidth(m_LineWidth); // Applying shading properties this->ApplyShaderProperties(renderer); // We have been modified => save this for next Update() localStorage->m_LastUpdateTime.Modified(); } vtkProp* mitk::FiberBundleMapper2D::GetVtkProp(mitk::BaseRenderer *renderer) { this->Update(renderer); return m_LocalStorageHandler.GetLocalStorage(renderer)->m_PointActor; } void mitk::FiberBundleMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { Superclass::SetDefaultProperties(node, renderer, overwrite); - node->SetProperty("shader",mitk::ShaderProperty::New("mitkShaderFiberClipping")); - - // Shaders - IShaderRepository* shaderRepo = CoreServices::GetShaderRepository(); - if (shaderRepo) - { - shaderRepo->AddDefaultProperties(node, renderer, overwrite); - } +// node->SetProperty("shader",mitk::ShaderProperty::New("mitkShaderFiberClipping")); //add other parameters to propertylist node->AddProperty( "Fiber2DSliceThickness", mitk::FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "Fiber2DfadeEFX", mitk::BoolProperty::New(true), renderer, overwrite ); node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); } mitk::FiberBundleMapper2D::FBXLocalStorage::FBXLocalStorage() { m_PointActor = vtkSmartPointer::New(); m_FiberMapper = vtkSmartPointer::New(); } diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 6ee8f22a2b..722e63dbde 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,83 +1,82 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(mitk_modules Core CommandLine AppUtil DCMTesting RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction LegacyAdaptors SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QtWidgets QtWidgetsExt C3js QmlItems SegmentationUI DiffusionImaging GPGPU OpenIGTLink IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI - VtkShaders DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware Classification TumorInvasionAnalysis MatchPointRegistration MatchPointRegistrationUI BoundingShape RenderWindowManager RenderWindowManagerUI ) if(MITK_ENABLE_PIC_READER) list(APPEND mitk_modules IpPicSupportIO) endif() diff --git a/Modules/SceneSerializationBase/src/mitkEnumerationSubclassesSerializer.cpp b/Modules/SceneSerializationBase/src/mitkEnumerationSubclassesSerializer.cpp index fb4ec6ee57..416677d481 100644 --- a/Modules/SceneSerializationBase/src/mitkEnumerationSubclassesSerializer.cpp +++ b/Modules/SceneSerializationBase/src/mitkEnumerationSubclassesSerializer.cpp @@ -1,78 +1,76 @@ /*=================================================================== 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 mitkEnumerationSubclassesSerializer_h_included #define mitkEnumerationSubclassesSerializer_h_included #include "mitkEnumerationPropertySerializer.h" #include "mitkModalityProperty.h" #include "mitkPlaneOrientationProperty.h" #include "mitkPointSetShapeProperty.h" #include "mitkRenderingModeProperty.h" -#include "mitkShaderProperty.h" #include "mitkVtkInterpolationProperty.h" #include "mitkVtkRepresentationProperty.h" #include "mitkVtkResliceInterpolationProperty.h" #include "mitkVtkScalarModeProperty.h" #include "mitkVtkVolumeRenderingProperty.h" #define MITK_REGISTER_ENUM_SUB_SERIALIZER(classname) \ \ namespace mitk \ \ { \ \ class classname##Serializer \ : public EnumerationPropertySerializer\ {public : \ \ mitkClassMacro(classname##Serializer, EnumerationPropertySerializer) itkFactorylessNewMacro(Self) \ itkCloneMacro(Self) \ \ virtual BaseProperty::Pointer Deserialize(TiXmlElement * element) override{if (!element) return NULL; \ const char *sa(element->Attribute("value")); \ \ std::string s(sa ? sa : ""); \ classname::Pointer property = classname::New(); \ property->SetValue(s); \ \ return property.GetPointer(); \ } \ \ protected: \ classname##Serializer() {} \ virtual ~classname##Serializer() {} \ \ } \ ; \ \ } \ \ MITK_REGISTER_SERIALIZER(classname##Serializer); MITK_REGISTER_ENUM_SUB_SERIALIZER(PlaneOrientationProperty); -MITK_REGISTER_ENUM_SUB_SERIALIZER(ShaderProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(VtkInterpolationProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(VtkRepresentationProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(VtkResliceInterpolationProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(VtkScalarModeProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(VtkVolumeRenderingProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(ModalityProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(RenderingModeProperty); MITK_REGISTER_ENUM_SUB_SERIALIZER(PointSetShapeProperty); #endif diff --git a/Modules/SceneSerializationBase/test/mitkPropertySerializationTest.cpp b/Modules/SceneSerializationBase/test/mitkPropertySerializationTest.cpp index 014c5f1ed0..380b778218 100644 --- a/Modules/SceneSerializationBase/test/mitkPropertySerializationTest.cpp +++ b/Modules/SceneSerializationBase/test/mitkPropertySerializationTest.cpp @@ -1,281 +1,279 @@ /*=================================================================== 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 "mitkTestingMacros.h" #include "mitkCoreObjectFactory.h" #include "mitkBaseProperty.h" #include "mitkProperties.h" #include #include #include #include /* #include #include #include */ #include //#include //#include #include #include #include #include -#include #include #include #include #include #include #include #include #include "mitkBasePropertySerializer.h" #include "mitkPropertyList.h" #include "mitkPropertyListSerializer.h" #include #include #include #include /* #include #include #include #include #include #include #include #include #include #include */ void TestAllProperties(const mitk::PropertyList *propList); /**Documentation * \brief Test for all PropertySerializer classes. * */ int mitkPropertySerializationTest(int /* argc */, char * /*argv*/ []) { MITK_TEST_BEGIN("PropertySerializationTest"); mitk::PropertyListSerializer::Pointer serializer = mitk::PropertyListSerializer::New(); // make sure something from the lib is actually used (registration of // serializers) /* build list of properties that will be serialized and deserialized */ mitk::PropertyList::Pointer propList = mitk::PropertyList::New(); propList->SetProperty("booltrue", mitk::BoolProperty::New(true)); propList->SetProperty("boolfalse", mitk::BoolProperty::New(false)); propList->SetProperty("int", mitk::IntProperty::New(-32)); propList->SetProperty("float", mitk::FloatProperty::New(-31.337)); propList->SetProperty("double", mitk::DoubleProperty::New(-31.337)); propList->SetProperty("string", mitk::StringProperty::New("Hello MITK")); mitk::Point3D p3d; mitk::FillVector3D(p3d, 1.0, 2.2, -3.3); propList->SetProperty("p3d", mitk::Point3dProperty::New(p3d)); mitk::Point3I p3i; mitk::FillVector3D(p3i, 1, 2, -3); propList->SetProperty("p3i", mitk::Point3iProperty::New(p3i)); mitk::Point4D p4d; mitk::FillVector4D(p4d, 1.5, 2.6, -3.7, 4.44); propList->SetProperty("p4d", mitk::Point4dProperty::New(p4d)); mitk::Vector3D v3d; mitk::FillVector3D(v3d, 1.0, 2.2, -3.3); propList->SetProperty("v3d", mitk::Vector3DProperty::New(v3d)); propList->SetProperty("annotation", mitk::AnnotationProperty::New("My Annotation", p3d)); propList->SetProperty("clipping", mitk::ClippingProperty::New(p3d, v3d)); propList->SetProperty("color", mitk::ColorProperty::New(1.0, 0.2, 0.2)); // mitk::EnumerationProperty::Pointer en = mitk::EnumerationProperty::New(); // en->AddEnum("PC", 1); en->AddEnum("Playstation", 2); en->AddEnum("Wii", 111); en->AddEnum("XBox", 7); // en->SetValue("XBox"); // propList->SetProperty("enum", en); /* propList->SetProperty("gridrep", mitk::GridRepresentationProperty::New(2)); propList->SetProperty("gridvol", mitk::GridVolumeMapperProperty::New(0)); propList->SetProperty("OrganTypeProperty", mitk::OrganTypeProperty::New("Larynx")); */ propList->SetProperty("modality", mitk::ModalityProperty::New("Color Doppler")); // propList->SetProperty("OdfNormalizationMethodProperty", mitk::OdfNormalizationMethodProperty::New("Global // Maximum")); // propList->SetProperty("OdfScaleByProperty", mitk::OdfScaleByProperty::New("Principal Curvature")); propList->SetProperty("PlaneOrientationProperty", mitk::PlaneOrientationProperty::New("Arrows in positive direction")); - propList->SetProperty("ShaderProperty", mitk::ShaderProperty::New("fixed")); propList->SetProperty("VtkInterpolationProperty", mitk::VtkInterpolationProperty::New("Gouraud")); propList->SetProperty("VtkRepresentationProperty", mitk::VtkRepresentationProperty::New("Surface")); propList->SetProperty("VtkResliceInterpolationProperty", mitk::VtkResliceInterpolationProperty::New("Cubic")); propList->SetProperty("VtkScalarModeProperty", mitk::VtkScalarModeProperty::New("PointFieldData")); propList->SetProperty("VtkVolumeRenderingProperty", mitk::VtkVolumeRenderingProperty::New("COMPOSITE")); mitk::BoolLookupTable blt; blt.SetTableValue(0, true); blt.SetTableValue(1, false); blt.SetTableValue(2, true); propList->SetProperty("BoolLookupTableProperty", mitk::BoolLookupTableProperty::New(blt)); mitk::FloatLookupTable flt; flt.SetTableValue(0, 3.1); flt.SetTableValue(1, 3.3); flt.SetTableValue(2, 7.0); propList->SetProperty("FloatLookupTableProperty", mitk::FloatLookupTableProperty::New(flt)); mitk::IntLookupTable ilt; ilt.SetTableValue(0, 3); ilt.SetTableValue(1, 2); ilt.SetTableValue(2, 11); propList->SetProperty("IntLookupTableProperty", mitk::IntLookupTableProperty::New(ilt)); mitk::StringLookupTable slt; slt.SetTableValue(0, "Hello"); slt.SetTableValue(1, "MITK"); slt.SetTableValue(2, "world"); propList->SetProperty("StringLookupTableProperty", mitk::StringLookupTableProperty::New(slt)); propList->SetProperty("GroupTagProperty", mitk::GroupTagProperty::New()); propList->SetProperty("LevelWindowProperty", mitk::LevelWindowProperty::New(mitk::LevelWindow(100.0, 50.0))); mitk::LookupTable::Pointer lt = mitk::LookupTable::New(); lt->ChangeOpacityForAll(0.25); lt->ChangeOpacity(17, 0.88); propList->SetProperty("LookupTableProperty", mitk::LookupTableProperty::New(lt)); propList->SetProperty("StringProperty", mitk::StringProperty::New("Oh why, gruel world")); // mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); // tf->SetTransferFunctionMode(1); // propList->SetProperty("TransferFunctionProperty", mitk::TransferFunctionProperty::New(tf)); MITK_TEST_CONDITION_REQUIRED(propList->GetMap()->size() > 0, "Initialize PropertyList"); TestAllProperties(propList); /* test default property lists of basedata objects */ // activate the following tests after MaterialProperty is deleted mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(mitk::PointSet::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Image::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Surface::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::VtkWidgetRendering::New()); TestAllProperties(node->GetPropertyList()); /* node->SetData(mitk::Contour::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::ContourSet::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Mesh::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cone::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cuboid::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cylinder::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Ellipsoid::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::ExtrudedContour::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Plane::New()); TestAllProperties(node->GetPropertyList()); //node->SetData(mitk::TrackingVolume::New()); // TrackingVolume is in IGT Module, it does not have special properties, therefore we skip it here //TestAllProperties(node->GetPropertyList()); node->SetData(mitk::UnstructuredGrid::New()); TestAllProperties(node->GetPropertyList()); */ /* untested base data types: BaseDataTestImplementation RenderWindowFrame GeometryData mitk::PlaneGeometryData GradientBackground ItkBaseDataAdapter SlicedData QBallImage SeedsImage TensorImage BoundingObject BoundingObjectGroup */ MITK_TEST_END(); } void TestAllProperties(const mitk::PropertyList *propList) { assert(propList); /* try to serialize each property in the list, then deserialize again and check for equality */ for (mitk::PropertyList::PropertyMap::const_iterator it = propList->GetMap()->begin(); it != propList->GetMap()->end(); ++it) { const mitk::BaseProperty *prop = it->second; // construct name of serializer class std::string serializername = std::string(prop->GetNameOfClass()) + "Serializer"; std::list allSerializers = itk::ObjectFactoryBase::CreateAllInstance(serializername.c_str()); MITK_TEST_CONDITION(allSerializers.size() > 0, std::string("Creating serializers for ") + serializername); if (allSerializers.size() == 0) { MITK_TEST_OUTPUT(<< "serialization not possible, skipping " << prop->GetNameOfClass()); continue; } if (allSerializers.size() > 1) { MITK_TEST_OUTPUT(<< "Warning: " << allSerializers.size() << " serializers found for " << prop->GetNameOfClass() << "testing only the first one."); } mitk::BasePropertySerializer *serializer = dynamic_cast(allSerializers.begin()->GetPointer()); MITK_TEST_CONDITION(serializer != NULL, serializername + std::string(" is valid")); if (serializer != NULL) { serializer->SetProperty(prop); TiXmlElement *valueelement = NULL; try { valueelement = serializer->Serialize(); } catch (...) { } MITK_TEST_CONDITION(valueelement != NULL, std::string("Serialize property with ") + serializername); if (valueelement == NULL) { MITK_TEST_OUTPUT(<< "serialization failed, skipping deserialization"); continue; } mitk::BaseProperty::Pointer deserializedProp = serializer->Deserialize(valueelement); MITK_TEST_CONDITION(deserializedProp.IsNotNull(), "serializer created valid property"); if (deserializedProp.IsNotNull()) { MITK_TEST_CONDITION(*(deserializedProp.GetPointer()) == *prop, "deserialized property equals initial property for type " << prop->GetNameOfClass()); } } else { MITK_TEST_OUTPUT(<< "created serializer object is of class " << allSerializers.begin()->GetPointer()->GetNameOfClass()) } } // for all properties } diff --git a/Modules/VtkShaders/CMakeLists.txt b/Modules/VtkShaders/CMakeLists.txt deleted file mode 100644 index 5d92e07ec6..0000000000 --- a/Modules/VtkShaders/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -MITK_CREATE_MODULE(VtkShaders - DEPENDS MitkCore - AUTOLOAD_WITH MitkCore - WARNINGS_AS_ERRORS -) diff --git a/Modules/VtkShaders/files.cmake b/Modules/VtkShaders/files.cmake deleted file mode 100644 index 1e8df320a0..0000000000 --- a/Modules/VtkShaders/files.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(CPP_FILES - vtkXMLMaterial.cpp - vtkXMLMaterialParser.cpp - vtkXMLShader.cpp - mitkVtkShaderRepository.cpp - mitkVtkShadersActivator.cpp - mitkVtkShaderProgram.cpp -) - - -set(RESOURCE_FILES - Shaders/mitkShaderLighting.xml -) diff --git a/Modules/VtkShaders/resource/Shaders/mitkShaderLighting.xml b/Modules/VtkShaders/resource/Shaders/mitkShaderLighting.xml deleted file mode 100644 index 5f4e2c54c7..0000000000 --- a/Modules/VtkShaders/resource/Shaders/mitkShaderLighting.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - attribute vec3 scalars; - - uniform vec3 LightPosition; - uniform vec3 SkyColor; - uniform vec3 GroundColor; - - varying vec3 DiffuseColor; - - - void main(void) - { - vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); - vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); - vec3 lightVec = normalize(LightPosition - ecPosition); - float costheta = dot(tnorm, lightVec); - float a = 0.5 + 0.5 * costheta; - - DiffuseColor = mix(GroundColor, SkyColor, a); - - gl_Position = ftransform(); - - } - - - varying vec3 DiffuseColor; - void main(void) - { - gl_FragColor = vec4(DiffuseColor, 1.0); - } - - diff --git a/Modules/VtkShaders/src/mitkVtkShaderProgram.cpp b/Modules/VtkShaders/src/mitkVtkShaderProgram.cpp deleted file mode 100644 index 70aeeec8ee..0000000000 --- a/Modules/VtkShaders/src/mitkVtkShaderProgram.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*=================================================================== - -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 "mitkVtkShaderProgram.h" - -#include "vtkShader.h" - -mitk::VtkShaderProgram::VtkShaderProgram() : m_VtkShaderProgram(NULL) -{ -} - -mitk::VtkShaderProgram::~VtkShaderProgram() -{ -} - -void mitk::VtkShaderProgram::Activate() -{ - if (m_VtkShaderProgram) - { -// m_VtkShaderProgram->Use(); //TODO 18922 - } -} - -void mitk::VtkShaderProgram::Deactivate() -{ - if (m_VtkShaderProgram) - { -// m_VtkShaderProgram->Restore(); //TODO 18922 - } -} - -void mitk::VtkShaderProgram::SetVtkShaderProgram(vtkSmartPointer p) -{ - m_VtkShaderProgram = p; -} - -vtkSmartPointer mitk::VtkShaderProgram::GetVtkShaderProgram() const -{ - return m_VtkShaderProgram; -} - -itk::TimeStamp &mitk::VtkShaderProgram::GetShaderTimestampUpdate() -{ - return m_ShaderTimestampUpdate; -} diff --git a/Modules/VtkShaders/src/mitkVtkShaderProgram.h b/Modules/VtkShaders/src/mitkVtkShaderProgram.h deleted file mode 100644 index 013a780d83..0000000000 --- a/Modules/VtkShaders/src/mitkVtkShaderProgram.h +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -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 _MITKVTKSHADERPROGRAM_H_ -#define _MITKVTKSHADERPROGRAM_H_ - -#include - -#include -#include - -namespace mitk { - -/** - * \brief SHADERTODO - */ -class VtkShaderProgram : public IShaderRepository::ShaderProgram -{ -public: - - mitkClassMacro( VtkShaderProgram, IShaderRepository::ShaderProgram ) - itkFactorylessNewMacro( Self ) - - /** - * Constructor - */ - VtkShaderProgram(); - - /** - * Destructor - */ - virtual ~VtkShaderProgram(); - - virtual void Activate() override; - virtual void Deactivate() override; - - void SetVtkShaderProgram(vtkSmartPointer p); - vtkSmartPointer GetVtkShaderProgram() const; - itk::TimeStamp& GetShaderTimestampUpdate(); - -private: - - vtkSmartPointer m_VtkShaderProgram; - itk::TimeStamp m_ShaderTimestampUpdate; - -}; - -} //end of namespace mitk -#endif diff --git a/Modules/VtkShaders/src/mitkVtkShaderRepository.cpp b/Modules/VtkShaders/src/mitkVtkShaderRepository.cpp deleted file mode 100644 index c331847014..0000000000 --- a/Modules/VtkShaders/src/mitkVtkShaderRepository.cpp +++ /dev/null @@ -1,617 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -#define SR_INFO MITK_INFO("shader.repository") -#define SR_WARN MITK_WARN("shader.repository") -#define SR_ERROR MITK_ERROR("shader.repository") - -#include "mitkVtkShaderRepository.h" -#include "mitkVtkShaderProgram.h" -#include "mitkShaderProperty.h" -#include "mitkProperties.h" -#include "mitkDataNode.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include - -int mitk::VtkShaderRepository::shaderId = 0; -const bool mitk::VtkShaderRepository::debug = false; - -mitk::VtkShaderRepository::VtkShaderRepository() -{ - LoadShaders(); -} - -mitk::VtkShaderRepository::~VtkShaderRepository() -{ -} - -mitk::IShaderRepository::ShaderProgram::Pointer mitk::VtkShaderRepository::CreateShaderProgram() -{ - mitk::IShaderRepository::ShaderProgram::Pointer shaderProg = (mitk::VtkShaderProgram::New()).GetPointer(); - return shaderProg; -} - -void mitk::VtkShaderRepository::LoadShaders() -{ - itk::Directory::Pointer dir = itk::Directory::New(); - - std::string dirPath = "./vtk_shader"; - - if( dir->Load( dirPath.c_str() ) ) - { - int n = dir->GetNumberOfFiles(); - for(int r=0;rGetFile( r ); - - std::string extension = itksys::SystemTools::GetFilenameExtension(filename); - - if(extension.compare(".xml")==0) - { - Shader::Pointer element=Shader::New(); - - element->SetName(itksys::SystemTools::GetFilenameWithoutExtension(filename)); - std::string filePath = dirPath + std::string("/") + element->GetName() + std::string(".xml"); - - SR_INFO(debug) << "found shader '" << element->GetName() << "'"; - - std::ifstream fileStream(filePath.c_str()); - element->LoadXmlShader(fileStream); - - shaders.push_back(element); - } - } - } -} - -mitk::VtkShaderRepository::Shader::Pointer mitk::VtkShaderRepository::GetShaderImpl(const std::string &name) const -{ - std::list::const_iterator i = shaders.begin(); - - while( i != shaders.end() ) - { - if( (*i)->GetName() == name) - return (*i); - - i++; - } - - return Shader::Pointer(); -} - -int mitk::VtkShaderRepository::LoadShader(std::istream& stream, const std::string& filename) -{ - Shader::Pointer element=Shader::New(); - element->SetName(filename); - element->SetId(shaderId++); - element->LoadXmlShader(stream); - shaders.push_back(element); - SR_INFO(debug) << "found shader '" << element->GetName() << "'"; - return element->GetId(); -} - -bool mitk::VtkShaderRepository::UnloadShader(int id) -{ - for (std::list::iterator i = shaders.begin(); - i != shaders.end(); ++i) - { - if ((*i)->GetId() == id) - { - shaders.erase(i); - return true; - } - } - return false; -} - -mitk::VtkShaderRepository::Shader::Shader() -{ -} - -mitk::VtkShaderRepository::Shader::~Shader() -{ -} - -void mitk::VtkShaderRepository::Shader::SetVertexShaderCode(const std::string& code) -{ - this->m_VertexShaderCode = code; -} - -std::string mitk::VtkShaderRepository::Shader::GetVertexShaderCode() const -{ - return this->m_VertexShaderCode; -} - -void mitk::VtkShaderRepository::Shader::SetFragmentShaderCode(const std::string& code) -{ - this->m_FragmentShaderCode = code; -} - -std::string mitk::VtkShaderRepository::Shader::GetFragmentShaderCode() const -{ - return this->m_FragmentShaderCode; -} - -void mitk::VtkShaderRepository::Shader::SetGeometryShaderCode(const std::string& code) -{ - this->m_GeometryShaderCode = code; -} - -std::string mitk::VtkShaderRepository::Shader::GetGeometryShaderCode() const -{ - return this->m_GeometryShaderCode; -} - -std::list mitk::VtkShaderRepository::Shader::GetUniforms() const -{ - return uniforms; -} - -void mitk::VtkShaderRepository::Shader::LoadXmlShader(std::istream& stream) -{ - std::string content; - content.reserve(2048); - char buffer[2048]; - while (stream.read(buffer, sizeof(buffer))) - { - content.append(buffer, sizeof(buffer)); - } - content.append(buffer, static_cast(stream.gcount())); - - if (content.empty()) return; - - this->SetMaterialXml(content); - - vtkXMLMaterialParser* parser = vtkXMLMaterialParser::New(); - vtkXMLMaterial* material = vtkXMLMaterial::New(); - parser->SetMaterial(material); - parser->Parse(content.c_str()); - parser->Delete(); - if (material == NULL) return; - - // Vertexshader uniforms - { - vtkXMLShader *s=material->GetVertexShader(); - if (s) - { - SetVertexShaderCode(s->GetCode()); - vtkXMLDataElement *x=s->GetRootElement(); - int n=x->GetNumberOfNestedElements(); - for(int r=0;rGetNestedElement(r); - if(strcmp(y->GetName(),"ApplicationUniform") == 0 || - strcmp(y->GetName(), "Uniform") == 0) - { - Uniform::Pointer element=Uniform::New(); - element->LoadFromXML(y); - uniforms.push_back(element); - } - } - } - } - - // Fragmentshader uniforms - { - vtkXMLShader *s=material->GetFragmentShader(); - if (s) - { - SetFragmentShaderCode(s->GetCode()); - vtkXMLDataElement *x=s->GetRootElement(); - int n=x->GetNumberOfNestedElements(); - for(int r=0;rGetNestedElement(r); - if(strcmp(y->GetName(),"ApplicationUniform") == 0 || - strcmp(y->GetName(), "Uniform") == 0) - { - Uniform::Pointer element=Uniform::New(); - element->LoadFromXML(y); - uniforms.push_back(element); - } - } - } - } - - // Geometryshader uniforms - { - vtkXMLShader *s=material->GetGeometryShader(); - if (s) - { - SetGeometryShaderCode(s->GetCode()); - vtkXMLDataElement *x=s->GetRootElement(); - int n=x->GetNumberOfNestedElements(); - for(int r=0;rGetNestedElement(r); - if(strcmp(y->GetName(),"ApplicationUniform") == 0 || - strcmp(y->GetName(), "Uniform") == 0) - { - Uniform::Pointer element=Uniform::New(); - element->LoadFromXML(y); - uniforms.push_back(element); - } - } - } - } - material->Delete(); - -} - -mitk::VtkShaderRepository::Shader::Uniform::Uniform() -{ -} - -mitk::VtkShaderRepository::Shader::Uniform::~Uniform() -{ -} - -void mitk::VtkShaderRepository::Shader::Uniform::LoadFromXML(vtkXMLDataElement *y) -{ - //MITK_INFO << "found uniform '" << y->GetAttribute("name") << "' type=" << y->GetAttribute("type");// << " default=" << y->GetAttribute("value"); - - name = y->GetAttribute("name"); - - const char *sType=y->GetAttribute("type"); - - if(!strcmp(sType,"float")) - type=glsl_float; - else if(!strcmp(sType,"vec2")) - type=glsl_vec2; - else if(!strcmp(sType,"vec3")) - type=glsl_vec3; - else if(!strcmp(sType,"vec4")) - type=glsl_vec4; - else if(!strcmp(sType,"int")) - type=glsl_int; - else if(!strcmp(sType,"ivec2")) - type=glsl_ivec2; - else if(!strcmp(sType,"ivec3")) - type=glsl_ivec3; - else if(!strcmp(sType,"ivec4")) - type=glsl_ivec4; - else - { - type=glsl_none; - SR_WARN << "unknown type for uniform '" << name << "'" ; - } - - - defaultFloat[0]=defaultFloat[1]=defaultFloat[2]=defaultFloat[3]=0; - - const char *sDefault=y->GetAttribute("value"); - - if(sDefault) - { - switch(type) - { - case glsl_float: - sscanf(sDefault,"%f",&defaultFloat[0]); - break; - - case glsl_vec2: - sscanf(sDefault,"%f %f",&defaultFloat[0],&defaultFloat[1]); - break; - - case glsl_vec3: - sscanf(sDefault,"%f %f %f",&defaultFloat[0],&defaultFloat[1],&defaultFloat[2]); - break; - - case glsl_vec4: - sscanf(sDefault,"%f %f %f %f",&defaultFloat[0],&defaultFloat[1],&defaultFloat[2],&defaultFloat[3]); - break; - - case glsl_int: - sscanf(sDefault,"%d",&defaultInt[0]); - break; - - case glsl_ivec2: - sscanf(sDefault,"%d %d",&defaultInt[0],&defaultInt[1]); - break; - - case glsl_ivec3: - sscanf(sDefault,"%d %d %d",&defaultInt[0],&defaultInt[1],&defaultInt[2]); - break; - - case glsl_ivec4: - sscanf(sDefault,"%d %d %d %d",&defaultInt[0],&defaultInt[1],&defaultInt[2],&defaultInt[3]); - break; - - case glsl_none: - break; - } - } -} - -void mitk::VtkShaderRepository::AddDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) const -{ - node->AddProperty( "shader", mitk::ShaderProperty::New(), renderer, overwrite ); - - std::list::const_iterator i = shaders.begin(); - - while( i != shaders.end() ) - { - std::list uniforms = (*i)->GetUniforms(); - - std::string shaderName = (*i)->GetName(); - - std::list::const_iterator j = uniforms.begin(); - - while( j != uniforms.end() ) - { - std::string propertyName = "shader." + shaderName + "." + (*j)->name; - - switch( (*j)->type ) - { - case Shader::Uniform::glsl_float: - node->AddProperty( propertyName.c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[0] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_vec2: - node->AddProperty( (propertyName+".x").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[1] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_vec3: - node->AddProperty( (propertyName+".x").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[1] ), renderer, overwrite ); - node->AddProperty( (propertyName+".z").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[2] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_vec4: - node->AddProperty( (propertyName+".x").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[1] ), renderer, overwrite ); - node->AddProperty( (propertyName+".z").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[2] ), renderer, overwrite ); - node->AddProperty( (propertyName+".w").c_str(), mitk::FloatProperty::New( (*j)->defaultFloat[3] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_int: - node->AddProperty( propertyName.c_str(), mitk::IntProperty::New( (*j)->defaultInt[0] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_ivec2: - node->AddProperty( (propertyName+".x").c_str(), mitk::IntProperty::New( (*j)->defaultInt[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::IntProperty::New( (*j)->defaultInt[1] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_ivec3: - node->AddProperty( (propertyName+".x").c_str(), mitk::IntProperty::New( (*j)->defaultInt[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::IntProperty::New( (*j)->defaultInt[1] ), renderer, overwrite ); - node->AddProperty( (propertyName+".z").c_str(), mitk::IntProperty::New( (*j)->defaultInt[2] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_ivec4: - node->AddProperty( (propertyName+".x").c_str(), mitk::IntProperty::New( (*j)->defaultInt[0] ), renderer, overwrite ); - node->AddProperty( (propertyName+".y").c_str(), mitk::IntProperty::New( (*j)->defaultInt[1] ), renderer, overwrite ); - node->AddProperty( (propertyName+".z").c_str(), mitk::IntProperty::New( (*j)->defaultInt[2] ), renderer, overwrite ); - node->AddProperty( (propertyName+".w").c_str(), mitk::IntProperty::New( (*j)->defaultInt[3] ), renderer, overwrite ); - break; - - case Shader::Uniform::glsl_none: - break; - } - - j++; - - } - - i++; - } - - -} - -std::list mitk::VtkShaderRepository::GetShaders() const -{ - std::list result; - for (std::list::const_iterator i = shaders.begin(); - i != shaders.end(); ++i) - { - result.push_back(i->GetPointer()); - } - return result; -} - -mitk::IShaderRepository::Shader::Pointer mitk::VtkShaderRepository::GetShader(const std::string& name) const -{ - for (std::list::const_iterator i = shaders.begin(); - i != shaders.end(); ++i) - { - if ((*i)->GetName() == name) return i->GetPointer(); - } - return IShaderRepository::Shader::Pointer(); -} - -mitk::IShaderRepository::Shader::Pointer mitk::VtkShaderRepository::GetShader(int id) const -{ - for (std::list::const_iterator i = shaders.begin(); - i != shaders.end(); ++i) - { - if ((*i)->GetId() == id) return i->GetPointer(); - } - return IShaderRepository::Shader::Pointer(); -} - -void -mitk::VtkShaderRepository::UpdateShaderProgram(ShaderProgram* shaderProgram, - DataNode* node, BaseRenderer* renderer) const -{ - VtkShaderProgram* mitkVtkShaderProgram = dynamic_cast(shaderProgram); - mitk::ShaderProperty *sep= dynamic_cast(node->GetProperty("shader",renderer)); - if(!sep) - { - mitkVtkShaderProgram->SetVtkShaderProgram(0); - return; - } - - Shader::Pointer s = GetShaderImpl(sep->GetValueAsString()); - - // Need update pipeline mode - if(sep->GetMTime() > mitkVtkShaderProgram->GetShaderTimestampUpdate().GetMTime()) - { - if( s.IsNull() ) - { - mitkVtkShaderProgram->SetVtkShaderProgram(0); - mitkVtkShaderProgram->GetShaderTimestampUpdate().Modified(); - return; - } - - vtkSmartPointer program = vtkSmartPointer::New(); - -// program->SetContext(renderer->GetRenderWindow());//TODO 18922 - // The vertext shader - vtkShader *shader = vtkShader::New(); -// shader->SetType(VTK_SHADER_TYPE_VERTEX);//TODO 18922 -// shader->SetSourceCode(s->GetVertexShaderCode().c_str());//TODO 18922 -// shader->SetContext(renderer->GetRenderWindow());//TODO 18922 -// program->GetShaders()->AddItem(shader);//TODO 18922 - shader->Delete(); - - // The fragment shader - shader = vtkShader::New(); -// shader->SetType(VTK_SHADER_TYPE_FRAGMENT);//TODO 18922 -// shader->SetSourceCode(s->GetFragmentShaderCode().c_str());//TODO 18922 -// shader->SetContext(renderer->GetRenderWindow());//TODO 18922 -// program->GetShaders()->AddItem(shader);//TODO 18922 - shader->Delete(); - - if(s->GetGeometryShaderCode().size()>0) - { - // The Geometry shader - shader = vtkShader::New(); -// shader->SetType(VTK_SHADER_TYPE_GEOMETRY);//TODO 18922 -// shader->SetSourceCode(s->GetGeometryShaderCode().c_str());//TODO 18922 -// shader->SetContext(renderer->GetRenderWindow());//TODO 18922 -// program->GetShaders()->AddItem(shader);//TODO 18922 - shader->Delete(); - } - -// program->Build();//TODO 18922 - - mitkVtkShaderProgram->SetVtkShaderProgram(program); - - mitkVtkShaderProgram->GetShaderTimestampUpdate().Modified(); - } - - if(s.IsNull()) - return; - - // update uniforms - vtkShaderProgram *p = mitkVtkShaderProgram->GetVtkShaderProgram(); - - if(!p) - return; - - std::list::const_iterator j = s->uniforms.begin(); - - while( j != s->uniforms.end() ) - { - std::string propertyName = "shader." + s->GetName() + "." + (*j)->name; - - // MITK_INFO << "querying property: " << propertyName; - - // mitk::BaseProperty *p = node->GetProperty( propertyName.c_str(), renderer ); - - // if( p && p->GetMTime() > MTime.GetMTime() ) - { - float fval[4]; - int ival[4]; - - // MITK_INFO << "copying property " << propertyName << " ->->- " << (*j)->name << " type=" << (*j)->type ; - - - switch( (*j)->type ) - { - case Shader::Uniform::glsl_float: - node->GetFloatProperty( propertyName.c_str(), fval[0], renderer ); -// p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 1, fval);//TODO 18922 - break; - - case Shader::Uniform::glsl_vec2: - node->GetFloatProperty( (propertyName+".x").c_str(), fval[0], renderer ); - node->GetFloatProperty( (propertyName+".y").c_str(), fval[1], renderer ); -// p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 2, fval);//TODO 18922 - break; - - case Shader::Uniform::glsl_vec3: - node->GetFloatProperty( (propertyName+".x").c_str(), fval[0], renderer ); - node->GetFloatProperty( (propertyName+".y").c_str(), fval[1], renderer ); - node->GetFloatProperty( (propertyName+".z").c_str(), fval[2], renderer ); - //p->SetUniform3f( (*j)->name.c_str(), fval );//TODO 18922 -// p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 3, fval);//TODO 18922 - break; - - case Shader::Uniform::glsl_vec4: - node->GetFloatProperty( (propertyName+".x").c_str(), fval[0], renderer ); - node->GetFloatProperty( (propertyName+".y").c_str(), fval[1], renderer ); - node->GetFloatProperty( (propertyName+".z").c_str(), fval[2], renderer ); - node->GetFloatProperty( (propertyName+".w").c_str(), fval[3], renderer ); -// p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 4, fval);//TODO 18922 - break; - - case Shader::Uniform::glsl_int: - node->GetIntProperty( propertyName.c_str(), ival[0], renderer ); -// p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 1, ival);//TODO 18922 - break; - - case Shader::Uniform::glsl_ivec2: - node->GetIntProperty( (propertyName+".x").c_str(), ival[0], renderer ); - node->GetIntProperty( (propertyName+".y").c_str(), ival[1], renderer ); -// p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 2, ival);//TODO 18922 - break; - - case Shader::Uniform::glsl_ivec3: - node->GetIntProperty( (propertyName+".x").c_str(), ival[0], renderer ); - node->GetIntProperty( (propertyName+".y").c_str(), ival[1], renderer ); - node->GetIntProperty( (propertyName+".z").c_str(), ival[2], renderer ); - //p->SetUniform3f( (*j)->name.c_str(), fval ); -// p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 3, ival); //TODO 18922 - break; - - case Shader::Uniform::glsl_ivec4: - node->GetIntProperty( (propertyName+".x").c_str(), ival[0], renderer ); - node->GetIntProperty( (propertyName+".y").c_str(), ival[1], renderer ); - node->GetIntProperty( (propertyName+".z").c_str(), ival[2], renderer ); - node->GetIntProperty( (propertyName+".w").c_str(), ival[3], renderer ); -// p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 4, ival); //TODO 18922 - break; - - case Shader::Uniform::glsl_none: - break; - - } - } - - j++; - } - - return; -} diff --git a/Modules/VtkShaders/src/mitkVtkShaderRepository.h b/Modules/VtkShaders/src/mitkVtkShaderRepository.h deleted file mode 100644 index 14e77220ba..0000000000 --- a/Modules/VtkShaders/src/mitkVtkShaderRepository.h +++ /dev/null @@ -1,164 +0,0 @@ -/*=================================================================== - -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 _MITKVTKSHADERREPOSITORY_H_ -#define _MITKVTKSHADERREPOSITORY_H_ - -#include "mitkIShaderRepository.h" -#include -#include - -class vtkXMLDataElement; -class vtkXMLMaterial; -class vtkProperty; - -namespace mitk -{ - /** - * \brief Management class for vtkShader XML descriptions. - * - * Looks for all XML shader files in a given directory and adds default properties - * for each shader object (shader uniforms) to the specified mitk::DataNode. - * - * Additionally, it provides a utility function for applying properties for shaders - * in mappers. - */ - class VtkShaderRepository : public IShaderRepository - { - protected: - class Shader : public IShaderRepository::Shader - { - public: - mitkClassMacro(Shader, IShaderRepository::Shader) itkFactorylessNewMacro(Self) - - class Uniform : public itk::Object - { - public: - mitkClassMacroItkParent(Uniform, itk::Object) itkFactorylessNewMacro(Self) - - enum Type { - glsl_none, - glsl_float, - glsl_vec2, - glsl_vec3, - glsl_vec4, - glsl_int, - glsl_ivec2, - glsl_ivec3, - glsl_ivec4 - }; - - /** - * Constructor - */ - Uniform(); - - /** - * Destructor - */ - ~Uniform(); - - Type type; - std::string name; - - int defaultInt[4]; - float defaultFloat[4]; - - void LoadFromXML(vtkXMLDataElement *e); - }; - - std::list uniforms; - - /** - * Constructor - */ - Shader(); - - /** - * Destructor - */ - ~Shader(); - - void SetVertexShaderCode(const std::string &code); - std::string GetVertexShaderCode() const; - - void SetFragmentShaderCode(const std::string &code); - std::string GetFragmentShaderCode() const; - - void SetGeometryShaderCode(const std::string &code); - std::string GetGeometryShaderCode() const; - - std::list GetUniforms() const; - - private: - friend class VtkShaderRepository; - - std::string m_VertexShaderCode; - std::string m_FragmentShaderCode; - std::string m_GeometryShaderCode; - - void LoadXmlShader(std::istream &stream); - }; - - void LoadShaders(); - - Shader::Pointer GetShaderImpl(const std::string &name) const; - - private: - std::list shaders; - - static int shaderId; - static const bool debug; - - public: - /** - * Constructor - */ - VtkShaderRepository(); - - /** - * Destructor - */ - ~VtkShaderRepository(); - - ShaderProgram::Pointer CreateShaderProgram() override; - - std::list GetShaders() const override; - - IShaderRepository::Shader::Pointer GetShader(const std::string &name) const override; - - IShaderRepository::Shader::Pointer GetShader(int id) const override; - - /** \brief Adds all parsed shader uniforms to property list of the given DataNode; - * used by mappers. - */ - void AddDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) const override; - - /** \brief Applies shader and shader specific variables of the specified DataNode - * to the VTK object by updating the shader variables of its vtkProperty. - */ - - int LoadShader(std::istream &stream, const std::string &name) override; - - bool UnloadShader(int id) override; - - void UpdateShaderProgram(mitk::IShaderRepository::ShaderProgram *shaderProgram, - DataNode *node, - BaseRenderer *renderer) const override; - }; - -} // end of namespace mitk -#endif diff --git a/Modules/VtkShaders/src/mitkVtkShadersActivator.cpp b/Modules/VtkShaders/src/mitkVtkShadersActivator.cpp deleted file mode 100644 index c910a6e66c..0000000000 --- a/Modules/VtkShaders/src/mitkVtkShadersActivator.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*=================================================================== - -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 -#include -#include -#include -#include -#include -#include - -namespace mitk -{ - class VtkShadersActivator : public us::ModuleActivator - { - public: - VtkShadersActivator() {} - ~VtkShadersActivator() {} - void Load(us::ModuleContext *context) override - { - m_VtkShaderRepository.reset(new VtkShaderRepository); - context->RegisterService(m_VtkShaderRepository.get()); - } - - void Unload(us::ModuleContext *) override { m_VtkShaderRepository.reset(NULL); } - private: - VtkShadersActivator(const VtkShadersActivator &); - VtkShadersActivator &operator=(const VtkShadersActivator &); - - std::unique_ptr m_VtkShaderRepository; - }; -} - -US_EXPORT_MODULE_ACTIVATOR(mitk::VtkShadersActivator) diff --git a/Modules/VtkShaders/src/vtkXMLMaterial.cpp b/Modules/VtkShaders/src/vtkXMLMaterial.cpp deleted file mode 100644 index ab5602a23d..0000000000 --- a/Modules/VtkShaders/src/vtkXMLMaterial.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLMaterial.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ - -#include "vtkXMLMaterial.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkXMLDataElement.h" -#include "vtkXMLMaterialParser.h" -#include "vtkXMLShader.h" - -#include -#include - -class vtkXMLMaterialInternals -{ -public: - typedef std::vector VectorOfElements; - typedef std::vector> VectorOfShaders; - VectorOfElements Properties; - VectorOfShaders VertexShaders; - VectorOfShaders FragmentShaders; - VectorOfShaders GeometryShaders; - VectorOfElements Textures; - void Initialize() - { - this->Properties.clear(); - this->VertexShaders.clear(); - this->FragmentShaders.clear(); - this->GeometryShaders.clear(); - this->Textures.clear(); - } -}; - -vtkStandardNewMacro(vtkXMLMaterial); - -//----------------------------------------------------------------------------- -vtkXMLMaterial::vtkXMLMaterial() -{ - this->RootElement = nullptr; - this->Internals = new vtkXMLMaterialInternals; -} - -//----------------------------------------------------------------------------- -vtkXMLMaterial::~vtkXMLMaterial() -{ - this->SetRootElement(nullptr); - delete this->Internals; -} - -vtkXMLMaterial *vtkXMLMaterial::CreateInstance(const char *name) -{ - if (!name) - { - return nullptr; - } - - vtkXMLMaterialParser *parser = vtkXMLMaterialParser::New(); - vtkXMLMaterial *material = vtkXMLMaterial::New(); - parser->SetMaterial(material); - - // First, look for material library files. - // Then, look for Repository files. - - char *filename = vtkXMLShader::LocateFile(name); - if (filename) - { - parser->SetFileName(filename); - delete[] filename; - parser->Parse(); - parser->Delete(); - return material; - } - - parser->Delete(); - material->Delete(); - return nullptr; -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterial::SetRootElement(vtkXMLDataElement *root) -{ - this->Internals->Initialize(); - - vtkSetObjectBodyMacro(RootElement, vtkXMLDataElement, root); - if (this->RootElement) - { - // Update the internal data structure to - // avoid repeated searches. - int numElems = this->RootElement->GetNumberOfNestedElements(); - for (int i = 0; i < numElems; i++) - { - vtkXMLDataElement *elem = this->RootElement->GetNestedElement(i); - const char *name = elem->GetName(); - if (!name) - { - continue; - } - if (strcmp(name, "Property") == 0) - { - this->Internals->Properties.push_back(elem); - } - else if (strcmp(name, "Shader") == 0) - { - vtkXMLShader *shader = vtkXMLShader::New(); - shader->SetRootElement(elem); - - switch (shader->GetScope()) - { - case vtkXMLShader::SCOPE_VERTEX: - this->Internals->VertexShaders.push_back(shader); - break; - case vtkXMLShader::SCOPE_FRAGMENT: - this->Internals->FragmentShaders.push_back(shader); - break; - case vtkXMLShader::SCOPE_GEOMETRY: - this->Internals->GeometryShaders.push_back(shader); - break; - default: - vtkErrorMacro("Invalid scope for shader: " << shader->GetName()); - } - - shader->Delete(); - } - else if (strcmp(name, "Texture") == 0) - { - this->Internals->Textures.push_back(elem); - } - } - } -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterial::GetNumberOfProperties() -{ - return static_cast(this->Internals->Properties.size()); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterial::GetNumberOfTextures() -{ - return static_cast(this->Internals->Textures.size()); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterial::GetNumberOfVertexShaders() -{ - return static_cast(this->Internals->VertexShaders.size()); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterial::GetNumberOfFragmentShaders() -{ - return static_cast(this->Internals->FragmentShaders.size()); -} - -int vtkXMLMaterial::GetNumberOfGeometryShaders() -{ - return static_cast(this->Internals->GeometryShaders.size()); -} - -//----------------------------------------------------------------------------- -vtkXMLDataElement *vtkXMLMaterial::GetProperty(int id) -{ - if (id < this->GetNumberOfProperties()) - { - return this->Internals->Properties[id]; - } - return nullptr; -} - -//----------------------------------------------------------------------------- -vtkXMLDataElement *vtkXMLMaterial::GetTexture(int index) -{ - if (index < this->GetNumberOfTextures()) - { - return this->Internals->Textures[index]; - } - return nullptr; -} - -//----------------------------------------------------------------------------- -vtkXMLShader *vtkXMLMaterial::GetVertexShader(int id) -{ - if (id < this->GetNumberOfVertexShaders()) - { - return this->Internals->VertexShaders[id].GetPointer(); - } - return nullptr; -} - -//----------------------------------------------------------------------------- -vtkXMLShader *vtkXMLMaterial::GetFragmentShader(int id) -{ - if (id < this->GetNumberOfFragmentShaders()) - { - return this->Internals->FragmentShaders[id].GetPointer(); - } - return nullptr; -} - -vtkXMLShader *vtkXMLMaterial::GetGeometryShader(int id) -{ - if (id < this->GetNumberOfGeometryShaders()) - { - return this->Internals->GeometryShaders[id].GetPointer(); - } - return nullptr; -} - -//---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// Description: -// Get the style the shaders. -// \post valid_result: result==1 || result==2 -int vtkXMLMaterial::GetShaderStyle() -{ - int result = 1; - int vStyle = 0; - if (this->GetVertexShader()) - { - vStyle = this->GetVertexShader()->GetStyle(); - } - int fStyle = 0; - if (this->GetFragmentShader()) - { - fStyle = this->GetFragmentShader()->GetStyle(); - } - int gStyle = 0; - if (this->GetGeometryShader()) - { - gStyle = this->GetGeometryShader()->GetStyle(); - } - if (vStyle != 0 && fStyle != 0 && !gStyle && vStyle != fStyle) - { - vtkErrorMacro(<< "vertex shader and fragment shader style differ."); - } - else - { - if (vStyle != 0) - { - result = vStyle; - } - else - { - result = fStyle; - } - } - - assert("post: valid_result" && (result == 1 || result == 2)); - return result; -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterial::PrintSelf(ostream &os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "Number of Properties: " << this->GetNumberOfProperties() << endl; - os << indent << "Number of Vertex Shaders: " << this->GetNumberOfVertexShaders() << endl; - os << indent << "Number of Fragment Shaders: " << this->GetNumberOfFragmentShaders() << endl; - os << indent << "RootElement: "; - if (this->RootElement) - { - os << endl; - this->RootElement->PrintSelf(os, indent.GetNextIndent()); - } - else - { - os << "(null)" << endl; - } -} diff --git a/Modules/VtkShaders/src/vtkXMLMaterial.h b/Modules/VtkShaders/src/vtkXMLMaterial.h deleted file mode 100644 index 61c675f58e..0000000000 --- a/Modules/VtkShaders/src/vtkXMLMaterial.h +++ /dev/null @@ -1,122 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLMaterial.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ -// .NAME vtkXMLMaterial - encapsulates a VTK Material description. -// .SECTION Description -// vtkXMLMaterial encapsulates VTK Material description. It keeps a pointer -// to vtkXMLDataElement that defines the material and provides -// access to Shaders/Properties defined in it. -// .SECTION Thanks -// Shader support in VTK includes key contributions by Gary Templet at -// Sandia National Labs. - -#ifndef __vtkXMLMaterial_h -#define __vtkXMLMaterial_h - -#include "vtkObject.h" -#include "vtkRenderingCoreModule.h" // For export macro - -class vtkXMLDataElement; -class vtkXMLMaterialInternals; -class vtkXMLShader; - -class vtkXMLMaterial : public vtkObject -{ -public: - static vtkXMLMaterial *New(); - vtkTypeMacro(vtkXMLMaterial, vtkObject); - void PrintSelf(ostream &os, vtkIndent indent) override; - - // Description: - // Create a new instance. It searches for the material - // using the following order: first, check the MaterialLibrary; second, - // treat the name as an absolute path and try to locate it; third, - // search the Material repository. Returns null is it fails to - // locate the material. - static vtkXMLMaterial *CreateInstance(const char *name); - - // Description: - // Get number of elements of type Property. - int GetNumberOfProperties(); - - // Description: - // Get number of elements of type Texture. - int GetNumberOfTextures(); - - // Description: - // Get number of Vertex shaders. - int GetNumberOfVertexShaders(); - - // Description: - // Get number of fragment shaders. - int GetNumberOfFragmentShaders(); - int GetNumberOfGeometryShaders(); - - // Description: - // Get the ith vtkXMLDataElement of type . - vtkXMLDataElement *GetProperty(int id = 0); - - // Description: - // Get the ith vtkXMLDataElement of type . - vtkXMLDataElement *GetTexture(int id = 0); - - // Description: - // Get the ith vtkXMLDataElement of type . - vtkXMLShader *GetVertexShader(int id = 0); - - // Description: - // Get the ith vtkXMLDataElement of type . - vtkXMLShader *GetFragmentShader(int id = 0); - - vtkXMLShader *GetGeometryShader(int id = 0); - - // Description: - // Get/Set the XML root element that describes this material. - vtkGetObjectMacro(RootElement, vtkXMLDataElement); - void SetRootElement(vtkXMLDataElement *); - - // Description: - // Get the style the shaders. - // \post valid_result: result==1 || result==2 - int GetShaderStyle(); - -protected: - vtkXMLMaterial(); - ~vtkXMLMaterial(); - - vtkXMLDataElement *RootElement; - vtkXMLMaterialInternals *Internals; - -private: - vtkXMLMaterial(const vtkXMLMaterial &); // Not implemented. - void operator=(const vtkXMLMaterial &); // Not implemented. -}; - -#endif diff --git a/Modules/VtkShaders/src/vtkXMLMaterialParser.cpp b/Modules/VtkShaders/src/vtkXMLMaterialParser.cpp deleted file mode 100644 index 0a85a9a7f6..0000000000 --- a/Modules/VtkShaders/src/vtkXMLMaterialParser.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLMaterialParser.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ - -/* - * Copyright 2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the - * U.S. Government. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that this Notice and any - * statement of authorship are reproduced on all copies. - */ - -#include "vtkXMLMaterialParser.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkXMLDataElement.h" -#include "vtkXMLMaterial.h" - -#include "vtkXMLUtilities.h" - -#include - -//----------------------------------------------------------------------------- -class vtkXMLMaterialParserInternals -{ -public: - typedef std::vector> VectorOfElements; - VectorOfElements Stack; -}; - -//----------------------------------------------------------------------------- -vtkStandardNewMacro(vtkXMLMaterialParser); -vtkCxxSetObjectMacro(vtkXMLMaterialParser, Material, vtkXMLMaterial); - -//----------------------------------------------------------------------------- -vtkXMLMaterialParser::vtkXMLMaterialParser() -{ - this->Material = vtkXMLMaterial::New(); - this->Material->Register(this); - this->Material->Delete(); - this->Internals = new vtkXMLMaterialParserInternals; -} - -//----------------------------------------------------------------------------- -vtkXMLMaterialParser::~vtkXMLMaterialParser() -{ - delete this->Internals; - this->SetMaterial(nullptr); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterialParser::Parse(const char *str) -{ - return this->Superclass::Parse(str); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterialParser::Parse(const char *str, unsigned int length) -{ - return this->Superclass::Parse(str, length); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterialParser::Parse() -{ - this->Internals->Stack.clear(); - return this->Superclass::Parse(); -} - -//----------------------------------------------------------------------------- -int vtkXMLMaterialParser::InitializeParser() -{ - int ret = this->Superclass::InitializeParser(); - if (ret) - { - this->Internals->Stack.clear(); - } - return ret; -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterialParser::StartElement(const char *name, const char **atts) -{ - vtkXMLDataElement *element = vtkXMLDataElement::New(); - element->SetName(name); - element->SetXMLByteIndex(this->GetXMLByteIndex()); - vtkXMLUtilities::ReadElementFromAttributeArray(element, atts, VTK_ENCODING_NONE); - const char *id = element->GetAttribute("id"); - if (id) - { - element->SetId(id); - } - this->Internals->Stack.push_back(element); - element->Delete(); -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterialParser::EndElement(const char *vtkNotUsed(name)) -{ - vtkXMLDataElement *finished = this->Internals->Stack.back().GetPointer(); - int prev_pos = static_cast(this->Internals->Stack.size()) - 2; - if (prev_pos >= 0) - { - this->Internals->Stack[prev_pos].GetPointer()->AddNestedElement(finished); - } - else - { - this->Material->SetRootElement(finished); - } - - this->Internals->Stack.pop_back(); -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterialParser::CharacterDataHandler(const char *inData, int inLength) -{ - if (this->Internals->Stack.size() > 0) - { - vtkXMLDataElement *elem = this->Internals->Stack.back().GetPointer(); - elem->AddCharacterData(inData, inLength); - } - /* - // this wont happen as the XML parser will flag it as an error. - else - { - vtkErrorMacro("Character data not enclosed in XML tags"); - } - */ -} - -//----------------------------------------------------------------------------- -void vtkXMLMaterialParser::PrintSelf(ostream &os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "Material: "; - this->Material->PrintSelf(os, indent.GetNextIndent()); -} diff --git a/Modules/VtkShaders/src/vtkXMLMaterialParser.h b/Modules/VtkShaders/src/vtkXMLMaterialParser.h deleted file mode 100644 index 893c94c976..0000000000 --- a/Modules/VtkShaders/src/vtkXMLMaterialParser.h +++ /dev/null @@ -1,140 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLMaterialParser.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ - -/* - * Copyright 2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the - * U.S. Government. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that this Notice and any - * statement of authorship are reproduced on all copies. - */ - -// .NAME vtkXMLMaterialParser - Parses VTK Material file -// -// .SECTION Description -// vtkXMLMaterialParser parses a VTK Material file and provides that file's -// description of a number of vertex and fragment shaders along with data -// values specified for data members of vtkProperty. This material is to be -// applied to an actor through it's vtkProperty and augments VTK's concept -// of a vtkProperty to include explicitly include vertex and fragment shaders -// and parameter settings for those shaders. This effectively makes reflectance -// models and other shaders a material property. If no shaders are specified -// VTK should default to standard rendering. -// -// .SECTION Design -// vtkXMLMaterialParser provides access to 3 distinct types of first-level -// vtkXMLDataElements that describe a VTK material. These elements are as -// follows: -// -// vtkProperty - describe values for vtkProperty data members -// -// vtkVertexShader - a vertex shader and enough information to -// install it into the hardware rendering pipeline including values for -// specific shader parameters and structures. -// -// vtkFragmentShader - a fragment shader and enough information to -// install it into the hardware rendering pipeline including values for -// specific shader parameters and structures. -// -// The design of the material file closely follows that of vtk's xml -// descriptions of it's data sets. This allows use of the very handy -// vtkXMLDataElement which provides easy access to an xml element's -// attribute values. Inlined data is currently not handled. -// -// Ideally this class would be a Facade to a DOM parser, but VTK only -// provides access to expat, a SAX parser. Other vtk classes that parse -// xml files are tuned to read vtkDataSets and don't provide the functionality -// to handle generic xml data. As such they are of little use here. -// -// This class may be extended for better data handling or may become a -// Facade to a DOM parser should on become part of the VTK code base. -// .SECTION Thanks -// Shader support in VTK includes key contributions by Gary Templet at -// Sandia National Labs. - -#ifndef __vtkXMLMaterialParser_h -#define __vtkXMLMaterialParser_h - -#include "vtkRenderingCoreModule.h" // For export macro -#include "vtkXMLParser.h" - -class vtkXMLMaterial; -class vtkXMLMaterialParserInternals; - -class vtkXMLMaterialParser : public vtkXMLParser -{ -public: - static vtkXMLMaterialParser *New(); - vtkTypeMacro(vtkXMLMaterialParser, vtkXMLParser); - void PrintSelf(ostream &os, vtkIndent indent) override; - - // Description: - // Set/Get the vtkXMLMaterial representation of the parsed material. - vtkGetObjectMacro(Material, vtkXMLMaterial); - void SetMaterial(vtkXMLMaterial *); - - // Description: - // Overridden to initialize the internal structures before - // the parsing begins. - virtual int Parse() override; - virtual int Parse(const char *inputString) override; - virtual int Parse(const char *inputString, unsigned int length) override; - - // Description: - // Overridden to clean up internal structures before the chunk-parsing - // begins. - virtual int InitializeParser() override; - -protected: - vtkXMLMaterialParser(); - ~vtkXMLMaterialParser(); - - // Description: - // Event for handling the start of an element - virtual void StartElement(const char *name, const char **atts) override; - - // Description: - // Event for handling the end of an element - virtual void EndElement(const char *) override; - - // Description: - // Handle character data, not yet implemented - virtual void CharacterDataHandler(const char *data, int length) override; - - vtkXMLMaterial *Material; - vtkXMLMaterialParserInternals *Internals; - -private: - vtkXMLMaterialParser(const vtkXMLMaterialParser &); // Not implemented - void operator=(const vtkXMLMaterialParser &); // Not implemented -}; -#endif diff --git a/Modules/VtkShaders/src/vtkXMLShader.cpp b/Modules/VtkShaders/src/vtkXMLShader.cpp deleted file mode 100644 index 0955aa6da8..0000000000 --- a/Modules/VtkShaders/src/vtkXMLShader.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLShader.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ -#include "vtkXMLShader.h" - -#include "vtkObjectFactory.h" -#include "vtkXMLDataElement.h" - -#include -#include - -vtkStandardNewMacro(vtkXMLShader); -vtkCxxSetObjectMacro(vtkXMLShader, SourceLibraryElement, vtkXMLDataElement); -//----------------------------------------------------------------------------- -vtkXMLShader::vtkXMLShader() : Code(nullptr), RootElement(nullptr), SourceLibraryElement(nullptr), Args(nullptr) -{ -} - -//----------------------------------------------------------------------------- -vtkXMLShader::~vtkXMLShader() -{ - if (this->RootElement) - { - this->RootElement->UnRegister(this); - this->RootElement = nullptr; - } - this->SetSourceLibraryElement(nullptr); - this->SetCode(nullptr); - this->CleanupArgs(); -} - -//----------------------------------------------------------------------------- -void vtkXMLShader::SetRootElement(vtkXMLDataElement *root) -{ - vtkSetObjectBodyMacro(RootElement, vtkXMLDataElement, root); - this->SetCode(nullptr); - this->SetSourceLibraryElement(nullptr); // release the SourceLibrary element. -} - -//----------------------------------------------------------------------------- -// Note that this method allocates a new string which must be deleted by -// the caller. -char *vtkXMLShader::LocateFile(const char *filename) -{ - if (!filename) - { - return nullptr; - } - - // if filename is absolute path, return the same. - if (vtksys::SystemTools::FileExists(filename)) - { - return vtksys::SystemTools::DuplicateString(filename); - } - - // Fetch any runtime defined user paths for materials - std::vector paths; - std::string userpaths; - vtksys::SystemTools::GetEnv("USER_MATERIALS_DIRS", userpaths); - if (userpaths.size() > 0) - { - vtksys::SystemTools::Split(userpaths.c_str(), paths, ';'); - } - -#ifdef VTK_MATERIALS_DIRS - // search thru default paths to locate file. - vtksys::SystemTools::Split(VTK_MATERIALS_DIRS, paths, ';'); -#endif - for (unsigned int i = 0; i < paths.size(); i++) - { - std::string path = paths[i]; - if (path.size() == 0) - { - continue; - } - vtksys::SystemTools::ConvertToUnixSlashes(path); - if (path[path.size() - 1] != '/') - { - path += "/"; - } - path += filename; - if (vtksys::SystemTools::FileExists(path.c_str())) - { - return vtksys::SystemTools::DuplicateString(path.c_str()); - } - } - return nullptr; -} - -//----------------------------------------------------------------------------- -int vtkXMLShader::GetScope() -{ - if (this->RootElement) - { - const char *scope = this->RootElement->GetAttribute("scope"); - if (!scope) - { - vtkErrorMacro("Shader description missing \"scope\" attribute."); - } - else if (strcmp(scope, "Vertex") == 0) - { - return vtkXMLShader::SCOPE_VERTEX; - } - else if (strcmp(scope, "Fragment") == 0) - { - return vtkXMLShader::SCOPE_FRAGMENT; - } - else if (strcmp(scope, "Geometry") == 0) - { - return vtkXMLShader::SCOPE_GEOMETRY; - } - } - return vtkXMLShader::SCOPE_NONE; -} - -// ---------------------------------------------------------------------------- -// \post valid_result: result==1 || result==2 -int vtkXMLShader::GetStyle() -{ - int result = 1; - if (this->RootElement) - { - const char *loc = this->RootElement->GetAttribute("style"); - if (loc == nullptr) - { - // fine. this attribute is optional. - } - else - { - if (strcmp(loc, "1") == 0) - { - // fine. default value. - } - else - { - if (strcmp(loc, "2") == 0) - { - result = 2; // new style - } - else - { - vtkErrorMacro(<< "style number not supported. Expect 1 or 2. We force it to be 1."); - } - } - } - } - - assert("post valid_result" && (result == 1 || result == 2)); - return result; -} - -//----------------------------------------------------------------------------- -const char *vtkXMLShader::GetName() -{ - return (this->RootElement) ? this->RootElement->GetAttribute("name") : nullptr; -} - -//----------------------------------------------------------------------------- -const char *vtkXMLShader::GetEntry() -{ - return (this->RootElement) ? this->RootElement->GetAttribute("entry") : nullptr; -} - -//----------------------------------------------------------------------------- -const char **vtkXMLShader::GetArgs() -{ - this->CleanupArgs(); - if (!this->RootElement || !this->RootElement->GetAttribute("args")) - { - return nullptr; - } - - std::vector args; - vtksys::SystemTools::Split(this->RootElement->GetAttribute("args"), args, ' '); - - int i; - int size = static_cast(args.size()); - if (size == 0) - { - return nullptr; - } - this->Args = new char *[size + 1]; - for (i = 0; i < size; i++) - { - this->Args[i] = vtksys::SystemTools::DuplicateString(args[i].c_str()); - } - this->Args[size] = nullptr; - return const_cast(this->Args); -} - -//----------------------------------------------------------------------------- -const char *vtkXMLShader::GetCode() -{ - return this->RootElement->GetCharacterData(); -} - -//----------------------------------------------------------------------------- -void vtkXMLShader::CleanupArgs() -{ - if (this->Args) - { - char **a = this->Args; - while (*a) - { - delete[](*a); - a++; - } - delete[] this->Args; - this->Args = nullptr; - } -} - -//----------------------------------------------------------------------------- -void vtkXMLShader::PrintSelf(ostream &os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "Name: " << (this->GetName() ? this->GetName() : "(none)") << endl; - os << indent << "Scope: "; - switch (this->GetScope()) - { - case SCOPE_NONE: - os << "None"; - break; - case SCOPE_MIXED: - os << "Mixed"; - break; - case SCOPE_VERTEX: - os << "Vertex"; - break; - case SCOPE_FRAGMENT: - os << "Fragment"; - break; - case SCOPE_GEOMETRY: - os << "Geometry"; - break; - } - os << endl; - - os << indent << "Entry: " << (this->GetEntry() ? this->GetEntry() : "(none)") << endl; - os << indent << "Args: "; - const char **args = this->GetArgs(); - if (!args) - { - os << "(none)" << endl; - } - else - { - while (*args) - { - os << indent << *args << " "; - args++; - } - os << endl; - } - - os << indent << "RootElement: "; - if (this->RootElement) - { - os << endl; - this->RootElement->PrintSelf(os, indent.GetNextIndent()); - } - else - { - os << "(none)" << endl; - } -} diff --git a/Modules/VtkShaders/src/vtkXMLShader.h b/Modules/VtkShaders/src/vtkXMLShader.h deleted file mode 100644 index 2e08590882..0000000000 --- a/Modules/VtkShaders/src/vtkXMLShader.h +++ /dev/null @@ -1,129 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkXMLShader.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information. - -=========================================================================*/ -// .NAME vtkXMLShader - encapsulates a Shader XML description. -// .SECTION Description -// vtkXMLShader encapsulates the XML description for a Shader. -// It provides convenient access to various attributes/properties -// of a shader. -// .SECTION Thanks -// Shader support in VTK includes key contributions by Gary Templet at -// Sandia National Labs. - -#ifndef __vtkXMLShader_h -#define __vtkXMLShader_h - -#include "vtkObject.h" -#include "vtkRenderingCoreModule.h" // For export macro - -class vtkXMLDataElement; - -class vtkXMLShader : public vtkObject -{ -public: - static vtkXMLShader *New(); - vtkTypeMacro(vtkXMLShader, vtkObject); - void PrintSelf(ostream &os, vtkIndent indent) override; - - // Description: - // Get/Set the XML root element that describes this shader. - vtkGetObjectMacro(RootElement, vtkXMLDataElement); - void SetRootElement(vtkXMLDataElement *); - - // Description: - // Returns the type of the shader as defined in the XML description. - int GetScope(); - - // Description: - // Returns the style of the shader as optionaly defined in the XML - // description. If not present, default style is 1. "style=2" means it is - // a shader without a main(). In style 2, the "main" function for the vertex - // shader part is void propFuncVS(void), the main function for the fragment - // shader part is void propFuncFS(). This is useful when combining a shader - // at the actor level and a shader defines at the renderer level, like - // the depth peeling pass. - // \post valid_result: result==1 || result==2 - int GetStyle(); - - // Description: - // Get the name of the Shader. - const char *GetName(); - - // Description: - // Get the entry point to the shader code as defined in the XML. - const char *GetEntry(); - - // Description: - // Get the shader code. - const char *GetCode(); - - // Description: - // Returns an null terminate array of the pointers to space sepatared Args - // defined in the XML description. - const char **GetArgs(); - - // Description: - // Searches the file in the VTK_MATERIALS_DIRS. - // Note that this allocates new memory for the string. - // The caller must delete it. - static char *LocateFile(const char *filename); - - // BTX - - enum ScopeCodes - { - SCOPE_NONE = 0, - SCOPE_MIXED, - SCOPE_VERTEX, - SCOPE_FRAGMENT, - SCOPE_GEOMETRY - }; - - // ETX -protected: - vtkXMLShader(); - ~vtkXMLShader(); - - char *Code; // cache for the code. - vtkSetStringMacro(Code); - - vtkXMLDataElement *RootElement; - vtkXMLDataElement *SourceLibraryElement; - void SetSourceLibraryElement(vtkXMLDataElement *); - - char **Args; - void CleanupArgs(); - -private: - vtkXMLShader(const vtkXMLShader &); // Not implemented. - void operator=(const vtkXMLShader &); // Not implemented. -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h index 265bf49572..0b77184264 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h @@ -1,171 +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. ===================================================================*/ #ifndef RTDoseVisualizer_h #define RTDoseVisualizer_h #include #include #include #include "ui_RTDoseVisualizerControls.h" #include #include #include "mitkDoseVisPreferenceHelper.h" // Shader #include -#include -#include #include #include #include #include #include /*forward declarations*/ class QmitkIsoDoseLevelSetModel; class QmitkDoseColorDelegate; class QmitkDoseValueDelegate; class QmitkDoseVisualStyleDelegate; class ctkEvent; /** \brief RTDoseVisualizer \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class RTDoseVisualizer : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: RTDoseVisualizer(); virtual ~RTDoseVisualizer(); static const std::string VIEW_ID; void OnSliceChanged(itk::Object *sender, const itk::EventObject &e); protected slots: void OnAddFreeValueClicked(); void OnRemoveFreeValueClicked(); void OnUsePrescribedDoseClicked(); void OnDataChangedInIsoLevelSetView(); void OnAbsDoseToggled(bool); void OnGlobalVisColorWashToggled(bool); void OnGlobalVisIsoLineToggled(bool); void OnShowContextMenuIsoSet(const QPoint&); void OnCurrentPresetChanged(const QString&); void OnReferenceDoseChanged(double); void OnHandleCTKEventReferenceDoseChanged(const ctkEvent& event); void OnHandleCTKEventPresetsChanged(const ctkEvent& event); void OnHandleCTKEventGlobalVisChanged(const ctkEvent& event); void ActualizeFreeIsoLine(); void OnDoseClicked(); protected: virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus(); /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ); /** Update the transfer funtion property for the color wash*/ void UpdateColorWashTransferFunction(); /** Method updates the list widget according to the current free iso values.*/ void UpdateFreeIsoValues(); /** Update the members according to the currently selected node */ void UpdateBySelectedNode(); /** Update the member widgets according to the information stored in the application preferences*/ void UpdateByPreferences(); /**helper function that iterates throug all data nodes and sets there iso level set property according to the selected preset. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeIsoLevelsForAllDoseDataNodes(); /**helper function that iterates throug all data nodes and sets there reference dose value according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeReferenceDoseForAllDoseDataNodes(); /**helper function that iterates through all data nodes and sets there dose display style (relative/absolute) according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeDisplayStyleForAllDoseDataNodes(); void NodeRemoved(const mitk::DataNode* node) override; void NodeChanged(const mitk::DataNode *node) override; Ui::RTDoseVisualizerControls m_Controls; mitk::DataNode::Pointer m_selectedNode; unsigned int m_freeIsoValuesCount; mitk::PresetMapType m_Presets; std::string m_selectedPresetName; /** Prescribed Dose of the selected data.*/ mitk::DoseValueAbs m_PrescribedDose_Data; QmitkIsoDoseLevelSetModel* m_LevelSetModel; QmitkDoseColorDelegate* m_DoseColorDelegate; QmitkDoseValueDelegate* m_DoseValueDelegate; QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; bool m_internalUpdate; private: mitk::DataNode::Pointer GetIsoDoseNode(mitk::DataNode::Pointer doseNode); bool ModalityIsRTDose(const mitk::DataNode* dataNode) const; }; #endif // RTDoseVisualizer_h diff --git a/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp index 077fc2b67a..eca6e1b5c5 100644 --- a/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp +++ b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp @@ -1,267 +1,263 @@ /*=================================================================== 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 "QmitkMITKSurfaceMaterialEditorView.h" #include "mitkBaseRenderer.h" #include "mitkNodePredicateDataType.h" #include "mitkProperties.h" #include "mitkIDataStorageService.h" #include "mitkDataNodeObject.h" #include "berryIEditorPart.h" #include "berryIWorkbenchPage.h" -#include "mitkShaderProperty.h" - #include "QmitkDataStorageComboBox.h" #include "QmitkStdMultiWidget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkStandaloneDataStorage.h" const std::string QmitkMITKSurfaceMaterialEditorView::VIEW_ID = "org.mitk.views.mitksurfacematerialeditor"; QmitkMITKSurfaceMaterialEditorView::QmitkMITKSurfaceMaterialEditorView() : QmitkFunctionality(), m_Controls(NULL), m_MultiWidget(NULL) { fixedProperties.push_back( "shader" ); fixedProperties.push_back( "material.representation" ); fixedProperties.push_back( "color" ); fixedProperties.push_back( "opacity" ); fixedProperties.push_back( "material.wireframeLineWidth" ); fixedProperties.push_back( "material.ambientCoefficient" ); fixedProperties.push_back( "material.diffuseCoefficient" ); fixedProperties.push_back( "material.ambientColor" ); fixedProperties.push_back( "material.diffuseColor" ); fixedProperties.push_back( "material.specularColor" ); fixedProperties.push_back( "material.specularCoefficient" ); fixedProperties.push_back( "material.specularPower" ); fixedProperties.push_back( "material.interpolation" ); shaderProperties.push_back( "shader" ); shaderProperties.push_back( "material.representation" ); shaderProperties.push_back( "color" ); shaderProperties.push_back( "opacity" ); shaderProperties.push_back( "material.wireframeLineWidth" ); observerAllocated = false; } QmitkMITKSurfaceMaterialEditorView::~QmitkMITKSurfaceMaterialEditorView() { } void QmitkMITKSurfaceMaterialEditorView::InitPreviewWindow() { usedTimer=0; vtkSphereSource* sphereSource = vtkSphereSource::New(); sphereSource->SetThetaResolution(25); sphereSource->SetPhiResolution(25); sphereSource->Update(); vtkPolyData* sphere = sphereSource->GetOutput(); m_Surface = mitk::Surface::New(); m_Surface->SetVtkPolyData( sphere ); m_DataNode = mitk::DataNode::New(); m_DataNode->SetData( m_Surface ); m_DataTree = mitk::StandaloneDataStorage::New(); m_DataTree->Add( m_DataNode , (mitk::DataNode *)0 ); m_Controls->m_PreviewRenderWindow->GetRenderer()->SetDataStorage( m_DataTree ); m_Controls->m_PreviewRenderWindow->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard3D ); sphereSource->Delete(); } void QmitkMITKSurfaceMaterialEditorView::RefreshPropertiesList() { mitk::DataNode* SrcND = m_SelectedDataNode; mitk::DataNode* DstND = m_DataNode; mitk::PropertyList* DstPL = DstND->GetPropertyList(); m_Controls->m_ShaderPropertyList->SetPropertyList( 0 ); DstPL->Clear(); if(observerAllocated) { observedProperty->RemoveObserver( observerIndex ); observerAllocated=false; } if(SrcND) { mitk::PropertyList* SrcPL = SrcND->GetPropertyList(); - mitk::ShaderProperty::Pointer shaderEnum = dynamic_cast(SrcPL->GetProperty("shader")); - std::string shaderState = "fixed"; - if(shaderEnum.IsNotNull()) - { - shaderState = shaderEnum->GetValueAsString(); +// if(shaderEnum.IsNotNull()) +// { +// shaderState = shaderEnum->GetValueAsString(); - itk::MemberCommand::Pointer propertyModifiedCommand = itk::MemberCommand::New(); - propertyModifiedCommand->SetCallbackFunction(this, &QmitkMITKSurfaceMaterialEditorView::shaderEnumChange); - observerIndex = shaderEnum->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); - observedProperty = shaderEnum; - observerAllocated=true; - } +// itk::MemberCommand::Pointer propertyModifiedCommand = itk::MemberCommand::New(); +// propertyModifiedCommand->SetCallbackFunction(this, &QmitkMITKSurfaceMaterialEditorView::shaderEnumChange); +// observerIndex = shaderEnum->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); +// observedProperty = shaderEnum; +// observerAllocated=true; +// } MITK_INFO << "PROPERTIES SCAN BEGIN"; for(mitk::PropertyList::PropertyMap::const_iterator it=SrcPL->GetMap()->begin(); it!=SrcPL->GetMap()->end(); it++) { std::string name=it->first; mitk::BaseProperty *p=it->second; // MITK_INFO << "property '" << name << "' found"; if(shaderState.compare("fixed")==0) { if(std::find(fixedProperties.begin(), fixedProperties.end(), name) != fixedProperties.end()) { DstPL->SetProperty(name,p); } } else { //if(std::find(shaderProperties.begin(), shaderProperties.end(), name) != shaderProperties.end()) { DstPL->SetProperty(name,p); } } } MITK_INFO << "PROPERTIES SCAN END"; } m_Controls->m_ShaderPropertyList->SetPropertyList( DstPL ); //m_Controls->m_PreviewRenderWindow->GetRenderer()->GetVtkRenderer()->ResetCameraClippingRange(); } void QmitkMITKSurfaceMaterialEditorView::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkMITKSurfaceMaterialEditorViewControls; m_Controls->setupUi(parent); this->CreateConnections(); InitPreviewWindow(); RefreshPropertiesList(); } } void QmitkMITKSurfaceMaterialEditorView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkMITKSurfaceMaterialEditorView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkMITKSurfaceMaterialEditorView::CreateConnections() { } void QmitkMITKSurfaceMaterialEditorView::Activated() { QmitkFunctionality::Activated(); } void QmitkMITKSurfaceMaterialEditorView::Deactivated() { QmitkFunctionality::Deactivated(); } void QmitkMITKSurfaceMaterialEditorView::OnSelectionChanged(std::vector nodes) { if(!nodes.empty()) { m_SelectedDataNode = nodes.at(0); MITK_INFO << "Node '" << m_SelectedDataNode->GetName() << "' selected"; SurfaceSelected(); } } void QmitkMITKSurfaceMaterialEditorView::SurfaceSelected() { postRefresh(); } void QmitkMITKSurfaceMaterialEditorView::shaderEnumChange(const itk::Object * /*caller*/, const itk::EventObject & /*event*/) { postRefresh(); } void QmitkMITKSurfaceMaterialEditorView::postRefresh() { if(usedTimer) return; usedTimer=startTimer(0); } void QmitkMITKSurfaceMaterialEditorView::timerEvent( QTimerEvent *e ) { if(usedTimer!=e->timerId()) { MITK_ERROR << "INTERNAL ERROR: usedTimer[" << usedTimer << "] != timerId[" << e->timerId() << "]"; } if(usedTimer) { killTimer(usedTimer); usedTimer=0; } RefreshPropertiesList(); } diff --git a/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h index 475a20caad..04edd6fef1 100644 --- a/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h +++ b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h @@ -1,122 +1,120 @@ /*=================================================================== 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 _QMITKMITKSURFACEMATERIALEDITORVIEW_H_INCLUDED #define _QMITKMITKSURFACEMATERIALEDITORVIEW_H_INCLUDED #include #include #include #include "ui_QmitkMITKSurfaceMaterialEditorViewControls.h" /* #include #include #include #include #include #include #include "QtGui/QMenubarUpdatedEvent" */ #include "QmitkRenderWindow.h" #include "mitkCommon.h" #include "mitkDataStorage.h" #include "mitkDataNode.h" -#include "mitkShaderProperty.h" #include "mitkSurface.h" #include "vtkRenderer.h" #include "vtkTextActor.h" /*! \brief QmitkMITKSurfaceMaterialEditorView \sa QmitkFunctionality \ingroup Functionalities */ class QmitkMITKSurfaceMaterialEditorView : public QmitkFunctionality { // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkMITKSurfaceMaterialEditorView(); virtual ~QmitkMITKSurfaceMaterialEditorView(); virtual void CreateQtPartControl(QWidget *parent) override; /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); /// \brief Called when the functionality is activated virtual void Activated() override; virtual void Deactivated() override; virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) override; virtual void StdMultiWidgetNotAvailable() override; virtual void OnSelectionChanged(std::vector nodes) override; protected slots: void SurfaceSelected(); protected: Ui::QmitkMITKSurfaceMaterialEditorViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; private: mitk::Surface::Pointer m_Surface; mitk::DataStorage::Pointer m_DataTree; mitk::DataNode::Pointer m_DataNode; mitk::DataNode::Pointer m_SelectedDataNode; std::list fixedProperties; std::list shaderProperties; unsigned long observerIndex; bool observerAllocated; - mitk::ShaderProperty::Pointer observedProperty; void InitPreviewWindow(); int usedTimer; void timerEvent( QTimerEvent *e ) override; void RefreshPropertiesList(); void postRefresh(); void shaderEnumChange(const itk::Object *caller, const itk::EventObject &event); berry::IStructuredSelection::ConstPointer m_CurrentSelection; }; #endif // _QMITKMITKSURFACEMATERIALEDITORVIEW_H_INCLUDED