Conductor : formula and text is now two different things.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4799 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-12-06 19:49:18 +00:00
parent c0b5aa7a59
commit 7ab0115c62
16 changed files with 213 additions and 236 deletions

View File

@@ -49,7 +49,6 @@ class Conductor : public QObject, public QGraphicsPathItem
signals:
void propertiesChange();
// constructors, destructor
public:
Conductor(Terminal *, Terminal *);
virtual ~Conductor();
@@ -59,44 +58,41 @@ class Conductor : public QObject, public QGraphicsPathItem
private:
Conductor(const Conductor &);
// attributes
public:
enum { Type = UserType + 1001 };
enum Highlight { None, Normal, Alert };
enum { Type = UserType + 1001 };
enum Highlight { None, Normal, Alert };
/// First terminal the wire is attached to
Terminal *terminal1;
/// Second terminal the wire is attached to
Terminal *terminal2;
/// First terminal the wire is attached to
Terminal *terminal1;
/// Second terminal the wire is attached to
Terminal *terminal2;
// methods
public:
/**
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
Conductor.
@return the QGraphicsItem type
*/
virtual int type() const { return Type; }
Diagram *diagram() const;
ConductorTextItem *textItem() const;
void updatePath(const QRectF & = QRectF());
/**
* Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a conductor.
* @return the QGraphicsItem type
*/
virtual int type() const { 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 *);
QRectF boundingRect() const;
virtual QPainterPath shape() const;
virtual QPainterPath nearShape() const;
qreal length() const;
ConductorSegment *middleSegment();
QPointF posForText(Qt::Orientations &flag);
QString text() const;
void setText(const QString &);
void refreshText();
void setOthersSequential (Conductor *);
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
QRectF boundingRect() const;
virtual QPainterPath shape() const;
virtual QPainterPath nearShape() const;
qreal length() const;
ConductorSegment *middleSegment();
QPointF posForText(Qt::Orientations &flag);
QString text() const;
void setText(const QString &);
void refreshText();
void setOthersSequential (Conductor *);
public:
static bool valideXml (QDomElement &);
@@ -127,12 +123,11 @@ class Conductor : public QObject, public QGraphicsPathItem
autonum::sequenceStruct m_autoNum_seq;
public:
bool setSeq;
void setFreezeLabel(bool freeze);
QString m_frozen_label;
public slots:
void displayedTextChanged();
void displayedTextChanged();
protected:
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
@@ -143,58 +138,57 @@ class Conductor : public QObject, public QGraphicsPathItem
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
bool bMouseOver;
private:
bool m_mouse_over;
QetGraphicsHandlerUtility m_handler;
/// Functional properties
ConductorProperties properties_;
ConductorProperties m_properties;
/// Text input for non simple, non-singleline conductors
ConductorTextItem *text_item;
ConductorTextItem *text_item;
/// Segments composing the conductor
ConductorSegment *segments;
ConductorSegment *segments;
/// Attributs related to mouse interaction
bool moving_segment;
int moved_point;
qreal previous_z_value;
ConductorSegment *moved_segment;
QPointF before_mov_text_pos_;
bool moving_segment;
int moved_point;
qreal previous_z_value;
ConductorSegment *moved_segment;
QPointF before_mov_text_pos_;
/// Whether the conductor was manually modified by users
bool modified_path;
bool modified_path;
/// Whether the current profile should be saved as soon as possible
bool has_to_save_profile;
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;
ConductorProfilesGroup conductor_profiles;
/// QPen et QBrush objects used to draw conductors
static QPen conductor_pen;
static QBrush conductor_brush;
static bool pen_and_brush_initialized;
static QPen conductor_pen;
static QBrush conductor_brush;
static bool pen_and_brush_initialized;
/// Define whether and how the conductor should be highlighted
Highlight must_highlight_;
bool m_valid;
bool m_freeze_label = false;
Highlight must_highlight_;
bool m_valid;
bool m_freeze_label = false;
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;
QList<QPointF> junctions() const;
void pointsToSegments(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 loadSequential(QDomElement* e, QString seq, QStringList* list);
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;
QList<QPointF> junctions() const;
void pointsToSegments(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 loadSequential(QDomElement* e, QString seq, QStringList* list);
};
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);