Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
QmitkDataNodeToggleVisibilityAction.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 
15 
16 // mitk core
17 #include <mitkRenderingManager.h>
18 
19 // berry
20 #include <berryIPreferences.h>
22 #include <berryPlatform.h>
23 
24 // namespace that contains the concrete action
26 {
27  void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, const QList<mitk::DataNode::Pointer>& selectedNodes /*= QList<mitk::DataNode::Pointer>()*/, mitk::BaseRenderer* baseRenderer /*= nullptr*/)
28  {
29  bool isVisible;
30  for (auto& node : selectedNodes)
31  {
32  if (node.IsNotNull())
33  {
34  isVisible = false;
35  node->GetBoolProperty("visible", isVisible, baseRenderer);
36  node->SetVisibility(!isVisible, baseRenderer);
37  }
38  }
39 
41 
43  bool globalReinit = preferences->GetBool("Call global reinit if node visibility is changed", false);
44  if (globalReinit)
45  {
46  GlobalReinitAction::Run(workbenchPartSite, dataStorage);
47  }
48  else
49  {
50  if (nullptr == baseRenderer)
51  {
53  }
54  else
55  {
57  }
58  }
59  }
60 }
61 
63  : QAction(parent)
64  , QmitkAbstractDataNodeAction(workbenchpartSite)
65 {
66  setText(tr("Toggle visibility"));
68 }
69 
71  : QAction(parent)
72  , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
73 {
74  setText(tr("Toggle visibility"));
76 }
77 
79 {
80  connect(this, &QmitkDataNodeToggleVisibilityAction::triggered, this, &QmitkDataNodeToggleVisibilityAction::OnActionTriggered);
81 }
82 
83 void QmitkDataNodeToggleVisibilityAction::OnActionTriggered(bool /*checked*/)
84 {
86  {
87  return;
88  }
89 
91  {
92  return;
93  }
94 
96 
97  auto dataNodes = GetSelectedNodes();
99 }
mitk::BaseRenderer::Pointer GetBaseRenderer()
Grants access to the base renderer stored for the action. Will return nullptr if renderer was never s...
itk::SmartPointer< T > Lock() const
QList< mitk::DataNode::Pointer > GetSelectedNodes() const
Organizes the rendering process.
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
QmitkDataNodeToggleVisibilityAction(QWidget *parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
SmartPointer< ObjectType > Lock() const
static RenderingManager * GetInstance()
bool IsExpired() const noexcept
void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, const QList< mitk::DataNode::Pointer > &selectedNodes, mitk::BaseRenderer *baseRenderer)
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
void RequestUpdate(vtkRenderWindow *renderWindow)
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite
void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
static IPreferencesService * GetPreferencesService()