mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Lors du deplacement d'un champ de texte rattache a un conducteur, ce dernier est desormais mis en evidence.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@988 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -48,7 +48,8 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
|||||||
previous_z_value(zValue()),
|
previous_z_value(zValue()),
|
||||||
modified_path(false),
|
modified_path(false),
|
||||||
has_to_save_profile(false),
|
has_to_save_profile(false),
|
||||||
segments_squares_scale_(1.0)
|
segments_squares_scale_(1.0),
|
||||||
|
must_highlight_(Conductor::None)
|
||||||
{
|
{
|
||||||
// ajout du conducteur a la liste de conducteurs de chacune des deux bornes
|
// ajout du conducteur a la liste de conducteurs de chacune des deux bornes
|
||||||
bool ajout_p1 = terminal1 -> addConductor(this);
|
bool ajout_p1 = terminal1 -> addConductor(this);
|
||||||
@@ -419,16 +420,13 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
qp -> save();
|
qp -> save();
|
||||||
qp -> setRenderHint(QPainter::Antialiasing, false);
|
qp -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
/*
|
|
||||||
qp -> save();
|
|
||||||
qp -> setPen(Qt::blue);
|
|
||||||
qp -> drawPath(variableShape(60.0).simplified());
|
|
||||||
qp -> restore();
|
|
||||||
*/
|
|
||||||
|
|
||||||
// determine la couleur du conducteur
|
// determine la couleur du conducteur
|
||||||
QColor final_conductor_color(properties_.color);
|
QColor final_conductor_color(properties_.color);
|
||||||
if (isSelected()) {
|
if (must_highlight_ == Normal) {
|
||||||
|
final_conductor_color = QColor::fromRgb(69, 137, 255, 255);
|
||||||
|
} else if (must_highlight_ == Alert) {
|
||||||
|
final_conductor_color =QColor::fromRgb(255, 69, 0, 255);
|
||||||
|
} else if (isSelected()) {
|
||||||
final_conductor_color = Qt::red;
|
final_conductor_color = Qt::red;
|
||||||
} else {
|
} else {
|
||||||
if (Diagram *parent_diagram = diagram()) {
|
if (Diagram *parent_diagram = diagram()) {
|
||||||
@@ -1234,6 +1232,21 @@ void Conductor::adjustTextItemPosition() {
|
|||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true si le conducteur est mis en evidence
|
||||||
|
*/
|
||||||
|
Conductor::Highlight Conductor::highlight() const {
|
||||||
|
return(must_highlight_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param hl true pour mettre le conducteur en evidence, false sinon
|
||||||
|
*/
|
||||||
|
void Conductor::setHighlighted(Conductor::Highlight hl) {
|
||||||
|
must_highlight_ = hl;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
// attributs
|
// attributs
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1001 };
|
enum { Type = UserType + 1001 };
|
||||||
|
enum Highlight { None, Normal, Alert };
|
||||||
|
|
||||||
/// premiere borne a laquelle le fil est rattache
|
/// premiere borne a laquelle le fil est rattache
|
||||||
Terminal *terminal1;
|
Terminal *terminal1;
|
||||||
@@ -87,6 +88,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
ConductorProfilesGroup profiles() const;
|
ConductorProfilesGroup profiles() const;
|
||||||
void readProperties();
|
void readProperties();
|
||||||
void adjustTextItemPosition();
|
void adjustTextItemPosition();
|
||||||
|
virtual Highlight highlight() const;
|
||||||
|
virtual void setHighlighted(Highlight);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void displayedTextChanged();
|
void displayedTextChanged();
|
||||||
@@ -130,6 +133,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
static bool pen_and_brush_initialized;
|
static bool pen_and_brush_initialized;
|
||||||
/// facteur de taille du carre de saisie du segment
|
/// facteur de taille du carre de saisie du segment
|
||||||
qreal segments_squares_scale_;
|
qreal segments_squares_scale_;
|
||||||
|
/// Definit la facon dont le conducteur doit etre mis en evidence
|
||||||
|
Highlight must_highlight_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void segmentsToPath();
|
void segmentsToPath();
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
|
||||||
DiagramTextItem(parent_conductor, parent_diagram),
|
DiagramTextItem(parent_conductor, parent_diagram),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false)
|
moved_by_user_(false),
|
||||||
|
first_move_(true)
|
||||||
{
|
{
|
||||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||||
// cela nous convient, on ne touche pas a ces flags
|
// cela nous convient, on ne touche pas a ces flags
|
||||||
@@ -42,7 +43,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
|
|||||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
|
||||||
DiagramTextItem(text, parent_conductor, parent_diagram),
|
DiagramTextItem(text, parent_conductor, parent_diagram),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false)
|
moved_by_user_(false),
|
||||||
|
first_move_(true)
|
||||||
{
|
{
|
||||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||||
// cela nous convient, on ne touche pas a ces flags
|
// cela nous convient, on ne touche pas a ces flags
|
||||||
@@ -128,6 +130,7 @@ void ConductorTextItem::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
|
if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
|
||||||
before_mov_pos_ = pos();
|
before_mov_pos_ = pos();
|
||||||
}
|
}
|
||||||
|
first_move_ = true;
|
||||||
DiagramTextItem::mousePressEvent(e);
|
DiagramTextItem::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,10 +150,17 @@ void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (parent_conductor_) {
|
if (parent_conductor_) {
|
||||||
if (parent_conductor_ -> isNearConductor(intended_pos)) {
|
if (parent_conductor_ -> isNearConductor(intended_pos)) {
|
||||||
setPos(intended_pos);
|
setPos(intended_pos);
|
||||||
|
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
||||||
|
} else {
|
||||||
|
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else e -> ignore();
|
} else e -> ignore();
|
||||||
|
|
||||||
|
if (first_move_) {
|
||||||
|
first_move_ = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,6 +184,10 @@ void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
|
|
||||||
diagram_ptr -> undoStack().push(undo_object);
|
diagram_ptr -> undoStack().push(undo_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parent_conductor_) {
|
||||||
|
parent_conductor_ -> setHighlighted(Conductor::None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||||
|
|||||||
@@ -60,5 +60,6 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
bool moved_by_user_;
|
bool moved_by_user_;
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
|
bool first_move_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user