mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
Basic Shapes: Move coords corrected for XML, DXF export
(Bounding Rectangle had to be updated with each move) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2912 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -497,6 +497,10 @@ void MoveElementsCommand::move(const QPointF &actual_movement) {
|
||||
// deplace les shapes
|
||||
foreach (QetShapeItem *dsi, content_to_move.shapes) {
|
||||
dsi -> setPos(dsi -> pos() + actual_movement);
|
||||
QRectF rec = dsi -> boundingRect();
|
||||
rec.translate(actual_movement);
|
||||
dsi -> setBoundingRect(rec);
|
||||
dsi -> setPos(dsi -> pos() - actual_movement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,31 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
}
|
||||
}
|
||||
|
||||
void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
_origMousePress = mapToScene(e -> pos());
|
||||
first_move_ = true;
|
||||
if (e -> modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void QetShapeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
if (diagram()) diagram() -> endMoveElements();
|
||||
QPointF newCoord = mapToScene(e -> pos());
|
||||
if (newCoord != _origMousePress) {
|
||||
//translate bounding rectangle
|
||||
QRectF rec = boundingRect();
|
||||
rec.translate(newCoord - _origMousePress);
|
||||
setBoundingRect(rec);
|
||||
setPos(pos() - newCoord + _origMousePress);
|
||||
}
|
||||
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) QGraphicsItem::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
|
||||
bool QetShapeItem::fromXml(const QDomElement &e)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,7 @@ class QetShapeItem : public QetGraphicsItem
|
||||
virtual QDomElement toXml(QDomDocument &document) const;
|
||||
void setWritingXml(bool writing) { _writingXml = writing; }
|
||||
virtual void editProperty();
|
||||
QRectF boundingRect() const;
|
||||
|
||||
private:
|
||||
ShapeType _shapeType;
|
||||
@@ -52,11 +53,13 @@ class QetShapeItem : public QetGraphicsItem
|
||||
bool _isFullyBuilt;
|
||||
QPointF _lineP1;
|
||||
QPointF _lineP2;
|
||||
QPointF _origMousePress;
|
||||
bool _writingXml;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
|
||||
QPainterPath shape() const;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user