File indexing completed on 2024-04-28 03:44:25

0001 
0002 #include "horizonnode.h"
0003 
0004 #include "ksutils.h"
0005 #include "Options.h"
0006 #include "nodes/polynode.h"
0007 
0008 HorizonNode::HorizonNode() : m_polygonNode(new PolyNode)
0009 {
0010     appendChildNode(m_polygonNode);
0011 }
0012 
0013 void HorizonNode::update()
0014 {
0015     if (!m_polygonNode->visible())
0016     {
0017         m_polygonNode->show();
0018     }
0019 
0020     QColor color = KStarsData::Instance()->colorScheme()->colorNamed("HorzColor");
0021 
0022     m_polygonNode->setColor(color);
0023     m_polygonNode->setLineWidth(2);
0024 
0025     QVector<Eigen::Vector2f> ground = SkyMapLite::Instance()->projector()->groundPoly();
0026 
0027     if (ground.size())
0028     {
0029         QPolygonF groundPoly(ground.size());
0030         for (int i = 0; i < ground.size(); ++i)
0031             groundPoly[i] = KSUtils::vecToPoint(ground[i]);
0032         if (Options::showGround())
0033         {
0034             m_polygonNode->updateGeometry(groundPoly, true);
0035         }
0036         else
0037         {
0038             groundPoly.append(groundPoly.first());
0039             m_polygonNode->updateGeometry(groundPoly, false);
0040         }
0041     }
0042     else
0043     {
0044         m_polygonNode->hide();
0045         return;
0046     }
0047     m_polygonNode->markDirty(QSGNode::DirtyGeometry);
0048 }
0049 
0050 void HorizonNode::hide()
0051 {
0052     m_polygonNode->hide();
0053 }