Kstars

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

KDE's Doxygen guidelines are available online.