Tulip  5.3.0
Large graphs analysis and drawing
GlOverviewGraphicsItem.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 GLOVERVIEWGRAPHICSITEM_H
22 #define GLOVERVIEWGRAPHICSITEM_H
23 
24 #include <tulip/tulipconf.h>
25 #include <tulip/Camera.h>
26 #include <tulip/Color.h>
27 
28 #include <QGraphicsPixmapItem>
29 #include <QGraphicsPathItem>
30 
31 #include <set>
32 
33 namespace tlp {
34 
35 class GlMainView;
36 class GlScene;
37 
38 class TLP_QT_SCOPE GlOverviewGraphicsItem : public QObject, public QGraphicsRectItem {
39 
40  Q_OBJECT
41 
42 public:
43  GlOverviewGraphicsItem(GlMainView *view, GlScene &scene);
44  ~GlOverviewGraphicsItem() override;
45 
46  void setSize(unsigned int width, unsigned int height);
47  inline unsigned int getWidth() {
48  return width;
49  }
50  inline unsigned int getHeight() {
51  return height;
52  }
53 
54  void setFrameColor(const Color &color) {
55  _frameColor = color;
56  }
57 
58  void setFrameWidth(int width) {
59  _frameWidth = width;
60  }
61 
62  void setLayerVisible(const std::string &name, bool visible);
63 
64 public slots:
65 
66  void draw(bool generatePixmap);
67 
68 private:
69  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
70  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
71  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
72  void setScenePosition(QPointF pos);
73 
74  GlMainView *view;
75  GlScene &baseScene;
76  unsigned int width, height;
77 
78  QGraphicsPixmapItem overview;
79  QGraphicsPathItem overviewBorder;
80  QGraphicsLineItem line[8];
81  QGraphicsPolygonItem poly[4];
82 
83  bool mouseClicked;
84 
85  std::set<std::string> _hiddenLayers;
86 
87  std::vector<Camera> _oldCameras;
88 
89  Color _frameColor;
90  int _frameWidth;
91 };
92 } // namespace tlp
93 
94 #endif // GLOVERVIEWGRAPHICSITEM_H
95 ///@endcond