Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
MouseSelectionEditor.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 MOUSEMOVESELECTION_H
22 #define MOUSEMOVESELECTION_H
23 
24 //#include <tulip/GlRect.h>
25 #include <tulip/GlCircle.h>
26 #include <tulip/GlRect.h>
27 #include <tulip/GlComposite.h>
28 #include <tulip/Observable.h>
29 #include <tulip/GLInteractor.h>
30 #include <tulip/GlComplexPolygon.h>
31 #include <tulip/LayoutProperty.h>
32 #include <tulip/DoubleProperty.h>
33 #include <tulip/SizeProperty.h>
34 
35 namespace tlp {
36 
37 /// This interactor allows to move/rotate/stretch the current selection layout
38 class TLP_QT_SCOPE MouseSelectionEditor:public GLInteractorComponent {
39 
40 public:
41 
42  MouseSelectionEditor();
43  ~MouseSelectionEditor();
44  void clear();
45  bool compute(GlMainWidget *glMainWidget);
46  bool draw(GlMainWidget *);
47  bool eventFilter(QObject *, QEvent *);
48  InteractorComponent *clone() {
49  return new MouseSelectionEditor();
50  }
51 
52 private:
53  enum EditOperation { NONE=0, ROTATE_Z, ROTATE_XY, STRETCH_X, STRETCH_Y, STRETCH_XY, TRANSLATE, ALIGN_TOP, ALIGN_BOTTOM, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_VERTICALLY, ALIGN_HORIZONTALLY};
54  enum OperationTarget { COORD = 0, SIZE, COORD_AND_SIZE};
55 
56  Graph *_graph;
57  GlMainWidget *glMainWidget;
58  LayoutProperty *_layout;
59  BooleanProperty *_selection;
60  DoubleProperty *_rotation;
61  SizeProperty *_sizes;
62  LayoutProperty *_copyLayout;
63  SizeProperty *_copySizes;
64  DoubleProperty *_copyRotation;
65 
66  void initProxies(GlMainWidget *glMainWidget);
67  void initEdition();
68  void undoEdition();
69  void stopEdition();
70 
71  EditOperation operation;
72  OperationTarget mode;
73 
74  Coord editCenter;
75  Coord editPosition;
76  Coord editLayoutCenter;
77 
78  // int x,y;
79  // double centerX, centerY;
80  Coord ffdCenter;
81 
82  GlLayer *layer;
83  GlComposite *composite;
84  GlCircle _controls[8];
85  GlComplexPolygon _advControls[6];
86  GlRect centerRect;
87  GlRect advRect;
88  Coord _layoutCenter;
89 
90  bool computeFFD(GlMainWidget*);
91  void getOperation(GlEntity *select);
92  void mMouseTranslate(double, double, GlMainWidget*);
93  void mMouseRotate(double, double, GlMainWidget*);
94  void mMouseStretchAxis(double, double, GlMainWidget*);
95  void mAlign(EditOperation operation,GlMainWidget*);
96 
97 
98 };
99 
100 }
101 
102 
103 #endif
104 ///@endcond