void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount)
{
    QPen pen = state()->pen;
    if (pen.capStyle() == Qt::FlatCap)
        pen.setCapStyle(Qt::SquareCap);

    if (pen.brush().isOpaque()) {
        while (pointCount > 0) {
            int count = qMin(pointCount, 16);
            qreal pts[64];
            int oset = -1;
            for (int i=0; i<count; ++i) {
                pts[++oset] = points[i].x();
                pts[++oset] = points[i].y();
                pts[++oset] = points[i].x() + 1/63.;
                pts[++oset] = points[i].y();
            }
            QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint);
            stroke(path, pen);
            pointCount -= 16;
            points += 16;
        }
    } else {
        for (int i=0; i<pointCount; ++i) {
            qreal pts[] = { qreal(points[i].x()), qreal(points[i].y()),
                            qreal(points[i].x() +1/63.), qreal(points[i].y()) };
            QVectorPath path(pts, 2, 0);
            stroke(path, pen);
        }
    }
}
void KnotRendererBatch::PaintInterfaceData::set(int fillColour, int outlineColour, int outlineWidth, const QList< QColor > colorList)
{
    QPen pen = p->pen();
    pen.setWidth(outlineWidth);
    if (outlineColour != -1)
        pen.setColor(colorList[outlineColour]);
    else
    {
        QBrush brush = pen.brush();
        brush.setStyle(Qt::NoBrush);
        pen.setBrush(brush);
    }
    p->setPen(pen);
    
    QBrush brush = p->brush();
    if (fillColour == -1)
    {
        brush.setStyle(Qt::NoBrush);
    }
    else
    {
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(colorList[fillColour]);
    }
    p->setBrush(brush);
}
Example #3
0
qreal QSvgNode::strokeWidth(QPainter *p)
{
    QPen pen = p->pen();
    if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic())
        return 0;
    return pen.widthF();
}
Example #4
0
void tst_QPen::stream()
{
    QFETCH(QPen, pen);

    QByteArray bytes;

    {
        QDataStream stream(&bytes, QIODevice::WriteOnly);
        stream << pen;
    }

    QPen cmp;
    {
        QDataStream stream(&bytes, QIODevice::ReadOnly);
        stream >> cmp;
    }

    QCOMPARE(pen.widthF(), cmp.widthF());
    QCOMPARE(pen.style(), cmp.style());
    QCOMPARE(pen.capStyle(), cmp.capStyle());
    QCOMPARE(pen.joinStyle(), cmp.joinStyle());
    QCOMPARE(pen.brush(), cmp.brush());

    QCOMPARE(pen, cmp);
}
Example #5
0
int Pen::brush(lua_State * L) // () const : QBrush
{
    QPen* obj = QtValue<QPen>::check( L, 1 );
    QBrush* res = QtValue<QBrush>::create( L );
    *res = obj->brush();
    return 1;
}
void DrawingPolyItem::setPen(const QPen& pen)
{
	setPenColor(pen.brush().color());
	setPenWidth(pen.widthF());
	setPenStyle(pen.style());
	setPenCapStyle(pen.capStyle());
	setPenJoinStyle(pen.joinStyle());
}
void KoOdfGraphicStyles::saveOdfStrokeStyle(KoGenStyle &styleStroke, KoGenStyles &mainStyles, const QPen &pen)
{
    // TODO implement all possibilities
    switch (pen.style()) {
    case Qt::NoPen:
        styleStroke.addProperty("draw:stroke", "none");
        return;
    case Qt::SolidLine:
        styleStroke.addProperty("draw:stroke", "solid");
        break;
    default: { // must be a dashed line
        styleStroke.addProperty("draw:stroke", "dash");
        // save stroke dash (14.14.7) which is severly limited, but still
        KoGenStyle dashStyle(KoGenStyle::StrokeDashStyle);
        dashStyle.addAttribute("draw:style", "rect");
        QVector<qreal> dashes = pen.dashPattern();
        dashStyle.addAttribute("draw:dots1", static_cast<int>(1));
        dashStyle.addAttributePt("draw:dots1-length", dashes[0]*pen.widthF());
        dashStyle.addAttributePt("draw:distance", dashes[1]*pen.widthF());
        if (dashes.size() > 2) {
            dashStyle.addAttribute("draw:dots2", static_cast<int>(1));
            dashStyle.addAttributePt("draw:dots2-length", dashes[2]*pen.widthF());
        }
        QString dashStyleName = mainStyles.insert(dashStyle, "dash");
        styleStroke.addProperty("draw:stroke-dash", dashStyleName);
        break;
    }
    }

    if (pen.brush().gradient()) {
        styleStroke.addProperty("koffice:stroke-gradient", saveOdfGradientStyle(mainStyles, pen.brush()));
    }
    else {
        styleStroke.addProperty("svg:stroke-color", pen.color().name());
        styleStroke.addProperty("svg:stroke-opacity", QString("%1").arg(pen.color().alphaF()));
    }
    styleStroke.addPropertyPt("svg:stroke-width", pen.widthF());

    switch (pen.joinStyle()) {
    case Qt::MiterJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "miter");
        break;
    case Qt::BevelJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "bevel");
        break;
    case Qt::RoundJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "round");
        break;
    default:
        styleStroke.addProperty("draw:stroke-linejoin", "miter");
        styleStroke.addProperty("koffice:stroke-miterlimit", QString("%1").arg(pen.miterLimit()));
        break;
    }
}
Example #8
0
void KoShapeStroke::Private::paintBorder(KoShape *shape, QPainter &painter, const QPen &pen) const
{
    if (!pen.isCosmetic()) {
        KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
        if (pathShape) {
            QPainterPath path = pathShape->pathStroke(pen);
            painter.fillPath(path, pen.brush());
            return;
        }
        painter.strokePath(shape->outline(), pen);
    }
}
Example #9
0
static bool qwtHasScalablePen( const QPainter *painter )
{
    const QPen pen = painter->pen();

    bool scalablePen = false;

    if ( pen.style() != Qt::NoPen && pen.brush().style() != Qt::NoBrush )
    {
        scalablePen = !pen.isCosmetic();
        if ( !scalablePen && pen.widthF() == 0.0 )
        {
            const QPainter::RenderHints hints = painter->renderHints();
            if ( hints.testFlag( QPainter::NonCosmeticDefaultPen ) )
                scalablePen = true;
        }
    }

    return scalablePen;
}
Example #10
0
void TupPaintAreaCommand::redo()
{
    switch (k->event->action()) {
            case TupPaintAreaEvent::ChangePen:
                 {
                   k->oldData = k->paintArea->brushManager()->pen();
                   QPen pen = qvariant_cast<QPen>(k->event->data());
                   if (!pen.color().isValid()) {
                       QPen old = k->paintArea->brushManager()->pen();
                       pen.setColor(old.color());
                       pen.setBrush(old.brush());
                   } 
                   k->paintArea->brushManager()->setPen(pen);
                 }
                 break;
            case TupPaintAreaEvent::ChangePenColor:
                 {
                   k->oldData = k->paintArea->brushManager()->pen().color();
                   k->paintArea->brushManager()->setPenColor(qvariant_cast<QColor>(k->event->data()));
                 }
                 break;
            case TupPaintAreaEvent::ChangePenThickness:
                 {
                   k->oldData = k->paintArea->brushManager()->pen().width();
                   k->paintArea->brushManager()->setPenWidth(qvariant_cast<int>(k->event->data()));
                 }
                 break;
            case TupPaintAreaEvent::ChangeBrush:
                 {
                   k->oldData = k->paintArea->brushManager()->brush();
                   k->paintArea->brushManager()->setBrush(qvariant_cast<QBrush>(k->event->data()));
                 }
                 break;
            case TupPaintAreaEvent::ChangeBgColor:
                 {
                   k->oldData = k->paintArea->brushManager()->bgColor();
                   k->paintArea->brushManager()->setBgColor(qvariant_cast<QColor>(k->event->data()));
                 }
                 break;
            default: 
                 break;
    }
}
Example #11
0
void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) {
        QPen bgPen = pen;
        bgPen.setBrush(s->bgBrush);
        bgPen.setStyle(Qt::SolidLine);
        real_engine->stroke(path, bgPen);
    }

    QBrush brush = pen.brush();
    QPen copy = pen;
    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();

        if (g->coordinateMode() > QGradient::LogicalMode) {
            if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
                QTransform mat = brush.transform();
                mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height());
                brush.setTransform(mat);
                copy.setBrush(brush);
                real_engine->stroke(path, copy);
                return;
            } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
                QTransform mat = brush.transform();
                QRectF r = path.controlPointRect();
                mat.translate(r.x(), r.y());
                mat.scale(r.width(), r.height());
                brush.setTransform(mat);
                copy.setBrush(brush);
                real_engine->stroke(path, copy);
                return;
            }
        }
    }

    real_engine->stroke(path, pen);
}
Example #12
0
void Render::renderizaFace(HalfEdge *h,QImage* b,QPen pen)
{
    QPainter buff(b);
    QPainterPath *path;
    QPoint p;
    HalfEdge::iterator it;

    buff.setPen(pen);

    path = new QPainterPath();
    p = transforma(h->getOrigem()->getPoint());
    path->moveTo(p.x(),p.y());
    for(it = h->f_begin(); it !=  h->f_end(); ++it)
    {
        p = transforma(it->getOrigem()->getPoint());
        path->lineTo(p.x(),p.y());
    }
    p = transforma(h->getOrigem()->getPoint());
    path->lineTo(p.x(),p.y());

    buff.fillPath(*path,pen.brush());
    delete path;
}
Example #13
0
void TupPaintAreaCommand::redo()
{
    switch (k->event->action()) {
            case TupPaintAreaEvent::ChangePen:
                 {
                   k->oldData = k->paintArea->brushManager()->pen();
                   QPen pen = qvariant_cast<QPen>(k->event->data());
                   if (!pen.color().isValid()) {
                       QPen old = k->paintArea->brushManager()->pen();
                       pen.setColor(old.color());
                       pen.setBrush(old.brush());
                   } 
                   k->paintArea->brushManager()->setPen(pen);
                 }
                 break;

            case TupPaintAreaEvent::ChangeColorPen:
                 {
                   // tFatal() << "TupPaintAreaCommand::redo() - ChangeColorPen/Setting color!";
                   k->oldData = k->paintArea->brushManager()->pen().color();
                   k->paintArea->brushManager()->setPenColor(qvariant_cast<QColor>(k->event->data()));
                 }
                 break;

            case TupPaintAreaEvent::ChangeBrush:
                 {
                   // tFatal() << "TupPaintAreaCommand::redo() - ChangeBrush/Setting brush!";
                   k->oldData = k->paintArea->brushManager()->brush();
                   k->paintArea->brushManager()->setBrush(qvariant_cast<QBrush>(k->event->data()));
                 }
                 break;

            default: 
                 break;
    }
}
Example #14
0
void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) {
        QPen bgPen = pen;
        bgPen.setBrush(s->bgBrush);
        bgPen.setStyle(Qt::SolidLine);
        real_engine->stroke(path, bgPen);
    }


    QBrush brush = pen.brush();
    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();
        if (g->coordinateMode() > QGradient::LogicalMode) {
            QPaintEngineEx::stroke(path, pen);
            return;
        }
    }

    real_engine->stroke(path, pen);
}
Example #15
0
void TupBrushStatus::setForeground(const QPen &pen)
{
    brush->setBrush(pen.brush());
}
Example #16
0
void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
{
#ifdef QT_DEBUG_DRAW
    qDebug() << "QPaintEngineEx::stroke()" << pen;
#endif

    Q_D(QPaintEngineEx);

    if (path.isEmpty())
        return;

    if (!d->strokeHandler) {
        d->strokeHandler = new StrokeHandler(path.elementCount()+4);
        d->stroker.setMoveToHook(qpaintengineex_moveTo);
        d->stroker.setLineToHook(qpaintengineex_lineTo);
        d->stroker.setCubicToHook(qpaintengineex_cubicTo);
    }

    if (!qpen_fast_equals(pen, d->strokerPen)) {
        d->strokerPen = pen;
        d->stroker.setJoinStyle(pen.joinStyle());
        d->stroker.setCapStyle(pen.capStyle());
        d->stroker.setMiterLimit(pen.miterLimit());
        qreal penWidth = pen.widthF();
        if (penWidth == 0)
            d->stroker.setStrokeWidth(1);
        else
            d->stroker.setStrokeWidth(penWidth);

        Qt::PenStyle style = pen.style();
        if (style == Qt::SolidLine) {
            d->activeStroker = &d->stroker;
        } else if (style == Qt::NoPen) {
            d->activeStroker = 0;
        } else {
            d->dasher.setDashPattern(pen.dashPattern());
            d->dasher.setDashOffset(pen.dashOffset());
            d->activeStroker = &d->dasher;
        }
    }

    if (!d->activeStroker) {
        return;
    }

    if (pen.style() > Qt::SolidLine) {
        if (pen.isCosmetic()) {
            d->activeStroker->setClipRect(d->exDeviceRect);
        } else {
            QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
            d->activeStroker->setClipRect(clipRect);
        }
    }

    const QPainterPath::ElementType *types = path.elements();
    const qreal *points = path.points();
    int pointCount = path.elementCount();

    const qreal *lastPoint = points + (pointCount<<1);

    d->strokeHandler->types.reset();
    d->strokeHandler->pts.reset();

    // Some engines might decide to optimize for the non-shape hint later on...
    uint flags = QVectorPath::WindingFill;

    if (path.elementCount() > 2)
        flags |= QVectorPath::NonConvexShapeMask;

    if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)
        flags |= QVectorPath::CurvedShapeMask;

    // ### Perspective Xforms are currently not supported...
    if (!pen.isCosmetic()) {
        // We include cosmetic pens in this case to avoid having to
        // change the current transform. Normal transformed,
        // non-cosmetic pens will be transformed as part of fill
        // later, so they are also covered here..
        d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
        d->activeStroker->begin(d->strokeHandler);
        if (types) {
            while (points < lastPoint) {
                switch (*types) {
                case QPainterPath::MoveToElement:
                    d->activeStroker->moveTo(points[0], points[1]);
                    points += 2;
                    ++types;
                    break;
                case QPainterPath::LineToElement:
                    d->activeStroker->lineTo(points[0], points[1]);
                    points += 2;
                    ++types;
                    break;
                case QPainterPath::CurveToElement:
                    d->activeStroker->cubicTo(points[0], points[1],
                                              points[2], points[3],
                                              points[4], points[5]);
                    points += 6;
                    types += 3;
                    flags |= QVectorPath::CurvedShapeMask;
                    break;
                default:
                    break;
                }
            }
            if (path.hasImplicitClose())
                d->activeStroker->lineTo(path.points()[0], path.points()[1]);

        } else {
            d->activeStroker->moveTo(points[0], points[1]);
            points += 2;
            while (points < lastPoint) {
                d->activeStroker->lineTo(points[0], points[1]);
                points += 2;
            }
            if (path.hasImplicitClose())
                d->activeStroker->lineTo(path.points()[0], path.points()[1]);
        }
        d->activeStroker->end();

        if (!d->strokeHandler->types.size()) // an empty path...
            return;

        QVectorPath strokePath(d->strokeHandler->pts.data(),
                               d->strokeHandler->types.size(),
                               d->strokeHandler->types.data(),
                               flags);
        fill(strokePath, pen.brush());
    } else {
        // For cosmetic pens we need a bit of trickery... We to process xform the input points
        if (state()->matrix.type() >= QTransform::TxProject) {
            QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
            d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
        } else {
            d->activeStroker->setCurveThresholdFromTransform(QTransform());
            d->activeStroker->begin(d->strokeHandler);
            if (types) {
                while (points < lastPoint) {
                    switch (*types) {
                    case QPainterPath::MoveToElement: {
                        QPointF pt = (*(QPointF *) points) * state()->matrix;
                        d->activeStroker->moveTo(pt.x(), pt.y());
                        points += 2;
                        ++types;
                        break;
                    }
                    case QPainterPath::LineToElement: {
                        QPointF pt = (*(QPointF *) points) * state()->matrix;
                        d->activeStroker->lineTo(pt.x(), pt.y());
                        points += 2;
                        ++types;
                        break;
                    }
                    case QPainterPath::CurveToElement: {
                        QPointF c1 = ((QPointF *) points)[0] * state()->matrix;
                        QPointF c2 = ((QPointF *) points)[1] * state()->matrix;
                        QPointF e =  ((QPointF *) points)[2] * state()->matrix;
                        d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
                        points += 6;
                        types += 3;
                        flags |= QVectorPath::CurvedShapeMask;
                        break;
                    }
                    default:
                        break;
                    }
                }
                if (path.hasImplicitClose()) {
                    QPointF pt = * ((QPointF *) path.points()) * state()->matrix;
                    d->activeStroker->lineTo(pt.x(), pt.y());
                }

            } else {
                QPointF p = ((QPointF *)points)[0] * state()->matrix;
                d->activeStroker->moveTo(p.x(), p.y());
                points += 2;
                while (points < lastPoint) {
                    QPointF p = ((QPointF *)points)[0] * state()->matrix;
                    d->activeStroker->lineTo(p.x(), p.y());
                    points += 2;
                }
                if (path.hasImplicitClose())
                    d->activeStroker->lineTo(p.x(), p.y());
            }
            d->activeStroker->end();
        }

        QVectorPath strokePath(d->strokeHandler->pts.data(),
                               d->strokeHandler->types.size(),
                               d->strokeHandler->types.data(),
                               flags);

        QTransform xform = state()->matrix;
        state()->matrix = QTransform();
        transformChanged();

        QBrush brush = pen.brush();
        if (qbrush_style(brush) != Qt::SolidPattern)
            brush.setTransform(brush.transform() * xform);

        fill(strokePath, brush);

        state()->matrix = xform;
        transformChanged();
    }
}
void MainWindow::contextMenu(const QPoint &p)
{
    // mostra o menu de contexto para o item na posicao "p"
    QGraphicsItem *item = ui->graphicsView->itemAt(p);

    if (item) {
        // o menu deve ser mostrado na posicao onde o mouse foi clicado
        QPoint globalPos = ui->graphicsView->mapToGlobal(p);
        QMenu menu;

        QMenu *linha = new QMenu("Linha/Texto", &menu);
        QMenu *preenchimento = new QMenu("Preenchimento", &menu);
        QMenu *menuLinha = new QMenu("Estilo", linha);
        QMenu *menuPadroes = new QMenu("Padrões", preenchimento);
        QMenu *menuEspessura = new QMenu("Espessura", linha);

        QAction* estilo1 = new QAction(" - - - - - ", menuLinha);
        QAction* estilo2 = new QAction(" - . - . - ", menuLinha);
        QAction* estilo3 = new QAction(" - .. - .. - ", menuLinha);

        menuLinha->addAction(estilo1);
        menuLinha->addAction(estilo2);
        menuLinha->addAction(estilo3);

        QAction* estiloPadrao1 = new QAction("Linhas horizontais", menuPadroes);
        QAction* estiloPadrao2 = new QAction("Linhas verticais", menuPadroes);
        QAction* estiloPadrao3 = new QAction("Quadriculado", menuPadroes);

        menuPadroes->addAction(estiloPadrao1);
        menuPadroes->addAction(estiloPadrao2);
        menuPadroes->addAction(estiloPadrao3);

        QAction* espessura1 = new QAction("2", menuEspessura);
        QAction* espessura2 = new QAction("3", menuEspessura);
        QAction* espessura3 = new QAction("4", menuEspessura);

        menuEspessura->addAction(espessura1);
        menuEspessura->addAction(espessura2);
        menuEspessura->addAction(espessura3);

        QAction* corLinha = new QAction("Cor", linha);
        QAction* corPreen = new QAction("Cor", preenchimento);

        linha->addAction(corLinha);
        linha->addAction(menuLinha->menuAction());
        linha->addAction(menuEspessura->menuAction());

        preenchimento->addAction(menuPadroes->menuAction());
        preenchimento->addAction(corPreen);

        menu.addAction(linha->menuAction());
        menu.addAction(preenchimento->menuAction());

        QAction* selectedItem;
        int tipoItem = item->type();

        // seleciona o que vai ficar Habilitado/Desabilitado no menu baseado no item selecionado
        if (tipoItem == MainWindow::Line) {
            if (QGraphicsItemGroup *g = item->group()) {
                preenchimento->setEnabled(false);
                menuLinha->setEnabled(false);

                // pega a entrada do menu que foi selecionada
                selectedItem = menu.exec(globalPos);
                if (selectedItem) {

                    // Alterar Cor da Linha
                    if (selectedItem == corLinha) {
                        QColor cor = QColorDialog::getColor();
                        if (cor.isValid())
                           foreach (QGraphicsItem* i, g->childItems())
                               (static_cast<QGraphicsLineItem*>(i))->setPen(QPen(cor));

                    // Alterar Espessura da Linha: 2
                    } else if (selectedItem == espessura1)  {
                        QList<QGraphicsItem*> itens = g->childItems();
                        QPen currentPen = (static_cast<QGraphicsLineItem*>(itens[0]))->pen();
                        foreach (QGraphicsItem* i, itens)
                            (static_cast<QGraphicsLineItem*>(i))->setPen(QPen(currentPen.brush(), 2));

                    // Alterar Espessura da Linha: 3
                    } else if (selectedItem == espessura2) {
                        QList<QGraphicsItem*> itens = g->childItems();
                        QPen currentPen = (static_cast<QGraphicsLineItem*>(itens[0]))->pen();
                        foreach (QGraphicsItem* i, itens)
                            (static_cast<QGraphicsLineItem*>(i))->setPen(QPen(currentPen.brush(), 3));

                    // Alterar Espessura da Linha: 4
                    } else if (selectedItem == espessura3) {
                        QList<QGraphicsItem*> itens = g->childItems();
                        QPen currentPen = (static_cast<QGraphicsLineItem*>(itens[0]))->pen();
                        foreach (QGraphicsItem* i, itens)
                            (static_cast<QGraphicsLineItem*>(i))->setPen(QPen(currentPen.brush(), 4));
                    }

                }

           } else {
               preenchimento->setEnabled(false);
               // devo recuperar aqui dentro, pois preciso desabilitar algumas opções
               selectedItem = menu.exec(globalPos);

               if (selectedItem) {
                   if (selectedItem == estilo1) {
                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashLine);
                       (static_cast<QGraphicsLineItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo2) {
                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotLine);
                       (static_cast<QGraphicsLineItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo3) {
                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotDotLine);
                       (static_cast<QGraphicsLineItem*>(item))->setPen(currentPen);


                   } else if (selectedItem == corLinha) {
                       QColor cor = QColorDialog::getColor();

                       if (cor.isValid()) {
                           QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();
                           currentPen.setColor(cor);
                           (static_cast<QGraphicsLineItem*>(item))->setPen(currentPen);
                       }

                   } else if (selectedItem == espessura1) {

                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       (static_cast<QGraphicsLineItem*>(item))->setPen(QPen(currentPen.brush(), 2));

                   } else if (selectedItem == espessura2) {

                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       (static_cast<QGraphicsLineItem*>(item))->setPen(QPen(currentPen.brush(), 3));

                   } else if (selectedItem == espessura3) {

                       QPen currentPen = (static_cast<QGraphicsLineItem*>(item))->pen();

                       (static_cast<QGraphicsLineItem*>(item))->setPen(QPen(currentPen.brush(), 4));

                   }
               }


           }
       }
       else {
           if (tipoItem == MainWindow::Quadrado) {

               selectedItem = menu.exec(globalPos);

               if (selectedItem) {
                   if (selectedItem == corLinha) {
                       QColor cor = QColorDialog::getColor();

                       if (cor.isValid()) {
                           QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();
                           currentPen.setColor(cor);
                           (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);
                       }

                   } else if (selectedItem == estilo1) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashLine);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo2) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotLine);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo3) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotLine);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura1) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setWidth(2);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura2) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setWidth(3);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura3) {
                       QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();

                       currentPen.setWidth(4);
                       (static_cast<QGraphicsRectItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == corPreen) {
                       QColor cor = QColorDialog::getColor();

                       if (cor.isValid()) {

                           QPen currentPen = (static_cast<QGraphicsRectItem*>(item))->pen();
                           QBrush b = currentPen.brush();
                           b.setColor(cor);
                           b.setStyle(Qt::SolidPattern);

                           (static_cast<QGraphicsRectItem*>(item))->setBrush(b);
                       }

                   } else if (selectedItem == estiloPadrao1) {
                       QBrush b = (static_cast<QGraphicsRectItem*>(item))->brush();

                       b.setStyle(Qt::HorPattern);
                       (static_cast<QGraphicsRectItem*>(item))->setBrush(b);

                   } else if (selectedItem == estiloPadrao2) {
                       QBrush b = (static_cast<QGraphicsRectItem*>(item))->brush();

                       b.setStyle(Qt::VerPattern);
                       (static_cast<QGraphicsRectItem*>(item))->setBrush(b);

                   } else if (selectedItem == estiloPadrao3) {
                       QBrush b = (static_cast<QGraphicsRectItem*>(item))->brush();

                       b.setStyle(Qt::CrossPattern);
                       (static_cast<QGraphicsRectItem*>(item))->setBrush(b);
                   }
               }

           } else  if (tipoItem == MainWindow::Texto) {
               preenchimento->setEnabled(false);
               menuLinha->setEnabled(false);
               menuEspessura->setEnabled(false);

               selectedItem = menu.exec(globalPos);
               if (selectedItem && selectedItem == corLinha) {
                   QColor cor = QColorDialog::getColor();
                   if (cor.isValid())
                       (static_cast<QGraphicsTextItem*>(item))->setDefaultTextColor(cor);
               }

           } else if (tipoItem == MainWindow::Circulo) {
               selectedItem = menu.exec(globalPos);

               if (selectedItem) {
                   if (selectedItem == corLinha) {
                       QColor cor = QColorDialog::getColor();

                       if (cor.isValid()) {
                           QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();
                           currentPen.setColor(cor);
                           (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);
                       }
                   } else if (selectedItem == estilo1) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashLine);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo2) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotLine);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == estilo3) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setStyle(Qt::DashDotLine);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura1) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setWidth(2);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura2) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setWidth(3);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == espessura3) {
                       QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();

                       currentPen.setWidth(4);
                       (static_cast<QGraphicsEllipseItem*>(item))->setPen(currentPen);

                   } else if (selectedItem == corPreen) {
                       QColor cor = QColorDialog::getColor();

                       if (cor.isValid()) {

                           QPen currentPen = (static_cast<QGraphicsEllipseItem*>(item))->pen();
                           QBrush b = currentPen.brush();
                           b.setColor(cor);
                           b.setStyle(Qt::SolidPattern);

                           (static_cast<QGraphicsEllipseItem*>(item))->setBrush(b);
                       }

                   } else if (selectedItem == estiloPadrao1) {
                       QBrush b = (static_cast<QGraphicsEllipseItem*>(item))->brush();

                       b.setStyle(Qt::HorPattern);
                       (static_cast<QGraphicsEllipseItem*>(item))->setBrush(b);

                   } else if (selectedItem == estiloPadrao2) {
                       QBrush b = (static_cast<QGraphicsEllipseItem*>(item))->brush();

                       b.setStyle(Qt::VerPattern);
                       (static_cast<QGraphicsEllipseItem*>(item))->setBrush(b);

                   } else if (selectedItem == estiloPadrao3) {
                       QBrush b = (static_cast<QGraphicsEllipseItem*>(item))->brush();

                       b.setStyle(Qt::CrossPattern);
                       (static_cast<QGraphicsEllipseItem*>(item))->setBrush(b);
                   }
               }
           }
       }
    }
}