1 /*
2  SPDX-FileCopyrightText: 2010 Henry de Valence <[email protected]>
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
7 #pragma once
9 #include "ksasteroid.h"
10 #include "skypainter.h"
11 #include "config-kstars.h"
13 #include <QColor>
14 #include <QMap>
16 class Projector;
17 class QWidget;
18 class QSize;
19 class QMessageBox;
20 class HIPSRenderer;
21 class TerrainRenderer;
22 class ImageOverlay;
23 class KSEarthShadow;
25 /**
26  * @short The QPainter-based painting backend.
27  * This class implements the SkyPainter interface using a QPainter.
28  * For documentation, @see SkyPainter.
29  */
30 class SkyQPainter : public SkyPainter, public QPainter
31 {
32  public:
33  /** Release the image cache */
34  static void releaseImageCache();
36  /**
37  * @short Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canvas dimensions
38  * @param pd the painting device. Cannot be 0
39  * @param canvasSize the size of the canvas
40  */
41  SkyQPainter(QPaintDevice *pd, const QSize &canvasSize);
43  /**
44  * @short Creates a SkyQPainter with the given QPaintDevice and given canvas size
45  * @param pd the painting device. Cannot be 0
46  */
47  explicit SkyQPainter(QPaintDevice *pd);
49  /**
50  * @short Creates a SkyQPainter given a QWidget and an optional QPaintDevice.
51  * @param widget the QWidget that provides the canvas size, and also the paint device unless @p pd is specified
52  * @param pd the painting device. If 0, then @p widget will be used.
53  */
54  explicit SkyQPainter(QWidget *widget, QPaintDevice *pd = nullptr);
56  ~SkyQPainter() override;
58  void setPaintDevice(QPaintDevice *pd)
59  {
60  m_pd = pd;
61  }
62  void setPen(const QPen &pen) override;
63  void setBrush(const QBrush &brush) override;
65  /**
66  * @param vectorStars Draw stars as vector graphics whenever possible.
67  * @note Drawing stars as vectors is slower, but is better when saving .svg files. Set to true only when you are drawing on a canvas where speed doesn't matter. Definitely not when drawing on the SkyMap.
68  */
69  inline void setVectorStars(bool vectorStars)
70  {
71  m_vectorStars = vectorStars;
72  }
73  inline bool getVectorStars() const
74  {
75  return m_vectorStars;
76  }
78  void begin() override;
79  void end() override;
81  /** Recalculates the star pixmaps. */
82  static void initStarImages();
84  // Sky drawing functions
85  void drawSkyBackground() override;
86  void drawSkyLine(SkyPoint *a, SkyPoint *b) override;
87  void drawSkyPolyline(LineList *list, SkipHashList *skipList = nullptr,
88  LineListLabel *label = nullptr) override;
89  void drawSkyPolygon(LineList *list, bool forceClip = true) override;
90  bool drawPointSource(const SkyPoint *loc, float mag, char sp = 'A') override;
91  bool drawCatalogObject(const CatalogObject &obj) override;
92  void drawCatalogObjectImage(const QPointF &pos, const CatalogObject &obj,
93  float positionAngle);
94  bool drawPlanet(KSPlanetBase *planet) override;
95  bool drawEarthShadow(KSEarthShadow *shadow) override;
96  void drawObservingList(const QList<SkyObject *> &obs) override;
97  void drawFlags() override;
98  void drawHorizon(bool filled, SkyPoint *labelPoint = nullptr,
99  bool *drawLabel = nullptr) override;
100  bool drawSatellite(Satellite *sat) override;
101  virtual void drawDeepSkySymbol(const QPointF &pos, int type, float size, float e,
102  float positionAngle);
103  bool drawSupernova(Supernova *sup) override;
104  bool drawComet(KSComet *com) override;
105  bool drawAsteroid(KSAsteroid *ast) override;
106  /// This function exists so that we can draw other objects (e.g., planets) as point sources.
107  virtual void drawPointSource(const QPointF &pos, float size, char sp = 'A');
108  bool drawConstellationArtImage(ConstellationsArt *obj) override;
109 #ifdef HAVE_INDI
110  bool drawMosaicPanel(MosaicTiles *obj) override;
111 #endif
112  bool drawHips(bool useCache = false) override;
113  bool drawTerrain(bool useCache = false) override;
114  bool drawImageOverlay(const QList<ImageOverlay> *imageOverlays, bool useCache = false) override;
116  private:
117  QPaintDevice *m_pd{ nullptr };
118  const Projector *m_proj{ nullptr };
119  bool m_vectorStars{ false };
120  HIPSRenderer *m_hipsRender{ nullptr };
121  TerrainRenderer *m_terrainRender{ nullptr };
122  QSize m_size;
123  QScopedPointer<QImage> m_HiPSImage;
124  static int starColorMode;
125  static QColor m_starColor;
126  static QMap<char, QColor> ColorMap;
127 };
static void releaseImageCache()
Release the image cache.
Definition: skyqpainter.cpp:95
void begin() override
Begin painting.
The QPainter-based painting backend.
Definition: skyqpainter.h:30
void drawFlags() override
Draw flags.
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
static void initStarImages()
Recalculates the star pixmaps.
void drawSkyPolyline(LineList *list, SkipHashList *skipList=nullptr, LineListLabel *label=nullptr) override
Draw a polyline in the sky.
void drawSkyBackground() override
Draw the sky background.
bool drawPointSource(const SkyPoint *loc, float mag, char sp='A') override
Draw a point source (e.g., a star).
void setPen(const QPen &pen) override
Set the pen of the painter.
A subclass of KSPlanetBase that implements asteroids.
Definition: ksasteroid.h:41
A subclass of KSPlanetBase that implements comets.
Definition: kscomet.h:43
bool drawSupernova(Supernova *sup) override
Draw a Supernova.
const QPen & pen() const const
bool drawPlanet(KSPlanetBase *planet) override
Draw a planet.
void drawSkyPolygon(LineList *list, bool forceClip=true) override
Draw a polygon in the sky.
bool drawComet(KSComet *com) override
Draw a comet in the sky.
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
Definition: ksearthshadow.h:27
bool drawEarthShadow(KSEarthShadow *shadow) override
Draw the earths shadow on the moon (red-ish)
bool drawTerrain(bool useCache=false) override
drawTerrain Draw the Terrain
void drawObservingList(const QList< SkyObject * > &obs) override
Draw the symbols for the observing list.
bool drawImageOverlay(const QList< ImageOverlay > *imageOverlays, bool useCache=false) override
drawImageOverlay Draws a user-supplied image onto the skymap
Draws things on the sky, without regard to backend.
Definition: skypainter.h:39
const QBrush & brush() const const
SkyQPainter(QPaintDevice *pd, const QSize &canvasSize)
Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canv...
void setVectorStars(bool vectorStars)
Definition: skyqpainter.h:69
void drawSkyLine(SkyPoint *a, SkyPoint *b) override
Draw a line between points in the sky.
bool drawConstellationArtImage(ConstellationsArt *obj) override
Draw a ConstellationsArt object.
bool drawAsteroid(KSAsteroid *ast) override
Draw an asteroid in the sky.
void end() override
End and finalize painting.
bool drawSatellite(Satellite *sat) override
Draw a satellite.
bool drawCatalogObject(const CatalogObject &obj) override
Draw a deep sky object (loaded from the new implementation)
Information about a ConstellationsArt object. This class represents a constellation image.
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
Definition: catalogobject.h:40
bool drawHips(bool useCache=false) override
drawMosaicPanel Draws mosaic panel in planning or operation mode.
void setBrush(const QBrush &brush) override
Set the brush of the painter.
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 04:02:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.