2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 The QElectroTech Team
|
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
|
2010-04-18 17:59:54 +00:00
|
|
|
#include <QtGui>
|
2008-08-15 12:46:22 +00:00
|
|
|
#include "borderproperties.h"
|
2013-11-14 10:11:22 +00:00
|
|
|
#include "qetgraphicsitem/conductor.h"
|
2007-10-14 14:44:33 +00:00
|
|
|
#include "conductorproperties.h"
|
2010-04-18 17:59:54 +00:00
|
|
|
#include "diagramcontent.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
#include "titleblockproperties.h"
|
2010-04-18 17:59:54 +00:00
|
|
|
#include "qet.h"
|
2014-02-28 14:30:59 +00:00
|
|
|
#include "qetgraphicsitem/qetshapeitem.h"
|
2014-07-21 20:44:32 +00:00
|
|
|
#include "conductorprofile.h"
|
2014-10-10 08:58:44 +00:00
|
|
|
#include "diagram.h"
|
|
|
|
|
2010-04-18 17:59:54 +00:00
|
|
|
class DiagramTextItem;
|
|
|
|
class Element;
|
2010-04-24 20:42:20 +00:00
|
|
|
class ElementTextItem;
|
2010-04-18 17:59:54 +00:00
|
|
|
class IndependentTextItem;
|
2013-08-24 15:18:45 +00:00
|
|
|
class DiagramImageItem;
|
2010-04-18 17:59:54 +00:00
|
|
|
|
2007-09-25 23:24:36 +00:00
|
|
|
/**
|
2014-10-10 08:58:44 +00:00
|
|
|
* @brief The AddItemCommand class
|
|
|
|
* This command add an item in a diagram
|
|
|
|
* The item to add is template, but must be QGraphicsItem or derived.
|
|
|
|
*/
|
|
|
|
template <typename QGI>
|
|
|
|
class AddItemCommand : public QUndoCommand {
|
2013-08-24 15:18:45 +00:00
|
|
|
public:
|
2014-10-10 08:58:44 +00:00
|
|
|
AddItemCommand(QGI item, Diagram *diagram, const QPointF &pos = QPointF(), QUndoCommand *parent = nullptr) :
|
|
|
|
QUndoCommand (parent),
|
|
|
|
m_item (item),
|
|
|
|
m_diagram (diagram),
|
|
|
|
m_pos(pos)
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Ajouter ") + itemText(item));
|
|
|
|
m_diagram -> qgiManager().manage(m_item);
|
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
|
2014-10-10 08:58:44 +00:00
|
|
|
virtual ~AddItemCommand() {
|
|
|
|
m_diagram -> qgiManager().release(m_item);
|
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
|
2014-10-10 08:58:44 +00:00
|
|
|
virtual void undo() {
|
|
|
|
m_diagram -> showMe();
|
|
|
|
m_diagram -> removeItem(m_item);
|
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
|
2014-10-10 08:58:44 +00:00
|
|
|
virtual void redo() {
|
|
|
|
m_diagram -> showMe();
|
|
|
|
m_diagram -> addItem(m_item);
|
|
|
|
m_item -> setPos(m_pos);
|
|
|
|
}
|
2014-02-28 14:30:59 +00:00
|
|
|
|
|
|
|
private:
|
2014-10-10 08:58:44 +00:00
|
|
|
QGI m_item;
|
|
|
|
Diagram *m_diagram;
|
|
|
|
QPointF m_pos;
|
2014-02-28 14:30:59 +00:00
|
|
|
};
|
|
|
|
|
2007-09-25 23:24:36 +00:00
|
|
|
/**
|
2014-10-10 08:58:44 +00:00
|
|
|
*Template function: return generique name of a QGraphicsItem.
|
|
|
|
*/
|
|
|
|
template <typename T>
|
|
|
|
QString itemText(T item) {
|
|
|
|
Q_UNUSED (item);
|
|
|
|
return QObject::tr("un item");
|
|
|
|
}
|
2007-09-25 23:24:36 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command removes content from a particular diagram.
|
2007-09-25 23:24:36 +00:00
|
|
|
*/
|
|
|
|
class DeleteElementsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-25 23:24:36 +00:00
|
|
|
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 &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-25 23:24:36 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-25 23:24:36 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// removed content
|
2007-11-09 13:06:51 +00:00
|
|
|
DiagramContent removed_content;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// diagram which the content is removed from
|
2007-09-25 23:24:36 +00:00
|
|
|
Diagram *diagram;
|
|
|
|
};
|
|
|
|
|
2007-09-26 12:36:31 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command pastes some content onto a particular diagram.
|
2007-09-26 12:36:31 +00:00
|
|
|
*/
|
|
|
|
class PasteDiagramCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-26 12:36:31 +00:00
|
|
|
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 &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
2007-09-26 12:36:31 +00:00
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-26 12:36:31 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// pasted content
|
2007-11-09 13:06:51 +00:00
|
|
|
DiagramContent content;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// diagram content is pasted onto
|
2007-09-26 12:36:31 +00:00
|
|
|
Diagram *diagram;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// filter stating what kinds of items should be pasted
|
2007-11-11 16:12:45 +00:00
|
|
|
int filter;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2007-09-26 12:36:31 +00:00
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command cuts content from a particular diagram.
|
2007-09-26 12:36:31 +00:00
|
|
|
*/
|
|
|
|
class CutDiagramCommand : public DeleteElementsCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-26 12:36:31 +00:00
|
|
|
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
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command moves some content on a particular diagram.
|
2007-09-26 17:14:09 +00:00
|
|
|
*/
|
|
|
|
class MoveElementsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-26 17:14:09 +00:00
|
|
|
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 &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-26 17:14:09 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
virtual void move(const QPointF &);
|
2010-05-08 21:24:43 +00:00
|
|
|
virtual void addConductorTextItemMovement(ConductorTextItem *, const QPointF &, const QPointF &);
|
2014-07-09 16:50:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void setupAnimation (QObject * target, const QByteArray &propertyName, const QVariant start, const QVariant end);
|
2007-09-26 17:14:09 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-26 17:14:09 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// diagram the movement takes place on.
|
2007-09-26 17:14:09 +00:00
|
|
|
Diagram *diagram;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// moved content
|
2007-11-09 13:06:51 +00:00
|
|
|
DiagramContent content_to_move;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// applied movement
|
2007-09-26 17:14:09 +00:00
|
|
|
QPointF movement;
|
2014-07-09 16:50:30 +00:00
|
|
|
///animation group
|
|
|
|
QParallelAnimationGroup *m_anim_group;
|
2010-05-08 21:24:43 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Moving elements impacts their conductors: either they are moved, or their path
|
|
|
|
needs to be generated again, which in turn tends to move their child text
|
|
|
|
items. This attribute holds both new and previous positions for each moved
|
|
|
|
text item.
|
2010-05-08 21:24:43 +00:00
|
|
|
*/
|
|
|
|
QHash<ConductorTextItem *, QPair<QPointF, QPointF> > moved_conductor_texts_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2007-09-26 17:14:09 +00:00
|
|
|
bool first_redo;
|
|
|
|
};
|
2007-09-26 22:57:53 +00:00
|
|
|
|
2010-04-24 20:42:20 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command moves text items related to elements on a particular diagram.
|
2010-04-24 20:42:20 +00:00
|
|
|
*/
|
|
|
|
class MoveElementsTextsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2010-04-24 20:42:20 +00:00
|
|
|
public:
|
|
|
|
MoveElementsTextsCommand(Diagram *, const QSet<ElementTextItem *> &, const QPointF &m, QUndoCommand * = 0);
|
|
|
|
virtual ~MoveElementsTextsCommand();
|
|
|
|
private:
|
|
|
|
MoveElementsTextsCommand(const MoveElementsTextsCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2010-04-24 20:42:20 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
virtual void move(const QPointF &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2010-04-24 20:42:20 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// diagram the movement takes place on.
|
2010-04-24 20:42:20 +00:00
|
|
|
Diagram *diagram;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// text items to be moved
|
2010-04-24 20:42:20 +00:00
|
|
|
QSet<ElementTextItem *> texts_to_move;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// applied movement
|
2010-04-24 20:42:20 +00:00
|
|
|
QPointF movement;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2010-04-24 20:42:20 +00:00
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
2010-05-08 21:24:43 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command moves text items related to conductors on a particular
|
|
|
|
diagram.
|
2010-05-08 21:24:43 +00:00
|
|
|
*/
|
|
|
|
class MoveConductorsTextsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2010-05-08 21:24:43 +00:00
|
|
|
public:
|
|
|
|
MoveConductorsTextsCommand(Diagram *, QUndoCommand * = 0);
|
|
|
|
virtual ~MoveConductorsTextsCommand();
|
|
|
|
private:
|
|
|
|
MoveConductorsTextsCommand(const MoveConductorsTextsCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2010-05-08 21:24:43 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
virtual void addTextMovement(ConductorTextItem *, const QPointF &, const QPointF &, bool = false);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void regenerateTextLabel();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2010-05-08 21:24:43 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// diagram the movement takes place on.
|
2010-05-08 21:24:43 +00:00
|
|
|
Diagram *diagram;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// text items to be moved
|
2010-05-08 21:24:43 +00:00
|
|
|
QHash<ConductorTextItem *, QPair<QPointF, bool> > texts_to_move_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2010-05-08 21:24:43 +00:00
|
|
|
bool first_redo;
|
|
|
|
};
|
|
|
|
|
2007-09-26 22:57:53 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This commad modifies a text item.
|
2007-09-26 22:57:53 +00:00
|
|
|
*/
|
|
|
|
class ChangeDiagramTextCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-26 22:57:53 +00:00
|
|
|
public:
|
|
|
|
ChangeDiagramTextCommand(DiagramTextItem *, const QString &before, const QString &after, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeDiagramTextCommand();
|
|
|
|
private:
|
|
|
|
ChangeDiagramTextCommand(const ChangeDiagramTextCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-26 22:57:53 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-26 22:57:53 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// modified text item
|
2007-09-26 22:57:53 +00:00
|
|
|
DiagramTextItem *text_item;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// former text
|
2007-09-26 22:57:53 +00:00
|
|
|
QString text_before;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// new text
|
2007-09-26 22:57:53 +00:00
|
|
|
QString text_after;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2007-09-26 22:57:53 +00:00
|
|
|
bool first_redo;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2007-09-26 22:57:53 +00:00
|
|
|
};
|
2007-09-27 15:36:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command rotates several elements or text items by a particular angle.
|
2007-09-27 15:36:15 +00:00
|
|
|
*/
|
|
|
|
class RotateElementsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-27 15:36:15 +00:00
|
|
|
public:
|
2013-11-14 10:11:22 +00:00
|
|
|
RotateElementsCommand(const QList<Element *> &elements, const QList<DiagramTextItem *> &, const QList<DiagramImageItem *> &, QUndoCommand * = 0);
|
2007-09-27 15:36:15 +00:00
|
|
|
virtual ~RotateElementsCommand();
|
|
|
|
private:
|
|
|
|
RotateElementsCommand(const RotateElementsCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-27 15:36:15 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-27 15:36:15 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// hold rotated elements along with their former orientation
|
2013-11-14 10:11:22 +00:00
|
|
|
QList<Element *> elements_to_rotate;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// text items to be rotated
|
2009-11-29 21:56:48 +00:00
|
|
|
QList<DiagramTextItem *> texts_to_rotate;
|
2013-08-24 15:18:45 +00:00
|
|
|
/// images item to be rotated
|
|
|
|
QList<DiagramImageItem *> images_to_rotate;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// angle of rotation to be applied to text items
|
2010-02-11 23:35:04 +00:00
|
|
|
qreal applied_rotation_angle_;
|
2013-06-19 21:40:28 +00:00
|
|
|
/// previous state of each conductor text item
|
|
|
|
QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2010-02-11 23:35:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command directs several text items to a same particular angle of
|
|
|
|
rotation.
|
2010-02-11 23:35:04 +00:00
|
|
|
*/
|
|
|
|
class RotateTextsCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2010-02-11 23:35:04 +00:00
|
|
|
public:
|
|
|
|
RotateTextsCommand(const QHash<DiagramTextItem *, double> &, double, QUndoCommand * = 0);
|
|
|
|
RotateTextsCommand(const QList<DiagramTextItem *> &, double, QUndoCommand * = 0);
|
|
|
|
virtual ~RotateTextsCommand();
|
|
|
|
private:
|
|
|
|
RotateTextsCommand(const RotateTextsCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2010-02-11 23:35:04 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void defineCommandName();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2010-02-11 23:35:04 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// hold rotated text items along with their former angle of rotation
|
2010-02-11 23:35:04 +00:00
|
|
|
QHash<DiagramTextItem *, double> texts_to_rotate;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// angle of rotation of all text items after the command
|
2010-02-11 23:35:04 +00:00
|
|
|
double applied_rotation_angle_;
|
2013-06-19 21:40:28 +00:00
|
|
|
/// previous state of each conductor text item
|
|
|
|
QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2007-09-27 15:36:15 +00:00
|
|
|
};
|
2007-09-27 17:42:02 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command changes a particular conductor.
|
2007-09-27 17:42:02 +00:00
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
class ChangeConductorCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-27 17:42:02 +00:00
|
|
|
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
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-27 17:42:02 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
2010-05-08 21:24:43 +00:00
|
|
|
virtual void setConductorTextItemMove(const QPointF &, const QPointF &);
|
2007-09-27 17:42:02 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-27 17:42:02 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// changed conductor
|
2007-10-03 17:02:39 +00:00
|
|
|
Conductor *conductor;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// profile before the change
|
2007-10-03 17:02:39 +00:00
|
|
|
ConductorProfile old_profile;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// profile after the change
|
2007-10-03 17:02:39 +00:00
|
|
|
ConductorProfile new_profile;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Path type of the modified conductor
|
2007-10-22 20:27:39 +00:00
|
|
|
Qt::Corner path_type;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// position of the text item before the change
|
2010-05-08 21:24:43 +00:00
|
|
|
QPointF text_pos_before_mov_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// position of the text item after the change
|
2010-05-08 21:24:43 +00:00
|
|
|
QPointF text_pos_after_mov_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// prevent the first call to redo()
|
2007-09-27 17:42:02 +00:00
|
|
|
bool first_redo;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2007-09-27 17:42:02 +00:00
|
|
|
};
|
2007-09-28 17:39:30 +00:00
|
|
|
|
2007-10-06 18:37:21 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command resets conductor paths.
|
2007-10-06 18:37:21 +00:00
|
|
|
*/
|
|
|
|
class ResetConductorCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-10-06 18:37:21 +00:00
|
|
|
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 &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-10-06 18:37:21 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-10-06 18:37:21 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// impacted conductors along with their former profiles
|
2007-10-22 20:27:39 +00:00
|
|
|
QHash<Conductor *, ConductorProfilesGroup> conductors_profiles;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2007-10-06 18:37:21 +00:00
|
|
|
};
|
|
|
|
|
2007-09-28 17:39:30 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command changes the title block properties for a particular diagram.
|
2007-09-28 17:39:30 +00:00
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
class ChangeTitleBlockCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-28 17:39:30 +00:00
|
|
|
public:
|
2010-12-20 02:45:36 +00:00
|
|
|
ChangeTitleBlockCommand(Diagram *, const TitleBlockProperties &, const TitleBlockProperties &, QUndoCommand * = 0);
|
|
|
|
virtual ~ChangeTitleBlockCommand();
|
2007-09-28 17:39:30 +00:00
|
|
|
private:
|
2010-12-20 02:45:36 +00:00
|
|
|
ChangeTitleBlockCommand(const ChangeTitleBlockCommand &);
|
2007-09-28 17:39:30 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-28 17:39:30 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-28 17:39:30 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// modified diagram
|
2007-09-28 17:39:30 +00:00
|
|
|
Diagram *diagram;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties before the change
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockProperties old_titleblock;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties after the change
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockProperties new_titleblock;
|
2007-09-28 17:39:30 +00:00
|
|
|
};
|
2007-09-28 21:48:59 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command changes the border properties of a particular diagram.
|
2007-09-28 21:48:59 +00:00
|
|
|
*/
|
|
|
|
class ChangeBorderCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-28 21:48:59 +00:00
|
|
|
public:
|
2008-08-15 12:46:22 +00:00
|
|
|
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = 0);
|
2007-09-28 21:48:59 +00:00
|
|
|
virtual ~ChangeBorderCommand();
|
|
|
|
private:
|
|
|
|
ChangeBorderCommand(const ChangeBorderCommand &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-28 21:48:59 +00:00
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-28 21:48:59 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// modified diagram
|
2007-09-28 21:48:59 +00:00
|
|
|
Diagram *diagram;
|
|
|
|
public:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties before the change
|
2008-08-15 12:46:22 +00:00
|
|
|
BorderProperties old_properties;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties after the change
|
2008-08-15 12:46:22 +00:00
|
|
|
BorderProperties new_properties;
|
2007-09-28 21:48:59 +00:00
|
|
|
};
|
2007-10-03 15:51:04 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This command changes the properties for a particular conductor.
|
2007-10-03 15:51:04 +00:00
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
class ChangeConductorPropertiesCommand : public QUndoCommand {
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-10-03 15:51:04 +00:00
|
|
|
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
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-10-03 15:51:04 +00:00
|
|
|
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
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-10-03 15:51:04 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// modified conductor
|
2007-10-03 17:02:39 +00:00
|
|
|
Conductor *conductor;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties before the change
|
2007-10-14 14:44:33 +00:00
|
|
|
ConductorProperties old_properties;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// properties after the change
|
2007-10-14 14:44:33 +00:00
|
|
|
ConductorProperties new_properties;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// track whether pre-change properties were set
|
2007-10-03 15:51:04 +00:00
|
|
|
bool old_settings_set;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// track whether post-change properties were set
|
2007-10-03 15:51:04 +00:00
|
|
|
bool new_settings_set;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2007-10-03 15:51:04 +00:00
|
|
|
};
|
2013-04-04 16:57:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This command changes the properties for several conductors.
|
|
|
|
*/
|
|
|
|
class ChangeSeveralConductorsPropertiesCommand : public QUndoCommand {
|
|
|
|
// constructors, destructor
|
|
|
|
public:
|
2014-01-06 18:21:58 +00:00
|
|
|
ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>, QUndoCommand * = 0);
|
2013-04-04 16:57:15 +00:00
|
|
|
virtual ~ChangeSeveralConductorsPropertiesCommand();
|
|
|
|
private:
|
|
|
|
ChangeSeveralConductorsPropertiesCommand(const ChangeSeveralConductorsPropertiesCommand &);
|
|
|
|
|
|
|
|
// methods
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
virtual void setOldSettings(const QList<ConductorProperties> &);
|
|
|
|
virtual void setNewSettings(const QList<ConductorProperties> &);
|
2013-11-21 21:34:49 +00:00
|
|
|
virtual void setNewSettings(const ConductorProperties &);
|
2013-04-04 16:57:15 +00:00
|
|
|
|
|
|
|
// attributes
|
|
|
|
private:
|
|
|
|
/// modified conductor
|
2014-01-06 18:21:58 +00:00
|
|
|
QList<Conductor *> conductors;
|
2013-04-04 16:57:15 +00:00
|
|
|
/// properties before the change
|
|
|
|
QList <ConductorProperties> old_properties;
|
|
|
|
/// properties after the change
|
|
|
|
QList <ConductorProperties> new_properties;
|
2013-11-21 21:34:49 +00:00
|
|
|
/// single properties for each conductor
|
|
|
|
ConductorProperties single_new_properties;
|
2013-04-04 16:57:15 +00:00
|
|
|
/// track whether pre-change properties were set
|
|
|
|
bool old_settings_set;
|
|
|
|
/// track whether post-change properties were set
|
|
|
|
bool new_settings_set;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2013-04-04 16:57:15 +00:00
|
|
|
};
|
2013-09-09 13:29:28 +00:00
|
|
|
|
2014-06-14 16:04:34 +00:00
|
|
|
class ItemResizerCommand : public QUndoCommand {
|
2013-09-09 13:29:28 +00:00
|
|
|
//constructor and destructor
|
|
|
|
public:
|
2014-06-14 16:04:34 +00:00
|
|
|
ItemResizerCommand (QetGraphicsItem *qgi, qreal &old_, qreal &new_,const QString &text, QUndoCommand *parent = 0);
|
|
|
|
virtual ~ItemResizerCommand();
|
2013-09-09 13:29:28 +00:00
|
|
|
|
|
|
|
//methods
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
//attributes
|
|
|
|
private:
|
2014-06-14 16:04:34 +00:00
|
|
|
QetGraphicsItem *m_qgi;
|
2013-09-09 13:29:28 +00:00
|
|
|
qreal old_size, new_size;
|
2014-01-06 18:21:58 +00:00
|
|
|
Diagram *diagram;
|
2014-06-14 16:04:34 +00:00
|
|
|
QString m_text;
|
2013-09-09 13:29:28 +00:00
|
|
|
};
|
|
|
|
|
2014-03-07 08:05:25 +00:00
|
|
|
|
|
|
|
class ChangeShapeStyleCommand : public QUndoCommand {
|
|
|
|
//constructor and destructor
|
|
|
|
public:
|
|
|
|
ChangeShapeStyleCommand (QetShapeItem *shape, Qt::PenStyle &old_, Qt::PenStyle &new_, QUndoCommand *parent = 0);
|
|
|
|
virtual ~ChangeShapeStyleCommand();
|
|
|
|
|
|
|
|
//methods
|
|
|
|
public:
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
//attributes
|
|
|
|
private:
|
|
|
|
QetShapeItem *shape_;
|
|
|
|
Qt::PenStyle old_style, new_style;
|
|
|
|
Diagram *diagram;
|
|
|
|
};
|
|
|
|
|
2014-01-07 20:11:28 +00:00
|
|
|
class LinkElementsCommand : public QUndoCommand {
|
|
|
|
public:
|
|
|
|
// constructor destructor
|
|
|
|
LinkElementsCommand (Element *elmt1, Element *elmt2, QUndoCommand *parent = 0);
|
2014-02-26 23:57:22 +00:00
|
|
|
LinkElementsCommand (Element *elmt1, QList <Element *> &elmtList, QUndoCommand *parent = 0);
|
2014-01-07 20:11:28 +00:00
|
|
|
virtual ~LinkElementsCommand();
|
|
|
|
//methods
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
//attributes
|
2014-01-08 19:27:38 +00:00
|
|
|
Diagram *diagram_;
|
2014-03-12 09:32:56 +00:00
|
|
|
Element *element_;
|
2014-02-26 23:57:22 +00:00
|
|
|
QList <Element *> elmt_list;
|
2014-03-12 09:32:56 +00:00
|
|
|
QList <Element *> previous_linked;
|
2014-02-06 21:35:13 +00:00
|
|
|
bool first_redo;
|
2014-01-08 19:27:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class unlinkElementsCommand : public QUndoCommand {
|
|
|
|
public:
|
|
|
|
//constructor destructor
|
|
|
|
unlinkElementsCommand (Element *elmt1, Element *elmt2 = 0, QUndoCommand *parent = 0);
|
2014-02-26 23:57:22 +00:00
|
|
|
unlinkElementsCommand (Element *elmt1, QList <Element *> &elmtList, QUndoCommand *parent = 0);
|
2014-01-08 19:27:38 +00:00
|
|
|
virtual ~unlinkElementsCommand();
|
|
|
|
//methods
|
|
|
|
virtual void undo();
|
|
|
|
virtual void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
//attributes
|
|
|
|
Diagram *diagram_;
|
|
|
|
Element *element_;
|
|
|
|
QList <Element *> elmt_list;
|
2014-01-07 20:11:28 +00:00
|
|
|
};
|
|
|
|
|
2007-09-25 23:24:36 +00:00
|
|
|
#endif
|