Adapted the ruler to the strokes as objects

preferencesAboutTextFull
shibakaneki 13 years ago
parent 6ab23ce43a
commit bc875a6672
  1. 9
      src/domain/UBGraphicsPolygonItem.cpp
  2. 1
      src/domain/UBGraphicsPolygonItem.h
  3. 17
      src/domain/UBGraphicsScene.cpp
  4. 9
      src/tools/UBGraphicsRuler.cpp

@ -176,7 +176,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{ {
if(mHasAlpha && scene() && scene()->isLightBackground()) if(mHasAlpha && scene() && scene()->isLightBackground())
{ {
painter->setCompositionMode(QPainter::CompositionMode_Darken); painter->setCompositionMode(QPainter::CompositionMode_Darken);
@ -190,11 +189,3 @@ UBGraphicsScene* UBGraphicsPolygonItem::scene()
{ {
return qobject_cast<UBGraphicsScene*>(QGraphicsPolygonItem::scene()); return qobject_cast<UBGraphicsScene*>(QGraphicsPolygonItem::scene());
} }

@ -116,7 +116,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected: protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
private: private:
void clearStroke(); void clearStroke();

@ -432,13 +432,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor(); width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom(); width /= UBApplication::boardController->currentZoom();
if (dc->mActiveRuler) if (currentTool == UBStylusTool::Line || dc->mActiveRuler)
{
dc->mActiveRuler->DrawLine(position, width);
}
else
{
if (currentTool == UBStylusTool::Line)
{ {
if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){
UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon);
@ -464,6 +458,9 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
position = newPosition; position = newPosition;
} }
if(dc->mActiveRuler){
dc->mActiveRuler->DrawLine(position, width);
}else{
drawLineTo(position, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); drawLineTo(position, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
} }
} }
@ -675,14 +672,14 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
mpLastPolygon = polygonItem; mpLastPolygon = polygonItem;
mAddedItems.insert(polygonItem); mAddedItems.insert(polygonItem);
// Here we add the item to the scene
addItem(polygonItem);
if (mCurrentStroke) if (mCurrentStroke)
{ {
polygonItem->setStroke(mCurrentStroke); polygonItem->setStroke(mCurrentStroke);
} }
// Here we add the item to the scene
addItem(polygonItem);
mPreviousPolygonItems.append(polygonItem); mPreviousPolygonItems.append(polygonItem);
if (!bLineStyle) if (!bLineStyle)

@ -103,6 +103,7 @@ void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *s
painter->setPen(drawColor()); painter->setPen(drawColor());
painter->setRenderHint(QPainter::Antialiasing, true);
painter->drawRoundedRect(rect(), sRoundingRadius, sRoundingRadius); painter->drawRoundedRect(rect(), sRoundingRadius, sRoundingRadius);
fillBackground(painter); fillBackground(painter);
paintGraduations(painter); paintGraduations(painter);
@ -478,9 +479,11 @@ void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
// We have to use "pointed" line for marker tool // We have to use "pointed" line for marker tool
scene()->drawLineTo(itemPos, width, scene()->drawLineTo(itemPos, width, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
} }
void UBGraphicsRuler::EndLine() void UBGraphicsRuler::EndLine()
{} {
// We never come to this place
scene()->inputDeviceRelease();
}

Loading…
Cancel
Save