Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkMxNMultiWidgetEditor.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 
16 #include <berryIPreferences.h>
17 #include <berryIWorkbenchPage.h>
19 #include <berryUIException.h>
20 
21 // mxn multi widget editor plugin
23 
24 // mitk qt widgets module
25 #include <QmitkMxNMultiWidget.h>
28 
29 // qt
30 #include <QHBoxLayout>
31 
32 const QString QmitkMxNMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.mxnmultiwidget";
33 
34 struct QmitkMxNMultiWidgetEditor::Impl final
35 {
36  Impl();
37  ~Impl() = default;
38 
39  QmitkInteractionSchemeToolBar* m_InteractionSchemeToolBar;
40  QmitkMultiWidgetConfigurationToolBar* m_ConfigurationToolBar;
41 };
42 
43 QmitkMxNMultiWidgetEditor::Impl::Impl()
44  : m_InteractionSchemeToolBar(nullptr)
45  , m_ConfigurationToolBar(nullptr)
46 {
47  // nothing here
48 }
49 
51 // QmitkMxNMultiWidgetEditor
55  , m_Impl(std::make_unique<Impl>())
56 {
57  // nothing here
58 }
59 
61 {
62  GetSite()->GetPage()->RemovePartListener(this);
63 }
64 
65 void QmitkMxNMultiWidgetEditor::OnLayoutSet(int row, int column)
66 {
67  const auto &multiWidget = dynamic_cast<QmitkMxNMultiWidget *>(GetMultiWidget());
68  if (nullptr != multiWidget)
69  {
70  multiWidget->SetCrosshairVisibility(true);
72  }
73 }
74 
76 {
77  const auto &multiWidget = GetMultiWidget();
78  if (nullptr == multiWidget)
79  {
80  return;
81  }
82 
84  {
85  m_Impl->m_InteractionSchemeToolBar->setVisible(true);
86  }
87  else
88  {
89  m_Impl->m_InteractionSchemeToolBar->setVisible(false);
90  }
91 
93 }
94 
96 // PRIVATE
98 void QmitkMxNMultiWidgetEditor::SetFocus()
99 {
100  const auto& multiWidget = GetMultiWidget();
101  if (nullptr != multiWidget)
102  {
103  multiWidget->setFocus();
104  }
105 }
106 
107 void QmitkMxNMultiWidgetEditor::CreateQtPartControl(QWidget* parent)
108 {
109  QHBoxLayout *layout = new QHBoxLayout(parent);
110  layout->setContentsMargins(0, 0, 0, 0);
111 
113 
114  auto multiWidget = GetMultiWidget();
115  if (nullptr == multiWidget)
116  {
117  multiWidget = new QmitkMxNMultiWidget(parent, 0, nullptr);
118 
119  // create left toolbar: interaction scheme toolbar to switch how the render window navigation behaves in PACS mode
120  if (nullptr == m_Impl->m_InteractionSchemeToolBar)
121  {
122  m_Impl->m_InteractionSchemeToolBar = new QmitkInteractionSchemeToolBar(parent);
123  layout->addWidget(m_Impl->m_InteractionSchemeToolBar);
124  }
125  m_Impl->m_InteractionSchemeToolBar->SetInteractionEventHandler(multiWidget->GetInteractionEventHandler());
126 
127  // show / hide PACS mouse mode interaction scheme toolbar
128  bool PACSInteractionScheme = preferences->GetBool("PACS like mouse interaction", false);
129  m_Impl->m_InteractionSchemeToolBar->setVisible(PACSInteractionScheme);
130 
131  multiWidget->SetDataStorage(GetDataStorage());
132  multiWidget->InitializeMultiWidget();
133  SetMultiWidget(multiWidget);
134  }
135 
136  layout->addWidget(multiWidget);
137 
138  // create right toolbar: configuration toolbar to change the render window widget layout
139  if (nullptr == m_Impl->m_ConfigurationToolBar)
140  {
141  m_Impl->m_ConfigurationToolBar = new QmitkMultiWidgetConfigurationToolBar(multiWidget);
142  layout->addWidget(m_Impl->m_ConfigurationToolBar);
143  }
144 
145  connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::LayoutSet,
147  connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::Synchronized,
149  connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::InteractionSchemeChanged,
151 
152  GetSite()->GetPage()->AddPartListener(this);
153 
154  OnPreferencesChanged(preferences);
155 }
156 
157 void QmitkMxNMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* preferences)
158 {
159  const auto& multiWidget = GetMultiWidget();
160  if (nullptr == multiWidget)
161  {
162  return;
163  }
164 
165  // update decoration preferences
166  //m_Impl->m_MultiWidgetDecorationManager->DecorationPreferencesChanged(preferences);
167 
168  // zooming and panning preferences
169  bool constrainedZooming = preferences->GetBool("Use constrained zooming and panning", true);
171 
172  bool PACSInteractionScheme = preferences->GetBool("PACS like mouse interaction", false);
173  OnInteractionSchemeChanged(PACSInteractionScheme ?
176 
179 }
virtual void SetConstrainedPanningZooming(bool _arg)
virtual QmitkAbstractMultiWidget * GetMultiWidget() const
Return the current multi widget of this editor.
void LayoutSet(int row, int column)
void SetCrosshairVisibility(bool activate) override
STL namespace.
virtual void SetMultiWidget(QmitkAbstractMultiWidget *multiWidget)
Set the current multi widget of this editor.
void OnInteractionSchemeChanged(mitk::InteractionSchemeSwitcher::InteractionScheme scheme)
virtual bool GetBool(const QString &key, bool def) const =0
virtual void OnSynchronize(bool synchronized)
virtual void OnLayoutSet(int row, int column)
A slot that can be called if the layout has been changed. This function will call the function &#39;SetLa...
virtual mitk::DataStorage::Pointer GetDataStorage() const
static RenderingManager * GetInstance()
virtual void OnInteractionSchemeChanged(mitk::InteractionSchemeSwitcher::InteractionScheme scheme)
void Synchronized(bool synchronized)
void InteractionSchemeChanged(mitk::InteractionSchemeSwitcher::InteractionScheme scheme)
The &#39;QmitkMxNMultiWidget&#39; is a &#39;QmitkAbstractMultiWidget&#39; that is used to display multiple render win...
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
void OnLayoutSet(int row, int column)
A slot that can be called if the layout has been changed. This function will call the function &#39;SetLa...
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
IWorkbenchPartSite::Pointer GetSite() const override
ObjectType * GetPointer() const
virtual berry::IPreferences::Pointer GetPreferences() const