Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
1e67bf6e
Commit
1e67bf6e
authored
Apr 03, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-475
Improve the rendering of the magnifier
parent
9745c5d0
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
571 additions
and
489 deletions
+571
-489
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-2
UBDesktopAnnotationController.cpp
src/desktop/UBDesktopAnnotationController.cpp
+1
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+62
-2
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+6
-1
UBMagnifer.cpp
src/gui/UBMagnifer.cpp
+402
-388
UBMagnifer.h
src/gui/UBMagnifer.h
+97
-96
No files found.
src/board/UBBoardController.cpp
View file @
1e67bf6e
...
...
@@ -664,6 +664,7 @@ void UBBoardController::zoom(const qreal ratio, QPointF scenePoint)
UBApplication
::
applicationController
->
adjustDisplayView
();
emit
controlViewportChanged
();
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
}
...
...
@@ -1163,7 +1164,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mControlView
->
setScene
(
mActiveScene
);
mDisplayView
->
setScene
(
mActiveScene
);
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
pDocumentProxy
->
setDefaultDocumentSize
(
mActiveScene
->
nominalSize
());
updatePageSizeState
();
...
...
@@ -1564,7 +1565,7 @@ void UBBoardController::updateSystemScaleFactor()
mControlView
->
setTransform
(
scalingTransform
);
mControlView
->
horizontalScrollBar
()
->
setValue
(
viewState
.
horizontalPosition
);
mControlView
->
verticalScrollBar
()
->
setValue
(
viewState
.
verticalPostition
);
}
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
}
void
UBBoardController
::
setWidePageSize
(
bool
checked
)
...
...
src/desktop/UBDesktopAnnotationController.cpp
View file @
1e67bf6e
...
...
@@ -88,6 +88,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene
=
new
UBGraphicsScene
(
0
);
mTransparentDrawingView
->
setScene
(
mTransparentDrawingScene
);
mTransparentDrawingScene
->
setDrawingMode
(
true
);
// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView);
//mRightPalette = new UBRightPalette(mTransparentDrawingView);
...
...
src/domain/UBGraphicsScene.cpp
View file @
1e67bf6e
...
...
@@ -135,6 +135,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
,
enableUndoRedoStack
(
true
)
,
magniferControlViewWidget
(
0
)
,
magniferDisplayViewWidget
(
0
)
,
mIsDesktopMode
(
false
)
{
...
...
@@ -160,8 +161,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene
::~
UBGraphicsScene
()
{
DisposeMagnifierQWidgets
();
if
(
mCurrentStroke
)
if
(
mCurrentStroke
->
polygons
().
empty
())
delete
mCurrentStroke
;
...
...
@@ -711,6 +710,15 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
}
}
void
UBGraphicsScene
::
setBackgroundZoomFactor
(
qreal
zoom
)
{
mZoomFactor
=
zoom
;
}
void
UBGraphicsScene
::
setDrawingMode
(
bool
bModeDesktop
)
{
mIsDesktopMode
=
bModeDesktop
;
}
void
UBGraphicsScene
::
recolorAllItems
()
{
...
...
@@ -1854,6 +1862,58 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
}
}
void
UBGraphicsScene
::
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
)
{
if
(
mIsDesktopMode
)
{
QGraphicsScene
::
drawBackground
(
painter
,
rect
);
return
;
}
bool
darkBackground
=
isDarkBackground
();
if
(
darkBackground
)
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
black
)));
}
else
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
white
)));
}
if
(
mZoomFactor
>
0.5
)
{
QColor
bgCrossColor
;
if
(
darkBackground
)
bgCrossColor
=
UBSettings
::
crossDarkBackground
;
else
bgCrossColor
=
UBSettings
::
crossLightBackground
;
if
(
mZoomFactor
<
1.0
)
{
int
alpha
=
255
*
mZoomFactor
/
2
;
bgCrossColor
.
setAlpha
(
alpha
);
// fade the crossing on small zooms
}
painter
->
setPen
(
bgCrossColor
);
if
(
isCrossedBackground
())
{
qreal
firstY
=
((
int
)
(
rect
.
y
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
yPos
=
firstY
;
yPos
<
rect
.
y
()
+
rect
.
height
();
yPos
+=
UBSettings
::
crossSize
)
{
painter
->
drawLine
(
rect
.
x
(),
yPos
,
rect
.
x
()
+
rect
.
width
(),
yPos
);
}
qreal
firstX
=
((
int
)
(
rect
.
x
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
xPos
=
firstX
;
xPos
<
rect
.
x
()
+
rect
.
width
();
xPos
+=
UBSettings
::
crossSize
)
{
painter
->
drawLine
(
xPos
,
rect
.
y
(),
xPos
,
rect
.
y
()
+
rect
.
height
());
}
}
}
}
void
UBGraphicsScene
::
keyReleaseEvent
(
QKeyEvent
*
keyEvent
)
{
...
...
src/domain/UBGraphicsScene.h
View file @
1e67bf6e
...
...
@@ -288,7 +288,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
hideEraser
();
void
setBackground
(
bool
pIsDark
,
bool
pIsCrossed
);
void
setBackgroundZoomFactor
(
qreal
zoom
);
void
setDrawingMode
(
bool
bModeDesktop
);
void
deselectAllItems
();
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
qreal
scaleFactor
=
1
.
0
,
bool
pUseAnimation
=
false
);
...
...
@@ -331,6 +332,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QGraphicsItem
*
rootItem
(
QGraphicsItem
*
item
)
const
;
virtual
void
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
);
private
:
void
setDocumentUpdated
();
void
createEraiser
();
...
...
@@ -348,6 +351,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool
mDarkBackground
;
bool
mCrossedBackground
;
bool
mIsDesktopMode
;
qreal
mZoomFactor
;
bool
mIsModified
;
...
...
src/gui/UBMagnifer.cpp
View file @
1e67bf6e
This diff is collapsed.
Click to expand it.
src/gui/UBMagnifer.h
View file @
1e67bf6e
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
#include <QtGui>
class
UBMagnifierParams
{
public
:
int
x
;
int
y
;
qreal
zoom
;
qreal
sizePercentFromScene
;
};
class
UBMagnifier
:
public
QWidget
{
Q_OBJECT
public
:
UBMagnifier
(
QWidget
*
parent
=
0
,
bool
isInteractive
=
false
);
~
UBMagnifier
();
void
setSize
(
qreal
percentFromScene
);
void
setZoom
(
qreal
zoom
);
void
setGrabView
(
QWidget
*
view
);
void
setMoveView
(
QWidget
*
view
)
{
mView
=
view
;}
void
grabPoint
();
void
grabPoint
(
const
QPoint
&
point
);
void
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
=
true
,
bool
needMove
=
true
);
UBMagnifierParams
params
;
signals
:
void
magnifierMoved_Signal
(
QPoint
newPos
);
void
magnifierClose_Signal
();
void
magnifierZoomIn_Signal
();
void
magnifierZoomOut_Signal
();
void
magnifierResized_Signal
(
qreal
newPercentSize
);
protected
:
void
paintEvent
(
QPaintEvent
*
);
void
timerEvent
(
QTimerEvent
*
);
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
:
bool
inTimer
;
bool
m_isInteractive
;
int
timerUpdate
;
QPoint
updPointGrab
;
QPoint
updPointMove
;
QPixmap
pMap
;
QBitmap
bmpMask
;
QPen
borderPen
;
QWidget
*
gView
;
QWidget
*
mView
;
};
#endif // UBMAGNIFIER_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
#include <QtGui>
class
UBMagnifierParams
{
public
:
int
x
;
int
y
;
qreal
zoom
;
qreal
sizePercentFromScene
;
};
class
UBMagnifier
:
public
QWidget
{
Q_OBJECT
public
:
UBMagnifier
(
QWidget
*
parent
=
0
,
bool
isInteractive
=
false
);
~
UBMagnifier
();
void
setSize
(
qreal
percentFromScene
);
void
setZoom
(
qreal
zoom
);
void
setGrabView
(
QWidget
*
view
);
void
setMoveView
(
QWidget
*
view
)
{
mView
=
view
;}
void
grabPoint
();
void
grabPoint
(
const
QPoint
&
point
);
void
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
=
true
,
bool
needMove
=
true
);
UBMagnifierParams
params
;
signals
:
void
magnifierMoved_Signal
(
QPoint
newPos
);
void
magnifierClose_Signal
();
void
magnifierZoomIn_Signal
();
void
magnifierZoomOut_Signal
();
void
magnifierResized_Signal
(
qreal
newPercentSize
);
public
slots
:
void
slot_refresh
();
protected
:
void
paintEvent
(
QPaintEvent
*
);
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
:
QTimer
mRefreshTimer
;
bool
m_isInteractive
;
QPoint
updPointGrab
;
QPoint
updPointMove
;
QPixmap
pMap
;
QBitmap
bmpMask
;
QPen
borderPen
;
QWidget
*
gView
;
QWidget
*
mView
;
};
#endif // UBMAGNIFIER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment