File indexing completed on 2024-04-14 03:42:49
0001 /* 0002 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "satellitesitem.h" 0007 #include "satellitescomponent.h" 0008 0009 #include "Options.h" 0010 #include "projections/projector.h" 0011 #include "kscomet.h" 0012 0013 #include "rootnode.h" 0014 #include "labelsitem.h" 0015 #include "satellite.h" 0016 #include "skylabeler.h" 0017 0018 #include "skynodes/satellitenode.h" 0019 0020 SatellitesItem::SatellitesItem(SatellitesComponent *satComp, RootNode *rootNode) 0021 : SkyItem(LabelsItem::label_t::SATELLITE_LABEL, rootNode), m_satComp(satComp) 0022 { 0023 recreateList(); 0024 Options::setDrawSatellitesLikeStars(false); 0025 } 0026 0027 void SatellitesItem::update() 0028 { 0029 if (!m_satComp->selected()) 0030 { 0031 hide(); 0032 return; 0033 } 0034 0035 QSGNode *n = firstChild(); 0036 0037 while (n != 0) 0038 { 0039 SatelliteNode *satNode = static_cast<SatelliteNode *>(n); 0040 Satellite *sat = satNode->sat(); 0041 if (sat->selected()) 0042 { 0043 if (Options::showVisibleSatellites()) 0044 { 0045 if (sat->isVisible()) 0046 { 0047 satNode->update(); 0048 } 0049 else 0050 { 0051 satNode->hide(); 0052 } 0053 } 0054 else 0055 { 0056 satNode->update(); 0057 } 0058 } 0059 else 0060 { 0061 satNode->hide(); 0062 } 0063 n = n->nextSibling(); 0064 } 0065 } 0066 0067 void SatellitesItem::recreateList() 0068 { 0069 QList<SatelliteGroup *> list = m_satComp->groups(); 0070 for (int i = 0; i < list.size(); ++i) 0071 { 0072 SatelliteGroup *group = list.at(i); 0073 for (int c = 0; c < group->size(); ++c) 0074 { 0075 appendChildNode(new SatelliteNode(group->at(c), rootNode())); 0076 } 0077 } 0078 }