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
b2646904
Commit
b2646904
authored
Nov 07, 2013
by
cfauconnier
Committed by
-f
Feb 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sankore 570
parent
d21f8b9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
43 deletions
+38
-43
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+38
-43
No files found.
src/tools/UBGraphicsTriangle.cpp
View file @
b2646904
...
@@ -309,76 +309,71 @@ QPainterPath UBGraphicsTriangle::shape() const
...
@@ -309,76 +309,71 @@ QPainterPath UBGraphicsTriangle::shape() const
void
UBGraphicsTriangle
::
paintGraduations
(
QPainter
*
painter
)
void
UBGraphicsTriangle
::
paintGraduations
(
QPainter
*
painter
)
{
{
const
int
SEPARATOR
=
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
;
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
()
+
kx
*
sPixelsPerMillimeter
*
millimeters
;
int
graduationX
=
rotationCenter
().
x
()
+
kx
*
sPixelsPerMillimeter
*
millimeters
;
int
graduationHeight
=
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
?
int
graduationHeight
=
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
?
UBGeometryUtils
::
centimeterGraduationHeight
:
UBGeometryUtils
::
centimeterGraduationHeight
:
((
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerHalfCentimeter
)
?
((
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerHalfCentimeter
)
?
UBGeometryUtils
::
halfCentimeterGraduationHeight
:
UBGeometryUtils
::
millimeterGraduationHeight
);
UBGeometryUtils
::
halfCentimeterGraduationHeight
:
UBGeometryUtils
::
millimeterGraduationHeight
);
// Check that grad. line inside triangle
qreal
requiredSpace
=
graduationHeight
+
SEPARATOR
;
qreal
dx
=
(
kx
>
0
)
?
rect
().
width
()
-
graduationX
:
graduationX
-
rect
().
x
();
/* B____C
qreal
lineY
=
rotationCenter
().
y
()
-
ky
*
rect
().
height
()
/
rect
().
width
()
*
dx
;
| /
if
(
mOrientation
==
BottomLeft
||
mOrientation
==
BottomRight
)
D|_/E <-- availableSpace Thalès
|/
A
*/
qreal
AD
;
switch
(
mOrientation
)
{
{
if
(
lineY
>=
rotationCenter
().
y
()
-
ky
*
graduationHeight
)
case
BottomLeft
:
AD
=
QLineF
(
rect
().
bottomRight
(),
QPointF
(
graduationX
,
rotationCenter
().
y
())).
length
();
break
;
break
;
}
case
TopLeft
:
else
AD
=
QLineF
(
rect
().
topRight
(),
QPointF
(
graduationX
,
rotationCenter
().
y
())).
length
();
{
break
;
if
(
lineY
<=
rotationCenter
().
y
()
-
ky
*
graduationHeight
)
case
TopRight
:
AD
=
QLineF
(
rect
().
topLeft
(),
QPointF
(
graduationX
,
rotationCenter
().
y
())).
length
();
break
;
case
BottomRight
:
AD
=
QLineF
(
rect
().
bottomLeft
(),
QPointF
(
graduationX
,
rotationCenter
().
y
())).
length
();
break
;
break
;
}
}
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
-
ky
*
graduationHeight
));
qreal
AB
=
rect
().
width
();
qreal
BC
=
rect
().
height
();
qreal
DE
=
AD
*
BC
/
AB
,
availableSpace
=
DE
;
if
(
requiredSpace
<=
availableSpace
)
painter
->
drawLine
(
QLine
(
graduationX
,
rotationCenter
().
y
(),
graduationX
,
rotationCenter
().
y
()
-
ky
*
graduationHeight
));
else
break
;
if
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
if
(
0
==
millimeters
%
UBGeometryUtils
::
millimetersPerCentimeter
)
{
{
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
UBGeometryUtils
::
millimetersPerCentimeter
));
QString
text
=
QString
(
"%1"
).
arg
((
int
)(
millimeters
/
UBGeometryUtils
::
millimetersPerCentimeter
));
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
();
int
textY
=
(
ky
>
0
)
?
rotationCenter
().
y
()
-
5
-
UBGeometryUtils
::
centimeterGraduationHeight
-
textHeight
requiredSpace
=
graduationHeight
+
textHeight
+
textWidth
+
SEPARATOR
;
:
rotationCenter
().
y
()
+
5
+
UBGeometryUtils
::
centimeterGraduationHeight
;
bool
bText
=
false
;
if
(
requiredSpace
<=
availableSpace
)
switch
(
mOrientation
)
{
{
case
BottomLeft
:
int
textY
=
(
ky
>
0
)
?
rotationCenter
().
y
()
-
SEPARATOR
-
UBGeometryUtils
::
centimeterGraduationHeight
-
textHeight
dx
=
rect
().
width
()
-
textXRight
;
:
rotationCenter
().
y
()
+
SEPARATOR
+
UBGeometryUtils
::
centimeterGraduationHeight
;
lineY
=
rotationCenter
().
y
()
-
rect
().
height
()
/
rect
().
width
()
*
dx
;
painter
->
drawText
(
QRectF
(
graduationX
-
textWidth
/
2
,
textY
,
textWidth
,
textHeight
),
Qt
::
AlignVCenter
,
text
);
bText
=
lineY
<=
textY
;
break
;
case
TopLeft
:
dx
=
rect
().
width
()
-
textXRight
;
lineY
=
rotationCenter
().
y
()
+
rect
().
height
()
/
rect
().
width
()
*
dx
;
bText
=
lineY
>=
textY
+
textHeight
;
break
;
case
TopRight
:
dx
=
textXRight
-
textWidth
-
rect
().
left
();
lineY
=
rotationCenter
().
y
()
+
rect
().
height
()
/
rect
().
width
()
*
dx
;
bText
=
lineY
>=
textY
+
textHeight
;
break
;
case
BottomRight
:
dx
=
textXRight
-
textWidth
-
rect
().
left
();
lineY
=
rotationCenter
().
y
()
-
rect
().
height
()
/
rect
().
width
()
*
dx
;
bText
=
lineY
<=
textY
;
break
;
}
}
if
(
bText
)
painter
->
drawText
(
QRectF
(
graduationX
-
textWidth
/
2
,
textY
,
textWidth
,
textHeight
),
Qt
::
AlignVCenter
,
text
);
}
}
}
}
painter
->
restore
();
painter
->
restore
();
...
...
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