Slicer  5.0
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) override;
83 
84  //----------------------------------------------------------------
86  //----------------------------------------------------------------
87 
88  vtkMRMLNode* CreateNodeInstance() override;
89 
92  void ReadXMLAttributes( const char** atts) override;
93 
96  void WriteXML(ostream& of, int indent) override;
97 
100  const char* GetNodeTagName() 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  void ProcessMRMLEvents (vtkObject *caller,
120  unsigned long event,
121  void *callData) 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 = nullptr);
216 
219  vtkGetMacro(Opacity, double);
220  vtkSetMacro(Opacity, double);
221 
224  bool IsXColumnRequired();
225 
226  //----------------------------------------------------------------
228  //----------------------------------------------------------------
229 protected:
231  ~vtkMRMLPlotSeriesNode() override;
233  void operator=(const vtkMRMLPlotSeriesNode&);
234 
235  static const char* TableNodeReferenceRole;
237 
238  virtual const char* GetTableNodeReferenceRole();
239  virtual const char* GetTableNodeReferenceMRMLAttributeName();
240 
243  void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
244  {
245  Superclass::OnNodeReferenceAdded(reference);
246  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
247  {
249  }
250  }
251 
255  {
256  Superclass::OnNodeReferenceModified(reference);
257  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
258  {
260  }
261  }
262 
266  {
267  Superclass::OnNodeReferenceRemoved(reference);
268  if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
269  {
271  }
272  }
273 
277 
278  //----------------------------------------------------------------
280  //----------------------------------------------------------------
281  protected:
282 
285  int PlotType{PlotTypeLine};
286 
287  std::string XColumnName;
288  std::string YColumnName;
289  std::string LabelColumnName;
290 
291  float LineWidth{2};
292  int LineStyle{LineStyleSolid};
293 
294  float MarkerSize{7};
295  int MarkerStyle{MarkerStyleCircle};
296 
297  double Color[3];
298  double Opacity{1.0};
299 };
300 
301 #endif
virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
This method allows the node to compress events.
Definition: vtkMRMLNode.h:577
MRML node to represent a vtkPlot object.
vtkMRMLNode * GetReferencedNode() const
virtual void ReadXMLAttributes(const char **atts)
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.
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Called after a node reference ID is removed (list size decreased).
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model).
A superclass for other storage nodes.
virtual void WriteXML(ostream &of, int indent)
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Called when a node reference ID is added (list size increased).
void PrintSelf(ostream &os, vtkIndent indent) override
#define vtkMRMLCopyContentMacro(thisClassName)
Definition: vtkMRMLNode.h:142
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:801
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Called when a node reference ID is modified.
static const char * TableNodeReferenceRole