Tulip  4.3.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 
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 
33 class TLP_QT_SCOPE MouseEdgeBuilder:public GLInteractorComponent, public Observable {
34 private:
35  node _source;
36  bool _started;
37  Coord _startPos,_curPos;
38  std::vector<Coord> _bends;
39  Graph *_graph;
40  LayoutProperty *_layoutProperty;
41 
42 protected:
43  /**
44  * @brief addLink Adds a link between a source and destination nodes. Adds an edge by default
45  * @param source
46  * @param dest
47  */
48  virtual void addLink(QObject *, const node source, const node dest);
49  /**
50  * @brief source gets the source node.
51  * @return
52  */
53  node source()const {
54  return _source;
55  }
56  /**
57  * @brief bends returns the bends list.
58  * @return
59  */
60  const std::vector<Coord>& bends()const {
61  return _bends;
62  }
63  /**
64  * @brief setBends updates the bends list.
65  * @param bends
66  */
67  void setBends(const std::vector<Coord>& bends) {
68  _bends = bends;
69  }
70 
71 public:
72  MouseEdgeBuilder();
73  bool draw(GlMainWidget *);
74  bool eventFilter(QObject *, QEvent *);
75  void initObserver(Graph *);
76  void clearObserver();
77 
78  void treatEvent(const Event&);
79 
80  void clear();
81 };
82 
83 
84 }
85 #endif
86 ///@endcond