Kstars

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

KDE's Doxygen guidelines are available online.