Tulip  5.3.0
Large graphs analysis and drawing
MouseEdgeBuilder.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
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 
24 #include <vector>
25 #include <tulip/Coord.h>
26 #include <tulip/GLInteractor.h>
27 #include <tulip/Observable.h>
28 
29 namespace tlp {
30 class Graph;
31 class LayoutProperty;
32 class GlMainWidget;
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  GlMainWidget *glMainWidget;
43 
44 protected:
45  /**
46  * @brief addLink Adds a link between a source and destination nodes. Adds an edge by default
47  * @param source
48  * @param dest
49  */
50  virtual void addLink(const node &source, const node &dest);
51  /**
52  * @brief source gets the source node.
53  * @return
54  */
55  node source() const {
56  return _source;
57  }
58  /**
59  * @brief bends returns the bends list.
60  * @return
61  */
62  const std::vector<Coord> &bends() const {
63  return _bends;
64  }
65  /**
66  * @brief setBends updates the bends list.
67  * @param bends
68  */
69  void setBends(const std::vector<Coord> &bends) {
70  _bends = bends;
71  }
72 
73 public:
74  MouseEdgeBuilder();
75  bool draw(GlMainWidget *) override;
76  bool eventFilter(QObject *, QEvent *) override;
77  void initObserver(Graph *);
78  void clearObserver();
79 
80  void treatEvent(const Event &) override;
81 
82  void clear() override;
83 };
84 } // namespace tlp
85 #endif
86 ///@endcond