Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerMarkupsPlaceWidget.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Matthew Holden, PerkLab, Queen's University
16  and was supported through the Applied Cancer Research Unit program of Cancer Care
17  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerMarkupsPlaceWidget_h
22 #define __qSlicerMarkupsPlaceWidget_h
23 
24 // Qt includes
25 #include "qSlicerWidget.h"
26 
27 #include "qMRMLUtils.h"
28 
29 // Markups Widgets includes
30 #include "qSlicerMarkupsModuleWidgetsExport.h"
31 #include "ui_qSlicerMarkupsPlaceWidget.h"
32 
33 
34 class qSlicerMarkupsPlaceWidgetPrivate;
38 class vtkMRMLMarkupsNode;
39 
41 class Q_SLICER_MODULE_MARKUPS_WIDGETS_EXPORT
43 {
44  Q_OBJECT
46  Q_PROPERTY(bool buttonsVisible READ buttonsVisible WRITE setButtonsVisible)
47  Q_PROPERTY(bool deleteAllControlPointsOptionVisible READ deleteAllControlPointsOptionVisible WRITE setDeleteAllControlPointsOptionVisible)
48  Q_PROPERTY(bool unsetLastControlPointOptionVisible READ unsetLastControlPointOptionVisible WRITE setUnsetLastControlPointOptionVisible)
49  Q_PROPERTY(bool unsetAllControlPointsOptionVisible READ unsetAllControlPointsOptionVisible WRITE setUnsetAllControlPointsOptionVisible)
50  Q_PROPERTY(PlaceMultipleMarkupsType placeMultipleMarkups READ placeMultipleMarkups WRITE setPlaceMultipleMarkups)
51  Q_PROPERTY(QColor nodeColor READ nodeColor WRITE setNodeColor)
52  Q_PROPERTY(QColor defaultNodeColor READ defaultNodeColor WRITE setDefaultNodeColor)
53  Q_PROPERTY(bool currentNodeActive READ currentNodeActive WRITE setCurrentNodeActive)
54  Q_PROPERTY(bool placeModeEnabled READ placeModeEnabled WRITE setPlaceModeEnabled)
55  Q_PROPERTY(bool placeModePersistency READ placeModePersistency WRITE setPlaceModePersistency)
56 
58  Q_PROPERTY(bool deleteAllMarkupsOptionVisible READ deleteAllMarkupsOptionVisible WRITE setDeleteAllMarkupsOptionVisible)
59 
60 public:
62  qSlicerMarkupsPlaceWidget(QWidget *parent=nullptr);
63  ~qSlicerMarkupsPlaceWidget() override;
64 
66  {
67  ShowPlaceMultipleMarkupsOption, // show a menu on the place button to place multiple markup points
68  HidePlaceMultipleMarkupsOption, // don't allow to change persistency of place mode, just use current
69  ForcePlaceSingleMarkup, // always disable persistency when enabling place mode
70  ForcePlaceMultipleMarkups // always enable persistency when enabling place mode
71  };
72 
74  Q_INVOKABLE vtkMRMLNode* currentNode() const;
75  Q_INVOKABLE vtkMRMLMarkupsFiducialNode* currentMarkupsFiducialNode() const;
76  Q_INVOKABLE vtkMRMLMarkupsNode* currentMarkupsNode() const;
77 
80  Q_INVOKABLE vtkMRMLInteractionNode* interactionNode()const;
81  Q_INVOKABLE vtkMRMLSelectionNode* selectionNode()const;
82 
84  bool currentNodeActive() const;
85 
87  bool placeModeEnabled() const;
88 
90  bool placeModePersistency() const;
91 
93  PlaceMultipleMarkupsType placeMultipleMarkups() const;
94 
96  bool buttonsVisible() const;
97 
99  bool deleteAllControlPointsOptionVisible() const;
100 
102  bool unsetLastControlPointOptionVisible() const;
103 
105  bool unsetAllControlPointsOptionVisible() const;
106 
108  QColor nodeColor() const;
109 
111  QColor defaultNodeColor() const;
112 
113  // Returns true if additional points are allowed in the current markup node, false when point number is fixed
114  bool currentMarkupPointPlacementValid();
115 
116  Q_INVOKABLE QToolButton* placeButton() const;
117 
118  // Button to delete control point(s) or unset their position
119  Q_INVOKABLE QToolButton* deleteButton() const;
120 
121  //-----------------------------------------------------------
122  // All public methods below are deprecated
123  //
124  // These methods are deprecated because they use old terms (markup instead of control point),
125 
128  {
129  qWarning("qSlicerMarkupsPlaceWidget::deleteAllMarkupsOptionVisible method is deprecated, please use deleteAllControlPointsOptionVisible instead");
130  return this->deleteAllControlPointsOptionVisible();
131  };
132 
133 
134 public slots:
135 
136  void setMRMLScene(vtkMRMLScene* scene) override;
137 
139  void setCurrentNode(vtkMRMLNode* currentNode);
140 
142  void setCurrentNodeActive(bool active);
143 
146  void setInteractionNode(vtkMRMLInteractionNode* interactionNode);
147  void setSelectionNode(vtkMRMLSelectionNode* selectionNode);
148 
149  void setDefaultNodeColor(QColor color);
150 
151  void setNodeColor(QColor color);
152 
154  void setPlaceModeEnabled(bool enable);
155 
157  void setPlaceMultipleMarkups(PlaceMultipleMarkupsType option);
158 
160  void setButtonsVisible(bool visible);
161 
163  void setDeleteAllControlPointsOptionVisible(bool visible);
164 
166  void setUnsetLastControlPointOptionVisible(bool visible);
167 
169  void setUnsetAllControlPointsOptionVisible(bool visible);
170 
172  void setPlaceModePersistency(bool);
173 
177  void modifyLastPoint();
178 
180  void deleteLastPoint();
181 
183  void deleteAllPoints();
184 
186  void unsetLastDefinedPoint();
187 
189  void unsetAllPoints();
190 
191  //-----------------------------------------------------------
192  // All public methods below are deprecated
193  //
194  // These methods are deprecated because they use old terms (markup instead of control point),
195 
198  {
199  qWarning("qSlicerMarkupsPlaceWidget::deleteLastMarkup method is deprecated, please use deleteLastPoint instead");
200  this->deleteLastPoint();
201  };
204  {
205  qWarning("qSlicerMarkupsPlaceWidget::deleteAllMarkups method is deprecated, please use deleteAllPoints instead");
206  this->deleteAllPoints();
207  };
210  {
211  qWarning("qSlicerMarkupsPlaceWidget::setDeleteAllMarkupsOptionVisible method is deprecated, please use setDeleteAllControlPointsOptionVisible instead");
212  this->setDeleteAllControlPointsOptionVisible(visible);
213  };
214 
215 protected slots:
216 
218  void updateWidget();
219 
221  void updateDeleteButton();
222 
224  void onColorButtonChanged(QColor);
226  void onVisibilityButtonClicked();
228  void onLockedButtonClicked();
230  void onFixedNumberOfControlPointsButtonClicked();
231 
232  void onPlacePersistentPoint(bool enable);
233 
234 signals:
235 
239  void activeMarkupsPlaceModeChanged(bool enabled);
240 
242  void activeMarkupsFiducialPlaceModeChanged(bool enabled);
243 
244 protected:
245  QScopedPointer<qSlicerMarkupsPlaceWidgetPrivate> d_ptr;
246 
247  virtual void setup();
248 
249 private:
250  Q_DECLARE_PRIVATE(qSlicerMarkupsPlaceWidget);
251  Q_DISABLE_COPY(qSlicerMarkupsPlaceWidget);
252 
253 };
254 
255 #endif
void setDeleteAllMarkupsOptionVisible(bool visible)
QScopedPointer< qSlicerMarkupsPlaceWidgetPrivate > d_ptr
MRML node to represent a fiducial markup Fiducial Markups nodes contain a list of control points...
void setMRMLScene(vtkMRMLScene *scene) override
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
MRML node for storing information about the active nodes in the scene.