Warning, file /education/kstars/kstars/skycomponents/highpmstarlist.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "highpmstarlist.h" 0008 0009 #include "skymesh.h" 0010 #include "skyobjects/starobject.h" 0011 0012 #include <QDebug> 0013 0014 typedef struct HighPMStar 0015 { 0016 HighPMStar(Trixel t, StarObject *s) : trixel(t), star(s) {} 0017 Trixel trixel; 0018 StarObject *star { nullptr }; 0019 0020 } HighPMStar; 0021 0022 HighPMStarList::HighPMStarList(double threshold) : m_reindexNum(J2000), m_threshold(threshold) 0023 { 0024 m_skyMesh = SkyMesh::Instance(); 0025 } 0026 0027 HighPMStarList::~HighPMStarList() 0028 { 0029 qDeleteAll(m_stars); 0030 m_stars.clear(); 0031 } 0032 0033 bool HighPMStarList::append(Trixel trixel, StarObject *star, double pm) 0034 { 0035 if (pm < m_threshold) 0036 return false; 0037 0038 if (trixel >= m_skyMesh->size()) 0039 qDebug() << Q_FUNC_INFO << "### Trixel ID out of range for the Mesh currently in use!" << trixel; 0040 0041 m_stars.append(new HighPMStar(trixel, star)); 0042 if (m_maxPM >= pm) 0043 return true; 0044 0045 m_maxPM = pm; 0046 m_reindexInterval = StarObject::reindexInterval(pm); 0047 0048 return true; 0049 } 0050 0051 void HighPMStarList::setIndexTime(KSNumbers *num) 0052 { 0053 m_reindexNum = KSNumbers(*num); 0054 } 0055 0056 bool HighPMStarList::reindex(KSNumbers *num, StarIndex *starIndex) 0057 { 0058 if (fabs(num->julianCenturies() - m_reindexNum.julianCenturies()) < m_reindexInterval) 0059 return false; 0060 0061 m_reindexNum = KSNumbers(*num); 0062 m_skyMesh->setKSNumbers(num); 0063 0064 int cnt(0); 0065 0066 for (auto &HPStar : m_stars) 0067 { 0068 Trixel trixel = m_skyMesh->indexStar(HPStar->star); 0069 0070 if (trixel == HPStar->trixel) 0071 continue; 0072 cnt++; 0073 StarObject *star = HPStar->star; 0074 0075 // out with the old ... 0076 if (HPStar->trixel >= m_skyMesh->size()) 0077 { 0078 qDebug() << Q_FUNC_INFO << "### Expect an Index out-of-range error. star->trixel =" << HPStar->trixel; 0079 } 0080 0081 StarList *old = starIndex->at(HPStar->trixel); 0082 old->removeAt(old->indexOf(star)); 0083 0084 float mag = star->mag(); 0085 //printf("\n mag = %4.2f trixel %d -> %d\n", mag, HPStar->trixel, trixel ); 0086 0087 // in with the new ... 0088 HPStar->trixel = trixel; 0089 if (trixel >= m_skyMesh->size()) 0090 qDebug() << Q_FUNC_INFO << "### Expect an Index out-of-range error. trixel =" << trixel; 0091 0092 StarList *list = starIndex->at(trixel); 0093 int j; 0094 for (j = 0; j < list->size(); j++) 0095 { 0096 if (list->at(j)->mag() < mag) 0097 continue; 0098 list->insert(j, star); 0099 break; 0100 } 0101 if (j == list->size()) 0102 list->append(star); 0103 0104 //for ( j = 0; j < list->size(); j++ ) { 0105 // printf(" %4.2f\n", list->at(j)->mag() ); 0106 //} 0107 } 0108 return true; 0109 //printf("Re-indexed %d stars at interval %6.1f\n", cnt, 100.0 * m_reindexInterval ); 0110 } 0111 0112 void HighPMStarList::stats() 0113 { 0114 printf("\n"); 0115 printf("maxPM: %6.1f threshold %5.1f\n", m_maxPM, m_threshold); 0116 printf("stars: %d\n", size()); 0117 printf("Update Interval: %6.1f years\n", 100.0 * m_reindexInterval); 0118 printf("Last Update: %6.1f\n", 2000.0 + 100.0 * (int)m_reindexNum.julianCenturies()); 0119 }