Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Robert Lancaster
KStars
Commits
7fdf2924
Commit
7fdf2924
authored
Sep 11, 2020
by
Jasem Mutlaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically adjust font size based on how long the FOV name is
parent
002d6dd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
24 deletions
+34
-24
kstars/auxiliary/fov.cpp
kstars/auxiliary/fov.cpp
+34
-24
No files found.
kstars/auxiliary/fov.cpp
View file @
7fdf2924
...
...
@@ -37,7 +37,7 @@
#include <algorithm>
QList
<
FOV
*>
FOVManager
::
m_FOVs
;
int
FOV
::
m_ID
=
1
;
int
FOV
::
m_ID
=
1
;
FOVManager
::~
FOVManager
()
{
...
...
@@ -168,13 +168,14 @@ void FOVManager::releaseCache()
m_FOVs
.
clear
();
}
FOV
::
FOV
(
const
QString
&
n
,
float
a
,
float
b
,
float
xoffset
,
float
yoffset
,
float
rot
,
Shape
sh
,
const
QString
&
col
,
bool
useLockedCP
)
:
QObject
()
FOV
::
FOV
(
const
QString
&
n
,
float
a
,
float
b
,
float
xoffset
,
float
yoffset
,
float
rot
,
Shape
sh
,
const
QString
&
col
,
bool
useLockedCP
)
:
QObject
()
{
qRegisterMetaType
<
FOV
::
Shape
>
(
"FOV::Shape"
);
qDBusRegisterMetaType
<
FOV
::
Shape
>
();
new
FovAdaptor
(
this
);
QDBusConnection
::
sessionBus
().
registerObject
(
QString
(
"/KStars/FOV/%1"
).
arg
(
getID
())
,
this
);
QDBusConnection
::
sessionBus
().
registerObject
(
QString
(
"/KStars/FOV/%1"
).
arg
(
getID
()),
this
);
m_name
=
n
;
m_sizeX
=
a
;
...
...
@@ -198,7 +199,7 @@ FOV::FOV() : QObject()
qDBusRegisterMetaType
<
FOV
::
Shape
>
();
new
FovAdaptor
(
this
);
QDBusConnection
::
sessionBus
().
registerObject
(
QString
(
"/KStars/FOV/%1"
).
arg
(
getID
())
,
this
);
QDBusConnection
::
sessionBus
().
registerObject
(
QString
(
"/KStars/FOV/%1"
).
arg
(
getID
()),
this
);
m_name
=
i18n
(
"No FOV"
);
m_color
=
"#FFFFFF"
;
...
...
@@ -216,8 +217,8 @@ FOV::FOV(const FOV &other) : QObject()
m_sizeX
=
other
.
m_sizeX
;
m_sizeY
=
other
.
m_sizeY
;
m_shape
=
other
.
m_shape
;
m_offsetX
=
other
.
m_offsetX
;
m_offsetY
=
other
.
m_offsetY
;
m_offsetX
=
other
.
m_offsetX
;
m_offsetY
=
other
.
m_offsetY
;
m_PA
=
other
.
m_PA
;
m_imageDisplay
=
other
.
m_imageDisplay
;
m_lockCelestialPole
=
other
.
m_lockCelestialPole
;
...
...
@@ -230,8 +231,8 @@ void FOV::sync(const FOV &other)
m_sizeX
=
other
.
m_sizeX
;
m_sizeY
=
other
.
m_sizeY
;
m_shape
=
other
.
m_shape
;
m_offsetX
=
other
.
m_offsetX
;
m_offsetY
=
other
.
m_offsetY
;
m_offsetX
=
other
.
m_offsetX
;
m_offsetY
=
other
.
m_offsetY
;
m_PA
=
other
.
m_PA
;
m_imageDisplay
=
other
.
m_imageDisplay
;
m_lockCelestialPole
=
other
.
m_lockCelestialPole
;
...
...
@@ -287,19 +288,26 @@ void FOV::draw(QPainter &p, float zoomFactor)
p
.
drawLine
(
center
.
x
()
+
pixelSizeX
/
20
,
center
.
y
()
-
(
3
*
pixelSizeY
/
5
),
center
.
x
()
+
pixelSizeX
/
70
,
center
.
y
()
-
(
0.7
*
pixelSizeY
));
int
fontSize
=
pixelSizeX
/
15
;
if
(
fontSize
<=
4
)
break
;
QFont
font
=
p
.
font
();
font
.
setPixelSize
(
fontSize
);
p
.
setFont
(
font
);
QRect
nameRect
(
targetRect
.
topLeft
().
x
(),
targetRect
.
topLeft
().
y
()
-
(
pixelSizeY
/
8
),
targetRect
.
width
()
/
2
,
pixelSizeX
/
10
);
p
.
drawText
(
nameRect
,
Qt
::
AlignCenter
,
name
());
QRect
sizeRect
(
targetRect
.
center
().
x
(),
targetRect
.
topLeft
().
y
()
-
(
pixelSizeY
/
8
),
targetRect
.
width
()
/
2
,
pixelSizeX
/
10
);
p
.
drawText
(
sizeRect
,
Qt
::
AlignCenter
,
QString
(
"%1'x%2'"
).
arg
(
QString
::
number
(
m_sizeX
,
'f'
,
1
),
QString
::
number
(
m_sizeY
,
'f'
,
1
)));
if
(
name
().
count
()
>
0
)
{
int
fontSize
=
pixelSizeX
/
15
;
fontSize
*=
14.0
/
name
().
count
();
if
(
fontSize
<=
4
)
break
;
QFont
font
=
p
.
font
();
font
.
setPixelSize
(
fontSize
);
p
.
setFont
(
font
);
QRect
nameRect
(
targetRect
.
topLeft
().
x
(),
targetRect
.
topLeft
().
y
()
-
(
pixelSizeY
/
8
),
targetRect
.
width
()
/
2
,
pixelSizeX
/
10
);
p
.
drawText
(
nameRect
,
Qt
::
AlignCenter
,
name
());
QRect
sizeRect
(
targetRect
.
center
().
x
(),
targetRect
.
topLeft
().
y
()
-
(
pixelSizeY
/
8
),
targetRect
.
width
()
/
2
,
pixelSizeX
/
10
);
p
.
drawText
(
sizeRect
,
Qt
::
AlignCenter
,
QString
(
"%1'x%2'"
).
arg
(
QString
::
number
(
m_sizeX
,
'f'
,
1
),
QString
::
number
(
m_sizeY
,
'f'
,
1
)));
}
}
break
;
case
CIRCLE
:
...
...
@@ -329,7 +337,8 @@ void FOV::draw(QPainter &p, float zoomFactor)
p
.
setBrush
(
Qt
::
NoBrush
);
break
;
}
default:
;
default:
;
}
p
.
restore
();
...
...
@@ -348,7 +357,8 @@ void FOV::draw(QPainter &p, float x, float y)
case
BULLSEYE
:
zoomFactor
/=
8
;
break
;
default:
;
default:
;
}
draw
(
p
,
zoomFactor
);
}
...
...
@@ -393,7 +403,7 @@ void FOV::setLockCelestialPole(bool lockCelestialPole)
m_lockCelestialPole
=
lockCelestialPole
;
}
QDBusArgument
&
operator
<<
(
QDBusArgument
&
argument
,
const
FOV
::
Shape
&
source
)
QDBusArgument
&
operator
<<
(
QDBusArgument
&
argument
,
const
FOV
::
Shape
&
source
)
{
argument
.
beginStructure
();
argument
<<
static_cast
<
int
>
(
source
);
...
...
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