Kstars
6 #include "linelistlabel.h"
13 #include "skylabeler.h"
14 #include "projections/projector.h"
16 LineListLabel::LineListLabel(
const QString &text) : m_text(text)
18 m_skyLabeler = SkyLabeler::Instance();
21 for (
int i = 0; i < 4; i++)
23 m_labList[i] =
nullptr;
28 void LineListLabel::reset()
34 for (
int i = 0; i < 4; i++)
36 m_labList[i] =
nullptr;
47 m_skyLabeler->getMargins(m_text, &m_marginLeft, &m_marginRight, &m_marginTop, &m_marginBot);
50 void LineListLabel::updateLabelCandidates(qreal x, qreal y,
LineList *lineList,
int i)
55 if (x < m_marginLeft || x > m_marginRight || y < m_marginTop || y > m_marginBot)
60 m_labIndex[LeftCandidate] = i;
61 m_labList[LeftCandidate] = lineList;
66 m_labIndex[RightCandidate] = i;
67 m_labList[RightCandidate] = lineList;
72 m_labIndex[BotCandidate] = i;
73 m_labList[BotCandidate] = lineList;
78 m_labIndex[TopCandidate] = i;
79 m_labList[TopCandidate] = lineList;
84 void LineListLabel::draw()
89 double comfyAngle = 40.0;
100 double a[4] = { 360.0, 360.0, 360.0, 360.0 };
102 bool okay[4] = {
true,
true,
true,
true };
106 static int Order[4] = { LeftCandidate, BotCandidate, TopCandidate, LeftCandidate };
108 for (
int j = 0; j < 4; j++)
110 idx[j] = m_labIndex[Order[j]];
111 list[j] = m_labList[Order[j]];
116 for (; first < 4; first++)
128 for (
int j = first; j < 4; j++)
130 o[j] = angleAt(proj, list[j], idx[j], &a[j]);
138 if (fabs(a[j]) > comfyAngle)
141 if (m_skyLabeler->drawGuideLabel(o[j], m_text, a[j]))
153 for (; best < 4; best++)
155 if (idx[best] && okay[best])
164 for (
int j = best + 1; j < 4; j++)
166 if (idx[j] && okay[j] && fabs(a[j]) < fabs(a[best]))
170 m_skyLabeler->drawGuideLabel(o[best], m_text, a[best]);
182 double sx = double(oThis.
x() - oLast.
x());
183 double sy = double(oThis.
y() - oLast.
y());
185 *angle = atan2(sy, sx) * 180.0 /
dms::PI;
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
const T & at(int i) const const
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
const Projector * projector() const
Get the current projector.
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:01 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.