Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
MouseInteractors.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 
22 #ifndef MOUSEOBJECT_H
23 #define MOUSEOBJECT_H
24 
25 #include <tulip/tulipconf.h>
26 
27 #include <QtGui/qcursor.h>
28 
29 #include <tulip/InteractorComposite.h>
30 #include <tulip/NodeLinkDiagramComponent.h>
31 #include <tulip/Camera.h>
32 
33 namespace tlp {
34 
35 /** An interactor class allowing to zoom and pan using the mouse wheel.
36  */
37 class TLP_QT_SCOPE MousePanNZoomNavigator:public InteractorComponent {
38 public:
39  MousePanNZoomNavigator():cameraScaleFactor(1), isGesturing(false) {}
40  ~MousePanNZoomNavigator() {}
41  bool eventFilter(QObject *, QEvent *);
42  InteractorComponent *clone() {
43  return new MousePanNZoomNavigator();
44  }
45 protected:
46  float cameraScaleFactor;
47  bool isGesturing;
48 };
49 
50 /** An interactor class used to delete a graph element on mouse left click
51  */
52 class TLP_QT_SCOPE MouseElementDeleter:public InteractorComponent {
53 public:
54  MouseElementDeleter() {}
55  ~MouseElementDeleter() {}
56  bool eventFilter(QObject *, QEvent *);
57  InteractorComponent *clone() {
58  return new MouseElementDeleter();
59  }
60  void clear();
61 };
62 
63 /** An interactor class to translate/rotate using keys or mouse movements,
64  or to zoom and pan using the mouse wheel or
65  */
66 class TLP_QT_SCOPE MouseNKeysNavigator: public MousePanNZoomNavigator {
67 private:
68  InteractorComponent *currentSpecInteractorComponent;
69 
70  QCursor oldCursor;
71 public:
72  MouseNKeysNavigator() : currentSpecInteractorComponent(NULL) {}
73  MouseNKeysNavigator(const MouseNKeysNavigator&) {}
74  ~MouseNKeysNavigator() {}
75  bool eventFilter(QObject *, QEvent *);
76  InteractorComponent *clone() {
77  return new MouseNKeysNavigator(*this);
78  }
79  void clear();
80  void viewChanged(tlp::View *view);
81 
82 private :
83 
84  // member below are to manage meta node navigation
85  tlp::NodeLinkDiagramComponent *nldc;
86  std::vector<tlp::Graph*> graphHierarchy;
87  std::vector<tlp::Camera> cameraHierarchy;
88  std::vector<tlp::node> nodeHierarchy;
89  std::vector<float> alphaHierarchy;
90 };
91 
92 
93 }
94 #endif
95 ///@endcond