Tulip  6.0.0
Large graphs analysis and drawing
QuickAccessBar.h
1 /*
2  *
3  * This file is part of Tulip (https://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  NODEICON = 0x800000,
99  EDGESHAPE = 0x20000,
100  NODESIZE = 0x40000,
101  EDGESIZE = 0x80000,
102  NODELABELPOSITION = 0x100000,
103  SELECTFONT = 0x200000,
104  SHOWNODES = 0x400000,
105  ALLBUTTONS = 0xFFFFFF
106  };
107  Q_DECLARE_FLAGS(QuickAccessButtons, QuickAccessButton)
108 
109  explicit QuickAccessBarImpl(QGraphicsItem *quickAccessBarItem = nullptr,
110  QuickAccessButtons button = ALLBUTTONS, QWidget *parent = nullptr);
111  ~QuickAccessBarImpl() override;
112 
113  QPushButton *showEdgesButton();
114  QPushButton *showNodesButton();
115  ColorButton *backgroundColorButton();
116  QPushButton *showLabelsButton();
117  QPushButton *showLabelScaled();
118  QPushButton *showColorInterpolation();
119 
120 protected:
121  void addButtonAtEnd(QAbstractButton *button);
122  void addButtonsAtEnd(const QVector<QAbstractButton *> &buttonvect);
123  void addSeparator();
124  void updateFontButtonStyle();
125  void showHideCaption(CaptionItem::CaptionType captionType);
126  void setAllValues(unsigned int eltType, PropertyInterface *prop, QString str = "");
127 
128 public slots:
129  void reset() override;
130 
131  virtual void setBackgroundColor(const QColor &);
132  virtual void setColorInterpolation(bool);
133  void setLabelColor();
134  void setNodeColor();
135  void setNodeBorderColor();
136  void setEdgeColor();
137  void setEdgeBorderColor();
138  void setNodeShape();
139  void setNodeIcon();
140  void setEdgeShape();
141  void setNodeSize();
142  void setEdgeSize();
143  void setSizeInterpolation(bool);
144  void showHideNodesColorCaption();
145  void showHideNodesSizeCaption();
146  void showHideEdgesColorCaption();
147  void showHideEdgesSizeCaption();
148  void takeSnapshot();
149  virtual void setEdgesVisible(bool);
150  virtual void setNodesVisible(bool);
151  virtual void setLabelsVisible(bool);
152  virtual void setLabelsScaled(bool);
153  void selectFont();
154  void setNodeLabelPosition();
155 };
156 } // namespace tlp
157 Q_DECLARE_OPERATORS_FOR_FLAGS(tlp::QuickAccessBarImpl::QuickAccessButtons)
158 #endif // QUICKACCESSBAR_H
159 ///@endcond
An abstract view that displays a GlMainWidget as its central widget.
Definition: GlMainView.h:68