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