Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkDataNodeTextureInterpolationAction.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
16 #include <mitkRenderingManager.h>
17 
19  : QAction(parent)
20  , QmitkAbstractDataNodeAction(workbenchpartSite)
21 {
22  setText(tr("Texture Interpolation"));
24 }
25 
27  : QAction(parent)
28  , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
29 {
30  setText(tr("Texture Interpolation"));
32 }
33 
35 {
36  setCheckable(true);
37 
38  connect(this, &QmitkDataNodeTextureInterpolationAction::toggled, this, &QmitkDataNodeTextureInterpolationAction::OnActionToggled);
39  connect(this, &QmitkDataNodeTextureInterpolationAction::changed, this, &QmitkDataNodeTextureInterpolationAction::OnActionChanged);
40 }
41 
43 {
44  if (nullptr == dataNode)
45  {
46  setChecked(false);
47  return;
48  }
49 
51 
52  bool textureInterpolation = false;
53  dataNode->GetBoolProperty("texture interpolation", textureInterpolation, baseRenderer);
54  setChecked(textureInterpolation);
55 }
56 
57 void QmitkDataNodeTextureInterpolationAction::OnActionToggled(bool checked)
58 {
59  auto dataNode = GetSelectedNode();
60  if (dataNode.IsNull())
61  {
62  return;
63  }
64 
66  dataNode->SetBoolProperty("texture interpolation", checked, baseRenderer);
67 
68  if (nullptr == baseRenderer)
69  {
71  }
72  else
73  {
74  mitk::RenderingManager::GetInstance()->RequestUpdate(baseRenderer->GetRenderWindow());
75  }
76 }
77 
78 void QmitkDataNodeTextureInterpolationAction::OnActionChanged()
79 {
80  auto dataNode = GetSelectedNode();
81  if (dataNode.IsNull())
82  {
83  return;
84  }
85 
86  InitializeWithDataNode(dataNode);
87 }
mitk::BaseRenderer::Pointer GetBaseRenderer()
Grants access to the base renderer stored for the action. Will return nullptr if renderer was never s...
QmitkDataNodeTextureInterpolationAction(QWidget *parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
static RenderingManager * GetInstance()
mitk::DataNode::Pointer GetSelectedNode() const
void RequestUpdate(vtkRenderWindow *renderWindow)
void InitializeWithDataNode(const mitk::DataNode *dataNode) override
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57