diff --git a/Modules/Core/include/mitkAbstractAnnotationRenderer.h b/Modules/Core/include/mitkAbstractAnnotationRenderer.h index 5f3b3ca9f7..3064f19b80 100644 --- a/Modules/Core/include/mitkAbstractAnnotationRenderer.h +++ b/Modules/Core/include/mitkAbstractAnnotationRenderer.h @@ -1,74 +1,73 @@ /*=================================================================== * 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 "mitkOverlay.h" #include "mitkServiceInterface.h" #include "usGetModuleContext.h" #include "mitkOverlayServiceTracker.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: - AbstractAnnotationRenderer(const std::string& rendererID); + explicit AbstractAnnotationRenderer(const std::string& rendererID); /** \brief virtual destructor in order to derive from this class */ virtual ~AbstractAnnotationRenderer(); virtual const std::string GetID() const = 0; const std::string GetRendererID() const; static const std::string US_INTERFACE_NAME; static const std::string US_PROPKEY_ID; static const std::string US_PROPKEY_RENDERER_ID; private: /** \brief copy constructor */ AbstractAnnotationRenderer( const AbstractAnnotationRenderer &); /** \brief assignment operator */ AbstractAnnotationRenderer &operator=(const AbstractAnnotationRenderer &); OverlayServiceTracker* m_OverlayServiceTracker; const std::string m_RendererID; }; } // namespace mitk MITK_DECLARE_SERVICE_INTERFACE(mitk::AbstractAnnotationRenderer, "org.mitk.services.AbstractAnnotationRenderer") #endif // ABSTRACTANNOTATIONRENDERER_H diff --git a/Modules/Core/include/mitkOverlayServiceTracker.h b/Modules/Core/include/mitkOverlayServiceTracker.h index 3a823dd64e..2df6ab13d6 100644 --- a/Modules/Core/include/mitkOverlayServiceTracker.h +++ b/Modules/Core/include/mitkOverlayServiceTracker.h @@ -1,45 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKOVERLAYSERVICETRACKER_H #define MITKOVERLAYSERVICETRACKER_H #include "usServiceTracker.h" #include "mitkOverlay.h" namespace mitk { class OverlayServiceTracker : public us::ServiceTracker { - OverlayServiceTracker(); + +public: + + OverlayServiceTracker(const us::LDAPFilter &filter); private: typedef us::ServiceTracker Superclass; TrackedType AddingService(const ServiceReferenceType &reference) override; void RemovedService(const ServiceReferenceType& /*reference*/, TrackedType tracked) override; -private: - std::vector m_OverlayServices; }; } // end of namespace mitk #endif // MITKOVERLAYSERVICETRACKER_H diff --git a/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp b/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp index 2dff8a94a8..656a8dfd6c 100644 --- a/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp +++ b/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp @@ -1,36 +1,48 @@ /*=================================================================== 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 "mitkAbstractAnnotationRenderer.h" #include +#include "usGetModuleContext.h" +#include "mitkOverlay.h" -const std::string mitk::AbstractAnnotationRenderer::US_INTERFACE_NAME = "org.mitk.services.AbstractAnnotationRenderer"; -const std::string mitk::AbstractAnnotationRenderer::US_PROPKEY_ID = US_INTERFACE_NAME + ".id"; -const std::string mitk::AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId"; +namespace mitk +{ + +const std::string AbstractAnnotationRenderer::US_INTERFACE_NAME = "org.mitk.services.AbstractAnnotationRenderer"; +const std::string AbstractAnnotationRenderer::US_PROPKEY_ID = US_INTERFACE_NAME + ".id"; +const std::string AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId"; -mitk::AbstractAnnotationRenderer::AbstractAnnotationRenderer(const std::string& rendererID) +AbstractAnnotationRenderer::AbstractAnnotationRenderer(const std::string& rendererID) :m_RendererID(rendererID) { + std::string specificRenderer = "(rendererName=" + rendererID +")"; + std::string classInteractionEventObserver = "(" + us::ServiceConstants::OBJECTCLASS() + "=" + ")"; + us::LDAPFilter filter( "(&(|"+ specificRenderer + ")"+classInteractionEventObserver+")" ); + + m_OverlayServiceTracker = new OverlayServiceTracker(filter); } -mitk::AbstractAnnotationRenderer::~AbstractAnnotationRenderer() +AbstractAnnotationRenderer::~AbstractAnnotationRenderer() { } -const std::string mitk::AbstractAnnotationRenderer::GetRendererID() const +const std::string AbstractAnnotationRenderer::GetRendererID() const { return m_RendererID; } + +} diff --git a/Modules/Overlays/include/mitkAnnotationPlacer.h b/Modules/Overlays/include/mitkAnnotationPlacer.h index 5784c050df..33858e755b 100644 --- a/Modules/Overlays/include/mitkAnnotationPlacer.h +++ b/Modules/Overlays/include/mitkAnnotationPlacer.h @@ -1,60 +1,54 @@ /*=================================================================== 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 ANNOTATIONPLACER_H #define ANNOTATIONPLACER_H #include "MitkOverlaysExports.h" #include "mitkOverlay.h" #include "mitkAbstractAnnotationRenderer.h" namespace mitk { class BaseRenderer; /** \brief The AnnotationPlacer updates and manages Overlays and the respective Layouters. */ /** An Instance of the AnnotationPlacer 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 AnnotationPlacer : public AbstractAnnotationRenderer { public: /** \brief virtual destructor in order to derive from this class */ virtual ~AnnotationPlacer(); const std::string GetID() const; static AnnotationPlacer* GetAnnotationRenderer(const std::string& rendererID); private: - AnnotationPlacer(const std::string& rendererID); - - /** \brief copy constructor */ - AnnotationPlacer( const AnnotationPlacer &); - - /** \brief assignment operator */ - AnnotationPlacer &operator=(const AnnotationPlacer &); + using AbstractAnnotationRenderer::AbstractAnnotationRenderer; static const std::string ANNOTATIONRENDERER_ID; }; } // namespace mitk #endif // ANNOTATIONPLACER_H diff --git a/Modules/Overlays/include/mitkOverlayLayouter2D.h b/Modules/Overlays/include/mitkOverlayLayouter2D.h index 37a3f840f3..e6161f451c 100644 --- a/Modules/Overlays/include/mitkOverlayLayouter2D.h +++ b/Modules/Overlays/include/mitkOverlayLayouter2D.h @@ -1,61 +1,55 @@ /*=================================================================== 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 "mitkAbstractAnnotationRenderer.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 AbstractAnnotationRenderer { public: /** \brief virtual destructor in order to derive from this class */ virtual ~OverlayLayouter2D(); const std::string GetID() const; static OverlayLayouter2D *GetAnnotationRenderer(const std::string& rendererID); static const std::string ANNOTATIONRENDERER_ID; private: - OverlayLayouter2D(const std::string& rendererID); - - /** \brief copy constructor */ - OverlayLayouter2D( const OverlayLayouter2D &); - - /** \brief assignment operator */ - OverlayLayouter2D &operator=(const OverlayLayouter2D &); + using AbstractAnnotationRenderer::AbstractAnnotationRenderer; }; } // namespace mitk #endif // OVERLAYLAYOUTER2D_H diff --git a/Modules/Overlays/src/mitkAnnotationPlacer.cpp b/Modules/Overlays/src/mitkAnnotationPlacer.cpp index 1cf57f1565..a1c3650108 100644 --- a/Modules/Overlays/src/mitkAnnotationPlacer.cpp +++ b/Modules/Overlays/src/mitkAnnotationPlacer.cpp @@ -1,60 +1,54 @@ /*=================================================================== 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 "mitkAnnotationPlacer.h" #include "mitkBaseRenderer.h" #include #include "mitkOverlay2DLayouter.h" #include "mitkAnnotationService.h" namespace mitk { const std::string mitk::AnnotationPlacer::ANNOTATIONRENDERER_ID = "AnnotationPlacer"; -AnnotationPlacer::AnnotationPlacer(const std::string& rendererID): - AbstractAnnotationRenderer(rendererID) -{ - -} - AnnotationPlacer::~AnnotationPlacer() { } const std::string AnnotationPlacer::GetID() const { return ANNOTATIONRENDERER_ID; } AnnotationPlacer *AnnotationPlacer::GetAnnotationRenderer(const std::string &rendererID) { AnnotationPlacer* result = nullptr; AbstractAnnotationRenderer* registeredService = AnnotationService::GetAnnotationRenderer(ANNOTATIONRENDERER_ID,rendererID); if(registeredService) result = dynamic_cast(registeredService); if(!result) { result = new AnnotationPlacer(rendererID); AnnotationService::RegisterAnnotationRenderer(result); } return result; } } diff --git a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp b/Modules/Overlays/src/mitkOverlayLayouter2D.cpp index 57b5b7eacd..012683ede0 100644 --- a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp +++ b/Modules/Overlays/src/mitkOverlayLayouter2D.cpp @@ -1,60 +1,54 @@ /*=================================================================== 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" #include "mitkAnnotationService.h" namespace mitk { const std::string mitk::OverlayLayouter2D::ANNOTATIONRENDERER_ID = "OverlayLayouter2D"; -OverlayLayouter2D::OverlayLayouter2D(const std::string& rendererID): - AbstractAnnotationRenderer(rendererID) -{ - -} - OverlayLayouter2D::~OverlayLayouter2D() { } const std::string OverlayLayouter2D::GetID() const { return ANNOTATIONRENDERER_ID; } OverlayLayouter2D *OverlayLayouter2D::GetAnnotationRenderer(const std::string &rendererID) { OverlayLayouter2D* result = nullptr; AbstractAnnotationRenderer* registeredService = AnnotationService::GetAnnotationRenderer(ANNOTATIONRENDERER_ID,rendererID); if(registeredService) result = dynamic_cast(registeredService); if(!result) { result = new OverlayLayouter2D(rendererID); AnnotationService::RegisterAnnotationRenderer(result); } return result; } }