2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2008-02-06 19:40:45 +00:00
|
|
|
Copyright 2006-2008 Xavier Guerrin
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
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-11-09 13:06:51 +00:00
|
|
|
#include "diagramcontent.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;
|
|
|
|
};
|
|
|
|
|
2007-10-27 13:18:17 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'action d'ajouter du texte au schema
|
|
|
|
*/
|
|
|
|
class AddTextCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
AddTextCommand(Diagram *, DiagramTextItem *, const QPointF &, QUndoCommand * = 0);
|
|
|
|
virtual ~AddTextCommand();
|
|
|
|
private:
|
|
|
|
AddTextCommand(const AddTextCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// texte ajoute
|
|
|
|
DiagramTextItem *textitem;
|
|
|
|
/// schema sur lequel on ajoute le texte
|
|
|
|
Diagram *diagram;
|
|
|
|
/// position du texte sur le schema
|
|
|
|
QPointF position;
|
|
|
|
};
|
|
|
|
|
2007-09-25 23:24:36 +00:00
|
|
|
/**
|
|
|
|
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-11-09 13:06:51 +00:00
|
|
|
DeleteElementsCommand(Diagram *, const DiagramContent &, 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-11-09 13:06:51 +00:00
|
|
|
/// contenu enleve
|
|
|
|
DiagramContent removed_content;
|
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-11-09 13:06:51 +00:00
|
|
|
PasteDiagramCommand(Diagram *, const DiagramContent &, 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-11-09 13:06:51 +00:00
|
|
|
/// contenu ajoute
|
|
|
|
DiagramContent content;
|
2007-09-26 12:36:31 +00:00
|
|
|
/// schema sur lequel on colle les elements et conducteurs
|
|
|
|
Diagram *diagram;
|
2007-11-11 16:12:45 +00:00
|
|
|
/// entien pour filtrer le contenu du schema
|
|
|
|
int filter;
|
2007-09-26 12:36:31 +00:00
|
|
|
/// 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-11-09 13:06:51 +00:00
|
|
|
CutDiagramCommand(Diagram *, const DiagramContent &, 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-11-09 13:06:51 +00:00
|
|
|
MoveElementsCommand(Diagram *, const DiagramContent &, 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-11-09 13:06:51 +00:00
|
|
|
/// contenu a deplacer
|
|
|
|
DiagramContent content_to_move;
|
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
|