ImGraph
 All Classes Functions Variables Enumerations Pages
Connectors.h
1 #ifndef _CONNECTORS_HEADER_
2 #define _CONNECTORS_HEADER_
3 
4 #ifdef _WIN32
5 #pragma warning(disable:4503)
6 #pragma warning(push)
7 #pragma warning(disable:4996 4251 4275 4800 4503)
8 #endif
9 #include <QGraphicsLineItem>
10 #include <QLabel>
11 #include <QPainter>
12 #ifdef _WIN32
13 #pragma warning(pop)
14 #endif
15 
16 #include "Block.h"
17 
18 namespace charliesoft
19 {
20  class VertexRepresentation;
21  class LinkConnexionRepresentation;
22  class SubBlock;
23 
24  class LinkPath : public QGraphicsLineItem
25  {
26  bool _selected;
27  QPolygonF _arrowHead;
30  public:
33  QGraphicsItem *parent=0, QGraphicsScene *scene=0);
34 
35  bool intersect(const QRect& pos) const;
36  QPainterPath shape() const;
37 
38  void draw(QPainter *painter, const QStyleOptionGraphicsItem *,
39  QWidget *);
40 
41  bool isSelected() const { return _selected; }
42  void setSelected(bool val) { _selected = val; }
43  };
44 
45  class LinkConnexionRepresentation :public QLabel
46  {
47  Q_OBJECT;
48  protected:
49  bool _isInput;
50  bool _shouldShow;
51  VertexRepresentation* _activeVertex;
52  VertexRepresentation* _vertex;
53  std::string _name;
54  QWidget *_father;
55  public:
56  LinkConnexionRepresentation(std::string text, bool isInput, QWidget *father);
57 
58  virtual void mousePressEvent(QMouseEvent *);
59  virtual void mouseReleaseEvent(QMouseEvent *);
60  virtual void mouseMoveEvent(QMouseEvent *);
61  virtual void enterEvent(QEvent *);
62 
63  std::string getName() const { return _name; }
64  VertexRepresentation* getVertex() const { return _vertex; }
65 
66  bool isInput() const { return _isInput; }
67 
68  virtual ParamVisibility shouldShow() const { return _shouldShow ? notUsed : toBeLinked; }
69  virtual void setVisibility(bool visible);
70  void changeStyleProperty(const char* propertyName, QVariant val);
71 
72  QPoint getWorldAnchor();
73  signals:
74  void creationLink(QPoint startPos);
75  void releaseLink(QPoint endPos);
76  void askSynchro();
77  };
78 
80  {
81  Q_OBJECT;
82 
83  ConditionOfRendering* _model;
84  bool _isLeftCond;
85  public:
86  ConditionLinkRepresentation(ConditionOfRendering* model, bool isLeftCond, QWidget *father);
87  bool isLeftCond() const { return _isLeftCond; }
88  ConditionOfRendering* getModel() const { return _model; }
89  signals:
90  void askSynchro();
91  };
92 
94  {
95  Q_OBJECT;
96 
97  SubBlock* _model;
98  ParamDefinition _param;
99  bool _isLeftCond;
100  public:
101  SubGraphParamRepresentation(SubBlock* model, const ParamDefinition* def, bool isInput, QWidget *father);
102 
103  const ParamDefinition& getDefinition() const{ return _param; };
104  SubBlock* getModel() const { return _model; }
105  };
106 
108  {
109  Q_OBJECT;
110 
111  Block* _model;
112  ParamDefinition* _param;
113  ParamType _paramType;
114  bool _isSubParam;
115  std::string _subName;
116  bool _defaultValue;
117  public:
118  ParamRepresentation(Block* model, ParamDefinition* param, bool isInput, QWidget *father);
120 
121  virtual ParamVisibility shouldShow() const { return _param->_show; }
122  virtual void setVisibility(ParamVisibility visible);
123 
124  bool isDefaultVal() const { return _defaultValue; }
125  void useDefault(bool defaultVal) { _defaultValue = defaultVal; };
126  std::string getParamName() const { return _subName.empty() ? _param->_name : _subName; }
127  ParamValue* getParamValue() const {
128  if (_model != NULL) return _model->getParam(_param->_name, _isInput); else return NULL;
129  }
130  std::string getParamHelper() const;
131  std::vector<std::string> getParamListChoice() const;
132  Block* getModel() const { return _model; };
133  void setSubParam(bool param1);
134  bool isSubParam() const { return _isSubParam; };
135  void redefineParam(std::string fullSubName, ParamType newType);
136  };
137 
138 }
139 
140 
141 #endif
Definition: Block.h:163
Definition: Block.h:108
Definition: Block.h:197
void setSubParam(bool param1)
Definition: Connectors.cpp:159
Definition: VertexRepresentation.h:167
Definition: SubBlock.h:20
Definition: Connectors.h:107
Definition: Connectors.h:93
Definition: ParamValue.h:52