|
|
@ -13,6 +13,7 @@ |
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "gui/UBResources.h" |
|
|
|
#include "gui/UBResources.h" |
|
|
|
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency |
|
|
|
#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 QRect UBGraphicsRuler::sDefaultRect = QRect(0, 0, 800, 96); |
|
|
|
const QColor UBGraphicsRuler::sLightBackgroundMiddleFillColor = QColor(0x72, 0x72, 0x72, sFillTransparency); |
|
|
|
const QColor UBGraphicsRuler::sLightBackgroundMiddleFillColor = QColor(0x72, 0x72, 0x72, sFillTransparency); |
|
|
@ -200,6 +201,10 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentTool == UBStylusTool::Selector) |
|
|
|
|
|
|
|
{ |
|
|
|
mCloseSvgItem->setParentItem(this); |
|
|
|
mCloseSvgItem->setParentItem(this); |
|
|
|
mResizeSvgItem->setParentItem(this); |
|
|
|
mResizeSvgItem->setParentItem(this); |
|
|
|
mRotateSvgItem->setParentItem(this); |
|
|
|
mRotateSvgItem->setParentItem(this); |
|
|
@ -223,6 +228,13 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
} |
|
|
|
} |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (UBDrawingController::drawingController()->isDrawingTool()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setCursor(drawRulerLineCursor()); |
|
|
|
|
|
|
|
UBDrawingController::drawingController()->mActiveRuler = this; |
|
|
|
|
|
|
|
event->accept(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
|
@ -232,12 +244,17 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
mCloseSvgItem->setVisible(mShowButtons); |
|
|
|
mCloseSvgItem->setVisible(mShowButtons); |
|
|
|
mResizeSvgItem->setVisible(mShowButtons); |
|
|
|
mResizeSvgItem->setVisible(mShowButtons); |
|
|
|
mRotateSvgItem->setVisible(mShowButtons); |
|
|
|
mRotateSvgItem->setVisible(mShowButtons); |
|
|
|
|
|
|
|
UBDrawingController::drawingController()->mActiveRuler = NULL; |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentTool == UBStylusTool::Selector) |
|
|
|
|
|
|
|
{ |
|
|
|
mCloseSvgItem->setVisible(mShowButtons); |
|
|
|
mCloseSvgItem->setVisible(mShowButtons); |
|
|
|
mResizeSvgItem->setVisible(mShowButtons); |
|
|
|
mResizeSvgItem->setVisible(mShowButtons); |
|
|
|
mRotateSvgItem->setVisible(mShowButtons); |
|
|
|
mRotateSvgItem->setVisible(mShowButtons); |
|
|
@ -255,6 +272,11 @@ void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) |
|
|
|
setCursor(moveCursor()); |
|
|
|
setCursor(moveCursor()); |
|
|
|
} |
|
|
|
} |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Marker) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
event->accept(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsRuler::fillBackground(QPainter *painter) |
|
|
|
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); |
|
|
|
QCursor resizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2); |
|
|
|
mResizeCursor = resizeCursor; |
|
|
|
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() |
|
|
|
|
|
|
|
{} |
|
|
|