diff --git a/resources/images/cursors/drawRulerLine.png b/resources/images/cursors/drawRulerLine.png
new file mode 100644
index 00000000..999f7703
Binary files /dev/null and b/resources/images/cursors/drawRulerLine.png differ
diff --git a/resources/sankore.qrc b/resources/sankore.qrc
index 9471e2cd..6af43d5d 100644
--- a/resources/sankore.qrc
+++ b/resources/sankore.qrc
@@ -173,6 +173,7 @@
images/cursors/rotate.png
images/cursors/resize.png
images/cursors/drawCompass.png
+ images/cursors/drawRulerLine.png
images/print/onepage.png
images/print/thumbnails.png
images/print/twopages.png
diff --git a/src/api/UBWidgetUniboardAPI.cpp b/src/api/UBWidgetUniboardAPI.cpp
index c6453de9..b8c1e9a9 100644
--- a/src/api/UBWidgetUniboardAPI.cpp
+++ b/src/api/UBWidgetUniboardAPI.cpp
@@ -179,7 +179,8 @@ void UBWidgetUniboardAPI::drawLineTo(const qreal x, const qreal y, const qreal p
return;
if (mScene)
- mScene->drawLineTo(QPointF(x, y), pWidth);
+ mScene->drawLineTo(QPointF(x, y), pWidth,
+ UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
}
diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp
index ea51f01b..648e4ec1 100644
--- a/src/board/UBBoardView.cpp
+++ b/src/board/UBBoardView.cpp
@@ -450,15 +450,18 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
event->accept ();
}
- else
- {
- viewport ()->setCursor (QCursor (Qt::BlankCursor));
-
- if (scene () && !mTabletStylusIsPressed)
- {
- scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())));
- }
- event->accept ();
+ else
+ {
+ if(UBDrawingController::drawingController()->mActiveRuler==NULL)
+ {
+ viewport()->setCursor (QCursor (Qt::BlankCursor));
+ }
+
+ if (scene () && !mTabletStylusIsPressed)
+ {
+ scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())));
+ }
+ event->accept ();
}
}
}
@@ -487,6 +490,11 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
{
QGraphicsView::mouseMoveEvent (event);
}
+ else if ((UBDrawingController::drawingController()->isDrawingTool())
+ && !mMouseButtonIsPressed)
+ {
+ QGraphicsView::mouseMoveEvent (event);
+ }
else if (currentTool == UBStylusTool::Text || currentTool == UBStylusTool::Capture)
{
if (mRubberBand && (mIsCreatingTextZone || mIsCreatingSceneGrabZone))
diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp
index 8b9d546a..849be774 100644
--- a/src/board/UBDrawingController.cpp
+++ b/src/board/UBDrawingController.cpp
@@ -27,6 +27,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
: QObject(parent)
, mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1)
+ , mActiveRuler(NULL)
{
connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged()));
diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h
index 59e66d28..0c2b4a97 100644
--- a/src/board/UBDrawingController.h
+++ b/src/board/UBDrawingController.h
@@ -12,6 +12,8 @@
#include "core/UB.h"
+class UBAbstractDrawRuler;
+
class UBDrawingController : public QObject
{
Q_OBJECT;
@@ -39,6 +41,8 @@ class UBDrawingController : public QObject
void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerAlpha(qreal alpha);
+ UBAbstractDrawRuler* mActiveRuler;
+
public slots:
void setStylusTool(int tool);
diff --git a/src/core/UB.h b/src/core/UB.h
index 7113250e..369897ca 100644
--- a/src/core/UB.h
+++ b/src/core/UB.h
@@ -16,7 +16,17 @@ struct UBStylusTool
{
enum Enum
{
- Pen = 0, Eraser, Marker, Selector, Hand, ZoomIn, ZoomOut, Pointer, Line, Text, Capture
+ Pen = 0,
+ Eraser,
+ Marker,
+ Selector,
+ Hand,
+ ZoomIn,
+ ZoomOut,
+ Pointer,
+ Line,
+ Text,
+ Capture
};
};
diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp
index b0dc09b9..6a667560 100644
--- a/src/core/UBDisplayManager.cpp
+++ b/src/core/UBDisplayManager.cpp
@@ -114,7 +114,10 @@ void UBDisplayManager::setAsControl(QWidget* pControlWidget )
mControlWidget->hide();
mControlWidget->setGeometry(mDesktop->screenGeometry(mControlScreenIndex));
mControlWidget->showFullScreen();
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
mControlWidget->setAttribute(Qt::WA_MacNoShadow);
+#endif
}
}
@@ -127,7 +130,10 @@ void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget)
mDisplayWidget->hide();
mDisplayWidget->setGeometry(mDesktop->screenGeometry(mDisplayScreenIndex));
mDisplayWidget->showFullScreen();
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
mDisplayWidget->setAttribute(Qt::WA_MacNoShadow);
+#endif
}
}
diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp
index 7224a673..5f2e1a9a 100644
--- a/src/desktop/UBDesktopAnnotationController.cpp
+++ b/src/desktop/UBDesktopAnnotationController.cpp
@@ -60,7 +60,10 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingView = new UBBoardView(UBApplication::boardController, 0); // deleted in UBDesktopAnnotationController::destructor
mTransparentDrawingView->setAttribute(Qt::WA_TranslucentBackground, true);
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
mTransparentDrawingView->setAttribute(Qt::WA_MacNoShadow, true);
+#endif
mTransparentDrawingView->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Window);
mTransparentDrawingView->setCacheMode(QGraphicsView::CacheNone);
mTransparentDrawingView->resize(UBApplication::desktop()->width(), UBApplication::desktop()->height());
diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp
index 4d743305..50d0433b 100644
--- a/src/domain/UBGraphicsDelegateFrame.cpp
+++ b/src/domain/UBGraphicsDelegateFrame.cpp
@@ -19,7 +19,6 @@
#include "gui/UBResources.h"
-const double PI = 4.0 * atan(1.0);
qreal const UBGraphicsDelegateFrame::mAngleTolerance = 6;
UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio)
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 2b400f55..31bd2934 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -59,8 +59,6 @@ qreal UBGraphicsScene::toolOffsetEraser = 200;
qreal UBGraphicsScene::toolOffsetCurtain = 1000;
qreal UBGraphicsScene::toolOffsetPointer = 1100;
-const double PI = 4.0 * atan(1.0);
-
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
: UBCoreGraphicsScene(parent)
, mEraser(0)
@@ -163,8 +161,18 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mAddedItems.clear();
mRemovedItems.clear();
- moveTo(scenePos);
- drawLineTo(scenePos, width);
+
+ if (UBDrawingController::drawingController()->mActiveRuler)
+ {
+ UBDrawingController::drawingController()->mActiveRuler->StartLine(
+ scenePos, width);
+ }
+ else
+ {
+ moveTo(scenePos);
+ drawLineTo(scenePos, width,
+ UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
+ }
accepted = true;
}
else if (currentTool == UBStylusTool::Eraser)
@@ -220,21 +228,29 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom();
- if (currentTool == UBStylusTool::Line)
- {
- QLineF radius(mPreviousPoint, position);
- qreal angle = radius.angle();
- angle = qRound(angle / 45) * 45;
- qreal radiusLength = radius.length();
- QPointF newPosition(
- mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
- mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
- QLineF chord(position, newPosition);
- if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
- position = newPosition;
- }
-
- drawLineTo(position, width);
+ if (dc->mActiveRuler)
+ {
+ dc->mActiveRuler->DrawLine(position, width);
+ }
+ else
+ {
+ if (currentTool == UBStylusTool::Line)
+ {
+ QLineF radius(mPreviousPoint, position);
+ qreal angle = radius.angle();
+ angle = qRound(angle / 45) * 45;
+ qreal radiusLength = radius.length();
+ QPointF newPosition(
+ mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
+ mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
+ QLineF chord(position, newPosition);
+ if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
+ position = newPosition;
+ }
+
+ drawLineTo(position, width,
+ UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
+ }
}
else if (currentTool == UBStylusTool::Eraser)
{
@@ -348,7 +364,7 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint)
}
-void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
+void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle)
{
if (mPreviousWidth == -1.0)
mPreviousWidth = pWidth;
@@ -364,7 +380,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
}
- if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line)
+ if (bLineStyle)
{
QSetIterator itItems(mAddedItems);
@@ -388,7 +404,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
mPreviousPolygonItems.append(polygonItem);
- if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line)
+ if (!bLineStyle)
{
mPreviousPoint = pEndPoint;
mPreviousWidth = pWidth;
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
index d07793f8..3302a449 100644
--- a/src/domain/UBGraphicsScene.h
+++ b/src/domain/UBGraphicsScene.h
@@ -37,6 +37,7 @@ class UBDocumentProxy;
class UBGraphicsCurtainItem;
class UBGraphicsStroke;
+const double PI = 4.0 * atan(1.0);
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
{
@@ -99,7 +100,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QRectF normalizedSceneRect(qreal ratio = -1.0);
void moveTo(const QPointF& pPoint);
- void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth);
+ void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle);
void eraseLineTo(const QPointF& pEndPoint, const qreal& pWidth);
void drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle);
@@ -240,6 +241,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
mTools << item;
}
+ const QPointF& previousPoint()
+ {
+ return mPreviousPoint;
+ }
+
public slots:
void hideEraser();
diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp
index 723619bc..aae28de1 100644
--- a/src/gui/UBDockPalette.cpp
+++ b/src/gui/UBDockPalette.cpp
@@ -33,7 +33,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
{
// standalone window
setAttribute(Qt::WA_TranslucentBackground);
- setAttribute(Qt::WA_MacNoShadow);
+
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
+ setAttribute(Qt::WA_MacNoShadow);
+#endif
+
}
mBackgroundBrush = QBrush(UBSettings::paletteColor);
diff --git a/src/gui/UBFloatingPalette.cpp b/src/gui/UBFloatingPalette.cpp
index 3f83764a..2338dae1 100644
--- a/src/gui/UBFloatingPalette.cpp
+++ b/src/gui/UBFloatingPalette.cpp
@@ -26,10 +26,13 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent)
else
{
// standalone window
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_MacAlwaysShowToolWindow);
setAttribute(Qt::WA_MacNonActivatingToolWindow);
setAttribute(Qt::WA_MacNoShadow);
+#endif
}
mBackgroundBrush = QBrush(UBSettings::paletteColor);
diff --git a/src/gui/UBResources.cpp b/src/gui/UBResources.cpp
index 2fe8cecf..0ec5770f 100644
--- a/src/gui/UBResources.cpp
+++ b/src/gui/UBResources.cpp
@@ -43,4 +43,5 @@ void UBResources::init()
arrowCursor = QCursor(Qt::ArrowCursor);
textCursor = QCursor(Qt::ArrowCursor);
rotateCursor = QCursor(QPixmap(":/images/cursors/rotate.png"), 16, 16);
+ drawLineRulerCursor = QCursor(QPixmap(":/images/cursors/drawRulerLine.png"), 3, 12);
}
diff --git a/src/gui/UBResources.h b/src/gui/UBResources.h
index 6bd21d1c..7f689ba1 100644
--- a/src/gui/UBResources.h
+++ b/src/gui/UBResources.h
@@ -31,6 +31,7 @@ class UBResources : public QObject
QCursor arrowCursor;
QCursor textCursor;
QCursor rotateCursor;
+ QCursor drawLineRulerCursor;
};
#endif /* UBRESOURCES_H_ */
diff --git a/src/tools/UBAbstractDrawRuler.cpp b/src/tools/UBAbstractDrawRuler.cpp
new file mode 100644
index 00000000..906895b6
--- /dev/null
+++ b/src/tools/UBAbstractDrawRuler.cpp
@@ -0,0 +1,9 @@
+
+#include "UBAbstractDrawRuler.h"
+
+UBAbstractDrawRuler::UBAbstractDrawRuler()
+{}
+
+
+UBAbstractDrawRuler::~UBAbstractDrawRuler()
+{}
diff --git a/src/tools/UBAbstractDrawRuler.h b/src/tools/UBAbstractDrawRuler.h
new file mode 100644
index 00000000..ae2f423f
--- /dev/null
+++ b/src/tools/UBAbstractDrawRuler.h
@@ -0,0 +1,21 @@
+#ifndef UB_ABSTRACTDRAWRULER_H_
+#define UB_ABSTRACTDRAWRULER_H_
+
+#include
+class UBGraphicsScene;
+
+class UBAbstractDrawRuler : public QObject
+{
+ Q_OBJECT;
+
+ public:
+ UBAbstractDrawRuler();
+ ~UBAbstractDrawRuler();
+
+ virtual void StartLine(const QPointF& position, qreal width) = 0;
+ virtual void DrawLine(const QPointF& position, qreal width) = 0;
+ virtual void EndLine() = 0;
+
+};
+
+#endif
\ No newline at end of file
diff --git a/src/tools/UBGraphicsCompass.cpp b/src/tools/UBGraphicsCompass.cpp
index f5495713..ef3489bd 100644
--- a/src/tools/UBGraphicsCompass.cpp
+++ b/src/tools/UBGraphicsCompass.cpp
@@ -16,8 +16,6 @@
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBDrawingController.h" // TODO UB 4.x clean that dependency
-const double PI = 4.0 * atan(1.0);
-
const QRect UBGraphicsCompass::sDefaultRect = QRect(0, -20, 300, 48);
const QColor UBGraphicsCompass::sLightBackgroundMiddleFillColor = QColor(0x72, 0x72, 0x72, sFillTransparency);
const QColor UBGraphicsCompass::sLightBackgroundEdgeFillColor = QColor(0xc3, 0xc3, 0xc3, sFillTransparency);
@@ -511,9 +509,11 @@ void UBGraphicsCompass::paintCenterCross()
{
QPointF needleCrossCenter = mapToScene(needlePosition());
scene()->moveTo(QPointF(needleCrossCenter.x() - 5, needleCrossCenter.y()));
- scene()->drawLineTo(QPointF(needleCrossCenter.x() + 5, needleCrossCenter.y()), 1);
+ scene()->drawLineTo(QPointF(needleCrossCenter.x() + 5, needleCrossCenter.y()), 1,
+ UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
scene()->moveTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() - 5));
- scene()->drawLineTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() + 5), 1);
+ scene()->drawLineTo(QPointF(needleCrossCenter.x(), needleCrossCenter.y() + 5), 1,
+ UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
}
QPointF UBGraphicsCompass::needlePosition() const
diff --git a/src/tools/UBGraphicsProtractor.cpp b/src/tools/UBGraphicsProtractor.cpp
index da38a1d2..bed25022 100644
--- a/src/tools/UBGraphicsProtractor.cpp
+++ b/src/tools/UBGraphicsProtractor.cpp
@@ -13,7 +13,6 @@
#include "board/UBBoardController.h"
-const double PI = 4.0 * atan(1.0);
const int UBGraphicsProtractor::sFillTransparency = 127;
const int UBGraphicsProtractor::sDrawTransparency = 192;
const QRectF UBGraphicsProtractor::sDefaultRect = QRectF(-175, -175, 350, 350);
diff --git a/src/tools/UBGraphicsRuler.cpp b/src/tools/UBGraphicsRuler.cpp
index b8b7a08d..85fa5991 100644
--- a/src/tools/UBGraphicsRuler.cpp
+++ b/src/tools/UBGraphicsRuler.cpp
@@ -13,6 +13,7 @@
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
+#include "board/UBDrawingController.h"
const QRect UBGraphicsRuler::sDefaultRect = QRect(0, 0, 800, 96);
const QColor UBGraphicsRuler::sLightBackgroundMiddleFillColor = QColor(0x72, 0x72, 0x72, sFillTransparency);
@@ -200,29 +201,40 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
- mCloseSvgItem->setParentItem(this);
- mResizeSvgItem->setParentItem(this);
- mRotateSvgItem->setParentItem(this);
-
- mShowButtons = true;
- mCloseSvgItem->setVisible(mShowButtons);
- mResizeSvgItem->setVisible(mShowButtons);
- mRotateSvgItem->setVisible(mShowButtons);
- if (event->pos().x() >= resizeButtonRect().left())
- {
- setCursor(resizeCursor());
- }
- else
- {
- if (closeButtonRect().contains(event->pos()))
- setCursor(closeCursor());
- else if (rotateButtonRect().contains(event->pos()))
- setCursor(rotateCursor());
- else
- setCursor(moveCursor());
- }
- event->accept();
- update();
+ UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
+
+ if (currentTool == UBStylusTool::Selector)
+ {
+ mCloseSvgItem->setParentItem(this);
+ mResizeSvgItem->setParentItem(this);
+ mRotateSvgItem->setParentItem(this);
+
+ mShowButtons = true;
+ mCloseSvgItem->setVisible(mShowButtons);
+ mResizeSvgItem->setVisible(mShowButtons);
+ mRotateSvgItem->setVisible(mShowButtons);
+ if (event->pos().x() >= resizeButtonRect().left())
+ {
+ setCursor(resizeCursor());
+ }
+ else
+ {
+ if (closeButtonRect().contains(event->pos()))
+ setCursor(closeCursor());
+ else if (rotateButtonRect().contains(event->pos()))
+ setCursor(rotateCursor());
+ else
+ setCursor(moveCursor());
+ }
+ event->accept();
+ update();
+ }
+ else if (UBDrawingController::drawingController()->isDrawingTool())
+ {
+ setCursor(drawRulerLineCursor());
+ UBDrawingController::drawingController()->mActiveRuler = this;
+ event->accept();
+ }
}
void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@@ -232,29 +244,39 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons);
+ UBDrawingController::drawingController()->mActiveRuler = NULL;
event->accept();
update();
}
void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
- mCloseSvgItem->setVisible(mShowButtons);
- mResizeSvgItem->setVisible(mShowButtons);
- mRotateSvgItem->setVisible(mShowButtons);
- if (event->pos().x() >= resizeButtonRect().left())
- {
- setCursor(resizeCursor());
- }
- else
- {
- if (closeButtonRect().contains(event->pos()))
- setCursor(closeCursor());
- else if (rotateButtonRect().contains(event->pos()))
- setCursor(rotateCursor());
- else
- setCursor(moveCursor());
- }
- event->accept();
+ UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
+
+ if (currentTool == UBStylusTool::Selector)
+ {
+ mCloseSvgItem->setVisible(mShowButtons);
+ mResizeSvgItem->setVisible(mShowButtons);
+ mRotateSvgItem->setVisible(mShowButtons);
+ if (event->pos().x() >= resizeButtonRect().left())
+ {
+ setCursor(resizeCursor());
+ }
+ else
+ {
+ if (closeButtonRect().contains(event->pos()))
+ setCursor(closeCursor());
+ else if (rotateButtonRect().contains(event->pos()))
+ setCursor(rotateCursor());
+ else
+ setCursor(moveCursor());
+ }
+ event->accept();
+ }
+ else if (currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Marker)
+ {
+ event->accept();
+ }
}
void UBGraphicsRuler::fillBackground(QPainter *painter)
@@ -456,3 +478,66 @@ void UBGraphicsRuler::updateResizeCursor()
QCursor resizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2);
mResizeCursor = resizeCursor;
}
+
+QCursor UBGraphicsRuler::drawRulerLineCursor() const
+{
+ return UBResources::resources()->drawLineRulerCursor;
+}
+
+void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
+{
+ QPointF itemPos = mapFromScene(scenePos);
+
+ qreal y;
+
+ if (itemPos.y() > rect().y() + rect().height() / 2)
+ {
+ drawLineDirection = 0;
+ y = rect().y() + rect().height() + width / 2;
+ }
+ else
+ {
+ drawLineDirection = 1;
+ y = rect().y() - width /2;
+ }
+
+ if (itemPos.x() < rect().x() + sLeftEdgeMargin)
+ itemPos.setX(rect().x() + sLeftEdgeMargin);
+ if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin)
+ itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin);
+
+ itemPos.setY(y);
+ itemPos = mapToScene(itemPos);
+
+ scene()->moveTo(itemPos);
+ scene()->drawLineTo(itemPos, width, true);
+}
+
+void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
+{
+ QPointF itemPos = mapFromScene(scenePos);
+
+ qreal y;
+ if (drawLineDirection == 0)
+ {
+ y = rect().y() + rect().height() + width / 2;
+ }
+ else
+ {
+ y = rect().y() - width /2;
+ }
+ if (itemPos.x() < rect().x() + sLeftEdgeMargin)
+ itemPos.setX(rect().x() + sLeftEdgeMargin);
+ if (itemPos.x() > rect().x() + rect().width() - sLeftEdgeMargin)
+ itemPos.setX(rect().x() + rect().width() - sLeftEdgeMargin);
+
+ itemPos.setY(y);
+ itemPos = mapToScene(itemPos);
+
+ // We have to use "pointed" line for marker tool
+ scene()->drawLineTo(itemPos, width,
+ UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
+}
+
+void UBGraphicsRuler::EndLine()
+{}
diff --git a/src/tools/UBGraphicsRuler.h b/src/tools/UBGraphicsRuler.h
index 1715aab2..9add46b8 100644
--- a/src/tools/UBGraphicsRuler.h
+++ b/src/tools/UBGraphicsRuler.h
@@ -14,10 +14,11 @@
#include "core/UB.h"
#include "domain/UBItem.h"
+#include "tools/UBAbstractDrawRuler.h"
class UBGraphicsScene;
-class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
+class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, public UBItem
{
Q_OBJECT;
@@ -34,6 +35,10 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
virtual UBItem* deepCopy() const;
+ virtual void StartLine(const QPointF& position, qreal width);
+ virtual void DrawLine(const QPointF& position, qreal width);
+ virtual void EndLine();
+
signals:
void hidden();
@@ -63,6 +68,7 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QCursor resizeCursor() const;
QCursor rotateCursor() const;
QCursor closeCursor() const;
+ QCursor drawRulerLineCursor() const;
QRectF resizeButtonRect() const;
QRectF closeButtonRect() const;
QRectF rotateButtonRect() const;
@@ -72,6 +78,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QColor edgeFillColor() const;
QFont font() const;
+ int drawLineDirection;
+
// Members
bool mResizing;
bool mRotating;
@@ -82,6 +90,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QCursor mResizeCursor;
qreal mAntiScaleRatio;
+ QPointF startDrawPosition;
+
// Constants
static const QRect sDefaultRect;
static const int sLeftEdgeMargin = 10;
diff --git a/src/tools/tools.pri b/src/tools/tools.pri
index bd72cb16..690a444b 100644
--- a/src/tools/tools.pri
+++ b/src/tools/tools.pri
@@ -4,11 +4,13 @@ HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsCompass.h \
src/tools/UBToolsManager.h \
src/tools/UBGraphicsCurtainItem.h \
- src/tools/UBGraphicsCurtainItemDelegate.h
+ src/tools/UBGraphicsCurtainItemDelegate.h \
+ src/tools/UBAbstractDrawRuler.h
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsProtractor.cpp \
src/tools/UBGraphicsCompass.cpp \
src/tools/UBToolsManager.cpp \
src/tools/UBGraphicsCurtainItem.cpp \
- src/tools/UBGraphicsCurtainItemDelegate.cpp \
\ No newline at end of file
+ src/tools/UBGraphicsCurtainItemDelegate.cpp \
+ src/tools/UBAbstractDrawRuler.cpp
\ No newline at end of file