Kstars

imageexporter.h
1 /*
2  SPDX-FileCopyrightText: 2013 Akarsh Simha <[email protected]>
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 
14 class KStars;
15 class 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 <[email protected]>
21  * @author Akarsh Simha <[email protected]>
22  */
23 class ImageExporter : public QObject
24 {
25  Q_OBJECT
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  */
60  void setLegendProperties(Legend::LEGEND_TYPE type, Legend::LEGEND_ORIENTATION orientation,
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
Q_OBJECTQ_OBJECT
The QPainter-based painting backend.
Definition: skyqpainter.h:29
ImageExporter(QObject *parent=nullptr)
Constructor.
Q_SLOTSQ_SLOTS
bool exportImage(QString url)
Exports an image with the defined settings.
void setLegendProperties(Legend::LEGEND_TYPE type, Legend::LEGEND_ORIENTATION orientation, Legend::LEGEND_POSITION position, int alpha=160, bool include=true)
Set the legend properties.
Backends for exporting a sky image, either raster or vector, with a legend.
Definition: imageexporter.h:23
void includeLegend(bool include)
Include legend?
Definition: imageexporter.h:67
void setLegendAlpha(int alpha)
Set legend transparency.
QString getLastErrorMessage() const
Definition: imageexporter.h:41
void setRasterOutputSize(const QSize *size)
Set the size of output raster images.
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:88
~ImageExporter() override
Destructor.
Legend * getLegend()
Definition: imageexporter.h:85
QObject * parent() const const
Legend class is used for painting legends on class inheriting QPaintDevice. Its methods enable changi...
Definition: legend.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.