Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
MouseEdgeBuilder.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 MOUSEADDEDGE_H
22 #define MOUSEADDEDGE_H
23 #include <vector>
24 #include <tulip/Coord.h>
25 #include <tulip/GLInteractor.h>
26 #include <tulip/ObservableGraph.h>
27 #include <tulip/Observable.h>
28 #include <tulip/ObservableProperty.h>
29 
30 namespace tlp {
31 class Graph;
32 class LayoutProperty;
33 
34 class TLP_QT_SCOPE MouseEdgeBuilder:public GLInteractorComponent, public Observable {
35 private:
36  node _source;
37  bool _started;
38  Coord _startPos,_curPos;
39  std::vector<Coord> _bends;
40  Graph *_graph;
41  LayoutProperty *_layoutProperty;
42 
43 protected:
44  /**
45  * @brief addLink Adds a link between a source and destination nodes. Adds an edge by default
46  * @param source
47  * @param dest
48  */
49  virtual void addLink(QObject *, const node source, const node dest);
50  /**
51  * @brief source gets the source node.
52  * @return
53  */
54  node source()const {
55  return _source;
56  }
57  /**
58  * @brief bends returns the bends list.
59  * @return
60  */
61  const std::vector<Coord>& bends()const {
62  return _bends;
63  }
64  /**
65  * @brief setBends updates the bends list.
66  * @param bends
67  */
68  void setBends(const std::vector<Coord>& bends) {
69  _bends = bends;
70  }
71 
72 public:
73  MouseEdgeBuilder();
74  bool draw(GlMainWidget *);
75  bool eventFilter(QObject *, QEvent *);
76  void initObserver(Graph *);
77  void clearObserver();
78 
79  void treatEvent(const Event&);
80 
81  InteractorComponent *clone() {
82  return new MouseEdgeBuilder();
83  }
84 
85  void clear();
86 };
87 
88 
89 }
90 #endif
91 ///@endcond