2007-08-23 15:33:55 +00:00
|
|
|
#ifndef EDITOR_COMMANDS_H
|
|
|
|
#define EDITOR_COMMANDS_H
|
|
|
|
#include "customelementpart.h"
|
2007-08-25 15:04:45 +00:00
|
|
|
#include "partpolygon.h"
|
2007-08-25 03:43:05 +00:00
|
|
|
#include "elementscene.h"
|
2007-08-23 15:33:55 +00:00
|
|
|
#include "qgimanager.h"
|
|
|
|
#include <QtGui>
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de supprimer une ou plusieurs
|
|
|
|
parties lors de l'edition d'un element
|
|
|
|
*/
|
|
|
|
class DeletePartsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-08-25 03:43:05 +00:00
|
|
|
DeletePartsCommand(ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual ~DeletePartsCommand();
|
|
|
|
private:
|
|
|
|
DeletePartsCommand(const DeletePartsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Liste des parties supprimees
|
|
|
|
QList<QGraphicsItem *> deleted_parts;
|
|
|
|
/// scene sur laquelle se produisent les actions
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementScene *editor_scene;
|
2007-08-23 15:33:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de deplacer une ou plusieurs
|
|
|
|
parties lors de l'edition d'un element
|
|
|
|
*/
|
|
|
|
class MovePartsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-08-25 03:43:05 +00:00
|
|
|
MovePartsCommand(const QPointF &, ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual ~MovePartsCommand();
|
|
|
|
private:
|
|
|
|
MovePartsCommand(const MovePartsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Liste des parties supprimees
|
|
|
|
QList<QGraphicsItem *> moved_parts;
|
|
|
|
/// scene sur laquelle se produisent les actions
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementScene *editor_scene;
|
2007-08-23 15:33:55 +00:00
|
|
|
/// translation appliquee
|
|
|
|
QPointF movement;
|
|
|
|
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2007-09-25 23:24:36 +00:00
|
|
|
Cette classe represente l'action d'ajouter une partie lors de l'edition
|
|
|
|
d'un element
|
2007-08-23 15:33:55 +00:00
|
|
|
*/
|
|
|
|
class AddPartCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-08-25 03:43:05 +00:00
|
|
|
AddPartCommand(const QString &, ElementScene *, QGraphicsItem *, QUndoCommand * = 0);
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual ~AddPartCommand();
|
|
|
|
private:
|
|
|
|
AddPartCommand(const AddPartCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-08-23 15:33:55 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Liste des parties supprimees
|
|
|
|
QGraphicsItem *part;
|
|
|
|
/// scene sur laquelle se produisent les actions
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementScene *editor_scene;
|
2007-08-23 15:33:55 +00:00
|
|
|
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
2007-08-25 03:43:05 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier une propriete d'une partie
|
|
|
|
lors de l'edition d'un element
|
|
|
|
*/
|
|
|
|
class ChangePartCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &, const QVariant &, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangePartCommand();
|
|
|
|
private:
|
|
|
|
ChangePartCommand(const ChangePartCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-08-25 03:43:05 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Partie modifiee
|
|
|
|
CustomElementPart *cep;
|
|
|
|
/// Propriete modifiee
|
|
|
|
QString property;
|
|
|
|
/// ancienne valeur
|
|
|
|
QVariant old_value;
|
|
|
|
/// nouvelle valeur
|
|
|
|
QVariant new_value;
|
|
|
|
};
|
2007-08-25 15:04:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-08-25 15:04:45 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
/// Polygone modifie
|
|
|
|
PartPolygon *polygon;
|
|
|
|
/// anciens points
|
|
|
|
QVector<QPointF> old_points;
|
|
|
|
/// nouveaux points
|
|
|
|
QVector<QPointF> new_points;
|
|
|
|
};
|
2007-09-10 21:12:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier les dimensions et le point de saisie d'un element
|
|
|
|
*/
|
|
|
|
class ChangeHotspotCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeHotspotCommand(ElementScene *, const QSize &, const QSize &, const QPoint &, const QPoint &, const QPoint & = QPoint(), QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeHotspotCommand();
|
|
|
|
private:
|
|
|
|
ChangeHotspotCommand(const ChangeHotspotCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void applyOffset(const QPointF &);
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
/// Element edite auquel il faut appliquer les modifications
|
|
|
|
ElementScene *element;
|
|
|
|
/// dimensions avant l'action
|
|
|
|
QSize size_before;
|
|
|
|
/// dimensions apres l'action
|
|
|
|
QSize size_after;
|
|
|
|
/// point de saisie avant l'action
|
|
|
|
QPoint hotspot_before;
|
|
|
|
/// point de saisie apres l'action
|
|
|
|
QPoint hotspot_after;
|
|
|
|
/// decalage a appliquer aux elements
|
|
|
|
QPoint offset;
|
|
|
|
};
|
2007-09-10 21:50:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de changer les noms d'un element
|
|
|
|
*/
|
|
|
|
class ChangeNamesCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeNamesCommand();
|
|
|
|
private:
|
|
|
|
ChangeNamesCommand(const ChangeNamesCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-10 21:50:17 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Liste des noms avant changement
|
|
|
|
NamesList names_before;
|
|
|
|
/// Liste des noms apres changement
|
|
|
|
NamesList names_after;
|
2007-09-10 22:11:47 +00:00
|
|
|
/// Element edite auquel il faut appliquer les modifications
|
|
|
|
ElementScene *element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de changer les noms d'un element
|
|
|
|
*/
|
|
|
|
class ChangeOrientationsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeOrientationsCommand(ElementScene *, const OrientationSet &, const OrientationSet &, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeOrientationsCommand();
|
|
|
|
private:
|
|
|
|
ChangeOrientationsCommand(const ChangeOrientationsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-10 22:11:47 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Orientations avant changement
|
|
|
|
OrientationSet ori_before;
|
|
|
|
/// Orientations apres changement
|
|
|
|
OrientationSet ori_after;
|
|
|
|
/// Element edite auquel il faut appliquer les modifications
|
2007-09-10 21:50:17 +00:00
|
|
|
ElementScene *element;
|
|
|
|
};
|
2007-08-23 15:33:55 +00:00
|
|
|
#endif
|