mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Les deplacements d'elements sont desormais annulables
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@137 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -218,3 +218,64 @@ CutDiagramCommand::CutDiagramCommand(
|
||||
/// Destructeur
|
||||
CutDiagramCommand::~CutDiagramCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param
|
||||
*/
|
||||
MoveElementsCommand::MoveElementsCommand(
|
||||
Diagram *dia,
|
||||
const QSet<Element *> &move_elements,
|
||||
const QSet<Conducer *> &move_conducers,
|
||||
const QHash<Conducer *, Terminal *> &modify_conducers,
|
||||
const QPointF &m,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(parent),
|
||||
diagram(dia),
|
||||
elements_to_move(move_elements),
|
||||
conducers_to_move(move_conducers),
|
||||
conducers_to_update(modify_conducers),
|
||||
movement(m)
|
||||
{
|
||||
setText(QObject::tr("d\351placer ") + QET::ElementsAndConducersSentence(elements_to_move.count(), conducers_to_move.count()));
|
||||
foreach(QGraphicsItem *qgi, elements_to_move) diagram -> qgiManager().manage(qgi);
|
||||
foreach(QGraphicsItem *qgi, conducers_to_move) diagram -> qgiManager().manage(qgi);
|
||||
foreach(QGraphicsItem *qgi, conducers_to_update) diagram -> qgiManager().manage(qgi);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
MoveElementsCommand::~MoveElementsCommand() {
|
||||
foreach(QGraphicsItem *qgi, elements_to_move) diagram -> qgiManager().release(qgi);
|
||||
foreach(QGraphicsItem *qgi, conducers_to_move) diagram -> qgiManager().release(qgi);
|
||||
foreach(QGraphicsItem *qgi, conducers_to_update) diagram -> qgiManager().release(qgi);
|
||||
}
|
||||
|
||||
/// annule le deplacement
|
||||
void MoveElementsCommand::undo() {
|
||||
move(-movement);
|
||||
}
|
||||
|
||||
/// refait le deplacement
|
||||
void MoveElementsCommand::redo() {
|
||||
if (first_redo) first_redo = false;
|
||||
else move(movement);
|
||||
}
|
||||
|
||||
///
|
||||
void MoveElementsCommand::move(const QPointF &actual_movement) {
|
||||
// deplace les elements
|
||||
foreach(Element *element, elements_to_move) {
|
||||
element -> setPos(element -> pos() + actual_movement);
|
||||
}
|
||||
|
||||
// deplace certains conducteurs
|
||||
foreach(Conducer *conducer, conducers_to_move) {
|
||||
conducer -> setPos(conducer -> pos() + actual_movement);
|
||||
}
|
||||
|
||||
// recalcule les autres conducteurs
|
||||
foreach(Conducer *conducer, conducers_to_update.keys()) {
|
||||
conducer -> updateWithNewPos(QRectF(), conducers_to_update[conducer], conducers_to_update[conducer] -> amarrageConducer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user