Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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 (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 
13 
15 #include "internal/QmitkCommonActivator.h"
16 
18 #include <mitkIRenderingManager.h>
19 
21 #include <berryUIException.h>
22 
23 #include <ctkServiceTracker.h>
24 
25 class QmitkAbstractRenderEditorPrivate
26 {
27 public:
28 
29  QmitkAbstractRenderEditorPrivate()
30  : m_RenderingManagerInterface(mitk::MakeRenderingManagerInterface(mitk::RenderingManager::GetInstance()))
31  , m_PrefServiceTracker(QmitkCommonActivator::GetContext())
32  {
33  m_PrefServiceTracker.open();
34  }
35 
36  ~QmitkAbstractRenderEditorPrivate()
37  {
38  delete m_RenderingManagerInterface;
39  }
40 
41  mitk::IRenderingManager* m_RenderingManagerInterface;
42  ctkServiceTracker<berry::IPreferencesService*> m_PrefServiceTracker;
44 };
45 
47  : d(new QmitkAbstractRenderEditorPrivate)
48 {
49 }
50 
52 {
53  if (d->m_Prefs.IsNotNull())
54  {
56  (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) );
57  }
58 }
59 
61 {
62  if (input.Cast<mitk::DataStorageEditorInput>().IsNull())
63  throw berry::PartInitException("Invalid Input: Must be mitk::DataStorageEditorInput");
64 
65  this->SetSite(site);
66  this->SetInput(input);
67 
68  d->m_Prefs = this->GetPreferences().Cast<berry::IBerryPreferences>();
69  if (d->m_Prefs.IsNotNull())
70  {
72  (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) );
73  }
74 }
75 
77 {
79  if (input.IsNotNull())
80  {
81  return input->GetDataStorageReference();
82  }
84 }
85 
87 {
89  if (ref.IsNotNull()) return ref->GetDataStorage();
90  return mitk::DataStorage::Pointer(nullptr);
91 }
92 
94 {
95  berry::IPreferencesService* prefService = d->m_PrefServiceTracker.getService();
96  if (prefService != nullptr)
97  {
98  return prefService->GetSystemPreferences()->Node(this->GetSite()->GetId());
99  }
100  return berry::IPreferences::Pointer(nullptr);
101 }
102 
104 {
105  // we use the global rendering manager here. This should maybe replaced
106  // by a local one, managing only the render windows specific for the editor
107  return d->m_RenderingManagerInterface;
108 }
109 
111 {
112  if (GetRenderingManager())
113  GetRenderingManager()->RequestUpdateAll(requestType);
114 }
115 
117 {
118  if (GetRenderingManager())
120 }
121 
123 {
124  if (GetRenderingManager())
126  return nullptr;
127 }
128 
129 void QmitkAbstractRenderEditor::OnPreferencesChanged(const berry::IBerryPreferences *)
130 {}
131 
133 {}
134 
136 {}
137 
139 { return false; }
140 
142 { 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)
SmartPointer< Other > Cast() 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:82
virtual mitk::DataStorage::Pointer GetDataStorage() const
void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) override
virtual mitk::IDataStorageReference::Pointer GetDataStorageReference() const
virtual void RequestUpdateAll(RenderingManager::RequestType type=RenderingManager::REQUEST_UPDATE_ALL)=0
virtual void SetInput(IEditorInput::Pointer input)
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
virtual berry::IPreferences::Pointer GetPreferences() const