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
d58dafa1
Commit
d58dafa1
authored
Oct 15, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release-candidate' of github.com:Sankore/Sankore-3.1 into release-candidate
Conflicts: src/tools/UBGraphicsRuler.cpp
parents
9e44b36d
47844ccf
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
34 deletions
+36
-34
UBBoardController.cpp
src/board/UBBoardController.cpp
+2
-0
UBGeometryUtils.cpp
src/frameworks/UBGeometryUtils.cpp
+5
-0
UBGeometryUtils.h
src/frameworks/UBGeometryUtils.h
+6
-0
UBAbstractDrawRuler.h
src/tools/UBAbstractDrawRuler.h
+4
-1
UBGraphicsProtractor.h
src/tools/UBGraphicsProtractor.h
+1
-1
UBGraphicsRuler.cpp
src/tools/UBGraphicsRuler.cpp
+8
-14
UBGraphicsRuler.h
src/tools/UBGraphicsRuler.h
+1
-1
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+8
-14
UBGraphicsTriangle.h
src/tools/UBGraphicsTriangle.h
+1
-3
No files found.
src/board/UBBoardController.cpp
View file @
d58dafa1
...
@@ -108,6 +108,8 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
...
@@ -108,6 +108,8 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
mPenColorOnLightBackground
=
UBSettings
::
settings
()
->
penColors
(
false
).
at
(
penColorIndex
);
mPenColorOnLightBackground
=
UBSettings
::
settings
()
->
penColors
(
false
).
at
(
penColorIndex
);
mMarkerColorOnDarkBackground
=
UBSettings
::
settings
()
->
markerColors
(
true
).
at
(
markerColorIndex
);
mMarkerColorOnDarkBackground
=
UBSettings
::
settings
()
->
markerColors
(
true
).
at
(
markerColorIndex
);
mMarkerColorOnLightBackground
=
UBSettings
::
settings
()
->
markerColors
(
false
).
at
(
markerColorIndex
);
mMarkerColorOnLightBackground
=
UBSettings
::
settings
()
->
markerColors
(
false
).
at
(
markerColorIndex
);
UBSettings
::
settings
()
->
crossSize
=
UBGeometryUtils
::
millimetersPerCentimeter
*
4
;
}
}
...
...
src/frameworks/UBGeometryUtils.cpp
View file @
d58dafa1
...
@@ -18,6 +18,11 @@
...
@@ -18,6 +18,11 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
const
double
PI
=
4.0
*
atan
(
1.0
);
const
double
PI
=
4.0
*
atan
(
1.0
);
const
int
UBGeometryUtils
::
centimeterGraduationHeight
=
15
;
const
int
UBGeometryUtils
::
halfCentimeterGraduationHeight
=
10
;
const
int
UBGeometryUtils
::
millimeterGraduationHeight
=
5
;
const
int
UBGeometryUtils
::
millimetersPerCentimeter
=
10
;
const
int
UBGeometryUtils
::
millimetersPerHalfCentimeter
=
5
;
UBGeometryUtils
::
UBGeometryUtils
()
UBGeometryUtils
::
UBGeometryUtils
()
{
{
...
...
src/frameworks/UBGeometryUtils.h
View file @
d58dafa1
...
@@ -37,6 +37,12 @@ class UBGeometryUtils
...
@@ -37,6 +37,12 @@ class UBGeometryUtils
static
QPoint
pointConstrainedInRect
(
QPoint
point
,
QRect
rect
);
static
QPoint
pointConstrainedInRect
(
QPoint
point
,
QRect
rect
);
static
void
crashPointList
(
QVector
<
QPointF
>
&
points
);
static
void
crashPointList
(
QVector
<
QPointF
>
&
points
);
const
static
int
centimeterGraduationHeight
;
const
static
int
halfCentimeterGraduationHeight
;
const
static
int
millimeterGraduationHeight
;
const
static
int
millimetersPerCentimeter
;
const
static
int
millimetersPerHalfCentimeter
;
};
};
#endif
/* UBGEOMETRYUTILS_H_ */
#endif
/* UBGEOMETRYUTILS_H_ */
src/tools/UBAbstractDrawRuler.h
View file @
d58dafa1
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#define UB_ABSTRACTDRAWRULER_H_
#define UB_ABSTRACTDRAWRULER_H_
#include <QtGui>
#include <QtGui>
#include "frameworks/UBGeometryUtils.h"
class
UBGraphicsScene
;
class
UBGraphicsScene
;
class
QGraphicsSvgItem
;
class
QGraphicsSvgItem
;
...
@@ -46,6 +48,7 @@ protected:
...
@@ -46,6 +48,7 @@ protected:
virtual
QPointF
rotationCenter
()
const
=
0
;
virtual
QPointF
rotationCenter
()
const
=
0
;
virtual
QRectF
closeButtonRect
()
const
=
0
;
virtual
QRectF
closeButtonRect
()
const
=
0
;
virtual
void
paintGraduations
(
QPainter
*
painter
)
=
0
;
bool
mShowButtons
;
bool
mShowButtons
;
QGraphicsSvgItem
*
mCloseSvgItem
;
QGraphicsSvgItem
*
mCloseSvgItem
;
...
...
src/tools/UBGraphicsProtractor.h
View file @
d58dafa1
...
@@ -62,10 +62,10 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
...
@@ -62,10 +62,10 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
QPainterPath
shape
()
const
;
virtual
QPainterPath
shape
()
const
;
QRectF
boundingRect
()
const
;
QRectF
boundingRect
()
const
;
void
paintGraduations
(
QPainter
*
painter
);
private
:
private
:
// Helpers
// Helpers
void
paintGraduations
(
QPainter
*
painter
);
void
paintButtons
(
QPainter
*
painter
);
void
paintButtons
(
QPainter
*
painter
);
void
paintAngleMarker
(
QPainter
*
painter
);
void
paintAngleMarker
(
QPainter
*
painter
);
Tool
toolFromPos
(
QPointF
pos
);
Tool
toolFromPos
(
QPointF
pos
);
...
...
src/tools/UBGraphicsRuler.cpp
View file @
d58dafa1
...
@@ -158,36 +158,30 @@ void UBGraphicsRuler::fillBackground(QPainter *painter)
...
@@ -158,36 +158,30 @@ void UBGraphicsRuler::fillBackground(QPainter *painter)
void
UBGraphicsRuler
::
paintGraduations
(
QPainter
*
painter
)
void
UBGraphicsRuler
::
paintGraduations
(
QPainter
*
painter
)
{
{
const
int
centimeterGraduationHeight
=
15
;
const
int
halfCentimeterGraduationHeight
=
10
;
const
int
millimeterGraduationHeight
=
5
;
const
int
millimetersPerCentimeter
=
10
;
const
int
millimetersPerHalfCentimeter
=
5
;
painter
->
save
();
painter
->
save
();
painter
->
setFont
(
font
());
painter
->
setFont
(
font
());
QFontMetricsF
fontMetrics
(
painter
->
font
());
QFontMetricsF
fontMetrics
(
painter
->
font
());
for
(
int
millimeters
=
0
;
millimeters
<
(
rect
().
width
()
-
sLeftEdgeMargin
-
sRoundingRadius
)
/
sPixelsPerMillimeter
;
millimeters
++
)
for
(
int
millimeters
=
0
;
millimeters
<
(
rect
().
width
()
-
sLeftEdgeMargin
-
sRoundingRadius
)
/
sPixelsPerMillimeter
;
millimeters
++
)
{
{
int
graduationX
=
rotationCenter
().
x
()
+
sPixelsPerMillimeter
*
millimeters
;
int
graduationX
=
rotationCenter
().
x
()
+
sPixelsPerMillimeter
*
millimeters
;
int
graduationHeight
=
(
0
==
millimeters
%
millimetersPerCentimeter
)
?
int
graduationHeight
=
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
?
centimeterGraduationHeight
:
UBGeometryUtils
::
centimeterGraduationHeight
:
((
0
==
millimeters
%
millimetersPerHalfCentimeter
)
?
((
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerHalfCentimeter
)
?
halfCentimeterGraduationHeight
:
millimeterGraduationHeight
);
UBGeometryUtils
::
halfCentimeterGraduationHeight
:
UBGeometryUtils
::
millimeterGraduationHeight
);
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
+
graduationHeight
));
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
+
graduationHeight
));
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
()
+
rect
().
height
(),
graduationX
,
rotationCenter
().
y
()
+
rect
().
height
()
-
graduationHeight
));
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
()
+
rect
().
height
(),
graduationX
,
rotationCenter
().
y
()
+
rect
().
height
()
-
graduationHeight
));
if
(
0
==
millimeters
%
millimetersPerCentimeter
)
if
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
{
{
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
millimetersPerCentimeter
));
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
UBGeometryUtils
::
millimetersPerCentimeter
));
if
(
graduationX
+
fontMetrics
.
width
(
text
)
/
2
<
rect
().
right
())
if
(
graduationX
+
fontMetrics
.
width
(
text
)
/
2
<
rect
().
right
())
{
{
qreal
textWidth
=
fontMetrics
.
width
(
text
);
qreal
textWidth
=
fontMetrics
.
width
(
text
);
qreal
textHeight
=
fontMetrics
.
tightBoundingRect
(
text
).
height
()
+
5
;
qreal
textHeight
=
fontMetrics
.
tightBoundingRect
(
text
).
height
()
+
5
;
painter
->
drawText
(
painter
->
drawText
(
QRectF
(
graduationX
-
textWidth
/
2
,
rect
().
top
()
+
5
+
centimeterGraduationHeight
,
textWidth
,
textHeight
),
QRectF
(
graduationX
-
textWidth
/
2
,
rect
().
top
()
+
5
+
UBGeometryUtils
::
centimeterGraduationHeight
,
textWidth
,
textHeight
),
Qt
::
AlignVCenter
,
text
);
Qt
::
AlignVCenter
,
text
);
painter
->
drawText
(
painter
->
drawText
(
QRectF
(
graduationX
-
textWidth
/
2
,
rect
().
bottom
()
-
5
-
centimeterGraduationHeight
-
textHeight
,
textWidth
,
textHeight
),
QRectF
(
graduationX
-
textWidth
/
2
,
rect
().
bottom
()
-
5
-
UBGeometryUtils
::
centimeterGraduationHeight
-
textHeight
,
textWidth
,
textHeight
),
Qt
::
AlignVCenter
,
text
);
Qt
::
AlignVCenter
,
text
);
}
}
}
}
...
...
src/tools/UBGraphicsRuler.h
View file @
d58dafa1
...
@@ -59,6 +59,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
...
@@ -59,6 +59,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
paintGraduations
(
QPainter
*
painter
);
private
:
private
:
...
@@ -68,7 +69,6 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
...
@@ -68,7 +69,6 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
// Helpers
// Helpers
void
fillBackground
(
QPainter
*
painter
);
void
fillBackground
(
QPainter
*
painter
);
void
paintGraduations
(
QPainter
*
painter
);
void
paintRotationCenter
(
QPainter
*
painter
);
void
paintRotationCenter
(
QPainter
*
painter
);
virtual
void
rotateAroundCenter
(
qreal
angle
);
virtual
void
rotateAroundCenter
(
qreal
angle
);
...
...
src/tools/UBGraphicsTriangle.cpp
View file @
d58dafa1
...
@@ -297,12 +297,6 @@ QPainterPath UBGraphicsTriangle::shape() const
...
@@ -297,12 +297,6 @@ QPainterPath UBGraphicsTriangle::shape() const
void
UBGraphicsTriangle
::
paintGraduations
(
QPainter
*
painter
)
void
UBGraphicsTriangle
::
paintGraduations
(
QPainter
*
painter
)
{
{
const
int
centimeterGraduationHeight
=
15
;
const
int
halfCentimeterGraduationHeight
=
10
;
const
int
millimeterGraduationHeight
=
5
;
const
int
millimetersPerCentimeter
=
10
;
const
int
millimetersPerHalfCentimeter
=
5
;
qreal
kx
=
(
mOrientation
==
TopLeft
||
mOrientation
==
BottomLeft
)
?
1
:
-
1
;
qreal
kx
=
(
mOrientation
==
TopLeft
||
mOrientation
==
BottomLeft
)
?
1
:
-
1
;
qreal
ky
=
(
mOrientation
==
BottomLeft
||
mOrientation
==
BottomRight
)
?
1
:
-
1
;
qreal
ky
=
(
mOrientation
==
BottomLeft
||
mOrientation
==
BottomRight
)
?
1
:
-
1
;
...
@@ -312,10 +306,10 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
...
@@ -312,10 +306,10 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
for
(
int
millimeters
=
0
;
millimeters
<
(
rect
().
width
()
-
sLeftEdgeMargin
-
sRoundingRadius
)
/
sPixelsPerMillimeter
;
millimeters
++
)
for
(
int
millimeters
=
0
;
millimeters
<
(
rect
().
width
()
-
sLeftEdgeMargin
-
sRoundingRadius
)
/
sPixelsPerMillimeter
;
millimeters
++
)
{
{
int
graduationX
=
rotationCenter
().
x
()
+
kx
*
sPixelsPerMillimeter
*
millimeters
;
int
graduationX
=
rotationCenter
().
x
()
+
kx
*
sPixelsPerMillimeter
*
millimeters
;
int
graduationHeight
=
(
0
==
millimeters
%
millimetersPerCentimeter
)
?
int
graduationHeight
=
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
?
centimeterGraduationHeight
:
UBGeometryUtils
::
centimeterGraduationHeight
:
((
0
==
millimeters
%
millimetersPerHalfCentimeter
)
?
((
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerHalfCentimeter
)
?
halfCentimeterGraduationHeight
:
millimeterGraduationHeight
);
UBGeometryUtils
::
halfCentimeterGraduationHeight
:
UBGeometryUtils
::
millimeterGraduationHeight
);
// Check that grad. line inside triangle
// Check that grad. line inside triangle
qreal
dx
=
(
kx
>
0
)
?
rect
().
width
()
-
graduationX
:
graduationX
-
rect
().
x
();
qreal
dx
=
(
kx
>
0
)
?
rect
().
width
()
-
graduationX
:
graduationX
-
rect
().
x
();
...
@@ -332,15 +326,15 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
...
@@ -332,15 +326,15 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
}
}
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
-
ky
*
graduationHeight
));
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
-
ky
*
graduationHeight
));
if
(
0
==
millimeters
%
millimetersPerCentimeter
)
if
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
{
{
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
millimetersPerCentimeter
));
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
UBGeometryUtils
::
millimetersPerCentimeter
));
int
textXRight
=
graduationX
+
fontMetrics
.
width
(
text
)
/
2
;
int
textXRight
=
graduationX
+
fontMetrics
.
width
(
text
)
/
2
;
qreal
textWidth
=
fontMetrics
.
width
(
text
);
qreal
textWidth
=
fontMetrics
.
width
(
text
);
qreal
textHeight
=
fontMetrics
.
tightBoundingRect
(
text
).
height
()
+
5
;
qreal
textHeight
=
fontMetrics
.
tightBoundingRect
(
text
).
height
()
+
5
;
int
textY
=
(
ky
>
0
)
?
rotationCenter
().
y
()
-
5
-
centimeterGraduationHeight
-
textHeight
int
textY
=
(
ky
>
0
)
?
rotationCenter
().
y
()
-
5
-
UBGeometryUtils
::
centimeterGraduationHeight
-
textHeight
:
rotationCenter
().
y
()
+
5
+
centimeterGraduationHeight
;
:
rotationCenter
().
y
()
+
5
+
UBGeometryUtils
::
centimeterGraduationHeight
;
bool
bText
=
false
;
bool
bText
=
false
;
switch
(
mOrientation
)
switch
(
mOrientation
)
...
...
src/tools/UBGraphicsTriangle.h
View file @
d58dafa1
...
@@ -118,6 +118,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
...
@@ -118,6 +118,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
paintGraduations
(
QPainter
*
painter
);
private
:
private
:
...
@@ -143,9 +144,6 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
...
@@ -143,9 +144,6 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
static
const
QRect
sDefaultRect
;
static
const
QRect
sDefaultRect
;
static
const
UBGraphicsTriangleOrientation
sDefaultOrientation
;
static
const
UBGraphicsTriangleOrientation
sDefaultOrientation
;
void
paintGraduations
(
QPainter
*
painter
);
UBGraphicsTriangleOrientation
mOrientation
;
UBGraphicsTriangleOrientation
mOrientation
;
QPointF
A1
,
B1
,
C1
,
A2
,
B2
,
C2
;
// coordinates of points in ext and int triangles
QPointF
A1
,
B1
,
C1
,
A2
,
B2
,
C2
;
// coordinates of points in ext and int triangles
...
...
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