Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkAbstractRenderEditor.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
19 #include "internal/QmitkCommonActivator.h"
20 
22 #include <mitkIRenderingManager.h>
23 
25 #include <berryUIException.h>
26 
27 #include <ctkServiceTracker.h>
28 
29 class QmitkAbstractRenderEditorPrivate
30 {
31 public:
32 
33  QmitkAbstractRenderEditorPrivate()
34  : m_RenderingManagerInterface(mitk::MakeRenderingManagerInterface(mitk::RenderingManager::GetInstance()))
35  , m_PrefServiceTracker(QmitkCommonActivator::GetContext())
36  {
37  m_PrefServiceTracker.open();
38  }
39 
40  ~QmitkAbstractRenderEditorPrivate()
41  {
42  delete m_RenderingManagerInterface;
43  }
44 
45  mitk::IRenderingManager* m_RenderingManagerInterface;
46  ctkServiceTracker<berry::IPreferencesService*> m_PrefServiceTracker;
48 };
49 
50 QmitkAbstractRenderEditor::QmitkAbstractRenderEditor()
51  : d(new QmitkAbstractRenderEditorPrivate)
52 {
53 }
54 
56 {
57  if (d->m_Prefs.IsNotNull())
58  {
60  (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) );
61  }
62 }
63 
65 {
66  if (input.Cast<mitk::DataStorageEditorInput>().IsNull())
67  throw berry::PartInitException("Invalid Input: Must be mitk::DataStorageEditorInput");
68 
69  this->SetSite(site);
70  this->SetInput(input);
71 
72  d->m_Prefs = this->GetPreferences().Cast<berry::IBerryPreferences>();
73  if (d->m_Prefs.IsNotNull())
74  {
76  (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) );
77  }
78 }
79 
81 {
83  if (input.IsNotNull())
84  {
85  return input->GetDataStorageReference();
86  }
88 }
89 
91 {
93  if (ref.IsNotNull()) return ref->GetDataStorage();
94  return mitk::DataStorage::Pointer(nullptr);
95 }
96 
98 {
99  berry::IPreferencesService* prefService = d->m_PrefServiceTracker.getService();
100  if (prefService != nullptr)
101  {
102  return prefService->GetSystemPreferences()->Node(this->GetSite()->GetId());
103  }
104  return berry::IPreferences::Pointer(nullptr);
105 }
106 
108 {
109  // we use the global rendering manager here. This should maybe replaced
110  // by a local one, managing only the render windows specific for the editor
111  return d->m_RenderingManagerInterface;
112 }
113 
115 {
116  if (GetRenderingManager())
117  GetRenderingManager()->RequestUpdateAll(requestType);
118 }
119 
121 {
122  if (GetRenderingManager())
124 }
125 
127 {
128  if (GetRenderingManager())
130  return nullptr;
131 }
132 
133 void QmitkAbstractRenderEditor::OnPreferencesChanged(const berry::IBerryPreferences *)
134 {}
135 
137 {}
138 
140 {}
141 
143 { return false; }
144 
146 { return false; }
virtual void ForceImmediateUpdateAll(RenderingManager::RequestType type=RenderingManager::REQUEST_UPDATE_ALL)=0
IEditorInput::Pointer GetEditorInput() const override
void ForceImmediateUpdate(mitk::RenderingManager::RequestType requestType=mitk::RenderingManager::REQUEST_UPDATE_ALL) override
IRenderingManager * MakeRenderingManagerInterface(RenderingManager::Pointer manager)
virtual mitk::IDataStorageReference::Pointer GetDataStorageReference() const
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
void SetSite(IWorkbenchPartSite::Pointer site)
Controls the selection of the slice the associated BaseRenderer will display.
An editor input based on a mitk::DataStorage.
mitk::SliceNavigationController * GetTimeNavigationController() const override
mitk::IRenderingManager * GetRenderingManager() const override
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
virtual mitk::DataStorage::Pointer GetDataStorage() const
void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) override
virtual berry::IPreferences::Pointer GetPreferences() const
virtual void RequestUpdateAll(RenderingManager::RequestType type=RenderingManager::REQUEST_UPDATE_ALL)=0
virtual void SetInput(IEditorInput::Pointer input)
SmartPointer< Other > Cast() const
berry::SmartPointer< Self > Pointer
An interface for accessing a mitk::RenderingManager instance.
void RequestUpdate(mitk::RenderingManager::RequestType requestType=mitk::RenderingManager::REQUEST_UPDATE_ALL) override
IWorkbenchPartSite::Pointer GetSite() const override
virtual const SliceNavigationController * GetTimeNavigationController() const =0