| 399 | } |
| 400 | |
| 401 | bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure, Qt::KeyboardModifiers modifiers) |
| 402 | { |
| 403 | bool accepted = false; |
| 404 | |
| 405 | if (mInputDeviceIsPressed) { |
| 406 | qWarning() << "scene received input device pressed, without input device release, muting event as input device move"; |
| 407 | accepted = inputDeviceMove(scenePos, pressure, modifiers); |
| 408 | } |
| 409 | else { |
| 410 | mInputDeviceIsPressed = true; |
| 411 | |
| 412 | UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); |
| 413 | |
| 414 | if (UBDrawingController::drawingController()->isDrawingTool()) { |
| 415 | // ----------------------------------------------------------------- |
| 416 | // We fall here if we are using the Pen, the Marker or the Line tool |
| 417 | // ----------------------------------------------------------------- |
| 418 | qreal width = 0; |
| 419 | |
| 420 | // delete current stroke, if not assigned to any polygon |
| 421 | if (mCurrentStroke && mCurrentStroke->polygons().empty()){ |
| 422 | delete mCurrentStroke; |
| 423 | mCurrentStroke = NULL; |
| 424 | } |
| 425 | |
| 426 | // hide the marker preview circle |
| 427 | if (currentTool == UBStylusTool::Marker) |
| 428 | hideMarkerCircle(); |
| 429 | |
| 430 | // hide the pen preview circle |
| 431 | if (currentTool == UBStylusTool::Pen) |
| 432 | hidePenCircle(); |
| 433 | |
| 434 | // --------------------------------------------------------------- |
| 435 | // Create a new Stroke. A Stroke is a collection of QGraphicsLines |
| 436 | // --------------------------------------------------------------- |
| 437 | mCurrentStroke = new UBGraphicsStroke(shared_from_this()); |
| 438 | |
| 439 | if (currentTool != UBStylusTool::Line){ |
| 440 | // Handle the pressure |
| 441 | width = UBDrawingController::drawingController()->currentToolWidth() * pressure; |
| 442 | } |
| 443 | else{ |
| 444 | // Ignore pressure for the line tool |
| 445 | width = UBDrawingController::drawingController()->currentToolWidth(); |
| 446 | } |
| 447 | |
| 448 | width /= UBApplication::boardController->systemScaleFactor(); |
| 449 | width /= UBApplication::boardController->currentZoom(); |
| 450 | |
| 451 | mAddedItems.clear(); |
| 452 | mRemovedItems.clear(); |
| 453 | |
| 454 | if (UBDrawingController::drawingController()->activeRuler()) |
| 455 | UBDrawingController::drawingController()->activeRuler()->StartLine(scenePos, width); |
| 456 | else { |
| 457 | bool isLine = UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line; |
| 458 | QPointF pos = scenePos; |
no test coverage detected