Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkDataNodeSurfaceRepresentationAction.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 
15 // mitk core
17 #include <mitkRenderingManager.h>
18 
19 // qt
20 #include <QMenu>
21 
23  : QAction(parent)
24  , QmitkAbstractDataNodeAction(workbenchpartSite)
25 {
26  setText(tr("Surface Representation"));
28 }
29 
31  : QAction(parent)
32  , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
33 {
34  setText(tr("Surface Representation"));
36 }
37 
39 {
40  setCheckable(true);
41 
42  setMenu(new QMenu);
43  connect(menu(), &QMenu::aboutToShow, this, &QmitkDataNodeSurfaceRepresentationAction::OnMenuAboutShow);
44 }
45 
46 void QmitkDataNodeSurfaceRepresentationAction::OnMenuAboutShow()
47 {
49  if (nullptr == dataNode)
50  {
51  return;
52  }
53 
55  mitk::EnumerationProperty* representationProp = dynamic_cast<mitk::EnumerationProperty*>(dataNode->GetProperty("material.representation", baseRenderer));
56  if (nullptr == representationProp)
57  {
58  return;
59  }
60 
61  menu()->clear();
62  QAction* tmp;
63 
64  for (mitk::EnumerationProperty::EnumConstIterator it = representationProp->Begin(); it != representationProp->End(); ++it)
65  {
66  tmp = menu()->addAction(QString::fromStdString(it->second));
67  tmp->setCheckable(true);
68 
69  if (it->second == representationProp->GetValueAsString())
70  {
71  tmp->setChecked(true);
72  }
73 
74  connect(tmp, &QAction::triggered, this, &QmitkDataNodeSurfaceRepresentationAction::OnActionTriggered);
75  }
76 }
77 
78 void QmitkDataNodeSurfaceRepresentationAction::OnActionTriggered(bool /*checked*/)
79 {
80  auto dataNode = GetSelectedNode();
81  if (dataNode.IsNull())
82  {
83  return;
84  }
85 
87  mitk::EnumerationProperty* representationProp = dynamic_cast<mitk::EnumerationProperty*>(dataNode->GetProperty("material.representation", baseRenderer));
88  if (nullptr == representationProp)
89  {
90  return;
91  }
92 
93  QAction* senderAction = qobject_cast<QAction*>(QObject::sender());
94  if (nullptr == senderAction)
95  {
96  return;
97  }
98 
99  std::string activatedItem = senderAction->text().toStdString();
100  if (activatedItem != representationProp->GetValueAsString())
101  {
102  if (representationProp->IsValidEnumerationValue(activatedItem))
103  {
104  representationProp->SetValue(activatedItem);
105  representationProp->InvokeEvent(itk::ModifiedEvent());
106  representationProp->Modified();
107 
108  if (nullptr == baseRenderer)
109  {
111  }
112  else
113  {
114  mitk::RenderingManager::GetInstance()->RequestUpdate(baseRenderer->GetRenderWindow());
115  }
116  }
117  }
118 }
mitk::BaseRenderer::Pointer GetBaseRenderer()
Grants access to the base renderer stored for the action. Will return nullptr if renderer was never s...
virtual bool SetValue(const std::string &name)
std::string GetValueAsString() const override
QmitkDataNodeSurfaceRepresentationAction(QWidget *parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
virtual EnumConstIterator End() const
static RenderingManager * GetInstance()
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer an instance of QmitkDataManagerView allows for data selection Visualization of the selected data is then performed by a simple render window view According data can either be directly loaded from file or be imported as DICOM data DICOM import functionality is accessible from the DICOM perspective incorporating the QmitkDicomExternalDataWidget The customization of Qt Stylesheets is used to give the application a non native look and feel This is further emphasized by a Tab Widget like unification of the perspectives with the according perspective bar In addition to an absence of menu
EnumIdsContainerType::const_iterator EnumConstIterator
mitk::DataNode::Pointer GetSelectedNode() const
virtual EnumConstIterator Begin() const
void RequestUpdate(vtkRenderWindow *renderWindow)
virtual bool IsValidEnumerationValue(const IdType &id) const
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)