Commit d1ae78c2 authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

SANKORE-92: Magnifier

parent 00f1f768
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -121,6 +121,12 @@
<file>images/toolbar/eraserTool.png</file>
<file>images/toolbar/lineTool.png</file>
<file>images/toolbar/tools.png</file>
<file>images/toolbar/largeMagnifierSize.png</file>
<file>images/toolbar/mediumMagnifierSize.png</file>
<file>images/toolbar/smallMagnifierSize.png</file>
<file>images/toolbar/largeMagnifierZoom.png</file>
<file>images/toolbar/mediumMagnifierZoom.png</file>
<file>images/toolbar/smallMagnifierZoom.png</file>
<file>images/stylusPalette/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/eraser.png</file>
......@@ -144,6 +150,8 @@
<file>images/stylusPalette/textOn.png</file>
<file>images/stylusPalette/captureArea.png</file>
<file>images/stylusPalette/captureAreaOn.png</file>
<file>images/stylusPalette/magnifier.png</file>
<file>images/stylusPalette/magnifierOn.png</file>
<file>images/backgroundPalette/background1.svg</file>
<file>images/backgroundPalette/background1On.svg</file>
<file>images/backgroundPalette/background2.svg</file>
......
......@@ -289,7 +289,9 @@ void UBBoardController::setupToolbar()
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineWidthChoice);
//-----------------------------------------------------------//
// Setup eraser width choice widget
QList<QAction *> eraserWidthActions;
eraserWidthActions.append(mMainWindow->actionEraserSmall);
eraserWidthActions.append(mMainWindow->actionEraserMedium);
......@@ -307,6 +309,45 @@ void UBBoardController::setupToolbar()
eraserWidthChoice->setCurrentIndex(settings->eraserWidthIndex());
mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds);
//-----------------------------------------------------------//
QList<QAction *> magnifierZoomActions;
magnifierZoomActions.append(mMainWindow->actionMagnifierZoomSmall);
magnifierZoomActions.append(mMainWindow->actionMagnifierZoomMedium);
magnifierZoomActions.append(mMainWindow->actionMagnifierZoomLarge);
UBToolbarButtonGroup *magnifierZoomChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, magnifierZoomActions);
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, magnifierZoomChoice);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), magnifierZoomChoice, SLOT(displayText(QVariant)));
connect(magnifierZoomChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setMagnifierZoomIndex(int)));
magnifierZoomChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
magnifierZoomChoice->setCurrentIndex(settings->magnifierZoomIndex());
QList<QAction *> magnifierSizeActions;
magnifierSizeActions.append(mMainWindow->actionMagnifierSizeSmall);
magnifierSizeActions.append(mMainWindow->actionMagnifierSizeMedium);
magnifierSizeActions.append(mMainWindow->actionMagnifierSizeLarge);
UBToolbarButtonGroup *magnifierSizeChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, magnifierSizeActions);
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, magnifierSizeChoice);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), magnifierSizeChoice, SLOT(displayText(QVariant)));
connect(magnifierSizeChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setMagnifierSizeIndex(int)));
magnifierSizeChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
magnifierSizeChoice->setCurrentIndex(settings->magnifierSizeIndex());
mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds);
//-----------------------------------------------------------//
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard);
......
......@@ -855,7 +855,10 @@ UBBoardView::setToolCursor (int tool)
controlViewport->setCursor (UBResources::resources ()->penCursor);
break;
case UBStylusTool::Eraser:
controlViewport->setCursor (UBResources::resources ()->eraserCursor);
controlViewport->setCursor (UBResources::resources ()->eraserCursor);
break;
case UBStylusTool::Magnifier:
controlViewport->setCursor (UBResources::resources ()->magnifierCursor);
break;
case UBStylusTool::Marker:
controlViewport->setCursor (UBResources::resources ()->markerCursor);
......
......@@ -44,6 +44,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(penToolSelected(bool)));
connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(eraserToolSelected(bool)));
connect(UBApplication::mainWindow->actionMagnifier, SIGNAL(triggered(bool)), this, SLOT(magnifierToolSelected(bool)));
connect(UBApplication::mainWindow->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(bool)));
......@@ -102,6 +103,8 @@ void UBDrawingController::setStylusTool(int tool)
UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true);
else if (mStylusTool == UBStylusTool::Magnifier)
UBApplication::mainWindow->actionMagnifier->setChecked(true);
else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector)
......@@ -263,6 +266,20 @@ void UBDrawingController::setEraserWidthIndex(int index)
}
void UBDrawingController::setMagnifierZoomIndex(int index)
{
setStylusTool(UBStylusTool::Magnifier);
UBSettings::settings()->setMagnifierZoomIndex(index);
}
void UBDrawingController::setMagnifierSizeIndex(int index)
{
setStylusTool(UBStylusTool::Magnifier);
UBSettings::settings()->setMagnifierSizeIndex(index);
}
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{
if (onDarkBackground)
......@@ -323,6 +340,11 @@ void UBDrawingController::eraserToolSelected(bool checked)
setStylusTool(UBStylusTool::Eraser);
}
void UBDrawingController::magnifierToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Magnifier);
}
void UBDrawingController::markerToolSelected(bool checked)
{
......
......@@ -57,6 +57,8 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index);
void setColorIndex(int index);
void setEraserWidthIndex(int index);
void setMagnifierZoomIndex(int index);
void setMagnifierSizeIndex(int index);
signals:
void stylusToolChanged(int tool);
......@@ -75,6 +77,7 @@ class UBDrawingController : public QObject
void penToolSelected(bool checked);
void eraserToolSelected(bool checked);
void magnifierToolSelected(bool checked);
void markerToolSelected(bool checked);
void selectorToolSelected(bool checked);
void handToolSelected(bool checked);
......
......@@ -26,6 +26,7 @@ struct UBStylusTool
{
Pen = 0,
Eraser,
Magnifier,
Marker,
Selector,
Hand,
......@@ -46,6 +47,23 @@ struct UBWidth
};
};
struct UBZoom
{
enum Enum
{
Small = 0, Medium, Large
};
};
struct UBSize
{
enum Enum
{
Small = 0, Medium, Large
};
};
struct UBItemLayerType
{
enum Enum
......@@ -80,7 +98,8 @@ struct UBGraphicsItemType
CompassItemType,
ProtractorItemType,
StrokeItemType,
TriangleItemType
TriangleItemType,
MagnifierItemType,
};
};
......
......@@ -556,55 +556,49 @@ QList<QColor> UBSettings::markerColors(bool onDarkBackground)
}
}
//----------------------------------------//
// eraser
int UBSettings::eraserWidthIndex()
{
return value("Board/EraserCircleWidthIndex", 1).toInt();
}
void UBSettings::setEraserWidthIndex(int index)
{
setValue("Board/EraserCircleWidthIndex", index);
}
qreal UBSettings::eraserFineWidth()
{
return value("Board/EraserFineWidth", 16).toDouble();
}
void UBSettings::setEraserFineWidth(qreal width)
{
setValue("Board/EraserFineWidth", width);
}
qreal UBSettings::eraserMediumWidth()
{
return value("Board/EraserMediumWidth", 64).toDouble();
}
void UBSettings::setEraserMediumWidth(qreal width)
{
setValue("Board/EraserMediumWidth", width);
}
qreal UBSettings::eraserStrongWidth()
{
return value("Board/EraserStrongWidth", 128).toDouble();
}
void UBSettings::setEraserStrongWidth(qreal width)
{
setValue("Board/EraserStrongWidth", width);
}
qreal UBSettings::currentEraserWidth()
{
qreal width = 0;
......@@ -630,6 +624,169 @@ qreal UBSettings::currentEraserWidth()
return width;
}
//----------------------------------------//
// magnifier
//-------------//
// zoom index
int UBSettings::magnifierZoomIndex()
{
return value("Board/MagnifierZoomIndex", 1).toInt();
}
void UBSettings::setMagnifierZoomIndex(int index)
{
setValue("Board/MagnifierZoomIndex", index);
}
//-------------//
// small zoom
qreal UBSettings::magnifierSmallZoom()
{
return value("Board/MagnifierSmallZoom", 2).toDouble();
}
void UBSettings::setMagnifierSmallZoom(qreal xZoom)
{
setValue("Board/MagnifierSmallZoom", xZoom);
}
//-------------//
// medium zoom
qreal UBSettings::magnifierMediumZoom()
{
return value("Board/MagnifierMediumZoom", 3).toDouble();
}
void UBSettings::setMagnifierMediumZoom(qreal xZoom)
{
setValue("Board/MagnifierMediumZoom", xZoom);
}
//-------------//
// large zoom
qreal UBSettings::magnifierLargeZoom()
{
return value("Board/MagnifierLargeZoom", 4).toDouble();
}
void UBSettings::setMagnifierLargeZoom(qreal xZoom)
{
setValue("Board/MagnifierLargeZoom", xZoom);
}
//-------------//
qreal UBSettings::currentMagnifierZoom()
{
qreal zoom = 0;
switch (magnifierZoomIndex())
{
case UBZoom::Small:
zoom = magnifierSmallZoom();
break;
case UBZoom::Medium:
zoom = magnifierMediumZoom();
break;
case UBZoom::Large:
zoom = magnifierLargeZoom();
break;
default:
Q_ASSERT(false);
//failsafe
zoom = magnifierSmallZoom();
break;
}
return zoom;
}
//-------------//
// size index
int UBSettings::magnifierSizeIndex()
{
return value("Board/MagnifierSizeIndex", 1).toInt();
}
void UBSettings::setMagnifierSizeIndex(int index)
{
setValue("Board/MagnifierSizeIndex", index);
}
//-------------//
// small zoom
qreal UBSettings::magnifierSmallSize()
{
return value("Board/MagnifierSmallSize", 10).toDouble();
}
void UBSettings::setMagnifierSmallSize(qreal xSize)
{
setValue("Board/MagnifierSmallSize", xSize);
}
//-------------//
// medium zoom
qreal UBSettings::magnifierMediumSize()
{
return value("Board/MagnifierMediumSize", 20).toDouble();
}
void UBSettings::setMagnifierMediumSize(qreal xSize)
{
setValue("Board/MagnifierMediumSize", xSize);
}
//-------------//
// large zoom
qreal UBSettings::magnifierLargeSize()
{
return value("Board/MagnifierLargeSize", 30).toDouble();
}
void UBSettings::setMagnifierLargeSize(qreal xSize)
{
setValue("Board/MagnifierLargeSize", xSize);
}
//-------------//
qreal UBSettings::currentMagnifierSize()
{
qreal size = 0;
switch (magnifierSizeIndex())
{
case UBSize::Small:
size = magnifierSmallSize();
break;
case UBSize::Medium:
size = magnifierMediumSize();
break;
case UBSize::Large:
size = magnifierLargeSize();
break;
default:
Q_ASSERT(false);
//failsafe
size = magnifierSmallSize();
break;
}
return size;
}
//----------------------------------------//
bool UBSettings::isDarkBackground()
{
......
......@@ -66,6 +66,19 @@ class UBSettings : public QObject
qreal eraserStrongWidth();
qreal currentEraserWidth();
// Magnifier related
int magnifierZoomIndex();
qreal magnifierSmallZoom();
qreal magnifierMediumZoom();
qreal magnifierLargeZoom();
qreal currentMagnifierZoom();
int magnifierSizeIndex();
qreal magnifierSmallSize();
qreal magnifierMediumSize();
qreal magnifierLargeSize();
qreal currentMagnifierSize();
// Background related
bool isDarkBackground();
bool isCrossedBackground();
......@@ -347,6 +360,17 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(qreal width);
void setMagnifierZoomIndex(int index);
void setMagnifierSmallZoom(qreal xZoom);
void setMagnifierMediumZoom(qreal xZoom);
void setMagnifierLargeZoom(qreal xZoom);
void setMagnifierSizeIndex(int index);
void setMagnifierSmallSize(qreal xSize);
void setMagnifierMediumSize(qreal xSize);
void setMagnifierLargeSize(qreal xSize);
void setStylusPaletteVisible(bool visible);
void setPenPressureSensitive(bool sensitive);
......
......@@ -29,6 +29,8 @@
#include "core/UBDisplayManager.h"
#include "core/UBPersistenceManager.h"
#include "gui/UBMagnifer.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCompass.h"
......@@ -88,6 +90,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCurrentStroke(0)
, mShouldUseOMP(true)
, mItemCount(0)
, magniferControlViewWidget(0)
, magniferDisplayViewWidget(0)
{
#ifdef __ppc__
......@@ -232,6 +236,15 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
drawPointer(scenePos);
accepted = true;
}
else if (currentTool == UBStylusTool::Magnifier)
{
CreateMagnifierQWidgets(QCursor::pos() /*scenePos*/);
magniferControlViewWidget->grabNMove(QCursor::pos(), true);
magniferDisplayViewWidget->grabNMove(scenePos, true);
magniferControlViewWidget->show();
magniferDisplayViewWidget->show();
accepted = true;
}
}
return accepted;
......@@ -305,6 +318,11 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{
drawPointer(position);
}
else if (currentTool == UBStylusTool::Magnifier)
{
magniferControlViewWidget->grabNMove(QCursor::pos(), false);
magniferDisplayViewWidget->grabNMove(position, false);
}
accepted = true;
}
......@@ -329,15 +347,25 @@ bool UBGraphicsScene::inputDeviceRelease()
bool accepted = false;
if (mPointer)
{
mPointer->hide();
accepted = true;
}
if (UBDrawingController::drawingController()->isDrawingTool())
UBDrawingController *dc = UBDrawingController::drawingController();
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool();
if (dc->isDrawingTool())
{
mCurrentStroke = 0;
}
else
if (currentTool == UBStylusTool::Magnifier)
{
DisposeMagnifierQWidgets();
//qDebug() << "deleted";
}
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
......@@ -395,6 +423,45 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint)
}
}
// call this function when user press mouse button in Magnifier mode
void UBGraphicsScene::CreateMagnifierQWidgets(const QPoint & globalPos)
{
UBApplication::app()->setOverrideCursor( QCursor( Qt::BlankCursor ) );
magniferControlViewWidget = new UBMagnifer((QWidget*)(UBApplication::boardController->controlContainer()));
magniferControlViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
magniferControlViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->controlContainer());
magniferControlViewWidget->setSize(UBSettings::settings()->currentMagnifierSize());
magniferControlViewWidget->setZoom(UBSettings::settings()->currentMagnifierZoom());
magniferDisplayViewWidget = new UBMagnifer((QWidget*)(UBApplication::boardController->displayView()));
magniferDisplayViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
magniferDisplayViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->displayView());
magniferDisplayViewWidget->setSize(UBSettings::settings()->currentMagnifierSize());
magniferDisplayViewWidget->setZoom(UBSettings::settings()->currentMagnifierZoom());
}
// call this function when user release mouse button in Magnifier mode
void UBGraphicsScene::DisposeMagnifierQWidgets()
{
if(magniferControlViewWidget)
{
magniferControlViewWidget->hide();
magniferControlViewWidget->setParent(0);
delete magniferControlViewWidget;
magniferControlViewWidget = NULL;
}
if(magniferDisplayViewWidget)
{
magniferDisplayViewWidget->hide();
magniferDisplayViewWidget->setParent(0);
delete magniferDisplayViewWidget;
magniferDisplayViewWidget = NULL;
}
UBApplication::app()->restoreOverrideCursor();
}
void UBGraphicsScene::moveTo(const QPointF &pPoint)
{
......
......@@ -44,6 +44,7 @@ class UBAbstractWidget;
class UBDocumentProxy;
class UBGraphicsCurtainItem;
class UBGraphicsStroke;
class UBMagnifer;
const double PI = 4.0 * atan(1.0);
......@@ -288,6 +289,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void drawEraser(const QPointF& pEndPoint);
void drawPointer(const QPointF& pEndPoint);
void CreateMagnifierQWidgets(const QPoint &point);
void DisposeMagnifierQWidgets();
virtual void keyReleaseEvent(QKeyEvent * keyEvent);
......@@ -347,6 +351,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QList<QGraphicsItem*> mFastAccessItems; // a local copy as QGraphicsScene::items() is very slow in Qt 4.6
//int mMesure1Ms, mMesure2Ms;
UBMagnifer *magniferControlViewWidget;
UBMagnifer *magniferDisplayViewWidget;
};
#endif /* UBGRAPHICSSCENE_H_ */
#include "UBMagnifer.h"
#include <QPainter>
#include <QPixmap>
#include <QDebug>
#include <QWidget>
#include <QGraphicsView>
#include <QTimerEvent>
#include <QBitmap>
#include <QPen>
UBMagnifer::UBMagnifer(QWidget *parent)
: QWidget(parent)
, gView(0)
, mView(0)
, sizePercentFromScene(20)
, inTimer(false)
, borderPen(Qt::darkGray)
{
borderPen.setWidth(2);
}
UBMagnifer::~UBMagnifer()
{
if (timerUpdate != 0)
{
killTimer(timerUpdate);
timerUpdate = 0;
}
}
void UBMagnifer::setSize(int percentFromScene)
{
if(gView == NULL) return;
// calculate object size
sizePercentFromScene = percentFromScene;
QSize sceneSize = gView->size();
int size = sizePercentFromScene * sceneSize.width() / 100;
setGeometry(0, 0, size, size);
// prepare transparent bit mask
QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawEllipse(QPoint(size/2, size/2), size/2, size/2);
bmpMask = QBitmap::fromImage(mask_img);
// prepare general image
pMap = QPixmap(width(), height());
pMap.fill(Qt::transparent);
pMap.setMask(bmpMask);
}
void UBMagnifer::setZoom(int z)
{
zoom = z;
zWidth = size().width() / zoom;
zWidthHalf = zWidth / 2;
zHeight = size().height() / zoom;
zHeightHalf = zHeight / 2;
}
void UBMagnifer::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.drawPixmap(0, 0, pMap);
// in future replace to image border
QPen pen(Qt::darkGray);
pen.setWidth(2);
p.setPen(borderPen);
p.drawEllipse(QPoint( size().width() / 2, size().height() / 2), size().width() / 2, size().height() / 2);
}
void UBMagnifer::timerEvent(QTimerEvent *e)
{
if(inTimer) return;
if (e->timerId() == timerUpdate)
{
inTimer = true;
if(!(updPoint.isNull())) grabPoint(updPoint);
if(!(updPointF.isNull()))grabPoint(updPointF);
inTimer = false;
}
}
void UBMagnifer::grabPoint(const QPoint &point)
{
QPointF itemPos = gView->mapFromGlobal(point);
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
update();
}
void UBMagnifer::grabPoint(const QPointF &point)
{
QPoint itemPos = gView->mapFromScene(point);
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
update();
}
// from global
void UBMagnifer::grabNMove(const QPoint &point, bool needGrab = true)
{
updPoint = point;
if(needGrab)
grabPoint(point);
QPoint itemPos = mView->mapFromGlobal(point);
move(itemPos.x() - width()/2, itemPos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
// from scene
void UBMagnifer::grabNMove(const QPointF &point, bool needGrab = true)
{
updPointF = point;
if(needGrab)
grabPoint(point);
QPoint itemPos = mView->mapFromScene(point);
move(itemPos.x() - width()/2, itemPos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
void UBMagnifer::setGrabView(QGraphicsView *view)
{
if (timerUpdate != 0)
killTimer(timerUpdate);
gView = view;
timerUpdate = startTimer(200);
}
#ifndef UBMAGNIFER_H
#define UBMAGNIFER_H
#include <QWidget>
#include <QBitmap>
#include <QPen>
class QPixmap;
class QBitmap;
class QPen;
class QGraphicsView;
class UBMagnifer : public QWidget
{
Q_OBJECT
public:
UBMagnifer(QWidget *parent = 0);
~UBMagnifer();
void setSize(int percentFromScene);
void setZoom(int z);
void setGrabView(QGraphicsView *view);
void setMoveView(QGraphicsView *view) {mView = view;}
void grabPoint(const QPoint &point);
void grabPoint(const QPointF &point);
void grabNMove(const QPoint &point, bool needGrab);
void grabNMove(const QPointF &point, bool needGrab);
protected:
void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
int sizePercentFromScene;
private:
int zoom;
int zWidth;
int zHeight;
int zWidthHalf;
int zHeightHalf;
bool inTimer;
int timerUpdate;
QPoint updPoint;
QPointF updPointF;
QPixmap pMap;
QBitmap bmpMask;
QPen borderPen;
QGraphicsView *gView;
QGraphicsView *mView;
};
#endif // UBMAGNIFER_H
......@@ -49,15 +49,16 @@ UBResources* UBResources::resources()
void UBResources::init()
{
// Cursors
penCursor = QCursor(Qt::CrossCursor);
eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21);
markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30);
pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1);
handCursor = QCursor(Qt::OpenHandCursor);
zoomInCursor = QCursor(QPixmap(":/images/cursors/zoomIn.png"), 9, 9);
zoomOutCursor = QCursor(QPixmap(":/images/cursors/zoomOut.png"), 9, 9);
arrowCursor = QCursor(Qt::ArrowCursor);
textCursor = QCursor(Qt::ArrowCursor);
rotateCursor = QCursor(QPixmap(":/images/cursors/rotate.png"), 16, 16);
penCursor = QCursor(Qt::CrossCursor);
eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21);
magnifierCursor = QCursor(QPixmap(":/images/cursors/zoomIn.png"), 9, 9);
markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30);
pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1);
handCursor = QCursor(Qt::OpenHandCursor);
zoomInCursor = QCursor(QPixmap(":/images/cursors/zoomIn.png"), 9, 9);
zoomOutCursor = QCursor(QPixmap(":/images/cursors/zoomOut.png"), 9, 9);
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);
}
......@@ -37,6 +37,7 @@ class UBResources : public QObject
QCursor penCursor;
QCursor eraserCursor;
QCursor magnifierCursor;
QCursor markerCursor;
QCursor pointerCursor;
QCursor handCursor;
......
......@@ -37,6 +37,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMagnifier;
actions << UBApplication::mainWindow->actionMarker;
actions << UBApplication::mainWindow->actionSelector;
......
......@@ -38,7 +38,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibActionBar.h \
src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \
src/gui/UBUpdateDlg.h
src/gui/UBUpdateDlg.h \
src/gui/UBMagnifer.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
......@@ -79,7 +80,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibActionBar.cpp \
src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \
src/gui/UBUpdateDlg.cpp
src/gui/UBUpdateDlg.cpp \
src/gui/UBMagnifer.cpp
win32 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment