C++ main module for gpm Package  1.0
GPMG_DrawPanel.h
Go to the documentation of this file.
1 #ifndef GPMG_DrawPanel_H
2 #define GPMG_DrawPanel_H
3 
4 #include "GUI2D_DrawPanel.h"
5 
6 #include "GPM_ModelGraph.h"
7 
8 
15 class GPMG_DrawPanel : public GUI2D_DrawPanel {
16  SP_OBJECT(GPMG_DrawPanel);
17 
18  // ATTRIBUTES
19 public:
20 
21 protected:
22 
23  static const tFlag X;
24  static const tFlag Y;
25  static const tFlag Z;
26  static const tFlag NODE_COLOR_SCALE;
27  static const tFlag PORT_COLOR_SCALE;
28  static const tFlag EDGE_COLOR_SCALE;
29 private:
30  // projection plane
31  tFlag mX;
32  tFlag mY;
33 
34 
35 
36 
37  // graph elements to show
38  tBoolean mAreNodesShown;
39  tBoolean mArePortsShown;
40  tBoolean mAreEdgesShown;
41 
42  //attributes fo drawing vertices
43  int mTau;
44  int mAlpha;
45  tBoolean mAreVerticesClickabled;
46 
47  // attributes for drawing edges
48  int mEdgeWidth;
49  tBoolean mAreEdgesClickabled;
50 
51  //name of the variable of the node to show on graph
52  tString mNodeStateNameToShow;
53  //name of the variable of the port to show on graph
54  tString mPortStateNameToShow;
55  //name of the variable of the edge to show on graph
56  tString mEdgeStateNameToShow;
57 
58 
59  //attributes for drawing edge creation
60  tBoolean mIsEdgeDrawing;
61  SP::CORE_Color mEdgeDrawingColor;
62  int mX0,mY0,mX1,mY1;
63 
64  // selected color
65  SP::CORE_Color mSelectedObjectColor;
66 
67  // menu index of the vertex zone
68  int mToNodeEdgeMenuIndex,mToPortEdgeMenuIndex,mEdgeMenuIndex;
69 
70  // adding edge type
71  static const tFlag EDGE;
72  static const tFlag EDGE_TO_NODE;
73  static const tFlag EDGE_TO_PORT;
74  tFlag mAddingEdgeType;
75 
76 
77  SP::CORE_Color mBlackColor;
78 
79 
80  // ASSOCIATIONS
81 
82  // popup obejct clicked on
83  SP::CORE_Object mPopupObject;
84 
85  // source vertex for drawing edge creation
86  SP::GPM_Vertex mSourceVertex;
87 
88 
89  //selected objects
90  SP::GPM_Vertex mSelectedVertex;
91  SP::GPM_Edge mSelectedEdge;
92 
93 
94 
95 
96  // METHODS
97 protected:
98  // CONSTRUCTORS
101  GPMG_DrawPanel();
102 
103 
104  // DESTRUCTORS
108  virtual ~GPMG_DrawPanel(void);
109 
110 
111 
112 
113 public:
114 
117  virtual void toDoAfterThisSetting() {
118  GUI2D_DrawPanel::toDoAfterThisSetting();
119  initAttributes();
120  fitToGraphics();
121  eraseAllExceptLastDrawingBoxes();
123  }
124 
125 
126  // SET
127 protected:
128 
131  virtual void initAttributes();
132 
133 
134 public:
135 
138  void setIsReadOnly(const tBoolean& isReadOnly);
141  inline void setAreNodesShown(const tBoolean& v) {
142  mAreNodesShown=v;
143  }
146  inline void setArePortsShown(const tBoolean& v) {
147  mArePortsShown=v;
148  }
151  inline void setAreEdgesShown(const tBoolean& v) {
152  mAreEdgesShown=v;
153  }
156  virtual void setIsMovingEnabled(const tBoolean& v);
157 
160  inline void setSelectedVertex(SP::GPM_Vertex obj) {
161  mSelectedVertex=obj;
162  }
165  inline void setSelectedEdge(SP::GPM_Edge obj) {
166  mSelectedEdge=obj;
167  }
170  inline void resetSelectedVertex() {
171  mSelectedVertex.reset();
174  updateValues();
175  }
178  inline void resetSelectedEdge() {
179  mSelectedEdge.reset();
181  updateValues();
182  }
183 
186  inline void setVertexSize(const int& v) {
187  mTau=v;
188  updateValues();
189  }
190 
193  inline void setEdgeWidth(const int& v) {
194  mEdgeWidth=v;
195  updateValues();
196  }
197 
198  // vertex & edges states methods
199  // =============================
202  inline void setNodeVariableNameToShow(const tString& name) {
203  mNodeStateNameToShow=name;
205  updateValues();
206  }
209  inline void setPortVariableNameToShow(const tString& name) {
210  mPortStateNameToShow=name;
212  updateValues();
213  }
216  inline void setEdgeVariableNameToShow(const tString& name) {
217  mEdgeStateNameToShow=name;
219  updateValues();
220  }
221 
224  inline void setAreObjectsClickabled(const tBoolean& v) {
225  mAreVerticesClickabled=v;
226  mAreEdgesClickabled=v;
227  }
228 
229 
230  // GET
231 
235  return mNodeStateNameToShow;
236  }
240  return mPortStateNameToShow;
241  }
245  return mEdgeStateNameToShow;
246  }
247 
250  virtual tFlag getGraphType(const GPM_Graph* graph) const=0;
253  inline SP::CORE_Object getPopupObject() {
254  return mPopupObject;
255  }
256 
259  inline int getToNodeEdgeMenuIndex() const {
260  return mToNodeEdgeMenuIndex;
261  }
264  inline int getToPortEdgeMenuIndex() const {
265  return mToPortEdgeMenuIndex;
266  }
269  inline int getEdgeMenuIndex() const {
270  return mEdgeMenuIndex;
271  }
272 
275  inline int getTau() const {
276  return mTau;
277  }
280  inline int getEdgeWidth() const {
281  return mEdgeWidth;
282  }
285  inline void getProjection(tFlag& projX,tFlag& projY) const {
286  projX=mX;
287  projY=mY;
288  }
289 
293  return *mSelectedObjectColor.get();
294  }
297  inline GPM_Vertex* getSelectedVertex() const {
298  return mSelectedVertex.get();
299  }
302  inline GPM_Edge* getSelectedEdge() const {
303  return mSelectedEdge.get();
304  }
308  return !isPopupMenuPrinted();
309  }
312  inline tBoolean areNodesShown() const {
313  return mAreNodesShown;
314  }
317  inline tBoolean arePortsShown() const {
318  return mArePortsShown;
319  }
322  inline tBoolean areEdgesShown() const {
323  return mAreEdgesShown;
324  }
325 
326 
327  // OTHERS
328 public:
329 
330 
331  // SPECIALIZED Popup Menus Methods
332 
335  virtual void createPopupMenus();
336 
339  virtual void popupMenuClicked(const tString& name,
340  const int& x,const int& y);
341 
344  virtual GUI_AlonePopupMenu* getPopupMenu(const int& x,const int& y,GUI2D_Item* item);
345 
346  // SAVER & LOADER methods
347 
350  virtual void loadFromUIClass(const UI_Class& mclass);
353  virtual void saveToUIClass(UI_Class& mclass) const;
354 
355 
356 protected:
357 
358  // DRAW methods
359 
362  virtual tBoolean paintElements();
363 
364 
370  virtual void computeBoundingBox(GUI2D_Box& box) const;
371 
372 
375  virtual void mouseHasChanged(SP::GUI_Mouse mouse);
376 
379  virtual void computeVertexBounds(double& xMin,double& yMin,double& xMax,double& yMax) const=0;
380 
381 protected:
382  // scale methods
383  // =============
384 
387  void computeNodesScale(GPM_PortGraph& graph,double& minValue,double& maxValue);
390  virtual void computeNodesScale()=0;
393  void computePortsScale(GPM_PortGraph& graph,double& minValue,double& maxValue);
396  virtual void computePortsScale()=0;
399  void computeEdgesScale(GPM_PortGraph& graph,double& minValue,double& maxValue);
402  virtual void computeEdgesScale()=0;
403 
404 
405 protected:
408  virtual void objectIsClickedOn(SP::CORE_Object item);
411  virtual void objectIsMovedTo(SP::CORE_Object item,const tReal& x,const tReal& y);
412 
413 
414 protected:
417  void getCoordinates(const GPM_PortGraph& graph,GPM_Vertex& vertex,tReal& x,tReal& y);
418 
419 
422  void drawVertex(GPM_Node& node,const CORE_Color& color,const tString& label,
423  const tReal& Cx,const tReal& Cy,const tReal& w,const tReal& h);
426  void drawVertex(GPM_Port& port,const CORE_Color& color,const tString& label,
427  const tReal& Cx,const tReal& Cy,const tReal& w,const tReal& h);
430  void drawEdge(GPM_Edge* edge,const CORE_Color& color,const tString& label,
431  const tReal& Sx,const tReal& Sy,const tReal& Tx,const tReal& Ty,const tReal& width);
434  virtual SP::GPM_Edge addEdge(SP::GPM_Vertex source,SP::GPM_Vertex target);
437  virtual void deleteEdge(GPM_Edge& edge);
438 
443  SP::GPM_Vertex addPort(const tReal& x,const tReal& y,GPM_PortGraph& graph);
448  SP::GPM_Vertex addNode(const tReal& x,const tReal& y,GPM_PortGraph& graph);
451  virtual void deleteVertex(GPM_Vertex& vertex);
452 
455  void addEdgeToPort(SP::GPM_Vertex source,SP::GPM_Port target);
458  void addEdgeToNode(SP::GPM_Vertex source,SP::GPM_Node target);
459 
460 };
461 #endif
virtual void objectIsClickedOn(SP::CORE_Object item)
method called when the object is double clicked on
Definition: GPMG_DrawPanel.cpp:468
int getTau() const
get Tau
Definition: GPMG_DrawPanel.h:275
DEFINE_SPTR(GPMG_DrawPanel)
int getToPortEdgeMenuIndex() const
get the index of the menu item
Definition: GPMG_DrawPanel.h:264
SP::CORE_Object getPopupObject()
get the popup object
Definition: GPMG_DrawPanel.h:253
virtual void computeVertexBounds(double &xMin, double &yMin, double &xMax, double &yMax) const =0
recompute the vertex bounds
GPMG_DrawPanel()
build a GPMG_DrawPanel
Definition: GPMG_DrawPanel.cpp:33
SP::GPM_Vertex addNode(const tReal &x, const tReal &y, GPM_PortGraph &graph)
add port in graph
Definition: GPMG_DrawPanel.cpp:774
void setEdgeVariableNameToShow(const tString &name)
set edge variable name to show
Definition: GPMG_DrawPanel.h:216
virtual void createPopupMenus()
create popup menus
Definition: GPMG_DrawPanel.cpp:559
void addEdgeToPort(SP::GPM_Vertex source, SP::GPM_Port target)
draw an edge between source & target vertices from graph
Definition: GPMG_DrawPanel.cpp:915
this class describes a Graph Draw Panel.
Definition: GPMG_DrawPanel.h:15
int getEdgeMenuIndex() const
get the index of the menu item
Definition: GPMG_DrawPanel.h:269
virtual void saveToUIClass(UI_Class &mclass) const
how to save the object from a mate model class
Definition: GPMG_DrawPanel.cpp:944
SP::GPM_Vertex addPort(const tReal &x, const tReal &y, GPM_PortGraph &graph)
add port in graph
Definition: GPMG_DrawPanel.cpp:753
static const tFlag Z
Definition: GPMG_DrawPanel.h:25
tString getNodeStateNameToShow() const
get the node state to show
Definition: GPMG_DrawPanel.h:234
void setEdgeWidth(const int &v)
set the vertex width
Definition: GPMG_DrawPanel.h:193
void setSelectedVertex(SP::GPM_Vertex obj)
set the selected vertex
Definition: GPMG_DrawPanel.h:160
virtual void mouseHasChanged(SP::GUI_Mouse mouse)
method called when the mouse changed
Definition: GPMG_DrawPanel.cpp:496
static const tFlag X
Definition: GPMG_DrawPanel.h:23
#define tBoolean
Definition: types.h:35
virtual SP::GPM_Edge addEdge(SP::GPM_Vertex source, SP::GPM_Vertex target)
add an edge between source & target vertices into graph
Definition: GPMG_DrawPanel.cpp:796
virtual void computePortsScale()=0
compute the port scale
static const tFlag PORT_COLOR_SCALE
Definition: GPMG_DrawPanel.h:27
void drawVertex(GPM_Node &node, const CORE_Color &color, const tString &label, const tReal &Cx, const tReal &Cy, const tReal &w, const tReal &h)
draw a node with color & label at (Cx,Cy) with size (w,h)
Definition: GPMG_DrawPanel.cpp:384
virtual tBoolean paintElements()
paint the element in the drawing area
Definition: GPMG_DrawPanel.cpp:368
tString getEdgeStateNameToShow() const
get the port state to show
Definition: GPMG_DrawPanel.h:244
virtual ~GPMG_DrawPanel(void)
destroy a GPMG_DrawPanel
Definition: GPMG_DrawPanel.cpp:45
void getCoordinates(const GPM_PortGraph &graph, GPM_Vertex &vertex, tReal &x, tReal &y)
get the coordinates of the vertex from graph in (x,y)
Definition: GPMG_DrawPanel.cpp:290
This class describes a node.
Definition: GPM_Vertex.h:16
This class describes a port.
Definition: GPM_Port.h:16
void getProjection(tFlag &projX, tFlag &projY) const
get project
Definition: GPMG_DrawPanel.h:285
virtual void objectIsMovedTo(SP::CORE_Object item, const tReal &x, const tReal &y)
method called when the object is moved to
Definition: GPMG_DrawPanel.cpp:484
void setPortVariableNameToShow(const tString &name)
set port variable name to show
Definition: GPMG_DrawPanel.h:209
void setAreObjectsClickabled(const tBoolean &v)
set if the object are clickabled
Definition: GPMG_DrawPanel.h:224
void setIsReadOnly(const tBoolean &isReadOnly)
set is read only
Definition: GPMG_DrawPanel.cpp:131
virtual void toDoAfterThisSetting()
method called after thi ssetting
Definition: GPMG_DrawPanel.h:117
void drawEdge(GPM_Edge *edge, const CORE_Color &color, const tString &label, const tReal &Sx, const tReal &Sy, const tReal &Tx, const tReal &Ty, const tReal &width)
draw an edge with color & label from (Sx,Sy)->(Tx,Ty)
Definition: GPMG_DrawPanel.cpp:438
void setArePortsShown(const tBoolean &v)
set if the ports are shown
Definition: GPMG_DrawPanel.h:146
void setNodeVariableNameToShow(const tString &name)
set node variable name to show
Definition: GPMG_DrawPanel.h:202
void resetSelectedEdge()
reset the selected edge object
Definition: GPMG_DrawPanel.h:178
This class describes a edge.
Definition: GPM_Edge.h:15
CORE_Color & getSelectedObjectColor() const
get the selected object color
Definition: GPMG_DrawPanel.h:292
void setSelectedEdge(SP::GPM_Edge obj)
set the selected edge
Definition: GPMG_DrawPanel.h:165
void addEdgeToNode(SP::GPM_Vertex source, SP::GPM_Node target)
draw an edge between source & target vertices from graph
Definition: GPMG_DrawPanel.cpp:853
virtual GUI_AlonePopupMenu * getPopupMenu(const int &x, const int &y, GUI2D_Item *item)
get the popup menu
Definition: GPMG_DrawPanel.cpp:622
static const tFlag NODE_COLOR_SCALE
Definition: GPMG_DrawPanel.h:26
void resetSelectedVertex()
reset the selected vertex object
Definition: GPMG_DrawPanel.h:170
tBoolean areNodesShown() const
get if the nodes are shown
Definition: GPMG_DrawPanel.h:312
virtual tFlag getGraphType(const GPM_Graph *graph) const =0
return the graph type of the graph
GPM_Vertex * getSelectedVertex() const
get the selected vertex object
Definition: GPMG_DrawPanel.h:297
virtual void computeBoundingBox(GUI2D_Box &box) const
compute the bounding box of the object to see
Definition: GPMG_DrawPanel.cpp:155
int getEdgeWidth() const
get edge width
Definition: GPMG_DrawPanel.h:280
#define tString
Definition: types.h:36
virtual void computeNodesScale()=0
compute the node scale
tBoolean areEdgesShown() const
get if the edges are shown
Definition: GPMG_DrawPanel.h:322
This class describes a graph which is a list of vertices, ports & edges.
Definition: GPM_PortGraph.h:22
virtual void computeEdgesScale()=0
compute the edges scale
tString getPortStateNameToShow() const
get the port state to show
Definition: GPMG_DrawPanel.h:239
virtual void loadFromUIClass(const UI_Class &mclass)
how to load the object from a Meta Model class
Definition: GPMG_DrawPanel.cpp:925
this class describes color
Definition: CORE_Color.h:28
virtual void deleteVertex(GPM_Vertex &vertex)
delete a vertex
Definition: GPMG_DrawPanel.cpp:828
void setAreNodesShown(const tBoolean &v)
set if the nodes are shown
Definition: GPMG_DrawPanel.h:141
virtual void initAttributes()
init attributes of the draw panel
Definition: GPMG_DrawPanel.cpp:50
virtual void popupMenuClicked(const tString &name, const int &x, const int &y)
method called when ab item of a popup menu is clicked on component
Definition: GPMG_DrawPanel.cpp:683
void setVertexSize(const int &v)
set the vertex size
Definition: GPMG_DrawPanel.h:186
tBoolean isReadOnly() const
return true if the read only mode is on
Definition: GPMG_DrawPanel.h:307
static const tFlag EDGE_COLOR_SCALE
Definition: GPMG_DrawPanel.h:28
static const tFlag Y
Definition: GPMG_DrawPanel.h:24
This class describes a graph which is a list of nodes & ports.
Definition: GPM_Graph.h:19
virtual void setIsMovingEnabled(const tBoolean &v)
set zoom selection enabled
Definition: GPMG_DrawPanel.cpp:114
#define tReal
Definition: types.h:18
virtual void deleteEdge(GPM_Edge &edge)
delete an edge
Definition: GPMG_DrawPanel.cpp:840
tBoolean arePortsShown() const
get if the ports are shown
Definition: GPMG_DrawPanel.h:317
GPM_Edge * getSelectedEdge() const
get the selected edge object
Definition: GPMG_DrawPanel.h:302
int getToNodeEdgeMenuIndex() const
get the index of the menu item
Definition: GPMG_DrawPanel.h:259
void setAreEdgesShown(const tBoolean &v)
set if the edges are shown
Definition: GPMG_DrawPanel.h:151
This class describes a node.
Definition: GPM_Node.h:14
#define tFlag
Definition: types.h:14