Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkSurfaceStampWidget.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 #include <mitkLabelSetImage.h>
16 #include <mitkRenderingManager.h>
17 #include <mitkSurface.h>
19 
20 #include <QMessageBox>
21 
22 QmitkSurfaceStampWidget::QmitkSurfaceStampWidget(QWidget *parent, const char * /*name*/)
23  : QWidget(parent), m_ToolManager(nullptr), m_DataStorage(nullptr)
24 {
25  m_Controls.setupUi(this);
26  m_Controls.m_InformationWidget->hide();
27 
29  assert(m_ToolManager);
30  m_ToolManager->ActivateTool(-1);
31 
33  m_SurfacePredicate->AddPredicate(mitk::NodePredicateDataType::New("Surface"));
34  m_SurfacePredicate->AddPredicate(mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object")));
35 
36  m_Controls.m_cbSurfaceNodeSelector->SetPredicate(m_SurfacePredicate);
37 
38  connect(m_Controls.m_pbStamp, SIGNAL(clicked()), this, SLOT(OnStamp()));
39  connect(m_Controls.m_cbShowInformation, SIGNAL(toggled(bool)), this, SLOT(OnShowInformation(bool)));
40  m_Controls.m_InformationWidget->hide();
41 }
42 
44 {
45 }
46 
48 {
49  m_DataStorage = storage;
50  m_Controls.m_cbSurfaceNodeSelector->SetDataStorage(m_DataStorage);
51 }
52 
54 {
55  mitk::DataNode *surfaceNode = m_Controls.m_cbSurfaceNodeSelector->GetSelectedNode();
56 
57  if (!surfaceNode)
58  {
59  QMessageBox::information(this, "Surface Stamp", "Please load and select a surface before starting some action.");
60  return;
61  }
62 
64  assert(m_ToolManager);
65  m_ToolManager->ActivateTool(-1);
66 
67  mitk::Surface *surface = dynamic_cast<mitk::Surface *>(surfaceNode->GetData());
68  if (!surface)
69  {
70  QMessageBox::information(this, "Surface Stamp", "Please load and select a surface before starting some action.");
71  return;
72  }
73 
74  mitk::DataNode *workingNode = m_ToolManager->GetWorkingData(0);
75 
76  if (!workingNode)
77  {
78  QMessageBox::information(
79  this, "Surface Stamp", "Please load and select a segmentation before starting some action.");
80  return;
81  }
82 
83  mitk::LabelSetImage *workingImage = dynamic_cast<mitk::LabelSetImage *>(workingNode->GetData());
84 
85  if (!workingImage)
86  {
87  QMessageBox::information(
88  this, "Surface Stamp", "Please load and select a segmentation before starting some action.");
89  return;
90  }
91 
92  QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
93 
94  try
95  {
96  // workingImage->SurfaceStamp( surface, m_Controls.m_chkOverwrite->isChecked() );
97  }
98  catch (mitk::Exception &e)
99  {
100  QApplication::restoreOverrideCursor();
101  MITK_ERROR << "Exception caught: " << e.GetDescription();
102  QMessageBox::information(
103  this, "Surface Stamp", "Could not stamp the selected surface.\n See error log for details.\n");
104  return;
105  }
106 
107  QApplication::restoreOverrideCursor();
108 
110 }
111 
113 {
114  if (on)
115  m_Controls.m_InformationWidget->show();
116  else
117  m_Controls.m_InformationWidget->hide();
118 }
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
Data management class that handles &#39;was created by&#39; relations.
static Pointer New()
#define MITK_ERROR
Definition: mitkLogMacros.h:20
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
QmitkSurfaceStampWidget(QWidget *parent=nullptr, const char *name=nullptr)
bool ActivateTool(int id)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
mitk::DataStorage::Pointer m_DataStorage
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
static RenderingManager * GetInstance()
static Pointer New(const mitk::NodePredicateBase *_arg)
static Pointer New(const char *_arg)
static Pointer New(const char *_arg)
LabelSetImage class for handling labels and layers in a segmentation session.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
DataVectorType GetWorkingData()
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
void SetDataStorage(mitk::DataStorage *storage)