[qet] [4061] Element editor : minor improvement |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4061
Author: blacksun
Date: 2015-07-21 14:29:43 +0200 (Tue, 21 Jul 2015)
Log Message:
-----------
Element editor : minor improvement
Modified Paths:
--------------
trunk/sources/editor/graphicspart/customelementgraphicpart.cpp
trunk/sources/editor/graphicspart/customelementgraphicpart.h
trunk/sources/editor/graphicspart/partarc.cpp
trunk/sources/editor/graphicspart/partarc.h
trunk/sources/editor/graphicspart/partellipse.cpp
trunk/sources/editor/graphicspart/partellipse.h
trunk/sources/editor/graphicspart/partline.cpp
trunk/sources/editor/graphicspart/partline.h
trunk/sources/editor/graphicspart/partpolygon.cpp
trunk/sources/editor/graphicspart/partpolygon.h
trunk/sources/editor/graphicspart/partrectangle.cpp
trunk/sources/editor/graphicspart/partrectangle.h
trunk/sources/editor/graphicspart/partterminal.h
Modified: trunk/sources/editor/graphicspart/customelementgraphicpart.cpp
===================================================================
--- trunk/sources/editor/graphicspart/customelementgraphicpart.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/customelementgraphicpart.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -393,7 +393,7 @@
color.setAlpha(50);
painter -> setBrush (QBrush (color));
painter -> setPen (Qt::NoPen);
- painter -> drawPath (strock.createStroke(shape()));
+ painter -> drawPath (strock.createStroke(shadowShape()));
painter -> restore ();
}
Modified: trunk/sources/editor/graphicspart/customelementgraphicpart.h
===================================================================
--- trunk/sources/editor/graphicspart/customelementgraphicpart.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/customelementgraphicpart.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -92,6 +92,8 @@
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 QPainterPath shadowShape ()const = 0;
+
protected:
void stylesToXml (QDomElement &) const;
void stylesFromXml(const QDomElement &);
Modified: trunk/sources/editor/graphicspart/partarc.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partarc.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partarc.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -122,6 +122,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
* @return the shape of this item
@@ -143,6 +153,18 @@
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
* Handle mouse press event
Modified: trunk/sources/editor/graphicspart/partarc.h
===================================================================
--- trunk/sources/editor/graphicspart/partarc.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partarc.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -55,7 +55,9 @@
virtual const QDomElement toXml (QDomDocument &) const;
virtual void fromXml (const QDomElement &);
+ virtual QRectF boundingRect() const;
virtual QPainterPath shape() const;
+ virtual QPainterPath shadowShape() const;
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
Modified: trunk/sources/editor/graphicspart/partellipse.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partellipse.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partellipse.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -125,6 +125,16 @@
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
* @return the shape of this item
@@ -145,6 +155,17 @@
return shape;
}
+QPainterPath PartEllipse::shadowShape() const
+{
+ QPainterPath shape;
+ shape.addEllipse(m_rect);
+
+ QPainterPathStroker pps;
+ pps.setWidth(penWeight());
+
+ return (pps.createStroke(shape));
+}
+
/**
* @brief PartEllipse::mousePressEvent
* Handle mouse press event
Modified: trunk/sources/editor/graphicspart/partellipse.h
===================================================================
--- trunk/sources/editor/graphicspart/partellipse.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partellipse.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -56,7 +56,9 @@
virtual const QDomElement toXml (QDomDocument &) const;
virtual void fromXml (const QDomElement &);
+ virtual QRectF boundingRect() const;
virtual QPainterPath shape() const;
+ virtual QPainterPath shadowShape() const;
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
Modified: trunk/sources/editor/graphicspart/partline.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partline.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partline.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -274,7 +274,32 @@
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;
+ pps.setWidth(penWeight());
+
return (pps.createStroke(shape));
}
@@ -409,6 +434,10 @@
bound = bound.normalized();
bound.adjust(-adjust, -adjust, adjust, adjust);
+
+ foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForLine(m_line)))
+ bound |= rect;
+
return bound;
}
Modified: trunk/sources/editor/graphicspart/partline.h
===================================================================
--- trunk/sources/editor/graphicspart/partline.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partline.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -74,6 +74,7 @@
virtual QPointF sceneP1() const;
virtual QPointF sceneP2() const;
virtual QPainterPath shape() const;
+ virtual QPainterPath shadowShape() const;
virtual QRectF boundingRect() const;
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
Modified: trunk/sources/editor/graphicspart/partpolygon.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partpolygon.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partpolygon.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -311,7 +311,26 @@
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)
+ shape.lineTo(m_polygon.first());
+
+ QPainterPathStroker pps;
+ pps.setWidth(penWeight());
+
return (pps.createStroke(shape));
}
@@ -329,5 +348,9 @@
if (penWeight() == 0) adjust += 0.5;
r.adjust(-adjust, -adjust, adjust, adjust);
+
+ foreach(QRectF rect, m_handler.handlerRect(m_polygon))
+ r |=rect;
+
return(r);
}
Modified: trunk/sources/editor/graphicspart/partpolygon.h
===================================================================
--- trunk/sources/editor/graphicspart/partpolygon.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partpolygon.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -61,6 +61,7 @@
const QDomElement toXml(QDomDocument &) const;
virtual QPainterPath shape () const;
+ virtual QPainterPath shadowShape() const;
virtual QRectF boundingRect() const;
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
Modified: trunk/sources/editor/graphicspart/partrectangle.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partrectangle.cpp 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partrectangle.cpp 2015-07-21 12:29:43 UTC (rev 4061)
@@ -202,7 +202,23 @@
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;
+ pps.setWidth(penWeight());
+
return (pps.createStroke(shape));
}
@@ -219,6 +235,10 @@
QRectF r = m_rect.normalized();
r.adjust(-adjust, -adjust, adjust, adjust);
+
+ foreach(QRectF rect, m_handler.handlerRect(m_handler.pointsForRect(m_rect)))
+ r |= rect;
+
return(r);
}
Modified: trunk/sources/editor/graphicspart/partrectangle.h
===================================================================
--- trunk/sources/editor/graphicspart/partrectangle.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partrectangle.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -76,6 +76,7 @@
virtual QPointF sceneTopLeft() const;
virtual QPainterPath shape () const;
+ virtual QPainterPath shadowShape() const;
virtual QRectF boundingRect() const;
virtual bool isUseless() const;
Modified: trunk/sources/editor/graphicspart/partterminal.h
===================================================================
--- trunk/sources/editor/graphicspart/partterminal.h 2015-07-20 21:06:00 UTC (rev 4060)
+++ trunk/sources/editor/graphicspart/partterminal.h 2015-07-21 12:29:43 UTC (rev 4061)
@@ -57,6 +57,7 @@
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual QPainterPath shape() const;
+ virtual QPainterPath shadowShape() const {return shape();}
virtual QRectF boundingRect() const;
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;