Warning, file /education/kstars/kstars/skymapdrawabstract.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2010 Akarsh Simha <akarsh.simha@kdemail.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef SKYMAPDRAWABSTRACT_H_ 0008 #define SKYMAPDRAWABSTRACT_H_ 0009 0010 #include "kstarsdata.h" 0011 #include <QPainter> 0012 #include <QPaintEvent> 0013 #include <QPaintDevice> 0014 0015 class SkyMap; 0016 class SkyQPainter; 0017 0018 /** 0019 *@short This class defines the methods that both rendering engines 0020 * (GLPainter and QPainter) must implement. This also allows us to add 0021 * more rendering engines if required. 0022 *@version 1.0 0023 *@author Akarsh Simha <akarsh.simha@kdemail.net> 0024 */ 0025 0026 // In summary, this is a class created by stealing all the 0027 // drawing-related methods from the old SkyMap class 0028 0029 class SkyMapDrawAbstract 0030 { 0031 protected: 0032 /** 0033 *@short Virtual Destructor 0034 */ 0035 virtual ~SkyMapDrawAbstract() = default; 0036 0037 public: 0038 /** 0039 *@short Constructor that sets data and m_SkyMap, and initializes 0040 * the FPS counters. 0041 */ 0042 explicit SkyMapDrawAbstract(SkyMap *sm); 0043 0044 // *********************** "IMPURE" VIRTUAL METHODS ******************* // 0045 // NOTE: The following methods are implemented using native 0046 // QPainter in both cases. So it's virtual, but not pure virtual 0047 0048 /**Draw the overlays on top of the sky map. These include the infoboxes, 0049 *field-of-view indicator, telescope symbols, zoom box and any other 0050 *user-interaction graphics. 0051 * 0052 *The overlays can be updated rapidly, without having to recompute the entire SkyMap. 0053 *The stored Sky image is simply blitted onto the SkyMap widget, and then we call 0054 *drawOverlays() to refresh the overlays. 0055 *@param p pointer to the Sky pixmap 0056 *@param drawFov determines if the FOV should be drawn 0057 */ 0058 void drawOverlays(QPainter &p, bool drawFov = true); 0059 0060 /**Draw symbols at the position of each Telescope currently being controlled by KStars. 0061 *@note The shape of the Telescope symbol is currently a hard-coded bullseye. 0062 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). 0063 */ 0064 void drawTelescopeSymbols(QPainter &psky); 0065 0066 /**Draw FOV of solved image in Ekos Alignment Module 0067 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). 0068 */ 0069 void drawSolverFOV(QPainter &psky); 0070 0071 /** 0072 *@short Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode. 0073 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). 0074 */ 0075 void drawZoomBox(QPainter &psky); 0076 0077 /**Draw a dashed line from the Angular-Ruler start point to the current mouse cursor, 0078 *when in Angular-Ruler mode. 0079 *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). 0080 */ 0081 void drawAngleRuler(QPainter &psky); 0082 0083 /** @short Draw the current Sky map to a pixmap which is to be printed or exported to a file. 0084 * 0085 *@param pd pointer to the QPaintDevice on which to draw. 0086 *@param scale defines if the Sky map should be scaled. 0087 *@see KStars::slotExportImage() 0088 *@see KStars::slotPrint() 0089 */ 0090 void exportSkyImage(QPaintDevice *pd, bool scale = false); 0091 0092 /** @short Draw the current Sky map using passed SkyQPainter instance. Required when 0093 * used QPaintDevice doesn't support drawing using multiple painters (e.g. QSvgGenerator 0094 * which generates broken SVG output when more than one QPainter subclass is used). 0095 * Passed painter should already be initialized to draw on selected QPaintDevice subclass 0096 * using begin() and it won't be ended [end()] by this method. 0097 *@param painter pointer to the SkyQPainter already set up to paint on selected QPaintDevice subclass. 0098 *@param scale should sky image be scaled to fit used QPaintDevice? 0099 */ 0100 void exportSkyImage(SkyQPainter *painter, bool scale = false); 0101 0102 /** @short Draw "user labels". User labels are name labels attached to objects manually with 0103 * the right-click popup menu. Also adds a label to the FocusObject if the Option UseAutoLabel 0104 * is true. 0105 * @param labelObjects QList of pointers to the objects which need labels (excluding the centered object) 0106 * @note the labelObjects list is managed by the SkyMapComponents class 0107 */ 0108 void drawObjectLabels(QList<SkyObject *> &labelObjects); 0109 0110 /** 0111 *@return true if a draw is in progress or is locked, false otherwise. This is just the value of m_DrawLock 0112 */ 0113 static inline bool drawLock() { return m_DrawLock; } 0114 0115 /** 0116 *@short Acquire / release a draw lock. This prevents other drawing from happening 0117 */ 0118 static void setDrawLock(bool state); 0119 0120 // *********************** PURE VIRTUAL METHODS ******************* // 0121 // NOTE: The following methods differ between GL and QPainter backends 0122 // Thus, they are pure virtual and must be implemented by the subclass 0123 0124 protected: 0125 /** 0126 *@short Overridden paintEvent method. Must be implemented by 0127 * subclasses to draw the SkyMap. (This method is pure 0128 * virtual) 0129 */ 0130 virtual void paintEvent(QPaintEvent *e) = 0; 0131 0132 /* 0133 *NOTE: 0134 * Depending on whether the implementation of this class is a 0135 * GL-backend, it may need to implement these methods: 0136 * virtual void resizeGL(int width, int height); 0137 * virtual void initializeGL(); 0138 * So we will not even bother defining them here. 0139 * They must be taken care of in the subclasses 0140 */ 0141 0142 KStarsData *m_KStarsData; 0143 SkyMap *m_SkyMap; 0144 static bool m_DrawLock; 0145 0146 /** Calculate FPS and dump result to stderr using qDebug */ 0147 //void calculateFPS(); 0148 private: 0149 // int m_framecount; // To count FPS 0150 //QTime m_fpstime; 0151 }; 0152 0153 #endif