SANKORE-92: Magnifier

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 00f1f768d3
commit d1ae78c2d2
  1. 109
      resources/forms/mainWindow.ui
  2. BIN
      resources/images/stylusPalette/magnifier.png
  3. BIN
      resources/images/stylusPalette/magnifierOn.png
  4. BIN
      resources/images/toolbar/largeMagnifierSize.png
  5. BIN
      resources/images/toolbar/largeMagnifierZoom.png
  6. BIN
      resources/images/toolbar/mediumMagnifierSize.png
  7. BIN
      resources/images/toolbar/mediumMagnifierZoom.png
  8. BIN
      resources/images/toolbar/smallMagnifierSize.png
  9. BIN
      resources/images/toolbar/smallMagnifierZoom.png
  10. 8
      resources/sankore.qrc
  11. 41
      src/board/UBBoardController.cpp
  12. 3
      src/board/UBBoardView.cpp
  13. 22
      src/board/UBDrawingController.cpp
  14. 3
      src/board/UBDrawingController.h
  15. 21
      src/core/UB.h
  16. 173
      src/core/UBSettings.cpp
  17. 24
      src/core/UBSettings.h
  18. 69
      src/domain/UBGraphicsScene.cpp
  19. 7
      src/domain/UBGraphicsScene.h
  20. 155
      src/gui/UBMagnifer.cpp
  21. 60
      src/gui/UBMagnifer.h
  22. 1
      src/gui/UBResources.cpp
  23. 1
      src/gui/UBResources.h
  24. 1
      src/gui/UBStylusPalette.cpp
  25. 6
      src/gui/gui.pri

@ -1638,6 +1638,115 @@
<string>Ctrl+H</string> <string>Ctrl+H</string>
</property> </property>
</action> </action>
<action name="actionMagnifier">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/stylusPalette/magnifier.png</normaloff>
<normalon>:/images/stylusPalette/magnifierOn.png</normalon>:/images/stylusPalette/magnifier.png</iconset>
</property>
<property name="text">
<string>Magnifier</string>
</property>
<property name="toolTip">
<string>Magnifier</string>
</property>
</action>
<action name="actionMagnifierZoomSmall">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/smallMagnifierZoom.png</normaloff>:/images/toolbar/smallMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x2 Zoom</string>
</property>
</action>
<action name="actionMagnifierZoomMedium">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/mediumMagnifierZoom.png</normaloff>:/images/toolbar/mediumMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x3 Zoom</string>
</property>
</action>
<action name="actionMagnifierZoomLarge">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/largeMagnifierZoom.png</normaloff>:/images/toolbar/largeMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x4 Zoom</string>
</property>
</action>
<action name="actionMagnifierSizeSmall">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/smallMagnifierSize.png</normaloff>:/images/toolbar/smallMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>10% from scene size</string>
</property>
</action>
<action name="actionMagnifierSizeMedium">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/mediumMagnifierSize.png</normaloff>:/images/toolbar/mediumMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>20% from scene size</string>
</property>
</action>
<action name="actionMagnifierSizeLarge">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/largeMagnifierSize.png</normaloff>:/images/toolbar/largeMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>30% from scene size</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../sankore.qrc"/> <include location="../sankore.qrc"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

@ -121,6 +121,12 @@
<file>images/toolbar/eraserTool.png</file> <file>images/toolbar/eraserTool.png</file>
<file>images/toolbar/lineTool.png</file> <file>images/toolbar/lineTool.png</file>
<file>images/toolbar/tools.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/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file> <file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/eraser.png</file> <file>images/stylusPalette/eraser.png</file>
@ -144,6 +150,8 @@
<file>images/stylusPalette/textOn.png</file> <file>images/stylusPalette/textOn.png</file>
<file>images/stylusPalette/captureArea.png</file> <file>images/stylusPalette/captureArea.png</file>
<file>images/stylusPalette/captureAreaOn.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/background1.svg</file>
<file>images/backgroundPalette/background1On.svg</file> <file>images/backgroundPalette/background1On.svg</file>
<file>images/backgroundPalette/background2.svg</file> <file>images/backgroundPalette/background2.svg</file>

@ -289,7 +289,9 @@ void UBBoardController::setupToolbar()
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineWidthChoice); mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineWidthChoice);
//-----------------------------------------------------------//
// Setup eraser width choice widget // Setup eraser width choice widget
QList<QAction *> eraserWidthActions; QList<QAction *> eraserWidthActions;
eraserWidthActions.append(mMainWindow->actionEraserSmall); eraserWidthActions.append(mMainWindow->actionEraserSmall);
eraserWidthActions.append(mMainWindow->actionEraserMedium); eraserWidthActions.append(mMainWindow->actionEraserMedium);
@ -307,6 +309,45 @@ void UBBoardController::setupToolbar()
eraserWidthChoice->setCurrentIndex(settings->eraserWidthIndex()); eraserWidthChoice->setCurrentIndex(settings->eraserWidthIndex());
mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds); 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->boardToolBar, mMainWindow->actionBoard);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard); UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard);

@ -857,6 +857,9 @@ UBBoardView::setToolCursor (int tool)
case UBStylusTool::Eraser: case UBStylusTool::Eraser:
controlViewport->setCursor (UBResources::resources ()->eraserCursor); controlViewport->setCursor (UBResources::resources ()->eraserCursor);
break; break;
case UBStylusTool::Magnifier:
controlViewport->setCursor (UBResources::resources ()->magnifierCursor);
break;
case UBStylusTool::Marker: case UBStylusTool::Marker:
controlViewport->setCursor (UBResources::resources ()->markerCursor); controlViewport->setCursor (UBResources::resources ()->markerCursor);
break; break;

@ -44,6 +44,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(penToolSelected(bool))); 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->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->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool))); connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(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); UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser) else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true); UBApplication::mainWindow->actionEraser->setChecked(true);
else if (mStylusTool == UBStylusTool::Magnifier)
UBApplication::mainWindow->actionMagnifier->setChecked(true);
else if (mStylusTool == UBStylusTool::Marker) else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector) 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) void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{ {
if (onDarkBackground) if (onDarkBackground)
@ -323,6 +340,11 @@ void UBDrawingController::eraserToolSelected(bool checked)
setStylusTool(UBStylusTool::Eraser); setStylusTool(UBStylusTool::Eraser);
} }
void UBDrawingController::magnifierToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Magnifier);
}
void UBDrawingController::markerToolSelected(bool checked) void UBDrawingController::markerToolSelected(bool checked)
{ {

@ -57,6 +57,8 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index); void setLineWidthIndex(int index);
void setColorIndex(int index); void setColorIndex(int index);
void setEraserWidthIndex(int index); void setEraserWidthIndex(int index);
void setMagnifierZoomIndex(int index);
void setMagnifierSizeIndex(int index);
signals: signals:
void stylusToolChanged(int tool); void stylusToolChanged(int tool);
@ -75,6 +77,7 @@ class UBDrawingController : public QObject
void penToolSelected(bool checked); void penToolSelected(bool checked);
void eraserToolSelected(bool checked); void eraserToolSelected(bool checked);
void magnifierToolSelected(bool checked);
void markerToolSelected(bool checked); void markerToolSelected(bool checked);
void selectorToolSelected(bool checked); void selectorToolSelected(bool checked);
void handToolSelected(bool checked); void handToolSelected(bool checked);

@ -26,6 +26,7 @@ struct UBStylusTool
{ {
Pen = 0, Pen = 0,
Eraser, Eraser,
Magnifier,
Marker, Marker,
Selector, Selector,
Hand, 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 struct UBItemLayerType
{ {
enum Enum enum Enum
@ -80,7 +98,8 @@ struct UBGraphicsItemType
CompassItemType, CompassItemType,
ProtractorItemType, ProtractorItemType,
StrokeItemType, StrokeItemType,
TriangleItemType TriangleItemType,
MagnifierItemType,
}; };
}; };

@ -556,55 +556,49 @@ QList<QColor> UBSettings::markerColors(bool onDarkBackground)
} }
} }
//----------------------------------------//
// eraser
int UBSettings::eraserWidthIndex() int UBSettings::eraserWidthIndex()
{ {
return value("Board/EraserCircleWidthIndex", 1).toInt(); return value("Board/EraserCircleWidthIndex", 1).toInt();
} }
void UBSettings::setEraserWidthIndex(int index) void UBSettings::setEraserWidthIndex(int index)
{ {
setValue("Board/EraserCircleWidthIndex", index); setValue("Board/EraserCircleWidthIndex", index);
} }
qreal UBSettings::eraserFineWidth() qreal UBSettings::eraserFineWidth()
{ {
return value("Board/EraserFineWidth", 16).toDouble(); return value("Board/EraserFineWidth", 16).toDouble();
} }
void UBSettings::setEraserFineWidth(qreal width) void UBSettings::setEraserFineWidth(qreal width)
{ {
setValue("Board/EraserFineWidth", width); setValue("Board/EraserFineWidth", width);
} }
qreal UBSettings::eraserMediumWidth() qreal UBSettings::eraserMediumWidth()
{ {
return value("Board/EraserMediumWidth", 64).toDouble(); return value("Board/EraserMediumWidth", 64).toDouble();
} }
void UBSettings::setEraserMediumWidth(qreal width) void UBSettings::setEraserMediumWidth(qreal width)
{ {
setValue("Board/EraserMediumWidth", width); setValue("Board/EraserMediumWidth", width);
} }
qreal UBSettings::eraserStrongWidth() qreal UBSettings::eraserStrongWidth()
{ {
return value("Board/EraserStrongWidth", 128).toDouble(); return value("Board/EraserStrongWidth", 128).toDouble();
} }
void UBSettings::setEraserStrongWidth(qreal width) void UBSettings::setEraserStrongWidth(qreal width)
{ {
setValue("Board/EraserStrongWidth", width); setValue("Board/EraserStrongWidth", width);
} }
qreal UBSettings::currentEraserWidth() qreal UBSettings::currentEraserWidth()
{ {
qreal width = 0; qreal width = 0;
@ -630,6 +624,169 @@ qreal UBSettings::currentEraserWidth()
return width; 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() bool UBSettings::isDarkBackground()
{ {

@ -66,6 +66,19 @@ class UBSettings : public QObject
qreal eraserStrongWidth(); qreal eraserStrongWidth();
qreal currentEraserWidth(); 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 // Background related
bool isDarkBackground(); bool isDarkBackground();
bool isCrossedBackground(); bool isCrossedBackground();
@ -347,6 +360,17 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width); void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(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 setStylusPaletteVisible(bool visible);
void setPenPressureSensitive(bool sensitive); void setPenPressureSensitive(bool sensitive);

@ -29,6 +29,8 @@
#include "core/UBDisplayManager.h" #include "core/UBDisplayManager.h"
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "gui/UBMagnifer.h"
#include "tools/UBGraphicsRuler.h" #include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsProtractor.h" #include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
@ -88,6 +90,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCurrentStroke(0) , mCurrentStroke(0)
, mShouldUseOMP(true) , mShouldUseOMP(true)
, mItemCount(0) , mItemCount(0)
, magniferControlViewWidget(0)
, magniferDisplayViewWidget(0)
{ {
#ifdef __ppc__ #ifdef __ppc__
@ -232,6 +236,15 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
drawPointer(scenePos); drawPointer(scenePos);
accepted = true; 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; return accepted;
@ -305,6 +318,11 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{ {
drawPointer(position); drawPointer(position);
} }
else if (currentTool == UBStylusTool::Magnifier)
{
magniferControlViewWidget->grabNMove(QCursor::pos(), false);
magniferDisplayViewWidget->grabNMove(position, false);
}
accepted = true; accepted = true;
} }
@ -329,16 +347,26 @@ bool UBGraphicsScene::inputDeviceRelease()
bool accepted = false; bool accepted = false;
if (mPointer) if (mPointer)
{ {
mPointer->hide(); mPointer->hide();
accepted = true; accepted = true;
} }
if (UBDrawingController::drawingController()->isDrawingTool()) UBDrawingController *dc = UBDrawingController::drawingController();
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool();
if (dc->isDrawingTool())
{ {
mCurrentStroke = 0; mCurrentStroke = 0;
} }
else
if (currentTool == UBStylusTool::Magnifier)
{
DisposeMagnifierQWidgets();
//qDebug() << "deleted";
}
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) 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) void UBGraphicsScene::moveTo(const QPointF &pPoint)
{ {

@ -44,6 +44,7 @@ class UBAbstractWidget;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsCurtainItem; class UBGraphicsCurtainItem;
class UBGraphicsStroke; class UBGraphicsStroke;
class UBMagnifer;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
@ -288,6 +289,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void drawEraser(const QPointF& pEndPoint); void drawEraser(const QPointF& pEndPoint);
void drawPointer(const QPointF& pEndPoint); void drawPointer(const QPointF& pEndPoint);
void CreateMagnifierQWidgets(const QPoint &point);
void DisposeMagnifierQWidgets();
virtual void keyReleaseEvent(QKeyEvent * keyEvent); 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 QList<QGraphicsItem*> mFastAccessItems; // a local copy as QGraphicsScene::items() is very slow in Qt 4.6
//int mMesure1Ms, mMesure2Ms; //int mMesure1Ms, mMesure2Ms;
UBMagnifer *magniferControlViewWidget;
UBMagnifer *magniferDisplayViewWidget;
}; };
#endif /* UBGRAPHICSSCENE_H_ */ #endif /* UBGRAPHICSSCENE_H_ */

@ -0,0 +1,155 @@
#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);
}

@ -0,0 +1,60 @@
#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

@ -51,6 +51,7 @@ void UBResources::init()
// Cursors // Cursors
penCursor = QCursor(Qt::CrossCursor); penCursor = QCursor(Qt::CrossCursor);
eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21); 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); markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30);
pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1); pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1);
handCursor = QCursor(Qt::OpenHandCursor); handCursor = QCursor(Qt::OpenHandCursor);

@ -37,6 +37,7 @@ class UBResources : public QObject
QCursor penCursor; QCursor penCursor;
QCursor eraserCursor; QCursor eraserCursor;
QCursor magnifierCursor;
QCursor markerCursor; QCursor markerCursor;
QCursor pointerCursor; QCursor pointerCursor;
QCursor handCursor; QCursor handCursor;

@ -37,6 +37,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMagnifier;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;

@ -38,7 +38,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibActionBar.h \ src/gui/UBLibActionBar.h \
src/gui/UBLibraryWidget.h \ src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \ src/gui/UBLibPathViewer.h \
src/gui/UBUpdateDlg.h src/gui/UBUpdateDlg.h \
src/gui/UBMagnifer.h
SOURCES += src/gui/UBThumbnailView.cpp \ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \ src/gui/UBFloatingPalette.cpp \
@ -79,7 +80,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibActionBar.cpp \ src/gui/UBLibActionBar.cpp \
src/gui/UBLibraryWidget.cpp \ src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \ src/gui/UBLibPathViewer.cpp \
src/gui/UBUpdateDlg.cpp src/gui/UBUpdateDlg.cpp \
src/gui/UBMagnifer.cpp
win32 { win32 {

Loading…
Cancel
Save