void QwtPolarPlot::updateScale( int scaleId ) { if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) return; ScaleData &d = d_data->scaleData[scaleId]; double minValue = d.minValue; double maxValue = d.maxValue; double stepSize = d.stepSize; if ( scaleId == QwtPolar::ScaleRadius && d.doAutoScale ) { QwtDoubleInterval interval; const QwtPolarItemList& itmList = itemList(); for ( QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { const QwtPolarItem *item = *it; if ( item->testItemAttribute( QwtPolarItem::AutoScale ) ) interval |= item->boundingInterval( scaleId ); } minValue = interval.minValue(); maxValue = interval.maxValue(); d.scaleEngine->autoScale( d.maxMajor, minValue, maxValue, stepSize ); d.scaleDiv.invalidate(); } if ( !d.scaleDiv.isValid() ) { d.scaleDiv = d.scaleEngine->divideScale( minValue, maxValue, d.maxMajor, d.maxMinor, stepSize ); } const QwtDoubleInterval interval = visibleInterval(); const QwtPolarItemList& itmList = itemList(); for ( QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { QwtPolarItem *item = *it; item->updateScaleDiv( *scaleDiv( QwtPolar::Azimuth ), *scaleDiv( QwtPolar::Radius ), interval ); } }
/*! \return Maximum of all item margin hints. \sa QwtPolarItem::marhinHint() */ int QwtPolarPlot::plotMarginHint() const { int margin = 0; const QwtPolarItemList& itmList = itemList(); for ( QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { QwtPolarItem *item = *it; if ( item && item->isVisible() ) { const int hint = item->marginHint(); if ( hint > margin ) margin = hint; } } return margin; }
/*! Detach items from the dictionary \param rtti In case of QwtPolarItem::Rtti_PlotItem detach all items otherwise only those items of the type rtti. \param autoDelete If true, delete all detached items */ void QwtPolarItemDict::detachItems( int rtti, bool autoDelete ) { PrivateData::ItemList list = d_data->itemList; QwtPolarItemIterator it = list.begin(); while ( it != list.end() ) { QwtPolarItem *item = *it; ++it; // increment before removing item from the list if ( rtti == QwtPolarItem::Rtti_PolarItem || item->rtti() == rtti ) { item->attach( NULL ); if ( autoDelete ) delete item; } } }
/*! Redraw the canvas items. \param painter Painter used for drawing \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI \param radialMap Maps radius values into painter coordinates. \param pole Position of the pole in painter coordinates \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ void QwtPolarPlot::drawItems( QPainter *painter, const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, double radius, const QRectF &canvasRect ) const { const QRectF pr = plotRect( canvasRect ); const QwtPolarItemList& itmList = itemList(); for ( QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { QwtPolarItem *item = *it; if ( item && item->isVisible() ) { painter->save(); // Unfortunately circular clipping slows down // painting a lot. So we better try to avoid it. bool doClipping = false; if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid ) { const QwtInterval intv = item->boundingInterval( QwtPolar::Radius ); if ( !intv.isValid() ) doClipping = true; else { if ( radialMap.s1() < radialMap.s2() ) doClipping = intv.maxValue() > radialMap.s2(); else doClipping = intv.minValue() < radialMap.s2(); } } if ( doClipping ) { const int margin = item->marginHint(); const QRectF clipRect = pr.adjusted( -margin, -margin, margin, margin ); if ( !clipRect.contains( canvasRect ) ) { QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse ); painter->setClipRegion( clipRegion, Qt::IntersectClip ); } } painter->setRenderHint( QPainter::Antialiasing, item->testRenderHint( QwtPolarItem::RenderAntialiased ) ); item->draw( painter, azimuthMap, radialMap, pole, radius, canvasRect ); painter->restore(); } } }