Esempio n. 1
0
void ElbowGrabber::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    painter->setRenderHint(QPainter::Antialiasing, true);
    painter->setRenderHint(QPainter::SmoothPixmapTransform, true);

    if ( _paintStyle == kBox)
    {
        // fill the box with solid color, use sharp corners

        _outterborderPen.setCapStyle(Qt::RoundCap);
        _outterborderPen.setStyle(Qt::SolidLine);
        painter->setPen(_outterborderPen);

        QPointF topLeft (0-(_width/2.0), 0-(_height/2.0));
        QPointF bottomRight ( _width/2.0 ,_height/2.0);

        QRectF rect (topLeft, bottomRight);

        QBrush brush (Qt::SolidPattern);
        brush.setColor (_outterborderColor);





        painter->drawEllipse(rect);
        painter->fillRect(rect, brush);

//            painter->drawRect(rect);
//            painter->fillRect(rect,brush);

    }
    else  if (_paintStyle == kCrossHair)
    {
        painter->setPen( _outterborderColor );

        // center of the box is at 0,0
        painter->drawLine( QPointF(0,0), QPointF(0,-(_height/2)) );
        painter->drawLine( QPointF(0,0), QPointF(0, (_height/2)) );
        painter->drawLine( QPointF(0,0), QPointF(-(_width/2) , 0) );
        painter->drawLine( QPointF(0,0), QPointF((_width/2) , 0) );
    }
    else  if (_paintStyle == kArrowHead)
    {
       // qDebug()<< "setting arrowhead angle: " << _arrowAngle;
        updateArrowHead();
        _arrowHead->setRotation(_arrowAngle);
        _arrowHead->setColor(_outterborderPen.color());
        _arrowHead->setWidth(_width);
        _arrowHead->setHeight(_height);
        _arrowHead->setPos( - _width/2, - _height/2);
        _arrowHead->update();
    }

}
Esempio n. 2
0
void GraphicsEdge::notify(Subject *subject)
{
    if (_edge != subject)
    {
        // first remove the old edge
        dynamic_cast<GraphDrawingScene*>(scene())->removeFromMap(_edge);
        _edge = (Edge*)subject;
        dynamic_cast<GraphDrawingScene*>(scene())->addToMap(_edge, this);
        dynamic_cast<GraphDrawingScene*>(scene())->uncashEdges();
    }

    // if the subject is deleted, tell the scene that this observer should be removed at the next update
    if(_edge->getWillBeDeleted())
    {
        _edge->unregisterObserver(this);
        // don't set _edge to NULL because we still need the old point to locate what should be removed
        assert(dynamic_cast<GraphDrawingScene*>(scene()));
        dynamic_cast<GraphDrawingScene*>(scene())->deleteMeAtNextUpdate(this);
        return ; // no need to update if we will delete next time
    }
    _isSelfEdge =  _edge->isSelfEdge();
    _label = QString::fromStdString(_edge->getLabel().getLabelString());
    _color.setRgb(_edge->getColor().getRed(), _edge->getColor().getGreen(), _edge->getColor().getBlue());
    if (_edge->getColor() == RGB::colorSelection())
        setZValue(-1);
    else
        setZValue(_zValue);
    _brush.setColor(_color);
    _pen.setColor(_color);
    // calculate how the arrowhead should look, now GraphicArrowHead::getPolygon() will return the polygon that represents the arrowhead
    setLine(_edge->getSource()->getCoords().getX(),
            _edge->getSource()->getCoords().getY(),
            _edge->getTarget()->getCoords().getX(),
            _edge->getTarget()->getCoords().getY()
            );
    calculateLabelPosition();
    updateArrowHead();
}
Esempio n. 3
0
void RLeaderData::setArrowHead(bool on) {
    arrowHead = on;
    updateArrowHead();
}