Kstars

skyqpainter.h
1 /*
2  SPDX-FileCopyrightText: 2010 Henry de Valence <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "skypainter.h"
10 #include "config-kstars.h"
11 
12 #include <QColor>
13 #include <QMap>
14 
15 class Projector;
16 class QWidget;
17 class QSize;
18 class QMessageBox;
19 class HIPSRenderer;
20 class TerrainRenderer;
21 class KSEarthShadow;
22 
23 /**
24  * @short The QPainter-based painting backend.
25  * This class implements the SkyPainter interface using a QPainter.
26  * For documentation, @see SkyPainter.
27  */
28 class SkyQPainter : public SkyPainter, public QPainter
29 {
30  public:
31  /** Release the image cache */
32  static void releaseImageCache();
33 
34  /**
35  * @short Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canvas dimensions
36  * @param pd the painting device. Cannot be 0
37  * @param canvasSize the size of the canvas
38  */
39  SkyQPainter(QPaintDevice *pd, const QSize &canvasSize);
40 
41  /**
42  * @short Creates a SkyQPainter with the given QPaintDevice and given canvas size
43  * @param pd the painting device. Cannot be 0
44  */
45  explicit SkyQPainter(QPaintDevice *pd);
46 
47  /**
48  * @short Creates a SkyQPainter given a QWidget and an optional QPaintDevice.
49  * @param widget the QWidget that provides the canvas size, and also the paint device unless @p pd is specified
50  * @param pd the painting device. If 0, then @p widget will be used.
51  */
52  explicit SkyQPainter(QWidget *widget, QPaintDevice *pd = nullptr);
53 
54  ~SkyQPainter() override;
55 
56  void setPaintDevice(QPaintDevice *pd)
57  {
58  m_pd = pd;
59  }
60  void setPen(const QPen &pen) override;
61  void setBrush(const QBrush &brush) override;
62 
63  /**
64  * @param vectorStars Draw stars as vector graphics whenever possible.
65  * @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.
66  */
67  inline void setVectorStars(bool vectorStars)
68  {
69  m_vectorStars = vectorStars;
70  }
71  inline bool getVectorStars() const
72  {
73  return m_vectorStars;
74  }
75 
76  void begin() override;
77  void end() override;
78 
79  /** Recalculates the star pixmaps. */
80  static void initStarImages();
81 
82  // Sky drawing functions
83  void drawSkyBackground() override;
84  void drawSkyLine(SkyPoint *a, SkyPoint *b) override;
85  void drawSkyPolyline(LineList *list, SkipHashList *skipList = nullptr,
86  LineListLabel *label = nullptr) override;
87  void drawSkyPolygon(LineList *list, bool forceClip = true) override;
88  bool drawPointSource(const SkyPoint *loc, float mag, char sp = 'A') override;
89  bool drawCatalogObject(const CatalogObject &obj) override;
90  void drawCatalogObjectImage(const QPointF &pos, const CatalogObject &obj,
91  float positionAngle);
92  bool drawPlanet(KSPlanetBase *planet) override;
93  bool drawEarthShadow(KSEarthShadow *shadow) override;
94  void drawObservingList(const QList<SkyObject *> &obs) override;
95  void drawFlags() override;
96  void drawHorizon(bool filled, SkyPoint *labelPoint = nullptr,
97  bool *drawLabel = nullptr) override;
98  bool drawSatellite(Satellite *sat) override;
99  virtual void drawDeepSkySymbol(const QPointF &pos, int type, float size, float e,
100  float positionAngle);
101  bool drawSupernova(Supernova *sup) override;
102  bool drawComet(KSComet *com) override;
103  /// This function exists so that we can draw other objects (e.g., planets) as point sources.
104  virtual void drawPointSource(const QPointF &pos, float size, char sp = 'A');
105  bool drawConstellationArtImage(ConstellationsArt *obj) override;
106 #ifdef HAVE_INDI
107  bool drawMosaicPanel(MosaicTiles *obj) override;
108 #endif
109  bool drawHips(bool useCache = false) override;
110  bool drawTerrain(bool useCache = false) override;
111 
112  private:
113  QPaintDevice *m_pd{ nullptr };
114  const Projector *m_proj{ nullptr };
115  bool m_vectorStars{ false };
116  HIPSRenderer *m_hipsRender{ nullptr };
117  TerrainRenderer *m_terrainRender{ nullptr };
118  QSize m_size;
119  QScopedPointer<QImage> m_HiPSImage;
120  static int starColorMode;
121  static QColor m_starColor;
122  static QMap<char, QColor> ColorMap;
123 };
static void releaseImageCache()
Release the image cache.
Definition: skyqpainter.cpp:91
void begin() override
Begin painting.
The QPainter-based painting backend.
Definition: skyqpainter.h:28
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 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
drawHips Draw the Terrain
void drawObservingList(const QList< SkyObject * > &obs) override
Draw the symbols for the observing list.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
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:67
void drawSkyLine(SkyPoint *a, SkyPoint *b) override
Draw a line between points in the sky.
bool drawConstellationArtImage(ConstellationsArt *obj) override
Draw a ConstellationsArt object.
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 Deeb 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-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:14:02 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.