mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 06:20:53 +01:00
Wrap code for better readability + Mod doc
This commit is contained in:
committed by
Laurent Trinques
parent
2cdfce18ec
commit
d7e1d326a2
@@ -250,7 +250,13 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
|||||||
typedef DiagramContent dc;
|
typedef DiagramContent dc;
|
||||||
|
|
||||||
//Move every movable items, except conductor
|
//Move every movable items, except conductor
|
||||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup | dc::ElementTextFields | dc::Tables))
|
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements
|
||||||
|
| dc::TextFields
|
||||||
|
| dc::Images
|
||||||
|
| dc::Shapes
|
||||||
|
| dc::TextGroup
|
||||||
|
| dc::ElementTextFields
|
||||||
|
| dc::Tables))
|
||||||
{
|
{
|
||||||
//If curent item have parent, and parent item is in content_to_move
|
//If curent item have parent, and parent item is in content_to_move
|
||||||
//we don't apply movement to this item, because this item will be moved by is parent.
|
//we don't apply movement to this item, because this item will be moved by is parent.
|
||||||
@@ -259,19 +265,22 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(qgi->toGraphicsObject())
|
if(qgi->toGraphicsObject())
|
||||||
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
|
setupAnimation(qgi->toGraphicsObject(), "pos",
|
||||||
else if(qgi->type() == QGraphicsItemGroup::Type) //ElementTextItemGroup is a QObject but not a QGraphicsObject
|
qgi->pos(), qgi->pos() + actual_movement);
|
||||||
|
else if(qgi->type() == QGraphicsItemGroup::Type)
|
||||||
{
|
{
|
||||||
//ElementTextItemGroup is a QObject but not a QGraphicsObject
|
//ElementTextItemGroup is a QObject but not a QGraphicsObject
|
||||||
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi))
|
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi))
|
||||||
setupAnimation(etig, "pos", etig->pos(), etig->pos() + actual_movement);
|
setupAnimation(etig, "pos", etig->pos(),
|
||||||
|
etig->pos() + actual_movement);
|
||||||
}
|
}
|
||||||
else qgi -> setPos(qgi->pos() + actual_movement);
|
else qgi -> setPos(qgi->pos() + actual_movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move some conductors
|
// Move some conductors
|
||||||
for (Conductor *conductor : content_to_move.m_conductors_to_move)
|
for (Conductor *conductor : content_to_move.m_conductors_to_move)
|
||||||
setupAnimation(conductor, "pos", conductor->pos(), conductor->pos() + actual_movement);
|
setupAnimation(conductor, "pos", conductor->pos(),
|
||||||
|
conductor->pos() + actual_movement);
|
||||||
|
|
||||||
// Recalcul the path of other conductor
|
// Recalcul the path of other conductor
|
||||||
for (Conductor *conductor : content_to_move.m_conductors_to_update)
|
for (Conductor *conductor : content_to_move.m_conductors_to_update)
|
||||||
@@ -279,14 +288,17 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MoveElementsCommand::setupAnimation
|
@brief MoveElementsCommand::setupAnimation
|
||||||
* Set up the animation for this undo command
|
Set up the animation for this undo command
|
||||||
* @param target object to anim
|
@param target object to anim
|
||||||
* @param propertyName property to animate
|
@param propertyName property to animate
|
||||||
* @param start value at start
|
@param start value at start
|
||||||
* @param end value at end
|
@param end value at end
|
||||||
*/
|
*/
|
||||||
void MoveElementsCommand::setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end) {
|
void MoveElementsCommand::setupAnimation(QObject *target,
|
||||||
|
const QByteArray &propertyName,
|
||||||
|
const QVariant& start,
|
||||||
|
const QVariant& end) {
|
||||||
//create animation group if not yet.
|
//create animation group if not yet.
|
||||||
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
||||||
@@ -366,11 +378,15 @@ void MoveConductorsTextsCommand::redo() {
|
|||||||
@param alread_moved true si le champ de texte etait deja a une position
|
@param alread_moved true si le champ de texte etait deja a une position
|
||||||
personnalisee par l'utilisateur, false sinon
|
personnalisee par l'utilisateur, false sinon
|
||||||
*/
|
*/
|
||||||
void MoveConductorsTextsCommand::addTextMovement(ConductorTextItem *text_item, const QPointF &old_pos, const QPointF &new_pos, bool already_moved) {
|
void MoveConductorsTextsCommand::addTextMovement(ConductorTextItem *text_item,
|
||||||
|
const QPointF &old_pos,
|
||||||
|
const QPointF &new_pos,
|
||||||
|
bool already_moved) {
|
||||||
// si le champ de texte est deja connu de l'objet d'annulation, il sera ignore
|
// si le champ de texte est deja connu de l'objet d'annulation, il sera ignore
|
||||||
if (texts_to_move_.contains(text_item)) return;
|
if (texts_to_move_.contains(text_item)) return;
|
||||||
|
|
||||||
// on memorise le champ de texte, en l'associant au mouvement effectue et a son etat avant le deplacement
|
// on memorise le champ de texte,
|
||||||
|
//en l'associant au mouvement effectue et a son etat avant le deplacement
|
||||||
texts_to_move_.insert(text_item, qMakePair(new_pos - old_pos, already_moved));
|
texts_to_move_.insert(text_item, qMakePair(new_pos - old_pos, already_moved));
|
||||||
|
|
||||||
// met a jour la description de l'objet d'annulation
|
// met a jour la description de l'objet d'annulation
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ QString itemText(const Conductor *item);
|
|||||||
class PasteDiagramCommand : public QUndoCommand {
|
class PasteDiagramCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PasteDiagramCommand(Diagram *, const DiagramContent &, QUndoCommand * = nullptr);
|
PasteDiagramCommand(Diagram *, const DiagramContent &,
|
||||||
|
QUndoCommand * = nullptr);
|
||||||
~PasteDiagramCommand() override;
|
~PasteDiagramCommand() override;
|
||||||
private:
|
private:
|
||||||
PasteDiagramCommand(const PasteDiagramCommand &);
|
PasteDiagramCommand(const PasteDiagramCommand &);
|
||||||
@@ -117,7 +118,8 @@ class PasteDiagramCommand : public QUndoCommand {
|
|||||||
class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
CutDiagramCommand(Diagram *, const DiagramContent &, QUndoCommand * = nullptr);
|
CutDiagramCommand(Diagram *, const DiagramContent &,
|
||||||
|
QUndoCommand * = nullptr);
|
||||||
~CutDiagramCommand() override;
|
~CutDiagramCommand() override;
|
||||||
private:
|
private:
|
||||||
CutDiagramCommand(const CutDiagramCommand &);
|
CutDiagramCommand(const CutDiagramCommand &);
|
||||||
@@ -130,7 +132,8 @@ class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
|||||||
class MoveElementsCommand : public QUndoCommand {
|
class MoveElementsCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
MoveElementsCommand(Diagram *, const DiagramContent &, const QPointF &m, QUndoCommand * = nullptr);
|
MoveElementsCommand(Diagram *, const DiagramContent &,
|
||||||
|
const QPointF &m, QUndoCommand * = nullptr);
|
||||||
~MoveElementsCommand() override;
|
~MoveElementsCommand() override;
|
||||||
private:
|
private:
|
||||||
MoveElementsCommand(const MoveElementsCommand &);
|
MoveElementsCommand(const MoveElementsCommand &);
|
||||||
@@ -142,7 +145,10 @@ class MoveElementsCommand : public QUndoCommand {
|
|||||||
virtual void move(const QPointF &);
|
virtual void move(const QPointF &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupAnimation (QObject * target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
|
void setupAnimation (QObject * target,
|
||||||
|
const QByteArray &propertyName,
|
||||||
|
const QVariant& start,
|
||||||
|
const QVariant& end);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@@ -175,7 +181,8 @@ class MoveConductorsTextsCommand : public QUndoCommand {
|
|||||||
public:
|
public:
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
virtual void addTextMovement(ConductorTextItem *, const QPointF &, const QPointF &, bool = false);
|
virtual void addTextMovement(ConductorTextItem *, const QPointF &,
|
||||||
|
const QPointF &, bool = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void regenerateTextLabel();
|
void regenerateTextLabel();
|
||||||
@@ -191,12 +198,16 @@ class MoveConductorsTextsCommand : public QUndoCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief The ChangeDiagramTextCommand class
|
||||||
This commad modifies a text item.
|
This commad modifies a text item.
|
||||||
*/
|
*/
|
||||||
class ChangeDiagramTextCommand : public QUndoCommand {
|
class ChangeDiagramTextCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeDiagramTextCommand(DiagramTextItem *, const QString &before, const QString &after, QUndoCommand * = nullptr);
|
ChangeDiagramTextCommand(DiagramTextItem *,
|
||||||
|
const QString &before,
|
||||||
|
const QString &after,
|
||||||
|
QUndoCommand * = nullptr);
|
||||||
~ChangeDiagramTextCommand() override;
|
~ChangeDiagramTextCommand() override;
|
||||||
private:
|
private:
|
||||||
ChangeDiagramTextCommand(const ChangeDiagramTextCommand &);
|
ChangeDiagramTextCommand(const ChangeDiagramTextCommand &);
|
||||||
@@ -220,12 +231,15 @@ class ChangeDiagramTextCommand : public QUndoCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief The ChangeConductorCommand class
|
||||||
This command changes a particular conductor.
|
This command changes a particular conductor.
|
||||||
*/
|
*/
|
||||||
class ChangeConductorCommand : public QUndoCommand {
|
class ChangeConductorCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeConductorCommand(Conductor *, const ConductorProfile &, const ConductorProfile &, Qt::Corner, QUndoCommand * = nullptr);
|
ChangeConductorCommand(Conductor *, const ConductorProfile &,
|
||||||
|
const ConductorProfile &, Qt::Corner,
|
||||||
|
QUndoCommand * = nullptr);
|
||||||
~ChangeConductorCommand() override;
|
~ChangeConductorCommand() override;
|
||||||
private:
|
private:
|
||||||
ChangeConductorCommand(const ChangeConductorCommand &);
|
ChangeConductorCommand(const ChangeConductorCommand &);
|
||||||
@@ -256,12 +270,15 @@ class ChangeConductorCommand : public QUndoCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief The ResetConductorCommand class
|
||||||
This command resets conductor paths.
|
This command resets conductor paths.
|
||||||
*/
|
*/
|
||||||
class ResetConductorCommand : public QUndoCommand {
|
class ResetConductorCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ResetConductorCommand(const QHash<Conductor *, ConductorProfilesGroup> &, QUndoCommand * = nullptr);
|
ResetConductorCommand(const QHash<Conductor *,
|
||||||
|
ConductorProfilesGroup> &,
|
||||||
|
QUndoCommand * = nullptr);
|
||||||
~ResetConductorCommand() override;
|
~ResetConductorCommand() override;
|
||||||
private:
|
private:
|
||||||
ResetConductorCommand(const ResetConductorCommand &);
|
ResetConductorCommand(const ResetConductorCommand &);
|
||||||
@@ -281,12 +298,14 @@ class ResetConductorCommand : public QUndoCommand {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief The ChangeBorderCommand class
|
||||||
This command changes the border properties of a particular diagram.
|
This command changes the border properties of a particular diagram.
|
||||||
*/
|
*/
|
||||||
class ChangeBorderCommand : public QUndoCommand {
|
class ChangeBorderCommand : public QUndoCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = nullptr);
|
ChangeBorderCommand(Diagram *, const BorderProperties &,
|
||||||
|
const BorderProperties &, QUndoCommand * = nullptr);
|
||||||
~ChangeBorderCommand() override;
|
~ChangeBorderCommand() override;
|
||||||
private:
|
private:
|
||||||
ChangeBorderCommand(const ChangeBorderCommand &);
|
ChangeBorderCommand(const ChangeBorderCommand &);
|
||||||
|
|||||||
@@ -410,7 +410,8 @@ QLineF Terminal::HelpLine() const
|
|||||||
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
||||||
*/
|
*/
|
||||||
QRectF Terminal::boundingRect() const {
|
QRectF Terminal::boundingRect() const {
|
||||||
if (br_ -> isNull()) {
|
if (br_ -> isNull())
|
||||||
|
{
|
||||||
qreal dcx = d->m_pos.x();
|
qreal dcx = d->m_pos.x();
|
||||||
qreal dcy = d->m_pos.y();
|
qreal dcy = d->m_pos.y();
|
||||||
qreal dex = dock_elmt_.x();
|
qreal dex = dock_elmt_.x();
|
||||||
@@ -717,8 +718,12 @@ QList<Conductor *> Terminal::conductors() const {
|
|||||||
*/
|
*/
|
||||||
QDomElement Terminal::toXml(QDomDocument &doc) const {
|
QDomElement Terminal::toXml(QDomDocument &doc) const {
|
||||||
QDomElement qdo = doc.createElement("terminal");
|
QDomElement qdo = doc.createElement("terminal");
|
||||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x())); // for backward compatibility
|
|
||||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));// for backward compatibility
|
// for backward compatibility
|
||||||
|
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||||
|
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||||
|
// end for backward compatibility
|
||||||
|
|
||||||
qdo.setAttribute("orientation", d->m_orientation);
|
qdo.setAttribute("orientation", d->m_orientation);
|
||||||
qdo.setAttribute("number", number_terminal_);
|
qdo.setAttribute("number", number_terminal_);
|
||||||
qdo.setAttribute("name", name_terminal_);
|
qdo.setAttribute("name", name_terminal_);
|
||||||
@@ -757,7 +762,10 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
|||||||
// parse l'orientation
|
// parse l'orientation
|
||||||
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
||||||
if (!conv_ok) return(false);
|
if (!conv_ok) return(false);
|
||||||
if (terminal_or != Qet::North && terminal_or != Qet::South && terminal_or != Qet::East && terminal_or != Qet::West) return(false);
|
if (terminal_or != Qet::North
|
||||||
|
&& terminal_or != Qet::South
|
||||||
|
&& terminal_or != Qet::East
|
||||||
|
&& terminal_or != Qet::West) return(false);
|
||||||
|
|
||||||
// a ce stade, la borne est syntaxiquement correcte
|
// a ce stade, la borne est syntaxiquement correcte
|
||||||
return(true);
|
return(true);
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class Terminal : public QGraphicsObject
|
|||||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(TerminalData* data, Element *e = nullptr);
|
Terminal(TerminalData* data, Element *e = nullptr);
|
||||||
Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = nullptr);
|
Terminal(QPointF, Qet::Orientation, QString number,
|
||||||
|
QString name, bool hiddenName, Element * = nullptr);
|
||||||
~Terminal() override;
|
~Terminal() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -60,7 +61,8 @@ class Terminal : public QGraphicsObject
|
|||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint (QPainter *,const QStyleOptionGraphicsItem *,
|
||||||
|
QWidget *) override;
|
||||||
void drawHelpLine (bool draw = true);
|
void drawHelpLine (bool draw = true);
|
||||||
QLineF HelpLine () const;
|
QLineF HelpLine () const;
|
||||||
QRectF boundingRect () const override;
|
QRectF boundingRect () const override;
|
||||||
@@ -149,7 +151,8 @@ class Terminal : public QGraphicsObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void init(QString number, QString name, bool hiddenName);
|
void init(QString number, QString name, bool hiddenName);
|
||||||
void init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName);
|
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||||
|
QString name, bool hiddenName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,12 +172,14 @@ inline QString Terminal::number() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief Terminal::name
|
||||||
@return the name of terminal.
|
@return the name of terminal.
|
||||||
*/
|
*/
|
||||||
inline QString Terminal::name() const {
|
inline QString Terminal::name() const {
|
||||||
return(name_terminal_);
|
return(name_terminal_);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram = true);
|
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||||
|
const bool all_diagram = true);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,14 +18,15 @@
|
|||||||
#include "terminalelement.h"
|
#include "terminalelement.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalElement::TerminalElement
|
@brief TerminalElement::TerminalElement
|
||||||
* Default constructor
|
Default constructor
|
||||||
* @param location location of xml definition
|
@param location location of xml definition
|
||||||
* @param qgi parent QGraphicItem
|
@param qgi parent QGraphicItem
|
||||||
* @param s parent diagram
|
@param s parent diagram
|
||||||
* @param state int used to know if the creation of element have error
|
@param state int used to know if the creation of element have error
|
||||||
*/
|
*/
|
||||||
TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
TerminalElement::TerminalElement(const ElementsLocation &location,
|
||||||
|
QGraphicsItem *qgi, int *state) :
|
||||||
Element(location, qgi, state, Element::Terminale)
|
Element(location, qgi, state, Element::Terminale)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,15 @@
|
|||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
|
||||||
class QETProject;
|
class QETProject;
|
||||||
|
/**
|
||||||
|
@brief The TerminalElement class
|
||||||
|
*/
|
||||||
class TerminalElement : public Element
|
class TerminalElement : public Element
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TerminalElement(const ElementsLocation &, QGraphicsItem * = nullptr, int * = nullptr);
|
TerminalElement(const ElementsLocation &,
|
||||||
|
QGraphicsItem * = nullptr, int * = nullptr);
|
||||||
~TerminalElement() override;
|
~TerminalElement() override;
|
||||||
void initLink(QETProject *project) override;
|
void initLink(QETProject *project) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user