Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkAbstractAnnotationRenderer.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkBaseRenderer.h"
15 #include "mitkRenderingManager.h"
16 #include "usGetModuleContext.h"
17 #include <memory>
18 
19 namespace mitk
20 {
21  const std::string AbstractAnnotationRenderer::US_INTERFACE_NAME = "org.mitk.services.AbstractAnnotationRenderer";
22  const std::string AbstractAnnotationRenderer::US_PROPKEY_ID = US_INTERFACE_NAME + ".id";
23  const std::string AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId";
24 
25  AbstractAnnotationRenderer::AbstractAnnotationRenderer(const std::string &rendererID, const std::string &arID)
27  us::LDAPFilter("(&(" + Annotation::US_PROPKEY_RENDERER_ID + "=" + rendererID + ")(" +
28  Annotation::US_PROPKEY_AR_ID + "=" + arID + "))")),
29  m_RendererID(rendererID),
30  m_ID(arID)
31  {
32  this->Open();
33  }
34 
36  const std::string AbstractAnnotationRenderer::GetRendererID() const { return m_RendererID; }
38  {
40  if (renderer)
41  {
42  for (Annotation *o : this->GetServices())
43  {
44  o->AddToBaseRenderer(renderer);
45  }
46  }
47  }
48 
50  {
52  if (renderer)
53  {
54  for (Annotation *o : this->GetServices())
55  {
56  o->RemoveFromBaseRenderer(renderer);
57  }
58  }
59  }
60 
62  {
64  if (renderer)
65  {
66  for (Annotation *o : this->GetServices())
67  {
68  o->Update(renderer);
69  }
70  }
71  }
72  const std::string AbstractAnnotationRenderer::GetID() const { return m_ID; }
73  AbstractAnnotationRenderer::TrackedType AbstractAnnotationRenderer::AddingService(
75  {
78  if (Annotation && renderer)
79  {
80  Annotation->AddToBaseRenderer(renderer);
81  }
82  // OnAnnotationRenderersChanged();
83  return Annotation;
84  }
85 
86  void AbstractAnnotationRenderer::ModifiedService(const AbstractAnnotationRenderer::ServiceReferenceType &,
88  {
90  if (tracked && renderer)
91  {
92  tracked->Update(renderer);
93  }
94  OnAnnotationRenderersChanged();
95  }
96 
97  void AbstractAnnotationRenderer::RemovedService(const AbstractAnnotationRenderer::ServiceReferenceType &,
99  {
100  OnAnnotationRenderersChanged();
101  }
102 
104  {
105  return BaseRenderer::GetByName(this->GetRendererID());
106  }
107 }
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
virtual void AddToBaseRenderer(BaseRenderer *renderer)=0
Adds the Annotation to the specified renderer. Update Annotation should be called soon in order to ap...
AbstractAnnotationRenderer(const std::string &rendererID, const std::string &arID)
~AbstractAnnotationRenderer() override
virtual destructor in order to derive from this class
Base class for all Annotation This class is to be implemented in order to create Annotation which are...
static BaseRenderer * GetByName(const std::string &name)
T AddingService(const ServiceReferenceType &reference) override
virtual std::vector< T > GetServices() const
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.