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 );
120 if ( !title.isEmpty() )
253 it != itmList.end(); ++it )
267 if ( plotItem == NULL )
275 const QVariant itemInfo =
itemToInfo( const_cast< QwtPolarItem *>( plotItem) );
403 maxMinor = qBound( 0, maxMinor, 100 );
407 if ( maxMinor != scaleData.
maxMinor )
440 maxMajor = qBound( 1, maxMajor, 10000 );
443 if ( maxMajor != scaleData.
maxMinor )
479 if ( scaleEngine == NULL || scaleEngine == scaleData.
scaleEngine )
528 double min,
double max,
double stepSize )
614 origin = ::fmod( origin, 2 *
M_PI );
650 zoomFactor = qAbs( zoomFactor );
710 return scaleMap( scaleId, pr.width() / 2.0 );
761 bool ok = QWidget::event( e );
764 case QEvent::LayoutRequest:
769 case QEvent::PolishRequest:
783 QFrame::resizeEvent( e );
796 d_data->
titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
836 setSizePolicy( QSizePolicy::MinimumExpanding,
837 QSizePolicy::MinimumExpanding );
928 const QRectF &canvasRect )
const 930 const QRectF cr = canvasRect;
933 const double radius = pr.width() / 2.0;
938 painter->setPen( Qt::NoPen );
941 if (
qwtDistance( pr.center(), cr.topLeft() ) < radius &&
942 qwtDistance( pr.center(), cr.topRight() ) < radius &&
943 qwtDistance( pr.center(), cr.bottomRight() ) < radius &&
944 qwtDistance( pr.center(), cr.bottomLeft() ) < radius )
950 painter->setRenderHint( QPainter::Antialiasing,
true );
959 pr.center(), radius, canvasRect );
974 const QPointF &pole,
double radius,
975 const QRectF &canvasRect )
const 977 const QRectF pr =
plotRect( canvasRect );
981 it != itmList.end(); ++it )
991 bool doClipping =
false;
1001 if ( radialMap.
s1() < radialMap.
s2() )
1002 doClipping = intv.
maxValue() > radialMap.
s2();
1004 doClipping = intv.
minValue() < radialMap.
s2();
1012 const QRectF clipRect = pr.adjusted(
1013 -margin, -margin, margin, margin );
1014 if ( !clipRect.contains( canvasRect ) )
1016 QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
1017 painter->setClipRegion( clipRegion, Qt::IntersectClip );
1021 painter->setRenderHint( QPainter::Antialiasing,
1024 item->
draw( painter, azimuthMap, radialMap,
1025 pole, radius, canvasRect );
1054 it != itmList.end(); ++it )
1065 minValue, maxValue, stepSize );
1080 it != itmList.end(); ++it )
1097 it != itmList.end(); ++it )
1103 if ( hint > margin )
1136 const QRectF cr = canvasRect;
1137 const int radius = qMin( cr.width(), cr.height() ) / 2 - margin;
1144 double v = map.s1();
1145 if ( map.s1() <= map.s2() )
1149 v = map.transform( v );
1154 QPointF
center( cr.center().x(), cr.top() + margin + radius );
1155 center -= QPointF( off.x(), -off.y() );
1157 QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
1158 rect.moveCenter( center );
1171 const QRectF cRect =
canvas()->contentsRect();
1172 const QRectF pRect =
plotRect( cRect );
1173 if ( cRect.contains( pRect ) || !cRect.intersects( pRect ) )
1178 const QPointF pole = pRect.center();
1179 const QRectF scaleRect = pRect & cRect;
1185 if ( scaleRect.contains( pole ) )
1190 corners[0] = scaleRect.bottomRight();
1191 corners[1] = scaleRect.topRight();
1192 corners[2] = scaleRect.topLeft();
1193 corners[3] = scaleRect.bottomLeft();
1196 for (
int i = 0; i < 4; i++ )
1198 const double dist =
qwtDistance( pole, corners[i] );
1205 if ( pole.x() < scaleRect.left() )
1207 if ( pole.y() < scaleRect.top() )
1210 dmax =
qwtDistance( pole, scaleRect.bottomRight() );
1212 else if ( pole.y() > scaleRect.bottom() )
1214 dmin =
qwtDistance( pole, scaleRect.bottomLeft() );
1219 dmin = scaleRect.left() - pole.x();
1220 dmax = qMax(
qwtDistance( pole, scaleRect.bottomRight() ),
1224 else if ( pole.x() > scaleRect.right() )
1226 if ( pole.y() < scaleRect.top() )
1229 dmax =
qwtDistance( pole, scaleRect.bottomLeft() );
1231 else if ( pole.y() > scaleRect.bottom() )
1233 dmin =
qwtDistance( pole, scaleRect.bottomRight() );
1238 dmin = pole.x() - scaleRect.right();
1239 dmax = qMax(
qwtDistance( pole, scaleRect.bottomLeft() ),
1243 else if ( pole.y() < scaleRect.top() )
1245 dmin = scaleRect.top() - pole.y();
1246 dmax = qMax(
qwtDistance( pole, scaleRect.bottomLeft() ),
1249 else if ( pole.y() > scaleRect.bottom() )
1251 dmin = pole.y() - scaleRect.bottom();
1252 dmax = qMax(
qwtDistance( pole, scaleRect.topLeft() ),
1257 const double radius = pRect.width() / 2.0;
1258 if ( dmax > radius )
1309 const QVariant itemInfo =
itemToInfo( plotItem );
1336 return QVariant::fromValue( plotItem );
1363 #include "moc_qwt_polar_plot.cpp" const QRectF & legendRect() const
virtual bool event(QEvent *) QWT_OVERRIDE
Qt event handler.
void setScaleMaxMajor(int scaleId, int maxMajor)
const QRectF & canvasRect() const
The legend will be between canvas and title.
double zoomFactor() const
QPointer< QwtAbstractLegend > legend
virtual QwtInterval boundingInterval(int scaleId) const
A point in polar coordinates.
bool testItemAttribute(ItemAttribute) 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)
QwtPolarLayout * plotLayout()
A Widget which displays a QwtText.
A class representing an interval.
virtual QVariant itemToInfo(QwtPolarItem *) const
Build an information, that can be used to identify a plot item on the legend.
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
double radius() const
Returns the radius.
void removeItem(QwtPolarItem *)
virtual void drawCanvas(QPainter *, const QRectF &) const
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 void drawItems(QPainter *painter, const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap, const QPointF &pole, double radius, const QRectF &canvasRect) const
bool hasAutoScale(int scaleId) const
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
QwtPointPolar zoomPos() const
QwtTransform * transformation() const
double azimuth() const
Returns the azimuth.
QwtScaleMap scaleMap(int scaleId, double radius) const
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)
void setScaleEngine(int scaleId, QwtScaleEngine *)
void legendDataChanged(const QVariant &itemInfo, const QList< QwtLegendData > &data)
double upperBound() const
QwtScaleEngine * scaleEngine(int scaleId)
The legend will be right from the canvas.
void setAutoReplot(bool tf=true)
Set or reset the autoReplot option.
QwtPolarPlot::LegendPosition legendPosition() const
Base class for items on a polar plot.
void insertItem(QwtPolarItem *)
int plotMarginHint() const
void zoom(const QwtPointPolar &, double factor)
Translate and in/decrease the zoom factor.
bool testRenderHint(RenderHint) const
QwtPolarPlot(QWidget *parent=NULL)
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
double lowerBound() const
void setTransformation(QwtTransform *)
void setPaintInterval(double p1, double p2)
Specify the borders of the paint device interval.
const QwtScaleDiv * scaleDiv(int scaleId) const
Return the scale division of a specified scale.
QPointer< QwtPolarCanvas > canvas
QwtTextLabel * titleLabel()
A class representing a text.
QPointer< QwtTextLabel > titleLabel
void autoRefresh()
Replots the plot if QwtPlot::autoReplot() is true.
virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE
Resize and update internal layout.
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.
QList< QwtPolarItem * >::ConstIterator QwtPolarItemIterator
void attachItem(QwtPolarItem *, bool)
Attach/Detach a plot item.
Canvas of a QwtPolarPlot.
virtual QwtPolarItem * infoToItem(const QVariant &) const
Identify the plot item according to an item info object, that has bee generated from itemToInfo()...
void insertLegend(QwtAbstractLegend *, LegendPosition=RightLegend, double ratio=-1.0)
Insert a legend.
double invTransform(double p) const
bool isValid() const
Returns true if radius() >= 0.0.
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)
double azimuthOrigin() const
void setAutoScale(int scaleId)
Enable autoscaling.
QwtAbstractLegend * legend()
QwtScaleEngine * scaleEngine
static void drawRect(QPainter *, qreal x, qreal y, qreal w, qreal h)
Wrapper for QPainter::drawRect()
Abstract base class for legend widgets.
void setTitle(const QString &)
virtual ~QwtPolarPlot()
Destructor.
int scaleMaxMajor(int scaleId) const
The legend will be left from the canvas.
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
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.
A scale engine for linear scales.
void setPlotBackground(const QBrush &c)
Set the background of the plot area.
QwtInterval visibleInterval() const
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
const QBrush & plotBackground() const
void initPlot(const QwtText &)
Layout class for QwtPolarPlot.
virtual void replot()
Redraw the plot.
const QwtPolarItemList & itemList() const
A QwtPolarItemList of all attached plot items.
void setScaleMaxMinor(int scaleId, int maxMinor)
Base class for scale engines.
int scaleMaxMinor(int scaleId) const