mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-26 13:20:52 +01:00
replace tabs by 4 spaces
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#ifndef CONDUCTOR_H
|
||||
#define CONDUCTOR_H
|
||||
@@ -36,200 +36,200 @@ class QetGraphicsHandlerItem;
|
||||
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
||||
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
||||
/**
|
||||
This class represents a conductor, i.e. a wire between two element
|
||||
terminals.
|
||||
This class represents a conductor, i.e. a wire between two element
|
||||
terminals.
|
||||
*/
|
||||
class Conductor : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
||||
Q_PROPERTY(autonum::sequentialNumbers sequenceNum READ sequenceNum WRITE setSequenceNum)
|
||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
||||
Q_PROPERTY(autonum::sequentialNumbers sequenceNum READ sequenceNum WRITE setSequenceNum)
|
||||
|
||||
signals:
|
||||
void propertiesChange();
|
||||
|
||||
public:
|
||||
Conductor(Terminal *, Terminal *);
|
||||
~Conductor() override;
|
||||
signals:
|
||||
void propertiesChange();
|
||||
|
||||
public:
|
||||
Conductor(Terminal *, Terminal *);
|
||||
~Conductor() override;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
Conductor(const Conductor &);
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
Conductor(const Conductor &);
|
||||
|
||||
public:
|
||||
enum { Type = UserType + 1001 };
|
||||
enum Highlight { None, Normal, Alert };
|
||||
public:
|
||||
enum { Type = UserType + 1001 };
|
||||
enum Highlight { None, Normal, Alert };
|
||||
|
||||
Terminal *terminal1;
|
||||
Terminal *terminal2;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief type
|
||||
Enable the use of qgraphicsitem_cast
|
||||
to safely cast a QGraphicsItem into a conductor.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
Diagram *diagram() const;
|
||||
ConductorTextItem *textItem() const;
|
||||
void updatePath(const QRectF & = QRectF());
|
||||
Terminal *terminal1;
|
||||
Terminal *terminal2;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief type
|
||||
Enable the use of qgraphicsitem_cast
|
||||
to safely cast a QGraphicsItem into a conductor.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
Diagram *diagram() const;
|
||||
ConductorTextItem *textItem() const;
|
||||
void updatePath(const QRectF & = QRectF());
|
||||
|
||||
//This method do nothing, it's only made to be used with Q_PROPERTY
|
||||
//It's used to anim the path when is change
|
||||
void updatePathAnimate(const int = 1) {updatePath();}
|
||||
int fakePath() {return 1;}
|
||||
//This method do nothing, it's only made to be used with Q_PROPERTY
|
||||
//It's used to anim the path when is change
|
||||
void updatePathAnimate(const int = 1) {updatePath();}
|
||||
int fakePath() {return 1;}
|
||||
|
||||
void paint(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
QRectF boundingRect() const override;
|
||||
QPainterPath shape() const override;
|
||||
virtual QPainterPath nearShape() const;
|
||||
qreal length() const;
|
||||
ConductorSegment *middleSegment();
|
||||
QPointF posForText(Qt::Orientations &flag);
|
||||
void refreshText();
|
||||
void setPath(const QPainterPath &path);
|
||||
QPainterPath path() const;
|
||||
void paint(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
QRectF boundingRect() const override;
|
||||
QPainterPath shape() const override;
|
||||
virtual QPainterPath nearShape() const;
|
||||
qreal length() const;
|
||||
ConductorSegment *middleSegment();
|
||||
QPointF posForText(Qt::Orientations &flag);
|
||||
void refreshText();
|
||||
void setPath(const QPainterPath &path);
|
||||
QPainterPath path() const;
|
||||
|
||||
public:
|
||||
static bool valideXml (QDomElement &);
|
||||
bool fromXml (QDomElement &);
|
||||
QDomElement toXml (
|
||||
QDomDocument &,
|
||||
QHash<Terminal *,
|
||||
int> &) const;
|
||||
private:
|
||||
bool pathFromXml(const QDomElement &);
|
||||
public:
|
||||
static bool valideXml (QDomElement &);
|
||||
bool fromXml (QDomElement &);
|
||||
QDomElement toXml (
|
||||
QDomDocument &,
|
||||
QHash<Terminal *,
|
||||
int> &) const;
|
||||
private:
|
||||
bool pathFromXml(const QDomElement &);
|
||||
|
||||
public:
|
||||
QVector <QPointF> handlerPoints() const;
|
||||
const QList<ConductorSegment *> segmentsList() const;
|
||||
public:
|
||||
QVector <QPointF> handlerPoints() const;
|
||||
const QList<ConductorSegment *> segmentsList() const;
|
||||
|
||||
void setPropertyToPotential(
|
||||
const ConductorProperties &property,
|
||||
bool only_text = false);
|
||||
void setProperties(const ConductorProperties &property);
|
||||
ConductorProperties properties() const;
|
||||
void setPropertyToPotential(
|
||||
const ConductorProperties &property,
|
||||
bool only_text = false);
|
||||
void setProperties(const ConductorProperties &property);
|
||||
ConductorProperties properties() const;
|
||||
|
||||
void setProfile(const ConductorProfile &, Qt::Corner);
|
||||
ConductorProfile profile(Qt::Corner) const;
|
||||
void setProfiles(const ConductorProfilesGroup &);
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void calculateTextItemPosition();
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
QSet<Conductor *> relatedPotentialConductors(
|
||||
const bool all_diagram = true,
|
||||
QList <Terminal *> *t_list=nullptr);
|
||||
QETDiagramEditor* diagramEditor() const;
|
||||
void editProperty ();
|
||||
void setProfile(const ConductorProfile &, Qt::Corner);
|
||||
ConductorProfile profile(Qt::Corner) const;
|
||||
void setProfiles(const ConductorProfilesGroup &);
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void calculateTextItemPosition();
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
QSet<Conductor *> relatedPotentialConductors(
|
||||
const bool all_diagram = true,
|
||||
QList <Terminal *> *t_list=nullptr);
|
||||
QETDiagramEditor* diagramEditor() const;
|
||||
void editProperty ();
|
||||
|
||||
autonum::sequentialNumbers sequenceNum () const
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceNum()
|
||||
{return m_autoNum_seq;}
|
||||
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
||||
autonum::sequentialNumbers sequenceNum () const
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceNum()
|
||||
{return m_autoNum_seq;}
|
||||
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
||||
|
||||
QList<QPointF> junctions() const;
|
||||
|
||||
private:
|
||||
void setUpConnectionForFormula(
|
||||
QString old_formula, QString new_formula);
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
private:
|
||||
void setUpConnectionForFormula(
|
||||
QString old_formula, QString new_formula);
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
|
||||
public:
|
||||
void setFreezeLabel(bool freeze);
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
QVariant itemChange(
|
||||
GraphicsItemChange, const QVariant &) override;
|
||||
bool sceneEventFilter(
|
||||
QGraphicsItem *watched, QEvent *event) override;
|
||||
public:
|
||||
void setFreezeLabel(bool freeze);
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
QVariant itemChange(
|
||||
GraphicsItemChange, const QVariant &) override;
|
||||
bool sceneEventFilter(
|
||||
QGraphicsItem *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
|
||||
void handlerMousePressEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void addHandler();
|
||||
void removeHandler();
|
||||
|
||||
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
int m_vector_index = -1;
|
||||
bool m_mouse_over;
|
||||
/// Functional properties
|
||||
ConductorProperties m_properties;
|
||||
/// Text input for non simple, non-singleline conductors
|
||||
ConductorTextItem *m_text_item;
|
||||
/// Segments composing the conductor
|
||||
ConductorSegment *segments;
|
||||
/// Attributs related to mouse interaction
|
||||
bool m_moving_segment;
|
||||
int moved_point;
|
||||
qreal m_previous_z_value;
|
||||
ConductorSegment *m_moved_segment;
|
||||
QPointF before_mov_text_pos_;
|
||||
/// Whether the conductor was manually modified by users
|
||||
bool modified_path;
|
||||
/// Whether the current profile should be saved as soon as possible
|
||||
bool has_to_save_profile;
|
||||
/// conductor profile: "photography" of what the conductor is supposed to look
|
||||
/// like - there is one profile per kind of traject
|
||||
ConductorProfilesGroup conductor_profiles;
|
||||
/// Define whether and how the conductor should be highlighted
|
||||
Highlight must_highlight_;
|
||||
bool m_valid;
|
||||
bool m_freeze_label = false;
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
|
||||
void handlerMousePressEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void addHandler();
|
||||
void removeHandler();
|
||||
|
||||
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
int m_vector_index = -1;
|
||||
bool m_mouse_over;
|
||||
/// Functional properties
|
||||
ConductorProperties m_properties;
|
||||
/// Text input for non simple, non-singleline conductors
|
||||
ConductorTextItem *m_text_item;
|
||||
/// Segments composing the conductor
|
||||
ConductorSegment *segments;
|
||||
/// Attributs related to mouse interaction
|
||||
bool m_moving_segment;
|
||||
int moved_point;
|
||||
qreal m_previous_z_value;
|
||||
ConductorSegment *m_moved_segment;
|
||||
QPointF before_mov_text_pos_;
|
||||
/// Whether the conductor was manually modified by users
|
||||
bool modified_path;
|
||||
/// Whether the current profile should be saved as soon as possible
|
||||
bool has_to_save_profile;
|
||||
/// conductor profile: "photography" of what the conductor is supposed to look
|
||||
/// like - there is one profile per kind of traject
|
||||
ConductorProfilesGroup conductor_profiles;
|
||||
/// Define whether and how the conductor should be highlighted
|
||||
Highlight must_highlight_;
|
||||
bool m_valid;
|
||||
bool m_freeze_label = false;
|
||||
|
||||
/// QPen et QBrush objects used to draw conductors
|
||||
static QPen conductor_pen;
|
||||
static QBrush conductor_brush;
|
||||
static bool pen_and_brush_initialized;
|
||||
QPainterPath m_path;
|
||||
|
||||
private:
|
||||
void segmentsToPath();
|
||||
void saveProfile(bool = true);
|
||||
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
||||
QList<QPointF> segmentsToPoints() const;
|
||||
QList<ConductorBend> bends() const;
|
||||
/// QPen et QBrush objects used to draw conductors
|
||||
static QPen conductor_pen;
|
||||
static QBrush conductor_brush;
|
||||
static bool pen_and_brush_initialized;
|
||||
QPainterPath m_path;
|
||||
|
||||
private:
|
||||
void segmentsToPath();
|
||||
void saveProfile(bool = true);
|
||||
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
||||
QList<QPointF> segmentsToPoints() const;
|
||||
QList<ConductorBend> bends() const;
|
||||
|
||||
void pointsToSegments(const QList<QPointF>&);
|
||||
Qt::Corner currentPathType() const;
|
||||
void deleteSegments();
|
||||
static int getCoeff(const qreal &, const qreal &);
|
||||
static int getSign(const qreal &);
|
||||
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
||||
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
|
||||
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
||||
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
|
||||
void pointsToSegments(const QList<QPointF>&);
|
||||
Qt::Corner currentPathType() const;
|
||||
void deleteSegments();
|
||||
static int getCoeff(const qreal &, const qreal &);
|
||||
static int getSign(const qreal &);
|
||||
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
||||
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
|
||||
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
||||
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
|
||||
};
|
||||
|
||||
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);
|
||||
@@ -239,7 +239,7 @@ QList <Conductor *> relatedConductors (const Conductor *conductor);
|
||||
//return true if @a is between or at @b and @c.
|
||||
template <typename T>
|
||||
bool isBetween (const T a, const T b, const T c) {
|
||||
return (b <= c)? (a >= b && a <= c) : (a <= b && a >= c);
|
||||
return (b <= c)? (a >= b && a <= c) : (a <= b && a >= c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#include "conductortextitem.h"
|
||||
#include "conductor.h"
|
||||
@@ -21,245 +21,245 @@
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||
Constructeur
|
||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||
*/
|
||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||
DiagramTextItem(parent_conductor),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false)
|
||||
DiagramTextItem(parent_conductor),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param text Le texte affiche par le champ de texte
|
||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||
Constructeur
|
||||
@param text Le texte affiche par le champ de texte
|
||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||
*/
|
||||
ConductorTextItem::ConductorTextItem(
|
||||
const QString &text, Conductor *parent_conductor) :
|
||||
DiagramTextItem(text, parent_conductor),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false)
|
||||
const QString &text, Conductor *parent_conductor) :
|
||||
DiagramTextItem(text, parent_conductor),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false)
|
||||
{}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
Destructeur
|
||||
*/
|
||||
ConductorTextItem::~ConductorTextItem()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@return le conducteur parent de ce champ de texte, ou 0 si celui-ci n'en a
|
||||
pas
|
||||
@return le conducteur parent de ce champ de texte, ou 0 si celui-ci n'en a
|
||||
pas
|
||||
*/
|
||||
Conductor *ConductorTextItem::parentConductor() const
|
||||
{
|
||||
return(parent_conductor_);
|
||||
return(parent_conductor_);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::fromXml
|
||||
Read the properties stored in the xml element given in parameter
|
||||
@param e
|
||||
@brief ConductorTextItem::fromXml
|
||||
Read the properties stored in the xml element given in parameter
|
||||
@param e
|
||||
*/
|
||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||
if (e.hasAttribute("userx")) {
|
||||
setPos(e.attribute("userx").toDouble(),
|
||||
e.attribute("usery").toDouble());
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
if (e.hasAttribute("rotation")) {
|
||||
setRotation(e.attribute("rotation").toDouble());
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
if (e.hasAttribute("userx")) {
|
||||
setPos(e.attribute("userx").toDouble(),
|
||||
e.attribute("usery").toDouble());
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
if (e.hasAttribute("rotation")) {
|
||||
setRotation(e.attribute("rotation").toDouble());
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si ce champ de texte a ete explictement deplace par
|
||||
l'utilisateur, false sinon
|
||||
@return true si ce champ de texte a ete explictement deplace par
|
||||
l'utilisateur, false sinon
|
||||
*/
|
||||
bool ConductorTextItem::wasMovedByUser() const
|
||||
{
|
||||
return(moved_by_user_);
|
||||
return(moved_by_user_);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::wasRotateByUser
|
||||
@return true if text was explicit moved by user else false
|
||||
@brief ConductorTextItem::wasRotateByUser
|
||||
@return true if text was explicit moved by user else false
|
||||
*/
|
||||
bool ConductorTextItem::wasRotateByUser() const
|
||||
{
|
||||
return(rotate_by_user_);
|
||||
return(rotate_by_user_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param moved_by_user true pour que la position du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
pour remettre le texte a sa position originelle
|
||||
@param moved_by_user true pour que la position du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
pour remettre le texte a sa position originelle
|
||||
*/
|
||||
void ConductorTextItem::forceMovedByUser(bool moved_by_user) {
|
||||
if (moved_by_user == moved_by_user_) return;
|
||||
|
||||
moved_by_user_ = moved_by_user;
|
||||
if (!moved_by_user && parent_conductor_) {
|
||||
parent_conductor_ -> calculateTextItemPosition();
|
||||
}
|
||||
|
||||
if (moved_by_user == moved_by_user_) return;
|
||||
|
||||
moved_by_user_ = moved_by_user;
|
||||
if (!moved_by_user && parent_conductor_) {
|
||||
parent_conductor_ -> calculateTextItemPosition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::forceRotateByUser
|
||||
@param rotate_by_user true pour que la rotation du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
pour remettre le texte a sont angle originelle
|
||||
@brief ConductorTextItem::forceRotateByUser
|
||||
@param rotate_by_user true pour que la rotation du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
pour remettre le texte a sont angle originelle
|
||||
*/
|
||||
void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
|
||||
if (rotate_by_user == rotate_by_user_) return;
|
||||
if (rotate_by_user == rotate_by_user_) return;
|
||||
|
||||
rotate_by_user_ = rotate_by_user;
|
||||
if (!rotate_by_user && parent_conductor_) {
|
||||
parent_conductor_ -> calculateTextItemPosition();
|
||||
}
|
||||
rotate_by_user_ = rotate_by_user;
|
||||
if (!rotate_by_user && parent_conductor_) {
|
||||
parent_conductor_ -> calculateTextItemPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::setPos
|
||||
@param pos
|
||||
@brief ConductorTextItem::setPos
|
||||
@param pos
|
||||
*/
|
||||
void ConductorTextItem::setPos(const QPointF &pos)
|
||||
{
|
||||
/*
|
||||
* In some condition the conductor text item is outside the border of folio in the left.
|
||||
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
|
||||
* If the text is empty and the scene position is outside the border (left and top),
|
||||
* we can say that this position, is unwanted by user.
|
||||
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
|
||||
*/
|
||||
DiagramTextItem::setPos(pos);
|
||||
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
||||
{
|
||||
Conductor *cond = parentConductor();
|
||||
if(cond)
|
||||
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
||||
else
|
||||
DiagramTextItem::setPos(0,0);
|
||||
}
|
||||
/*
|
||||
* In some condition the conductor text item is outside the border of folio in the left.
|
||||
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
|
||||
* If the text is empty and the scene position is outside the border (left and top),
|
||||
* we can say that this position, is unwanted by user.
|
||||
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
|
||||
*/
|
||||
DiagramTextItem::setPos(pos);
|
||||
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
||||
{
|
||||
Conductor *cond = parentConductor();
|
||||
if(cond)
|
||||
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
||||
else
|
||||
DiagramTextItem::setPos(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::setPos
|
||||
@param x
|
||||
@param y
|
||||
@brief ConductorTextItem::setPos
|
||||
@param x
|
||||
@param y
|
||||
*/
|
||||
void ConductorTextItem::setPos(qreal x, qreal y)
|
||||
{
|
||||
QPointF p(x,y);
|
||||
setPos(p);
|
||||
QPointF p(x,y);
|
||||
setPos(p);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::mousePressEvent
|
||||
@param event
|
||||
@brief ConductorTextItem::mousePressEvent
|
||||
@param event
|
||||
*/
|
||||
void ConductorTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
before_mov_pos_ = pos();
|
||||
DiagramTextItem::mousePressEvent(event);
|
||||
before_mov_pos_ = pos();
|
||||
DiagramTextItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::mouseMoveEvent
|
||||
@param event
|
||||
@brief ConductorTextItem::mouseMoveEvent
|
||||
@param event
|
||||
*/
|
||||
void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
if (textInteractionFlags() & Qt::TextEditable) QGraphicsTextItem::mouseMoveEvent(event);
|
||||
if (textInteractionFlags() & Qt::TextEditable) QGraphicsTextItem::mouseMoveEvent(event);
|
||||
|
||||
else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
|
||||
else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
|
||||
|
||||
QPointF intended_pos = event ->scenePos() + m_mouse_to_origin_movement;
|
||||
QPointF intended_pos = event ->scenePos() + m_mouse_to_origin_movement;
|
||||
|
||||
if (parent_conductor_) {
|
||||
if (parent_conductor_->nearShape().contains(intended_pos)) {
|
||||
event->modifiers() == Qt::ControlModifier ? setPos(intended_pos) : setPos(Diagram::snapToGrid(intended_pos));
|
||||
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
||||
} else {
|
||||
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (parent_conductor_) {
|
||||
if (parent_conductor_->nearShape().contains(intended_pos)) {
|
||||
event->modifiers() == Qt::ControlModifier ? setPos(intended_pos) : setPos(Diagram::snapToGrid(intended_pos));
|
||||
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
||||
} else {
|
||||
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else event -> ignore();
|
||||
else event -> ignore();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorTextItem::mouseReleaseEvent
|
||||
@param e
|
||||
@brief ConductorTextItem::mouseReleaseEvent
|
||||
@param e
|
||||
*/
|
||||
void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (flags() & QGraphicsItem::ItemIsMovable) {
|
||||
if (flags() & QGraphicsItem::ItemIsMovable) {
|
||||
|
||||
if (Diagram *diagram_ptr = diagram()) {
|
||||
QPointF applied_movement = pos() - before_mov_pos_;
|
||||
|
||||
if (!applied_movement.isNull()) {
|
||||
//Create an undo object
|
||||
MoveConductorsTextsCommand *undo_object = new MoveConductorsTextsCommand(diagram_ptr);
|
||||
undo_object -> addTextMovement(this, before_mov_pos_, pos(), moved_by_user_);
|
||||
if (Diagram *diagram_ptr = diagram()) {
|
||||
QPointF applied_movement = pos() - before_mov_pos_;
|
||||
|
||||
if (!applied_movement.isNull()) {
|
||||
//Create an undo object
|
||||
MoveConductorsTextsCommand *undo_object = new MoveConductorsTextsCommand(diagram_ptr);
|
||||
undo_object -> addTextMovement(this, before_mov_pos_, pos(), moved_by_user_);
|
||||
|
||||
moved_by_user_ = true;
|
||||
|
||||
diagram_ptr -> undoStack().push(undo_object);
|
||||
}
|
||||
|
||||
if (parent_conductor_) {
|
||||
parent_conductor_ -> setHighlighted(Conductor::None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||
}
|
||||
moved_by_user_ = true;
|
||||
|
||||
diagram_ptr -> undoStack().push(undo_object);
|
||||
}
|
||||
|
||||
if (parent_conductor_) {
|
||||
parent_conductor_ -> setHighlighted(Conductor::None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
When mouse over element
|
||||
change m_mouse_hover to true (used in paint() function )
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
When mouse over element
|
||||
change m_mouse_hover to true (used in paint() function )
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
*/
|
||||
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||
Q_UNUSED(e);
|
||||
Q_UNUSED(e);
|
||||
|
||||
m_mouse_hover = true;
|
||||
QString str_ToolTip = toPlainText();
|
||||
setToolTip( str_ToolTip );
|
||||
update();
|
||||
m_mouse_hover = true;
|
||||
QString str_ToolTip = toPlainText();
|
||||
setToolTip( str_ToolTip );
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
When mouse over element leave the position
|
||||
change m_mouse_hover to false(used in paint() function )
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
When mouse over element leave the position
|
||||
change m_mouse_hover to false(used in paint() function )
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
*/
|
||||
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
qDebug() << "Leave mouse over";
|
||||
m_mouse_hover = false;
|
||||
update();
|
||||
Q_UNUSED(e);
|
||||
qDebug() << "Leave mouse over";
|
||||
m_mouse_hover = false;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
Do nothing default function .
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
Do nothing default function .
|
||||
@param e QGraphicsSceneHoverEvent
|
||||
*/
|
||||
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
QGraphicsTextItem::hoverMoveEvent(e);
|
||||
QGraphicsTextItem::hoverMoveEvent(e);
|
||||
}
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#ifndef CONDUCTOR_TEXT_ITEM_H
|
||||
#define CONDUCTOR_TEXT_ITEM_H
|
||||
#include "diagramtextitem.h"
|
||||
class Conductor;
|
||||
/**
|
||||
This class represents a text item attached to a parent conductor.
|
||||
It may be moved and edited by users.
|
||||
It may also be rotated to any angle.
|
||||
Its movements are however limited to a particular distance around its
|
||||
parent conductor.
|
||||
This class represents a text item attached to a parent conductor.
|
||||
It may be moved and edited by users.
|
||||
It may also be rotated to any angle.
|
||||
Its movements are however limited to a particular distance around its
|
||||
parent conductor.
|
||||
*/
|
||||
class ConductorTextItem : public DiagramTextItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
ConductorTextItem(Conductor * = nullptr);
|
||||
ConductorTextItem(const QString &, Conductor * = nullptr);
|
||||
~ConductorTextItem() override;
|
||||
private:
|
||||
ConductorTextItem(const ConductorTextItem &);
|
||||
// constructors, destructor
|
||||
public:
|
||||
ConductorTextItem(Conductor * = nullptr);
|
||||
ConductorTextItem(const QString &, Conductor * = nullptr);
|
||||
~ConductorTextItem() override;
|
||||
private:
|
||||
ConductorTextItem(const ConductorTextItem &);
|
||||
|
||||
public:
|
||||
enum { Type = UserType + 1006 };
|
||||
Conductor *parentConductor() const;
|
||||
void fromXml(const QDomElement &) override;
|
||||
int type() const override { return Type; }
|
||||
virtual bool wasMovedByUser() const;
|
||||
virtual bool wasRotateByUser() const;
|
||||
virtual void forceMovedByUser(bool);
|
||||
virtual void forceRotateByUser(bool);
|
||||
virtual void setPos(const QPointF &pos);
|
||||
virtual void setPos(qreal x, qreal y);
|
||||
public:
|
||||
enum { Type = UserType + 1006 };
|
||||
Conductor *parentConductor() const;
|
||||
void fromXml(const QDomElement &) override;
|
||||
int type() const override { return Type; }
|
||||
virtual bool wasMovedByUser() const;
|
||||
virtual bool wasRotateByUser() const;
|
||||
virtual void forceMovedByUser(bool);
|
||||
virtual void forceRotateByUser(bool);
|
||||
virtual void setPos(const QPointF &pos);
|
||||
virtual void setPos(qreal x, qreal y);
|
||||
|
||||
protected:
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
protected:
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
|
||||
// attributes
|
||||
private:
|
||||
Conductor *parent_conductor_;
|
||||
bool moved_by_user_;
|
||||
bool rotate_by_user_;
|
||||
QPointF before_mov_pos_;
|
||||
// attributes
|
||||
private:
|
||||
Conductor *parent_conductor_;
|
||||
bool moved_by_user_;
|
||||
bool rotate_by_user_;
|
||||
QPointF before_mov_pos_;
|
||||
};
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#ifndef DYNAMICELEMENTTEXTITEM_H
|
||||
#define DYNAMICELEMENTTEXTITEM_H
|
||||
@@ -30,136 +30,136 @@ class ElementTextItemGroup;
|
||||
class CrossRefItem;
|
||||
|
||||
/**
|
||||
@brief The DynamicElementTextItem class
|
||||
This class provide a simple text field of element who can be added or removed directly from the diagram editor.
|
||||
This text is created to compensate a big lack of the ElementTextItem : ElementTextItem can't be added or removed directly in the diagram editor
|
||||
|
||||
@brief The DynamicElementTextItem class
|
||||
This class provide a simple text field of element who can be added or removed directly from the diagram editor.
|
||||
This text is created to compensate a big lack of the ElementTextItem : ElementTextItem can't be added or removed directly in the diagram editor
|
||||
|
||||
*/
|
||||
class DynamicElementTextItem : public DiagramTextItem
|
||||
{
|
||||
friend class DynamicTextItemDelegate;
|
||||
friend class CompositeTextEditDialog;
|
||||
friend class Element;
|
||||
friend class DynamicTextItemDelegate;
|
||||
friend class CompositeTextEditDialog;
|
||||
friend class Element;
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
||||
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
||||
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
enum TextFrom {
|
||||
UserText,
|
||||
ElementInfo,
|
||||
CompositeText
|
||||
};
|
||||
Q_ENUM (TextFrom)
|
||||
enum {Type = UserType + 1010};
|
||||
int type() const override {return Type;}
|
||||
enum TextFrom {
|
||||
UserText,
|
||||
ElementInfo,
|
||||
CompositeText
|
||||
};
|
||||
Q_ENUM (TextFrom)
|
||||
enum {Type = UserType + 1010};
|
||||
int type() const override {return Type;}
|
||||
|
||||
signals:
|
||||
void textChanged(QString text);
|
||||
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
||||
void infoNameChanged(QString info);
|
||||
void compositeTextChanged(QString text);
|
||||
void frameChanged(bool frame);
|
||||
void plainTextChanged();
|
||||
void textWidthChanged(qreal width);
|
||||
signals:
|
||||
void textChanged(QString text);
|
||||
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
||||
void infoNameChanged(QString info);
|
||||
void compositeTextChanged(QString text);
|
||||
void frameChanged(bool frame);
|
||||
void plainTextChanged();
|
||||
void textWidthChanged(qreal width);
|
||||
|
||||
public:
|
||||
DynamicElementTextItem(Element *parent_element);
|
||||
~DynamicElementTextItem() override;
|
||||
static QMetaEnum textFromMetaEnum();
|
||||
private:
|
||||
DynamicElementTextItem ();
|
||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||
|
||||
public:
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
void fromXml(const QDomElement &dom_elmt) override;
|
||||
public:
|
||||
DynamicElementTextItem(Element *parent_element);
|
||||
~DynamicElementTextItem() override;
|
||||
static QMetaEnum textFromMetaEnum();
|
||||
private:
|
||||
DynamicElementTextItem ();
|
||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||
|
||||
public:
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
void fromXml(const QDomElement &dom_elmt) override;
|
||||
|
||||
Element *parentElement() const;
|
||||
ElementTextItemGroup *parentGroup() const;
|
||||
Element *elementUseForInfo() const;
|
||||
void refreshLabelConnection();
|
||||
Element *parentElement() const;
|
||||
ElementTextItemGroup *parentGroup() const;
|
||||
Element *elementUseForInfo() const;
|
||||
void refreshLabelConnection();
|
||||
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
QString text() const;
|
||||
void setText(const QString &text);
|
||||
static QString xmlTagName() {return QString("dynamic_elmt_text");}
|
||||
void setInfoName(const QString &info_name);
|
||||
QString infoName() const;
|
||||
void setCompositeText(const QString &text);
|
||||
QString compositeText() const;
|
||||
void setFrame(const bool frame);
|
||||
bool frame() const;
|
||||
QUuid uuid() const;
|
||||
void updateXref();
|
||||
void setPlainText(const QString &text);
|
||||
void setTextWidth(qreal width);
|
||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
QString text() const;
|
||||
void setText(const QString &text);
|
||||
static QString xmlTagName() {return QString("dynamic_elmt_text");}
|
||||
void setInfoName(const QString &info_name);
|
||||
QString infoName() const;
|
||||
void setCompositeText(const QString &text);
|
||||
QString compositeText() const;
|
||||
void setFrame(const bool frame);
|
||||
bool frame() const;
|
||||
QUuid uuid() const;
|
||||
void updateXref();
|
||||
void setPlainText(const QString &text);
|
||||
void setTextWidth(qreal width);
|
||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void elementInfoChanged();
|
||||
void masterChanged();
|
||||
void reportChanged();
|
||||
void reportFormulaChanged();
|
||||
void setConnectionForReportFormula(const QString &formula);
|
||||
void removeConnectionForReportFormula(const QString &formula);
|
||||
void setupFormulaConnection();
|
||||
void clearFormulaConnection();
|
||||
void updateReportFormulaConnection();
|
||||
void updateReportText();
|
||||
void updateLabel();
|
||||
void conductorWasAdded(Conductor *conductor);
|
||||
void conductorWasRemoved(Conductor *conductor);
|
||||
void setPotentialConductor();
|
||||
void conductorPropertiesChanged();
|
||||
QString reportReplacedCompositeText() const;
|
||||
void zoomToLinkedElement();
|
||||
private:
|
||||
void elementInfoChanged();
|
||||
void masterChanged();
|
||||
void reportChanged();
|
||||
void reportFormulaChanged();
|
||||
void setConnectionForReportFormula(const QString &formula);
|
||||
void removeConnectionForReportFormula(const QString &formula);
|
||||
void setupFormulaConnection();
|
||||
void clearFormulaConnection();
|
||||
void updateReportFormulaConnection();
|
||||
void updateReportText();
|
||||
void updateLabel();
|
||||
void conductorWasAdded(Conductor *conductor);
|
||||
void conductorWasRemoved(Conductor *conductor);
|
||||
void setPotentialConductor();
|
||||
void conductorPropertiesChanged();
|
||||
QString reportReplacedCompositeText() const;
|
||||
void zoomToLinkedElement();
|
||||
|
||||
private:
|
||||
QPointer <Element>
|
||||
m_parent_element,
|
||||
m_master_element,
|
||||
m_other_report;
|
||||
QPointer <Conductor> m_watched_conductor;
|
||||
QString
|
||||
m_text,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
m_F_str;
|
||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||
QUuid m_uuid;
|
||||
QMetaObject::Connection m_report_formula_con;
|
||||
QList<QMetaObject::Connection>
|
||||
m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QColor m_user_color;
|
||||
bool
|
||||
m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
qreal m_text_width = -1;
|
||||
QPointF m_initial_position;
|
||||
private:
|
||||
QPointer <Element>
|
||||
m_parent_element,
|
||||
m_master_element,
|
||||
m_other_report;
|
||||
QPointer <Conductor> m_watched_conductor;
|
||||
QString
|
||||
m_text,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
m_F_str;
|
||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||
QUuid m_uuid;
|
||||
QMetaObject::Connection m_report_formula_con;
|
||||
QList<QMetaObject::Connection>
|
||||
m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QColor m_user_color;
|
||||
bool
|
||||
m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
qreal m_text_width = -1;
|
||||
QPointF m_initial_position;
|
||||
};
|
||||
|
||||
#endif // DYNAMICELEMENTTEXTITEM_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ELEMENT_H
|
||||
#define ELEMENT_H
|
||||
@@ -36,209 +36,209 @@ class DynamicElementTextItem;
|
||||
class ElementTextItemGroup;
|
||||
|
||||
/**
|
||||
This is the base class for electrical elements.
|
||||
This is the base class for electrical elements.
|
||||
*/
|
||||
class Element : public QetGraphicsItem
|
||||
{
|
||||
friend class DiagramEventAddElement;
|
||||
friend class DiagramEventAddElement;
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
@brief The kind enum
|
||||
Used to know the kind of this element
|
||||
(master, slave, report ect...)
|
||||
*/
|
||||
enum kind {
|
||||
Simple = 1,
|
||||
NextReport = 2,
|
||||
PreviousReport = 4,
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Terminale = 32};
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
@brief The kind enum
|
||||
Used to know the kind of this element
|
||||
(master, slave, report ect...)
|
||||
*/
|
||||
enum kind {
|
||||
Simple = 1,
|
||||
NextReport = 2,
|
||||
PreviousReport = 4,
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Terminale = 32};
|
||||
|
||||
Element(const ElementsLocation &location,
|
||||
QGraphicsItem * = nullptr,
|
||||
int *state = nullptr,
|
||||
Element::kind link_type = Element::Simple);
|
||||
~Element() override;
|
||||
private:
|
||||
Element(const Element &);
|
||||
Element(const ElementsLocation &location,
|
||||
QGraphicsItem * = nullptr,
|
||||
int *state = nullptr,
|
||||
Element::kind link_type = Element::Simple);
|
||||
~Element() override;
|
||||
private:
|
||||
Element(const Element &);
|
||||
|
||||
// attributes
|
||||
public:
|
||||
/**
|
||||
Enable the use of qgraphicsitem_cast
|
||||
to safely cast a QGraphicsItem into an Element.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
enum { Type = UserType + 1000 };
|
||||
int type() const override { return Type; }
|
||||
// attributes
|
||||
public:
|
||||
/**
|
||||
Enable the use of qgraphicsitem_cast
|
||||
to safely cast a QGraphicsItem into an Element.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
enum { Type = UserType + 1000 };
|
||||
int type() const override { return Type; }
|
||||
|
||||
signals:
|
||||
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
||||
void elementInfoChange(
|
||||
DiagramContext old_info,
|
||||
DiagramContext new_info);
|
||||
void textAdded(DynamicElementTextItem *deti);
|
||||
void textRemoved(DynamicElementTextItem *deti);
|
||||
void textsGroupAdded(ElementTextItemGroup *group);
|
||||
void textsGroupAboutToBeRemoved(ElementTextItemGroup *group);
|
||||
void textAddedToGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
void textRemovedFromGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
signals:
|
||||
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
||||
void elementInfoChange(
|
||||
DiagramContext old_info,
|
||||
DiagramContext new_info);
|
||||
void textAdded(DynamicElementTextItem *deti);
|
||||
void textRemoved(DynamicElementTextItem *deti);
|
||||
void textsGroupAdded(ElementTextItemGroup *group);
|
||||
void textsGroupAboutToBeRemoved(ElementTextItemGroup *group);
|
||||
void textAddedToGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
void textRemovedFromGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
|
||||
|
||||
public:
|
||||
QList<Terminal *> terminals() const;
|
||||
QList<Conductor *> conductors() const;
|
||||
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
||||
public:
|
||||
QList<Terminal *> terminals() const;
|
||||
QList<Conductor *> conductors() const;
|
||||
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
||||
|
||||
//METHODS related to information
|
||||
DiagramContext elementInformations()const
|
||||
{return m_element_informations;}
|
||||
virtual void setElementInformations(DiagramContext dc);
|
||||
DiagramContext kindInformations() const
|
||||
{return m_kind_informations;}
|
||||
//@kind_information_ is used to store more information
|
||||
//about the herited class like contactelement for know
|
||||
// kind of contact (simple tempo) or number of contact show by the element.
|
||||
//METHODS related to information
|
||||
DiagramContext elementInformations()const
|
||||
{return m_element_informations;}
|
||||
virtual void setElementInformations(DiagramContext dc);
|
||||
DiagramContext kindInformations() const
|
||||
{return m_kind_informations;}
|
||||
//@kind_information_ is used to store more information
|
||||
//about the herited class like contactelement for know
|
||||
// kind of contact (simple tempo) or number of contact show by the element.
|
||||
|
||||
autonum::sequentialNumbers sequenceStruct() const
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceStruct()
|
||||
{return m_autoNum_seq;}
|
||||
void setUpFormula(bool code_letter = true);
|
||||
void setPrefix(QString);
|
||||
QString getPrefix() const;
|
||||
void freezeLabel(bool freeze);
|
||||
bool isFreezeLabel() const {return m_freeze_label;}
|
||||
void freezeNewAddedElement();
|
||||
QString actualLabel();
|
||||
autonum::sequentialNumbers sequenceStruct() const
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceStruct()
|
||||
{return m_autoNum_seq;}
|
||||
void setUpFormula(bool code_letter = true);
|
||||
void setPrefix(QString);
|
||||
QString getPrefix() const;
|
||||
void freezeLabel(bool freeze);
|
||||
bool isFreezeLabel() const {return m_freeze_label;}
|
||||
void freezeNewAddedElement();
|
||||
QString actualLabel();
|
||||
|
||||
QString name() const override;
|
||||
ElementsLocation location() const;
|
||||
virtual void setHighlighted(bool);
|
||||
void displayHelpLine(bool b = true);
|
||||
QSize size() const;
|
||||
QPixmap pixmap();
|
||||
QPoint setHotspot(QPoint);
|
||||
QPoint hotspot() const;
|
||||
void editProperty() override;
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(
|
||||
QDomElement &,
|
||||
QHash<int,
|
||||
Terminal *> &);
|
||||
virtual QDomElement toXml(
|
||||
QDomDocument &,
|
||||
QHash<Terminal *,
|
||||
int> &) const;
|
||||
QUuid uuid() const;
|
||||
int orientation() const;
|
||||
QString name() const override;
|
||||
ElementsLocation location() const;
|
||||
virtual void setHighlighted(bool);
|
||||
void displayHelpLine(bool b = true);
|
||||
QSize size() const;
|
||||
QPixmap pixmap();
|
||||
QPoint setHotspot(QPoint);
|
||||
QPoint hotspot() const;
|
||||
void editProperty() override;
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(
|
||||
QDomElement &,
|
||||
QHash<int,
|
||||
Terminal *> &);
|
||||
virtual QDomElement toXml(
|
||||
QDomDocument &,
|
||||
QHash<Terminal *,
|
||||
int> &) const;
|
||||
QUuid uuid() const;
|
||||
int orientation() const;
|
||||
|
||||
//METHODS related to texts
|
||||
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
||||
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
||||
QList<DynamicElementTextItem *> dynamicTextItems() const;
|
||||
ElementTextItemGroup *addTextGroup(const QString &name);
|
||||
void addTextGroup(ElementTextItemGroup *group);
|
||||
void removeTextGroup(ElementTextItemGroup *group);
|
||||
ElementTextItemGroup *textGroup(const QString &name) const;
|
||||
QList<ElementTextItemGroup *> textGroups() const;
|
||||
bool addTextToGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
bool removeTextFromGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
//METHODS related to texts
|
||||
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
||||
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
||||
QList<DynamicElementTextItem *> dynamicTextItems() const;
|
||||
ElementTextItemGroup *addTextGroup(const QString &name);
|
||||
void addTextGroup(ElementTextItemGroup *group);
|
||||
void removeTextGroup(ElementTextItemGroup *group);
|
||||
ElementTextItemGroup *textGroup(const QString &name) const;
|
||||
QList<ElementTextItemGroup *> textGroups() const;
|
||||
bool addTextToGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
bool removeTextFromGroup(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group);
|
||||
|
||||
//METHODS related to linked element
|
||||
bool isFree() const;
|
||||
virtual void linkToElement(Element *) {}
|
||||
virtual void unlinkAllElements() {}
|
||||
virtual void unlinkElement(Element *) {}
|
||||
virtual void initLink(QETProject *);
|
||||
QList<Element *> linkedElements ();
|
||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||
QString linkTypeToString() const;
|
||||
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
||||
//METHODS related to linked element
|
||||
bool isFree() const;
|
||||
virtual void linkToElement(Element *) {}
|
||||
virtual void unlinkAllElements() {}
|
||||
virtual void unlinkElement(Element *) {}
|
||||
virtual void initLink(QETProject *);
|
||||
QList<Element *> linkedElements ();
|
||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||
QString linkTypeToString() const;
|
||||
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void setSize(int, int);
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void setSize(int, int);
|
||||
|
||||
private:
|
||||
void drawSelection(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *);
|
||||
void drawHighlight(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *);
|
||||
bool buildFromXml(const QDomElement &, int * = nullptr);
|
||||
bool parseElement(const QDomElement &dom);
|
||||
bool parseInput(const QDomElement &dom_element);
|
||||
DynamicElementTextItem *parseDynamicText(
|
||||
const QDomElement &dom_element);
|
||||
Terminal *parseTerminal(const QDomElement &dom_element);
|
||||
private:
|
||||
void drawSelection(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *);
|
||||
void drawHighlight(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *);
|
||||
bool buildFromXml(const QDomElement &, int * = nullptr);
|
||||
bool parseElement(const QDomElement &dom);
|
||||
bool parseInput(const QDomElement &dom_element);
|
||||
DynamicElementTextItem *parseDynamicText(
|
||||
const QDomElement &dom_element);
|
||||
Terminal *parseTerminal(const QDomElement &dom_element);
|
||||
|
||||
//Reimplemented from QGraphicsItem
|
||||
public:
|
||||
void paint(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
QRectF boundingRect() const override;
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
//Reimplemented from QGraphicsItem
|
||||
public:
|
||||
void paint(
|
||||
QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
QRectF boundingRect() const override;
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
|
||||
protected:
|
||||
// m_converted_text_from_description,
|
||||
// when a element is created from his description,
|
||||
// the old element text item (tagged as 'input' in the xml)
|
||||
// are converted to dynamic text field,
|
||||
// the QPointF is the original position of the text item,
|
||||
// because the origin transformation point of text item
|
||||
// and dynamic text item are not the same,
|
||||
// so we must to keep a track of this value,
|
||||
// to be use in the function element::fromXml
|
||||
QHash <DynamicElementTextItem *, QPointF>
|
||||
m_converted_text_from_xml_description;
|
||||
protected:
|
||||
// m_converted_text_from_description,
|
||||
// when a element is created from his description,
|
||||
// the old element text item (tagged as 'input' in the xml)
|
||||
// are converted to dynamic text field,
|
||||
// the QPointF is the original position of the text item,
|
||||
// because the origin transformation point of text item
|
||||
// and dynamic text item are not the same,
|
||||
// so we must to keep a track of this value,
|
||||
// to be use in the function element::fromXml
|
||||
QHash <DynamicElementTextItem *, QPointF>
|
||||
m_converted_text_from_xml_description;
|
||||
|
||||
//ATTRIBUTES related to linked element
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
QUuid m_uuid;
|
||||
kind m_link_type = Element::Simple;
|
||||
//ATTRIBUTES related to linked element
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
QUuid m_uuid;
|
||||
kind m_link_type = Element::Simple;
|
||||
|
||||
//ATTRIBUTES related to informations
|
||||
DiagramContext m_element_informations, m_kind_informations;
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
bool m_freeze_label = false;
|
||||
QString m_F_str;
|
||||
//ATTRIBUTES related to informations
|
||||
DiagramContext m_element_informations, m_kind_informations;
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
bool m_freeze_label = false;
|
||||
QString m_F_str;
|
||||
|
||||
ElementsLocation m_location;
|
||||
NamesList m_names;
|
||||
QList <Terminal *> m_terminals;
|
||||
const QPicture m_picture;
|
||||
const QPicture m_low_zoom_picture;
|
||||
ElementsLocation m_location;
|
||||
NamesList m_names;
|
||||
QList <Terminal *> m_terminals;
|
||||
const QPicture m_picture;
|
||||
const QPicture m_low_zoom_picture;
|
||||
|
||||
private:
|
||||
bool m_must_highlight = false;
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
bool m_mouse_over = false;
|
||||
QString m_prefix;
|
||||
QList <DynamicElementTextItem *> m_dynamic_text_list;
|
||||
QList <ElementTextItemGroup *> m_texts_group;
|
||||
private:
|
||||
bool m_must_highlight = false;
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
bool m_mouse_over = false;
|
||||
QString m_prefix;
|
||||
QList <DynamicElementTextItem *> m_dynamic_text_list;
|
||||
QList <ElementTextItemGroup *> m_texts_group;
|
||||
|
||||
};
|
||||
|
||||
@@ -246,40 +246,40 @@ bool comparPos(const Element * elmt1, const Element * elmt2);
|
||||
|
||||
inline bool Element::isFree() const
|
||||
{
|
||||
return (connected_elements.isEmpty());
|
||||
return (connected_elements.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
Indicate the current orientation of this element
|
||||
O = 0°
|
||||
1 = 90°
|
||||
2 = 180°
|
||||
3 = 270°
|
||||
@return the current orientation of this element
|
||||
Indicate the current orientation of this element
|
||||
O = 0°
|
||||
1 = 90°
|
||||
2 = 180°
|
||||
3 = 270°
|
||||
@return the current orientation of this element
|
||||
*/
|
||||
inline int Element::orientation() const
|
||||
{
|
||||
return(QET::correctAngle(rotation())/90);
|
||||
return(QET::correctAngle(rotation())/90);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Element::uuid
|
||||
@return the uuid of this element
|
||||
@brief Element::uuid
|
||||
@return the uuid of this element
|
||||
*/
|
||||
inline QUuid Element::uuid() const
|
||||
{return m_uuid;}
|
||||
|
||||
/**
|
||||
@brief Element::linkedElements
|
||||
@return the list of linked elements, the list is sorted by position
|
||||
@brief Element::linkedElements
|
||||
@return the list of linked elements, the list is sorted by position
|
||||
*/
|
||||
inline QList <Element *> Element::linkedElements()
|
||||
{
|
||||
std::sort(
|
||||
connected_elements.begin(),
|
||||
connected_elements.end(),
|
||||
comparPos);
|
||||
return connected_elements;
|
||||
std::sort(
|
||||
connected_elements.begin(),
|
||||
connected_elements.end(),
|
||||
comparPos);
|
||||
return connected_elements;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ELEMENTTEXTITEMGROUP_H
|
||||
#define ELEMENTTEXTITEMGROUP_H
|
||||
@@ -28,98 +28,98 @@ class Diagram;
|
||||
class CrossRefItem;
|
||||
|
||||
/**
|
||||
@brief The ElementTextItemGroup class
|
||||
This class represent a group of element text
|
||||
Texts in the group can be aligned left / center /right
|
||||
@brief The ElementTextItemGroup class
|
||||
This class represent a group of element text
|
||||
Texts in the group can be aligned left / center /right
|
||||
*/
|
||||
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
||||
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
|
||||
public:
|
||||
signals:
|
||||
void rotationChanged(qreal);
|
||||
void verticalAdjustmentChanged(int);
|
||||
void alignmentChanged(Qt::Alignment);
|
||||
void nameChanged(QString);
|
||||
void holdToBottomPageChanged(bool);
|
||||
void xChanged();
|
||||
void yChanged();
|
||||
void frameChanged(bool frame);
|
||||
|
||||
public:
|
||||
ElementTextItemGroup(const QString &name, Element *parent);
|
||||
~ElementTextItemGroup() override;
|
||||
void addToGroup(QGraphicsItem *item);
|
||||
void removeFromGroup(QGraphicsItem *item);
|
||||
void blockAlignmentUpdate(bool block);
|
||||
|
||||
void setAlignment(Qt::Alignment alignement);
|
||||
Qt::Alignment alignment() const;
|
||||
void updateAlignment();
|
||||
int verticalAdjustment() const {return m_vertical_adjustment;}
|
||||
void setVerticalAdjustment(int v);
|
||||
void setName(QString name);
|
||||
QString name() const {return m_name;}
|
||||
void setHoldToBottomPage(bool hold);
|
||||
bool holdToBottomPage() const {return m_hold_to_bottom_of_page;}
|
||||
void setFrame(const bool frame);
|
||||
bool frame() const;
|
||||
QList<DynamicElementTextItem *> texts() const;
|
||||
Diagram *diagram() const;
|
||||
Element *parentElement() const;
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_document) const;
|
||||
void fromXml(QDomElement &dom_element);
|
||||
static QString xmlTaggName() {return QString("texts_group");}
|
||||
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
void setRotation(qreal angle);
|
||||
void setPos(const QPointF &pos);
|
||||
void setPos(qreal x, qreal y);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
private:
|
||||
void updateXref();
|
||||
void adjustSlaveXrefPos();
|
||||
void autoPos();
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
||||
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
|
||||
public:
|
||||
signals:
|
||||
void rotationChanged(qreal);
|
||||
void verticalAdjustmentChanged(int);
|
||||
void alignmentChanged(Qt::Alignment);
|
||||
void nameChanged(QString);
|
||||
void holdToBottomPageChanged(bool);
|
||||
void xChanged();
|
||||
void yChanged();
|
||||
void frameChanged(bool frame);
|
||||
|
||||
public:
|
||||
ElementTextItemGroup(const QString &name, Element *parent);
|
||||
~ElementTextItemGroup() override;
|
||||
void addToGroup(QGraphicsItem *item);
|
||||
void removeFromGroup(QGraphicsItem *item);
|
||||
void blockAlignmentUpdate(bool block);
|
||||
|
||||
void setAlignment(Qt::Alignment alignement);
|
||||
Qt::Alignment alignment() const;
|
||||
void updateAlignment();
|
||||
int verticalAdjustment() const {return m_vertical_adjustment;}
|
||||
void setVerticalAdjustment(int v);
|
||||
void setName(QString name);
|
||||
QString name() const {return m_name;}
|
||||
void setHoldToBottomPage(bool hold);
|
||||
bool holdToBottomPage() const {return m_hold_to_bottom_of_page;}
|
||||
void setFrame(const bool frame);
|
||||
bool frame() const;
|
||||
QList<DynamicElementTextItem *> texts() const;
|
||||
Diagram *diagram() const;
|
||||
Element *parentElement() const;
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_document) const;
|
||||
void fromXml(QDomElement &dom_element);
|
||||
static QString xmlTaggName() {return QString("texts_group");}
|
||||
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
void setRotation(qreal angle);
|
||||
void setPos(const QPointF &pos);
|
||||
void setPos(qreal x, qreal y);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
private:
|
||||
void updateXref();
|
||||
void adjustSlaveXrefPos();
|
||||
void autoPos();
|
||||
|
||||
private:
|
||||
Qt::Alignment m_alignment = Qt::AlignJustify;
|
||||
QString m_name;
|
||||
bool m_first_move = true,
|
||||
m_hold_to_bottom_of_page = false,
|
||||
m_block_alignment_update = false,
|
||||
m_frame = false;
|
||||
QPointF m_initial_position;
|
||||
int m_vertical_adjustment = 0;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
Element *m_parent_element = nullptr;
|
||||
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
QMetaObject::Connection m_XrefChanged_timer,
|
||||
m_linked_changed_timer;
|
||||
private:
|
||||
Qt::Alignment m_alignment = Qt::AlignJustify;
|
||||
QString m_name;
|
||||
bool m_first_move = true,
|
||||
m_hold_to_bottom_of_page = false,
|
||||
m_block_alignment_update = false,
|
||||
m_frame = false;
|
||||
QPointF m_initial_position;
|
||||
int m_vertical_adjustment = 0;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
Element *m_parent_element = nullptr;
|
||||
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
QMetaObject::Connection m_XrefChanged_timer,
|
||||
m_linked_changed_timer;
|
||||
};
|
||||
|
||||
#endif // ELEMENTTEXTITEMGROUP_H
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#include "independenttextitem.h"
|
||||
#include "qet.h"
|
||||
@@ -25,24 +25,24 @@
|
||||
#include <QSettings>
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||
Constructeur
|
||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||
*/
|
||||
IndependentTextItem::IndependentTextItem() :
|
||||
DiagramTextItem(nullptr)
|
||||
DiagramTextItem(nullptr)
|
||||
{
|
||||
setFont(QETApp::indiTextsItemFont());
|
||||
QSettings settings;
|
||||
setRotation(settings.value("diagrameditor/independent_text_rotation", 0).toInt());
|
||||
setFont(QETApp::indiTextsItemFont());
|
||||
QSettings settings;
|
||||
setRotation(settings.value("diagrameditor/independent_text_rotation", 0).toInt());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief IndependentTextItem::IndependentTextItem
|
||||
Constructeur
|
||||
@param text Le texte affiche par le champ de texte
|
||||
@brief IndependentTextItem::IndependentTextItem
|
||||
Constructeur
|
||||
@param text Le texte affiche par le champ de texte
|
||||
*/
|
||||
IndependentTextItem::IndependentTextItem(const QString &text) :
|
||||
DiagramTextItem(text, nullptr)
|
||||
DiagramTextItem(text, nullptr)
|
||||
{}
|
||||
|
||||
/// Destructeur
|
||||
@@ -51,43 +51,43 @@ IndependentTextItem::~IndependentTextItem()
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||
Cette methode se base sur la position du champ pour assigner ou non la
|
||||
valeur a ce champ.
|
||||
@param e L'element XML representant le champ de texte
|
||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||
Cette methode se base sur la position du champ pour assigner ou non la
|
||||
valeur a ce champ.
|
||||
@param e L'element XML representant le champ de texte
|
||||
*/
|
||||
void IndependentTextItem::fromXml(const QDomElement &e) {
|
||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||
setHtml(e.attribute("text"));
|
||||
setRotation(e.attribute("rotation").toDouble());
|
||||
if (e.hasAttribute("font"))
|
||||
{
|
||||
QFont font;
|
||||
font.fromString(e.attribute("font"));
|
||||
setFont(font);
|
||||
}
|
||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||
setHtml(e.attribute("text"));
|
||||
setRotation(e.attribute("rotation").toDouble());
|
||||
if (e.hasAttribute("font"))
|
||||
{
|
||||
QFont font;
|
||||
font.fromString(e.attribute("font"));
|
||||
setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param document Le document XML a utiliser
|
||||
@return L'element XML representant ce champ de texte
|
||||
@param document Le document XML a utiliser
|
||||
@return L'element XML representant ce champ de texte
|
||||
*/
|
||||
QDomElement IndependentTextItem::toXml(QDomDocument &document) const
|
||||
{
|
||||
QDomElement result = document.createElement("input");
|
||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
result.setAttribute("text", toHtml());
|
||||
result.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
result.setAttribute("font", font().toString());
|
||||
|
||||
return(result);
|
||||
QDomElement result = document.createElement("input");
|
||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
result.setAttribute("text", toHtml());
|
||||
result.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
result.setAttribute("font", font().toString());
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
void IndependentTextItem::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
DiagramTextItem::focusOutEvent(event);
|
||||
if (diagram() && (m_previous_html_text != this->toHtml())) {
|
||||
diagram()->undoStack().push(new ChangeDiagramTextCommand(this, m_previous_html_text, this->toHtml()));
|
||||
}
|
||||
DiagramTextItem::focusOutEvent(event);
|
||||
if (diagram() && (m_previous_html_text != this->toHtml())) {
|
||||
diagram()->undoStack().push(new ChangeDiagramTextCommand(this, m_previous_html_text, this->toHtml()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,156 +1,156 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qetgraphicsitem.h"
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::QetGraphicsItem
|
||||
Default constructor
|
||||
@param parent : Parent Item
|
||||
@brief QetGraphicsItem::QetGraphicsItem
|
||||
Default constructor
|
||||
@param parent : Parent Item
|
||||
*/
|
||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||
QGraphicsObject(parent),
|
||||
is_movable_(true),
|
||||
m_first_move(true),
|
||||
snap_to_grid_(true)
|
||||
QGraphicsObject(parent),
|
||||
is_movable_(true),
|
||||
m_first_move(true),
|
||||
snap_to_grid_(true)
|
||||
{}
|
||||
|
||||
QetGraphicsItem::~QetGraphicsItem()
|
||||
{}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::diagram
|
||||
@brief QetGraphicsItem::diagram
|
||||
*return the diagram of this item
|
||||
*/
|
||||
Diagram* QetGraphicsItem::diagram() const{
|
||||
return(qobject_cast<Diagram *>(scene()));
|
||||
return(qobject_cast<Diagram *>(scene()));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::setPos
|
||||
@brief QetGraphicsItem::setPos
|
||||
*set the position of the item to p
|
||||
@param p the new position of item
|
||||
@param p the new position of item
|
||||
*/
|
||||
void QetGraphicsItem::setPos(const QPointF &p) {
|
||||
QPointF pp = Diagram::snapToGrid(p);
|
||||
if (pp == pos() || !is_movable_)
|
||||
return;
|
||||
QGraphicsItem::setPos(pp);
|
||||
QPointF pp = Diagram::snapToGrid(p);
|
||||
if (pp == pos() || !is_movable_)
|
||||
return;
|
||||
QGraphicsItem::setPos(pp);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::setPos
|
||||
@brief QetGraphicsItem::setPos
|
||||
*set the position of the item
|
||||
@param x new abscisse of item
|
||||
@param y new ordonne of item
|
||||
@param x new abscisse of item
|
||||
@param y new ordonne of item
|
||||
*/
|
||||
void QetGraphicsItem::setPos(qreal x, qreal y) {
|
||||
setPos(QPointF(x, y));
|
||||
setPos(QPointF(x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::state
|
||||
@return the current state of this item
|
||||
@brief QetGraphicsItem::state
|
||||
@return the current state of this item
|
||||
*/
|
||||
QET::GraphicsItemState QetGraphicsItem::state() const
|
||||
{
|
||||
return m_state;
|
||||
return m_state;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::mousePressEvent
|
||||
@brief QetGraphicsItem::mousePressEvent
|
||||
*handle the mouse click
|
||||
@param event
|
||||
@param event
|
||||
*/
|
||||
void QetGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_first_move = true;
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
}
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_first_move = true;
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::mouseDoubleClickEvent
|
||||
@brief QetGraphicsItem::mouseDoubleClickEvent
|
||||
*handle the mouse double click
|
||||
@param event
|
||||
@param event
|
||||
*/
|
||||
void QetGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
editProperty();
|
||||
event->accept();
|
||||
editProperty();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::mouseMoveEvent
|
||||
@brief QetGraphicsItem::mouseMoveEvent
|
||||
*handle mouse movement
|
||||
@param event
|
||||
@param event
|
||||
*/
|
||||
void QetGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (isSelected() && event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
//Item is moving
|
||||
if(diagram() && m_first_move) {
|
||||
//It's the first movement, we signal it to parent diagram
|
||||
diagram()->elementsMover().beginMovement(diagram(), this);
|
||||
}
|
||||
if (isSelected() && event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
//Item is moving
|
||||
if(diagram() && m_first_move) {
|
||||
//It's the first movement, we signal it to parent diagram
|
||||
diagram()->elementsMover().beginMovement(diagram(), this);
|
||||
}
|
||||
|
||||
//we apply the mouse movement
|
||||
QPointF old_pos = pos();
|
||||
if (m_first_move) {
|
||||
m_mouse_to_origin_movement = old_pos - event -> buttonDownScenePos(Qt::LeftButton);
|
||||
}
|
||||
QPointF expected_pos = event->scenePos() + m_mouse_to_origin_movement;
|
||||
setPos(expected_pos); // setPos() will snap the expected position to the grid
|
||||
//we apply the mouse movement
|
||||
QPointF old_pos = pos();
|
||||
if (m_first_move) {
|
||||
m_mouse_to_origin_movement = old_pos - event -> buttonDownScenePos(Qt::LeftButton);
|
||||
}
|
||||
QPointF expected_pos = event->scenePos() + m_mouse_to_origin_movement;
|
||||
setPos(expected_pos); // setPos() will snap the expected position to the grid
|
||||
|
||||
//we calcul the real movement apply by setPos()
|
||||
QPointF effective_movement = pos() - old_pos;
|
||||
if (diagram()) {
|
||||
//we signal the real movement apply to diagram,
|
||||
//who he apply to other selected item
|
||||
diagram()->elementsMover().continueMovement(effective_movement);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else {
|
||||
event->ignore();
|
||||
}
|
||||
//we calcul the real movement apply by setPos()
|
||||
QPointF effective_movement = pos() - old_pos;
|
||||
if (diagram()) {
|
||||
//we signal the real movement apply to diagram,
|
||||
//who he apply to other selected item
|
||||
diagram()->elementsMover().continueMovement(effective_movement);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else {
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
if (m_first_move) {
|
||||
m_first_move = false;
|
||||
}
|
||||
if (m_first_move) {
|
||||
m_first_move = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsItem::mouseReleaseEvent
|
||||
handle mouse release click
|
||||
@param event
|
||||
@brief QetGraphicsItem::mouseReleaseEvent
|
||||
handle mouse release click
|
||||
@param event
|
||||
*/
|
||||
void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (diagram()) {
|
||||
diagram()->elementsMover().endMovement();
|
||||
event->accept();
|
||||
}
|
||||
if (diagram()) {
|
||||
diagram()->elementsMover().endMovement();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QETGRAPHICSITEM_H
|
||||
#define QETGRAPHICSITEM_H
|
||||
@@ -25,41 +25,41 @@ class Diagram;
|
||||
|
||||
class QetGraphicsItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//constructor destructor
|
||||
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
||||
~QetGraphicsItem() override = 0;
|
||||
public:
|
||||
//constructor destructor
|
||||
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
||||
~QetGraphicsItem() override = 0;
|
||||
|
||||
//public methode
|
||||
Diagram *diagram () const;
|
||||
virtual void setPos (const QPointF &p);
|
||||
virtual void setPos (qreal x, qreal y);
|
||||
//public methode
|
||||
Diagram *diagram () const;
|
||||
virtual void setPos (const QPointF &p);
|
||||
virtual void setPos (qreal x, qreal y);
|
||||
|
||||
virtual bool isMovable () const
|
||||
virtual bool isMovable () const
|
||||
{return is_movable_;}
|
||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||
|
||||
virtual void editProperty () {}
|
||||
virtual QString name ()const
|
||||
virtual void editProperty () {}
|
||||
virtual QString name ()const
|
||||
{return QString("");}
|
||||
|
||||
QET::GraphicsItemState state() const;
|
||||
|
||||
QET::GraphicsItemState state() const;
|
||||
|
||||
//protected method
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
//protected method
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
bool is_movable_;
|
||||
bool m_first_move;
|
||||
bool snap_to_grid_;
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||
protected:
|
||||
bool is_movable_;
|
||||
bool m_first_move;
|
||||
bool snap_to_grid_;
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "slaveelement.h"
|
||||
#include "diagramposition.h"
|
||||
@@ -22,79 +22,79 @@
|
||||
#include "dynamicelementtextitem.h"
|
||||
|
||||
/**
|
||||
@brief SlaveElement::SlaveElement
|
||||
Default constructor
|
||||
@param location location of xml definition
|
||||
@param qgi parent QGraphicItem
|
||||
@param state int used to know if the creation of element have error
|
||||
@brief SlaveElement::SlaveElement
|
||||
Default constructor
|
||||
@param location location of xml definition
|
||||
@param qgi parent QGraphicItem
|
||||
@param state int used to know if the creation of element have error
|
||||
*/
|
||||
SlaveElement::SlaveElement(const ElementsLocation &location,
|
||||
QGraphicsItem *qgi,
|
||||
int *state) :
|
||||
Element(location, qgi, state, Element::Slave)
|
||||
QGraphicsItem *qgi,
|
||||
int *state) :
|
||||
Element(location, qgi, state, Element::Slave)
|
||||
{
|
||||
m_xref_item = nullptr;
|
||||
m_xref_item = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief SlaveElement::~SlaveElement
|
||||
default destructor
|
||||
@brief SlaveElement::~SlaveElement
|
||||
default destructor
|
||||
*/
|
||||
SlaveElement::~SlaveElement()
|
||||
{
|
||||
unlinkAllElements();
|
||||
unlinkAllElements();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief SlaveElement::linkToElement
|
||||
Link this slave to another element
|
||||
For this class element must be a master
|
||||
@param elmt
|
||||
@brief SlaveElement::linkToElement
|
||||
Link this slave to another element
|
||||
For this class element must be a master
|
||||
@param elmt
|
||||
*/
|
||||
void SlaveElement::linkToElement(Element *elmt)
|
||||
{
|
||||
// check if element is master and if isn't already linked
|
||||
if (elmt->linkType() == Master && !connected_elements.contains(elmt))
|
||||
{
|
||||
if(!isFree())
|
||||
unlinkAllElements();
|
||||
// check if element is master and if isn't already linked
|
||||
if (elmt->linkType() == Master && !connected_elements.contains(elmt))
|
||||
{
|
||||
if(!isFree())
|
||||
unlinkAllElements();
|
||||
|
||||
connected_elements << elmt;
|
||||
connected_elements << elmt;
|
||||
|
||||
elmt -> linkToElement(this);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
elmt -> linkToElement(this);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief SlaveElement::unlinkAllElements
|
||||
Unlink all of the element in the QList connected_elements
|
||||
@brief SlaveElement::unlinkAllElements
|
||||
Unlink all of the element in the QList connected_elements
|
||||
*/
|
||||
void SlaveElement::unlinkAllElements()
|
||||
{
|
||||
// if this element is free no need to do something
|
||||
if (!isFree())
|
||||
{
|
||||
foreach(Element *elmt, connected_elements)
|
||||
unlinkElement(elmt);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
// if this element is free no need to do something
|
||||
if (!isFree())
|
||||
{
|
||||
foreach(Element *elmt, connected_elements)
|
||||
unlinkElement(elmt);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief SlaveElement::unlinkElement
|
||||
Unlink the given elmt in parametre
|
||||
@param elmt
|
||||
@brief SlaveElement::unlinkElement
|
||||
Unlink the given elmt in parametre
|
||||
@param elmt
|
||||
*/
|
||||
void SlaveElement::unlinkElement(Element *elmt)
|
||||
{
|
||||
//Ensure elmt is linked to this element
|
||||
if (connected_elements.contains(elmt))
|
||||
{
|
||||
connected_elements.removeOne(elmt);
|
||||
//Ensure elmt is linked to this element
|
||||
if (connected_elements.contains(elmt))
|
||||
{
|
||||
connected_elements.removeOne(elmt);
|
||||
|
||||
elmt -> unlinkElement (this) ;
|
||||
elmt -> setHighlighted (false);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
elmt -> unlinkElement (this) ;
|
||||
elmt -> setHighlighted (false);
|
||||
emit linkedElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef SLAVEELEMENT_H
|
||||
#define SLAVEELEMENT_H
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
class SlaveElement : public Element
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlaveElement (
|
||||
const ElementsLocation &,
|
||||
QGraphicsItem * = nullptr,
|
||||
int * = nullptr);
|
||||
~SlaveElement() override;
|
||||
void linkToElement(Element *elmt) override;
|
||||
void unlinkAllElements() override;
|
||||
void unlinkElement(Element *elmt) override;
|
||||
|
||||
private:
|
||||
QGraphicsTextItem *m_xref_item;
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlaveElement (
|
||||
const ElementsLocation &,
|
||||
QGraphicsItem * = nullptr,
|
||||
int * = nullptr);
|
||||
~SlaveElement() override;
|
||||
void linkToElement(Element *elmt) override;
|
||||
void unlinkAllElements() override;
|
||||
void unlinkElement(Element *elmt) override;
|
||||
|
||||
private:
|
||||
QGraphicsTextItem *m_xref_item;
|
||||
};
|
||||
|
||||
#endif // SLAVEELEMENT_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef TERMINAL_H
|
||||
#define TERMINAL_H
|
||||
@@ -26,167 +26,167 @@ class Element;
|
||||
class TerminalData;
|
||||
|
||||
/**
|
||||
@brief The Terminal class
|
||||
This class represents a terminal of an electrical element, i.e. a possible
|
||||
plug point for conductors.
|
||||
This class handles all mouse events for connecting conductors
|
||||
@brief The Terminal class
|
||||
This class represents a terminal of an electrical element, i.e. a possible
|
||||
plug point for conductors.
|
||||
This class handles all mouse events for connecting conductors
|
||||
*/
|
||||
class Terminal : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void conductorWasAdded(Conductor *conductor);
|
||||
void conductorWasRemoved(Conductor *conductor);
|
||||
signals:
|
||||
void conductorWasAdded(Conductor *conductor);
|
||||
void conductorWasRemoved(Conductor *conductor);
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(TerminalData* data, Element *e = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, QString number,
|
||||
QString name, bool hiddenName, Element * = nullptr);
|
||||
~Terminal() override;
|
||||
// constructors, destructor
|
||||
public:
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(TerminalData* data, Element *e = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, QString number,
|
||||
QString name, bool hiddenName, Element * = nullptr);
|
||||
~Terminal() override;
|
||||
|
||||
private:
|
||||
Terminal(const Terminal &);
|
||||
private:
|
||||
Terminal(const Terminal &);
|
||||
|
||||
// methods
|
||||
public:
|
||||
/**
|
||||
@brief type
|
||||
Enable the use of qgraphicsitem_cast to safely
|
||||
cast a QGraphicsItem into a Terminal
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
// methods
|
||||
public:
|
||||
/**
|
||||
@brief type
|
||||
Enable the use of qgraphicsitem_cast to safely
|
||||
cast a QGraphicsItem into a Terminal
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
|
||||
void paint(
|
||||
QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
void drawHelpLine (bool draw = true);
|
||||
QLineF HelpLine () const;
|
||||
QRectF boundingRect () const override;
|
||||
void paint(
|
||||
QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
void drawHelpLine (bool draw = true);
|
||||
QLineF HelpLine () const;
|
||||
QRectF boundingRect () const override;
|
||||
|
||||
// methods to manage conductors attached to the terminal
|
||||
Terminal* alignedWithTerminal () const;
|
||||
bool addConductor (Conductor *conductor);
|
||||
void removeConductor (Conductor *conductor);
|
||||
int conductorsCount () const;
|
||||
Diagram *diagram () const;
|
||||
Element *parentElement () const;
|
||||
QUuid uuid () const;
|
||||
// methods to manage conductors attached to the terminal
|
||||
Terminal* alignedWithTerminal () const;
|
||||
bool addConductor (Conductor *conductor);
|
||||
void removeConductor (Conductor *conductor);
|
||||
int conductorsCount () const;
|
||||
Diagram *diagram () const;
|
||||
Element *parentElement () const;
|
||||
QUuid uuid () const;
|
||||
|
||||
QList<Conductor *> conductors() const;
|
||||
Qet::Orientation orientation() const;
|
||||
QPointF dockConductor() const;
|
||||
QString number() const;
|
||||
QString name() const;
|
||||
void setNumber(QString number);
|
||||
void setName(QString name, bool hiddenName);
|
||||
void updateConductor();
|
||||
bool isLinkedTo(Terminal *);
|
||||
bool canBeLinkedTo(Terminal *);
|
||||
QList<Conductor *> conductors() const;
|
||||
Qet::Orientation orientation() const;
|
||||
QPointF dockConductor() const;
|
||||
QString number() const;
|
||||
QString name() const;
|
||||
void setNumber(QString number);
|
||||
void setName(QString name, bool hiddenName);
|
||||
void updateConductor();
|
||||
bool isLinkedTo(Terminal *);
|
||||
bool canBeLinkedTo(Terminal *);
|
||||
|
||||
// methods related to XML import/export
|
||||
static bool valideXml(QDomElement &);
|
||||
bool fromXml (QDomElement &);
|
||||
QDomElement toXml (QDomDocument &) const;
|
||||
// methods related to XML import/export
|
||||
static bool valideXml(QDomElement &);
|
||||
bool fromXml (QDomElement &);
|
||||
QDomElement toXml (QDomDocument &) const;
|
||||
|
||||
protected:
|
||||
// methods related to events management
|
||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
||||
protected:
|
||||
// methods related to events management
|
||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
||||
|
||||
// attributes
|
||||
public:
|
||||
enum { Type = UserType + 1002 };
|
||||
// attributes
|
||||
public:
|
||||
enum { Type = UserType + 1002 };
|
||||
|
||||
static const qreal terminalSize;
|
||||
static const qreal Z;
|
||||
// Various static colors used for hover effects
|
||||
/// default color
|
||||
static QColor neutralColor;
|
||||
/// color for legal actions
|
||||
static QColor allowedColor;
|
||||
/// color for allowed but fuzzy or not recommended actions
|
||||
static QColor warningColor;
|
||||
/// color for forbidden actions
|
||||
static QColor forbiddenColor;
|
||||
static const qreal terminalSize;
|
||||
static const qreal Z;
|
||||
// Various static colors used for hover effects
|
||||
/// default color
|
||||
static QColor neutralColor;
|
||||
/// color for legal actions
|
||||
static QColor allowedColor;
|
||||
/// color for allowed but fuzzy or not recommended actions
|
||||
static QColor warningColor;
|
||||
/// color for forbidden actions
|
||||
static QColor forbiddenColor;
|
||||
|
||||
private:
|
||||
bool m_draw_help_line{false};
|
||||
QGraphicsLineItem *m_help_line{nullptr};
|
||||
QGraphicsLineItem *m_help_line_a{nullptr};
|
||||
private:
|
||||
bool m_draw_help_line{false};
|
||||
QGraphicsLineItem *m_help_line{nullptr};
|
||||
QGraphicsLineItem *m_help_line_a{nullptr};
|
||||
|
||||
|
||||
TerminalData* d;
|
||||
TerminalData* d;
|
||||
|
||||
/// Parent electrical element
|
||||
Element *parent_element_{nullptr};
|
||||
public:
|
||||
/// docking point for parent element
|
||||
QPointF dock_elmt_;
|
||||
private:
|
||||
/// List of conductors attached to the terminal
|
||||
QList<Conductor *> conductors_;
|
||||
/**
|
||||
Pointer to a rectangle representing the terminal bounding rect;
|
||||
used to calculate the bounding rect once only;
|
||||
used a pointer because boundingRect() is supposed to be const.
|
||||
*/
|
||||
QRectF *br_{nullptr};
|
||||
/// Last terminal seen through an attached conductor
|
||||
Terminal *previous_terminal_;
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool hovered_;
|
||||
/// Color used for the hover effect
|
||||
QColor hovered_color_;
|
||||
/// Number of Terminal
|
||||
QString number_terminal_;
|
||||
/// Name of Terminal
|
||||
QString name_terminal_;
|
||||
bool name_terminal_hidden;
|
||||
/// Parent electrical element
|
||||
Element *parent_element_{nullptr};
|
||||
public:
|
||||
/// docking point for parent element
|
||||
QPointF dock_elmt_;
|
||||
private:
|
||||
/// List of conductors attached to the terminal
|
||||
QList<Conductor *> conductors_;
|
||||
/**
|
||||
Pointer to a rectangle representing the terminal bounding rect;
|
||||
used to calculate the bounding rect once only;
|
||||
used a pointer because boundingRect() is supposed to be const.
|
||||
*/
|
||||
QRectF *br_{nullptr};
|
||||
/// Last terminal seen through an attached conductor
|
||||
Terminal *previous_terminal_;
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool hovered_;
|
||||
/// Color used for the hover effect
|
||||
QColor hovered_color_;
|
||||
/// Number of Terminal
|
||||
QString number_terminal_;
|
||||
/// Name of Terminal
|
||||
QString name_terminal_;
|
||||
bool name_terminal_hidden;
|
||||
|
||||
private:
|
||||
void init(QString number, QString name, bool hiddenName);
|
||||
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||
QString name, bool hiddenName);
|
||||
private:
|
||||
void init(QString number, QString name, bool hiddenName);
|
||||
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||
QString name, bool hiddenName);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Terminal::conductorsCount
|
||||
@return the number of conductors attached to the terminal.
|
||||
@brief Terminal::conductorsCount
|
||||
@return the number of conductors attached to the terminal.
|
||||
*/
|
||||
inline int Terminal::conductorsCount() const
|
||||
{
|
||||
return(conductors_.size());
|
||||
return(conductors_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::number
|
||||
@return the number of terminal.
|
||||
@brief Terminal::number
|
||||
@return the number of terminal.
|
||||
*/
|
||||
inline QString Terminal::number() const
|
||||
{
|
||||
return(number_terminal_);
|
||||
return(number_terminal_);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::name
|
||||
@return the name of terminal.
|
||||
@brief Terminal::name
|
||||
@return the name of terminal.
|
||||
*/
|
||||
inline QString Terminal::name() const
|
||||
{
|
||||
return(name_terminal_);
|
||||
return(name_terminal_);
|
||||
}
|
||||
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||
const bool all_diagram = true);
|
||||
const bool all_diagram = true);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user