@@ -366,6 +366,8 @@ UBGraphicsScene::UBGraphicsScene(std::shared_ptr<UBDocumentProxy> document, bool
366366// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
367367 connect (UBApplication::undoStack.data (), SIGNAL (indexChanged (int )), this , SLOT (updateSelectionFrameWrapper (int )));
368368 connect (UBDrawingController::drawingController (), SIGNAL (stylusToolChanged (int ,int )), this , SLOT (stylusToolChanged (int ,int )));
369+
370+ installEventFilter (this );
369371}
370372
371373UBGraphicsScene::~UBGraphicsScene ()
@@ -714,6 +716,7 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
714716 addPolygonItemToCurrentStroke (poly);
715717 }
716718
719+ if (multiDrawLines.isEmpty ()) // is it not polygons drawing by multiDraw
717720 // replace the stroke by a simplified version of it
718721 if ((currentTool == UBStylusTool::Pen && UBSettings::settings ()->boardSimplifyPenStrokes ->get ().toBool ())
719722 || (currentTool == UBStylusTool::Marker && UBSettings::settings ()->boardSimplifyMarkerStrokes ->get ().toBool ()))
@@ -2052,6 +2055,27 @@ bool UBGraphicsScene::isEmpty() const
20522055 return mItemCount == 0 ;
20532056}
20542057
2058+ bool UBGraphicsScene::eventFilter (QObject *watched, QEvent *event)
2059+ {
2060+ if ( UBApplication::applicationController != NULL ) // it needs to work only on Board mode
2061+ if ( UBApplication::applicationController->displayMode () != UBApplicationController::Board ||
2062+ UBApplication::applicationController->isShowingDesktop ())
2063+ return false ;
2064+ if (watched == this )
2065+ {
2066+ UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
2067+ if ((event->type () == QEvent::TouchUpdate || event->type () == QEvent::TouchEnd) // for use multiDraw
2068+ && (currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Marker)) // when Pen or Marker
2069+ {
2070+ MultiTouchDrawing (static_cast <QTouchEvent*>(event), currentTool);
2071+ if (event->type () == QEvent::TouchEnd) // end of multiDraw
2072+ MultiTouchEndDrawing ();
2073+ return true ;
2074+ }
2075+ }
2076+ return false ;
2077+ }
2078+
20552079QGraphicsItem* UBGraphicsScene::setAsBackgroundObject (QGraphicsItem* item, bool pAdaptTransformation, bool pExpand)
20562080{
20572081 if (mBackgroundObject )
@@ -3122,3 +3146,49 @@ void UBGraphicsScene::initStroke()
31223146{
31233147 mCurrentStroke = new UBGraphicsStroke (shared_from_this ());
31243148}
3149+
3150+ void UBGraphicsScene::MultiTouchDrawing (QTouchEvent* event, UBStylusTool::Enum currentTool)
3151+ {
3152+ QList <QTouchEvent::TouchPoint> touchPoints = event->touchPoints ();
3153+ foreach (QTouchEvent::TouchPoint point, touchPoints)
3154+ {
3155+ lastPoint_m = point.lastPos ();
3156+ endPoint_m = point.pos ();
3157+
3158+ int distance = sqrt (pow ((lastPoint_m.x () - endPoint_m.x ()),2 ) + pow ((lastPoint_m.y () - endPoint_m.y ()),2 )) + 1 ;
3159+ distance = sqrt (distance);
3160+ if (distance > 6 )
3161+ distance = 6 ;
3162+ else if (distance < 4 )
3163+ distance = 4 ;
3164+
3165+ UBBoardView* boardView = controlView ();
3166+ QLineF line;
3167+ line.setP1 (boardView->mapToScene (UBGeometryUtils::pointConstrainedInRect (lastPoint_m.toPoint (), boardView->rect ())));
3168+ line.setP2 (boardView->mapToScene (UBGeometryUtils::pointConstrainedInRect (endPoint_m.toPoint (), boardView->rect ())));
3169+ if (!multiDrawLines.contains (line)) // to eliminate duplicates
3170+ {
3171+ multiDrawLines.append (line);
3172+
3173+ qreal penWidth = 0 ;
3174+ if (currentTool == UBStylusTool::Pen)
3175+ penWidth = UBSettings::settings ()->currentPenWidth ();
3176+ else if (currentTool == UBStylusTool::Marker)
3177+ penWidth = UBSettings::settings ()->currentMarkerWidth ();
3178+ penWidth /= UBApplication::boardController->systemScaleFactor ();
3179+ penWidth /= UBApplication::boardController->currentZoom ();
3180+
3181+ UBGraphicsPolygonItem *polygonItem = lineToPolygonItem (line, penWidth, penWidth);
3182+ addPolygonItemToCurrentStroke (polygonItem);
3183+ }
3184+
3185+ lastPoint_m = endPoint_m;
3186+ }
3187+ }
3188+
3189+ void UBGraphicsScene::MultiTouchEndDrawing ()
3190+ {
3191+ inputDeviceRelease ();
3192+ multiDrawLines.clear ();
3193+ controlView ()->releaseAllInputDevices ();
3194+ }
0 commit comments