mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 09:40:52 +01:00
Le curseur change lorsqu'on le passe au-dessus des points de modification des conducteurs.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@55 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
27
conducer.cpp
27
conducer.cpp
@@ -40,6 +40,8 @@ Conducer::Conducer(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *
|
|||||||
segments = NULL;
|
segments = NULL;
|
||||||
priv_calculeConducer(terminal1 -> amarrageConducer(), terminal1 -> orientation(), terminal2 -> amarrageConducer(), terminal2 -> orientation());
|
priv_calculeConducer(terminal1 -> amarrageConducer(), terminal1 -> orientation(), terminal2 -> amarrageConducer(), terminal2 -> orientation());
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
|
previous_z_value = zValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,11 +414,15 @@ void Conducer::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (hasClickedOn(press_point, segment -> secondPoint())) {
|
if (hasClickedOn(press_point, segment -> secondPoint())) {
|
||||||
moving_point = true;
|
moving_point = true;
|
||||||
moving_segment = false;
|
moving_segment = false;
|
||||||
|
previous_z_value = zValue();
|
||||||
|
setZValue(5000.0);
|
||||||
moved_segment = segment;
|
moved_segment = segment;
|
||||||
break;
|
break;
|
||||||
} else if (hasClickedOn(press_point, segment -> middle())) {
|
} else if (hasClickedOn(press_point, segment -> middle())) {
|
||||||
moving_point = false;
|
moving_point = false;
|
||||||
moving_segment = true;
|
moving_segment = true;
|
||||||
|
previous_z_value = zValue();
|
||||||
|
setZValue(5000.0);
|
||||||
moved_segment = segment;
|
moved_segment = segment;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -487,9 +493,30 @@ void Conducer::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
// clic gauche
|
// clic gauche
|
||||||
moving_point = false;
|
moving_point = false;
|
||||||
moving_segment = false;
|
moving_segment = false;
|
||||||
|
setZValue(previous_z_value);
|
||||||
QGraphicsPathItem::mouseReleaseEvent(e);
|
QGraphicsPathItem::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Conducer::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
if (isSelected()) {
|
||||||
|
QPointF hover_point = mapFromScene(e -> pos());
|
||||||
|
ConducerSegment *segment = segments;
|
||||||
|
bool cursor_set = false;
|
||||||
|
while (segment -> hasNextSegment()) {
|
||||||
|
/*if (hasClickedOn(hover_point, segment -> secondPoint())) {
|
||||||
|
setCursor(Qt::CrossCursor);
|
||||||
|
cursor_set = true;
|
||||||
|
} else */if (hasClickedOn(hover_point, segment -> middle())) {
|
||||||
|
setCursor(segment -> isVertical() ? Qt::SplitHCursor : Qt::SplitVCursor);
|
||||||
|
cursor_set = true;
|
||||||
|
}
|
||||||
|
segment = segment -> nextSegment();
|
||||||
|
}
|
||||||
|
if (!cursor_set) setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
QGraphicsPathItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le rectangle delimitant l'espace de dessin du conducteur
|
@return Le rectangle delimitant l'espace de dessin du conducteur
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// booleen indiquant si le fil est encore valide
|
/// booleen indiquant si le fil est encore valide
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
bool moving_point;
|
bool moving_point;
|
||||||
bool moving_segment;
|
bool moving_segment;
|
||||||
int moved_point;
|
int moved_point;
|
||||||
|
qreal previous_z_value;
|
||||||
ConducerSegment *moved_segment;
|
ConducerSegment *moved_segment;
|
||||||
bool modified_path;
|
bool modified_path;
|
||||||
static QPen conducer_pen;
|
static QPen conducer_pen;
|
||||||
|
|||||||
Reference in New Issue
Block a user