MCPcopy Create free account
hub / github.com/TeXworks/texworks / mouseMove

Method mouseMove

modules/QtPDF/src/PDFDocumentTools.cpp:428–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428void MeasureLineGrip::mouseMove(const QPointF scenePos, const Qt::KeyboardModifiers modifiers)
429{
430 MeasureLine * ml = dynamic_cast<MeasureLine*>(parentItem());
431 Q_ASSERT(ml != nullptr);
432
433 switch(_pt) {
434 case 1:
435 {
436 QLineF line(scenePos, ml->line().p2());
437 if (modifiers.testFlag(Qt::ControlModifier)) {
438 // locked mode; horizontal or vertical line only
439 if (line.angle() <= 45 || line.angle() >= 315 ||
440 (line.angle() >= 135 && line.angle() <= 225))
441 line.setP1(QPointF(line.p1().x(), line.p2().y()));
442 else
443 line.setP1(QPointF(line.p2().x(), line.p1().y()));
444 }
445 ml->setLine(line);
446 break;
447 }
448 default:
449 {
450 QLineF line(ml->line().p1(), scenePos);
451 if (modifiers.testFlag(Qt::ControlModifier)) {
452 // locked mode; horizontal or vertical line only
453 if (line.angle() <= 45 || line.angle() >= 315 ||
454 (line.angle() >= 135 && line.angle() <= 225))
455 line.setP2(QPointF(line.p2().x(), line.p1().y()));
456 else
457 line.setP2(QPointF(line.p1().x(), line.p2().y()));
458 }
459 ml->setLine(line);
460 break;
461 }
462 }
463}
464
465// MeasureLine
466// ===========================

Callers 1

mouseMoveEventMethod · 0.80

Calls 1

setLineMethod · 0.45

Tested by

no test coverage detected