MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / hoverMoveEvent

Method hoverMoveEvent

ImagePlay/src/IPProcessEdge.cpp:201–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void IPProcessEdge::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
202{
203 // calculate distance from line to point
204 int x0 = event->scenePos().x();
205 int y0 = event->scenePos().y();
206 int x1 = _intersectionFrom.toPoint().x();
207 int y1 = _intersectionFrom.toPoint().y();
208 int x2 = _intersectionTo.toPoint().x();
209 int y2 = _intersectionTo.toPoint().y();
210
211 int v1 = (x2-x1)*(y1-y0) - (x1-x0)*(y2-y1);
212 int v2 = ::sqrt((double) ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
213 int distance = ::abs(v1)/v2;
214
215 if(distance < 20)
216 {
217 _mouseOver = true;
218 }
219 else
220 {
221 _mouseOver = false;
222 }
223
224 // redraw
225 update(boundingRect());
226
227 QGraphicsItem::hoverMoveEvent(event);
228}
229
230
231QVariant IPProcessEdge::itemChange(GraphicsItemChange change, const QVariant &value)

Callers

nothing calls this directly

Calls 2

toPointMethod · 0.80
absFunction · 0.50

Tested by

no test coverage detected