void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings )
{
  if ( !p )
  {
    return;
  }

  if ( rings == NULL )
  {
    // simple polygon without holes
    p->drawPolygon( points );
  }
  else
  {
    // polygon with holes must be drawn using painter path
    QPainterPath path;
    QPolygonF outerRing = points;
    path.addPolygon( outerRing );

    QList<QPolygonF>::const_iterator it = rings->constBegin();
    for ( ; it != rings->constEnd(); ++it )
    {
      QPolygonF ring = *it;
      path.addPolygon( ring );
    }

    p->drawPath( path );
  }
}
QPainterPath Fidelity::GUI::ComponentLinkItem::shape() const
{
	// Reshape our line to include the arrow's head
	QPainterPath path = QGraphicsLineItem::shape();
	path.addPolygon(m_StartArrowHead);
	path.addPolygon(m_EndArrowHead);

	return(path);
}
QPainterPath CopyFilterGUIConnectionItem::shape() const
{
	QLineF l = line();

	QPainterPath path;
	path.setFillRule(Qt::WindingFill);
	double length = line().length();
	if (length > 0)
	{
		double offset = min(length, maxArrowSize);
		QLineF unit = l.unitVector();
		QLineF normal = l.normalVector().unitVector();
		QPointF v(unit.dx(), unit.dy());
		QPointF n(normal.dx(), normal.dy());
		QPointF p2 = l.p2();

		QPointF p3 = p2 - v * offset + 0.5 * n * offset;
		QPointF p4 = p2 - v * offset - 0.5 * n * offset;
		QPolygonF polygon;
		polygon.append(p4);
		polygon.append(p3);
		polygon.append(p2);
		path.addPolygon(polygon);

		QPolygonF polygon2;
		QPointF p1 = l.p1();
		polygon2.append(p2 + 3 * n);
		polygon2.append(p2 - 2 * n);
		polygon2.append(p1 - 2 * n);
		polygon2.append(p1 + 3 * n);
		path.addPolygon(polygon2);

		if (factor != 1.0 || isDecibel)
		{
			QFont font;
			font.setPixelSize(10);
			QPointF center = (l.p1() + l.p2()) / 2;
			QString text = QString("%1").arg(factor);
			if (isDecibel)
				text += " dB";

			QFontMetrics fontMetrics(font);
			QSizeF size = fontMetrics.size(0, text);
			size += QSizeF(2, 0);
			QRectF rect;
			rect.setSize(size);
			rect.moveCenter(center);
			path.addRoundedRect(rect.adjusted(-0.5, 0.5, 0.5, 0.5), 3, 3);
		}
	}

	return path;
}
QPainterPath OrthogonalRenderer::shape(const MapObject *object) const
{
    QPainterPath path;

    if (!object->cell().isEmpty()) {
        path.addRect(boundingRect(object));
    } else {
        switch (object->shape()) {
        case MapObject::Rectangle: {
            const QRectF bounds = object->bounds();
            const QRectF rect(tileToPixelCoords(bounds.topLeft()),
                              tileToPixelCoords(bounds.bottomRight()));

            if (rect.isNull()) {
                path.addEllipse(rect.topLeft(), 20, 20);
            } else {
                path.addRoundedRect(rect, 10, 10);
            }
            break;
        }
        case MapObject::Polygon:
        case MapObject::Polyline: {
            const QPointF &pos = object->position();
            const QPolygonF polygon = object->polygon().translated(pos);
            const QPolygonF screenPolygon = tileToPixelCoords(polygon);
            if (object->shape() == MapObject::Polygon) {
                path.addPolygon(screenPolygon);
            } else {
                for (int i = 1; i < screenPolygon.size(); ++i) {
                    path.addPolygon(lineToPolygon(screenPolygon[i - 1],
                                                  screenPolygon[i]));
                }
                path.setFillRule(Qt::WindingFill);
            }
            break;
        }
        case MapObject::Ellipse: {
            const QRectF bounds = object->bounds();
            const QRectF rect(tileToPixelCoords(bounds.topLeft()),
                              tileToPixelCoords(bounds.bottomRight()));

            if (rect.isNull()) {
                path.addEllipse(rect.topLeft(), 20, 20);
            } else {
                path.addEllipse(rect);
            }
            break;
        }
        }
    }

    return path;
}
Exemple #5
0
QPainterPath ArrowItem::shape() const {
  QPainterPath selectPath;
  selectPath.setFillRule(Qt::WindingFill);
  selectPath.addPolygon(rect());
  selectPath.addPolygon(start);
  selectPath.addPolygon(end);
  if ((!isSelected() && !isHovering()) || (view()->mouseMode() == View::Create)) {
  } else {
    selectPath.addPath(grips());
  }
  return selectPath;
}
//! [4]
void mafNodeConnectionGraphicWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{
	Q_UNUSED(option);
    Q_UNUSED(w);

	painter->setRenderHint(QPainter::Antialiasing);

	if (mStartConnector == NULL || mEndConnector == NULL || mStartConnector->collidesWithItem(mEndConnector))
        return;

	QPointF controlPoint1;
	QPointF controlPoint2;
	recreatePath(controlPoint1, controlPoint2);
	
    if (static_cast<mafDiagramScene*>(scene())->isDebugDraw()) {
		QPen origPen = painter->pen();
		QBrush origBrush = painter->brush();
		debugPaint(painter, controlPoint1, controlPoint2);
		painter->setPen(origPen);
	    painter->setBrush(origBrush);
	}

    QPen mPen = pen();
    mPen.setColor(mColor);
    painter->setPen(mPen);
	//line
    //painter->setBrush(mColor);
	painter->setBrush(Qt::NoBrush);

	if (isSelected())
		painter->setPen(QPen(mColor, 1, Qt::DashLine));


    QPainterPath p = this->path();
	painter->drawPath(p);

	//fill
	painter->setBrush(mColor);

    QPolygonF arrowHeadEnd = createArrowPoly(p, mEndConnector);
	if (bidirectional()) {
		QPolygonF arrowHeadStart = createArrowPoly(p, mStartConnector);
		p.addPolygon(arrowHeadStart);
		painter->drawPolygon(arrowHeadStart);
	}
    p.addPolygon(arrowHeadEnd);
	painter->drawPolygon(arrowHeadEnd);
	
}
QPainterPath UBGraphicsTriangle::shape() const
{
    QPainterPath tShape;
    QPolygonF tPolygon;

    tPolygon << A1 << B1 << C1;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    tPolygon << A2 << B2 << C2;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    return tShape;
}
Exemple #8
0
QPainterPath Building::shape() const
{
    QPainterPath painterPath;
    painterPath.addPolygon(_building.toPolygonF());

    return painterPath;
}
//!
//! Returns the shape of the item as QPainterPath.
//!
//! \param The shape of the item as QPainterPath.
//!
QPainterPath ConnectionGraphicsItem::shape () const
{
    QPainterPath result;
    result.addPath(m_mainPath);
    result.addPolygon(m_arrowHeadPolygon);
    return result;
}
Exemple #10
0
QPainterPath SCgNode::shape() const
{
    QPainterPath path;
    QRectF boundRect = boundingRect();

    if (mContentVisible)
    {
        path.addRect(boundRect);
    }else
    {
        QMatrix matrix;
        switch (mConstType)
        {
        case SCgAlphabet::Const:
            path.addEllipse(boundRect);
            break;

        case SCgAlphabet::Var:
            path.addRect(boundRect);
            break;

        case SCgAlphabet::Meta:
            path.addPolygon(matrix.rotate(45.f).mapToPolygon(boundRect.toRect()));
            break;

        default:
            break;
        }
    }

    return path;
}
QPainterPath ItemPhysEnv::shape() const
{
    QPainterPath path;
    QPolygonF lineBoarder;
    QVector<qreal> points = {0.0,
                             0.0,
                             this->data(ITEM_WIDTH).toReal(),
                             this->data(ITEM_HEIGHT).toReal()};
#define PLEFT   0
#define PTOP    1
#define PRIGHT  2
#define PBOTTOM 3
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP]));
    lineBoarder.push_back(QPointF(points[PRIGHT],    points[PTOP]));
    lineBoarder.push_back(QPointF(points[PRIGHT],    points[PBOTTOM]));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PBOTTOM]));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP]));

    lineBoarder.push_back(QPointF(points[PLEFT] + 4, points[PTOP]));
    lineBoarder.push_back(QPointF(points[PLEFT] + 4, points[PBOTTOM] - 4));
    lineBoarder.push_back(QPointF(points[PRIGHT] - 4,points[PBOTTOM] - 4));
    lineBoarder.push_back(QPointF(points[PRIGHT] - 4,points[PTOP] + 4));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP] + 4));
#undef PLEFT
#undef PTOP
#undef PRIGHT
#undef PBOTTOM

    path.addPolygon(lineBoarder);
    return path;
}
Exemple #12
0
/**
 * @brief Hex::shape	Zwraca dokładne ograniczenie hexa, sześciąkąt foremny, który zawiera hex.
 * @return		QPainterPath z ograniczeniem hexa.
 */
QPainterPath Tile::shape() const
{
    QPainterPath result;
    result.addPolygon(QPolygonF(tileVertices(1)));
    result.closeSubpath();
    return result;
}
Exemple #13
0
void QChain::cutCircle(Circle circle) {
  if (m_vertices.size() == 0) return;
  circle.setCenter(circle.pos());

  QPainterPath cr;
  cr.addEllipse(circle.x - circle.r, circle.y - circle.r, 2 * circle.r,
                2 * circle.r);

  QPolygonF polygon;
  for (QPointF p : m_vertices) polygon.append(p);
  QPainterPath chain;
  chain.addPolygon(polygon);

  if (!chain.intersects(cr)) return;

  chain = chain.subtracted(cr);

  for (const QPolygonF &poly : chain.toSubpathPolygons()) {
    std::vector<Vector2d> pts(poly.begin(), poly.end() - 1);

    if (std::fabs(Geometry::area(pts.begin(), pts.end())) > 5.f) {
      auto chain = std::make_unique<QChain>(world());
      chain->setVertices(std::vector<QPointF>(pts.begin(), pts.end()));
      chain->initializeLater(world());

      world()->itemSet()->addBody(std::move(chain));
    }
  }

  m_vertices.clear();
  destroyLater();
}
Exemple #14
0
int PainterPath::addPolygon(lua_State * L) // ( const QPolygonF & polygon )
{
	QPainterPath* lhs = ValueInstaller2<QPainterPath>::check( L, 1 );
	QPolygonF* polygon = ValueInstaller2<QPolygonF>::check( L, 2 );
	lhs->addPolygon( *polygon );
	return 0;
}
//----------------------------------------------------------------------------------------------
QPainterPath GraphEdgeView::shape() const
{
    QPainterPath path;// = QGraphicsLineItem::shape();

    QLineF normal = this->line().unitVector().normalVector();
    qreal dx = normal.dx();
    qreal dy = normal.dy();

    QLineF myLine;

    myLine = this->line();
    myLine.translate(dx * 4, dy * 4);
    path.lineTo(myLine.p1());
    path.lineTo(myLine.p2());

    myLine = this->line();
    myLine.translate(-dx * 4,-dy * 4);
    path.lineTo(myLine.p2());
    path.lineTo(myLine.p1());
    path.closeSubpath();

    path.addPolygon(m_arrowHead);

    return path;
}
/*!
  \brief Set a path built from a polygon

  \param polygon Polygon
  \sa setShape(), setRect(), shape()
 */
void QwtPlotShapeItem::setPolygon( const QPolygonF &polygon )
{
    QPainterPath shape;
    shape.addPolygon( polygon );

    setShape( shape );
}
void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
{
    Q_D(QAlphaPaintEngine);

    QPolygonF poly;
    for (int i=0; i<pointCount; ++i)
        poly.append(points[i]);

    QPainterPath path;
    path.addPolygon(poly);
    QRectF tr = d->addPenWidth(path);

    if (d->m_pass == 0) {
        d->m_continueCall = false;
        if (d->canSeeTroughBackground(d->m_hasalpha, tr) || d->m_advancedPen || d->m_advancedBrush
            || d->m_emulateProjectiveTransforms)
        {
            d->addAlphaRect(tr);
        }

        d->addDirtyRect(tr);

        if (d->m_picengine)
            d->m_picengine->drawPolygon(points, pointCount, mode);
    } else {
        d->m_continueCall = !d->fullyContained(tr);
    }
}
Exemple #18
0
QPainterPath QGVCore::toPath(const char *type, const polygon_t *poly, qreal width, qreal height)
{
    QPainterPath path;
    if ((strcmp(type, "rectangle") == 0) ||
            (strcmp(type, "box") == 0) ||
            (strcmp(type, "hexagon") == 0) ||
            (strcmp(type, "polygon") == 0) ||
            (strcmp(type, "diamond") == 0))
    {
        QPolygonF polygon = toPolygon(poly, width, height);
        polygon.append(polygon[0]);
        path.addPolygon(polygon);
    }
    else if ((strcmp(type, "ellipse") == 0) ||
             (strcmp(type, "circle") == 0))
    {
        QPolygonF polygon = toPolygon(poly, width, height);
        path.addEllipse(QRectF(polygon[0], polygon[1]));
    }
    else
    {
        qWarning("unsupported shape %s", type);
    }
    return path;
}
Exemple #19
0
bool FlattenPathPlugin::run(ScribusDoc* doc, QString)
{
    ScribusDoc* currDoc = doc;
    if (currDoc == 0)
        currDoc = ScCore->primaryMainWindow()->doc;
    if (currDoc->m_Selection->count() > 0)
    {
        PageItem *currItem = currDoc->m_Selection->itemAt(0);
        QPainterPath pp;
        if (currItem->itemType() == PageItem::PolyLine)
            pp = currItem->PoLine.toQPainterPath(false);
        else
            pp = currItem->PoLine.toQPainterPath(true);
        QList<QPolygonF> polyList = pp.toSubpathPolygons();
        QPainterPath result;
        for (int a = 0; a < polyList.count(); a++)
        {
            result.addPolygon(polyList[a]);
        }
        currItem->PoLine.fromQPainterPath(result);
        currItem->ClipEdited = true;
        currItem->FrameType = 3;
        currDoc->AdjustItemSize(currItem);
        currItem->OldB2 = currItem->width();
        currItem->OldH2 = currItem->height();
        currItem->updateClip();
        currDoc->regionsChanged()->update(QRectF());
        currDoc->changed();
    }
    return true;
}
Exemple #20
0
QPainterPath Draw_Line::getPolyLine(int indx,QPointF pnt1,QPointF pnt2)
{
    if(indx==0)
    {
       poly_pnts[0]-=(pnt1-pnt2);
       poly_pnts[poly_pnts.size()]-=(pnt1-pnt2);
    }
    else
       poly_pnts[indx]-=(pnt1-pnt2);

    QPainterPath polygon;

    if(!poly_pnts.isEmpty())
    {
        QPolygonF polygon_pnts(poly_pnts);
        polygon.addPolygon(polygon_pnts);
    }


    pnt1.setX(((polygon.boundingRect().topLeft().x()+polygon.boundingRect().bottomRight().x())/2)-5);
    pnt1.setY(polygon.boundingRect().topLeft().y()-20);

    pnt2.setX(((polygon.boundingRect().topLeft().x()+polygon.boundingRect().bottomRight().x())/2)+5);
    pnt2.setY(polygon.boundingRect().topLeft().y()-10);

    Rot_Rect->setRect(QRectF(pnt1,pnt2));

    return polygon;
}
Exemple #21
0
void GraphicMoteur::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    qreal x = _dp.x();
    qreal y = _dp.y();

    QPolygonF polygone1, polygone2;

    QLineF line1(x+9, y+32, x+15, y+32);
    QLineF line2(x+31, y+32, x+25, y+32);

    polygone1 << QPointF(x, y) << QPointF(x+40, y) << QPointF(x+40, y+13) << QPointF(x, y+13);

    polygone2 << QPointF(x+6, y+13) << QPointF(x+34, y+13) << QPointF(x+34, y+25) << QPointF(x+28, y+48)
              << QPointF(x+12, y+48) << QPointF(x+6, y+25);

    painter->setPen(pen);

    painter->drawText(x+14, y+11, _nom);

    QPainterPath path;
    path.addPolygon(polygone2);

    painter->fillPath(path, brushDefault);

    painter->drawPolygon(polygone1);
    painter->drawPolygon(polygone2);
    painter->drawLine(line1);
    painter->drawLine(line2);
}
		/// Draw.
		void Shape2DFree::drawShape(QPainter& painter) const
		{
			QPainterPath path;
			path.addPolygon(m_polygon);
			painter.fillPath(path, m_fill_color);
			painter.drawPath(m_outline);
		}
void LineDiagram::LineDiagramType::paintAreas(
    PaintContext* ctx,
    const QModelIndex& index, const QList< QPolygonF >& areas,
    const uint transparency )
{
    QColor trans = diagram()->brush( index ).color();
    trans.setAlpha( transparency );
    QPen indexPen = diagram()->pen(index);
    indexPen.setColor( trans );
    const PainterSaver painterSaver( ctx->painter() );

    if( diagram()->antiAliasing() )
        ctx->painter()->setRenderHint( QPainter::Antialiasing );

    ctx->painter()->setPen( PrintingParameters::scalePen( indexPen ) );
    ctx->painter()->setBrush( trans );

    QPainterPath path;
    for( int i = 0; i < areas.count(); ++i )
    {
        const QPolygonF& p = areas[ i ];
        path.addPolygon( p );
        reverseMapper().addPolygon( index.row(), index.column(), p );
        path.closeSubpath();
    }
    ctx->painter()->drawPath( path );
}
Exemple #24
0
void Dialog::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);

    // make our polygon
    QPolygon poly;
    poly << QPoint(10, 10);
    poly << QPoint(10, 100);
    poly << QPoint(100, 10);
    poly << QPoint(100, 100);

    // make a pen
    QPen linePen;
    linePen.setWidth(8);
    linePen.setColor(Qt::red);
    //linePen.setJoinStyle(Qt::RoundJoin);
    linePen.setJoinStyle(Qt::MiterJoin);
    linePen.setStyle(Qt::DotLine);
    painter.setPen(linePen);

    // make a brush
    QBrush fillBrush;
    fillBrush.setColor(Qt::green);
    fillBrush.setStyle(Qt::SolidPattern);

    // fill the polygon
    QPainterPath path;
    path.addPolygon(poly);
    painter.fillPath(path, fillBrush);

    // draw polygon
    painter.drawPolygon(poly);

}
Exemple #25
0
QImage VolumeSlider::generateSliderImage(const QColor& borderColor, const QColor& color0, const QColor& color1) const
{
	QSize sliderSize = QSize(width() - (margin() * 2), height() - (margin() * 2));

	QImage sliderImage = QImage(sliderSize, QImage::Format_ARGB32);
	sliderImage.fill( QColor(0, 0, 0, 0).rgba() );

	QPainter sliderPainter(&sliderImage);

	QLinearGradient sliderGradient(0, 0, width(), 0);
	sliderGradient.setColorAt(0, color0);
	sliderGradient.setColorAt(1, color1);

	QPolygonF area;
	area << QPointF(0, sliderSize.height()) << QPointF(sliderSize.width(), sliderSize.height())
		 << QPointF(sliderSize.width(), 0)  << QPointF(0, sliderSize.height() - (sliderSize.height()/3));

	QPainterPath path;
	path.addPolygon(area);
	path.closeSubpath();

	QPen pen(borderColor, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

	sliderPainter.setRenderHint(QPainter::Antialiasing);
	sliderPainter.setBrush(sliderGradient);
	sliderPainter.setPen(pen);
	sliderPainter.drawPath(path);

	return sliderImage;
};
void PolygonAnnotation::drawPolygonAnnotaion(QPainter *painter)
{
  QPainterPath path;

  switch (mFillPattern)
  {
    case Qt::LinearGradientPattern:
    case Qt::Dense1Pattern:
    case Qt::RadialGradientPattern:
      painter->setBrush(QBrush(mFillColor, Qt::SolidPattern));
      break;
    default:
      painter->setBrush(QBrush(mFillColor, mFillPattern));
      break;
  }

  qreal thickness;
  // if (mCornerRadius > 0) // this is commented intentionally so that we dont need path stroker. Also helps in svg rendering
  thickness = ceil(mThickness);

  QPen pen(mLineColor, thickness, mLinePattern);
  pen.setCosmetic(true);
  painter->setPen(pen);

  path.addPolygon(QPolygonF(mPoints));
  painter->drawPath(path);
}
Exemple #27
0
void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )
{
  // OddEven fill rule by default
  QPainterPath path;

  p->setPen( mPen );
  p->setBrush( mBrush );

  for ( int i = 0; i < polygon.size(); i++ )
  {
    if ( polygon[i].empty() ) continue;

    QPolygonF ring;
    ring.reserve( polygon[i].size() + 1 );

    for ( int j = 0; j < polygon[i].size(); j++ )
    {
      //adding point only if it is more than a pixel appart from the previous one
      const QPointF cur = toCanvasCoordinates( polygon[i][j] ) - pos();
      if ( 0 == j || std::abs( ring.back().x() - cur.x() ) > 1 || std::abs( ring.back().y() - cur.y() ) > 1 )
      {
        ring.push_back( cur );
      }
    }

    ring.push_back( ring[ 0 ] );

    path.addPolygon( ring );
  }

  p->drawPath( path );
}
void QgsComposerPolygon::_draw( QPainter *painter )
{
  //setup painter scaling to dots so that raster symbology is drawn to scale
  const double dotsPerMM = painter->device()->logicalDpiX() / 25.4;

  QgsMapSettings ms = mComposition->mapSettings();
  ms.setOutputDpi( painter->device()->logicalDpiX() );

  QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
  context.setPainter( painter );
  context.setForceVectorOutput( true );

  QScopedPointer<QgsExpressionContext> expressionContext;
  expressionContext.reset( createExpressionContext() );
  context.setExpressionContext( *expressionContext.data() );

  painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
  QTransform t = QTransform::fromScale( dotsPerMM, dotsPerMM );

  QList<QPolygonF> rings; //empty
  QPainterPath polygonPath;
  polygonPath.addPolygon( mPolygon );

  mPolygonStyleSymbol->startRender( context );
  mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
                                      nullptr, context );
  mPolygonStyleSymbol->stopRender( context );
  painter->scale( dotsPerMM, dotsPerMM );
}
Exemple #29
0
void UMLGeneralizationLine::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * parent )
{
	QPolygonF head;
	head.append( QPointF( 0.0, 0.0 ) );
	head.append( QPointF( cos( PI / 6 ), -sin( PI / 6 ) ) );
	head.append( QPointF( cos( -PI / 6 ), -sin( -PI / 6 ) ) );

	QPainterPath path;
	path.addPolygon( head );

	QTransform transform;
	transform.translate( this->line().p2().x(), this->line().p2().y() );
	transform.scale( ARROW_HEAD_SIZE, ARROW_HEAD_SIZE );
	transform.rotate( 180.0 - this->line().angle() );

	QTransform backup( painter->transform() );
	painter->setTransform( transform, true );
	painter->fillPath( path, QColor( "blue" ) );
	painter->setPen( this->pen() );
	painter->drawPolygon( head );
	painter->setTransform( backup );

	qreal triangleHeight = ::sqrt( 3.0 ) / 2.0;
	QPointF realP2( transform.map( QLineF( QPointF( 0.0, 0.0 ), QPointF( triangleHeight, 0.0 ) ) ).p2() );
	painter->drawLine( this->line().p1(), realP2 );

}
void paintAreas( AbstractDiagram::Private* diagramPrivate, PaintContext* ctx, const QModelIndex& index,
                 const QList< QPolygonF >& areas, uint opacity )
{
    AbstractDiagram* diagram = diagramPrivate->diagram;
    QPainterPath path;
    for ( int i = 0; i < areas.count(); ++i )
    {
        const QPolygonF& p = areas[ i ];
        path.addPolygon( p );
        diagramPrivate->reverseMapper.addPolygon( index.row(), index.column(), p );
        path.closeSubpath();
    }

    ThreeDLineAttributes threeDAttrs = threeDLineAttributes( diagram, index );
    QBrush trans = diagram->brush( index );
    if ( threeDAttrs.isEnabled() ) {
        trans = threeDAttrs.threeDBrush( trans, path.boundingRect() );
    }
    QColor transColor = trans.color();
    transColor.setAlpha( opacity );
    trans.setColor(transColor);
    QPen indexPen = diagram->pen(index);
    indexPen.setBrush( trans );
    const PainterSaver painterSaver( ctx->painter() );

    ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() );
    ctx->painter()->setPen( PrintingParameters::scalePen( indexPen ) );
    ctx->painter()->setBrush( trans );

    ctx->painter()->drawPath( path );
}