Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLPlotDataNode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Kapteyn Astronomical Institute
4  University of Groningen, Groningen, Netherlands. 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 Davide Punzo, Kapteyn Astronomical Institute,
16  and was supported through the European Research Council grant nr. 291531.
17 
18 ==============================================================================*/
19 
20 #ifndef __vtkMRMLPlotDataNode_h
21 #define __vtkMRMLPlotDataNode_h
22 
23 #include <string>
24 #include <vector>
25 
26 // MRML Includes
27 #include "vtkMRMLNode.h"
28 
29 class vtkMRMLStorageNode;
30 class vtkMRMLTableNode;
31 
32 // VTK Includes
33 class vtkColor4ub;
34 class vtkPlot;
35 class vtkTable;
36 
44 class VTK_MRML_EXPORT vtkMRMLPlotDataNode : public vtkMRMLNode
45 {
46 public:
47  static vtkMRMLPlotDataNode *New();
49 
50  // Description:
51  // Enum of the available plot types
52  enum {
55  BAR,
56  };
57 
58  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
59 
60  //----------------------------------------------------------------
62  //----------------------------------------------------------------
63 
64  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
65 
68  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
69 
72  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
73 
76  virtual const char* GetNodeTagName() VTK_OVERRIDE { return "PlotData"; };
77 
81  virtual bool SetAndObserveTableNodeID(const char *TableNodeID);
82 
87  virtual bool SetAndObserveTableNodeID(const std::string& TableNodeID);
88 
91  virtual vtkMRMLTableNode* GetTableNode();
92 
95  virtual void ProcessMRMLEvents (vtkObject *caller,
96  unsigned long event,
97  void *callData) VTK_OVERRIDE;
98 
101  enum
102  {
103  TableModifiedEvent = 15000
104  };
105 
108  const char *GetTableNodeID();
109 
114  virtual void UpdateScene(vtkMRMLScene * scene) VTK_OVERRIDE;
115 
119  virtual void OnNodeAddedToScene() VTK_OVERRIDE;
120 
123  virtual void UpdateReferenceID(const char *oldID, const char *newID) VTK_OVERRIDE;
124 
129  virtual void SetSceneReferences() VTK_OVERRIDE;
130 
131  //----------------------------------------------------------------
133  //----------------------------------------------------------------
134 
138  virtual void SetAndObservePlot(vtkPlot* plot);
139 
143  vtkGetObjectMacro(Plot, vtkPlot);
144 
147  vtkGetMacro(Type, int);
148 
151  virtual void SetType(int type);
152 
156  virtual void SetType(const char* type);
157 
161  vtkGetMacro(XColumnName, vtkStdString);
162 
169  virtual void SetXColumnName(vtkStdString xColumnName);
170 
174  vtkGetMacro(YColumnName, vtkStdString);
175 
180  virtual void SetYColumnName(vtkStdString yColumnName);
181 
184  virtual const char *GetPlotTypeAsString(int id);
185  virtual int GetPlotTypeFromString(const char *name);
186 
190  virtual void SetMarkerStyle(int style);
191  virtual int GetMarkerStyle();
192 
195  const char *GetMarkersStyleAsString(int id);
196  int GetMarkersStyleFromString(const char *name);
197 
201  virtual void SetMarkerSize(float size);
202  virtual float GetMarkerSize();
203 
207  virtual void SetLineWidth(float width);
208  virtual float GetLineWidth();
209 
212  virtual void SetPlotColor(double color[4]);
213  virtual void SetPlotColor(unsigned char color[4]);
214  virtual void GetPlotColor(double color[4]);
215  virtual void GetPlotColor(unsigned char color[4]);
216 
217  //----------------------------------------------------------------
219  //----------------------------------------------------------------
220 protected:
222  ~vtkMRMLPlotDataNode();
223  vtkMRMLPlotDataNode(const vtkMRMLPlotDataNode&);
224  void operator=(const vtkMRMLPlotDataNode&);
225 
226  static const char* TableNodeReferenceRole;
227  static const char* TableNodeReferenceMRMLAttributeName;
228 
229  virtual const char* GetTableNodeReferenceRole();
230  virtual const char* GetTableNodeReferenceMRMLAttributeName();
231 
234  virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) VTK_OVERRIDE
235  {
236  Superclass::OnNodeReferenceAdded(reference);
237  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
238  {
239  this->InvokeCustomModifiedEvent(vtkMRMLPlotDataNode::TableModifiedEvent, reference->GetReferencedNode());
240  }
241  }
242 
245  virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference) VTK_OVERRIDE
246  {
247  Superclass::OnNodeReferenceModified(reference);
248  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
249  {
250  this->InvokeCustomModifiedEvent(vtkMRMLPlotDataNode::TableModifiedEvent, reference->GetReferencedNode());
251  }
252  }
253 
256  virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) VTK_OVERRIDE
257  {
258  Superclass::OnNodeReferenceRemoved(reference);
259  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
260  {
261  this->InvokeCustomModifiedEvent(vtkMRMLPlotDataNode::TableModifiedEvent, reference->GetReferencedNode());
262  }
263  }
264 
269  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
270 
276  virtual void SetInputData(vtkMRMLTableNode* tableNode,
277  vtkStdString xColumnName,
278  vtkStdString yColumnName);
279 
284  virtual void SetInputData(vtkMRMLTableNode* tableNode);
285 
286  //----------------------------------------------------------------
288  //----------------------------------------------------------------
289  protected:
290  vtkPlot* Plot;
291 
294  int Type;
295 
296  vtkStdString XColumnName;
297  vtkStdString YColumnName;
298 };
299 
300 #endif
virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) VTK_OVERRIDE
Called after a node reference ID is removed (list size decreased).
virtual void OnNodeAddedToScene()
Definition: vtkMRMLNode.h:178
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData)
Propagate events generated in mrml.
virtual void Copy(vtkMRMLNode *node)
Copy parameters (not including ID and Scene) from another node of the same type.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference) VTK_OVERRIDE
Called when a node reference ID is modified.
int Type
Type of Plot (Line, Scatter, Bar).
MRML node to represent a vtkPlot object.
A supercalss for other storage nodes.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void InvokeCustomModifiedEvent(int eventId, void *callData=NULL)
This method allows the node to compress events.
Definition: vtkMRMLNode.h:492
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:723
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:171