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 FOV of solved image in Ekos Alignment Module
67 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
68 */
69 void drawSolverFOV(QPainter &psky);
70
71 /**
72 * @short Draw north and zenith arrows to show the orientation while rotating the sky map
73 * @param p reference to the QPainter on which to draw (this should be the sky map)
74 */
76
77 /**
78 *@short Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode.
79 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
80 */
81 void drawZoomBox(QPainter &psky);
82
83 /**Draw a dashed line from the Angular-Ruler start point to the current mouse cursor,
84 *when in Angular-Ruler mode.
85 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap).
86 */
87 void drawAngleRuler(QPainter &psky);
88
89 /** @short Draw the current Sky map to a pixmap which is to be printed or exported to a file.
90 *
91 *@param pd pointer to the QPaintDevice on which to draw.
92 *@param scale defines if the Sky map should be scaled.
93 *@see KStars::slotExportImage()
94 *@see KStars::slotPrint()
95 */
96 void exportSkyImage(QPaintDevice *pd, bool scale = false);
97
98 /** @short Draw the current Sky map using passed SkyQPainter instance. Required when
99 * used QPaintDevice doesn't support drawing using multiple painters (e.g. QSvgGenerator
100 * which generates broken SVG output when more than one QPainter subclass is used).
101 * Passed painter should already be initialized to draw on selected QPaintDevice subclass
102 * using begin() and it won't be ended [end()] by this method.
103 *@param painter pointer to the SkyQPainter already set up to paint on selected QPaintDevice subclass.
104 *@param scale should sky image be scaled to fit used QPaintDevice?
105 */
106 void exportSkyImage(SkyQPainter *painter, bool scale = false);
107
108 /** @short Draw "user labels". User labels are name labels attached to objects manually with
109 * the right-click popup menu. Also adds a label to the FocusObject if the Option UseAutoLabel
110 * is true.
111 * @param labelObjects QList of pointers to the objects which need labels (excluding the centered object)
112 * @note the labelObjects list is managed by the SkyMapComponents class
113 */
114 void drawObjectLabels(QList<SkyObject *> &labelObjects);
115
116 /**
117 *@return true if a draw is in progress or is locked, false otherwise. This is just the value of m_DrawLock
118 */
119 static inline bool drawLock() { return m_DrawLock; }
120
121 /**
122 *@short Acquire / release a draw lock. This prevents other drawing from happening
123 */
124 static void setDrawLock(bool state);
125
126 // *********************** PURE VIRTUAL METHODS ******************* //
127 // NOTE: The following methods differ between GL and QPainter backends
128 // Thus, they are pure virtual and must be implemented by the subclass
129
130 protected:
131 /**
132 *@short Overridden paintEvent method. Must be implemented by
133 * subclasses to draw the SkyMap. (This method is pure
134 * virtual)
135 */
136 virtual void paintEvent(QPaintEvent *e) = 0;
137
138 /*
139 *NOTE:
140 * Depending on whether the implementation of this class is a
141 * GL-backend, it may need to implement these methods:
142 * virtual void resizeGL(int width, int height);
143 * virtual void initializeGL();
144 * So we will not even bother defining them here.
145 * They must be taken care of in the subclasses
146 */
147
148 KStarsData *m_KStarsData;
149 SkyMap *m_SkyMap;
150 static bool m_DrawLock;
151
152 /** Calculate FPS and dump result to stderr using qDebug */
153 //void calculateFPS();
154 private:
155 // int m_framecount; // To count FPS
156 //QTime m_fpstime;
157};
158
159#endif
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
This class defines the methods that both rendering engines (GLPainter and QPainter) must implement.
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.
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-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.