Kstars

skymapdrawabstract.h
1/*
2 SPDX-FileCopyrightText: 2010 Akarsh Simha <akarsh.simha@kdemail.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef SKYMAPDRAWABSTRACT_H_
8#define SKYMAPDRAWABSTRACT_H_
9
10#include "kstarsdata.h"
11#include <QPainter>
12#include <QPaintEvent>
13#include <QPaintDevice>
14
15class SkyMap;
16class SkyQPainter;
17
18/**
19 *@short This class defines the methods that both rendering engines
20 * (GLPainter and QPainter) must implement. This also allows us to add
21 * more rendering engines if required.
22 *@version 1.0
23 *@author Akarsh Simha <akarsh.simha@kdemail.net>
24 */
25
26// In summary, this is a class created by stealing all the
27// drawing-related methods from the old SkyMap class
28
30{
31 protected:
32 /**
33 *@short Virtual Destructor
34 */
35 virtual ~SkyMapDrawAbstract() = default;
36
37 public:
38 /**
39 *@short Constructor that sets data and m_SkyMap, and initializes
40 * the FPS counters.
41 */
42 explicit SkyMapDrawAbstract(SkyMap *sm);
43
44 // *********************** "IMPURE" VIRTUAL METHODS ******************* //
45 // NOTE: The following methods are implemented using native
46 // QPainter in both cases. So it's virtual, but not pure virtual
47
48 /**Draw the overlays on top of the sky map. These include the infoboxes,
49 *field-of-view indicator, telescope symbols, zoom box and any other
50 *user-interaction graphics.
51 *
52 *The overlays can be updated rapidly, without having to recompute the entire SkyMap.
53 *The stored Sky image is simply blitted onto the SkyMap widget, and then we call
54 *drawOverlays() to refresh the overlays.
55 *@param p pointer to the Sky pixmap
56 *@param drawFov determines if the FOV should be drawn
57 */
58 void drawOverlays(QPainter &p, bool drawFov = true);
59
60 /**Draw symbols at the position of each Telescope currently being controlled by KStars.
61 *@note The shape of the Telescope symbol is currently a hard-coded bullseye.
62 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
63 */
65
66 /**Draw dome slits for connected domes
67 *@param psky reference to the QPainter on which to draw
68 */
69 void drawDomeSlits(QPainter &psky);
70
71 /**Draw FOV of solved image in Ekos Alignment Module
72 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
73 */
74 void drawSolverFOV(QPainter &psky);
75
76 /**
77 * @short Draw north and zenith arrows to show the orientation while rotating the sky map
78 * @param p reference to the QPainter on which to draw (this should be the sky map)
79 */
81
82 /**
83 *@short Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode.
84 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
85 */
86 void drawZoomBox(QPainter &psky);
87
88 /**Draw a dashed line from the Angular-Ruler start point to the current mouse cursor,
89 *when in Angular-Ruler mode.
90 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
91 */
92 void drawAngleRuler(QPainter &psky);
93
94 /** @short Draw the current Sky map to a pixmap which is to be printed or exported to a file.
95 *
96 *@param pd pointer to the QPaintDevice on which to draw.
97 *@param scale defines if the Sky map should be scaled.
98 *@see KStars::slotExportImage()
99 *@see KStars::slotPrint()
100 */
101 void exportSkyImage(QPaintDevice *pd, bool scale = false);
102
103 /** @short Draw the current Sky map using passed SkyQPainter instance. Required when
104 * used QPaintDevice doesn't support drawing using multiple painters (e.g. QSvgGenerator
105 * which generates broken SVG output when more than one QPainter subclass is used).
106 * Passed painter should already be initialized to draw on selected QPaintDevice subclass
107 * using begin() and it won't be ended [end()] by this method.
108 *@param painter pointer to the SkyQPainter already set up to paint on selected QPaintDevice subclass.
109 *@param scale should sky image be scaled to fit used QPaintDevice?
110 */
111 void exportSkyImage(SkyQPainter *painter, bool scale = false);
112
113 /** @short Draw "user labels". User labels are name labels attached to objects manually with
114 * the right-click popup menu. Also adds a label to the FocusObject if the Option UseAutoLabel
115 * is true.
116 * @param labelObjects QList of pointers to the objects which need labels (excluding the centered object)
117 * @note the labelObjects list is managed by the SkyMapComponents class
118 */
119 void drawObjectLabels(QList<SkyObject *> &labelObjects);
120
121 /**
122 *@return true if a draw is in progress or is locked, false otherwise. This is just the value of m_DrawLock
123 */
124 static inline bool drawLock()
125 {
126 return m_DrawLock;
127 }
128
129 /**
130 *@short Acquire / release a draw lock. This prevents other drawing from happening
131 */
132 static void setDrawLock(bool state);
133
134 // *********************** PURE VIRTUAL METHODS ******************* //
135 // NOTE: The following methods differ between GL and QPainter backends
136 // Thus, they are pure virtual and must be implemented by the subclass
137
138 protected:
139 /**
140 *@short Overridden paintEvent method. Must be implemented by
141 * subclasses to draw the SkyMap. (This method is pure
142 * virtual)
143 */
144 virtual void paintEvent(QPaintEvent *e) = 0;
145
146 /*
147 *NOTE:
148 * Depending on whether the implementation of this class is a
149 * GL-backend, it may need to implement these methods:
150 * virtual void resizeGL(int width, int height);
151 * virtual void initializeGL();
152 * So we will not even bother defining them here.
153 * They must be taken care of in the subclasses
154 */
155
156 KStarsData *m_KStarsData;
157 SkyMap *m_SkyMap;
158 static bool m_DrawLock;
159
160 /** Calculate FPS and dump result to stderr using qDebug */
161 //void calculateFPS();
162 private:
163 // int m_framecount; // To count FPS
164 //QTime m_fpstime;
165};
166
167#endif
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
static void setDrawLock(bool state)
Acquire / release a draw lock.
void drawOrientationArrows(QPainter &p)
Draw north and zenith arrows to show the orientation while rotating the sky map.
void drawZoomBox(QPainter &psky)
Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode.
void drawTelescopeSymbols(QPainter &psky)
Draw symbols at the position of each Telescope currently being controlled by KStars.
void drawAngleRuler(QPainter &psky)
Draw a dashed line from the Angular-Ruler start point to the current mouse cursor,...
void drawSolverFOV(QPainter &psky)
Draw FOV of solved image in Ekos Alignment Module.
void drawObjectLabels(QList< SkyObject * > &labelObjects)
Draw "user labels".
void exportSkyImage(QPaintDevice *pd, bool scale=false)
Draw the current Sky map to a pixmap which is to be printed or exported to a file.
void drawOverlays(QPainter &p, bool drawFov=true)
Draw the overlays on top of the sky map.
virtual void paintEvent(QPaintEvent *e)=0
Overridden paintEvent method.
void drawDomeSlits(QPainter &psky)
Draw dome slits for connected domes.
SkyMapDrawAbstract(SkyMap *sm)
Constructor that sets data and m_SkyMap, and initializes the FPS counters.
virtual ~SkyMapDrawAbstract()=default
Virtual Destructor.
This is the canvas on which the sky is painted.
Definition skymap.h:54
The QPainter-based painting backend.
Definition skyqpainter.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:53:02 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.