C++ main module for gpm Package  1.0
GPMG_MovieGraphDrawPanel.h
Go to the documentation of this file.
1 #ifndef GPMG_MovieGraphDrawPanel_H
2 #define GPMG_MovieGraphDrawPanel_H
3 
4 #include "GPMG_DrawPanel.h"
5 
6 #include "GPM_ModelGraph.h"
7 #include "GPMG_Project.h"
8 #include "GPMG_MovieThread.h"
9 #include "CORE_Time.h"
10 
18  SP_OBJECT(GPMG_MovieGraphDrawPanel);
19 
20  // ATTRIBUTES
21 public:
22 
23 private:
24 
25  //all files names of graph
26  //without path
27  vector<tString> mGraphFiles;
28 
29 
30 
31  // current file index
32  int mFileIndex;
33 
34  //delay beetwen two file in ms
35  static const tFlag PLAY;
36  long int mDelay;
37 
38  // sacle
39  tReal mMinPoint[3],mMaxPoint[3];
40  map<tString,tReal*> mBoundsValue;
41  // ASSOCIATIONS
42 
43  SP::GPM_ModelGraph mCurrentGraph;
44 
45  SP::GPMG_MovieThread mMovieThread;
46  SP::CORE_Time mTime;
47 
48  tBoolean mIsDrawnEnabled;
49 
50 
51  // METHODS
52 protected:
53  // CONSTRUCTORS
57 
58 
59  // DESTRUCTORS
63  virtual ~GPMG_MovieGraphDrawPanel(void);
64 
65 
66 
67 
68 public:
69  // NEW
72  static inline SP::GPMG_MovieGraphDrawPanel New() {
73  SP::GPMG_MovieGraphDrawPanel p(new GPMG_MovieGraphDrawPanel(),
74  GPMG_MovieGraphDrawPanel::Delete());
75  p->setThis(p);
76  return p;
77  };
78 
79  virtual void toDoAfterThisSetting() {
81  mMovieThread->setPanel(getThis());
82  }
83 
84  // SET
85 protected:
88  void initAttributes();
89 
90 public:
91 
92 
93 
96  inline void setGraphFiles(const vector<tString>& files,
97  const tReal minPoint[3],
98  const tReal maxPoint[3],
99  const map<tString,tReal*>& bounds) {
100  // store the graph file names
101  int i,n=files.size();
102  mGraphFiles.resize(n);
103  for (i=0;i<n;i++) {
104  mGraphFiles[i]=files[i];
105  }
106 
107 
108 
109  // update the scales of the all the graphs
110  setScales(minPoint,maxPoint,bounds);
111 
112  // set the graph file to first index
113  mFileIndex=1;
114 
115  goToFirst();
116 
117  enableMovieMenus();
118  }
121  void clearGraphs();
122 
131  void addGraph(const GPM_ModelGraph& graph,
132  const tString& file,
133  const tReal minPoint[3],
134  const tReal maxPoint[3],
135  const map<tString,tReal*>& bounds);
136 
139  void clearScales();
142  void setScales(const tReal minPoint[3],
143  const tReal maxPoint[3],
144  const map<tString,tReal*>& bounds);
145 
146 
147 
148 
151  inline void setDelay(const int& i) {
152  mDelay=i*1000;
153  }
154  // GET
155  virtual tFlag getGraphType(const GPM_Graph* graph) const {
157 
158  }
159 
160  // OTHERS
161 public:
162 
163  // SAVER & LOADER methods
164 
167  virtual void loadFromUIClass(const UI_Class& mclass);
170  virtual void saveToUIClass(UI_Class& mclass) const;
171 
172 
173 protected:
174 
175  // DRAW methods
176 
179  virtual tBoolean paintElements();
180 
183  virtual void computeVertexBounds(double& xMin,double& yMin,double& xMax,double& yMax) const;
184 
187  virtual void computeNodesScale();
188 
191  virtual void computePortsScale();
192 
195  virtual void computeEdgesScale();
196 
197 
198 
199 public:
200  // MOVIE methods
201  //
204  inline void next() {
205  next(1);
206  }
207 
210  inline tBoolean hasNext() const {
211  return (mFileIndex<((int)mGraphFiles.size())-1);
212  }
215  inline tBoolean hasPrevious() const {
216  return (mFileIndex>0);
217  }
220  inline tBoolean isOnFirst() const {
221  return (mFileIndex==0);
222  }
225  inline tBoolean isOnLast() const {
226  return (mFileIndex==((int)mGraphFiles.size())-1);
227  }
228 
231  void next(const int& d);
232 
235  void previous() {
236  next(-1);
237  }
238 
241  inline void goToFirst() {
242 
243  if (mFileIndex==0) return;
244  mFileIndex=1;
245  next(-1);
246  }
247 
250  inline void goToLast() {
251  if (mFileIndex==((int)(mGraphFiles.size())-1)) return;
252  mFileIndex=mGraphFiles.size();
253  next(-1);
254  }
255 
256 
259  void play(const tBoolean& isLoopOn);
260 
263  void stop();
264 
265 
268  void save(const tString& prefix);
269 
272  void threadHasFinished(const tFlag& action);
275  void threadHasBeenSuspended(const int& steap,const tFlag& action);
276 
277 private:
278 
282  void loadGraph(GPM_ModelGraph& graph,CORE_Out *out);
283 
286  void showCurrentGraph();
287 
288 
291  void drawGraph();
292 
295  void drawVertices(const tBoolean& areNodesShown,
296  const tBoolean& arePortsShown,
297  const tReal& xmin,
298  const tReal& xmax,
299  const tReal& ymin,
300  const tReal& ymax);
301 
304  void drawEdges(const tReal& xmin,
305  const tReal& xmax,
306  const tReal& ymin,
307  const tReal& ymax,
308  const tReal& width);
309 
310 
311 
314  void enableMovieMenus();
315 };
316 #endif
void setDelay(const int &i)
set the delay in secunds
Definition: GPMG_MovieGraphDrawPanel.h:151
GPMG_MovieGraphDrawPanel()
build a GPMG_MovieGraphDrawPanel
Definition: GPMG_MovieGraphDrawPanel.cpp:28
virtual ~GPMG_MovieGraphDrawPanel(void)
destroy a GPMG_MovieGraphDrawPanel
Definition: GPMG_MovieGraphDrawPanel.cpp:44
void goToFirst()
go to first graph
Definition: GPMG_MovieGraphDrawPanel.h:241
void goToLast()
go to last graph
Definition: GPMG_MovieGraphDrawPanel.h:250
this class describes a Graph Draw Panel.
Definition: GPMG_DrawPanel.h:15
virtual void loadFromUIClass(const UI_Class &mclass)
how to load the object from a Meta Model class
Definition: GPMG_MovieGraphDrawPanel.cpp:566
This class describes a model graph.
Definition: GPM_ModelGraph.h:21
void addGraph(const GPM_ModelGraph &graph, const tString &file, const tReal minPoint[3], const tReal maxPoint[3], const map< tString, tReal * > &bounds)
add graph.
Definition: GPMG_MovieGraphDrawPanel.cpp:111
virtual void saveToUIClass(UI_Class &mclass) const
how to save the object from a mate model class
Definition: GPMG_MovieGraphDrawPanel.cpp:573
#define tBoolean
Definition: types.h:35
static const tFlag RESULT_GRAPH
Definition: GPMG_Project.h:37
virtual void computeEdgesScale()
compute the edge scale
Definition: GPMG_MovieGraphDrawPanel.cpp:208
void setGraphFiles(const vector< tString > &files, const tReal minPoint[3], const tReal maxPoint[3], const map< tString, tReal * > &bounds)
set the graph files
Definition: GPMG_MovieGraphDrawPanel.h:96
virtual void computePortsScale()
compute the port scale
Definition: GPMG_MovieGraphDrawPanel.cpp:193
virtual void toDoAfterThisSetting()
method called after thi ssetting
Definition: GPMG_DrawPanel.h:117
void stop()
play the graphs
Definition: GPMG_MovieGraphDrawPanel.cpp:671
void threadHasBeenSuspended(const int &steap, const tFlag &action)
method called from movie thread
Definition: GPMG_MovieGraphDrawPanel.cpp:612
tBoolean hasNext() const
return true if has next file
Definition: GPMG_MovieGraphDrawPanel.h:210
tBoolean isOnFirst() const
return true if the graph print is the first graph
Definition: GPMG_MovieGraphDrawPanel.h:220
virtual void computeNodesScale()
recompute the node scale
Definition: GPMG_MovieGraphDrawPanel.cpp:178
DEFINE_SPTR(GPMG_MovieGraphDrawPanel)
tBoolean areNodesShown() const
get if the nodes are shown
Definition: GPMG_DrawPanel.h:312
void play(const tBoolean &isLoopOn)
play the graphs
Definition: GPMG_MovieGraphDrawPanel.cpp:581
void clearScales()
clear scales
Definition: GPMG_MovieGraphDrawPanel.cpp:60
void save(const tString &prefix)
save the graphs
Definition: GPMG_MovieGraphDrawPanel.cpp:718
void setScales(const tReal minPoint[3], const tReal maxPoint[3], const map< tString, tReal * > &bounds)
set scales
Definition: GPMG_MovieGraphDrawPanel.cpp:77
virtual tBoolean paintElements()
paint the element in the drawing area
Definition: GPMG_MovieGraphDrawPanel.cpp:266
void previous()
show previous graph
Definition: GPMG_MovieGraphDrawPanel.h:235
#define tString
Definition: types.h:36
this class describes the output by default write on standart output
Definition: CORE_Out.h:21
virtual tFlag getGraphType(const GPM_Graph *graph) const
return the graph type of the graph
Definition: GPMG_MovieGraphDrawPanel.h:155
tBoolean isOnLast() const
return true if the graph print is the last graph
Definition: GPMG_MovieGraphDrawPanel.h:225
virtual void computeVertexBounds(double &xMin, double &yMin, double &xMax, double &yMax) const
recompute the vertex bounds
Definition: GPMG_MovieGraphDrawPanel.cpp:101
tBoolean hasPrevious() const
return true if has previous file
Definition: GPMG_MovieGraphDrawPanel.h:215
void initAttributes()
method called by toDOAfterThisSetting method
Definition: GPMG_MovieGraphDrawPanel.cpp:52
void clearGraphs()
clear the graph
Definition: GPMG_MovieGraphDrawPanel.cpp:171
void next()
show next graph
Definition: GPMG_MovieGraphDrawPanel.h:204
This class describes a graph which is a list of nodes & ports.
Definition: GPM_Graph.h:19
#define tReal
Definition: types.h:18
tBoolean arePortsShown() const
get if the ports are shown
Definition: GPMG_DrawPanel.h:317
static SP::GPMG_MovieGraphDrawPanel New()
create a 2D plotter panel
Definition: GPMG_MovieGraphDrawPanel.h:72
void threadHasFinished(const tFlag &action)
method called from movie thread
Definition: GPMG_MovieGraphDrawPanel.cpp:665
this class describes a Graph Draw Panel.
Definition: GPMG_MovieGraphDrawPanel.h:17
#define tFlag
Definition: types.h:14
virtual void toDoAfterThisSetting()
method called after thi ssetting
Definition: GPMG_MovieGraphDrawPanel.h:79