Les modifications de points sur les polygones sont desormais annulables

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@106 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavierqet
2007-08-25 15:04:45 +00:00
parent 4203f869fb
commit 1dd23c8af8
3 changed files with 50 additions and 2 deletions

View File

@@ -162,3 +162,27 @@ void ChangePartCommand::undo() {
void ChangePartCommand::redo() { void ChangePartCommand::redo() {
cep -> setProperty(property, new_value); cep -> setProperty(property, new_value);
} }
ChangePolygonPointsCommand::ChangePolygonPointsCommand(
PartPolygon *p,
const QVector<QPointF> &o_points,
const QVector<QPointF> &n_points,
QUndoCommand *parent
) :
QUndoCommand(QObject::tr("modification points polygone"), parent),
polygon(p),
old_points(o_points),
new_points(n_points)
{
}
ChangePolygonPointsCommand::~ChangePolygonPointsCommand() {
}
void ChangePolygonPointsCommand::undo() {
polygon -> setPolygon(old_points);
}
void ChangePolygonPointsCommand::redo() {
polygon -> setPolygon(new_points);
}

View File

@@ -1,6 +1,7 @@
#ifndef EDITOR_COMMANDS_H #ifndef EDITOR_COMMANDS_H
#define EDITOR_COMMANDS_H #define EDITOR_COMMANDS_H
#include "customelementpart.h" #include "customelementpart.h"
#include "partpolygon.h"
#include "elementscene.h" #include "elementscene.h"
#include "qgimanager.h" #include "qgimanager.h"
#include <QtGui> #include <QtGui>
@@ -109,4 +110,28 @@ class ChangePartCommand : public QUndoCommand {
/// nouvelle valeur /// nouvelle valeur
QVariant new_value; QVariant new_value;
}; };
/**
Cette classe represente l'action de modifier les points composants un polygone
*/
class ChangePolygonPointsCommand : public QUndoCommand {
// constructeurs, destructeur
public:
ChangePolygonPointsCommand(PartPolygon *, const QVector<QPointF> &, const QVector<QPointF> &, QUndoCommand * = 0);
virtual ~ChangePolygonPointsCommand();
private:
ChangePolygonPointsCommand(const ChangePolygonPointsCommand &);
// methodes
virtual void undo();
virtual void redo();
// attributs
/// Polygone modifie
PartPolygon *polygon;
/// anciens points
QVector<QPointF> old_points;
/// nouveaux points
QVector<QPointF> new_points;
};
#endif #endif

View File

@@ -48,7 +48,7 @@ void PolygonEditor::updatePolygonPoints() {
); );
return; return;
} }
part -> setPolygon(points); undoStack().push(new ChangePolygonPointsCommand(part, part -> polygon(), points));
} }
void PolygonEditor::updatePolygonClosedState() { void PolygonEditor::updatePolygonClosedState() {
@@ -61,7 +61,6 @@ void PolygonEditor::updatePolygonClosedState() {
QVariant(close_polygon.isChecked()) QVariant(close_polygon.isChecked())
) )
); );
// part -> setClosed(close_polygon.isChecked());
} }
void PolygonEditor::updateForm() { void PolygonEditor::updateForm() {