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 };
QRoundProgressBar::m_rebuildBrush
bool m_rebuildBrush
Definition: QRoundProgressBar.h:254
QRoundProgressBar::heightForWidth
virtual int heightForWidth(int w) const
Definition: QRoundProgressBar.h:242
QRoundProgressBar::m_dataPenWidth
double m_dataPenWidth
Definition: QRoundProgressBar.h:251
QRoundProgressBar::maximum
double maximum() const
Returns maximum of the allowed value range.
Definition: QRoundProgressBar.h:181
QRoundProgressBar::setRange
void setRange(double min, double max)
Defines minimum und maximum of the allowed value range. If the current value does not fit into the ra...
Definition: QRoundProgressBar.cpp:27
QRoundProgressBar::resetFormat
void resetFormat()
Sets format string to empty string. No text will be shown therefore. See setFormat() for more informa...
Definition: QRoundProgressBar.cpp:113
QRoundProgressBar::paintEvent
virtual void paintEvent(QPaintEvent *event)
Definition: QRoundProgressBar.cpp:127
QRoundProgressBar::UF_PERCENT
static const int UF_PERCENT
Definition: QRoundProgressBar.h:260
QRoundProgressBar::UF_VALUE
static const int UF_VALUE
Definition: QRoundProgressBar.h:259
QRoundProgressBar::drawBackground
virtual void drawBackground(QPainter &p, const QRectF &baseRect)
Definition: QRoundProgressBar.cpp:168
format
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:181
QRoundProgressBar::m_barStyle
BarStyle m_barStyle
Definition: QRoundProgressBar.h:250
QRoundProgressBar::StyleLine
@ StyleLine
Line style (thin round line around the text)
Definition: QRoundProgressBar.h:90
position
math::float3 position
Definition: LineSetBuffers.cpp:44
QRoundProgressBar::setMaximum
void setMaximum(double max)
Defines maximum of the allowed value range. If the current value does not fit into the range,...
Definition: QRoundProgressBar.cpp:45
QRoundProgressBar::outlinePenWidth
double outlinePenWidth() const
Returns width of the outline circle pen.
Definition: QRoundProgressBar.h:111
QRoundProgressBar::dataPenWidth
double dataPenWidth() const
Returns width of the data circle pen.
Definition: QRoundProgressBar.h:121
color
math::float4 color
Definition: LineSetBuffers.cpp:46
QRoundProgressBar::format
QString format() const
Returns the string used to generate the current text.
Definition: QRoundProgressBar.h:154
QRoundProgressBar::decimals
int decimals() const
Returns number of decimals to show after the comma (default is 1).
Definition: QRoundProgressBar.h:165
QRoundProgressBar::valueToText
virtual QString valueToText(double value) const
Definition: QRoundProgressBar.cpp:272
width
int width
Definition: FileIOFactory.cpp:142
QRoundProgressBar::m_gradientData
QGradientStops m_gradientData
Definition: QRoundProgressBar.h:253
QRoundProgressBar::setBarStyle
void setBarStyle(BarStyle style)
Sets visual style of the widget.
Definition: QRoundProgressBar.cpp:72
height
int height
Definition: FileIOFactory.cpp:143
QRoundProgressBar::drawInnerBackground
virtual void drawInnerBackground(QPainter &p, const QRectF &innerRect)
Definition: QRoundProgressBar.cpp:247
QRoundProgressBar::m_value
double m_value
Definition: QRoundProgressBar.h:247
QRoundProgressBar::setValue
void setValue(double val)
Sets a value which will be shown on the widget.
Definition: QRoundProgressBar.cpp:47
event
MouseEvent event
Definition: BitmapWindowSystem.cpp:61
QRoundProgressBar::setNullPosition
void setNullPosition(double position)
Defines position of minimum value.
Definition: QRoundProgressBar.cpp:62
QRoundProgressBar::setFormat
void setFormat(const QString &format)
Defines the string used to generate the current text. If no format is set, no text will be shown.
Definition: QRoundProgressBar.cpp:105
QRoundProgressBar::drawBase
virtual void drawBase(QPainter &p, const QRectF &baseRect)
Definition: QRoundProgressBar.cpp:173
QRoundProgressBar::StylePie
@ StylePie
Pie style (filled pie segment with the text in center)
Definition: QRoundProgressBar.h:88
QRoundProgressBar::m_min
double m_min
Definition: QRoundProgressBar.h:246
QRoundProgressBar::QRoundProgressBar
QRoundProgressBar(QWidget *parent=0)
Definition: QRoundProgressBar.cpp:13
QRoundProgressBar::BarStyle
BarStyle
The BarStyle enum defines general look of the progress bar.
Definition: QRoundProgressBar.h:84
QRoundProgressBar::UF_MAX
static const int UF_MAX
Definition: QRoundProgressBar.h:261
QRoundProgressBar::value
double value() const
Returns current value shown on the widget.
Definition: QRoundProgressBar.h:171
QRoundProgressBar::m_decimals
int m_decimals
Definition: QRoundProgressBar.h:257
QRoundProgressBar::setDataPenWidth
void setDataPenWidth(double penWidth)
Sets width of the data circle pen.
Definition: QRoundProgressBar.cpp:88
QRoundProgressBar::hasHeightForWidth
virtual bool hasHeightForWidth() const
Definition: QRoundProgressBar.h:241
QRoundProgressBar::setDecimals
void setDecimals(int count)
Sets number of decimals to show after the comma (default is 1).
Definition: QRoundProgressBar.cpp:119
QRoundProgressBar::m_nullPosition
double m_nullPosition
Definition: QRoundProgressBar.h:249
QRoundProgressBar::m_updateFlags
int m_updateFlags
Definition: QRoundProgressBar.h:262
QRoundProgressBar::m_format
QString m_format
Definition: QRoundProgressBar.h:256
QRoundProgressBar
The QRoundProgressBar class represents a circular progress bar and maintains its API similar to the Q...
Definition: QRoundProgressBar.h:59
QRoundProgressBar::rebuildDataBrushIfNeeded
void rebuildDataBrushIfNeeded()
Definition: QRoundProgressBar.cpp:302
QRoundProgressBar::barStyle
BarStyle barStyle() const
Returns current progree bar style.
Definition: QRoundProgressBar.h:101
QRoundProgressBar::calculateInnerRect
virtual void calculateInnerRect(const QRectF &baseRect, double outerRadius, QRectF &innerRect, double &innerRadius)
Definition: QRoundProgressBar.cpp:231
QRoundProgressBar.h
QRoundProgressBar::minimum
double minimum() const
Returns minimum of the allowed value range.
Definition: QRoundProgressBar.h:176
QRoundProgressBar::valueFormatChanged
virtual void valueFormatChanged()
Definition: QRoundProgressBar.cpp:290
count
int count
Definition: FileIOFactory.cpp:132
QPCL_ENGINE_LIB_API
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
QRoundProgressBar::drawText
virtual void drawText(QPainter &p, const QRectF &innerRect, double innerRadius, double value)
Definition: QRoundProgressBar.cpp:255
QRoundProgressBar::setDataColors
void setDataColors(const QGradientStops &stopPoints)
Sets colors of the visible data and makes gradient brush from them. Gradient colors can be set for Do...
Definition: QRoundProgressBar.cpp:96
QRoundProgressBar::setOutlinePenWidth
void setOutlinePenWidth(double penWidth)
Sets width of the outline circle pen.
Definition: QRoundProgressBar.cpp:80
QRoundProgressBar::minimumSizeHint
virtual QSize minimumSizeHint() const
Definition: QRoundProgressBar.h:239
QRoundProgressBar::nullPosition
double nullPosition() const
Return position (in degrees) of minimum value.
Definition: QRoundProgressBar.h:73
QRoundProgressBar::drawValue
virtual void drawValue(QPainter &p, const QRectF &baseRect, double value, double arcLength)
Definition: QRoundProgressBar.cpp:199
QRoundProgressBar::m_outlinePenWidth
double m_outlinePenWidth
Definition: QRoundProgressBar.h:251
QRoundProgressBar::StyleDonut
@ StyleDonut
Donut style (filled torus around the text)
Definition: QRoundProgressBar.h:86
QRoundProgressBar::setMinimum
void setMinimum(double min)
Defines minimum of the allowed value range. If the current value does not fit into the range,...
Definition: QRoundProgressBar.cpp:43
QRoundProgressBar::m_max
double m_max
Definition: QRoundProgressBar.h:246