mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 00:30:53 +01:00
Correction du bug rendant imprecis l'annulation des deplacements dans l'editeur d'elements
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@126 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -74,9 +74,6 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QPolygonF temp_polygon;
|
QPolygonF temp_polygon;
|
||||||
if (e -> buttons() & Qt::LeftButton) {
|
if (e -> buttons() & Qt::LeftButton) {
|
||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Normal:
|
|
||||||
QGraphicsScene::mouseMoveEvent(e);
|
|
||||||
break;
|
|
||||||
case Line:
|
case Line:
|
||||||
current_line -> setLine(QLineF(current_line -> line().p1(), e -> scenePos()));
|
current_line -> setLine(QLineF(current_line -> line().p1(), e -> scenePos()));
|
||||||
break;
|
break;
|
||||||
@@ -107,6 +104,7 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
temp_polygon << e -> scenePos();
|
temp_polygon << e -> scenePos();
|
||||||
current_polygon -> setPolygon(temp_polygon);
|
current_polygon -> setPolygon(temp_polygon);
|
||||||
break;
|
break;
|
||||||
|
case Normal:
|
||||||
default:
|
default:
|
||||||
QGraphicsScene::mouseMoveEvent(e);
|
QGraphicsScene::mouseMoveEvent(e);
|
||||||
}
|
}
|
||||||
@@ -123,9 +121,6 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QPolygonF temp_polygon;
|
QPolygonF temp_polygon;
|
||||||
if (e -> button() & Qt::LeftButton) {
|
if (e -> button() & Qt::LeftButton) {
|
||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Normal:
|
|
||||||
QGraphicsScene::mousePressEvent(e);
|
|
||||||
break;
|
|
||||||
case Line:
|
case Line:
|
||||||
current_line = new PartLine(element_editor, 0, this);
|
current_line = new PartLine(element_editor, 0, this);
|
||||||
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
||||||
@@ -152,8 +147,10 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
temp_polygon << e -> scenePos();
|
temp_polygon << e -> scenePos();
|
||||||
current_polygon -> setPolygon(temp_polygon);
|
current_polygon -> setPolygon(temp_polygon);
|
||||||
break;
|
break;
|
||||||
|
case Normal:
|
||||||
default:
|
default:
|
||||||
QGraphicsScene::mousePressEvent(e);
|
QGraphicsScene::mousePressEvent(e);
|
||||||
|
if (!selectedItems().isEmpty()) fsi_pos = selectedItems().first() -> scenePos();
|
||||||
}
|
}
|
||||||
} else QGraphicsScene::mousePressEvent(e);
|
} else QGraphicsScene::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
@@ -200,7 +197,7 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QGraphicsScene::mouseReleaseEvent(e);
|
QGraphicsScene::mouseReleaseEvent(e);
|
||||||
// detecte les deplacements de parties
|
// detecte les deplacements de parties
|
||||||
if (!selectedItems().isEmpty()) {
|
if (!selectedItems().isEmpty()) {
|
||||||
QPointF movement = e -> scenePos() - e -> buttonDownScenePos(Qt::LeftButton);
|
QPointF movement = selectedItems().first() -> scenePos() - fsi_pos;
|
||||||
if (!movement.isNull()) {
|
if (!movement.isNull()) {
|
||||||
undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
|
undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class ElementScene : public QGraphicsScene {
|
|||||||
QGIManager qgi_manager;
|
QGIManager qgi_manager;
|
||||||
/// Pile des actions annulables
|
/// Pile des actions annulables
|
||||||
QUndoStack undo_stack;
|
QUndoStack undo_stack;
|
||||||
|
/// Position du premier item selectionne (utilise pour annuler les deplacements)
|
||||||
|
QPointF fsi_pos;
|
||||||
|
|
||||||
/// Variables relatives a la gestion du dessin des parties sur la scene
|
/// Variables relatives a la gestion du dessin des parties sur la scene
|
||||||
Behavior behavior;
|
Behavior behavior;
|
||||||
|
|||||||
Reference in New Issue
Block a user