C++ main module for gpm Package  1.0
GPMG_RuleGraphDrawPanel.h
Go to the documentation of this file.
1 #ifndef GPMG_RuleGraphDrawPanel_H
2 #define GPMG_RuleGraphDrawPanel_H
3 
4 #include "GPMG_DrawPanel.h"
5 
6 #include "GPM_ModelFunction.h"
7 
8 
16  SP_OBJECT(GPMG_RuleGraphDrawPanel);
17 
18  // ATTRIBUTES
19 public:
20 
21 private:
22 
23 
24 
25 
26  // color for rule graph function
27  SP::CORE_Color mPatternGraphColor;
28  SP::CORE_Color mTransformGraphColor;
29  SP::CORE_Color mDeletedGraphElementColor;
30  SP::CORE_Color mKeptGraphElementColor;
31  SP::CORE_Color mPTEdgeColor;
32 
33  // ASSOCIATIONS
34 
35  // rule to visualize
36  SP::GPM_ModelFunction mRule;
37 
38 
39 
40 
41 
42  // METHODS
43 protected:
44  // CONSTRUCTORS
48 
49 
50  // DESTRUCTORS
54  virtual ~GPMG_RuleGraphDrawPanel(void);
55 
56 
57 
58 
59 public:
60  // NEW
63  static inline SP::GPMG_RuleGraphDrawPanel New() {
64  SP::GPMG_RuleGraphDrawPanel p(new GPMG_RuleGraphDrawPanel(),
65  GPMG_RuleGraphDrawPanel::Delete());
66  p->setThis(p);
67  return p;
68  };
69 
70 
71 
72  // SET
73 protected:
76  virtual void initAttributes();
77 
78 
79 
80 public:
83  void showRule(GPM_ModelFunction& function);
84 
87  void clearGraphs();
88 
91  virtual tFlag getGraphType(const GPM_Graph* graph) const;
92 
93  // SPECIALIZED Popup Menu Methods
94 
97  virtual void createPopupMenus();
100  virtual void popupMenuClicked(const tString& name,
101  const int& x,const int& y);
102 
105  virtual GUI_AlonePopupMenu* getPopupMenu(const int& x,const int& y,GUI2D_Item* item);
106 
107 protected:
110  virtual void objectIsClickedOn(SP::CORE_Object item);
111 
112 public:
113  // SAVER & LOADER methods
114 
117  virtual void loadFromUIClass(const UI_Class& mclass);
120  virtual void saveToUIClass(UI_Class& mclass) const;
121 
122 
123 protected:
124 
125  // DRAW methods
126 
129  virtual tBoolean paintElements();
130 
133  virtual void computeVertexBounds(double& xMin,double& yMin,double& xMax,double& yMax) const;
134 
137  virtual void computeNodesScale() {
138  double minValue=REAL_INFINITY;
139  double maxValue=-REAL_INFINITY;
140  GPMG_DrawPanel::computeNodesScale(mRule->getPatternGraph(),minValue,maxValue);
141  GPMG_DrawPanel::computeNodesScale(mRule->getTransformerGraph(),minValue,maxValue);
142  }
145  virtual void computePortsScale() {
146  double minValue=REAL_INFINITY;
147  double maxValue=-REAL_INFINITY;
148  GPMG_DrawPanel::computePortsScale(mRule->getPatternGraph(),minValue,maxValue);
149  GPMG_DrawPanel::computePortsScale(mRule->getTransformerGraph(),minValue,maxValue);
150  }
153  virtual void computeEdgesScale() {
154  double minValue=REAL_INFINITY;
155  double maxValue=-REAL_INFINITY;
156  GPMG_DrawPanel::computeEdgesScale(mRule->getPatternGraph(),minValue,maxValue);
157  GPMG_DrawPanel::computeEdgesScale(mRule->getTransformerGraph(),minValue,maxValue);
158  }
159 
160 
161 private:
162 
165  void drawGraphs();
168  void drawVertices(const tReal& xmin,
169  const tReal& xmax,
170  const tReal& ymin,
171  const tReal& ymax);
174  void drawEdges(const tReal& xmin,
175  const tReal& xmax,
176  const tReal& ymin,
177  const tReal& ymax);
178 
179 protected:
182  virtual SP::GPM_Edge addEdge(SP::GPM_Vertex source,SP::GPM_Vertex target);
183 
186  virtual void deleteEdge(GPM_Edge& edge);
189  virtual void deleteVertex(GPM_Vertex& vertex);
190 
191 
192 };
193 #endif
virtual void objectIsClickedOn(SP::CORE_Object item)
method called when the object is double clicked on
Definition: GPMG_RuleGraphDrawPanel.cpp:852
virtual void loadFromUIClass(const UI_Class &mclass)
how to load the object from a Meta Model class
Definition: GPMG_RuleGraphDrawPanel.cpp:1100
virtual ~GPMG_RuleGraphDrawPanel(void)
destroy a GPMG_RuleGraphDrawPanel
Definition: GPMG_RuleGraphDrawPanel.cpp:28
virtual void computeVertexBounds(double &xMin, double &yMin, double &xMax, double &yMax) const
recompute the vertex bounds
Definition: GPMG_RuleGraphDrawPanel.cpp:48
virtual void saveToUIClass(UI_Class &mclass) const
how to save the object from a mate model class
Definition: GPMG_RuleGraphDrawPanel.cpp:1119
void showRule(GPM_ModelFunction &function)
show the rule
Definition: GPMG_RuleGraphDrawPanel.cpp:127
virtual tFlag getGraphType(const GPM_Graph *graph) const
return the graph type of the graph
Definition: GPMG_RuleGraphDrawPanel.cpp:220
this class describes a Graph Draw Panel.
Definition: GPMG_DrawPanel.h:15
virtual void initAttributes()
init attributes of the draw panel
Definition: GPMG_RuleGraphDrawPanel.cpp:33
this class describes a Rule Graphs Draw Panel.
Definition: GPMG_RuleGraphDrawPanel.h:15
virtual SP::GPM_Edge addEdge(SP::GPM_Vertex source, SP::GPM_Vertex target)
add edge between vertices source & target
Definition: GPMG_RuleGraphDrawPanel.cpp:1035
#define tBoolean
Definition: types.h:35
virtual void computePortsScale()=0
compute the port scale
virtual void computePortsScale()
compute the port scale
Definition: GPMG_RuleGraphDrawPanel.h:145
This class describes a node.
Definition: GPM_Vertex.h:16
virtual tBoolean paintElements()
paint the element in the drawing area
Definition: GPMG_RuleGraphDrawPanel.cpp:238
void clearGraphs()
clear the graphs of the rules
Definition: GPMG_RuleGraphDrawPanel.cpp:227
#define REAL_INFINITY
Definition: types.h:57
This class describes a edge.
Definition: GPM_Edge.h:15
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_RuleGraphDrawPanel.cpp:876
virtual void computeEdgesScale()
compute the edge scale
Definition: GPMG_RuleGraphDrawPanel.h:153
virtual void computeNodesScale()
compute the node scale
Definition: GPMG_RuleGraphDrawPanel.h:137
virtual void deleteEdge(GPM_Edge &edge)
delete an edge
Definition: GPMG_RuleGraphDrawPanel.cpp:1025
#define tString
Definition: types.h:36
virtual void computeNodesScale()=0
compute the node scale
virtual void computeEdgesScale()=0
compute the edges scale
GPMG_RuleGraphDrawPanel()
build a GPMG_RuleGraphDrawPanel
Definition: GPMG_RuleGraphDrawPanel.cpp:20
virtual void deleteVertex(GPM_Vertex &vertex)
delete a vertex
Definition: GPMG_RuleGraphDrawPanel.cpp:1012
This class describes a pattern function.
Definition: GPM_ModelFunction.h:23
virtual void createPopupMenus()
create popup menus
Definition: GPMG_RuleGraphDrawPanel.cpp:635
virtual GUI_AlonePopupMenu * getPopupMenu(const int &x, const int &y, GUI2D_Item *item)
get the popup menu
Definition: GPMG_RuleGraphDrawPanel.cpp:723
DEFINE_SPTR(GPMG_RuleGraphDrawPanel)
This class describes a graph which is a list of nodes & ports.
Definition: GPM_Graph.h:19
#define tReal
Definition: types.h:18
#define tFlag
Definition: types.h:14
static SP::GPMG_RuleGraphDrawPanel New()
create a 2D plotter panel
Definition: GPMG_RuleGraphDrawPanel.h:63