21 #include <qpaintengine.h> 26 const QPointF& p1,
const QPointF& p2 )
28 double dx = p2.x() - p1.x();
29 double dy = p2.y() - p1.y();
30 return qSqrt( dx * dx + dy * dy );
78 QPointer< QwtAbstractLegend >
legend;
123 if ( !title.isEmpty() )
256 it != itmList.end(); ++it )
270 if ( plotItem == NULL )
278 const QVariant itemInfo =
itemToInfo( const_cast< QwtPolarItem* >( plotItem ) );
374 if ( !scaleData.doAutoScale )
376 scaleData.doAutoScale =
true;
406 maxMinor = qBound( 0, maxMinor, 100 );
410 if ( maxMinor != scaleData.maxMinor )
412 scaleData.maxMinor = maxMinor;
413 scaleData.isValid =
false;
443 maxMajor = qBound( 1, maxMajor, 10000 );
446 if ( maxMajor != scaleData.maxMinor )
448 scaleData.maxMajor = maxMajor;
449 scaleData.isValid =
false;
482 if ( scaleEngine == NULL || scaleEngine == scaleData.scaleEngine )
485 delete scaleData.scaleEngine;
488 scaleData.isValid =
false;
531 double min,
double max,
double stepSize )
538 scaleData.isValid =
false;
540 scaleData.minValue = min;
541 scaleData.maxValue = max;
542 scaleData.stepSize = stepSize;
543 scaleData.doAutoScale =
false;
562 scaleData.isValid =
true;
563 scaleData.doAutoScale =
false;
617 origin = ::fmod( origin, 2 *
M_PI );
653 zoomFactor = qAbs( zoomFactor );
713 return scaleMap( scaleId, pr.width() / 2.0 );
764 bool ok = QWidget::event( e );
767 case QEvent::LayoutRequest:
772 case QEvent::PolishRequest:
786 QFrame::resizeEvent( e );
799 m_data->
titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
816 scaleData.minValue = 0.0;
817 scaleData.maxValue = 360.0;
818 scaleData.stepSize = 30.0;
822 scaleData.minValue = 0.0;
823 scaleData.maxValue = 1000.0;
824 scaleData.stepSize = 0.0;
827 scaleData.doAutoScale =
true;
829 scaleData.maxMinor = 5;
830 scaleData.maxMajor = 8;
832 scaleData.isValid =
false;
839 setSizePolicy( QSizePolicy::MinimumExpanding,
840 QSizePolicy::MinimumExpanding );
931 const QRectF& canvasRect )
const 933 const QRectF cr = canvasRect;
936 const double radius = pr.width() / 2.0;
941 painter->setPen( Qt::NoPen );
944 if (
qwtDistance( pr.center(), cr.topLeft() ) < radius &&
945 qwtDistance( pr.center(), cr.topRight() ) < radius &&
946 qwtDistance( pr.center(), cr.bottomRight() ) < radius &&
947 qwtDistance( pr.center(), cr.bottomLeft() ) < radius )
953 painter->setRenderHint( QPainter::Antialiasing,
true );
962 pr.center(), radius, canvasRect );
977 const QPointF& pole,
double radius,
978 const QRectF& canvasRect )
const 980 const QRectF pr =
plotRect( canvasRect );
984 it != itmList.end(); ++it )
994 bool doClipping =
false;
1004 if ( radialMap.
s1() < radialMap.
s2() )
1005 doClipping = intv.
maxValue() > radialMap.
s2();
1007 doClipping = intv.
minValue() < radialMap.
s2();
1015 const QRectF clipRect = pr.adjusted(
1016 -margin, -margin, margin, margin );
1017 if ( !clipRect.contains( canvasRect ) )
1019 QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
1020 painter->setClipRegion( clipRegion, Qt::IntersectClip );
1024 painter->setRenderHint( QPainter::Antialiasing,
1027 item->
draw( painter, azimuthMap, radialMap,
1028 pole, radius, canvasRect );
1047 double minValue = d.minValue;
1048 double maxValue = d.maxValue;
1049 double stepSize = d.stepSize;
1057 it != itmList.end(); ++it )
1067 d.scaleEngine->autoScale( d.maxMajor,
1068 minValue, maxValue, stepSize );
1074 d.scaleDiv = d.scaleEngine->divideScale(
1075 minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
1083 it != itmList.end(); ++it )
1100 it != itmList.end(); ++it )
1106 if ( hint > margin )
1139 const QRectF cr = canvasRect;
1140 const int radius = qMin( cr.width(), cr.height() ) / 2 - margin;
1147 double v = map.s1();
1148 if ( map.s1() <= map.s2() )
1152 v = map.transform( v );
1157 QPointF
center( cr.center().x(), cr.top() + margin + radius );
1158 center -= QPointF( off.x(), -off.y() );
1160 QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
1161 rect.moveCenter( center );
1174 const QRectF cRect =
canvas()->contentsRect();
1175 const QRectF pRect =
plotRect( cRect );
1176 if ( cRect.contains( pRect ) || !cRect.intersects( pRect ) )
1181 const QPointF pole = pRect.center();
1182 const QRectF scaleRect = pRect & cRect;
1188 if ( scaleRect.contains( pole ) )
1193 corners[0] = scaleRect.bottomRight();
1194 corners[1] = scaleRect.topRight();
1195 corners[2] = scaleRect.topLeft();
1196 corners[3] = scaleRect.bottomLeft();
1199 for (
int i = 0; i < 4; i++ )
1201 const double dist =
qwtDistance( pole, corners[i] );
1208 if ( pole.x() < scaleRect.left() )
1210 if ( pole.y() < scaleRect.top() )
1213 dmax =
qwtDistance( pole, scaleRect.bottomRight() );
1215 else if ( pole.y() > scaleRect.bottom() )
1217 dmin =
qwtDistance( pole, scaleRect.bottomLeft() );
1222 dmin = scaleRect.left() - pole.x();
1223 dmax = qMax(
qwtDistance( pole, scaleRect.bottomRight() ),
1227 else if ( pole.x() > scaleRect.right() )
1229 if ( pole.y() < scaleRect.top() )
1232 dmax =
qwtDistance( pole, scaleRect.bottomLeft() );
1234 else if ( pole.y() > scaleRect.bottom() )
1236 dmin =
qwtDistance( pole, scaleRect.bottomRight() );
1241 dmin = pole.x() - scaleRect.right();
1242 dmax = qMax(
qwtDistance( pole, scaleRect.bottomLeft() ),
1246 else if ( pole.y() < scaleRect.top() )
1248 dmin = scaleRect.top() - pole.y();
1249 dmax = qMax(
qwtDistance( pole, scaleRect.bottomLeft() ),
1252 else if ( pole.y() > scaleRect.bottom() )
1254 dmin = pole.y() - scaleRect.bottom();
1255 dmax = qMax(
qwtDistance( pole, scaleRect.topLeft() ),
1260 const double radius = pRect.width() / 2.0;
1261 if ( dmax > radius )
1312 const QVariant itemInfo =
itemToInfo( plotItem );
1339 return QVariant::fromValue( plotItem );
1366 #include "moc_qwt_polar_plot.cpp" double invTransform(double p) const
int scaleMaxMinor(int scaleId) const
double lowerBound() const
virtual bool event(QEvent *) QWT_OVERRIDE
Qt event handler.
void setScaleMaxMajor(int scaleId, int maxMajor)
bool testRenderHint(RenderHint) const
The legend will be between canvas and title.
virtual void drawItems(QPainter *painter, const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap, const QPointF &pole, double radius, const QRectF &canvasRect) const
const QwtScaleDiv * scaleDiv(int scaleId) const
Return the scale division of a specified scale.
A point in polar coordinates.
const QBrush & plotBackground() const
Unspecific value, that can be used, when it doesn't matter.
static double qwtDistance(const QPointF &p1, const QPointF &p2)
void updateScale(int scaleId)
double radius() const
Returns the radius.
bool isValid(int axisPos)
QwtPolarLayout * plotLayout()
A Widget which displays a QwtText.
A class representing an interval.
void setRenderFlags(int)
Change the render flags.
QwtPolarCanvas * canvas()
The legend will be below the canvas.
virtual void updateLayout()
Rebuild the layout.
const QRectF & titleRect() const
QwtScaleMap scaleMap(int scaleId, double radius) const
void removeItem(QwtPolarItem *)
virtual void draw(QPainter *painter, const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, double radius, const QRectF &canvasRect) const =0
Draw the item.
virtual void activate(const QwtPolarPlot *, const QRectF &rect, Options options=Options())
Recalculate the geometry of all components.
ScaleData scaleData[QwtPolar::ScaleCount]
A class representing a scale division.
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, const QwtInterval &)
Update the item to changes of the axes scale division.
void detachItems(int rtti=QwtPolarItem::Rtti_PolarItem, bool autoDelete=true)
QwtPolarPlot::LegendPosition legendPosition() const
void setScaleEngine(int scaleId, QwtScaleEngine *)
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
bool hasAutoScale(int scaleId) const
virtual void drawCanvas(QPainter *, const QRectF &) const
QwtScaleEngine * scaleEngine(int scaleId)
The legend will be right from the canvas.
void setAutoReplot(bool tf=true)
Set or reset the autoReplot option.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Base class for items on a polar plot.
void insertItem(QwtPolarItem *)
double azimuthOrigin() const
virtual QwtInterval boundingInterval(int scaleId) const
QList< QwtPolarItem *>::ConstIterator QwtPolarItemIterator
QPointer< QwtTextLabel > titleLabel
void zoom(const QwtPointPolar &, double factor)
Translate and in/decrease the zoom factor.
const QRectF & legendRect() const
QwtPolarPlot(QWidget *parent=NULL)
void setTransformation(QwtTransform *)
bool isValid() const
Returns true if radius() >= 0.0.
QPointer< QwtPolarCanvas > canvas
virtual QwtPolarItem * infoToItem(const QVariant &) const
Identify the plot item according to an item info object, that has bee generated from itemToInfo()...
void setPaintInterval(double p1, double p2)
Specify the borders of the paint device interval.
QwtTextLabel * titleLabel()
A class representing a text.
void autoRefresh()
Replots the plot if QwtPlot::autoReplot() is true.
virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE
Resize and update internal layout.
int plotMarginHint() const
void setScale(int scaleId, double min, double max, double step=0)
Disable autoscaling and specify a fixed scale for a selected scale.
void setScaleDiv(int scaleId, const QwtScaleDiv &)
Disable autoscaling and specify a fixed scale for a selected scale.
void attachItem(QwtPolarItem *, bool)
Attach/Detach a plot item.
Canvas of a QwtPolarPlot.
double azimuth() const
Returns the azimuth.
void insertLegend(QwtAbstractLegend *, LegendPosition=RightLegend, double ratio=-1.0)
Insert a legend.
virtual int marginHint() const
void setAzimuthOrigin(double)
Change the origin of the azimuth scale.
static void drawEllipse(QPainter *, const QRectF &)
Wrapper for QPainter::drawEllipse()
void itemAttached(QwtPolarItem *plotItem, bool on)
QwtPointPolar zoomPos() const
void setAutoScale(int scaleId)
Enable autoscaling.
QwtAbstractLegend * legend()
static void drawRect(QPainter *, qreal x, qreal y, qreal w, qreal h)
Wrapper for QPainter::drawRect()
QPointer< QwtAbstractLegend > legend
virtual QVariant itemToInfo(QwtPolarItem *) const
Build an information, that can be used to identify a plot item on the legend.
Abstract base class for legend widgets.
void setTitle(const QString &)
virtual ~QwtPolarPlot()
Destructor.
The legend will be left from the canvas.
int scaleMaxMajor(int scaleId) const
double zoomFactor() const
void setLegendPosition(QwtPolarPlot::LegendPosition pos, double ratio)
Specify the position of the legend.
The item is represented on the legend.
void setMaxColumns(uint numColums)
Set the maximum number of entries in a row.
bool testItemAttribute(ItemAttribute) const
A scale engine for linear scales.
void setPlotBackground(const QBrush &c)
Set the background of the plot area.
double upperBound() const
const QRectF & canvasRect() const
QwtInterval visibleInterval() const
const QwtPolarItemList & itemList() const
A QwtPolarItemList of all attached plot items.
void initPlot(const QwtText &)
Layout class for QwtPolarPlot.
virtual void replot()
Redraw the plot.
void setScaleMaxMinor(int scaleId, int maxMinor)
QwtTransform * transformation() const
Base class for scale engines.