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