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;
256 it != itmList.end(); ++it )
270 if ( plotItem == NULL )
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;
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 );
713 return scaleMap( scaleId, pr.width() / 2.0 );
736 map.setTransformation(
scaleEngine( scaleId )->transformation() );
748 map.setPaintInterval( 0.0, radius );
764 bool ok = QWidget::event( e );
767 case QEvent::LayoutRequest:
772 case QEvent::PolishRequest:
786 QFrame::resizeEvent( e );
796 text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
799 m_data->
titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
800 if ( !text.isEmpty() )
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 );
1360 return qvariant_cast< QwtPolarItem* >( itemInfo );
1366 #include "moc_qwt_polar_plot.cpp"