Kstars

skypainter.h
1/*
2 SkyPainter: class for painting onto the sky for KStars
3 SPDX-FileCopyrightText: 2010 Henry de Valence <hdevalence@gmail.com>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "skycomponents/typedef.h"
11#include "config-kstars.h"
12
13#include <QList>
14#include <QPainter>
15
17class DeepSkyObject;
18class KSComet;
19class KSAsteroid;
20class KSPlanetBase;
21class KSEarthShadow;
22class LineList;
23class LineListLabel;
24class Satellite;
25class MosaicTiles;
26class SkipHashList;
27class SkyMap;
28class SkyObject;
29class SkyPoint;
30class Supernova;
31class CatalogObject;
32class ImageOverlay;
33
34/**
35 * @short Draws things on the sky, without regard to backend.
36 * This class serves as an interface to draw objects onto the sky without
37 * worrying about whether we are using a QPainter or OpenGL.
38 */
40{
41 public:
42 SkyPainter();
43
44 virtual ~SkyPainter() = default;
45
46 /** @short Set the pen of the painter **/
47 virtual void setPen(const QPen &pen) = 0;
48
49 /** @short Set the brush of the painter **/
50 virtual void setBrush(const QBrush &brush) = 0;
51
52 //FIXME: find a better way to do this.
53 void setSizeMagLimit(float sizeMagLim);
54
55 /**
56 * Begin painting.
57 * @note this function <b>must</b> be called before painting anything.
58 * @see end()
59 */
60 virtual void begin() = 0;
61
62 /**
63 * End and finalize painting.
64 * @note this function <b>must</b> be called after painting anything.
65 * @note it is not guaranteed that anything will actually be drawn until end() is called.
66 * @see begin();
67 */
68 virtual void end() = 0;
69
70 ////////////////////////////////////
71 // //
72 // SKY DRAWING FUNCTIONS: //
73 // //
74 ////////////////////////////////////
75
76 /** @short Draw the sky background */
77 virtual void drawSkyBackground() = 0;
78
79 /**
80 * @short Draw a line between points in the sky.
81 * @param a the first point
82 * @param b the second point
83 * @note this function will skip lines not on screen and clip lines
84 * that are only partially visible.
85 */
86 virtual void drawSkyLine(SkyPoint *a, SkyPoint *b) = 0;
87
88 /**
89 * @short Draw a polyline in the sky.
90 * @param list a list of points in the sky
91 * @param skipList a SkipList object used to control skipping line segments
92 * @param label a pointer to the label for this line
93 * @note it's more efficient to use this than repeated calls to drawSkyLine(),
94 * because it avoids an extra points->size() -2 projections.
95 */
96 virtual void drawSkyPolyline(LineList *list, SkipHashList *skipList = nullptr,
97 LineListLabel *label = nullptr) = 0;
98
99 /**
100 * @short Draw a polygon in the sky.
101 * @param list a list of points in the sky
102 * @param forceClip If true (default), it enforces clipping of the polygon, otherwise, it draws the
103 * complete polygen without running any boundary checks.
104 * @see drawSkyPolyline()
105 */
106 virtual void drawSkyPolygon(LineList *list, bool forceClip = true) = 0;
107
108 /**
109 * @short Draw a comet in the sky.
110 * @param com comet to draw
111 * @return true if a comet was drawn
112 */
113 virtual bool drawComet(KSComet *com) = 0;
114
115 /**
116 * @short Draw an asteroid in the sky.
117 * @param ast asteroid to draw
118 * @return true if a asteroid was drawn
119 */
120 virtual bool drawAsteroid(KSAsteroid *ast) = 0;
121
122 /**
123 * @short Draw a point source (e.g., a star).
124 * @param loc the location of the source in the sky
125 * @param mag the magnitude of the source
126 * @param sp the spectral class of the source
127 * @return true if a source was drawn
128 */
129 virtual bool drawPointSource(const SkyPoint *loc, float mag, char sp = 'A') = 0;
130
131 /**
132 * @short Draw a deep sky object (loaded from the new implementation)
133 * @param obj the object to draw
134 * @param drawImage if true, try to draw the image of the object
135 * @return true if it was drawn
136 */
137 virtual bool drawCatalogObject(const CatalogObject &obj) = 0;
138
139 /**
140 * @short Draw a planet
141 * @param planet the planet to draw
142 * @return true if it was drawn
143 */
144 virtual bool drawPlanet(KSPlanetBase *planet) = 0;
145
146 /**
147 * @short Draw the earths shadow on the moon (red-ish)
148 * @param shadow the shadow to draw
149 * @return true if it was drawn
150 */
151 virtual bool drawEarthShadow(KSEarthShadow *shadow) = 0;
152
153 /**
154 * @short Draw the symbols for the observing list
155 * @param obs the observing list
156 */
157 virtual void drawObservingList(const QList<SkyObject *> &obs) = 0;
158
159 /** @short Draw flags */
160 virtual void drawFlags() = 0;
161
162 /** @short Draw a satellite */
163 virtual bool drawSatellite(Satellite *sat) = 0;
164
165 /** @short Draw a Supernova */
166 virtual bool drawSupernova(Supernova *sup) = 0;
167
168 virtual void drawHorizon(bool filled, SkyPoint *labelPoint = nullptr,
169 bool *drawLabel = nullptr) = 0;
170
171 /** @short Get the width of a star of magnitude mag */
172 float starWidth(float mag) const;
173
174 /**
175 * @short Draw a ConstellationsArt object
176 * @param obj the object to draw
177 * @return true if it was drawn
178 */
180
181 /**
182 * @brief drawMosaicPanel Draws mosaic panel in planning or operation mode.
183 * @return true if it was drawn
184 */
185#ifdef HAVE_INDI
186 virtual bool drawMosaicPanel(MosaicTiles *obj) = 0;
187#endif
188 /**
189 * @brief drawHips Draw HIPS all sky catalog
190 * @param useCache if True, try to re-use last generated image instead of rendering a new image.
191 * @return true if it was drawn
192 */
193 virtual bool drawHips(bool useCache = false) = 0;
194
195 /**
196 * @brief drawTerrain Draw the Terrain
197 * @param useCache if True, try to re-use last generated image instead of rendering a new image.
198 * @return true if it was drawn
199 */
200 virtual bool drawTerrain(bool useCache = false) = 0;
201
202 /**
203 * @brief drawImageOverlay Draws a user-supplied image onto the skymap
204 * @param useCache if True, try to re-use last generated image instead of rendering a new image.
205 * @return true if it was drawn
206 */
207 virtual bool drawImageOverlay(const QList<ImageOverlay> *imageOverlays, bool useCache = false) = 0;
208
209 private:
210 float m_sizeMagLim{ 10.0f };
211};
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
Information about a ConstellationsArt object.
A subclass of KSPlanetBase that implements asteroids.
Definition ksasteroid.h:42
A subclass of KSPlanetBase that implements comets.
Definition kscomet.h:44
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
A subclass of TrailObject that provides additional information needed for most solar system objects.
A simple data container used by LineListIndex.
Definition linelist.h:25
Represents an artificial satellites.
Definition satellite.h:23
This is the canvas on which the sky is painted.
Definition skymap.h:54
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
virtual bool drawImageOverlay(const QList< ImageOverlay > *imageOverlays, bool useCache=false)=0
drawImageOverlay Draws a user-supplied image onto the skymap
virtual bool drawConstellationArtImage(ConstellationsArt *obj)=0
Draw a ConstellationsArt object.
virtual void drawSkyPolyline(LineList *list, SkipHashList *skipList=nullptr, LineListLabel *label=nullptr)=0
Draw a polyline in the sky.
virtual bool drawPlanet(KSPlanetBase *planet)=0
Draw a planet.
virtual bool drawSupernova(Supernova *sup)=0
Draw a Supernova.
virtual bool drawCatalogObject(const CatalogObject &obj)=0
Draw a deep sky object (loaded from the new implementation)
virtual void drawObservingList(const QList< SkyObject * > &obs)=0
Draw the symbols for the observing list.
virtual bool drawSatellite(Satellite *sat)=0
Draw a satellite.
virtual bool drawHips(bool useCache=false)=0
drawMosaicPanel Draws mosaic panel in planning or operation mode.
virtual void end()=0
End and finalize painting.
virtual void drawSkyPolygon(LineList *list, bool forceClip=true)=0
Draw a polygon in the sky.
virtual bool drawAsteroid(KSAsteroid *ast)=0
Draw an asteroid in the sky.
virtual bool drawComet(KSComet *com)=0
Draw a comet in the sky.
virtual bool drawEarthShadow(KSEarthShadow *shadow)=0
Draw the earths shadow on the moon (red-ish)
virtual void begin()=0
Begin painting.
virtual void drawSkyLine(SkyPoint *a, SkyPoint *b)=0
Draw a line between points in the sky.
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
virtual void drawFlags()=0
Draw flags.
virtual bool drawPointSource(const SkyPoint *loc, float mag, char sp='A')=0
Draw a point source (e.g., a star).
virtual void drawSkyBackground()=0
Draw the sky background.
float starWidth(float mag) const
Get the width of a star of magnitude mag.
virtual bool drawTerrain(bool useCache=false)=0
drawTerrain Draw the Terrain
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
The sky coordinates of a point in the sky.
Definition skypoint.h:45
Represents the supernova object.
Definition supernova.h:34
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.