mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Refactored command classes related to the element editor by adding a common base class.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2025 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -17,6 +17,63 @@
|
|||||||
*/
|
*/
|
||||||
#include "editorcommands.h"
|
#include "editorcommands.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructs an ElementEditionCommand, thus embedding the provided \a scene and \a view.
|
||||||
|
@param parent Parent command
|
||||||
|
*/
|
||||||
|
ElementEditionCommand::ElementEditionCommand(ElementScene *scene, ElementView *view, QUndoCommand *parent):
|
||||||
|
QUndoCommand(parent),
|
||||||
|
editor_scene_(scene),
|
||||||
|
editor_view_(view)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructs an ElementEditionCommand, thus embedding the provided \a scene and \a view.
|
||||||
|
@param text Text describing the effect of the command
|
||||||
|
@param parent Parent command
|
||||||
|
*/
|
||||||
|
ElementEditionCommand::ElementEditionCommand(const QString &text, ElementScene *scene, ElementView *view, QUndoCommand *parent):
|
||||||
|
QUndoCommand(text, parent),
|
||||||
|
editor_scene_(scene),
|
||||||
|
editor_view_(view)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructor
|
||||||
|
*/
|
||||||
|
ElementEditionCommand::~ElementEditionCommand() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return the element editor/scene the command should take place on
|
||||||
|
*/
|
||||||
|
ElementScene *ElementEditionCommand::elementScene() const {
|
||||||
|
return(editor_scene_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Define \a scene as the element editor/scene the command should take place
|
||||||
|
*/
|
||||||
|
void ElementEditionCommand::setElementScene(ElementScene *scene) {
|
||||||
|
editor_scene_ = scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return the view the effect of the command should be rendered on
|
||||||
|
*/
|
||||||
|
ElementView *ElementEditionCommand::elementView() const {
|
||||||
|
return(editor_view_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Define \a view as the view the effect of the command should be rendered on
|
||||||
|
*/
|
||||||
|
void ElementEditionCommand::setElementView(ElementView *view) {
|
||||||
|
editor_view_ = view;
|
||||||
|
}
|
||||||
|
|
||||||
/*** DeletePartsCommand ***/
|
/*** DeletePartsCommand ***/
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -29,38 +86,37 @@ DeletePartsCommand::DeletePartsCommand(
|
|||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("suppression", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("suppression", "undo caption"), scene, 0, parent),
|
||||||
deleted_parts(parts),
|
deleted_parts(parts)
|
||||||
editor_scene(scene)
|
|
||||||
{
|
{
|
||||||
foreach(QGraphicsItem *qgi, deleted_parts) {
|
foreach(QGraphicsItem *qgi, deleted_parts) {
|
||||||
editor_scene -> qgiManager().manage(qgi);
|
editor_scene_ -> qgiManager().manage(qgi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur : detruit egalement les parties supprimees
|
/// Destructeur : detruit egalement les parties supprimees
|
||||||
DeletePartsCommand::~DeletePartsCommand() {
|
DeletePartsCommand::~DeletePartsCommand() {
|
||||||
foreach(QGraphicsItem *qgi, deleted_parts) {
|
foreach(QGraphicsItem *qgi, deleted_parts) {
|
||||||
editor_scene -> qgiManager().release(qgi);
|
editor_scene_ -> qgiManager().release(qgi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Restaure les parties supprimees
|
/// Restaure les parties supprimees
|
||||||
void DeletePartsCommand::undo() {
|
void DeletePartsCommand::undo() {
|
||||||
editor_scene -> blockSignals(true);
|
editor_scene_ -> blockSignals(true);
|
||||||
foreach(QGraphicsItem *qgi, deleted_parts) {
|
foreach(QGraphicsItem *qgi, deleted_parts) {
|
||||||
editor_scene -> addItem(qgi);
|
editor_scene_ -> addItem(qgi);
|
||||||
}
|
}
|
||||||
editor_scene -> blockSignals(false);
|
editor_scene_ -> blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supprime les parties
|
/// Supprime les parties
|
||||||
void DeletePartsCommand::redo() {
|
void DeletePartsCommand::redo() {
|
||||||
editor_scene -> blockSignals(true);
|
editor_scene_ -> blockSignals(true);
|
||||||
foreach(QGraphicsItem *qgi, deleted_parts) {
|
foreach(QGraphicsItem *qgi, deleted_parts) {
|
||||||
editor_scene -> removeItem(qgi);
|
editor_scene_ -> removeItem(qgi);
|
||||||
}
|
}
|
||||||
editor_scene -> blockSignals(false);
|
editor_scene_ -> blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** CutPartsCommand ***/
|
/*** CutPartsCommand ***/
|
||||||
@@ -75,10 +131,8 @@ PastePartsCommand::PastePartsCommand(
|
|||||||
const ElementContent &c,
|
const ElementContent &c,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(parent),
|
ElementEditionCommand(view ? view -> scene() : 0, view, parent),
|
||||||
content_(c),
|
content_(c),
|
||||||
editor_view_(view),
|
|
||||||
editor_scene_(view -> scene()),
|
|
||||||
uses_offset(false),
|
uses_offset(false),
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
@@ -173,12 +227,11 @@ MovePartsCommand::MovePartsCommand(
|
|||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("d\351placement", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("d\351placement", "undo caption"), scene, 0, parent),
|
||||||
movement(m),
|
movement(m),
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
moved_parts = parts;
|
moved_parts = parts;
|
||||||
editor_scene = scene;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -214,22 +267,21 @@ AddPartCommand::AddPartCommand(
|
|||||||
QGraphicsItem *p,
|
QGraphicsItem *p,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QString(QObject::tr("ajout %1", "undo caption")).arg(name), parent),
|
ElementEditionCommand(QString(QObject::tr("ajout %1", "undo caption")).arg(name), scene, 0, parent),
|
||||||
part(p),
|
part(p),
|
||||||
editor_scene(scene),
|
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
editor_scene -> qgiManager().manage(part);
|
editor_scene_ -> qgiManager().manage(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
AddPartCommand::~AddPartCommand() {
|
AddPartCommand::~AddPartCommand() {
|
||||||
editor_scene -> qgiManager().release(part);
|
editor_scene_ -> qgiManager().release(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Annule l'ajout
|
/// Annule l'ajout
|
||||||
void AddPartCommand::undo() {
|
void AddPartCommand::undo() {
|
||||||
editor_scene -> removeItem(part);
|
editor_scene_ -> removeItem(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait l'ajout
|
/// Refait l'ajout
|
||||||
@@ -239,16 +291,16 @@ void AddPartCommand::redo() {
|
|||||||
if (!part -> zValue()) {
|
if (!part -> zValue()) {
|
||||||
// the added part has no specific zValue already defined, we put it
|
// the added part has no specific zValue already defined, we put it
|
||||||
// above existing items (but still under terminals)
|
// above existing items (but still under terminals)
|
||||||
QList<QGraphicsItem *> existing_items = editor_scene -> zItems();
|
QList<QGraphicsItem *> existing_items = editor_scene_ -> zItems();
|
||||||
qreal z = existing_items.count() ? existing_items.last() -> zValue() + 1 : 1;
|
qreal z = existing_items.count() ? existing_items.last() -> zValue() + 1 : 1;
|
||||||
part -> setZValue(z);
|
part -> setZValue(z);
|
||||||
}
|
}
|
||||||
editor_scene -> clearSelection();
|
editor_scene_ -> clearSelection();
|
||||||
part -> setSelected(true);
|
part -> setSelected(true);
|
||||||
first_redo = false;
|
first_redo = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editor_scene -> addItem(part);
|
editor_scene_ -> addItem(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,7 +320,7 @@ ChangePartCommand::ChangePartCommand(
|
|||||||
const QVariant &new_v,
|
const QVariant &new_v,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QString(QObject::tr("modification %1", "undo caption")).arg(name), parent),
|
ElementEditionCommand(QString(QObject::tr("modification %1", "undo caption")).arg(name), 0, 0, parent),
|
||||||
cep(part),
|
cep(part),
|
||||||
property(prop),
|
property(prop),
|
||||||
old_value(old_v),
|
old_value(old_v),
|
||||||
@@ -303,7 +355,7 @@ ChangePolygonPointsCommand::ChangePolygonPointsCommand(
|
|||||||
const QVector<QPointF> &n_points,
|
const QVector<QPointF> &n_points,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification points polygone", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification points polygone", "undo caption"), 0, 0, parent),
|
||||||
polygon(p),
|
polygon(p),
|
||||||
old_points(o_points),
|
old_points(o_points),
|
||||||
new_points(n_points)
|
new_points(n_points)
|
||||||
@@ -343,8 +395,7 @@ ChangeHotspotCommand::ChangeHotspotCommand(
|
|||||||
const QPoint &o,
|
const QPoint &o,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification dimensions/hotspot", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification dimensions/hotspot", "undo caption"), element_scene, 0, parent),
|
||||||
element(element_scene),
|
|
||||||
size_before(size_1),
|
size_before(size_1),
|
||||||
size_after(size_2),
|
size_after(size_2),
|
||||||
hotspot_before(hotspot_1),
|
hotspot_before(hotspot_1),
|
||||||
@@ -359,26 +410,26 @@ ChangeHotspotCommand::~ChangeHotspotCommand() {
|
|||||||
|
|
||||||
/// Annule le changement
|
/// Annule le changement
|
||||||
void ChangeHotspotCommand::undo() {
|
void ChangeHotspotCommand::undo() {
|
||||||
QRectF sc(element -> sceneContent());
|
QRectF sc(editor_scene_ -> sceneContent());
|
||||||
|
|
||||||
element -> setWidth(size_before.width());
|
editor_scene_ -> setWidth(size_before.width());
|
||||||
element -> setHeight(size_before.height());
|
editor_scene_ -> setHeight(size_before.height());
|
||||||
element -> setHotspot(hotspot_before);
|
editor_scene_ -> setHotspot(hotspot_before);
|
||||||
if (!offset.isNull()) applyOffset(-offset);
|
if (!offset.isNull()) applyOffset(-offset);
|
||||||
|
|
||||||
element -> update(element -> sceneContent().unite(sc));
|
editor_scene_ -> update(editor_scene_ -> sceneContent().unite(sc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait le changement
|
/// Refait le changement
|
||||||
void ChangeHotspotCommand::redo() {
|
void ChangeHotspotCommand::redo() {
|
||||||
QRectF sc(element -> sceneContent());
|
QRectF sc(editor_scene_ -> sceneContent());
|
||||||
|
|
||||||
element -> setWidth(size_after.width());
|
editor_scene_ -> setWidth(size_after.width());
|
||||||
element -> setHeight(size_after.height());
|
editor_scene_ -> setHeight(size_after.height());
|
||||||
element -> setHotspot(hotspot_after);
|
editor_scene_ -> setHotspot(hotspot_after);
|
||||||
if (!offset.isNull()) applyOffset(offset);
|
if (!offset.isNull()) applyOffset(offset);
|
||||||
|
|
||||||
element -> update(element -> sceneContent().unite(sc));
|
editor_scene_ -> update(editor_scene_ -> sceneContent().unite(sc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,7 +437,7 @@ void ChangeHotspotCommand::redo() {
|
|||||||
@param o Translation a appliquer
|
@param o Translation a appliquer
|
||||||
*/
|
*/
|
||||||
void ChangeHotspotCommand::applyOffset(const QPointF &o) {
|
void ChangeHotspotCommand::applyOffset(const QPointF &o) {
|
||||||
foreach(QGraphicsItem *qgi, element -> items()) {
|
foreach(QGraphicsItem *qgi, editor_scene_ -> items()) {
|
||||||
qgi -> translate(o.x(), o.y());
|
qgi -> translate(o.x(), o.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,10 +455,9 @@ ChangeNamesCommand::ChangeNamesCommand(
|
|||||||
const NamesList &after,
|
const NamesList &after,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification noms", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification noms", "undo caption"), element_scene, 0, parent),
|
||||||
names_before(before),
|
names_before(before),
|
||||||
names_after(after),
|
names_after(after)
|
||||||
element(element_scene)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,12 +467,12 @@ ChangeNamesCommand::~ChangeNamesCommand() {
|
|||||||
|
|
||||||
/// Annule le changement
|
/// Annule le changement
|
||||||
void ChangeNamesCommand::undo() {
|
void ChangeNamesCommand::undo() {
|
||||||
element -> setNames(names_before);
|
editor_scene_ -> setNames(names_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait le changement
|
/// Refait le changement
|
||||||
void ChangeNamesCommand::redo() {
|
void ChangeNamesCommand::redo() {
|
||||||
element -> setNames(names_after);
|
editor_scene_ -> setNames(names_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -438,10 +488,9 @@ ChangeOrientationsCommand::ChangeOrientationsCommand(
|
|||||||
const OrientationSet &after,
|
const OrientationSet &after,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification orientations", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification orientations", "undo caption"), element_scene, 0, parent),
|
||||||
ori_before(before),
|
ori_before(before),
|
||||||
ori_after(after),
|
ori_after(after)
|
||||||
element(element_scene)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,12 +500,12 @@ ChangeOrientationsCommand::~ChangeOrientationsCommand() {
|
|||||||
|
|
||||||
/// Annule le changement
|
/// Annule le changement
|
||||||
void ChangeOrientationsCommand::undo() {
|
void ChangeOrientationsCommand::undo() {
|
||||||
element -> setOrientations(ori_before);
|
editor_scene_ -> setOrientations(ori_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait le changement
|
/// Refait le changement
|
||||||
void ChangeOrientationsCommand::redo() {
|
void ChangeOrientationsCommand::redo() {
|
||||||
element -> setOrientations(ori_after);
|
editor_scene_ -> setOrientations(ori_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -470,12 +519,11 @@ ChangeZValueCommand::ChangeZValueCommand(
|
|||||||
ChangeZValueCommand::Option o,
|
ChangeZValueCommand::Option o,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(parent),
|
ElementEditionCommand(elmt, 0, parent),
|
||||||
element(elmt),
|
|
||||||
option(o)
|
option(o)
|
||||||
{
|
{
|
||||||
// recupere les parties de l'elements, sauf les bornes
|
// recupere les parties de l'elements, sauf les bornes
|
||||||
QList<QGraphicsItem *> items_list = element -> zItems();
|
QList<QGraphicsItem *> items_list = editor_scene_ -> zItems();
|
||||||
|
|
||||||
// prend un snapshot des zValues
|
// prend un snapshot des zValues
|
||||||
foreach(QGraphicsItem *qgi, items_list) undo_hash.insert(qgi, qgi -> zValue());
|
foreach(QGraphicsItem *qgi, items_list) undo_hash.insert(qgi, qgi -> zValue());
|
||||||
@@ -590,8 +638,7 @@ void ChangeZValueCommand::applySendBackward(const QList<QGraphicsItem *> &items_
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, QUndoCommand *parent) :
|
AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, QUndoCommand *parent) :
|
||||||
QUndoCommand(QObject::tr("modification connexions internes", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification connexions internes", "undo caption"), elmt, 0, parent),
|
||||||
element(elmt),
|
|
||||||
ic(allow)
|
ic(allow)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -602,12 +649,12 @@ AllowInternalConnectionsCommand::~AllowInternalConnectionsCommand() {
|
|||||||
|
|
||||||
/// Annule le changement d'autorisation pour les connexions internes
|
/// Annule le changement d'autorisation pour les connexions internes
|
||||||
void AllowInternalConnectionsCommand::undo() {
|
void AllowInternalConnectionsCommand::undo() {
|
||||||
element -> setInternalConnections(!ic);
|
editor_scene_ -> setInternalConnections(!ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait le changement d'autorisation pour les connexions internes
|
/// Refait le changement d'autorisation pour les connexions internes
|
||||||
void AllowInternalConnectionsCommand::redo() {
|
void AllowInternalConnectionsCommand::redo() {
|
||||||
element -> setInternalConnections(ic);
|
editor_scene_ -> setInternalConnections(ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -618,8 +665,7 @@ void AllowInternalConnectionsCommand::redo() {
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
ChangeInformationsCommand::ChangeInformationsCommand(ElementScene *elmt, const QString &old_infos, const QString &new_infos, QUndoCommand *parent) :
|
ChangeInformationsCommand::ChangeInformationsCommand(ElementScene *elmt, const QString &old_infos, const QString &new_infos, QUndoCommand *parent) :
|
||||||
QUndoCommand(QObject::tr("modification informations complementaires", "undo caption"), parent),
|
ElementEditionCommand(QObject::tr("modification informations complementaires", "undo caption"), elmt, 0, parent),
|
||||||
element(elmt),
|
|
||||||
old_informations_(old_infos),
|
old_informations_(old_infos),
|
||||||
new_informations_(new_infos)
|
new_informations_(new_infos)
|
||||||
{
|
{
|
||||||
@@ -631,10 +677,10 @@ ChangeInformationsCommand::~ChangeInformationsCommand() {
|
|||||||
|
|
||||||
/// Annule le changement d'autorisation pour les connexions internes
|
/// Annule le changement d'autorisation pour les connexions internes
|
||||||
void ChangeInformationsCommand::undo() {
|
void ChangeInformationsCommand::undo() {
|
||||||
element -> setInformations(old_informations_);
|
editor_scene_ -> setInformations(old_informations_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait le changement d'autorisation pour les connexions internes
|
/// Refait le changement d'autorisation pour les connexions internes
|
||||||
void ChangeInformationsCommand::redo() {
|
void ChangeInformationsCommand::redo() {
|
||||||
element -> setInformations(new_informations_);
|
editor_scene_ -> setInformations(new_informations_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,40 @@
|
|||||||
#include "elementcontent.h"
|
#include "elementcontent.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
|
/**
|
||||||
|
ElementEditionCommand is the base class for all commands classes involved in
|
||||||
|
the edition of an electrical element. It provides commonly required methods
|
||||||
|
and attributes, such as accessors to the modified scene and view.
|
||||||
|
*/
|
||||||
|
class ElementEditionCommand : public QUndoCommand {
|
||||||
|
// constructors, destructor
|
||||||
|
public:
|
||||||
|
ElementEditionCommand(ElementScene * = 0, ElementView * = 0, QUndoCommand * = 0);
|
||||||
|
ElementEditionCommand(const QString &, ElementScene * = 0, ElementView * = 0, QUndoCommand * = 0);
|
||||||
|
virtual ~ElementEditionCommand();
|
||||||
|
private:
|
||||||
|
ElementEditionCommand(const ElementEditionCommand &);
|
||||||
|
|
||||||
|
// methods
|
||||||
|
public:
|
||||||
|
ElementScene *elementScene() const;
|
||||||
|
void setElementScene(ElementScene *);
|
||||||
|
ElementView *elementView() const;
|
||||||
|
void setElementView(ElementView *);
|
||||||
|
|
||||||
|
// attributes
|
||||||
|
protected:
|
||||||
|
/// Element editor/view/scene the command should take place on
|
||||||
|
ElementScene *editor_scene_;
|
||||||
|
ElementView *editor_view_;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command deletes one or several primitives/parts when editing an
|
This command deletes one or several primitives/parts when editing an
|
||||||
electrical element.
|
electrical element.
|
||||||
*/
|
*/
|
||||||
class DeletePartsCommand : public QUndoCommand {
|
class DeletePartsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
DeletePartsCommand(ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
DeletePartsCommand(ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
||||||
@@ -45,14 +74,12 @@ class DeletePartsCommand : public QUndoCommand {
|
|||||||
private:
|
private:
|
||||||
/// Deleted primitives
|
/// Deleted primitives
|
||||||
QList<QGraphicsItem *> deleted_parts;
|
QList<QGraphicsItem *> deleted_parts;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *editor_scene;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command pastes primitives when editing an electrical element.
|
This command pastes primitives when editing an electrical element.
|
||||||
*/
|
*/
|
||||||
class PastePartsCommand : public QUndoCommand {
|
class PastePartsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PastePartsCommand(ElementView *, const ElementContent &, QUndoCommand * = 0);
|
PastePartsCommand(ElementView *, const ElementContent &, QUndoCommand * = 0);
|
||||||
@@ -70,9 +97,6 @@ class PastePartsCommand : public QUndoCommand {
|
|||||||
private:
|
private:
|
||||||
/// Pasted content
|
/// Pasted content
|
||||||
ElementContent content_;
|
ElementContent content_;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementView *editor_view_;
|
|
||||||
ElementScene *editor_scene_;
|
|
||||||
/// Data required to undo a copy/paste with offset
|
/// Data required to undo a copy/paste with offset
|
||||||
int old_offset_paste_count_;
|
int old_offset_paste_count_;
|
||||||
QPointF old_start_top_left_corner_;
|
QPointF old_start_top_left_corner_;
|
||||||
@@ -98,7 +122,7 @@ class CutPartsCommand : public DeletePartsCommand {
|
|||||||
/**
|
/**
|
||||||
This command moves primitives when editing an electrical element.
|
This command moves primitives when editing an electrical element.
|
||||||
*/
|
*/
|
||||||
class MovePartsCommand : public QUndoCommand {
|
class MovePartsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
MovePartsCommand(const QPointF &, ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
MovePartsCommand(const QPointF &, ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
||||||
@@ -115,8 +139,6 @@ class MovePartsCommand : public QUndoCommand {
|
|||||||
private:
|
private:
|
||||||
/// List of moved primitives
|
/// List of moved primitives
|
||||||
QList<QGraphicsItem *> moved_parts;
|
QList<QGraphicsItem *> moved_parts;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *editor_scene;
|
|
||||||
/// applied movement
|
/// applied movement
|
||||||
QPointF movement;
|
QPointF movement;
|
||||||
/// Prevent the first call to redo()
|
/// Prevent the first call to redo()
|
||||||
@@ -126,7 +148,7 @@ class MovePartsCommand : public QUndoCommand {
|
|||||||
/**
|
/**
|
||||||
This command adds a primitive when editing an electrical element.
|
This command adds a primitive when editing an electrical element.
|
||||||
*/
|
*/
|
||||||
class AddPartCommand : public QUndoCommand {
|
class AddPartCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
AddPartCommand(const QString &, ElementScene *, QGraphicsItem *, QUndoCommand * = 0);
|
AddPartCommand(const QString &, ElementScene *, QGraphicsItem *, QUndoCommand * = 0);
|
||||||
@@ -143,8 +165,6 @@ class AddPartCommand : public QUndoCommand {
|
|||||||
private:
|
private:
|
||||||
/// Added primitive
|
/// Added primitive
|
||||||
QGraphicsItem *part;
|
QGraphicsItem *part;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *editor_scene;
|
|
||||||
/// Prevent the first call to redo()
|
/// Prevent the first call to redo()
|
||||||
bool first_redo;
|
bool first_redo;
|
||||||
};
|
};
|
||||||
@@ -153,7 +173,7 @@ class AddPartCommand : public QUndoCommand {
|
|||||||
This command changes a property of a primitive when editing an electrical
|
This command changes a property of a primitive when editing an electrical
|
||||||
element.
|
element.
|
||||||
*/
|
*/
|
||||||
class ChangePartCommand : public QUndoCommand {
|
class ChangePartCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &, const QVariant &, QUndoCommand * = 0);
|
ChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &, const QVariant &, QUndoCommand * = 0);
|
||||||
@@ -182,7 +202,7 @@ class ChangePartCommand : public QUndoCommand {
|
|||||||
This command changes the points of a polygon when editing an electrical
|
This command changes the points of a polygon when editing an electrical
|
||||||
element.
|
element.
|
||||||
*/
|
*/
|
||||||
class ChangePolygonPointsCommand : public QUndoCommand {
|
class ChangePolygonPointsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangePolygonPointsCommand(PartPolygon *, const QVector<QPointF> &, const QVector<QPointF> &, QUndoCommand * = 0);
|
ChangePolygonPointsCommand(PartPolygon *, const QVector<QPointF> &, const QVector<QPointF> &, QUndoCommand * = 0);
|
||||||
@@ -208,7 +228,7 @@ class ChangePolygonPointsCommand : public QUndoCommand {
|
|||||||
This command changes the dimensions and/or the hotspot of an electrical
|
This command changes the dimensions and/or the hotspot of an electrical
|
||||||
element.
|
element.
|
||||||
*/
|
*/
|
||||||
class ChangeHotspotCommand : public QUndoCommand {
|
class ChangeHotspotCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeHotspotCommand(ElementScene *, const QSize &, const QSize &, const QPoint &, const QPoint &, const QPoint & = QPoint(), QUndoCommand * = 0);
|
ChangeHotspotCommand(ElementScene *, const QSize &, const QSize &, const QPoint &, const QPoint &, const QPoint & = QPoint(), QUndoCommand * = 0);
|
||||||
@@ -225,8 +245,6 @@ class ChangeHotspotCommand : public QUndoCommand {
|
|||||||
void applyOffset(const QPointF &);
|
void applyOffset(const QPointF &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
/// Former dimensions
|
/// Former dimensions
|
||||||
QSize size_before;
|
QSize size_before;
|
||||||
/// new dimensions
|
/// new dimensions
|
||||||
@@ -242,7 +260,7 @@ class ChangeHotspotCommand : public QUndoCommand {
|
|||||||
/**
|
/**
|
||||||
This command changes the translated names of an electrical element.
|
This command changes the translated names of an electrical element.
|
||||||
*/
|
*/
|
||||||
class ChangeNamesCommand : public QUndoCommand {
|
class ChangeNamesCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand * = 0);
|
ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand * = 0);
|
||||||
@@ -261,14 +279,12 @@ class ChangeNamesCommand : public QUndoCommand {
|
|||||||
NamesList names_before;
|
NamesList names_before;
|
||||||
/// List of new names
|
/// List of new names
|
||||||
NamesList names_after;
|
NamesList names_after;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command changes the allowed orientations of an electrical element.
|
This command changes the allowed orientations of an electrical element.
|
||||||
*/
|
*/
|
||||||
class ChangeOrientationsCommand : public QUndoCommand {
|
class ChangeOrientationsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeOrientationsCommand(ElementScene *, const OrientationSet &, const OrientationSet &, QUndoCommand * = 0);
|
ChangeOrientationsCommand(ElementScene *, const OrientationSet &, const OrientationSet &, QUndoCommand * = 0);
|
||||||
@@ -287,15 +303,13 @@ class ChangeOrientationsCommand : public QUndoCommand {
|
|||||||
OrientationSet ori_before;
|
OrientationSet ori_before;
|
||||||
/// New orientations
|
/// New orientations
|
||||||
OrientationSet ori_after;
|
OrientationSet ori_after;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command changes the zValue of a set of primitives when editing an
|
This command changes the zValue of a set of primitives when editing an
|
||||||
electrical element.
|
electrical element.
|
||||||
*/
|
*/
|
||||||
class ChangeZValueCommand : public QUndoCommand {
|
class ChangeZValueCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
/// List the various kind of changes for the zValue
|
/// List the various kind of changes for the zValue
|
||||||
@@ -327,8 +341,6 @@ class ChangeZValueCommand : public QUndoCommand {
|
|||||||
QHash<QGraphicsItem *, qreal> undo_hash;
|
QHash<QGraphicsItem *, qreal> undo_hash;
|
||||||
/// associates impacted primitives with their new zValues
|
/// associates impacted primitives with their new zValues
|
||||||
QHash<QGraphicsItem *, qreal> redo_hash;
|
QHash<QGraphicsItem *, qreal> redo_hash;
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
/// kind of treatment to apply
|
/// kind of treatment to apply
|
||||||
Option option;
|
Option option;
|
||||||
};
|
};
|
||||||
@@ -337,7 +349,7 @@ class ChangeZValueCommand : public QUndoCommand {
|
|||||||
This command enables or disables internal connections for an electrical
|
This command enables or disables internal connections for an electrical
|
||||||
element.
|
element.
|
||||||
*/
|
*/
|
||||||
class AllowInternalConnectionsCommand : public QUndoCommand {
|
class AllowInternalConnectionsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
AllowInternalConnectionsCommand(ElementScene *, bool, QUndoCommand * = 0);
|
AllowInternalConnectionsCommand(ElementScene *, bool, QUndoCommand * = 0);
|
||||||
@@ -352,8 +364,6 @@ class AllowInternalConnectionsCommand : public QUndoCommand {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
/// whether internal connections are allowed afterward
|
/// whether internal connections are allowed afterward
|
||||||
bool ic;
|
bool ic;
|
||||||
};
|
};
|
||||||
@@ -361,7 +371,7 @@ class AllowInternalConnectionsCommand : public QUndoCommand {
|
|||||||
/**
|
/**
|
||||||
This command changes extra information carried by an electrical element.
|
This command changes extra information carried by an electrical element.
|
||||||
*/
|
*/
|
||||||
class ChangeInformationsCommand : public QUndoCommand {
|
class ChangeInformationsCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand * = 0);
|
ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand * = 0);
|
||||||
@@ -376,8 +386,6 @@ class ChangeInformationsCommand : public QUndoCommand {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
/// Element editor/view/scene the command should take place on
|
|
||||||
ElementScene *element;
|
|
||||||
/// Former information
|
/// Former information
|
||||||
QString old_informations_;
|
QString old_informations_;
|
||||||
/// New information
|
/// New information
|
||||||
|
|||||||
Reference in New Issue
Block a user