1 /*
2     SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "noprecessindex.h"
10 
11 #include <QHash>
12 #include <QPolygonF>
13 
14 class PolyList;
15 class ConstellationBoundary;
16 class KSFileReader;
17 
18 typedef QVector<std::shared_ptr<PolyList>> PolyListList;
19 typedef QVector<std::shared_ptr<PolyListList>> PolyIndex;
20 
21 /**
22  * @class ConstellationBoundary
23  * Collection of lines comprising the borders between constellations
24  *
25  * @author Jason Harris
26  * @version 0.1
27  */
28 class ConstellationBoundaryLines : public NoPrecessIndex
29 {
30   public:
31     /**
32      * @short Constructor
33      * Simply adds all of the coordinate grid circles (meridians and parallels)
34      * @p parent Pointer to the parent SkyComposite object
35      *
36      * Reads the constellation boundary data from cbounds.dat. The boundary data is defined by
37      * a series of RA,Dec coordinate pairs defining the "nodes" of the boundaries. The nodes are
38      * organized into "segments", such that each segment represents a continuous series
39      * of boundary-line intervals that divide two particular constellations.
40      */
41     explicit ConstellationBoundaryLines(SkyComposite *parent);
42     virtual ~ConstellationBoundaryLines() override = default;
43 
44     QString constellationName(const SkyPoint *p) const;
45 
46     bool selected() override;
47 
48     void preDraw(SkyPainter *skyp) override;
49 
50   private:
51     void appendPoly(const std::shared_ptr<PolyList> &polyList, int debug = 0);
52 
53     /**
54      * @short reads the indices from the KSFileReader instead of using
55      * the SkyMesh to create them.  If the file pointer is null or if
56      * debug == -1 then we fall back to using the index.
57      */
58     void appendPoly(std::shared_ptr<PolyList> &polyList, KSFileReader *file, int debug);
59 
60     PolyList *ContainingPoly(const SkyPoint *p) const;
61 
62     SkyMesh *m_skyMesh { nullptr };
63     PolyIndex m_polyIndex;
64     int m_polyIndexCnt { 0 };
65 };
66