Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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#ifndef __vtkSlicerMarkupsLogic_h
24#define __vtkSlicerMarkupsLogic_h
25
26// Slicer includes
28
29// Markups module includes
32
33// MRML includes
34#include "vtkMRMLStorageNode.h"
42
43// VTK includes
44#include <vtkVector.h>
45class vtkIdList;
46class vtkMatrix4x4;
47class vtkPlane;
48class vtkPoints;
49class vtkPolyData;
50
51// STD includes
52#include <cstdlib>
53#include <list>
54#include <string>
55
56#include "vtkSlicerMarkupsModuleLogicExport.h"
57
58class VTK_SLICER_MARKUPS_MODULE_LOGIC_EXPORT vtkSlicerMarkupsLogic : public vtkSlicerModuleLogic
59{
60public:
61 enum Events
62 {
63 MarkupRegistered = vtkCommand::UserEvent + 1,
65 };
66
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
71 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
72
77 std::string GetSelectionNodeID();
78
82 std::string GetActiveListID();
83
87
94
100
106 std::string AddNewFiducialNode(const char* name = "F", vtkMRMLScene* scene = nullptr);
107
110 vtkMRMLMarkupsNode* AddNewMarkupsNode(std::string className, std::string nodeName = std::string(), vtkMRMLScene* scene = nullptr);
111
116 int AddControlPoint(double r = 0.0, double a = 0.0, double s = 0.0);
117
121 void JumpSlicesToLocation(double x, double y, double z, bool centered, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
124 void JumpSlicesToNthPointInMarkup(const char* id, int n, bool centered = false, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
127 void FocusCamerasOnNthPointInMarkup(const char* id, int n);
131 void FocusCameraOnNthPointInMarkup(const char* cameraNodeID, const char* markupNodeID, int n);
132
136 char* LoadMarkups(const char* fileName, const char* fidsName = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
137
139 char* LoadMarkupsFiducials(const char* fileName, const char* fidsName = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
140
141 char* LoadMarkupsFromFcsv(const char* fileName, const char* nodeName = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
142 char* LoadMarkupsFromJson(const char* fileName, const char* nodeName = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
143
147 char* LoadAnnotation(const char* filename, const char* name, int annotationFileType);
148
150 enum
151 {
156 };
157
167
173
176
181 bool CopyNthControlPointToNewList(int n, vtkMRMLMarkupsNode* markupsNode, vtkMRMLMarkupsNode* newMarkupsNode);
182
190 bool MoveNthControlPointToNewListAtIndex(int n, vtkMRMLMarkupsNode* markupsNode, vtkMRMLMarkupsNode* newMarkupsNode, int newIndex);
191
199 void ConvertAnnotationFiducialsToMarkups(vtkStringArray* addedNodeIds = nullptr, vtkStringArray* removedNodeIds = nullptr);
200
205 void ConvertAnnotationLinesROIsToMarkups(vtkStringArray* addedNodeIds = nullptr, vtkStringArray* removedNodeIds = nullptr);
206
208
214
220 bool StartPlaceMode(bool persistent, vtkMRMLInteractionNode* interactionNode = nullptr);
221
222 vtkSetMacro(AutoCreateDisplayNodes, bool);
223 vtkGetMacro(AutoCreateDisplayNodes, bool);
224 vtkBooleanMacro(AutoCreateDisplayNodes, bool);
225
227
231
239 static double GetClosedCurveSurfaceArea(vtkMRMLMarkupsClosedCurveNode* curveNode, vtkPolyData* surface = nullptr, bool projectWarp = true);
240
253 static bool FitSurfaceProjectWarp(vtkPoints* curvePoints, vtkPolyData* surface, double radiusScalingFactor = 1.0, vtkIdType numberOfInternalGridPoints = 225);
254
264 static bool FitSurfaceDiskWarp(vtkPoints* curvePoints, vtkPolyData* surface, double radiusScalingFactor = 1.0);
265
268 static bool IsPolygonClockwise(vtkPoints* points, vtkIdList* pointIds = nullptr);
269
271 static bool GetBestFitPlane(vtkMRMLMarkupsNode* curveNode, vtkPlane* plane);
272
273 std::string GetJsonStorageNodeClassNameForMarkupsType(std::string markupsType);
274 void RegisterJsonStorageNodeForMarkupsType(std::string markupsType, std::string storageNodeClassName);
276
284 vtkSlicerMarkupsWidget* markupsWidget,
285 bool createPushButton = true,
286 vtkSlicerMarkupsInteractionWidget* interactionWidget = nullptr);
287
292
295 bool IsMarkupsNodeRegistered(const char* nodeType) const;
296
302 vtkSlicerMarkupsWidget* GetWidgetByMarkupsType(const char* markupsType) const;
303
306
312 vtkMRMLMarkupsNode* GetNodeByMarkupsType(const char* markupsType) const;
313
315 const std::list<std::string>& GetRegisteredMarkupsTypes() const;
316
318 bool GetCreateMarkupsPushButton(const char* markupName) const;
319
322 static bool ImportControlPointsFromTable(vtkMRMLMarkupsNode* markupsNode, vtkMRMLTableNode* tableNode, int startRow = 0, int numberOfRows = -1);
323
325
330 static bool ExportControlPointsToCSV(vtkMRMLMarkupsNode* markupsNode, const std::string filename, bool lps = true);
331
335 static bool ImportControlPointsFromCSV(vtkMRMLMarkupsNode* markupsNode, const std::string filename);
336
337 //-----------------------------------------------------------
338 // All public methods below are deprecated
339 //
340 // These methods are deprecated because they use old terms (markup instead of control point),
341
343 bool CopyNthMarkupToNewList(int n, vtkMRMLMarkupsNode* markupsNode, vtkMRMLMarkupsNode* newMarkupsNode)
344 {
345 vtkWarningMacro("vtkSlicerMarkupsLogic::CopyNthMarkupToNewList method is deprecated, please use CopyNthControlPointToNewList instead");
346 return this->CopyNthControlPointToNewList(n, markupsNode, newMarkupsNode);
347 }
348
349 bool MoveNthMarkupToNewList(int n, vtkMRMLMarkupsNode* markupsNode, vtkMRMLMarkupsNode* newMarkupsNode, int newIndex)
350 {
351 vtkWarningMacro("vtkSlicerMarkupsLogic::MoveNthMarkupToNewList method is deprecated, please use MoveNthControlPointToNewListAtIndex instead");
352 return this->MoveNthControlPointToNewListAtIndex(n, markupsNode, newMarkupsNode, newIndex);
353 }
354
355 int AddFiducial(double r = 0.0, double a = 0.0, double s = 0.0)
356 {
357 vtkWarningMacro("vtkSlicerMarkupsLogic::AddFiducial method is deprecated, please use AddControlPoint instead");
358 return this->AddControlPoint(r, a, s);
359 };
360
362 {
363 vtkWarningMacro("vtkSlicerMarkupsLogic::SetAllMarkupsVisibility method is deprecated, please use SetAllControlPointsVisibility instead");
364 this->SetAllControlPointsVisibility(node, flag);
365 };
366
368 {
369 vtkWarningMacro("vtkSlicerMarkupsLogic::ToggleAllMarkupsVisibility method is deprecated, please use ToggleAllControlPointsVisibility instead");
371 };
372
374 {
375 vtkWarningMacro("vtkSlicerMarkupsLogic::SetAllMarkupsLocked method is deprecated, please use SetAllControlPointsLocked instead");
376 this->SetAllControlPointsLocked(node, flag);
377 };
378
380 {
381 vtkWarningMacro("vtkSlicerMarkupsLogic::ToggleAllMarkupsLocked method is deprecated, please use ToggleAllControlPointsLocked instead");
383 };
384
386 {
387 vtkWarningMacro("vtkSlicerMarkupsLogic::SetAllMarkupsSelected method is deprecated, please use SetAllControlPointsSelected instead");
388 this->SetAllControlPointsSelected(node, flag);
389 };
390
392 {
393 vtkWarningMacro("vtkSlicerMarkupsLogic::ToggleAllMarkupsSelected method is deprecated, please use ToggleAllControlPointsSelected instead");
395 };
396
398 {
399 vtkWarningMacro("vtkSlicerMarkupsLogic::RenameAllMarkupsFromCurrentFormat method is deprecated, please use RenameAllControlPointsFromCurrentFormat instead");
401 };
402
404
407 vtkVector3d GenerateUniqueColor();
408 void GenerateUniqueColor(double color[3]);
410
411protected:
414
416 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
417 void ObserveMRMLScene() override;
419
422
424 void RegisterNodes() override;
425 void UpdateFromMRMLScene() override;
426 void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
428 void OnMRMLSceneEndImport() override;
429
430private:
432 void operator=(const vtkSlicerMarkupsLogic&) = delete;
433
434 bool AutoCreateDisplayNodes;
435
436 class vtkInternal;
437 vtkInternal* Internal;
438};
439
440#endif
MRML node to represent a closed curve markup Closed Curve Markups nodes contain N control points....
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for storing information about the active nodes in the scene.
MRML node for storing a slice through RAS space.
MRML node to represent a table object.
Process interaction events to update state of interaction widgets.
void ToggleAllMarkupsLocked(vtkMRMLMarkupsNode *node)
void OnMRMLSceneEndImport() override
std::string AddNewDisplayNodeForMarkupsNode(vtkMRMLNode *mrmlNode)
void FocusCameraOnNthPointInMarkup(const char *cameraNodeID, const char *markupNodeID, int n)
void UpdateFromMRMLScene() override
bool CopyNthMarkupToNewList(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode)
static vtkSlicerMarkupsLogic * New()
static bool FitSurfaceDiskWarp(vtkPoints *curvePoints, vtkPolyData *surface, double radiusScalingFactor=1.0)
std::string GetActiveListID()
vtkVector3d GenerateUniqueColor()
void RenameAllControlPointsFromCurrentFormat(vtkMRMLMarkupsNode *markupsNode)
static bool FitSurfaceProjectWarp(vtkPoints *curvePoints, vtkPolyData *surface, double radiusScalingFactor=1.0, vtkIdType numberOfInternalGridPoints=225)
static double GetClosedCurveSurfaceArea(vtkMRMLMarkupsClosedCurveNode *curveNode, vtkPolyData *surface=nullptr, bool projectWarp=true)
void UpdatePlaceNodeClassNamesInSelectionNode()
Update list of place node class names in selection node based on currently registered markups.
void SetAllMarkupsSelected(vtkMRMLMarkupsNode *node, bool flag)
void OnMRMLSceneNodeAdded(vtkMRMLNode *node) override
void FocusCamerasOnNthPointInMarkup(const char *id, int n)
void SetAllControlPointsSelected(vtkMRMLMarkupsNode *node, bool flag)
std::string GetJsonStorageNodeClassNameForMarkupsType(std::string markupsType)
void SetAllControlPointsLocked(vtkMRMLMarkupsNode *node, bool flag)
void JumpSlicesToNthPointInMarkup(const char *id, int n, bool centered=false, int viewGroup=-1, vtkMRMLSliceNode *exclude=nullptr)
void SetActiveList(vtkMRMLMarkupsNode *markupsNode)
void ConvertAnnotationLinesROIsToMarkups(vtkStringArray *addedNodeIds=nullptr, vtkStringArray *removedNodeIds=nullptr)
vtkMRMLMarkupsDisplayNode * GetDefaultMarkupsDisplayNode()
static bool ExportControlPointsToTable(vtkMRMLMarkupsNode *markupsNode, vtkMRMLTableNode *tableNode, int coordinateSystem=vtkMRMLStorageNode::CoordinateSystemRAS)
static bool IsPolygonClockwise(vtkPoints *points, vtkIdList *pointIds=nullptr)
std::string AddNewFiducialNode(const char *name="F", vtkMRMLScene *scene=nullptr)
static bool ImportControlPointsFromCSV(vtkMRMLMarkupsNode *markupsNode, const std::string filename)
void ObserveMRMLScene() override
void ToggleAllMarkupsVisibility(vtkMRMLMarkupsNode *node)
std::string GetSelectionNodeID()
void SetAllControlPointsVisibility(vtkMRMLMarkupsNode *node, bool flag)
vtkSlicerMarkupsInteractionWidget * GetInteractionWidgetByMarkupsType(const char *markupsType) const
Returns the interaction widget for the specified markups type.
void JumpSlicesToLocation(double x, double y, double z, bool centered, int viewGroup=-1, vtkMRMLSliceNode *exclude=nullptr)
void ToggleAllControlPointsVisibility(vtkMRMLMarkupsNode *node)
int AddFiducial(double r=0.0, double a=0.0, double s=0.0)
char * LoadAnnotation(const char *filename, const char *name, int annotationFileType)
vtkMRMLMarkupsJsonStorageNode * AddNewJsonStorageNodeForMarkupsType(std::string markupsType)
bool IsMarkupsNodeRegistered(const char *nodeType) const
void SetAndObserveSelectionNode(vtkMRMLSelectionNode *selectionNode)
char * LoadMarkups(const char *fileName, const char *fidsName=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
vtkMRMLMarkupsNode * GetNodeByMarkupsType(const char *markupsType) const
void SetAllMarkupsVisibility(vtkMRMLMarkupsNode *node, bool flag)
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
Initialize listening to MRML events.
static bool ExportControlPointsToCSV(vtkMRMLMarkupsNode *markupsNode, const std::string filename, bool lps=true)
void RegisterMarkupsNode(vtkMRMLMarkupsNode *markupsNode, vtkSlicerMarkupsWidget *markupsWidget, bool createPushButton=true, vtkSlicerMarkupsInteractionWidget *interactionWidget=nullptr)
bool MoveNthControlPointToNewListAtIndex(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode, int newIndex)
void SetAllMarkupsLocked(vtkMRMLMarkupsNode *node, bool flag)
vtkMRMLMarkupsNode * AddNewMarkupsNode(std::string className, std::string nodeName=std::string(), vtkMRMLScene *scene=nullptr)
vtkSlicerMarkupsWidget * GetWidgetByMarkupsType(const char *markupsType) const
bool StartPlaceMode(bool persistent, vtkMRMLInteractionNode *interactionNode=nullptr)
void GenerateUniqueColor(double color[3])
void UnregisterMarkupsNode(vtkMRMLMarkupsNode *markupsNode)
void RegisterJsonStorageNodeForMarkupsType(std::string markupsType, std::string storageNodeClassName)
static bool GetBestFitPlane(vtkMRMLMarkupsNode *curveNode, vtkPlane *plane)
Get best fit plane for a markup.
void OnMRMLSceneNodeRemoved(vtkMRMLNode *node) override
void SetDisplayDefaultsFromNode(vtkMRMLMarkupsDisplayNode *displayNode)
utility method to set defaults from display node
void CopyBasicDisplayProperties(vtkMRMLMarkupsDisplayNode *sourceDisplayNode, vtkMRMLMarkupsDisplayNode *targetDisplayNode)
int AddControlPoint(double r=0.0, double a=0.0, double s=0.0)
char * LoadMarkupsFiducials(const char *fileName, const char *fidsName=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
This method is deprecated. It is kept for backward compatibility only, it does the same as LoadMarkup...
void RenameAllMarkupsFromCurrentFormat(vtkMRMLMarkupsNode *markupsNode)
void ToggleAllMarkupsSelected(vtkMRMLMarkupsNode *node)
char * LoadMarkupsFromFcsv(const char *fileName, const char *nodeName=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
void PrintSelf(ostream &os, vtkIndent indent) override
void ConvertAnnotationHierarchyToSubjectHierarchy(vtkMRMLScene *scene)
bool GetCreateMarkupsPushButton(const char *markupName) const
This returns the flags that indicates whether the GUI push button should be created.
void SetActiveListID(vtkMRMLMarkupsNode *markupsNode)
void ToggleAllControlPointsLocked(vtkMRMLMarkupsNode *node)
bool MoveNthMarkupToNewList(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode, int newIndex)
const std::list< std::string > & GetRegisteredMarkupsTypes() const
This returns the list of the markups registered in the logic.
void ToggleAllControlPointsSelected(vtkMRMLMarkupsNode *node)
void SetDisplayNodeToDefaults(vtkMRMLMarkupsDisplayNode *displayNode)
char * LoadMarkupsFromJson(const char *fileName, const char *nodeName=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
static bool ImportControlPointsFromTable(vtkMRMLMarkupsNode *markupsNode, vtkMRMLTableNode *tableNode, int startRow=0, int numberOfRows=-1)
~vtkSlicerMarkupsLogic() override
void ConvertAnnotationFiducialsToMarkups(vtkStringArray *addedNodeIds=nullptr, vtkStringArray *removedNodeIds=nullptr)
bool CopyNthControlPointToNewList(int n, vtkMRMLMarkupsNode *markupsNode, vtkMRMLMarkupsNode *newMarkupsNode)
void RegisterNodes() override
Register MRML Node classes to Scene. Gets called automatically when the MRMLScene is attached to this...
Process interaction events to update state of markup widget nodes.