38 struct QmitkStdMultiWidgetEditor::Impl final
46 std::unique_ptr<QmitkMultiWidgetDecorationManager> m_MultiWidgetDecorationManager;
49 QmitkStdMultiWidgetEditor::Impl::Impl()
50 : m_InteractionSchemeToolBar(nullptr)
51 , m_LevelWindowWidget(nullptr)
61 , m_Impl(
std::make_unique<Impl>())
68 GetSite()->GetPage()->RemovePartListener(
this);
81 if (
nullptr != multiWidget)
84 multiWidget->ActivateMenuWidget(
false);
94 if (
nullptr != multiWidget)
97 multiWidget->ActivateMenuWidget(
true);
107 if (
nullptr != multiWidget)
119 if (
nullptr != multiWidget)
128 return m_Impl->m_LevelWindowWidget;
134 if (
nullptr == multiWidget)
145 if (
nullptr == multiWidget)
151 if (node.IsNotNull())
153 bool visible =
false;
154 node->GetVisibility(visible,
nullptr);
166 if (
nullptr == multiWidget)
173 m_Impl->m_InteractionSchemeToolBar->setVisible(
true);
177 m_Impl->m_InteractionSchemeToolBar->setVisible(
false);
187 m_Impl->m_LevelWindowWidget->disconnect(
this);
189 m_Impl->m_LevelWindowWidget->show();
193 m_Impl->m_LevelWindowWidget->disconnect(
this);
194 m_Impl->m_LevelWindowWidget->hide();
198 void QmitkStdMultiWidgetEditor::SetFocus()
201 if (
nullptr != multiWidget)
203 multiWidget->setFocus();
207 void QmitkStdMultiWidgetEditor::CreateQtPartControl(QWidget* parent)
209 QHBoxLayout* layout =
new QHBoxLayout(parent);
210 layout->setContentsMargins(0, 0, 0, 0);
215 if (
nullptr == multiWidget)
220 if (
nullptr == m_Impl->m_InteractionSchemeToolBar)
223 layout->addWidget(m_Impl->m_InteractionSchemeToolBar);
225 m_Impl->m_InteractionSchemeToolBar->SetInteractionEventHandler(multiWidget->GetInteractionEventHandler());
228 multiWidget->InitializeMultiWidget();
232 layout->addWidget(multiWidget);
235 if (
nullptr == m_Impl->m_LevelWindowWidget)
238 m_Impl->m_LevelWindowWidget->setObjectName(QString::fromUtf8(
"levelWindowWidget"));
240 QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
241 sizePolicy.setHorizontalStretch(0);
242 sizePolicy.setVerticalStretch(0);
243 sizePolicy.setHeightForWidth(m_Impl->m_LevelWindowWidget->sizePolicy().hasHeightForWidth());
244 m_Impl->m_LevelWindowWidget->setSizePolicy(sizePolicy);
245 m_Impl->m_LevelWindowWidget->setMaximumWidth(50);
248 layout->addWidget(m_Impl->m_LevelWindowWidget);
250 m_Impl->m_MultiWidgetDecorationManager = std::make_unique<QmitkMultiWidgetDecorationManager>(multiWidget);
252 GetSite()->GetPage()->AddPartListener(
this);
254 InitializePreferences(preferences);
255 OnPreferencesChanged(preferences);
261 if (
nullptr == multiWidget)
267 GetPreferenceDecorations(preferences);
268 m_Impl->m_MultiWidgetDecorationManager->DecorationPreferencesChanged(preferences);
272 for (
const auto& renderWindowWidget : renderWindowWidgets)
274 auto decorationColor = renderWindowWidget.second->GetDecorationColor();
275 multiWidget->SetDecorationColor(i, decorationColor);
280 int crosshairgapsize = preferences->
GetInt(
"crosshair gap size", 32);
281 multiWidget->GetWidgetPlane1()->SetIntProperty(
"Crosshair.Gap Size", crosshairgapsize);
282 multiWidget->GetWidgetPlane2()->SetIntProperty(
"Crosshair.Gap Size", crosshairgapsize);
283 multiWidget->GetWidgetPlane3()->SetIntProperty(
"Crosshair.Gap Size", crosshairgapsize);
286 bool constrainedZooming = preferences->
GetBool(
"Use constrained zooming and panning",
true);
290 bool PACSInteractionScheme = preferences->
GetBool(
"PACS like mouse interaction",
false);
296 bool showLevelWindowWidget = preferences->
GetBool(
"Show level/window widget",
true);
307 if (
nullptr == multiWidget)
310 this->GetPreferenceDecorations(preferences);
312 for (
const auto& renderWindowWidget : multiWidget->GetRenderWindowWidgets())
314 auto widgetName = renderWindowWidget.second->GetWidgetName();
316 auto gradientBackgroundColors = renderWindowWidget.second->GetGradientBackgroundColors();
317 preferences->
Put(widgetName +
" first background color", this->MitkColorToHex(gradientBackgroundColors.first));
318 preferences->
Put(widgetName +
" second background color", this->MitkColorToHex(gradientBackgroundColors.second));
320 auto decorationColor = renderWindowWidget.second->GetDecorationColor();
321 preferences->
Put(widgetName +
" decoration color", this->MitkColorToHex(decorationColor));
323 auto cornerAnnotation = renderWindowWidget.second->GetCornerAnnotationText();
324 preferences->
Put(widgetName +
" corner annotation", QString::fromStdString(cornerAnnotation));
332 if (
nullptr == multiWidget)
335 auto hexBlack =
"#000000";
336 auto gradientBlack =
"#191919";
337 auto gradientGray =
"#7F7F7F";
341 for (
const auto& renderWindowWidget : renderWindowWidgets)
343 auto widgetName = renderWindowWidget.second->GetWidgetName();
347 auto upper = preferences->
Get(widgetName +
" first background color", gradientBlack);
348 auto lower = preferences->
Get(widgetName +
" second background color", gradientGray);
349 renderWindowWidget.second->SetGradientBackgroundColors(HexColorToMitkColor(upper), HexColorToMitkColor(lower));
353 auto upper = preferences->
Get(widgetName +
" first background color", hexBlack);
354 auto lower = preferences->
Get(widgetName +
" second background color", hexBlack);
355 renderWindowWidget.second->SetGradientBackgroundColors(HexColorToMitkColor(upper), HexColorToMitkColor(lower));
358 auto defaultDecorationColor = multiWidget->GetDecorationColor(i);
359 auto decorationColor = preferences->
Get(widgetName +
" decoration color", MitkColorToHex(defaultDecorationColor));
360 renderWindowWidget.second->SetDecorationColor(HexColorToMitkColor(decorationColor));
362 auto defaultCornerAnnotation = renderWindowWidget.second->GetCornerAnnotationText();
363 auto cornerAnnotation = preferences->
Get(widgetName +
" corner annotation", QString::fromStdString(defaultCornerAnnotation));
364 renderWindowWidget.second->SetCornerAnnotationText(cornerAnnotation.toStdString());
370 mitk::Color QmitkStdMultiWidgetEditor::HexColorToMitkColor(
const QString& hexColor)
372 QColor qColor(hexColor);
374 float colorMax = 255.0f;
375 if (hexColor.isEmpty())
377 returnColor[0] = 1.0;
378 returnColor[1] = 1.0;
379 returnColor[2] = 1.0;
380 MITK_ERROR <<
"Using default color for unknown hex color " << qPrintable(hexColor);
384 returnColor[0] = qColor.red() / colorMax;
385 returnColor[1] = qColor.green() / colorMax;
386 returnColor[2] = qColor.blue() / colorMax;
391 QString QmitkStdMultiWidgetEditor::MitkColorToHex(
const mitk::Color& color)
394 float colorMax = 255.0f;
395 returnColor.setRed(static_cast<int>(color[0] * colorMax + 0.5));
396 returnColor.setGreen(static_cast<int>(color[1] * colorMax + 0.5));
397 returnColor.setBlue(static_cast<int>(color[2] * colorMax + 0.5));
398 return returnColor.name();
virtual void SetConstrainedPanningZooming(bool _arg)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
virtual bool GetBool(const QString &key, bool def) const =0
virtual mitk::DataStorage::Pointer GetDataStorage() const
static RenderingManager * GetInstance()
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
virtual QString Get(const QString &key, const QString &def) const =0
virtual void Put(const QString &key, const QString &value)=0
virtual int GetInt(const QString &key, int def) const =0
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
IWorkbenchPartSite::Pointer GetSite() const override
ObjectType * GetPointer() const
virtual berry::IPreferences::Pointer GetPreferences() const