Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <mitkLabelSetImage.h>
20 #include <mitkRenderingManager.h>
21 #include <mitkSurface.h>
23 
24 #include <QMessageBox>
25 
26 QmitkSurfaceStampWidget::QmitkSurfaceStampWidget(QWidget *parent, const char * /*name*/)
27  : QWidget(parent), m_ToolManager(NULL), m_DataStorage(NULL)
28 {
29  m_Controls.setupUi(this);
30  m_Controls.m_InformationWidget->hide();
31 
33  assert(m_ToolManager);
34  m_ToolManager->ActivateTool(-1);
35 
37  m_SurfacePredicate->AddPredicate(mitk::NodePredicateDataType::New("Surface"));
38  m_SurfacePredicate->AddPredicate(mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object")));
39 
40  m_Controls.m_cbSurfaceNodeSelector->SetPredicate(m_SurfacePredicate);
41 
42  connect(m_Controls.m_pbStamp, SIGNAL(clicked()), this, SLOT(OnStamp()));
43  connect(m_Controls.m_cbShowInformation, SIGNAL(toggled(bool)), this, SLOT(OnShowInformation(bool)));
44  m_Controls.m_InformationWidget->hide();
45 }
46 
48 {
49 }
50 
52 {
53  m_DataStorage = storage;
54  m_Controls.m_cbSurfaceNodeSelector->SetDataStorage(m_DataStorage);
55 }
56 
58 {
59  mitk::DataNode *surfaceNode = m_Controls.m_cbSurfaceNodeSelector->GetSelectedNode();
60 
61  if (!surfaceNode)
62  {
63  QMessageBox::information(this, "Surface Stamp", "Please load and select a surface before starting some action.");
64  return;
65  }
66 
68  assert(m_ToolManager);
69  m_ToolManager->ActivateTool(-1);
70 
71  mitk::Surface *surface = dynamic_cast<mitk::Surface *>(surfaceNode->GetData());
72  if (!surface)
73  {
74  QMessageBox::information(this, "Surface Stamp", "Please load and select a surface before starting some action.");
75  return;
76  }
77 
78  mitk::DataNode *workingNode = m_ToolManager->GetWorkingData(0);
79 
80  if (!workingNode)
81  {
82  QMessageBox::information(
83  this, "Surface Stamp", "Please load and select a segmentation before starting some action.");
84  return;
85  }
86 
87  mitk::LabelSetImage *workingImage = dynamic_cast<mitk::LabelSetImage *>(workingNode->GetData());
88 
89  if (!workingImage)
90  {
91  QMessageBox::information(
92  this, "Surface Stamp", "Please load and select a segmentation before starting some action.");
93  return;
94  }
95 
96  QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
97 
98  try
99  {
100  // workingImage->SurfaceStamp( surface, m_Controls.m_chkOverwrite->isChecked() );
101  }
102  catch (mitk::Exception &e)
103  {
104  QApplication::restoreOverrideCursor();
105  MITK_ERROR << "Exception caught: " << e.GetDescription();
106  QMessageBox::information(
107  this, "Surface Stamp", "Could not stamp the selected surface.\n See error log for details.\n");
108  return;
109  }
110 
111  QApplication::restoreOverrideCursor();
112 
114 }
115 
117 {
118  if (on)
119  m_Controls.m_InformationWidget->show();
120  else
121  m_Controls.m_InformationWidget->hide();
122 }
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
Data management class that handles 'was created by' relations.
static Pointer New()
#define MITK_ERROR
Definition: mitkLogMacros.h:24
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
bool ActivateTool(int id)
mitk::DataStorage::Pointer m_DataStorage
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:49
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:66
DataVectorType GetWorkingData()
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
void SetDataStorage(mitk::DataStorage *storage)
QmitkSurfaceStampWidget(QWidget *parent=0, const char *name=0)