ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QRoundProgressBar.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <QWidget>
11 
12 #include "../qPCL.h"
13 
59 class QPCL_ENGINE_LIB_API QRoundProgressBar : public QWidget {
60  Q_OBJECT
61 public:
62  explicit QRoundProgressBar(QWidget* parent = 0);
63 
64  static const int PositionLeft = 180;
65  static const int PositionTop = 90;
66  static const int PositionRight = 0;
67  static const int PositionBottom = -90;
68 
73  double nullPosition() const { return m_nullPosition; }
79  void setNullPosition(double position);
80 
84  enum BarStyle {
90  StyleLine
91  };
96  void setBarStyle(BarStyle style);
101  BarStyle barStyle() const { return m_barStyle; }
102 
107  void setOutlinePenWidth(double penWidth);
111  double outlinePenWidth() const { return m_outlinePenWidth; }
112 
117  void setDataPenWidth(double penWidth);
121  double dataPenWidth() const { return m_dataPenWidth; }
122 
137  void setDataColors(const QGradientStops& stopPoints);
138 
145  void setFormat(const QString& format);
150  void resetFormat();
154  QString format() const { return m_format; }
155 
160  void setDecimals(int count);
165  int decimals() const { return m_decimals; }
166 
171  double value() const { return m_value; }
176  double minimum() const { return m_min; }
181  double maximum() const { return m_max; }
182 
183 public Q_SLOTS:
191  void setRange(double min, double max);
199  void setMinimum(double min);
207  void setMaximum(double max);
212  void setValue(double val);
217  void setValue(int val);
218 
219 protected:
220  virtual void paintEvent(QPaintEvent* event);
221  virtual void drawBackground(QPainter& p, const QRectF& baseRect);
222  virtual void drawBase(QPainter& p, const QRectF& baseRect);
223  virtual void drawValue(QPainter& p,
224  const QRectF& baseRect,
225  double value,
226  double arcLength);
227  virtual void calculateInnerRect(const QRectF& baseRect,
228  double outerRadius,
229  QRectF& innerRect,
230  double& innerRadius);
231  virtual void drawInnerBackground(QPainter& p, const QRectF& innerRect);
232  virtual void drawText(QPainter& p,
233  const QRectF& innerRect,
234  double innerRadius,
235  double value);
236  virtual QString valueToText(double value) const;
237  virtual void valueFormatChanged();
238 
239  virtual QSize minimumSizeHint() const { return QSize(32, 32); }
240 
241  virtual bool hasHeightForWidth() const { return true; }
242  virtual int heightForWidth(int w) const { return w; }
243 
244  void rebuildDataBrushIfNeeded();
245 
246  double m_min, m_max;
247  double m_value;
248 
251  double m_outlinePenWidth, m_dataPenWidth;
252 
253  QGradientStops m_gradientData;
255 
256  QString m_format;
258 
259  static const int UF_VALUE = 1;
260  static const int UF_PERCENT = 2;
261  static const int UF_MAX = 4;
263 };
MouseEvent event
filament::Texture::InternalFormat format
int count
math::float3 position
The QRoundProgressBar class represents a circular progress bar and maintains its API similar to the Q...
virtual QSize minimumSizeHint() const
BarStyle barStyle() const
Returns current progree bar style.
double outlinePenWidth() const
Returns width of the outline circle pen.
double value() const
Returns current value shown on the widget.
double dataPenWidth() const
Returns width of the data circle pen.
int decimals() const
Returns number of decimals to show after the comma (default is 1).
double minimum() const
Returns minimum of the allowed value range.
QGradientStops m_gradientData
QString format() const
Returns the string used to generate the current text.
BarStyle
The BarStyle enum defines general look of the progress bar.
@ StylePie
Pie style (filled pie segment with the text in center)
@ StyleDonut
Donut style (filled torus around the text)
virtual bool hasHeightForWidth() const
virtual int heightForWidth(int w) const
double nullPosition() const
Return position (in degrees) of minimum value.
double maximum() const
Returns maximum of the allowed value range.
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15