Kstars

imageexporter.h
1/*
2 SPDX-FileCopyrightText: 2013 Akarsh Simha <akarsh.simha@kdemail.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef IMAGEEXPORTER_H
8#define IMAGEEXPORTER_H
9
10#include "../printing/legend.h"
11
12#include <QObject>
13
14class KStars;
15class QSize;
16
17/**
18 * @class ImageExporter
19 * @short Backends for exporting a sky image, either raster or vector, with a legend
20 * @author Rafał Kułaga <rl.kulaga@gmail.com>
21 * @author Akarsh Simha <akarsh.simha@kdemail.net>
22 */
23class ImageExporter : public QObject
24{
26
27 public:
28 /**
29 * @short Constructor
30 */
31 explicit ImageExporter(QObject *parent = nullptr);
32
33 /**
34 * @short Destructor
35 */
36 ~ImageExporter() override;
37
38 /**
39 * @return last error message
40 */
41 inline QString getLastErrorMessage() const { return m_lastErrorMessage; }
42
43 public Q_SLOTS:
44 /**
45 * @short Exports an image with the defined settings.
46 * @param url URL of the exported image
47 * @return false if the URL was a network location and uploading to the network location failed
48 * @note This method calls an SVG backend instead if the file extension is svg. Otherwise, it draws raster.
49 */
50 bool exportImage(QString url);
51
52 /**
53 * @short Set the legend properties
54 * @param type Legend type. (See enum LEGEND_TYPE in legend.h)
55 * @param orientation Legend orientation. (See LEGEND_ORIENTATION in legend.h)
56 * @param position Legend position. (See LEGEND_POSITION in legend.h)
57 * @param alpha Legend alpha (transparency). Default value is 160.
58 * @param include Include the legend?
59 */
61 Legend::LEGEND_POSITION position, int alpha = 160, bool include = true);
62
63 /**
64 * @short Include legend?
65 * @param include The legend will be included if the flag is set to true
66 */
67 inline void includeLegend(bool include) { m_includeLegend = include; }
68
69 /**
70 * @short Set legend transparency
71 * @param alpha Transparency level
72 */
73 void setLegendAlpha(int alpha);
74
75 /**
76 * @short Set the size of output raster images
77 * @param size a pointer to a QSize containing the size of images. If a null pointer is supplied, the SkyMap size is used.
78 * @note If size is larger than the skymap size, then the sky image is padded; if it is smaller, then it is cropped. No rescaling is done.
79 */
80 void setRasterOutputSize(const QSize *size);
81
82 /**
83 * @return a pointer to the legend used
84 */
85 inline Legend *getLegend() { return m_Legend; }
86
87 private:
88 void exportSvg(const QString &fileName);
89 bool exportRasterGraphics(const QString &fileName);
90 void addLegend(SkyQPainter *painter);
91 void addLegend(QPaintDevice *pd);
92
93 bool m_includeLegend;
94 Legend *m_Legend;
95 QSize *m_Size;
96 QString m_lastErrorMessage;
97};
98
99#endif
Backends for exporting a sky image, either raster or vector, with a legend.
~ImageExporter() override
Destructor.
void setLegendAlpha(int alpha)
Set legend transparency.
QString getLastErrorMessage() const
void includeLegend(bool include)
Include legend?
void setLegendProperties(Legend::LEGEND_TYPE type, Legend::LEGEND_ORIENTATION orientation, Legend::LEGEND_POSITION position, int alpha=160, bool include=true)
Set the legend properties.
ImageExporter(QObject *parent=nullptr)
Constructor.
bool exportImage(QString url)
Exports an image with the defined settings.
void setRasterOutputSize(const QSize *size)
Set the size of output raster images.
Legend * getLegend()
This is the main window for KStars.
Definition kstars.h:91
Legend class is used for painting legends on class inheriting QPaintDevice.
Definition legend.h:33
LEGEND_POSITION
Legend position enumeration.
Definition legend.h:60
LEGEND_ORIENTATION
Legend orientation enumeration.
Definition legend.h:51
LEGEND_TYPE
Legend type enumeration.
Definition legend.h:39
The QPainter-based painting backend.
Definition skyqpainter.h:31
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:25 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.