diff --git a/Modules/Core/include/mitkAbstractAnnotationRenderer.h b/Modules/Core/include/mitkAbstractAnnotationRenderer.h index 2110fc0fd3..16e78691e9 100644 --- a/Modules/Core/include/mitkAbstractAnnotationRenderer.h +++ b/Modules/Core/include/mitkAbstractAnnotationRenderer.h @@ -1,66 +1,87 @@ /*=================================================================== * 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 ABSTRACTANNOTATIONRENDERER_H #define ABSTRACTANNOTATIONRENDERER_H #include #include #include #include "mitkOverlay.h" #include "mitkServiceInterface.h" +#include "usGetModuleContext.h" namespace mitk { class BaseRenderer; /** @brief Baseclass of Overlay layouters */ /** *A AbstractAnnotationRenderer can be implemented to control a set of Overlays by means of position and size. *AbstractAnnotationRenderer::PrepareLayout() should be implemented with a routine to set the position of the internal m_ManagedOverlays List. *A layouter is always connected to one BaseRenderer, so there is one instance of the layouter for each BaseRenderer. *One type of layouter should always have a unique identifier. *@ingroup Overlays */ class MITKCORE_EXPORT AbstractAnnotationRenderer : public itk::LightObject { -public: + + public: mitkClassMacroItkParent(AbstractAnnotationRenderer, itk::LightObject); protected: + template + static S* GetService(us::ModuleContext* context) + { + if (context == nullptr) return nullptr; + + S* coreService = nullptr; + +// m_PropertyAliases.reset(new mitk::PropertyAliases); +// context->RegisterService(m_PropertyAliases.get()); + + us::ServiceReference serviceRef = context->GetServiceReference(); + if (serviceRef) + { + coreService = context->GetService(serviceRef); + } + + return coreService; + } + /** \brief explicit constructor which disallows implicit conversions */ explicit AbstractAnnotationRenderer(); /** \brief virtual destructor in order to derive from this class */ virtual ~AbstractAnnotationRenderer(); private: /** \brief copy constructor */ AbstractAnnotationRenderer( const AbstractAnnotationRenderer &); /** \brief assignment operator */ AbstractAnnotationRenderer &operator=(const AbstractAnnotationRenderer &); }; } // namespace mitk MITK_DECLARE_SERVICE_INTERFACE(mitk::AbstractAnnotationRenderer, "org.mitk.services.AbstractAnnotationRenderer") #endif // ABSTRACTANNOTATIONRENDERER_H diff --git a/Modules/Core/include/mitkAnnotationService.h b/Modules/Core/include/mitkAnnotationService.h index cf7b9649d5..124dde95f9 100644 --- a/Modules/Core/include/mitkAnnotationService.h +++ b/Modules/Core/include/mitkAnnotationService.h @@ -1,38 +1,45 @@ /*=================================================================== 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 mitkAnnotationService_h #define mitkAnnotationService_h #include #include namespace mitk { + typedef std::map InstanceMapType; + class AnnotationService : public IAnnotationService { public: + + void AddAnnotationRenderer(AnnotationServiceRef ref, const std::string &id) override; + AnnotationService(); ~AnnotationService(); private: + InstanceMapType m_InstanceMap; + AnnotationService(const AnnotationService&); AnnotationService& operator=(const AnnotationService&); }; } #endif diff --git a/Modules/Core/include/mitkIAnnotationService.h b/Modules/Core/include/mitkIAnnotationService.h index c5619f6073..f1bb251583 100644 --- a/Modules/Core/include/mitkIAnnotationService.h +++ b/Modules/Core/include/mitkIAnnotationService.h @@ -1,45 +1,53 @@ /*=================================================================== 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 mitkIAnnotationService_h #define mitkIAnnotationService_h #include #include #include #include +#include namespace mitk { + class AbstractAnnotationRenderer; + + typedef us::ServiceRegistration AnnotationServiceRef; + /** * \ingroup MicroServices_Interfaces * \brief Interface of property aliases service. * * This service allows you to manage aliases of property names. * A property name can be mapped to more than one alias and aliases can be restricted to specific data node types. * The property view prefers to display aliases instead of genuine property names. */ class MITKCORE_EXPORT IAnnotationService { public: + + virtual void AddAnnotationRenderer(AnnotationServiceRef, const std::string& id) = 0; + virtual ~IAnnotationService(); }; } MITK_DECLARE_SERVICE_INTERFACE(mitk::IAnnotationService, "org.mitk.IAnnotationService") #endif diff --git a/Modules/Core/src/Rendering/mitkAnnotationService.cpp b/Modules/Core/src/Rendering/mitkAnnotationService.cpp index 544e9db72e..375d07b537 100644 --- a/Modules/Core/src/Rendering/mitkAnnotationService.cpp +++ b/Modules/Core/src/Rendering/mitkAnnotationService.cpp @@ -1,26 +1,32 @@ /*=================================================================== 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 "mitkAnnotationService.h" +#include + +void mitk::AnnotationService::AddAnnotationRenderer(mitk::AnnotationServiceRef ref, const std::string &id) +{ + m_InstanceMap[id] = ref; +} mitk::AnnotationService::AnnotationService() { } mitk::AnnotationService::~AnnotationService() { } diff --git a/Modules/Overlays/include/mitkOverlayLayouter2D.h b/Modules/Overlays/include/mitkOverlayLayouter2D.h index a65c7f7404..5a7ee1f737 100644 --- a/Modules/Overlays/include/mitkOverlayLayouter2D.h +++ b/Modules/Overlays/include/mitkOverlayLayouter2D.h @@ -1,66 +1,74 @@ /*=================================================================== 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 OVERLAYLAYOUTER2D_H #define OVERLAYLAYOUTER2D_H #include "MitkOverlaysExports.h" #include #include #include "mitkOverlay.h" #include "mitkAbstractAnnotationRenderer.h" #include "mitkLocalStorageHandler.h" #include "itkEventObject.h" namespace mitk { class BaseRenderer; /** \brief The OverlayLayouter2D updates and manages Overlays and the respective Layouters. */ /** An Instance of the OverlayLayouter2D can be registered to several BaseRenderer instances in order to * call the update method of each Overlay during the rendering phase of the renderer. * See \ref OverlaysPage for more info. */ class MITKOVERLAYS_EXPORT OverlayLayouter2D : public mitk::AbstractAnnotationRenderer { public: mitkClassMacro(OverlayLayouter2D, mitk::AbstractAnnotationRenderer); itkFactorylessNewMacro(Self) itkCloneMacro(Self) + /** + * @brief TODO19786 Get an IMimeTypeProvider instance. + * @param context The module context of the module getting the service. + * @return A non-NULL IMimeTypeProvider instance. + */ + static OverlayLayouter2D* GetOverlayLayouter2D(us::ModuleContext* context = us::GetModuleContext()); + + protected: /** \brief explicit constructor which disallows implicit conversions */ explicit OverlayLayouter2D(); /** \brief virtual destructor in order to derive from this class */ virtual ~OverlayLayouter2D(); private: /** \brief copy constructor */ OverlayLayouter2D( const OverlayLayouter2D &); /** \brief assignment operator */ OverlayLayouter2D &operator=(const OverlayLayouter2D &); }; } // namespace mitk #endif // OVERLAYLAYOUTER2D_H diff --git a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp b/Modules/Overlays/src/mitkOverlayLayouter2D.cpp index 5f9ee6744f..4b3588cdea 100644 --- a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp +++ b/Modules/Overlays/src/mitkOverlayLayouter2D.cpp @@ -1,37 +1,42 @@ /*=================================================================== 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 "mitkOverlayLayouter2D.h" #include "mitkBaseRenderer.h" #include #include "mitkOverlay2DLayouter.h" namespace mitk { +OverlayLayouter2D *OverlayLayouter2D::GetOverlayLayouter2D(us::ModuleContext *context) +{ + return Superclass::GetService(context); +} + OverlayLayouter2D::OverlayLayouter2D() { } OverlayLayouter2D::~OverlayLayouter2D() { } }