Kstars

eyepiecefield.h
1/*
2 SPDX-FileCopyrightText: 2014 Akarsh Simha <akarsh.simha@kdemail.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "dms.h"
10
11#include <QDialog>
12#include <QPixmap>
13#include <QTemporaryFile>
14
15#include <memory>
16
17class QCheckBox;
18class QComboBox;
19class QImage;
20class QLabel;
21class QPushButton;
22class QSlider;
23class QString;
24
25class FOV;
26class KSDssDownloader;
27class KStarsDateTime;
28class SkyPoint;
29
30/**
31 * @class EyepieceField
32 * @short Renders the view through the eyepiece of various telescope types
33 *
34 * @author Akarsh Simha <akarsh.simha@kdemail.net>
35 */
36class EyepieceField : public QDialog // FIXME: Rename to EyepieceView
37{
39
40 public:
41 /** Constructor */
42 explicit EyepieceField(QWidget *parent = nullptr);
43
44 /**
45 * @short Show the eyepiece field dialog
46 * @param sp Sky point to draw the eyepiece field around.
47 * @param fov Pointer to the FOV object describing the field of view. If no pointer is
48 * provided, tries to get from image. If no image is provided, assumes 1 degree.
49 * @param imagePath Optional path to DSS or other image. North should be on the top of the image.
50 * @note The SkyPoint must have correct Alt/Az coordinates, maybe by calling update()
51 * already before calling this method.
52 */
53 void showEyepieceField(SkyPoint *sp, FOV const *const fov = nullptr, const QString &imagePath = QString());
54
55 /**
56 * @short Show the eyepiece field dialog
57 * @param sp Sky point to draw the eyepiece field around.
58 * @param fovWidth width of field-of-view in arcminutes
59 * @param fovHeight height of field-of-view in arcminutes (if not supplied, is set to fovWidth)
60 * @param imagePath Optional path to DSS or other image. North should be on the top of the image.
61 * @note The SkyPoint must have correct Alt/Az coordinates, maybe by calling update() already
62 * before calling this method.
63 */
64 void showEyepieceField(SkyPoint *sp, const double fovWidth, double fovHeight = -1.0,
65 const QString &imagePath = QString());
66
67 /**
68 * @short Generate the eyepiece field view and corresponding image view
69 * @param sp Sky point to draw the render the eyepiece field around
70 * @param skyChart A non-null pointer to replace with the eyepiece field image
71 * @param skyImage An optionally non-null pointer to replace with the re-oriented sky image
72 * @param fovWidth width of the field-of-view in arcminutes
73 * @param fovHeight height of field-of-view in arcminutes (if not supplied, is set to fovWidth)
74 * @param imagePath Optional path to DSS or other image. North
75 * should be on the top of the image, and the size should be in
76 * the metadata; otherwise 1.01 arcsec/pixel is assumed.
77 * @note fovWidth can be zero/negative if imagePath is non-empty. If it is, the image
78 * size is used for the FOV.
79 * @note fovHeight can be zero/negative. If it is, fovWidth will be used. If fovWidth is also
80 * zero, image size is used.
81 */
82 static void generateEyepieceView(SkyPoint *sp, QImage *skyChart, QImage *skyImage = nullptr, double fovWidth = -1.0,
83 double fovHeight = -1.0, const QString &imagePath = QString());
84
85 /**
86 * @short Overloaded method provided for convenience. Obtains fovWidth/fovHeight from
87 * FOV if non-null, else uses image
88 */
89 static void generateEyepieceView(SkyPoint *sp, QImage *skyChart, QImage *skyImage = nullptr,
90 const FOV *fov = nullptr, const QString &imagePath = QString());
91
92 /**
93 * @short Orients the eyepiece view as needed, performs overlaying etc.
94 * @param skyChart image which contains the sky chart, possibly generated using generateEyepieceView
95 * @param skyImage optional image which contains the sky image, possibly generated using generateEyepieceView
96 * @param renderChart pixmap onto which the sky chart is to be rendered
97 * @param renderImage optional pixmap onto which the sky image is to be rendered
98 * @param rotation optional, number of degrees by which to rotate the image(s)
99 * @param scale optional, factor by which to scale the image(s)
100 * @param flip optional, if true, the image is mirrored horizontally
101 * @param invert optional, if true, the image is inverted, i.e. rotated by 180 degrees
102 * @param overlay optional, if true, the sky image is overlaid on the sky map
103 * @param invertColors optional, if true, the sky image is color-inverted
104 */
105 static void renderEyepieceView(const QImage *skyChart, QPixmap *renderChart, const double rotation = 0,
106 const double scale = 1.0, const bool flip = false, const bool invert = false,
107 const QImage *skyImage = nullptr, QPixmap *renderImage = nullptr,
108 const bool overlay = false, const bool invertColors = false);
109
110 /**
111 * @short Convenience method that generates and the renders the eyepiece view
112 * @note calls generateEyepieceView() followed by the raw form of renderEyepieceView() to render an eyepiece view
113 */
114 static void renderEyepieceView(SkyPoint *sp, QPixmap *renderChart, double fovWidth = -1.0, double fovHeight = -1.0,
115 const double rotation = 0, const double scale = 1.0, const bool flip = false,
116 const bool invert = false, const QString &imagePath = QString(),
117 QPixmap *renderImage = nullptr, const bool overlay = false,
118 const bool invertColors = false);
119
120 /**
121 * @short Finds the angle between "up" (i.e. direction of increasing altitude) and "north" (i.e. direction of increasing declination) at a given point in the sky
122 * @attention Procedure does not account for precession and nutation at the moment
123 * @note SkyPoint must already have Equatorial and Horizontal coordinate synced
124 */
125 static dms findNorthAngle(const SkyPoint *sp, const dms *lat);
126
127 public slots:
128
129 /**
130 * @short Re-renders the view
131 * Takes care of things like inverting colors, inverting orientation, flipping, rotation
132 * @note Calls the static method renderEyepieceView to set things up
133 */
134 void render();
135
136 /** Enforces a preset setting */
137 void slotEnforcePreset(int index = -1);
138
139 /** Save image */
140 void slotExport();
141
142 private slots:
143 /** Downloads a DSS image */
144 void slotDownloadDss();
145
146 /** Loads a downloaded DSS image */
147 void slotDssDownloaded(bool success);
148
149 private:
150 QLabel *m_skyChartDisplay { nullptr };
151 QLabel *m_skyImageDisplay { nullptr };
152 std::unique_ptr<QImage> m_skyChart;
153 std::unique_ptr<QImage> m_skyImage;
154 QSlider *m_rotationSlider { nullptr };
155 QCheckBox *m_invertColors { nullptr };
156 QCheckBox *m_overlay { nullptr };
157 QCheckBox *m_invertView { nullptr };
158 QCheckBox *m_flipView { nullptr };
159 QComboBox *m_presetCombo { nullptr };
160 QPushButton *m_getDSS { nullptr };
161 const FOV *m_currentFOV;
162 double m_fovWidth { 0 };
163 double m_fovHeight { 0 };
164 KSDssDownloader *m_dler { nullptr };
165 KStarsDateTime *m_dt { nullptr };
166 SkyPoint *m_sp { nullptr };
167 double m_lat { 0 };
168 QTemporaryFile m_tempFile;
169 QPixmap m_renderImage, m_renderChart;
170 bool m_usedAltAz { false };
171};
Renders the view through the eyepiece of various telescope types.
static void generateEyepieceView(SkyPoint *sp, QImage *skyChart, QImage *skyImage=nullptr, double fovWidth=-1.0, double fovHeight=-1.0, const QString &imagePath=QString())
Generate the eyepiece field view and corresponding image view.
void slotEnforcePreset(int index=-1)
Enforces a preset setting.
void showEyepieceField(SkyPoint *sp, FOV const *const fov=nullptr, const QString &imagePath=QString())
Show the eyepiece field dialog.
EyepieceField(QWidget *parent=nullptr)
Constructor.
void slotExport()
Save image.
static dms findNorthAngle(const SkyPoint *sp, const dms *lat)
Finds the angle between "up" (i.e.
static void renderEyepieceView(const QImage *skyChart, QPixmap *renderChart, const double rotation=0, const double scale=1.0, const bool flip=false, const bool invert=false, const QImage *skyImage=nullptr, QPixmap *renderImage=nullptr, const bool overlay=false, const bool invertColors=false)
Orients the eyepiece view as needed, performs overlaying etc.
void render()
Re-renders the view Takes care of things like inverting colors, inverting orientation,...
A simple class encapsulating a Field-of-View symbol.
Definition fov.h:28
Helps download a DSS image.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
The sky coordinates of a point in the sky.
Definition skypoint.h:45
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.