|
|
@ -19,6 +19,7 @@ |
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
#include "domain/UBGraphicsScene.h" |
|
|
|
#include "domain/UBGraphicsScene.h" |
|
|
|
|
|
|
|
#include "board/UBBoardView.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
@ -27,7 +28,6 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive) |
|
|
|
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) |
|
|
|
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) |
|
|
|
, mShouldMoveWidget(false) |
|
|
|
, mShouldMoveWidget(false) |
|
|
|
, mShouldResizeWidget(false) |
|
|
|
, mShouldResizeWidget(false) |
|
|
|
, inTimer(false) |
|
|
|
|
|
|
|
, borderPen(Qt::darkGray) |
|
|
|
, borderPen(Qt::darkGray) |
|
|
|
, gView(0) |
|
|
|
, gView(0) |
|
|
|
, mView(0) |
|
|
|
, mView(0) |
|
|
@ -70,16 +70,11 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(slot_refresh())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBMagnifier::~UBMagnifier() |
|
|
|
UBMagnifier::~UBMagnifier() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (timerUpdate != 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
killTimer(timerUpdate); |
|
|
|
|
|
|
|
timerUpdate = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(sClosePixmap) |
|
|
|
if(sClosePixmap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete sClosePixmap; |
|
|
|
delete sClosePixmap; |
|
|
@ -285,12 +280,8 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBMagnifier::timerEvent(QTimerEvent *e) |
|
|
|
void UBMagnifier::slot_refresh() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(inTimer) return; |
|
|
|
|
|
|
|
if (e->timerId() == timerUpdate) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
inTimer = true; |
|
|
|
|
|
|
|
if(!(updPointGrab.isNull()))
|
|
|
|
if(!(updPointGrab.isNull()))
|
|
|
|
grabPoint(updPointGrab); |
|
|
|
grabPoint(updPointGrab); |
|
|
|
|
|
|
|
|
|
|
@ -307,28 +298,37 @@ void UBMagnifier::timerEvent(QTimerEvent *e) |
|
|
|
isCusrsorAlreadyStored = false; |
|
|
|
isCusrsorAlreadyStored = false; |
|
|
|
setCursor(mOldCursor); |
|
|
|
setCursor(mOldCursor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inTimer = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBMagnifier::grabPoint() |
|
|
|
void UBMagnifier::grabPoint() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QMatrix transM = UBApplication::boardController->controlView()->matrix(); |
|
|
|
QPointF itemPos = gView->mapFromGlobal(updPointGrab); |
|
|
|
QPointF itemPos = gView->mapFromGlobal(updPointGrab); |
|
|
|
|
|
|
|
|
|
|
|
qreal zWidth = size().width() / params.zoom; |
|
|
|
qreal zWidth = width() / (params.zoom * transM.m11()); |
|
|
|
qreal zWidthHalf = zWidth / 2; |
|
|
|
qreal zWidthHalf = zWidth / 2; |
|
|
|
qreal zHeight = size().height() / params.zoom; |
|
|
|
qreal zHeight = height() / (params.zoom * transM.m22()); |
|
|
|
qreal zHeightHalf = zHeight / 2; |
|
|
|
qreal zHeightHalf = zHeight / 2; |
|
|
|
|
|
|
|
|
|
|
|
int x = itemPos.x() - zWidthHalf; |
|
|
|
|
|
|
|
int y = itemPos.y() - zHeightHalf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap newPixMap(QSize(zWidth,zHeight)); |
|
|
|
QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y()))); |
|
|
|
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); |
|
|
|
|
|
|
|
UBApplication::boardController->activeScene()->update(); |
|
|
|
|
|
|
|
|
|
|
|
QRect magnifierRect = rect(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float x = pfScLtF.x() - zWidthHalf; |
|
|
|
|
|
|
|
float y = pfScLtF.y() - zHeightHalf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPointF leftTop(x,y); |
|
|
|
|
|
|
|
QPointF rightBottom(x + zWidth, y + zHeight);
|
|
|
|
|
|
|
|
QRectF srcRect(leftTop, rightBottom); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap newPixMap(QSize(width(), height())); |
|
|
|
|
|
|
|
QPainter painter(&newPixMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect); |
|
|
|
|
|
|
|
painter.end(); |
|
|
|
|
|
|
|
|
|
|
|
pMap.fill(Qt::transparent); |
|
|
|
pMap.fill(Qt::transparent); |
|
|
|
pMap = newPixMap.scaled(QSize(width(), height())); |
|
|
|
pMap = newPixMap.scaled(QSize(width(), height())); |
|
|
@ -339,28 +339,43 @@ void UBMagnifier::grabPoint() |
|
|
|
|
|
|
|
|
|
|
|
void UBMagnifier::grabPoint(const QPoint &pGrab) |
|
|
|
void UBMagnifier::grabPoint(const QPoint &pGrab) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QMatrix transM = UBApplication::boardController->controlView()->matrix(); |
|
|
|
updPointGrab = pGrab; |
|
|
|
updPointGrab = pGrab; |
|
|
|
QPointF itemPos = gView->mapFromGlobal(pGrab); |
|
|
|
QPointF itemPos = gView->mapFromGlobal(pGrab); |
|
|
|
|
|
|
|
|
|
|
|
qreal zWidth = size().width() / params.zoom; |
|
|
|
qreal zWidth = width() / (params.zoom * transM.m11()); |
|
|
|
qreal zWidthHalf = zWidth / 2; |
|
|
|
qreal zWidthHalf = zWidth / 2; |
|
|
|
qreal zHeight = size().height() / params.zoom; |
|
|
|
qreal zHeight = height() / (params.zoom * transM.m22()); |
|
|
|
qreal zHeightHalf = zHeight / 2; |
|
|
|
qreal zHeightHalf = zHeight / 2; |
|
|
|
|
|
|
|
|
|
|
|
int x = itemPos.x() - zWidthHalf; |
|
|
|
|
|
|
|
int y = itemPos.y() - zHeightHalf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap newPixMap(QSize(zWidth,zHeight)); |
|
|
|
QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y()))); |
|
|
|
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); |
|
|
|
|
|
|
|
UBApplication::boardController->activeScene()->update(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pMap.fill(Qt::transparent); |
|
|
|
|
|
|
|
pMap = newPixMap.scaled(QSize(width(), height())); |
|
|
|
QRect magnifierRect = rect(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float x = pfScLtF.x() - zWidthHalf; |
|
|
|
|
|
|
|
float y = pfScLtF.y() - zHeightHalf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPointF leftTop(x,y); |
|
|
|
|
|
|
|
QPointF rightBottom(x + zWidth, y + zHeight);
|
|
|
|
|
|
|
|
QRectF srcRect(leftTop, rightBottom); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap newPixMap(QSize(width(), height())); |
|
|
|
|
|
|
|
QPainter painter(&newPixMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
|
|
|
|
|
|
|
|
painter.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pMap.fill(Qt::transparent);
|
|
|
|
|
|
|
|
pMap = newPixMap; |
|
|
|
pMap.setMask(bmpMask); |
|
|
|
pMap.setMask(bmpMask); |
|
|
|
|
|
|
|
|
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// from global
|
|
|
|
// from global
|
|
|
|
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove) |
|
|
|
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -380,9 +395,8 @@ void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needG |
|
|
|
|
|
|
|
|
|
|
|
void UBMagnifier::setGrabView(QWidget *view) |
|
|
|
void UBMagnifier::setGrabView(QWidget *view) |
|
|
|
{
|
|
|
|
{
|
|
|
|
if (timerUpdate != 0) |
|
|
|
|
|
|
|
killTimer(timerUpdate); |
|
|
|
|
|
|
|
gView = view; |
|
|
|
gView = view; |
|
|
|
timerUpdate = startTimer(200); |
|
|
|
mRefreshTimer.setInterval(40); |
|
|
|
|
|
|
|
mRefreshTimer.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|