cut 3.3.0
Loading...
Searching...
No Matches
QeRadialItemPlot.hpp
1#ifndef QERADIALITEMPLOT_HPP
2#define QERADIALITEMPLOT_HPP
3
4#include <QObject>
5#include <QString>
6#include <QDebug>
7#include <QMetaClassInfo>
8#include <QMetaObject>
9#include <QMetaProperty>
10#include <QVariant>
11#include <QWidget>
12#include <QtUiPlugin/QDesignerExportWidget>
13#include <qpainter.h>
14#include <iostream>
15
16#define _USE_MATH_DEFINES
17#include <cmath>
18
19
25class QeRadialItemPlot : public QWidget
26{
27 Q_OBJECT
28
34 Q_PROPERTY(bool isClockwise READ getIsClockwise WRITE setIsClockwise NOTIFY isClockwiseChanged FINAL)
35
36
41
46 Q_PROPERTY(bool showGrid READ getShowGrid WRITE setShowGrid NOTIFY showGridChanged FINAL)
47
48protected:
54 void changeEvent(QEvent *event) override;
55
61 void resizeEvent(QResizeEvent *event) override;
62
67 virtual void paintDartBoard(QPainter *painter){};
68
73 void cacheBackground(QPainter *painter);
74
80 void setDirectionIndicatorSigns(QString vertical, QString horizontal);
81
86 void setDirectionIndicatorVisible(bool isVisible);
87
93 void drawValues(QPainter *painter);
94
95public:
100 explicit QeRadialItemPlot(QWidget *parent = Q_NULLPTR);
101 virtual ~QeRadialItemPlot();
102
107 bool getIsClockwise(){ return m_isClockwise; }
108
114 bool getDegRadNumericDisplay(){ return m_degRadNumericDisplay; }
115
120 bool getShowGrid(){ return m_showGrid; }
121
128 QPixmap getBackgroundPixmap(){ return *(this->p_background.get()); }
129
130signals:
135 void isClockwiseChanged(bool newValue);
136
142 void degRadNumericDisplayTriggered(bool newValue);
143
148 void showGridChanged(bool newValue);
149
150
151public slots:
156 void setIsClockwise(bool newValue);
157
162 void setDegRadNumericDisplay(bool newValue);
163
168 void setShowGrid(bool newValue);
169
174 void updateBackground();
175
176
177protected:
178 bool m_backgroundUpdateNeeded = true;
179 double m_scale = 1.0;
180 // The scale at which the drawing of the radial plot is scaled;
181 // The value is defined arbitrary, may be changed if necessary.
182 double m_scale_factor = 120.0;
183 QString m_vertical_indicator = "N";
184 QString m_horizontal_indicator = "E";
185 bool m_areDirectionsVisible = true;
186 bool m_isClockwise = true;
187 bool m_degRadNumericDisplay = false;
188 bool m_showGrid = false;
189
190private:
191 std::unique_ptr<QPixmap> p_background;
192
193};
194
195
196#endif //QERADIALITEMPLOT_HPP
Base class for QeDartBoard and QePreFocalStation.
Definition QeRadialItemPlot.hpp:26
virtual void paintDartBoard(QPainter *painter)
Uses a QPainter to draw the dartboard (mostly static) background.
Definition QeRadialItemPlot.hpp:67
void drawValues(QPainter *painter)
Draws numeric values around the radial plot in a desired direction (eiher clockwise or counterclockwi...
Definition QeRadialItemPlot.cpp:176
void degRadNumericDisplayTriggered(bool newValue)
Indicates that the numerical unit representation has changed.
bool degRadNumericDisplay
Degrees/Radians numerical indicators representation (0 - Degrees, 1 - Radians)
Definition QeRadialItemPlot.hpp:40
void resizeEvent(QResizeEvent *event) override
Overrides QWidget::resizeEvent to catch when the size has changed.
Definition QeRadialItemPlot.cpp:47
void isClockwiseChanged(bool newValue)
Indicates that the direction of values distribution chanegd.
bool isClockwise
Flag that determines if radial coordinates of the plot change clockwise (true) or counterclockwise (f...
Definition QeRadialItemPlot.hpp:34
void changeEvent(QEvent *event) override
Overrides QWidget::changeEvent to catch when certain QWidget's properties has changed.
Definition QeRadialItemPlot.cpp:34
bool showGrid
Show/hide grid.
Definition QeRadialItemPlot.hpp:46
void setDegRadNumericDisplay(bool newValue)
Changes the units used to display the values.
Definition QeRadialItemPlot.cpp:156
void setIsClockwise(bool newValue)
Changes the direction of radial values distribution.
Definition QeRadialItemPlot.cpp:23
void showGridChanged(bool newValue)
Indicates that the numerical unit representation has changed.
bool getIsClockwise()
Gets the value the flag that determines if radial values change clockwise or counterclockwise.
Definition QeRadialItemPlot.hpp:107
void updateBackground()
Updates the m_backgroundUpdateNeeded internal flag to signal a significant change was detect,...
Definition QeRadialItemPlot.cpp:171
void setDirectionIndicatorSigns(QString vertical, QString horizontal)
Sets indicators' symbols for directions arrows painted in top right corner.
Definition QeRadialItemPlot.cpp:140
void cacheBackground(QPainter *painter)
Stores in a pointer the new background cache.
Definition QeRadialItemPlot.cpp:53
void setShowGrid(bool newValue)
Changes the grid visibility indicator.
Definition QeRadialItemPlot.cpp:163
QPixmap getBackgroundPixmap()
Returns background QPixmap that is stored in unique ptr.
Definition QeRadialItemPlot.hpp:128
bool getDegRadNumericDisplay()
Returns the true if using radians to display numerical values.
Definition QeRadialItemPlot.hpp:114
QeRadialItemPlot(QWidget *parent=Q_NULLPTR)
Constructor that is used to set a parent relationship with.
Definition QeRadialItemPlot.cpp:13
void setDirectionIndicatorVisible(bool isVisible)
Sets directions indicator (painted in the top right corner of the widget) visible.
Definition QeRadialItemPlot.cpp:149
bool getShowGrid()
Returns the true if grid is displayed.
Definition QeRadialItemPlot.hpp:120