void Plot::populate() { const double d = 900.0; const QRectF rect( 1.0, 1.0, d, d ); QPainterPath path; //path.setFillRule( Qt::WindingFill ); path.addEllipse( rect ); const QRectF rect2 = rect.adjusted( 0.2 * d, 0.3 * d, -0.22 * d, 1.5 * d ); path.addEllipse( rect2 ); #if 0 QFont font; font.setPointSizeF( 200 ); QPainterPath textPath; textPath.addText( rect.center(), font, "Seppi" ); QTransform transform; transform.translate( rect.center().x() - 600, rect.center().y() + 50 ); transform.rotate( 180.0, Qt::XAxis ); textPath = transform.map( textPath ); path.addPath( textPath ); #endif QwtPlotShapeItem *item = new QwtPlotShapeItem( "Shape" ); item->setItemAttribute( QwtPlotItem::Legend, true ); item->setRenderHint( QwtPlotItem::RenderAntialiased, true ); #if 1 item->setRenderTolerance( 1.0 ); #endif item->setShape( path ); item->setPen( Qt::yellow ); QColor c = Qt::darkRed; c.setAlpha( 100 ); item->setBrush( c ); item->attach( this ); }
void Plot::addShape( const QString &title, ShapeFactory::Shape shape, const QColor &color, const QPointF &pos, const QSizeF &size ) { QwtPlotShapeItem *item = new QwtPlotShapeItem( title ); item->setItemAttribute( QwtPlotItem::Legend, true ); item->setLegendMode( QwtPlotShapeItem::LegendShape ); item->setLegendIconSize( QSize( 20, 20 ) ); item->setRenderHint( QwtPlotItem::RenderAntialiased, true ); item->setShape( ShapeFactory::path( shape, pos, size ) ); QColor fillColor = color; fillColor.setAlpha( 200 ); QPen pen( color, 3 ); pen.setJoinStyle( Qt::MiterJoin ); item->setPen( pen ); item->setBrush( fillColor ); item->attach( this ); }