Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsDisplayNode.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 vtkMRMLMarkupsDisplayNode - MRML node to represent display properties for markups
19 // .SECTION Description
20 // vtkMRMLMarkupsDisplayNode nodes store display properties of markups,
21 // keeping elements that are applicable to all parts of the markups in this superclass
22 //
23 
24 #ifndef __vtkMRMLMarkupsDisplayNode_h
25 #define __vtkMRMLMarkupsDisplayNode_h
26 
27 #include "vtkSlicerMarkupsModuleMRMLExport.h"
28 
29 #include "vtkMRMLDisplayNode.h"
30 #include "vtkMRMLMarkupsNode.h"
31 
32 // vtkAddon includes
33 #include <vtkAddonSetGet.h>
34 
35 // STD includes
36 #include <map>
37 
38 // VTK include
39 #include <vtkTextProperty.h>
40 
43 
45 class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsDisplayNode : public vtkMRMLDisplayNode
46 {
47 public:
48  static vtkMRMLMarkupsDisplayNode *New();
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52  //--------------------------------------------------------------------------
53  // MRMLNode methods
54  //--------------------------------------------------------------------------
55 
56  vtkMRMLNode* CreateNodeInstance() override;
57 
59  void ReadXMLAttributes(const char** atts) override;
60 
62  void WriteXML(ostream& of, int indent) override;
63 
67 
69  const char* GetNodeTagName() override { return "MarkupsDisplay"; };
70 
72  void UpdateScene(vtkMRMLScene* scene) override;
73 
75  void ProcessMRMLEvents(vtkObject* /*caller*/, unsigned long /*event*/, void* /*callData*/ ) override;
76 
78  vtkMRMLMarkupsNode* GetMarkupsNode();
79 
81  static const std::string GetDefaultContextName() { return ""; };
82 
89  int GetActiveComponentType(std::string context=vtkMRMLMarkupsDisplayNode::GetDefaultContextName());
91  {
92  ComponentNone = 0,
100  Component_Last
101  };
103  {
105  {
106  this->Type = ComponentNone;
107  this->Index = -1;
108  }
109  int Type;
110  int Index;
111  };
112 
116  int GetActiveComponentIndex(std::string context=vtkMRMLMarkupsDisplayNode::GetDefaultContextName());
117 
119  void SetActiveComponent(int componentType, int componentIndex,
121 
123  bool HasActiveComponent();
124 
127  std::vector<std::string> GetActiveComponentInteractionContexts();
128 
130  void SetActiveControlPoint(int controlPointIndex);
131 
136  int UpdateActiveControlPointWorld(int controlPointIndex, vtkMRMLInteractionEventData* eventData,
137  double accurateWorldOrientationMatrix[9], const char* viewNodeID,
138  const char* associatedNodeID, int positionStatus);
139 
142  void GetActiveControlPoints(std::vector<int>& controlPointIndices);
146  int GetActiveControlPoint(std::string context=vtkMRMLMarkupsDisplayNode::GetDefaultContextName());
147 
149  vtkGetMacro(TextScale,double);
150  vtkSetMacro(TextScale,double);
151 
153 
156  vtkSetMacro(PointLabelsVisibility, bool);
157  vtkGetMacro(PointLabelsVisibility, bool);
158  vtkBooleanMacro(PointLabelsVisibility, bool);
160 
162 
165  vtkSetMacro(PropertiesLabelVisibility, bool);
166  vtkGetMacro(PropertiesLabelVisibility, bool);
167  vtkBooleanMacro(PropertiesLabelVisibility, bool);
169 
171 
174  vtkSetMacro(FillVisibility, bool);
175  vtkGetMacro(FillVisibility, bool);
176  vtkBooleanMacro(FillVisibility, bool);
177 
179 
182  vtkSetMacro(OutlineVisibility, bool);
183  vtkGetMacro(OutlineVisibility, bool);
184  vtkBooleanMacro(OutlineVisibility, bool);
185 
187 
190  vtkSetMacro(FillOpacity, double);
191  vtkGetMacro(FillOpacity, double);
192  vtkBooleanMacro(FillOpacity, double);
193 
195 
198  vtkSetMacro(OutlineOpacity, double);
199  vtkGetMacro(OutlineOpacity, double);
200  vtkBooleanMacro(OutlineOpacity, double);
201 
204  {
205  SnapModeUnconstrained, //< point is moved independently from displayed objects in 3D views (e.g., in parallel with camera plane)
206  SnapModeToVisibleSurface, //< point is snapped to any visible surface in 3D views
207  //SnapModeToNode //< point is snapped to a specific node, not implemented yet
208  SnapMode_Last // insert new items above this line
209  };
210 
214  {
215  GlyphTypeInvalid = 0,
230  GlyphType_Last // insert new types above this line
231  };
233  static int GetMinimumGlyphType() { return 1; };
235 
237  vtkSetMacro(GlyphType, int);
238  vtkGetMacro(GlyphType, int);
240  int GlyphTypeIs3D(int glyphType);
241  int GlyphTypeIs3D() { return this->GlyphTypeIs3D(this->GlyphType); };
242 
244  const char* GetGlyphTypeAsString();
245  void SetGlyphTypeFromString(const char* glyphString);
246 
247  static const char* GetGlyphTypeAsString(int g);
248  static int GetGlyphTypeFromString(const char*);
249 
252  vtkSetMacro(SnapMode, int);
253  vtkGetMacro(SnapMode, int);
254 
255  static const char* GetSnapModeAsString(int g);
256  static int GetSnapModeFromString(const char*);
257 
261  vtkSetMacro(GlyphScale,double);
262  vtkGetMacro(GlyphScale,double);
263 
267  vtkSetMacro(GlyphSize,double);
268  vtkGetMacro(GlyphSize,double);
269 
274  vtkSetMacro(UseGlyphScale, bool);
275  vtkGetMacro(UseGlyphScale, bool);
276  vtkBooleanMacro(UseGlyphScale, bool);
277 
278  enum
279  {
280  ResetToDefaultsEvent = 19001, //< reset this node to the default values, request completed by markups logic
281  JumpToPointEvent,
283  ActionEvent,
285  };
286 
292  vtkSetMacro(SliceProjection, bool);
293  vtkGetMacro(SliceProjection, bool);
294  vtkBooleanMacro(SliceProjection, bool);
295 
298  vtkSetMacro(SliceProjectionUseFiducialColor, bool);
299  vtkGetMacro(SliceProjectionUseFiducialColor, bool);
300  vtkBooleanMacro(SliceProjectionUseFiducialColor, bool);
301 
304  vtkSetMacro(SliceProjectionOutlinedBehindSlicePlane, bool);
305  vtkGetMacro(SliceProjectionOutlinedBehindSlicePlane, bool);
306  vtkBooleanMacro(SliceProjectionOutlinedBehindSlicePlane, bool);
307 
310  vtkSetVector3Macro(SliceProjectionColor, double);
311  vtkGetVector3Macro(SliceProjectionColor, double);
312 
315  vtkSetClampMacro(SliceProjectionOpacity, double, 0.0, 1.0);
316  vtkGetMacro(SliceProjectionOpacity, double);
317 
321  {
322  UseLineThickness = 0,
324  CurveLineSizeMode_Last // insert new types above this line
325  };
326 
329  vtkSetMacro(CurveLineSizeMode, int);
330  vtkGetMacro(CurveLineSizeMode, int);
331  const char* GetCurveLineSizeModeAsString();
332  void SetCurveLineSizeModeFromString(const char* modeString);
333  static const char* GetCurveLineSizeModeAsString(int mode);
334  static int GetCurveLineSizeModeFromString(const char*);
335 
341  vtkGetMacro(LineThickness, double);
342  vtkSetMacro(LineThickness, double);
343 
348  vtkGetMacro(LineDiameter, double);
349  vtkSetMacro(LineDiameter, double);
350 
353  vtkGetMacro(LineColorFadingStart, double);
354  vtkSetMacro(LineColorFadingStart, double);
355 
358  vtkGetMacro(LineColorFadingEnd, double);
359  vtkSetMacro(LineColorFadingEnd, double);
360 
363  vtkSetClampMacro(LineColorFadingSaturation, double, 0.0, 1.0);
364  vtkGetMacro(LineColorFadingSaturation, double);
365 
368  vtkSetClampMacro(LineColorFadingHueOffset, double, 0.0, 1.0);
369  vtkGetMacro(LineColorFadingHueOffset, double);
370 
375  virtual void SetLineColorNodeID(const char *lineColorNodeID);
376 
378  const char* GetLineColorNodeID();
379 
381  vtkMRMLProceduralColorNode* GetLineColorNode();
382  virtual const char* GetLineColorNodeReferenceRole();
383 
387  vtkGetMacro(OccludedVisibility, bool);
388  vtkSetMacro(OccludedVisibility, bool);
389  vtkBooleanMacro(OccludedVisibility, bool);
390 
394  vtkGetMacro(OccludedOpacity, double);
395  vtkSetMacro(OccludedOpacity, double);
396 
400  vtkGetObjectMacro(TextProperty, vtkTextProperty);
401 
403  vtkSetVector3Macro(ActiveColor, double);
405  vtkGetVector3Macro(ActiveColor, double);
406 
408  vtkGetMacro(HandlesInteractive, bool);
409  vtkSetMacro(HandlesInteractive, bool);
410  vtkBooleanMacro(HandlesInteractive, bool);
411  vtkGetMacro(TranslationHandleVisibility, bool);
412  vtkSetMacro(TranslationHandleVisibility, bool);
413  vtkBooleanMacro(TranslationHandleVisibility, bool);
414  vtkGetMacro(RotationHandleVisibility, bool);
415  vtkSetMacro(RotationHandleVisibility, bool);
416  vtkBooleanMacro(RotationHandleVisibility, bool);
417  vtkGetMacro(ScaleHandleVisibility, bool);
418  vtkSetMacro(ScaleHandleVisibility, bool);
419  vtkBooleanMacro(ScaleHandleVisibility, bool);
420  void SetHandleVisibility(int handleType, bool visibility);
421  bool GetHandleVisibility(int handleType);
422 
425  virtual vtkDataSet* GetScalarDataSet() override;
427  virtual vtkDataArray* GetActiveScalarArray() override;
428 
430  virtual void UpdateAssignedAttribute() override;
431 
432 protected:
434  ~vtkMRMLMarkupsDisplayNode() override;
436  void operator= ( const vtkMRMLMarkupsDisplayNode& );
437 
438  // Set the text style from a string
439  // String format follows html-style conventions
440  void SetTextPropertyFromString(std::string textPropertyString);
441 
442  // Return a string representing the text style
443  // String format follows html-style conventions
444  std::string GetTextPropertyAsString();
445 
446  // Returns a string containing the text style of the vtkTextProperty
447  // String format follows html-style conventions
448  static std::string GetTextPropertyAsString(vtkTextProperty* property);
449 
450  // Update the style of a vtkTextProperty from a string
451  // String format follows html-style conventions
452  static void UpdateTextPropertyFromString(std::string inputString, vtkTextProperty* property);
453 
454  // Get the color from a string of the form: rgba(0,0,0,0)
455  static void GetColorFromString(const std::string& colorString, double color[4]);
456 
459  std::map<std::string, ComponentInfo> ActiveComponents;
460 
461  int SnapMode;
462 
467  double FillOpacity;
469  double TextScale;
471  double GlyphScale;
472  double GlyphSize;
474 
478  double SliceProjectionColor[3];
480 
481  virtual const char* GetLineColorNodeReferenceMRMLAttributeName();
482 
483  static const char* LineColorNodeReferenceRole;
485 
488  double LineDiameter;
489 
494 
497 
498  vtkTextProperty* TextProperty;
499 
500  double ActiveColor[3];
501 
506 };
507 #endif
std::map< std::string, ComponentInfo > ActiveComponents
void PrintSelf(ostream &os, vtkIndent indent) override
virtual vtkDataArray * GetActiveScalarArray()
static const std::string GetDefaultContextName()
Get name of the default interaction context (typically the mouse)
void ReadXMLAttributes(const char **atts) override
void UpdateScene(vtkMRMLScene *scene) override
Finds the storage node and read the data.
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
vtkMRMLCopyContentMacro(vtkMRMLDisplayNode)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
SnapModes
Define how points are placed and moved in views.
void WriteXML(ostream &of, int indent) override
void operator=(const vtkMRMLDisplayNode &)
virtual vtkDataSet * GetScalarDataSet()
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
MRML node to represent procedurally defined color information.
static int GetMinimumGlyphType()
Return the min/max glyph types, for iterating over them in tcl.
static const char * LineColorNodeReferenceRole
Abstract class that contains graphical display properties for displayable nodes.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Markups)
static const char * LineColorNodeReferenceMRMLAttributeName
virtual void UpdateAssignedAttribute()