Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
31
32// VTK Includes
33class vtkColor4ub;
34class vtkPlot;
35class vtkTable;
36
42class VTK_MRML_EXPORT vtkMRMLPlotSeriesNode : public vtkMRMLNode
43{
44public:
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
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
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
225
226 //----------------------------------------------------------------
228 //----------------------------------------------------------------
229protected:
234
235 static const char* TableNodeReferenceRole;
237
238 virtual const char* GetTableNodeReferenceRole();
240
244 {
245 Superclass::OnNodeReferenceAdded(reference);
246 if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
247 {
248 this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
249 }
250 }
251
255 {
256 Superclass::OnNodeReferenceModified(reference);
257 if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
258 {
259 this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
260 }
261 }
262
266 {
267 Superclass::OnNodeReferenceRemoved(reference);
268 if (std::string(reference->GetReferenceRole()) == this->TableNodeReferenceRole)
269 {
270 this->InvokeCustomModifiedEvent(vtkMRMLPlotSeriesNode::TableModifiedEvent, reference->GetReferencedNode());
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
Class to hold information about a node reference.
Abstract Superclass for all specific types of MRML nodes.
MRML node to represent a vtkPlot object.
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Called when a node reference ID is modified.
static const char * TableNodeReferenceRole
static vtkMRMLPlotSeriesNode * New()
const char * GetTableNodeID()
Get referenced transform node id.
static int GetPlotTypeFromString(const char *name)
void PrintSelf(ostream &os, vtkIndent indent) override
void SetUniqueColor(const char *colorTableNodeID=nullptr)
vtkMRMLPlotSeriesNode(const vtkMRMLPlotSeriesNode &)
void ReadXMLAttributes(const char **atts) override
Set node attributes.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Called when a node reference ID is added (list size increased).
virtual vtkMRMLTableNode * GetTableNode()
Get associated Table MRML node.
const char * GetLineStyleAsString(int id)
Convert between line style ID and name.
vtkMRMLCopyContentMacro(vtkMRMLPlotSeriesNode)
void operator=(const vtkMRMLPlotSeriesNode &)
~vtkMRMLPlotSeriesNode() override
virtual const char * GetTableNodeReferenceRole()
vtkMRMLPlotSeriesNode()
Constructor and destructor.
virtual void SetAndObserveTableNodeID(const std::string &tableNodeID)
virtual void SetAndObserveTableNodeID(const char *tableNodeID)
vtkMRMLNode * CreateNodeInstance() override
Standard methods for MRML nodes.
static const char * GetMarkerStyleAsString(int id)
Convert between plot markers style ID and name.
bool IsXColumnRequired()
Returns true if X column is required (true for scatter plots)
static int GetMarkerStyleFromString(const char *name)
static const char * GetPlotTypeAsString(int id)
Convert between plot type ID and name.
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Called after a node reference ID is removed (list size decreased).
virtual const char * GetTableNodeReferenceMRMLAttributeName()
static const char * TableNodeReferenceMRMLAttributeName
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Method to propagate events generated in Plot nodes.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model).
virtual void SetPlotType(const char *type)
int GetLineStyleFromString(const char *name)
A superclass for other storage nodes.
MRML node to represent a table object.