Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 77ad8045a5
  1. 3
      resources/images/close.svg
  2. BIN
      resources/images/cursors/magnifier.png
  3. 9
      resources/images/decrease.svg
  4. 9
      resources/images/increase.svg
  5. BIN
      resources/images/stylusPalette/magnifier.png
  6. BIN
      resources/images/stylusPalette/magnifierOn.png
  7. BIN
      resources/images/toolPalette/magnifierTool.png
  8. BIN
      resources/images/toolbar/largeMagnifierSize.png
  9. BIN
      resources/images/toolbar/largeMagnifierZoom.png
  10. BIN
      resources/images/toolbar/mediumMagnifierSize.png
  11. BIN
      resources/images/toolbar/mediumMagnifierZoom.png
  12. BIN
      resources/images/toolbar/smallMagnifierSize.png
  13. BIN
      resources/images/toolbar/smallMagnifierZoom.png
  14. 12
      resources/sankore.qrc
  15. 48
      src/board/UBBoardController.cpp
  16. 5
      src/board/UBBoardController.h
  17. 3
      src/board/UBBoardView.cpp
  18. 24
      src/board/UBDrawingController.cpp
  19. 3
      src/board/UBDrawingController.h
  20. 3
      src/core/UB.h
  21. 164
      src/core/UBSettings.cpp
  22. 26
      src/core/UBSettings.h
  23. 175
      src/domain/UBGraphicsScene.cpp
  24. 21
      src/domain/UBGraphicsScene.h
  25. 355
      src/gui/UBMagnifer.cpp
  26. 82
      src/gui/UBMagnifer.h
  27. 1
      src/gui/UBStylusPalette.cpp
  28. 13
      src/tools/UBToolsManager.cpp
  29. 2
      src/tools/UBToolsManager.h

@ -5,6 +5,5 @@
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve"> width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/> <circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/> <circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20.071,17.242 15.828,13 20.071,8.757 17.242,5.929 13,10.171 8.757,5.929 5.929,8.757 <polygon style="fill:#FFFFFF;" points="20,17 16,13 20,9 17,6 13,10 9,6 6,9 10,13 6,17 9,20 13,16 17,20 "/>
10.171,13 5.929,17.242 8.757,20.071 13,15.828 17.242,20.071 "/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 796 B

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20,15 20,11 6,11 6,15 20,15"/>
</svg>

After

Width:  |  Height:  |  Size: 676 B

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20,15 20,11 15,11 15,6 11,6 11,11 6,11 6,15 11,15 11,20 15,20 15,15 20,15"/>
</svg>

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

@ -3,6 +3,8 @@
<file>images/uniboard.png</file> <file>images/uniboard.png</file>
<file>images/bigUniboard.png</file> <file>images/bigUniboard.png</file>
<file>images/close.svg</file> <file>images/close.svg</file>
<file>images/increase.svg</file>
<file>images/decrease.svg</file>
<file>images/resize.svg</file> <file>images/resize.svg</file>
<file>images/play.svg</file> <file>images/play.svg</file>
<file>images/pause.svg</file> <file>images/pause.svg</file>
@ -121,12 +123,6 @@
<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>
@ -150,8 +146,6 @@
<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>
@ -167,6 +161,7 @@
<file>images/toolPalette/protractorTool.png</file> <file>images/toolPalette/protractorTool.png</file>
<file>images/toolPalette/compassTool.png</file> <file>images/toolPalette/compassTool.png</file>
<file>images/toolPalette/maskTool.png</file> <file>images/toolPalette/maskTool.png</file>
<file>images/toolPalette/magnifierTool.png</file>
<file>images/extraPalette/blackout.png</file> <file>images/extraPalette/blackout.png</file>
<file>images/extraPalette/keyboard.png</file> <file>images/extraPalette/keyboard.png</file>
<file>images/extraPalette/trapFlash.png</file> <file>images/extraPalette/trapFlash.png</file>
@ -185,7 +180,6 @@
<file>images/cursors/resize.png</file> <file>images/cursors/resize.png</file>
<file>images/cursors/drawCompass.png</file> <file>images/cursors/drawCompass.png</file>
<file>images/cursors/drawRulerLine.png</file> <file>images/cursors/drawRulerLine.png</file>
<file>images/cursors/magnifier.png</file>
<file>images/print/onepage.png</file> <file>images/print/onepage.png</file>
<file>images/print/thumbnails.png</file> <file>images/print/thumbnails.png</file>
<file>images/print/twopages.png</file> <file>images/print/twopages.png</file>

@ -36,6 +36,7 @@
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBToolWidget.h" #include "gui/UBToolWidget.h"
#include "gui/UBKeyboardPalette.h" #include "gui/UBKeyboardPalette.h"
#include "gui/UBMagnifer.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsItemUndoCommand.h" #include "domain/UBGraphicsItemUndoCommand.h"
@ -308,42 +309,6 @@ void UBBoardController::setupToolbar()
//-----------------------------------------------------------// //-----------------------------------------------------------//
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);
@ -1052,9 +1017,14 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
mActiveScene->addTriangle(pPos); mActiveScene->addTriangle(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
else if(sourceUrl.toString() == UBToolsManager::manager()->cache.id) else if (sourceUrl.toString() == UBToolsManager::manager()->magnifier.id)
{ {
mActiveScene->addCache(); UBMagnifierParams params;
params.x = controlContainer()->geometry().width() / 2;
params.y = controlContainer()->geometry().height() / 2;
params.zoom = 2;
params.sizePercentFromScene = 20;
mActiveScene->addMagnifier(params);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
else if (sourceUrl.toString() == UBToolsManager::manager()->mask.id) else if (sourceUrl.toString() == UBToolsManager::manager()->mask.id)
@ -1175,7 +1145,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
} }
// Notify the navigator palette that the document has changed // Notify the navigator palette that the document has changed
mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy); mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy);
if (sceneChange) if (sceneChange)
emit activeSceneChanged(); emit activeSceneChanged();

@ -80,6 +80,11 @@ class UBBoardController : public QObject
return mDisplayView; return mDisplayView;
} }
UBGraphicsScene* activeScene()
{
return mActiveScene;
}
void setPenColorOnDarkBackground(const QColor& pColor) void setPenColorOnDarkBackground(const QColor& pColor)
{ {
if (mPenColorOnDarkBackground == pColor) if (mPenColorOnDarkBackground == pColor)

@ -857,9 +857,6 @@ 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,7 +44,6 @@ 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)));
@ -103,8 +102,6 @@ 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)
@ -265,21 +262,6 @@ void UBDrawingController::setEraserWidthIndex(int index)
UBSettings::settings()->setEraserWidthIndex(index); UBSettings::settings()->setEraserWidthIndex(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)
@ -340,12 +322,6 @@ 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)
{ {
if (checked) if (checked)

@ -57,8 +57,6 @@ 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);
@ -77,7 +75,6 @@ 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,8 +26,7 @@ struct UBStylusTool
{ {
Pen = 0, Pen = 0,
Eraser, Eraser,
Magnifier, Marker,
Marker,
Selector, Selector,
Hand, Hand,
ZoomIn, ZoomIn,

@ -624,170 +624,6 @@ 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()
{ {
return value("Board/DarkBackground", 0).toBool(); return value("Board/DarkBackground", 0).toBool();

@ -66,19 +66,6 @@ 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();
@ -360,18 +347,7 @@ 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 setStylusPaletteVisible(bool visible);
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); void setPenPressureSensitive(bool sensitive);
void setMarkerPressureSensitive(bool sensitive); void setMarkerPressureSensitive(bool sensitive);

@ -36,7 +36,6 @@
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsTriangle.h" #include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsCurtainItem.h" #include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCache.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -71,7 +70,6 @@ qreal UBGraphicsScene::toolOffsetProtractor = 100;
qreal UBGraphicsScene::toolOffsetTriangle = 100; qreal UBGraphicsScene::toolOffsetTriangle = 100;
qreal UBGraphicsScene::toolOffsetCompass = 100; qreal UBGraphicsScene::toolOffsetCompass = 100;
qreal UBGraphicsScene::toolOffsetEraser = 200; qreal UBGraphicsScene::toolOffsetEraser = 200;
qreal UBGraphicsScene::toolOffsetCache = 1000;
qreal UBGraphicsScene::toolOffsetCurtain = 1000; qreal UBGraphicsScene::toolOffsetCurtain = 1000;
qreal UBGraphicsScene::toolOffsetPointer = 1100; qreal UBGraphicsScene::toolOffsetPointer = 1100;
@ -138,13 +136,13 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
mHasCache = false;
} }
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
// NOOP // NOOP
DisposeMagnifierQWidgets();
} }
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
@ -238,15 +236,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
drawPointer(scenePos); drawPointer(scenePos);
accepted = true; accepted = true;
} }
else if (currentTool == UBStylusTool::Magnifier)
{
CreateMagnifierQWidgets();
magniferControlViewWidget->grabNMove(QCursor::pos(), true);
magniferDisplayViewWidget->grabNMove(scenePos, true);
magniferControlViewWidget->show();
magniferDisplayViewWidget->show();
accepted = true;
}
} }
return accepted; return accepted;
@ -320,11 +309,6 @@ 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;
} }
@ -363,13 +347,7 @@ bool UBGraphicsScene::inputDeviceRelease()
{ {
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)
{ {
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
@ -425,24 +403,6 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint)
} }
} }
// call this function when user press mouse button in Magnifier mode
void UBGraphicsScene::CreateMagnifierQWidgets()
{
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 // call this function when user release mouse button in Magnifier mode
void UBGraphicsScene::DisposeMagnifierQWidgets() void UBGraphicsScene::DisposeMagnifierQWidgets()
{ {
@ -1536,6 +1496,119 @@ void UBGraphicsScene::addTriangle(QPointF center)
setModified(true); setModified(true);
} }
void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
{
// can have only one magnifier at one time
if(magniferControlViewWidget) return;
QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer());
QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView();
QGraphicsView *dView = (QGraphicsView*)UBApplication::boardController->displayView();
QPoint ccZeroPoint = cContainer->mapToGlobal(QPoint(0,0));
QPoint cvZeroPoint = cView->mapToGlobal(QPoint(0,0));
QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0));
int cvW = cView->width();
int dvW = dView->width();
qreal wCoeff = (qreal)dvW / (qreal)cvW;
int cvH = cView->height();
int dvH = dView->height();
qreal hCoeff = (qreal)dvH / (qreal)cvH;
QPoint ccPoint(params.x,params.y);
QPoint globalPoint = cContainer->mapToGlobal(ccPoint);
QPoint cvPoint = cView->mapFromGlobal(globalPoint);
QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y());
magniferControlViewWidget = new UBMagnifier((QWidget*)(UBApplication::boardController->controlContainer()), true);
magniferControlViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
magniferControlViewWidget->setMoveView((QWidget*)(UBApplication::boardController->controlContainer()));
magniferControlViewWidget->setSize(params.sizePercentFromScene);
magniferControlViewWidget->setZoom(params.zoom);
magniferDisplayViewWidget = new UBMagnifier((QWidget*)(UBApplication::boardController->displayView()), false);
magniferDisplayViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
magniferDisplayViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->displayView());
magniferDisplayViewWidget->setSize(params.sizePercentFromScene);
magniferDisplayViewWidget->setZoom(params.zoom);
magniferControlViewWidget->grabNMove(globalPoint, globalPoint, true);
magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, true);
magniferControlViewWidget->show();
magniferDisplayViewWidget->show();
connect(magniferControlViewWidget, SIGNAL(magnifierMoved_Signal(QPoint)), this, SLOT(moveMagnifier(QPoint)));
connect(magniferControlViewWidget, SIGNAL(magnifierClose_Signal()), this, SLOT(closeMagnifier()));
connect(magniferControlViewWidget, SIGNAL(magnifierZoomIn_Signal()), this, SLOT(zoomInMagnifier()));
connect(magniferControlViewWidget, SIGNAL(magnifierZoomOut_Signal()), this, SLOT(zoomOutMagnifier()));
connect(magniferControlViewWidget, SIGNAL(magnifierResized_Signal(qreal)), this, SLOT(resizedMagnifier(qreal)));
setModified(true);
}
void UBGraphicsScene::moveMagnifier(QPoint newPos)
{
QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer());
QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView();
QGraphicsView *dView = (QGraphicsView*)UBApplication::boardController->displayView();
QPoint ccZeroPoint = cContainer->mapToGlobal(QPoint(0,0));
QPoint cvZeroPoint = cView->mapToGlobal(QPoint(0,0));
QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0));
int cvW = cView->width();
int dvW = dView->width();
qreal wCoeff = (qreal)dvW / (qreal)cvW;
int cvH = cView->height();
int dvH = dView->height();
qreal hCoeff = (qreal)dvH / (qreal)cvH;
QPoint globalPoint = cContainer->mapToGlobal(newPos);
QPoint cvPoint = cView->mapFromGlobal(globalPoint);
QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y());
magniferControlViewWidget->grabNMove(globalPoint, globalPoint, false, false);
magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, false, true);
setModified(true);
}
void UBGraphicsScene::closeMagnifier()
{
DisposeMagnifierQWidgets();
}
void UBGraphicsScene::zoomInMagnifier()
{
if(magniferControlViewWidget->params.zoom < 8)
{
magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom + 0.5);
magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom + 0.5);
}
}
void UBGraphicsScene::zoomOutMagnifier()
{
if(magniferControlViewWidget->params.zoom > 1)
{
magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5);
magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5);
}
}
void UBGraphicsScene::resizedMagnifier(qreal newPercent)
{
if(newPercent > 18 && newPercent < 50)
{
magniferControlViewWidget->setSize(newPercent);
magniferControlViewWidget->grabPoint();
magniferDisplayViewWidget->setSize(newPercent);
magniferDisplayViewWidget->grabPoint();
}
}
void UBGraphicsScene::addCompass(QPointF center) void UBGraphicsScene::addCompass(QPointF center)
{ {
@ -1553,24 +1626,6 @@ void UBGraphicsScene::addCompass(QPointF center)
setModified(true); setModified(true);
} }
void UBGraphicsScene::addCache()
{
UBGraphicsCache* cache = new UBGraphicsCache();
mTools << cache;
QGraphicsView* view;
if(UBApplication::applicationController->displayManager()->hasDisplay())
{
view = (QGraphicsView*)(UBApplication::boardController->displayView());
}
else
{
view = (QGraphicsView*)(UBApplication::boardController->controlView());
}
addItem(cache);
cache->setVisible(true);
cache->setSelected(true);
}
void UBGraphicsScene::addMask() void UBGraphicsScene::addMask()
{ {

@ -44,8 +44,8 @@ class UBAbstractWidget;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsCurtainItem; class UBGraphicsCurtainItem;
class UBGraphicsStroke; class UBGraphicsStroke;
class UBGraphicsCache; class UBMagnifierParams;
class UBMagnifer; class UBMagnifier;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
@ -166,10 +166,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
qreal getNextObjectZIndex(); qreal getNextObjectZIndex();
void addRuler(QPointF center); void addRuler(QPointF center);
void addTriangle(QPointF center);
void addProtractor(QPointF center); void addProtractor(QPointF center);
void addCompass(QPointF center); void addCompass(QPointF center);
void addCache(); void addTriangle(QPointF center);
void addMagnifier(UBMagnifierParams params);
void addMask(); void addMask();
@ -247,7 +247,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
static qreal toolOffsetCompass; static qreal toolOffsetCompass;
static qreal toolOffsetCurtain; static qreal toolOffsetCurtain;
static qreal toolOffsetTriangle; static qreal toolOffsetTriangle;
static qreal toolOffsetCache;
QSet<QGraphicsItem*> tools(){ return mTools;} QSet<QGraphicsItem*> tools(){ return mTools;}
@ -277,6 +276,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void selectionChangedProcessing(); void selectionChangedProcessing();
void moveMagnifier(QPoint newPos);
void closeMagnifier();
void zoomInMagnifier();
void zoomOutMagnifier();
void resizedMagnifier(qreal newPercent);
signals: signals:
@ -292,7 +296,6 @@ 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();
void DisposeMagnifierQWidgets(); void DisposeMagnifierQWidgets();
@ -355,10 +358,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
//int mMesure1Ms, mMesure2Ms; //int mMesure1Ms, mMesure2Ms;
bool mHasCache; UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget;
UBMagnifer *magniferControlViewWidget;
UBMagnifer *magniferDisplayViewWidget;
}; };
#endif /* UBGRAPHICSSCENE_H_ */ #endif /* UBGRAPHICSSCENE_H_ */

@ -1,51 +1,124 @@
#include <QtGui>
#include "UBMagnifer.h" #include "UBMagnifer.h"
#include <QPainter>
#include <QPixmap> #include "core/UBApplication.h"
#include <QDebug> #include "board/UBBoardController.h"
#include <QWidget> #include "domain/UBGraphicsScene.h"
#include <QGraphicsView>
#include <QTimerEvent> // #include <QPainter>
#include <QBitmap> // #include <QPixmap>
#include <QPen> // #include <QDebug>
// #include <QWidget>
UBMagnifer::UBMagnifer(QWidget *parent) // #include <QGraphicsView>
: QWidget(parent) // #include <QTimerEvent>
// #include <QBitmap>
// #include <QPen>
UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, gView(0) , gView(0)
, mView(0) , mView(0)
, sizePercentFromScene(20)
, inTimer(false) , inTimer(false)
, borderPen(Qt::darkGray) , borderPen(Qt::darkGray)
, mShouldMoveWidget(false)
, mShouldResizeWidget(false)
{ {
borderPen.setWidth(2); isCusrsorAlreadyStored = false;
setMouseTracking(true);
//--------------------------------------------------//
QPixmap pix(":/images/cursors/resize.png");
QTransform tr;
tr.rotate(45);
mResizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2);
//--------------------------------------------------//
params.sizePercentFromScene = 20;
m_isInteractive = isInteractive;
sClosePixmap = new QPixmap(":/images/close.svg");
sIncreasePixmap = new QPixmap(":/images/increase.svg");
sDecreasePixmap = new QPixmap(":/images/decrease.svg");
mResizeItem = new QPixmap(":/images/resize.svg");
if (parent)
{
setAttribute(Qt::WA_NoMousePropagation);
}
else
{
// standalone window
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_MacAlwaysShowToolWindow);
#endif
#ifdef Q_WS_MAC
setAttribute(Qt::WA_MacAlwaysShowToolWindow);
setAttribute(Qt::WA_MacNonActivatingToolWindow);
setAttribute(Qt::WA_MacNoShadow);
#endif
}
} }
UBMagnifer::~UBMagnifer() UBMagnifier::~UBMagnifier()
{ {
if (timerUpdate != 0) if (timerUpdate != 0)
{ {
killTimer(timerUpdate); killTimer(timerUpdate);
timerUpdate = 0; timerUpdate = 0;
} }
if(sClosePixmap)
{
delete sClosePixmap;
sClosePixmap = NULL;
}
if(sIncreasePixmap)
{
delete sIncreasePixmap;
sIncreasePixmap = NULL;
}
if(sDecreasePixmap)
{
delete sDecreasePixmap;
sDecreasePixmap = NULL;
}
} }
void UBMagnifer::setSize(int percentFromScene) void UBMagnifier::setSize(qreal percentFromScene)
{ {
if(gView == NULL) return; if(gView == NULL || mView == NULL) return;
// calculate object size // calculate object size
sizePercentFromScene = percentFromScene; params.sizePercentFromScene = percentFromScene;
QSize sceneSize = gView->size(); QSize sceneSize = mView->size();
int size = sizePercentFromScene * sceneSize.width() / 100; qreal size = params.sizePercentFromScene * sceneSize.width() / 100;
setGeometry(0, 0, size, size); QRect currGeom = geometry();
if(currGeom.width() == currGeom.height())
{
QPoint newPos = mView->mapFromGlobal(updPointMove);
setGeometry(newPos.x() - size / 2, newPos.y() - size / 2, size, size);
}
else
setGeometry(0, 0, size, size);
// prepare transparent bit mask // prepare transparent bit mask
QImage mask_img(width(), height(), QImage::Format_Mono); QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff); mask_img.fill(0xff);
QPainter mask_ptr(&mask_img); QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) ); mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawEllipse(QPoint(size/2, size/2), size/2, size/2); mask_ptr.drawEllipse(QPointF(size/2, size/2), size / 2 - sClosePixmap->width(), size / 2 - sClosePixmap->width());
bmpMask = QBitmap::fromImage(mask_img); bmpMask = QBitmap::fromImage(mask_img);
// prepare general image // prepare general image
@ -54,49 +127,207 @@ void UBMagnifer::setSize(int percentFromScene)
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
} }
void UBMagnifer::setZoom(int z) void UBMagnifier::setZoom(qreal zoom)
{
params.zoom = zoom;
}
void UBMagnifier::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
// painter.drawRect(0,0,size().width()-1, size().height()-1);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
if (m_isInteractive)
{
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawRoundedRect(QRectF(size().width() / 2, size().height() / 2, ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->width() ) / 2), 15, 15);
painter.setBrush(QColor(190, 190, 190, 255));
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
painter.drawPixmap(size().width() - sClosePixmap->width(), size().height() / 2 + sClosePixmap->height() * 1, *sClosePixmap);
painter.drawPixmap(size().width() - sIncreasePixmap->width(), size().height() / 2 + sIncreasePixmap->height() * 2.5, *sIncreasePixmap);
painter.drawPixmap(size().width() - sDecreasePixmap->width(), size().height() / 2 + sDecreasePixmap->height() * 3.6, *sDecreasePixmap);
painter.drawPixmap(size().width() - mResizeItem->width() - 20, size().height() - mResizeItem->height() - 20, *mResizeItem);
}
else
{
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
}
painter.drawPixmap(0, 0, pMap);
}
void UBMagnifier::mousePressEvent ( QMouseEvent * event )
{ {
zoom = z; if(m_isInteractive)
{
QWidget::mousePressEvent(event);
if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
event->pos().x() < size().width() - 20 &&
event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
event->pos().y() < size().height() - - 20)
{
mShouldResizeWidget = true;
}
else
{
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
}
mMousePressPos = event->pos();
mMousePressDelta = (qreal)updPointGrab.x() + (qreal)size().width() / 2 - (qreal)event->globalPos().x();
event->accept();
zWidth = size().width() / zoom; update();
zWidthHalf = zWidth / 2; }
zHeight = size().height() / zoom; else
zHeightHalf = zHeight / 2; event->ignore();
} }
void UBMagnifer::paintEvent(QPaintEvent *) void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
{ {
QPainter p(this); if(m_isInteractive)
p.drawPixmap(0, 0, pMap); {
if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton))
// in future replace to image border {
QPen pen(Qt::darkGray); QPoint offset = event->pos() - mMousePressPos;
pen.setWidth(2); move(pos() - mMousePressPos + event->pos());
p.setPen(borderPen); event->accept();
p.drawEllipse(QPoint( size().width() / 2, size().height() / 2), size().width() / 2, size().height() / 2);
QWidget::mouseMoveEvent(event);
emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 ));
return;
}
if(mShouldResizeWidget && (event->buttons() & Qt::LeftButton))
{
QPoint currGlobalPos = event->globalPos();
qreal cvW = mView->width();
qreal newXSize = ( currGlobalPos.x() + mMousePressDelta - updPointGrab.x() ) * 2;
qreal newPercentSize = newXSize * 100 / cvW;
emit magnifierResized_Signal(newPercentSize);
event->ignore();
return;
}
if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
event->pos().x() < size().width() - 20 &&
event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
event->pos().y() < size().height() - - 20 &&
isCusrsorAlreadyStored == false
)
{
mOldCursor = cursor();
isCusrsorAlreadyStored = true;
setCursor(mResizeCursor);
}
}
else
event->ignore();
}
void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
{
if(m_isInteractive)
{
mShouldMoveWidget = false;
mShouldResizeWidget = false;
if (event->pos().x() >= size().width() - sClosePixmap->width() &&
event->pos().x() < size().width()&&
event->pos().y() >= size().height() / 2 + sClosePixmap->height() * 1 &&
event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2)
{
event->accept();
emit magnifierClose_Signal();
}
else
if (event->pos().x() >= size().width() - sIncreasePixmap->width() &&
event->pos().x() < size().width()&&
event->pos().y() >= size().height() / 2 + sIncreasePixmap->height() * 2.5 &&
event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5)
{
event->accept();
emit magnifierZoomIn_Signal();
}
else
if (event->pos().x() >= size().width() - sDecreasePixmap->width() &&
event->pos().x() < size().width()&&
event->pos().y() >= size().height() / 2 + sDecreasePixmap->height() * 3.6 &&
event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6)
{
event->accept();
emit magnifierZoomOut_Signal();
}
else
QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
}
else
event->ignore();
} }
void UBMagnifer::timerEvent(QTimerEvent *e) void UBMagnifier::timerEvent(QTimerEvent *e)
{ {
if(inTimer) return; if(inTimer) return;
if (e->timerId() == timerUpdate) if (e->timerId() == timerUpdate)
{ {
inTimer = true; inTimer = true;
if(!(updPoint.isNull())) grabPoint(updPoint); if(!(updPointGrab.isNull()))
if(!(updPointF.isNull()))grabPoint(updPointF); grabPoint(updPointGrab);
if(isCusrsorAlreadyStored)
{
QPoint globalCursorPos = QCursor::pos();
QPoint cursorPos = mapFromGlobal(globalCursorPos);
if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
cursorPos.x() > size().width() - 20 ||
cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
cursorPos.y() > size().height() - - 20
)
{
isCusrsorAlreadyStored = false;
setCursor(mOldCursor);
}
}
inTimer = false; inTimer = false;
} }
} }
void UBMagnifer::grabPoint(const QPoint &point) void UBMagnifier::grabPoint()
{ {
QPointF itemPos = gView->mapFromGlobal(point); QPointF itemPos = gView->mapFromGlobal(updPointGrab);
qreal zWidth = size().width() / params.zoom;
qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom;
qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf; int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf; int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); ((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
@ -104,15 +335,23 @@ void UBMagnifer::grabPoint(const QPoint &point)
update(); update();
} }
void UBMagnifer::grabPoint(const QPointF &point) void UBMagnifier::grabPoint(const QPoint &pGrab)
{ {
QPoint itemPos = gView->mapFromScene(point); updPointGrab = pGrab;
QPointF itemPos = gView->mapFromGlobal(pGrab);
qreal zWidth = size().width() / params.zoom;
qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom;
qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf; int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf; int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); ((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
@ -120,32 +359,24 @@ void UBMagnifer::grabPoint(const QPointF &point)
update(); update();
} }
// from global // from global
void UBMagnifer::grabNMove(const QPoint &point, bool needGrab = true) void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
{ {
updPoint = point; updPointGrab = pGrab;
updPointMove = pMove;
if(needGrab) if(needGrab)
grabPoint(point); grabPoint(pGrab);
QPoint itemPos = mView->mapFromGlobal(point);
move(itemPos.x() - width()/2, itemPos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
// from scene if(needMove)
void UBMagnifer::grabNMove(const QPointF &point, bool needGrab = true) {
{ QPoint movePos = mView->mapFromGlobal(pMove);
updPointF = point; move(movePos.x() - width()/2, movePos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
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) void UBMagnifier::setGrabView(QWidget *view)
{ {
if (timerUpdate != 0) if (timerUpdate != 0)
killTimer(timerUpdate); killTimer(timerUpdate);

@ -1,60 +1,82 @@
#ifndef UBMAGNIFER_H #ifndef UBMAGNIFIER_H
#define UBMAGNIFER_H #define UBMAGNIFIER_H
#include <QWidget> #include <QtGui>
#include <QBitmap>
#include <QPen>
class QPixmap; class UBMagnifierParams
class QBitmap; {
class QPen; public :
class QGraphicsView; int x;
int y;
qreal zoom;
qreal sizePercentFromScene;
};
class UBMagnifer : public QWidget class UBMagnifier : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
UBMagnifer(QWidget *parent = 0); UBMagnifier(QWidget *parent = 0, bool isInteractive = false);
~UBMagnifer(); ~UBMagnifier();
void setSize(int percentFromScene); void setSize(qreal percentFromScene);
void setZoom(int z); void setZoom(qreal zoom);
void setGrabView(QGraphicsView *view); void setGrabView(QWidget *view);
void setMoveView(QGraphicsView *view) {mView = view;} void setMoveView(QWidget *view) {mView = view;}
void grabPoint();
void grabPoint(const QPoint &point); void grabPoint(const QPoint &point);
void grabPoint(const QPointF &point); void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true);
void grabNMove(const QPoint &point, bool needGrab);
void grabNMove(const QPointF &point, bool needGrab); UBMagnifierParams params;
signals:
void magnifierMoved_Signal(QPoint newPos);
void magnifierClose_Signal();
void magnifierZoomIn_Signal();
void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize);
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *); void timerEvent(QTimerEvent *);
int sizePercentFromScene; virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event );
virtual void mouseReleaseEvent ( QMouseEvent * event );
QPoint mMousePressPos;
qreal mMousePressDelta;
bool mShouldMoveWidget;
bool mShouldResizeWidget;
QPixmap *sClosePixmap;
QPixmap *sIncreasePixmap;
QPixmap *sDecreasePixmap;
QPixmap *mResizeItem;
bool isCusrsorAlreadyStored;
QCursor mOldCursor;
QCursor mResizeCursor;
private: private:
int zoom;
int zWidth;
int zHeight;
int zWidthHalf;
int zHeightHalf;
bool inTimer; bool inTimer;
bool m_isInteractive;
int timerUpdate; int timerUpdate;
QPoint updPoint; QPoint updPointGrab;
QPointF updPointF; QPoint updPointMove;
QPixmap pMap; QPixmap pMap;
QBitmap bmpMask; QBitmap bmpMask;
QPen borderPen; QPen borderPen;
QGraphicsView *gView; QWidget *gView;
QGraphicsView *mView; QWidget *mView;
}; };
#endif // UBMAGNIFER_H #endif // UBMAGNIFIER_H

@ -37,7 +37,6 @@ 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;

@ -58,12 +58,13 @@ UBToolsManager::UBToolsManager(QObject *parent)
mToolsIcon.insert(triangle.id,":/images/toolPalette/triangleTool.png"); mToolsIcon.insert(triangle.id,":/images/toolPalette/triangleTool.png");
mDescriptors << triangle; mDescriptors << triangle;
// cache.id = "uniboardTool://uniboard.mnemis.com/cache"; magnifier.id = "uniboardTool://uniboard.mnemis.com/magnifier";
// cache.icon = QPixmap(":/images/toolPalette/cacheTool.png"); magnifier.icon = QPixmap(":/images/toolPalette/magnifierTool.png");
// cache.label = tr("Cache"); magnifier.label = tr("Magnifier");
// cache.version = "1.0"; magnifier.version = "1.0";
// mToolsIcon.insert(cache.id, ":/images/toolPalette/cacheTool.png"); mToolsIcon.insert(magnifier.id,":/images/toolPalette/magnifierTool.png");
// mDescriptors << cache; mDescriptors << magnifier;
} }
UBToolsManager::~UBToolsManager() UBToolsManager::~UBToolsManager()

@ -78,7 +78,7 @@ class UBToolsManager : public QObject
UBToolDescriptor compass; UBToolDescriptor compass;
UBToolDescriptor mask; UBToolDescriptor mask;
UBToolDescriptor triangle; UBToolDescriptor triangle;
UBToolDescriptor cache; UBToolDescriptor magnifier;
QString iconFromToolId(QString id) { return mToolsIcon.value(id);} QString iconFromToolId(QString id) { return mToolsIcon.value(id);}

Loading…
Cancel
Save