Kstars

linelistindex.h
1/*
2 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "skycomponent.h"
10#include "skymesh.h"
11
12#include <QMutex>
13
14#include <memory>
15#include <set>
16
17class LineList;
18class LineListLabel;
19class SkipHashList;
20class SkyPainter;
21
22/**
23 * @class LineListIndex
24 * Contains almost all the code needed for indexing and drawing and clipping
25 * lines and polygons.
26 *
27 * @author James B. Bowlin @version 0.1
28 */
30{
31 friend class LinesItem; //Needs access to reindexLines
32 public:
33 /**
34 * @short Constructor
35 * Simply set the internal skyMesh, parent, and name.
36 * @param parent Pointer to the parent SkyComponent object
37 * @param name name of the subclass used for debugging
38 */
39 explicit LineListIndex(SkyComposite *parent, const QString &name = "");
40
41 virtual ~LineListIndex() override = default;
42
43 /**
44 * @short The top level draw routine. Draws all the LineLists for any
45 * subclass in one fell swoop which minimizes some of the loop overhead.
46 * Overridden by MilkWay so it can decide whether to draw outlines or
47 * filled. Therefore MilkyWay does not need to override preDraw(). The
48 * MilkyWay draw() routine calls all of the more specific draw()
49 * routines below.
50 */
51 void draw(SkyPainter *skyp) override;
52
53#ifdef KSTARS_LITE
54 /**
55 * @short KStars Lite needs direct access to m_lineIndex for drawing the lines
56 */
57 inline LineListHash *lineIndex() const { return m_lineIndex.get(); }
58 inline LineListHash *polyIndex() const { return m_polyIndex.get(); }
59
60 /** @short returns MeshIterator for currently visible trixels */
62
63#endif
64 //Moved to public because KStars Lite uses it
65 /**
66 * @short this is called from within the draw routines when the updateID
67 * of the lineList is stale. It is virtual because different subclasses
68 * have different update routines. NoPrecessIndex doesn't precess in
69 * the updates and ConstellationLines must update its points as stars,
70 * not points. that doesn't precess the points.
71 */
72 virtual void JITupdate(LineList *lineList);
73
74 protected:
75 /**
76 * @short as the name says, recreates the lineIndex using the LineLists
77 * in the previous index. Since we are indexing everything at J2000
78 * this is only used by ConstellationLines which needs to reindex
79 * because of the proper motion of the stars.
80 */
81 void reindexLines();
82
83 /** @short retrieve name of object */
84 QString name() const { return m_name; }
85
86 /**
87 * @short displays a message that we are loading m_name. Also prints
88 * out the message if skyMesh debug is greater than zero.
89 */
90 void intro();
91
92 /**
93 * @short prints out some summary statistics if the skyMesh debug is
94 * greater than 1.
95 */
96 void summary();
97
98 /** @short Returns the SkyMesh object. */
99 SkyMesh *skyMesh() { return m_skyMesh; }
100
101 /**
102 * @short Typically called from within a subclasses constructors.
103 * Adds the trixels covering the outline of lineList to the lineIndex.
104 */
105 void appendLine(const std::shared_ptr<LineList> &lineList);
106
107 void removeLine(const std::shared_ptr<LineList> &lineList);
108
109 /**
110 * @short Typically called from within a subclasses constructors.
111 * Adds the trixels covering the full lineList to the polyIndex.
112 */
113 void appendPoly(const std::shared_ptr<LineList> &lineList);
114
115 /**
116 * @short a convenience method that adds a lineList to both the lineIndex and the polyIndex.
117 */
118 void appendBoth(const std::shared_ptr<LineList> &lineList);
119
120 /**
121 * @short Draws all the lines in m_listList as simple lines in float mode.
122 */
124
125 /**
126 * @short Draws all the lines in m_listList as filled polygons in float
127 * mode.
128 */
130
131 /**
132 * @short Gives the subclasses access to the top of the draw() method.
133 * Typically used for setting the QPen, etc. in the QPainter being
134 * passed in. Defaults to setting a thin white pen.
135 */
136 virtual void preDraw(SkyPainter *skyp);
137
138 /**
139 * @short a callback overridden by NoPrecessIndex so it can use the
140 * drawing code with the non-reverse-precessed mesh buffer.
141 */
142 virtual MeshBufNum_t drawBuffer() { return DRAW_BUF; }
143
144 /**
145 * @short Returns an IndexHash from the SkyMesh that contains the set of
146 * trixels that cover lineList. Overridden by SkipListIndex so it can
147 * pass SkyMesh an IndexHash indicating which line segments should not
148 * be indexed @param lineList contains the list of points to be covered.
149 */
150 virtual const IndexHash &getIndexHash(LineList *lineList);
151
152 /**
153 * @short Also overridden by SkipListIndex.
154 * Controls skipping inside of the draw() routines. The default behavior
155 * is to simply return a null pointer.
156 *
157 * FIXME: I don't think that the SkipListIndex class even exists -- hdevalence
158 */
159 virtual SkipHashList *skipList(LineList *lineList);
160
161 virtual LineListLabel *label() { return nullptr; }
162
163 inline LineListList listList() const { return m_listList; }
164
165 private:
166 QString m_name;
167
168 SkyMesh *m_skyMesh { nullptr };
169 std::unique_ptr<LineListHash> m_lineIndex;
170 std::unique_ptr<LineListHash> m_polyIndex;
171
172 LineListList m_listList;
173
174 QMutex mutex;
175};
Contains almost all the code needed for indexing and drawing and clipping lines and polygons.
void drawLines(SkyPainter *skyp)
Draws all the lines in m_listList as simple lines in float mode.
void intro()
displays a message that we are loading m_name.
void appendBoth(const std::shared_ptr< LineList > &lineList)
a convenience method that adds a lineList to both the lineIndex and the polyIndex.
virtual void preDraw(SkyPainter *skyp)
Gives the subclasses access to the top of the draw() method.
virtual void JITupdate(LineList *lineList)
this is called from within the draw routines when the updateID of the lineList is stale.
SkyMesh * skyMesh()
Returns the SkyMesh object.
void summary()
prints out some summary statistics if the skyMesh debug is greater than 1.
virtual MeshBufNum_t drawBuffer()
a callback overridden by NoPrecessIndex so it can use the drawing code with the non-reverse-precessed...
void draw(SkyPainter *skyp) override
The top level draw routine.
void appendPoly(const std::shared_ptr< LineList > &lineList)
Typically called from within a subclasses constructors.
QString name() const
retrieve name of object
void appendLine(const std::shared_ptr< LineList > &lineList)
Typically called from within a subclasses constructors.
void drawFilled(SkyPainter *skyp)
Draws all the lines in m_listList as filled polygons in float mode.
void reindexLines()
as the name says, recreates the lineIndex using the LineLists in the previous index.
virtual SkipHashList * skipList(LineList *lineList)
Also overridden by SkipListIndex.
LineListIndex(SkyComposite *parent, const QString &name="")
Constructor Simply set the internal skyMesh, parent, and name.
virtual const IndexHash & getIndexHash(LineList *lineList)
Returns an IndexHash from the SkyMesh that contains the set of trixels that cover lineList.
A simple data container used by LineListIndex.
Definition linelist.h:25
Class that handles lines (Constellation lines and boundaries and both coordinate grids) in SkyMapLite...
Definition linesitem.h:38
MeshIterator is a very lightweight class used to iterate over the result set of an HTMesh intersectio...
SkyComponent represents an object on the sky map.
SkyComposite * parent()
SkyComposite is a kind of container class for SkyComponent objects.
Provides an interface to the Hierarchical Triangular Mesh (HTM) library written by A.
Definition skymesh.h:74
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.