6#include "linelistlabel.h" 
   13#include "skylabeler.h" 
   14#include "projections/projector.h" 
   16LineListLabel::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;
 
   28void 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);
 
   50void 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;
 
   84void LineListLabel::draw()
 
   87    const Projector *proj = SkyMap::Instance()->
projector();
 
   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]);
 
  176    const SkyPoint *pThis = 
list->
at(i).get();
 
  177    const SkyPoint *pLast = 
list->
at(i-1).get();
 
  179    QPointF oThis = proj->
toScreen(pThis);
 
  180    QPointF oLast = proj->
toScreen(pLast);
 
  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;
 
A simple data container used by LineListIndex.
 
The Projector class is the primary class that serves as an interface to handle projections.
 
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
 
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
 
const Projector * projector() const
Get the current projector.
 
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
 
KIOCORE_EXPORT QStringList list(const QString &fileClass)
 
const_reference at(qsizetype i) const const