Tulip  5.2.0
Large graphs analysis and drawing
QuickAccessBar.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 QUICKACCESSBAR_H
22 #define QUICKACCESSBAR_H
23 
24 #include <QWidget>
25 
26 #include <tulip/CaptionItem.h>
27 #include <tulip/tulipconf.h>
28 
29 class QGraphicsItem;
30 class QAbstractButton;
31 class QPushButton;
32 
33 namespace Ui {
34 class QuickAccessBar;
35 }
36 
37 namespace tlp {
38 class GlMainView;
39 class GlGraphRenderingParameters;
40 class GlGraphInputData;
41 class GlScene;
42 class TulipItemDelegate;
43 class ColorProperty;
44 class Color;
45 class PropertyInterface;
46 class ColorButton;
47 
48 class TLP_QT_SCOPE QuickAccessBar : public QWidget {
49  Q_OBJECT
50 
51 protected:
52  GlMainView *_mainView;
53  GlScene *scene() const;
54  GlGraphInputData *inputData() const;
55  GlGraphRenderingParameters *renderingParameters() const;
56 
57 public:
58  QuickAccessBar(QWidget *parent = nullptr);
59 public slots:
60  void setGlMainView(tlp::GlMainView *);
61  virtual void reset() = 0;
62 
63 signals:
64  void settingsChanged();
65 };
66 
67 class TLP_QT_SCOPE QuickAccessBarImpl : public QuickAccessBar {
68  Q_OBJECT
69  Ui::QuickAccessBar *_ui;
70  QGraphicsItem *_quickAccessBarItem;
71 
72  TulipItemDelegate *delegate;
73  bool _resetting;
74  double _oldFontScale;
75  double _oldNodeScale;
76  bool _captionsInitialized;
77  CaptionItem *_captions[4];
78 
79 public:
80  enum QuickAccessButton {
81  NODESCOLORCAPTION = 0x1,
82  NODESSIZECAPTION = 0x2,
83  EDGESCOLORCAPTION = 0x4,
84  EDGESIZECAPTION = 0x8,
85  SCREENSHOT = 0x10,
86  BACKGROUNDCOLOR = 0x20,
87  NODECOLOR = 0x40,
88  EDGECOLOR = 0x80,
89  NODEBORDERCOLOR = 0x100,
90  EDGEBORDERCOLOR = 0x200,
91  LABELCOLOR = 0x400,
92  COLORINTERPOLATION = 0x800,
93  SIZEINTERPOLATION = 0x1000,
94  SHOWEDGES = 0x2000,
95  SHOWLABELS = 0x4000,
96  LABELSSCALED = 0x8000,
97  NODESHAPE = 0x10000,
98  EDGESHAPE = 0x20000,
99  NODESIZE = 0x40000,
100  EDGESIZE = 0x80000,
101  NODELABELPOSITION = 0x100000,
102  SELECTFONT = 0x200000,
103  SHOWNODES = 0x400000,
104  ALLBUTTONS = 0xFFFFFF
105  };
106  Q_DECLARE_FLAGS(QuickAccessButtons, QuickAccessButton)
107 
108  explicit QuickAccessBarImpl(QGraphicsItem *quickAccessBarItem = nullptr,
109  QuickAccessButtons button = ALLBUTTONS, QWidget *parent = nullptr);
110  ~QuickAccessBarImpl() override;
111 
112  QPushButton *showEdgesButton();
113  QPushButton *showNodesButton();
114  ColorButton *backgroundColorButton();
115  QPushButton *showLabelsButton();
116  QPushButton *showLabelScaled();
117  QPushButton *showColorInterpolation();
118 
119 protected:
120  void addButtonAtEnd(QAbstractButton *button);
121  void addButtonsAtEnd(const QVector<QAbstractButton *> &buttonvect);
122  void addSeparator();
123  void updateFontButtonStyle();
124  void showHideCaption(CaptionItem::CaptionType captionType);
125  void setAllValues(unsigned int eltType, PropertyInterface *prop);
126  void setAllColorValues(unsigned int eltType, ColorProperty *prop, const Color &color);
127 
128 public slots:
129  void reset() override;
130 
131  virtual void setBackgroundColor(const QColor &);
132  virtual void setColorInterpolation(bool);
133  void setLabelColor(const QColor &);
134  void setNodeColor(const QColor &);
135  void setNodeBorderColor(const QColor &);
136  void setEdgeColor(const QColor &);
137  void setEdgeBorderColor(const QColor &);
138  void setNodeShape();
139  void setEdgeShape();
140  void setNodeSize();
141  void setEdgeSize();
142  void setSizeInterpolation(bool);
143  void showHideNodesColorCaption();
144  void showHideNodesSizeCaption();
145  void showHideEdgesColorCaption();
146  void showHideEdgesSizeCaption();
147  void takeSnapshot();
148  virtual void setEdgesVisible(bool);
149  virtual void setNodesVisible(bool);
150  virtual void setLabelsVisible(bool);
151  virtual void setLabelsScaled(bool);
152  void selectFont();
153  void setNodeLabelPosition();
154 };
155 }
156 Q_DECLARE_OPERATORS_FOR_FLAGS(tlp::QuickAccessBarImpl::QuickAccessButtons)
157 #endif // QUICKACCESSBAR_H
158 ///@endcond
An abstract view that displays a GlMainWidget as its central widget.
Definition: GlMainView.h:68