10#include "qwt_round_scale_draw.h"
11#include "qwt_painter.h"
12#include "qwt_scale_div.h"
13#include "qwt_scale_map.h"
19class QwtRoundScaleDraw::PrivateData
23 : center( 50.0, 50.0 )
25 , startAngle( -135.0 )
46 m_data =
new QwtRoundScaleDraw::PrivateData;
81 return m_data->radius;
98 return m_data->center;
121 angle1 = qBound( -360.0, angle1, 360.0 );
122 angle2 = qBound( -360.0, angle2, 360.0 );
125 m_data->startAngle = angle1;
126 m_data->endAngle = angle2;
128 if ( m_data->startAngle == m_data->endAngle )
130 m_data->startAngle -= 1;
131 m_data->endAngle += 1;
148 if ( ( tval >= m_data->startAngle + 360.0 )
149 || ( tval <= m_data->startAngle - 360.0 ) )
158 double radius = m_data->radius;
169 const double arc = qwtRadians( tval );
171 const double x = m_data->center.x() +
172 (
radius + sz.width() / 2.0 ) * std::sin( arc );
173 const double y = m_data->center.y() -
174 (
radius + sz.height() / 2.0 ) * std::cos( arc );
176 const QRectF r( x - sz.width() / 2, y - sz.height() / 2,
177 sz.width(), sz.height() );
197 const double cx = m_data->center.x();
198 const double cy = m_data->center.y();
199 const double radius = m_data->radius;
201 if ( ( tval < m_data->startAngle + 360.0 )
202 && ( tval > m_data->startAngle - 360.0 ) )
204 const double arc = qwtRadians( tval );
206 const double sinArc = std::sin( arc );
207 const double cosArc = std::cos( arc );
209 const double x1 = cx +
radius * sinArc;
210 const double x2 = cx + (
radius + len ) * sinArc;
211 const double y1 = cy -
radius * cosArc;
212 const double y2 = cy - (
radius + len ) * cosArc;
229 const int a1 = qRound( qwtMinF( deg1, deg2 ) - 90 );
230 const int a2 = qRound( qwtMaxF( deg1, deg2 ) - 90 );
232 const double radius = m_data->radius;
233 const double x = m_data->center.x() -
radius;
234 const double y = m_data->center.y() -
radius;
236 painter->drawArc( QRectF( x, y, 2 *
radius, 2 *
radius ),
237 -a2 * 16, ( a2 - a1 + 1 ) * 16 );
263 for (
int i = 0; i < ticks.count(); i++ )
265 const double value = ticks[i];
270 if ( ( tval < m_data->startAngle + 360 )
271 && ( tval > m_data->startAngle - 360 ) )
277 const double arc = qwtRadians( tval );
280 const double off = qMax( sz.width(), sz.height() );
282 double x = off * std::sin( arc );
283 double y = off * std::cos( arc );
285 const double dist = std::sqrt( x * x + y * y );
const QwtScaleMap & scaleMap() const
@ Backbone
Backbone = the line where the ticks are located.
double tickLength(QwtScaleDiv::TickType) const
bool hasComponent(ScaleComponent) const
const QwtText & tickLabel(const QFont &, double value) const
Convert a value into its representing label and cache it.
double maxTickLength() const
double minimumExtent() const
virtual QwtText label(double) const
Convert a value into its representing label.
const QwtScaleDiv & scaleDiv() const
double spacing() const
Get the spacing.
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
virtual double extent(const QFont &) const override
void setRadius(double radius)
QPointF center() const
Get the center of the scale.
virtual void drawBackbone(QPainter *) const override
virtual void drawLabel(QPainter *, double value) const override
void setAngleRange(double angle1, double angle2)
Adjust the baseline circle segment for round scales.
virtual ~QwtRoundScaleDraw()
Destructor.
QwtRoundScaleDraw()
Constructor.
void moveCenter(double x, double y)
Move the center of the scale draw, leaving the radius unchanged.
virtual void drawTick(QPainter *, double value, double len) const override
A class representing a scale division.
QList< double > ticks(int tickType) const
bool contains(double value) const
double transform(double s) const
void setPaintInterval(double p1, double p2)
Specify the borders of the paint device interval.
A class representing a text.
void draw(QPainter *painter, const QRectF &rect) const