2007-09-25 23:24:36 +00:00
|
|
|
#ifndef DIAGRAM_COMMANDS_H
|
|
|
|
#define DIAGRAM_COMMANDS_H
|
2007-09-27 15:36:15 +00:00
|
|
|
#include "qet.h"
|
2007-09-25 23:24:36 +00:00
|
|
|
#include "diagram.h"
|
2007-09-26 22:57:53 +00:00
|
|
|
#include "diagramtextitem.h"
|
2007-10-03 17:02:39 +00:00
|
|
|
#include "conductor.h"
|
2007-10-14 14:44:33 +00:00
|
|
|
#include "conductorproperties.h"
|
2007-09-25 23:24:36 +00:00
|
|
|
#include <QtGui>
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action d'ajouter un element au schema
|
|
|
|
*/
|
|
|
|
class AddElementCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
AddElementCommand(Diagram *, Element *, const QPointF &, QUndoCommand * = 0);
|
|
|
|
virtual ~AddElementCommand();
|
|
|
|
private:
|
|
|
|
AddElementCommand(const AddElementCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-25 23:24:36 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// element ajoute
|
2007-09-25 23:24:36 +00:00
|
|
|
Element *element;
|
|
|
|
/// schema sur lequel on ajoute l'element
|
|
|
|
Diagram *diagram;
|
|
|
|
/// position de l'element sur le schema
|
|
|
|
QPointF position;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action d'ajouter un conducteur au schema
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
class AddConductorCommand : public QUndoCommand {
|
2007-09-25 23:24:36 +00:00
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
AddConductorCommand(Diagram *, Conductor *, QUndoCommand * = 0);
|
|
|
|
virtual ~AddConductorCommand();
|
2007-09-25 23:24:36 +00:00
|
|
|
private:
|
2007-10-03 17:02:39 +00:00
|
|
|
AddConductorCommand(const AddConductorCommand &);
|
2007-09-25 23:24:36 +00:00
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-25 23:24:36 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteur ajoute
|
2007-10-03 17:02:39 +00:00
|
|
|
Conductor *conductor;
|
2007-09-25 23:24:36 +00:00
|
|
|
/// schema auquel on ajoute le conducteur
|
|
|
|
Diagram *diagram;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de supprimer des elements et / ou
|
|
|
|
conducteurs d'un schema
|
|
|
|
*/
|
|
|
|
class DeleteElementsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
DeleteElementsCommand(Diagram *, QSet<Element *>, QSet<Conductor *>, QUndoCommand * = 0);
|
2007-09-25 23:24:36 +00:00
|
|
|
virtual ~DeleteElementsCommand();
|
|
|
|
private:
|
|
|
|
DeleteElementsCommand(const DeleteElementsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-25 23:24:36 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// liste des elements enleves
|
2007-09-25 23:24:36 +00:00
|
|
|
QSet<Element *> removed_elements;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// liste des conducteurs enleves
|
2007-10-03 17:02:39 +00:00
|
|
|
QSet<Conductor *> removed_conductors;
|
2007-09-25 23:24:36 +00:00
|
|
|
/// schema dont on supprime des elements et conducteurs
|
|
|
|
Diagram *diagram;
|
|
|
|
};
|
|
|
|
|
2007-09-26 12:36:31 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action de coller quelque chose sur un schema
|
|
|
|
*/
|
|
|
|
class PasteDiagramCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
PasteDiagramCommand(Diagram *, const QList<Element *> &, const QList<Conductor *> &, QUndoCommand * = 0);
|
2007-09-26 12:36:31 +00:00
|
|
|
virtual ~PasteDiagramCommand();
|
|
|
|
private:
|
|
|
|
PasteDiagramCommand(const PasteDiagramCommand &);
|
|
|
|
|
|
|
|
// methodes
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-26 12:36:31 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// elements ajoutes
|
2007-09-26 12:36:31 +00:00
|
|
|
QList<Element *> elements;
|
|
|
|
/// conducteurs ajoutes
|
2007-10-03 17:02:39 +00:00
|
|
|
QList<Conductor *> conductors;
|
2007-09-26 12:36:31 +00:00
|
|
|
/// schema sur lequel on colle les elements et conducteurs
|
|
|
|
Diagram *diagram;
|
|
|
|
/// booleen pour empecher le premier appel a redo
|
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de supprimer des elements et / ou
|
|
|
|
conducteurs d'un schema
|
|
|
|
*/
|
|
|
|
class CutDiagramCommand : public DeleteElementsCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
CutDiagramCommand(Diagram *, QSet<Element *>, QSet<Conductor *>, QUndoCommand * = 0);
|
2007-09-26 12:36:31 +00:00
|
|
|
virtual ~CutDiagramCommand();
|
|
|
|
private:
|
|
|
|
CutDiagramCommand(const CutDiagramCommand &);
|
|
|
|
};
|
|
|
|
|
2007-09-26 17:14:09 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action de deplacer des elements et des
|
|
|
|
conducteurs sur un schema
|
|
|
|
*/
|
|
|
|
class MoveElementsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
MoveElementsCommand(Diagram *, const QSet<Element *> &, const QSet<Conductor *> &, const QHash<Conductor *, Terminal *> &, const QPointF &m, QUndoCommand * = 0);
|
2007-09-26 17:14:09 +00:00
|
|
|
virtual ~MoveElementsCommand();
|
|
|
|
private:
|
|
|
|
MoveElementsCommand(const MoveElementsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
virtual void move(const QPointF &);
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// schema sur lequel on deplace les elements
|
2007-09-26 17:14:09 +00:00
|
|
|
Diagram *diagram;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// elements a deplacer
|
2007-09-26 17:14:09 +00:00
|
|
|
QSet<Element *> elements_to_move;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteurs a deplacer
|
2007-10-03 17:02:39 +00:00
|
|
|
QSet<Conductor *> conductors_to_move;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteurs a actualiser
|
2007-10-03 17:02:39 +00:00
|
|
|
QHash<Conductor *, Terminal *> conductors_to_update;
|
2007-09-26 17:14:09 +00:00
|
|
|
/// mouvement effectue
|
|
|
|
QPointF movement;
|
|
|
|
/// booleen pour ne pas executer le premier redo()
|
|
|
|
bool first_redo;
|
|
|
|
};
|
2007-09-26 22:57:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente la modification d'un champ de texte
|
|
|
|
*/
|
|
|
|
class ChangeDiagramTextCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeDiagramTextCommand(DiagramTextItem *, const QString &before, const QString &after, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeDiagramTextCommand();
|
|
|
|
private:
|
|
|
|
ChangeDiagramTextCommand(const ChangeDiagramTextCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// DiagramTextItem modifie
|
|
|
|
DiagramTextItem *text_item;
|
|
|
|
/// texte avant changement
|
|
|
|
QString text_before;
|
|
|
|
/// texte apres changement
|
|
|
|
QString text_after;
|
|
|
|
/// booleen pour ne pas executer le premier redo()
|
|
|
|
bool first_redo;
|
|
|
|
};
|
2007-09-27 15:36:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de pivoter plusieurs elements
|
|
|
|
*/
|
|
|
|
class RotateElementsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
RotateElementsCommand(const QHash<Element *, QET::Orientation> &elements, QUndoCommand * = 0);
|
|
|
|
virtual ~RotateElementsCommand();
|
|
|
|
private:
|
|
|
|
RotateElementsCommand(const RotateElementsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// elements pivotes associes a leur ancienne orientation
|
2007-09-27 15:36:15 +00:00
|
|
|
QHash<Element *, QET::Orientation> elements_to_rotate;
|
|
|
|
};
|
2007-09-27 17:42:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier un conducteur
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
class ChangeConductorCommand : public QUndoCommand {
|
2007-09-27 17:42:02 +00:00
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-22 20:27:39 +00:00
|
|
|
ChangeConductorCommand(Conductor *, const ConductorProfile &, const ConductorProfile &, Qt::Corner, QUndoCommand * = 0);
|
2007-10-03 17:02:39 +00:00
|
|
|
virtual ~ChangeConductorCommand();
|
2007-09-27 17:42:02 +00:00
|
|
|
private:
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorCommand(const ChangeConductorCommand &);
|
2007-09-27 17:42:02 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteur modifie
|
2007-10-03 17:02:39 +00:00
|
|
|
Conductor *conductor;
|
2007-10-06 18:37:21 +00:00
|
|
|
/// profil avant changement
|
2007-10-03 17:02:39 +00:00
|
|
|
ConductorProfile old_profile;
|
2007-10-06 18:37:21 +00:00
|
|
|
/// profil apres changement
|
2007-10-03 17:02:39 +00:00
|
|
|
ConductorProfile new_profile;
|
2007-10-22 20:27:39 +00:00
|
|
|
/// Type de trajet
|
|
|
|
Qt::Corner path_type;
|
2007-09-27 17:42:02 +00:00
|
|
|
/// booleen pour ne pas executer le premier redo()
|
|
|
|
bool first_redo;
|
|
|
|
};
|
2007-09-28 17:39:30 +00:00
|
|
|
|
2007-10-06 18:37:21 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action de reinitialiser des conducteurs
|
|
|
|
*/
|
|
|
|
class ResetConductorCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-22 20:27:39 +00:00
|
|
|
ResetConductorCommand(const QHash<Conductor *, ConductorProfilesGroup> &, QUndoCommand * = 0);
|
2007-10-06 18:37:21 +00:00
|
|
|
virtual ~ResetConductorCommand();
|
|
|
|
private:
|
|
|
|
ResetConductorCommand(const ResetConductorCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteurs reinitialises associes a leur ancien profil
|
2007-10-22 20:27:39 +00:00
|
|
|
QHash<Conductor *, ConductorProfilesGroup> conductors_profiles;
|
2007-10-06 18:37:21 +00:00
|
|
|
};
|
|
|
|
|
2007-09-28 17:39:30 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier les informations du cartouche d'un schema
|
|
|
|
*/
|
|
|
|
class ChangeInsetCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeInsetCommand(Diagram *, const InsetProperties &, const InsetProperties &, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeInsetCommand();
|
|
|
|
private:
|
|
|
|
ChangeInsetCommand(const ChangeInsetCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// schema modifie
|
2007-09-28 17:39:30 +00:00
|
|
|
Diagram *diagram;
|
2007-09-28 21:48:59 +00:00
|
|
|
/// proprietes avant changement
|
2007-09-28 17:39:30 +00:00
|
|
|
InsetProperties old_inset;
|
2007-09-28 21:48:59 +00:00
|
|
|
/// proprietes apres changement
|
2007-09-28 17:39:30 +00:00
|
|
|
InsetProperties new_inset;
|
|
|
|
};
|
2007-09-28 21:48:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier :
|
|
|
|
-le nombre de colonnes d'un schema
|
|
|
|
-la hauteur des colonnes
|
|
|
|
-la largeur des colonnes
|
|
|
|
-la hauteur des en-tetes des colonnes
|
|
|
|
*/
|
|
|
|
class ChangeBorderCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ChangeBorderCommand(Diagram *, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeBorderCommand();
|
|
|
|
private:
|
|
|
|
ChangeBorderCommand(const ChangeBorderCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
private:
|
|
|
|
virtual void applyChanges(int = 1);
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// schema modifie
|
2007-09-28 21:48:59 +00:00
|
|
|
Diagram *diagram;
|
|
|
|
public:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// nombre de colonnes ajoutees / enlevees
|
2007-09-28 21:48:59 +00:00
|
|
|
int columnsCountDifference;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// delta pour la hauteur des colonnes
|
2007-09-28 21:48:59 +00:00
|
|
|
qreal columnsHeightDifference;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// delta pour la largeur des colonnes
|
2007-09-28 21:48:59 +00:00
|
|
|
qreal columnsWidthDifference;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// delta pour la hauteur des entetes des colonnes
|
2007-09-28 21:48:59 +00:00
|
|
|
qreal headersHeightDifference;
|
|
|
|
};
|
2007-10-03 15:51:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de modifier les proprietes d'un conducteur
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
class ChangeConductorPropertiesCommand : public QUndoCommand {
|
2007-10-03 15:51:04 +00:00
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorPropertiesCommand(Conductor *, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeConductorPropertiesCommand();
|
2007-10-03 15:51:04 +00:00
|
|
|
private:
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorPropertiesCommand(const ChangeConductorPropertiesCommand &);
|
2007-10-03 15:51:04 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
2007-10-14 14:44:33 +00:00
|
|
|
virtual void setOldSettings(const ConductorProperties &);
|
|
|
|
virtual void setNewSettings(const ConductorProperties &);
|
2007-10-03 15:51:04 +00:00
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
2007-10-10 17:50:26 +00:00
|
|
|
/// conducteur modifie
|
2007-10-03 17:02:39 +00:00
|
|
|
Conductor *conductor;
|
2007-10-03 15:51:04 +00:00
|
|
|
/// anciennes proprietes
|
2007-10-14 14:44:33 +00:00
|
|
|
ConductorProperties old_properties;
|
2007-10-03 15:51:04 +00:00
|
|
|
/// nouvelles proprietes
|
2007-10-14 14:44:33 +00:00
|
|
|
ConductorProperties new_properties;
|
2007-10-10 17:50:26 +00:00
|
|
|
/// booleens indiquant si les proprietes ont ete definies ou non
|
2007-10-03 15:51:04 +00:00
|
|
|
bool old_settings_set;
|
|
|
|
bool new_settings_set;
|
|
|
|
};
|
2007-09-25 23:24:36 +00:00
|
|
|
#endif
|