mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Element editor : minor improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4061 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
012ba2ccd7
commit
50c61b4e03
@ -393,7 +393,7 @@ void CustomElementGraphicPart::drawShadowShape(QPainter *painter)
|
|||||||
color.setAlpha(50);
|
color.setAlpha(50);
|
||||||
painter -> setBrush (QBrush (color));
|
painter -> setBrush (QBrush (color));
|
||||||
painter -> setPen (Qt::NoPen);
|
painter -> setPen (Qt::NoPen);
|
||||||
painter -> drawPath (strock.createStroke(shape()));
|
painter -> drawPath (strock.createStroke(shadowShape()));
|
||||||
painter -> restore ();
|
painter -> restore ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,8 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
|||||||
virtual void setProperty (const char *name, const QVariant &value) {QObject::setProperty(name, value);}
|
virtual void setProperty (const char *name, const QVariant &value) {QObject::setProperty(name, value);}
|
||||||
virtual QVariant property (const char *name) const {return QObject::property(name);}
|
virtual QVariant property (const char *name) const {return QObject::property(name);}
|
||||||
|
|
||||||
|
virtual QPainterPath shadowShape ()const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stylesToXml (QDomElement &) const;
|
void stylesToXml (QDomElement &) const;
|
||||||
void stylesFromXml(const QDomElement &);
|
void stylesFromXml(const QDomElement &);
|
||||||
|
@ -122,6 +122,16 @@ void PartArc::fromXml(const QDomElement &qde) {
|
|||||||
m_span_angle = qde.attribute("angle", "-1440").toInt() * 16;
|
m_span_angle = qde.attribute("angle", "-1440").toInt() * 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF PartArc::boundingRect() const
|
||||||
|
{
|
||||||
|
QRectF r = AbstractPartEllipse::boundingRect();
|
||||||
|
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForRect(m_rect)))
|
||||||
|
r |= rect;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PartArc::shape
|
* @brief PartArc::shape
|
||||||
* @return the shape of this item
|
* @return the shape of this item
|
||||||
@ -143,6 +153,18 @@ QPainterPath PartArc::shape() const
|
|||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPainterPath PartArc::shadowShape() const
|
||||||
|
{
|
||||||
|
QPainterPath shape;
|
||||||
|
shape.arcMoveTo(m_rect, m_start_angle/16);
|
||||||
|
shape.arcTo(m_rect, m_start_angle/16, m_span_angle/16);
|
||||||
|
|
||||||
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
|
return (pps.createStroke(shape));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PartArc::mousePressEvent
|
* @brief PartArc::mousePressEvent
|
||||||
* Handle mouse press event
|
* Handle mouse press event
|
||||||
|
@ -55,7 +55,9 @@ class PartArc : public AbstractPartEllipse
|
|||||||
virtual const QDomElement toXml (QDomDocument &) const;
|
virtual const QDomElement toXml (QDomDocument &) const;
|
||||||
virtual void fromXml (const QDomElement &);
|
virtual void fromXml (const QDomElement &);
|
||||||
|
|
||||||
|
virtual QRectF boundingRect() const;
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
virtual QPainterPath shadowShape() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
@ -125,6 +125,16 @@ void PartEllipse::fromXml(const QDomElement &qde)
|
|||||||
QSizeF(width, height));
|
QSizeF(width, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF PartEllipse::boundingRect() const
|
||||||
|
{
|
||||||
|
QRectF r = AbstractPartEllipse::boundingRect();
|
||||||
|
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForRect(m_rect)))
|
||||||
|
r |= rect;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PartEllipse::shape
|
* @brief PartEllipse::shape
|
||||||
* @return the shape of this item
|
* @return the shape of this item
|
||||||
@ -145,6 +155,17 @@ QPainterPath PartEllipse::shape() const
|
|||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPainterPath PartEllipse::shadowShape() const
|
||||||
|
{
|
||||||
|
QPainterPath shape;
|
||||||
|
shape.addEllipse(m_rect);
|
||||||
|
|
||||||
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
|
return (pps.createStroke(shape));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PartEllipse::mousePressEvent
|
* @brief PartEllipse::mousePressEvent
|
||||||
* Handle mouse press event
|
* Handle mouse press event
|
||||||
|
@ -56,7 +56,9 @@ class PartEllipse : public AbstractPartEllipse
|
|||||||
virtual const QDomElement toXml (QDomDocument &) const;
|
virtual const QDomElement toXml (QDomDocument &) const;
|
||||||
virtual void fromXml (const QDomElement &);
|
virtual void fromXml (const QDomElement &);
|
||||||
|
|
||||||
|
virtual QRectF boundingRect() const;
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
virtual QPainterPath shadowShape() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
@ -272,6 +272,31 @@ QPainterPath PartLine::shape() const
|
|||||||
shape.lineTo(m_line.p2());
|
shape.lineTo(m_line.p2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(penWeight());
|
||||||
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
|
if (isSelected())
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForLine(m_line)))
|
||||||
|
shape.addRect(rect);
|
||||||
|
|
||||||
|
return shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath PartLine::shadowShape() const
|
||||||
|
{
|
||||||
|
QPainterPath shape;
|
||||||
|
|
||||||
|
//We calcul path only if there is an end type
|
||||||
|
//Else we just draw a line
|
||||||
|
if (first_end || second_end)
|
||||||
|
shape.addPath(path());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.moveTo(m_line.p1());
|
||||||
|
shape.lineTo(m_line.p2());
|
||||||
|
}
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(penWeight());
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
@ -409,6 +434,10 @@ QRectF PartLine::boundingRect() const
|
|||||||
|
|
||||||
bound = bound.normalized();
|
bound = bound.normalized();
|
||||||
bound.adjust(-adjust, -adjust, adjust, adjust);
|
bound.adjust(-adjust, -adjust, adjust, adjust);
|
||||||
|
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForLine(m_line)))
|
||||||
|
bound |= rect;
|
||||||
|
|
||||||
return bound;
|
return bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
virtual QPointF sceneP1() const;
|
virtual QPointF sceneP1() const;
|
||||||
virtual QPointF sceneP2() const;
|
virtual QPointF sceneP2() const;
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
virtual QPainterPath shadowShape() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
|
@ -306,6 +306,25 @@ QPainterPath PartPolygon::shape() const
|
|||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addPolygon(m_polygon);
|
shape.addPolygon(m_polygon);
|
||||||
|
|
||||||
|
if (m_closed)
|
||||||
|
shape.lineTo(m_polygon.first());
|
||||||
|
|
||||||
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(penWeight());
|
||||||
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
|
if (isSelected())
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_polygon))
|
||||||
|
shape.addRect(rect);
|
||||||
|
|
||||||
|
return shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath PartPolygon::shadowShape() const
|
||||||
|
{
|
||||||
|
QPainterPath shape;
|
||||||
|
shape.addPolygon(m_polygon);
|
||||||
|
|
||||||
if (m_closed)
|
if (m_closed)
|
||||||
shape.lineTo(m_polygon.first());
|
shape.lineTo(m_polygon.first());
|
||||||
|
|
||||||
@ -329,5 +348,9 @@ QRectF PartPolygon::boundingRect() const
|
|||||||
if (penWeight() == 0) adjust += 0.5;
|
if (penWeight() == 0) adjust += 0.5;
|
||||||
|
|
||||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||||
|
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_polygon))
|
||||||
|
r |=rect;
|
||||||
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ class PartPolygon : public CustomElementGraphicPart
|
|||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
|
|
||||||
virtual QPainterPath shape () const;
|
virtual QPainterPath shape () const;
|
||||||
|
virtual QPainterPath shadowShape() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
|
@ -200,6 +200,22 @@ QPainterPath PartRectangle::shape() const
|
|||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addRect(m_rect);
|
shape.addRect(m_rect);
|
||||||
|
|
||||||
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(penWeight());
|
||||||
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
|
if (isSelected())
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForRect(m_rect)))
|
||||||
|
shape.addRect(rect);
|
||||||
|
|
||||||
|
return shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath PartRectangle::shadowShape() const
|
||||||
|
{
|
||||||
|
QPainterPath shape;
|
||||||
|
shape.addRect(m_rect);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(penWeight());
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
@ -219,6 +235,10 @@ QRectF PartRectangle::boundingRect() const
|
|||||||
|
|
||||||
QRectF r = m_rect.normalized();
|
QRectF r = m_rect.normalized();
|
||||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||||
|
|
||||||
|
foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForRect(m_rect)))
|
||||||
|
r |= rect;
|
||||||
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ class PartRectangle : public CustomElementGraphicPart
|
|||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
|
||||||
virtual QPainterPath shape () const;
|
virtual QPainterPath shape () const;
|
||||||
|
virtual QPainterPath shadowShape() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
|
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
virtual QPainterPath shadowShape() const {return shape();}
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user