Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerMarkupsLogic.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 ==============================================================================*/
17 
18 // .NAME vtkSlicerMarkupsLogic - slicer logic class for volumes manipulation
19 // .SECTION Description
20 // This class manages the logic associated with reading, saving,
21 // and changing propertied of the volumes
22 
23 
24 #ifndef __vtkSlicerMarkupsLogic_h
25 #define __vtkSlicerMarkupsLogic_h
26 
27 // Slicer includes
28 #include "vtkSlicerModuleLogic.h"
29 
30 // MRML includes
31 
32 // STD includes
33 #include <cstdlib>
34 
35 #include "vtkSlicerMarkupsModuleLogicExport.h"
36 
37 class vtkMatrix4x4;
38 class vtkMRMLMarkupsNode;
43 class vtkPlane;
44 class vtkPoints;
45 class vtkPolyData;
46 
48 class VTK_SLICER_MARKUPS_MODULE_LOGIC_EXPORT vtkSlicerMarkupsLogic :
50 {
51 public:
52 
53  static vtkSlicerMarkupsLogic *New();
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
57  void ProcessMRMLNodesEvents(vtkObject *caller,
58  unsigned long event,
59  void *callData ) override;
60 
65  std::string GetSelectionNodeID();
66 
70  std::string GetActiveListID();
71 
77  void SetActiveListID(vtkMRMLMarkupsNode *markupsNode);
78 
83  std::string AddNewDisplayNodeForMarkupsNode(vtkMRMLNode *mrmlNode);
84 
90  std::string AddNewFiducialNode(const char *name = "F", vtkMRMLScene *scene = nullptr);
91 
96  int AddFiducial(double r=0.0, double a=0.0, double s=0.0);
97 
101  void JumpSlicesToLocation(double x, double y, double z, bool centered, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
104  void JumpSlicesToNthPointInMarkup(const char *id, int n, bool centered = false, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
107  void FocusCamerasOnNthPointInMarkup(const char *id, int n);
111  void FocusCameraOnNthPointInMarkup(const char *cameraNodeID, const char *markupNodeID, int n);
112 
116  char* LoadMarkups(const char* fileName, const char* fidsName=nullptr);
117 
119  char* LoadMarkupsFiducials(const char* fileName, const char* fidsName = nullptr);
120 
121  char* LoadMarkupsFromFcsv(const char* fileName, const char* nodeName/*=nullptr*/);
122  char* LoadMarkupsFromJson(const char* fileName, const char* nodeName/*=nullptr*/);
123 
125  void SetAllMarkupsVisibility(vtkMRMLMarkupsNode *node, bool flag);
126  void ToggleAllMarkupsVisibility(vtkMRMLMarkupsNode *node);
127  void SetAllMarkupsLocked(vtkMRMLMarkupsNode *node, bool flag);
128  void ToggleAllMarkupsLocked(vtkMRMLMarkupsNode *node);
129  void SetAllMarkupsSelected(vtkMRMLMarkupsNode *node, bool flag);
130  void ToggleAllMarkupsSelected(vtkMRMLMarkupsNode *node);
131 
133  void SetDisplayNodeToDefaults(vtkMRMLMarkupsDisplayNode *displayNode);
134 
136  void SetDisplayDefaultsFromNode(vtkMRMLMarkupsDisplayNode *displayNode);
137 
142  bool CopyNthControlPointToNewList(int n, vtkMRMLMarkupsNode *markupsNode,
143  vtkMRMLMarkupsNode *newMarkupsNode);
144 
147  vtkMRMLMarkupsNode *newMarkupsNode)
148  {
149  return this->CopyNthControlPointToNewList(n, markupsNode, newMarkupsNode);
150  }
151 
159  bool MoveNthControlPointToNewListAtIndex(int n, vtkMRMLMarkupsNode *markupsNode,
160  vtkMRMLMarkupsNode *newMarkupsNode, int newIndex);
161 
164  vtkMRMLMarkupsNode *newMarkupsNode, int newIndex)
165  {
166  return this->MoveNthControlPointToNewListAtIndex(n, markupsNode, newMarkupsNode, newIndex);
167  }
168 
174  void ConvertAnnotationFiducialsToMarkups();
175 
180  void RenameAllMarkupsFromCurrentFormat(vtkMRMLMarkupsNode *markupsNode);
181 
187  bool StartPlaceMode(bool persistent, vtkMRMLInteractionNode* interactionNode = nullptr);
188 
192  int GetSliceIntersectionsVisibility();
195  void SetSliceIntersectionsVisibility(bool flag);
196 
197  vtkSetMacro(AutoCreateDisplayNodes, bool);
198  vtkGetMacro(AutoCreateDisplayNodes, bool);
199  vtkBooleanMacro(AutoCreateDisplayNodes, bool);
200 
201  vtkMRMLMarkupsDisplayNode* GetDefaultMarkupsDisplayNode();
202 
205  void CopyBasicDisplayProperties(vtkMRMLMarkupsDisplayNode *sourceDisplayNode, vtkMRMLMarkupsDisplayNode *targetDisplayNode);
206 
214  static double GetClosedCurveSurfaceArea(vtkMRMLMarkupsClosedCurveNode* curveNode, vtkPolyData* surface = nullptr, bool projectWarp = true);
215 
225  static bool FitSurfaceProjectWarp(vtkPoints* curvePoints, vtkPolyData* surface, double radiusScalingFactor = 1.0);
226 
234  static bool FitSurfaceDiskWarp(vtkPoints* curvePoints, vtkPolyData* surface, double radiusScalingFactor = 1.0);
235 
237  static bool IsPolygonClockwise(vtkPoints* points);
238 
240  static bool GetBestFitPlane(vtkMRMLMarkupsNode* curveNode, vtkPlane* plane);
241 
242  std::string GetJsonStorageNodeClassNameForMarkupsType(std::string markupsType);
243  void RegisterJsonStorageNodeForMarkupsType(std::string markupsType, std::string storageNodeClassName);
244  vtkMRMLMarkupsJsonStorageNode* AddNewJsonStorageNodeForMarkupsType(std::string markupsType);
245 
246 protected:
248  ~vtkSlicerMarkupsLogic() override;
249 
251  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
252  void ObserveMRMLScene() override;
253  void SetAndObserveSelectionNode(vtkMRMLSelectionNode* selectionNode);
254 
256  void RegisterNodes() override;
257  void UpdateFromMRMLScene() override;
258  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
259  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
260 
261  std::map<std::string, std::string> MarkupsTypeStorageNodes;
262  vtkMRMLSelectionNode* SelectionNode{nullptr};
263 
264 private:
265 
267  void operator=(const vtkSlicerMarkupsLogic&) = delete;
268 
269  bool AutoCreateDisplayNodes;
270 };
271 
272 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
MRML node for storing a slice through RAS space.
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
virtual void ObserveMRMLScene()
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
std::map< std::string, std::string > MarkupsTypeStorageNodes
bool MoveNthMarkupToNewList(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode, int newIndex)
virtual void UpdateFromMRMLScene()
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.
MRML node to represent a closed curve markup Closed Curve Markups nodes contain N control points...
bool CopyNthMarkupToNewList(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode)