KWWidgets
vtkKWStateMachineDOTWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWStateMachineDOTWriter.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWStateMachineDOTWriter - a state machine DOT writer.
15 // .SECTION Description
16 // This class is a state machine writer for the DOT format, based on the
17 // reference document: http://www.graphviz.org/Documentation/dotguide.pdf
18 // The resulting file can be rendered using dot:
19 // dot -T png -o foo.png foo.txt
20 // It can also be used directly from a Wiki page if your MediaWiki supports
21 // the GraphViz extension (http://meta.wikimedia.org/wiki/GraphViz).
22 // A state machine is defined by a set of states, a set of inputs and a
23 // transition matrix that defines for each pair of (state,input) what is
24 // the next state to assume.
25 // .SECTION Thanks
26 // This work is part of the National Alliance for Medical Image
27 // Computing (NAMIC), funded by the National Institutes of Health
28 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
29 // Information on the National Centers for Biomedical Computing
30 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
31 // .SECTION See Also
32 // vtkKWStateMachineWriter vtkKWStateMachine
33 
34 #ifndef __vtkKWStateMachineDOTWriter_h
35 #define __vtkKWStateMachineDOTWriter_h
36 
38 
40 {
41 public:
42  static vtkKWStateMachineDOTWriter* New();
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
46  // Description:
47  // Write state machine representation to stream or file.
48  // Returns 1 on success and 0 on failure.
49  virtual int WriteToStream(ostream& os);
50  virtual int WriteToFile(const char *filename);
51 
52  // Description:
53  // Set/Get the font name used for state labels. Defaults to Helvetica.
54  // It is best to stick to Times, Helvetica, Courier or Symbol
55  vtkGetStringMacro(StateFontName);
56  vtkSetStringMacro(StateFontName);
57 
58  // Description:
59  // Set/Get the font size used for state labels. Defaults to 9.
60  vtkSetClampMacro(StateFontSize, int, 2, 200);
61  vtkGetMacro(StateFontSize, int);
62 
63  // Description:
64  // Set/Get the font color used for state labels. Defaults to black.
65  vtkSetVector3Macro(StateFontColor,double);
66  vtkGetVector3Macro(StateFontColor,double);
67 
68  // Description:
69  // Set/Get the font name used for input labels. Defaults to Helvetica.
70  // It is best to stick to Times, Helvetica, Courier or Symbol
71  vtkGetStringMacro(InputFontName);
72  vtkSetStringMacro(InputFontName);
73 
74  // Description:
75  // Set/Get the font size used for input labels. Defaults to 8.
76  vtkSetClampMacro(InputFontSize, int, 2, 200);
77  vtkGetMacro(InputFontSize, int);
78 
79  // Description:
80  // Set/Get the font color used for input labels. Defaults to blue.
81  vtkSetVector3Macro(InputFontColor,double);
82  vtkGetVector3Macro(InputFontColor,double);
83 
84  // Description:
85  // Set/Get graph label (at the bottom of the graph).
86  vtkGetStringMacro(GraphLabel);
87  vtkSetStringMacro(GraphLabel);
88 
89  // Description:
90  // Set/Get the font name used for graph labels. Defaults to Helvetica.
91  // Graph labels do not include state or input labels.
92  // It is best to stick to Times, Helvetica, Courier or Symbol
93  vtkGetStringMacro(GraphFontName);
94  vtkSetStringMacro(GraphFontName);
95 
96  // Description:
97  // Set/Get the font size used for graph labels. Defaults to 12.
98  // Graph labels do not include state or input labels.
99  vtkSetClampMacro(GraphFontSize, int, 2, 200);
100  vtkGetMacro(GraphFontSize, int);
101 
102  // Description:
103  // Set/Get the font color used for graph labels. Defaults to black.
104  // Graph labels do not include state or input labels.
105  vtkSetVector3Macro(GraphFontColor,double);
106  vtkGetVector3Macro(GraphFontColor,double);
107 
108  // Description:
109  // Set/Get the preferred graph direction. Defaults to top to bottom.
110  //BTX
111  enum
112  {
113  GraphDirectionTopToBottom,
114  GraphDirectionLeftToRight
115  };
116  //ETX
117  vtkSetClampMacro(GraphDirection, int, GraphDirectionTopToBottom, GraphDirectionLeftToRight);
118  vtkGetMacro(GraphDirection, int);
119  virtual void SetGraphDirectionToTopToBottom();
120  virtual void SetGraphDirectionToLeftToRight();
121 
122  // Description:
123  // Set/Get if the all states should be put at the same rank.
124  // If GraphDirection is TopToBottom, all nodes will share the same rank
125  // horizontally, except the clusters which will still be set up in a
126  // vertical fashion. If the GraphDirection is LeftToRight, all nodes
127  // will share the same rank vertically, except the clusters which will still
128  // be set up in a horizontal fashion. Experiment :)
129  vtkBooleanMacro(PutStatesAtSameRank, int);
130  vtkGetMacro(PutStatesAtSameRank, int);
131  vtkSetMacro(PutStatesAtSameRank, int);
132 
133  // Description:
134  // Set/Get if the callbacks/commands associated to the state and
135  // transitions should be shown (default) or hidden.
136  vtkBooleanMacro(CommandVisibility, int);
137  vtkGetMacro(CommandVisibility, int);
138  vtkSetMacro(CommandVisibility, int);
139 
140  // Description:
141  // Set/Get the font name used for cluster labels. Defaults to Helvetica.
142  // It is best to stick to Times, Helvetica, Courier or Symbol
143  vtkGetStringMacro(ClusterFontName);
144  vtkSetStringMacro(ClusterFontName);
145 
146  // Description:
147  // Set/Get the font size used for cluster labels. Defaults to 10.
148  vtkSetClampMacro(ClusterFontSize, int, 2, 200);
149  vtkGetMacro(ClusterFontSize, int);
150 
151  // Description:
152  // Set/Get the font color used for cluster labels. Defaults to black.
153  vtkSetVector3Macro(ClusterFontColor,double);
154  vtkGetVector3Macro(ClusterFontColor,double);
155 
156 protected:
159 
160  char *GraphLabel;
161  char *GraphFontName;
162  int GraphFontSize;
163  double GraphFontColor[3];
164  int GraphDirection;
165 
166  char *StateFontName;
167  int StateFontSize;
168  double StateFontColor[3];
169 
170  char *InputFontName;
171  int InputFontSize;
172  double InputFontColor[3];
173 
174  char *ClusterFontName;
175  int ClusterFontSize;
176  double ClusterFontColor[3];
177 
178  int PutStatesAtSameRank;
179  int CommandVisibility;
180 
181 private:
182 
183  vtkKWStateMachineDOTWriter(const vtkKWStateMachineDOTWriter&); // Not implemented
184  void operator=(const vtkKWStateMachineDOTWriter&); // Not implemented
185 };
186 
187 #endif