2007-12-01 10:47:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2006-2007 Xavier Guerrin
|
|
|
|
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-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-10-07 18:52:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action de changer les noms d'un element
|
|
|
|
*/
|
|
|
|
class ChangeZValueCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2007-12-16 14:05:39 +00:00
|
|
|
/// Qualifie le type de changement de zValue
|
|
|
|
enum Option {
|
|
|
|
BringForward, ///< Amene la partie a l'avant-plan ; elle a alors la plus haute zValue
|
|
|
|
Raise, ///< Amene la partie un plan au-dessus ; la zValue de la partie est incrementee
|
|
|
|
Lower, ///< Envoie la partie un plan en-dessous ; la zValue de la partie est decrementee
|
|
|
|
SendBackward ///< Envoie la partie a l'arriere-plan ; elle a alors la plus faible zValue
|
|
|
|
};
|
2007-10-07 18:52:01 +00:00
|
|
|
ChangeZValueCommand(ElementScene *, Option, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeZValueCommand();
|
|
|
|
private:
|
|
|
|
ChangeZValueCommand(const ChangeZValueCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void applyBringForward(const QList<QGraphicsItem *> &);
|
|
|
|
void applyRaise(const QList<QGraphicsItem *> &);
|
|
|
|
void applyLower(const QList<QGraphicsItem *> &);
|
|
|
|
void applySendBackward(const QList<QGraphicsItem *> &);
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// zValues avant changement
|
|
|
|
QHash<QGraphicsItem *, qreal> undo_hash;
|
|
|
|
/// zValues apres changement
|
|
|
|
QHash<QGraphicsItem *, qreal> redo_hash;
|
|
|
|
/// Element edite auquel il faut appliquer les modifications
|
|
|
|
ElementScene *element;
|
|
|
|
/// type de traitement
|
|
|
|
Option option;
|
|
|
|
};
|
2007-12-09 10:54:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cette classe represente l'action d'autoriser ou non les connexions
|
|
|
|
internes pour un element.
|
|
|
|
*/
|
|
|
|
class AllowInternalConnectionsCommand : public QUndoCommand {
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
AllowInternalConnectionsCommand(ElementScene *, bool, QUndoCommand * = 0);
|
|
|
|
virtual ~AllowInternalConnectionsCommand();
|
|
|
|
private:
|
|
|
|
AllowInternalConnectionsCommand(const AllowInternalConnectionsCommand &);
|
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
/// Element edite auquel il faut appliquer les modifications
|
|
|
|
ElementScene *element;
|
|
|
|
/// autorisation des connexions internes apres modification
|
|
|
|
bool ic;
|
|
|
|
};
|
2007-08-23 15:33:55 +00:00
|
|
|
#endif
|