Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLPlotSeriesNode.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 __vtkMRMLPlotSeriesNode_h
21 #define __vtkMRMLPlotSeriesNode_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 
42 class VTK_MRML_EXPORT vtkMRMLPlotSeriesNode : public vtkMRMLNode
43 {
44 public:
45  static vtkMRMLPlotSeriesNode *New();
47 
49  enum
50  {
55  PlotType_Last // must be last
56  };
57 
59  enum
60  {
67  MarkerStyle_Last // must be last
68  };
69 
71  enum
72  {
79  LineStyle_Last // must be last
80  };
81 
82  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
83 
84  //----------------------------------------------------------------
86  //----------------------------------------------------------------
87 
88  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
89 
92  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
93 
96  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
97 
100  virtual const char* GetNodeTagName() VTK_OVERRIDE { return "PlotSeries"; };
101 
105  virtual void SetAndObserveTableNodeID(const char *tableNodeID);
106 
111  virtual void SetAndObserveTableNodeID(const std::string& tableNodeID);
112 
115  virtual vtkMRMLTableNode* GetTableNode();
116 
119  virtual void ProcessMRMLEvents (vtkObject *caller,
120  unsigned long event,
121  void *callData) VTK_OVERRIDE;
122 
125  enum
126  {
127  TableModifiedEvent = 15000
128  };
129 
132  const char *GetTableNodeID();
133 
134  //----------------------------------------------------------------
136  //----------------------------------------------------------------
137 
143  vtkSetMacro(PlotType, int);
144  vtkGetMacro(PlotType, int);
145 
149  virtual void SetPlotType(const char* type);
150 
152  vtkGetMacro(XColumnName, std::string);
153  vtkSetMacro(XColumnName, std::string);
154 
157  vtkGetMacro(YColumnName, std::string);
158  vtkSetMacro(YColumnName, std::string);
159 
162  vtkGetMacro(LabelColumnName, std::string);
163  vtkSetMacro(LabelColumnName, std::string);
164 
167  static const char *GetPlotTypeAsString(int id);
168  static int GetPlotTypeFromString(const char *name);
169 
175  vtkSetMacro(MarkerStyle, int);
176  vtkGetMacro(MarkerStyle, int);
177 
180  static const char *GetMarkerStyleAsString(int id);
181  static int GetMarkerStyleFromString(const char *name);
182 
186  vtkGetMacro(MarkerSize, float);
187  vtkSetMacro(MarkerSize, float);
188 
193  vtkSetMacro(LineStyle, int);
194  vtkGetMacro(LineStyle, int);
195 
198  const char *GetLineStyleAsString(int id);
199  int GetLineStyleFromString(const char *name);
200 
204  vtkGetMacro(LineWidth, float);
205  vtkSetMacro(LineWidth, float);
206 
209  vtkGetVector3Macro(Color, double);
210  vtkSetVector3Macro(Color, double);
211 
215  void SetUniqueColor(const char* colorTableNodeID = NULL);
216 
219  vtkGetMacro(Opacity, double);
220  vtkSetMacro(Opacity, double);
221 
224  bool IsXColumnRequired();
225 
226  //----------------------------------------------------------------
228  //----------------------------------------------------------------
229 protected:
233  void operator=(const vtkMRMLPlotSeriesNode&);
234 
235  static const char* TableNodeReferenceRole;
237 
238  virtual const char* GetTableNodeReferenceRole();
239  virtual const char* GetTableNodeReferenceMRMLAttributeName();
240 
243  virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) VTK_OVERRIDE
244  {
245  Superclass::OnNodeReferenceAdded(reference);
246  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
247  {
248  this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
249  }
250  }
251 
254  virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference) VTK_OVERRIDE
255  {
256  Superclass::OnNodeReferenceModified(reference);
257  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
258  {
259  this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
260  }
261  }
262 
265  virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) VTK_OVERRIDE
266  {
267  Superclass::OnNodeReferenceRemoved(reference);
268  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
269  {
270  this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
271  }
272  }
273 
278  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
279 
280  //----------------------------------------------------------------
282  //----------------------------------------------------------------
283  protected:
284 
287  int PlotType;
288 
289  std::string XColumnName;
290  std::string YColumnName;
291  std::string LabelColumnName;
292 
293  float LineWidth;
295 
296  float MarkerSize;
298 
299  double Color[3];
300  double Opacity;
301 };
302 
303 #endif
virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) VTK_OVERRIDE
Called after a node reference ID is removed (list size decreased).
virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference) VTK_OVERRIDE
Called when a node reference ID is modified.
MRML node to represent a vtkPlot object.
virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) VTK_OVERRIDE
Called when a node reference ID is added (list size increased).
static const char * TableNodeReferenceMRMLAttributeName
void operator=(const vtkMRMLNode &)
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 superclass 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:496
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:741
static const char * TableNodeReferenceRole