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
bc875a66
Commit
bc875a66
authored
Apr 24, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapted the ruler to the strokes as objects
parent
6ab23ce4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
50 deletions
+40
-50
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+0
-9
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+0
-1
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+32
-35
UBGraphicsRuler.cpp
src/tools/UBGraphicsRuler.cpp
+8
-5
No files found.
src/domain/UBGraphicsPolygonItem.cpp
View file @
bc875a66
...
@@ -176,7 +176,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
...
@@ -176,7 +176,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
void
UBGraphicsPolygonItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
UBGraphicsPolygonItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
{
if
(
mHasAlpha
&&
scene
()
&&
scene
()
->
isLightBackground
())
if
(
mHasAlpha
&&
scene
()
&&
scene
()
->
isLightBackground
())
{
{
painter
->
setCompositionMode
(
QPainter
::
CompositionMode_Darken
);
painter
->
setCompositionMode
(
QPainter
::
CompositionMode_Darken
);
...
@@ -190,11 +189,3 @@ UBGraphicsScene* UBGraphicsPolygonItem::scene()
...
@@ -190,11 +189,3 @@ UBGraphicsScene* UBGraphicsPolygonItem::scene()
{
{
return
qobject_cast
<
UBGraphicsScene
*>
(
QGraphicsPolygonItem
::
scene
());
return
qobject_cast
<
UBGraphicsScene
*>
(
QGraphicsPolygonItem
::
scene
());
}
}
src/domain/UBGraphicsPolygonItem.h
View file @
bc875a66
...
@@ -116,7 +116,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
...
@@ -116,7 +116,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected
:
protected
:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
private
:
private
:
void
clearStroke
();
void
clearStroke
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
bc875a66
...
@@ -364,7 +364,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
...
@@ -364,7 +364,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mRemovedItems
.
clear
();
mRemovedItems
.
clear
();
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
)
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
)
{
{
UBDrawingController
::
drawingController
()
->
mActiveRuler
->
StartLine
(
scenePos
,
width
);
UBDrawingController
::
drawingController
()
->
mActiveRuler
->
StartLine
(
scenePos
,
width
);
}
}
else
else
...
@@ -432,40 +432,37 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
...
@@ -432,40 +432,37 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width
/=
UBApplication
::
boardController
->
systemScaleFactor
();
width
/=
UBApplication
::
boardController
->
systemScaleFactor
();
width
/=
UBApplication
::
boardController
->
currentZoom
();
width
/=
UBApplication
::
boardController
->
currentZoom
();
if
(
dc
->
mActiveRuler
)
if
(
currentTool
==
UBStylusTool
::
Line
||
dc
->
mActiveRuler
)
{
{
dc
->
mActiveRuler
->
DrawLine
(
position
,
width
);
if
(
NULL
!=
mpLastPolygon
&&
NULL
!=
mCurrentStroke
&&
mAddedItems
.
size
()
>
0
){
}
UBCoreGraphicsScene
::
removeItemFromDeletion
(
mpLastPolygon
);
else
mAddedItems
.
remove
(
mpLastPolygon
);
{
mCurrentStroke
->
remove
(
mpLastPolygon
);
if
(
currentTool
==
UBStylusTool
::
Line
)
removeItem
(
mpLastPolygon
);
{
mPreviousPolygonItems
.
removeAll
(
mpLastPolygon
);
if
(
NULL
!=
mpLastPolygon
&&
NULL
!=
mCurrentStroke
&&
mAddedItems
.
size
()
>
0
){
}
UBCoreGraphicsScene
::
removeItemFromDeletion
(
mpLastPolygon
);
mAddedItems
.
remove
(
mpLastPolygon
);
mCurrentStroke
->
remove
(
mpLastPolygon
);
removeItem
(
mpLastPolygon
);
mPreviousPolygonItems
.
removeAll
(
mpLastPolygon
);
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Here we wanna make sure that the Line will 'grip' at i*45, i*90 degrees
// Here we wanna make sure that the Line will 'grip' at i*45, i*90 degrees
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
QLineF
radius
(
mPreviousPoint
,
position
);
QLineF
radius
(
mPreviousPoint
,
position
);
qreal
angle
=
radius
.
angle
();
qreal
angle
=
radius
.
angle
();
angle
=
qRound
(
angle
/
45
)
*
45
;
angle
=
qRound
(
angle
/
45
)
*
45
;
qreal
radiusLength
=
radius
.
length
();
qreal
radiusLength
=
radius
.
length
();
QPointF
newPosition
(
QPointF
newPosition
(
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
QLineF
chord
(
position
,
newPosition
);
QLineF
chord
(
position
,
newPosition
);
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
position
=
newPosition
;
position
=
newPosition
;
}
}
if
(
dc
->
mActiveRuler
){
dc
->
mActiveRuler
->
DrawLine
(
position
,
width
);
}
else
{
drawLineTo
(
position
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
drawLineTo
(
position
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
}
}
}
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
{
{
...
@@ -675,14 +672,14 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
...
@@ -675,14 +672,14 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
mpLastPolygon
=
polygonItem
;
mpLastPolygon
=
polygonItem
;
mAddedItems
.
insert
(
polygonItem
);
mAddedItems
.
insert
(
polygonItem
);
// Here we add the item to the scene
addItem
(
polygonItem
);
if
(
mCurrentStroke
)
if
(
mCurrentStroke
)
{
{
polygonItem
->
setStroke
(
mCurrentStroke
);
polygonItem
->
setStroke
(
mCurrentStroke
);
}
}
// Here we add the item to the scene
addItem
(
polygonItem
);
mPreviousPolygonItems
.
append
(
polygonItem
);
mPreviousPolygonItems
.
append
(
polygonItem
);
if
(
!
bLineStyle
)
if
(
!
bLineStyle
)
...
...
src/tools/UBGraphicsRuler.cpp
View file @
bc875a66
...
@@ -103,6 +103,7 @@ void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *s
...
@@ -103,6 +103,7 @@ void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *s
painter
->
setPen
(
drawColor
());
painter
->
setPen
(
drawColor
());
painter
->
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
->
drawRoundedRect
(
rect
(),
sRoundingRadius
,
sRoundingRadius
);
painter
->
drawRoundedRect
(
rect
(),
sRoundingRadius
,
sRoundingRadius
);
fillBackground
(
painter
);
fillBackground
(
painter
);
paintGraduations
(
painter
);
paintGraduations
(
painter
);
...
@@ -452,8 +453,8 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
...
@@ -452,8 +453,8 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
itemPos
.
setY
(
y
);
itemPos
.
setY
(
y
);
itemPos
=
mapToScene
(
itemPos
);
itemPos
=
mapToScene
(
itemPos
);
scene
()
->
moveTo
(
itemPos
);
scene
()
->
moveTo
(
itemPos
);
scene
()
->
drawLineTo
(
itemPos
,
width
,
true
);
scene
()
->
drawLineTo
(
itemPos
,
width
,
true
);
}
}
void
UBGraphicsRuler
::
DrawLine
(
const
QPointF
&
scenePos
,
qreal
width
)
void
UBGraphicsRuler
::
DrawLine
(
const
QPointF
&
scenePos
,
qreal
width
)
...
@@ -478,9 +479,11 @@ void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
...
@@ -478,9 +479,11 @@ void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
itemPos
=
mapToScene
(
itemPos
);
itemPos
=
mapToScene
(
itemPos
);
// We have to use "pointed" line for marker tool
// We have to use "pointed" line for marker tool
scene
()
->
drawLineTo
(
itemPos
,
width
,
scene
()
->
drawLineTo
(
itemPos
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
!=
UBStylusTool
::
Marker
);
UBDrawingController
::
drawingController
()
->
stylusTool
()
!=
UBStylusTool
::
Marker
);
}
}
void
UBGraphicsRuler
::
EndLine
()
void
UBGraphicsRuler
::
EndLine
()
{}
{
// We never come to this place
scene
()
->
inputDeviceRelease
();
}
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