mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Wrap code for better readability + Mod doc
This commit is contained in:
committed by
Laurent Trinques
parent
2cdfce18ec
commit
d7e1d326a2
@@ -249,8 +249,14 @@ 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 &);
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ const qreal Terminal::Z = 1000;
|
|||||||
*/
|
*/
|
||||||
void Terminal::init(QString number, QString name, bool hiddenName) {
|
void Terminal::init(QString number, QString name, bool hiddenName) {
|
||||||
|
|
||||||
hovered_color_ = Terminal::neutralColor;
|
hovered_color_ = Terminal::neutralColor;
|
||||||
|
|
||||||
// calcul de la position du point d'amarrage a l'element
|
// calcul de la position du point d'amarrage a l'element
|
||||||
dock_elmt_ = d->m_pos;
|
dock_elmt_ = d->m_pos;
|
||||||
switch(d->m_orientation) {
|
switch(d->m_orientation) {
|
||||||
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
||||||
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||||
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||||
@@ -82,14 +82,14 @@ void Terminal::init(QString number, QString name, bool hiddenName) {
|
|||||||
*/
|
*/
|
||||||
void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName)
|
void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName)
|
||||||
{
|
{
|
||||||
// definition du pount d'amarrage pour un conducteur
|
// definition du pount d'amarrage pour un conducteur
|
||||||
d->m_pos = pf;
|
d->m_pos = pf;
|
||||||
|
|
||||||
// definition de l'orientation de la borne (par defaut : sud)
|
// definition de l'orientation de la borne (par defaut : sud)
|
||||||
if (o < Qet::North || o > Qet::West) d->m_orientation = Qet::South;
|
if (o < Qet::North || o > Qet::West) d->m_orientation = Qet::South;
|
||||||
else d->m_orientation = o;
|
else d->m_orientation = o;
|
||||||
|
|
||||||
init(number, name, hiddenName);
|
init(number, name, hiddenName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,8 +101,8 @@ void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name
|
|||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsObject(e),
|
QGraphicsObject(e),
|
||||||
d(new TerminalData(this)),
|
d(new TerminalData(this)),
|
||||||
parent_element_ (e)
|
parent_element_ (e)
|
||||||
{
|
{
|
||||||
init(pf, o, "_", "_", false);
|
init(pf, o, "_", "_", false);
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,10 @@ Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
|||||||
*/
|
*/
|
||||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsObject(e),
|
QGraphicsObject(e),
|
||||||
d(new TerminalData(this)),
|
d(new TerminalData(this)),
|
||||||
parent_element_ (e)
|
parent_element_ (e)
|
||||||
{
|
{
|
||||||
init(QPointF(pf_x, pf_y), o, "_", "_", false);
|
init(QPointF(pf_x, pf_y), o, "_", "_", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,20 +135,20 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
|||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
|
||||||
QGraphicsObject (e),
|
QGraphicsObject (e),
|
||||||
d(new TerminalData(this)),
|
d(new TerminalData(this)),
|
||||||
parent_element_ (e)
|
parent_element_ (e)
|
||||||
{
|
{
|
||||||
init(pf, o, std::move(num), std::move(name), hiddenName);
|
init(pf, o, std::move(num), std::move(name), hiddenName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Terminal::Terminal(TerminalData* data, Element* e) :
|
Terminal::Terminal(TerminalData* data, Element* e) :
|
||||||
QGraphicsObject(e),
|
QGraphicsObject(e),
|
||||||
d(data),
|
d(data),
|
||||||
parent_element_(e)
|
parent_element_(e)
|
||||||
{
|
{
|
||||||
// TODO: what is when multiple parents exist. So the other relation is lost.
|
// TODO: what is when multiple parents exist. So the other relation is lost.
|
||||||
d->setParent(this);
|
d->setParent(this);
|
||||||
init("_", "_", false);
|
init("_", "_", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,15 +172,15 @@ Qet::Orientation Terminal::orientation() const {
|
|||||||
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
||||||
// orientations actuelle et par defaut de l'element
|
// orientations actuelle et par defaut de l'element
|
||||||
int ori_cur = elt -> orientation();
|
int ori_cur = elt -> orientation();
|
||||||
if (ori_cur == 0) return(d->m_orientation);
|
if (ori_cur == 0) return(d->m_orientation);
|
||||||
else {
|
else {
|
||||||
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
||||||
// angle de rotation de la borne sur la scene, divise par 90
|
// angle de rotation de la borne sur la scene, divise par 90
|
||||||
int angle = ori_cur + d->m_orientation;
|
int angle = ori_cur + d->m_orientation;
|
||||||
while (angle >= 4) angle -= 4;
|
while (angle >= 4) angle -= 4;
|
||||||
return((Qet::Orientation)angle);
|
return((Qet::Orientation)angle);
|
||||||
}
|
}
|
||||||
} else return(d->m_orientation);
|
} else return(d->m_orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
|
|||||||
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
|
||||||
// on travaille avec les coordonnees de l'element parent
|
// on travaille avec les coordonnees de l'element parent
|
||||||
QPointF c = mapFromParent(d->m_pos);
|
QPointF c = mapFromParent(d->m_pos);
|
||||||
QPointF e = mapFromParent(dock_elmt_);
|
QPointF e = mapFromParent(dock_elmt_);
|
||||||
|
|
||||||
QPen t;
|
QPen t;
|
||||||
@@ -410,12 +410,13 @@ 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 dcy = d->m_pos.y();
|
qreal dcx = d->m_pos.x();
|
||||||
|
qreal dcy = d->m_pos.y();
|
||||||
qreal dex = dock_elmt_.x();
|
qreal dex = dock_elmt_.x();
|
||||||
qreal dey = dock_elmt_.y();
|
qreal dey = dock_elmt_.y();
|
||||||
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
|
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
|
||||||
origin += QPointF(-3.0, -3.0);
|
origin += QPointF(-3.0, -3.0);
|
||||||
qreal w = qAbs((int)(dcx - dex)) + 7;
|
qreal w = qAbs((int)(dcx - dex)) + 7;
|
||||||
qreal h = qAbs((int)(dcy - dey)) + 7;
|
qreal h = qAbs((int)(dcy - dey)) + 7;
|
||||||
@@ -637,7 +638,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
|
|
||||||
if (use_properties)
|
if (use_properties)
|
||||||
{
|
{
|
||||||
Conductor *other = conductors_list.values().first();
|
Conductor *other = conductors_list.values().first();
|
||||||
new_conductor->rSequenceNum() = other->sequenceNum();
|
new_conductor->rSequenceNum() = other->sequenceNum();
|
||||||
new_conductor->setProperties(others_properties);
|
new_conductor->setProperties(others_properties);
|
||||||
}
|
}
|
||||||
@@ -651,7 +652,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
diagram() -> undoStack().push(undo);
|
diagram() -> undoStack().push(undo);
|
||||||
if (use_properties)
|
if (use_properties)
|
||||||
{
|
{
|
||||||
Conductor *other = conductors_list.values().first();
|
Conductor *other = conductors_list.values().first();
|
||||||
new_conductor->setProperties(other->properties());
|
new_conductor->setProperties(other->properties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -717,9 +718,13 @@ 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("orientation", d->m_orientation);
|
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("number", number_terminal_);
|
qdo.setAttribute("number", number_terminal_);
|
||||||
qdo.setAttribute("name", name_terminal_);
|
qdo.setAttribute("name", name_terminal_);
|
||||||
qdo.setAttribute("nameHidden", name_terminal_hidden);
|
qdo.setAttribute("nameHidden", name_terminal_hidden);
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -43,8 +43,9 @@ class Terminal : public QGraphicsObject
|
|||||||
public:
|
public:
|
||||||
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;
|
||||||
@@ -148,8 +150,9 @@ class Terminal : public QGraphicsObject
|
|||||||
bool name_terminal_hidden;
|
bool name_terminal_hidden;
|
||||||
|
|
||||||
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