Debian Codegraph @

src/customdial.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2019 Mario Stephan <[email protected]>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "customdial.h"cxx . . $ `<file>/src/customdial.h`/
19
20 #include <QColor>
21 #include <QPainter>
22
23 #include <cmath>
24
25 CustomDialcxx . . $ CustomDial#::CustomDialcxx . . $ CustomDial#CustomDial(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent)
26 : QDialcxx . . $ QDial#(parent)
27 {
28 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "START";
29 // Defaults
30 QDialcxx . . $ QDial#::setRangecxx . . $ QAbstractSlider#setRange(3e454b8ccf442868).(0, 360);
31 }
32
33 void CustomDialcxx . . $ CustomDial#::paintEventcxx . . $ CustomDial#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#*)
34 {
35 static const double degree270 = 1.5 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
36 static const double degree225 = 1.25 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
37 static const int scaleDiameter = static_cast<int>(round((this->heightcxx . . $ QWidget#height(455f465bc33b4cdf).() * 0.8) / 2) * 2);
38 static const int scaleOffset = static_cast<int>((this->heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - scaleDiameter) / 2);
39 static const int dialDiameter = static_cast<int>(round((this->heightcxx . . $ QWidget#height(455f465bc33b4cdf).() * 0.65) / 2) * 2);
40 static const int dialOffset = static_cast<int>((this->heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - dialDiameter) / 2);
41
42 QPaintercxx . . $ QPainter# paintercxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this);
43
44 // Smooth out the circle
45 painter.setRenderHintcxx . . $ QPainter#setRenderHint(df747a77a7bbbce1).(QPaintercxx . . $ QPainter#::Antialiasingcxx . . $ QPainter#Antialiasing.);
46
47 // Gradient for dial
48 QRadialGradientcxx . . $ QRadialGradient# radialGradcxx . . $ QRadialGradient#QRadialGradient(12845cb24d750046).(QPointFcxx . . $ QPointF#QPointF(bc12c9ec15586e6a).(dialOffset, dialOffset), dialDiameter);
49 radialGrad.setColorAtcxx . . $ QGradient#setColorAt(e8a5895791b6fa8c).(0.1, "#999"cxx . . $ QColor#QColor(85c52e162fed56f9).);
50 radialGrad.setColorAtcxx . . $ QGradient#setColorAt(e8a5895791b6fa8c).(0.5, "#777"cxx . . $ QColor#QColor(85c52e162fed56f9).);
51 radialGrad.setColorAtcxx . . $ QGradient#setColorAt(e8a5895791b6fa8c).(1, "#222"cxx . . $ QColor#QColor(85c52e162fed56f9).);
52
53 QBrushcxx . . $ QBrush# brushcxx . . $ QBrush#QBrush(cbd511d3bf8d464c).(radialGrad);
54 painter.setBrushcxx . . $ QPainter#setBrush(ffc9f5d0bda78261).(brush);
55 QPencxx . . $ QPen# pencxx . . $ QPen#QPen(49f6e7a06ebc5aa8).;
56 pen.setStylecxx . . $ QPen#setStyle(de7d79e7246fa26d).(Qtcxx . . $ Qt/::NoPencxx . . $ Qt/NoPen.);
57 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(pen);
58
59 // Draw dial
60 painter.drawEllipsecxx . . $ QPainter#drawEllipse(748afa4755bc9595).(dialOffset, dialOffset, dialDiameter, dialDiameter);
61
62 // Draw black border of dial
63 painter.setBrushcxx . . $ QPainter#setBrush(15c18aa000f81c3b).(Qtcxx . . $ Qt/::NoBrushcxx . . $ Qt/NoBrush.);
64 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).("#333"), 3));
65 painter.drawEllipsecxx . . $ QPainter#drawEllipse(748afa4755bc9595).(dialOffset, dialOffset, dialDiameter, dialDiameter);
66
67 // Draw scale arc
68 int startAngle = 225 * 16;
69 int spanAngle = -270 * 16;
70 QRectFcxx . . $ QRectF# rectScalecxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(scaleOffset, scaleOffset, scaleDiameter, scaleDiameter);
71 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).("#444"), 6));
72 painter.drawArccxx . . $ QPainter#drawArc(c5a35f869388a9d7).(rectScale, startAngle, spanAngle);
73 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).("#777"), 2));
74 painter.drawArccxx . . $ QPainter#drawArc(c5a35f869388a9d7).(rectScale, startAngle, spanAngle);
75
76 // Calc notch position
77 double ratio = static_cast<double>(QDialcxx . . $ QDial#::valuecxx . . $ QAbstractSlider#value(455f465bc33b4cdf).()) / QDialcxx . . $ QDial#::maximumcxx . . $ QAbstractSlider#maximum(455f465bc33b4cdf).();
78 double angle = ratio * degree270 - degree225;
79 double r = dialDiameter / 2.0;
80 double y = sin(angle) * (r - dialOffset / 2) + r + dialOffset;
81 double x = cos(angle) * (r - dialOffset / 2) + r + dialOffset;
82 double c = r + dialOffset;
83
84 // Draw the notch
85 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).("#ccc"), 2));
86 painter.drawLinecxx . . $ QPainter#drawLine(3628e2b324c1bb0).(QPointFcxx . . $ QPointF#QPointF(bc12c9ec15586e6a).(x, y), QPointFcxx . . $ QPointF#QPointF(bc12c9ec15586e6a).(c, c));
87 }