File indexing completed on 2024-04-14 14:11:21

0001 /*
0002     SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ksnumbers.h"
0010 #include "typedef.h"
0011 
0012 struct HighPMStar;
0013 class SkyMesh;
0014 
0015 /** @class HighPMStarList
0016  * Holds a list of stars with high proper motion along with the trixel each star
0017  * is currently located in.  The purpose of this class is to save some time by
0018  * only re-indexing the stars with high proper motion instead of the entire
0019  * collection of stars (which takes about 4 seconds on a AMD64 3600).
0020  *
0021  * Multiple HighPMStarList's can be used so we re-index a smaller number of
0022  * stars more frequently and a larger number of stars less frequently.
0023  *
0024  *
0025  * @author James B. Bowlin @version 0.1
0026 */
0027 
0028 class HighPMStarList
0029 {
0030   public:
0031     /** @short Constructor */
0032     explicit HighPMStarList(double threshold);
0033     ~HighPMStarList();
0034 
0035     /**
0036      * @short adds the star located at trixel to the list if the pm is
0037      * greater than the threshold.  We also use the pm to determine the
0038      * update interval.  Returns true if the star was appended and false
0039      * otherwise.
0040      */
0041     bool append(Trixel trixel, StarObject *star, double pm);
0042 
0043     /** @short returns the threshold. */
0044     double threshold() const { return m_threshold; }
0045 
0046     /** @short returns the number of stars in the list. */
0047     int size() const { return m_stars.size(); }
0048 
0049     /**
0050      * @short sets the time this list was last indexed to.  Normally this
0051      * is done automatically in the reindex() routine but this is useful
0052      * if the entire starIndex gets re-indexed.
0053      */
0054     void setIndexTime(KSNumbers *num);
0055 
0056     /**
0057      * @short if the date in num differs from the last time we indexed by
0058      * more than our update interval then we re-index all the stars in our
0059      * list that have actually changed trixels.
0060      */
0061     bool reindex(KSNumbers *num, StarIndex *starIndex);
0062 
0063     /** @short prints out some brief statistics. */
0064     void stats();
0065 
0066   private:
0067     QVector<HighPMStar *> m_stars;
0068 
0069     KSNumbers m_reindexNum;
0070     double m_reindexInterval { 0 };
0071     double m_threshold { 0 };
0072     double m_maxPM { 0 };
0073 
0074     SkyMesh *m_skyMesh { nullptr };
0075 };