mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-09 08:49:59 +01:00
QT6: QStyleOptionGraphicsItem
This commit is contained in:
@@ -262,23 +262,30 @@ void Terminal::removeConductor(Conductor *conductor)
|
||||
/**
|
||||
@brief Terminal::paint
|
||||
Fonction de dessin des bornes
|
||||
@param p Le QPainter a utiliser
|
||||
@param painter Le QPainter a utiliser
|
||||
@param options Les options de dessin
|
||||
*/
|
||||
void Terminal::paint(
|
||||
QPainter *p,
|
||||
QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *options,
|
||||
QWidget *)
|
||||
{
|
||||
// en dessous d'un certain zoom, les bornes ne sont plus dessinees
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
if (options && options -> levelOfDetail < 0.5) return;
|
||||
|
||||
p -> save();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 0.5)
|
||||
return;
|
||||
#endif
|
||||
painter -> save();
|
||||
|
||||
//annulation des renderhints
|
||||
p -> setRenderHint(QPainter::Antialiasing, false);
|
||||
p -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
// on travaille avec les coordonnees de l'element parent
|
||||
QPointF c = mapFromParent(d->m_pos);
|
||||
@@ -287,23 +294,31 @@ void Terminal::paint(
|
||||
QPen t;
|
||||
t.setWidthF(1.0);
|
||||
|
||||
if (options && options -> levelOfDetail < 1.0) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
if (options && options -> levelOfDetail < 1.0)
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 1.0)
|
||||
#endif
|
||||
{
|
||||
t.setCosmetic(true);
|
||||
}
|
||||
|
||||
// dessin de la borne en rouge
|
||||
t.setColor(Qt::red);
|
||||
p -> setPen(t);
|
||||
p -> drawLine(c, e);
|
||||
painter -> setPen(t);
|
||||
painter -> drawLine(c, e);
|
||||
|
||||
// dessin du point d'amarrage au conducteur en bleu
|
||||
t.setColor(hovered_color_);
|
||||
p -> setPen(t);
|
||||
p -> setBrush(hovered_color_);
|
||||
painter -> setPen(t);
|
||||
painter -> setBrush(hovered_color_);
|
||||
if (hovered_) {
|
||||
p -> setRenderHint(QPainter::Antialiasing, true);
|
||||
p -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||
} else p -> drawPoint(c);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, true);
|
||||
painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||
} else painter -> drawPoint(c);
|
||||
|
||||
//Draw help line if needed,
|
||||
if (diagram() && m_draw_help_line)
|
||||
@@ -365,7 +380,7 @@ void Terminal::paint(
|
||||
m_help_line_a -> setLine(line);
|
||||
}
|
||||
|
||||
p -> restore();
|
||||
painter -> restore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ class Terminal : public QGraphicsObject
|
||||
signals:
|
||||
void conductorWasAdded(Conductor *conductor);
|
||||
void conductorWasRemoved(Conductor *conductor);
|
||||
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
@@ -47,10 +47,10 @@ class Terminal : public QGraphicsObject
|
||||
Terminal(QPointF, Qet::Orientation, QString number,
|
||||
QString name, bool hiddenName, Element * = nullptr);
|
||||
~Terminal() override;
|
||||
|
||||
|
||||
private:
|
||||
Terminal(const Terminal &);
|
||||
|
||||
|
||||
// methods
|
||||
public:
|
||||
/**
|
||||
@@ -60,13 +60,15 @@ class Terminal : public QGraphicsObject
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
|
||||
void paint (QPainter *,const QStyleOptionGraphicsItem *,
|
||||
QWidget *) 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);
|
||||
@@ -75,7 +77,7 @@ class Terminal : public QGraphicsObject
|
||||
Diagram *diagram () const;
|
||||
Element *parentElement () const;
|
||||
QUuid uuid () const;
|
||||
|
||||
|
||||
QList<Conductor *> conductors() const;
|
||||
Qet::Orientation orientation() const;
|
||||
QPointF dockConductor() const;
|
||||
@@ -86,12 +88,12 @@ class Terminal : public QGraphicsObject
|
||||
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;
|
||||
|
||||
|
||||
protected:
|
||||
// methods related to events management
|
||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
||||
@@ -100,7 +102,7 @@ class Terminal : public QGraphicsObject
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
||||
|
||||
|
||||
// attributes
|
||||
public:
|
||||
enum { Type = UserType + 1002 };
|
||||
@@ -116,7 +118,7 @@ class Terminal : public QGraphicsObject
|
||||
static QColor warningColor;
|
||||
/// color for forbidden actions
|
||||
static QColor forbiddenColor;
|
||||
|
||||
|
||||
private:
|
||||
bool m_draw_help_line{false};
|
||||
QGraphicsLineItem *m_help_line{nullptr};
|
||||
@@ -127,10 +129,10 @@ class Terminal : public QGraphicsObject
|
||||
|
||||
/// Parent electrical element
|
||||
Element *parent_element_{nullptr};
|
||||
public:
|
||||
public:
|
||||
/// docking point for parent element
|
||||
QPointF dock_elmt_;
|
||||
private:
|
||||
private:
|
||||
/// List of conductors attached to the terminal
|
||||
QList<Conductor *> conductors_;
|
||||
/**
|
||||
@@ -150,7 +152,7 @@ class Terminal : public QGraphicsObject
|
||||
/// 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,
|
||||
@@ -185,6 +187,6 @@ inline QString Terminal::name() const
|
||||
}
|
||||
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||
const bool all_diagram = true);
|
||||
const bool all_diagram = true);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user