Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
MouseEdgeBendEditor.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef MOUSEEDGEBENDEDITION_H
22 #define MOUSEEDGEBENDEDITION_H
23 
24 #include <tulip/GlCircle.h>
25 #include <tulip/GlTriangle.h>
26 #include <tulip/GLInteractor.h>
27 #include <tulip/GlScene.h>
28 #include <tulip/GlLines.h>
29 
30 namespace tlp {
31 
32 class LayoutProperty;
33 class BooleanProperty;
34 class SizeProperty;
35 class DoubleProperty;
36 class CoordVectorProperty;
37 class IntegerProperty;
38 
39 class EdgeEntity : public GlSimpleEntity {
40 
41  Coord start;
42  Coord end;
43  std::vector<Coord> bends;
44 
45 public :
46 
47  void setCoordinates(const Coord &startPos, const Coord &endPos,const std::vector<Coord> &bendsPos) {
48  boundingBox = BoundingBox();
49  start=startPos;
50  end=endPos;
51  bends=bendsPos;
52  boundingBox.expand(start);
53  boundingBox.expand(end);
54 
55  for(std::vector<Coord>::iterator it=bends.begin(); it!=bends.end(); ++it) {
56  boundingBox.expand(*it);
57  }
58  }
59 
60  void draw(float,Camera *) {
61  GlLines::glDrawCurve(start,bends,end,10,0,Color(127,127,127,255),Color(127,127,127,255));
62  }
63 
64  void getXML(std::string &) {}
65  void setWithXML(const std::string &, unsigned int &) {}
66 };
67 
68 /// This interactor allows to move/add/delete EdgeBends
69 class TLP_QT_SCOPE MouseEdgeBendEditor:public GLInteractorComponent {
70 
71 public:
72 
73  MouseEdgeBendEditor();
74  ~MouseEdgeBendEditor();
75  bool compute(GlMainWidget *glMainWidget);
76  bool draw(GlMainWidget *);
77  void clear();
78  bool eventFilter(QObject *, QEvent *);
79  InteractorComponent *clone() {
80  return new MouseEdgeBendEditor();
81  }
82 
83 protected:
84  enum EditOperation { NONE_OP=0, TRANSLATE_OP, NEW_OP, DELETE_OP};
85 
86  EditOperation operation()const {
87  return _operation;
88  }
89 
90  tlp::edge getEdge()const {
91  return mEdge;
92  }
93 
94  void stopEdition();
95 
96 private:
97 
98  enum OperationTarget { COORD = 0, SIZE, COORD_AND_SIZE};
99 
100  Graph *_graph;
101  GlMainWidget* glMainWidget;
102  LayoutProperty *_layout;
103  BooleanProperty *_selection;
104  DoubleProperty *_rotation;
105  SizeProperty *_sizes;
106  IntegerProperty *_shape;
107  CoordVectorProperty *_coordsVectorProperty;
108 
109  void initProxies(GlMainWidget *glMainWidget);
110 
111 
112  EditOperation _operation;
113  OperationTarget mode;
114 
115  Coord editPosition;
116 
117  GlLayer *layer;
118  std::vector<tlp::GlCircle> circles;
119  EdgeEntity *edgeEntity;
120  std::vector<Coord> coordinates;
121  GlCircle basicCircle;
122  GlTriangle targetTriangle;
123  GlCircle sourceCircle;
124  GlComposite *circleString;
125  Graph *edgeBendsGraph;
126  std::vector <SelectedEntity> select;
127  bool edgeSelected;
128  tlp::edge mEdge;
129  node mNode;
130  Coord start, end;
131  std::string selectedEntity;
132  bool mouseButtonPressOnEdge;
133  bool belong(Coord, Coord, Coord, GlMainWidget*);
134  bool haveSelection(GlMainWidget *);
135  void computeSrcTgtEntities(GlMainWidget *);
136  bool computeBendsCircles(GlMainWidget*);
137  void mMouseTranslate(double, double, GlMainWidget*);
138  void mMouseDelete();
139  void mMouseCreate(double, double, GlMainWidget*);
140 };
141 
142 }
143 
144 
145 #endif
146 ///@endcond