Kstars

skyqpainter.h
1/*
2 SPDX-FileCopyrightText: 2010 Henry de Valence <hdevalence@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ksasteroid.h"
10#include "skypainter.h"
11#include "config-kstars.h"
12
13#include <QColor>
14#include <QMap>
15
16class Projector;
17class QWidget;
18class QSize;
19class QMessageBox;
20class HIPSRenderer;
21class TerrainRenderer;
22class ImageOverlay;
23class KSEarthShadow;
24
25/**
26 * @short The QPainter-based painting backend.
27 * This class implements the SkyPainter interface using a QPainter.
28 * For documentation, @see SkyPainter.
29 */
30class SkyQPainter : public SkyPainter, public QPainter
31{
32 public:
33 /** Release the image cache */
34 static void releaseImageCache();
35
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);
42
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);
48
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);
55
56 ~SkyQPainter() override;
57
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;
64
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 }
77
78 void begin() override;
79 void end() override;
80
81 /** Recalculates the star pixmaps. */
82 static void initStarImages();
83
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');
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;
115 void setSize(int width, int height);
116
117 private:
118 QColor skyColor() const;
119 QPaintDevice *m_pd{ nullptr };
120 const Projector *m_proj{ nullptr };
121 bool m_vectorStars{ false };
122 HIPSRenderer *m_hipsRender{ nullptr };
123 TerrainRenderer *m_terrainRender{ nullptr };
124 QSize m_size;
125 QScopedPointer<QImage> m_HiPSImage;
126 static int starColorMode;
127 static QColor m_starColor;
128 static QMap<char, QColor> ColorMap;
129};
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
Information about a ConstellationsArt object.
A subclass of KSPlanetBase that implements asteroids.
Definition ksasteroid.h:42
A subclass of KSPlanetBase that implements comets.
Definition kscomet.h:44
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
A subclass of TrailObject that provides additional information needed for most solar system objects.
A simple data container used by LineListIndex.
Definition linelist.h:25
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
Represents an artificial satellites.
Definition satellite.h:23
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
The QPainter-based painting backend.
Definition skyqpainter.h:31
bool drawAsteroid(KSAsteroid *ast) override
Draw an asteroid in the sky.
bool drawComet(KSComet *com) override
Draw a comet in the sky.
void end() override
End and finalize painting.
SkyQPainter(QPaintDevice *pd, const QSize &canvasSize)
Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canv...
bool drawPlanet(KSPlanetBase *planet) override
Draw a planet.
bool drawPointSource(const SkyPoint *loc, float mag, char sp='A') override
Draw a point source (e.g., a star).
void drawSkyLine(SkyPoint *a, SkyPoint *b) override
Draw a line between points in the sky.
bool drawImageOverlay(const QList< ImageOverlay > *imageOverlays, bool useCache=false) override
drawImageOverlay Draws a user-supplied image onto the skymap
void setBrush(const QBrush &brush) override
Set the brush of the painter.
void drawSkyPolyline(LineList *list, SkipHashList *skipList=nullptr, LineListLabel *label=nullptr) override
Draw a polyline in the sky.
bool drawTerrain(bool useCache=false) override
drawTerrain Draw the Terrain
void drawSkyPolygon(LineList *list, bool forceClip=true) override
Draw a polygon in the sky.
void drawSkyBackground() override
Draw the sky background.
bool drawCatalogObject(const CatalogObject &obj) override
Draw a deep sky object (loaded from the new implementation)
void drawObservingList(const QList< SkyObject * > &obs) override
Draw the symbols for the observing list.
static void initStarImages()
Recalculates the star pixmaps.
static void releaseImageCache()
Release the image cache.
void setPen(const QPen &pen) override
Set the pen of the painter.
bool drawEarthShadow(KSEarthShadow *shadow) override
Draw the earths shadow on the moon (red-ish)
bool drawConstellationArtImage(ConstellationsArt *obj) override
Draw a ConstellationsArt object.
void drawFlags() override
Draw flags.
void setVectorStars(bool vectorStars)
Definition skyqpainter.h:69
bool drawSupernova(Supernova *sup) override
Draw a Supernova.
bool drawHips(bool useCache=false) override
drawMosaicPanel Draws mosaic panel in planning or operation mode.
bool drawSatellite(Satellite *sat) override
Draw a satellite.
void begin() override
Begin painting.
Represents the supernova object.
Definition supernova.h:34
const QBrush & brush() const const
const QPen & pen() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.