Kstars

fov.h
1/*
2 SPDX-FileCopyrightText: 2003 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "skypoint.h"
10
11#include <QImage>
12#include <QList>
13#include <QString>
14#include <QtDBus/QDBusArgument>
15
16class QPainter;
17
18/**
19 * @class FOV
20 * A simple class encapsulating a Field-of-View symbol
21 *
22 * The FOV size, shape, name, and color can be customized. The rotation is by default 0 degrees East Of North.
23 * @author Jason Harris
24 * @author Jasem Mutlaq
25 * @version 1.1
26 */
27class FOV : public QObject
28{
30 Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.fov")
31
32 Q_PROPERTY(QString name MEMBER m_name)
33 Q_PROPERTY(FOV::Shape shape MEMBER m_shape)
34 Q_PROPERTY(float sizeX MEMBER m_sizeX)
35 Q_PROPERTY(float sizeY MEMBER m_sizeY)
36 Q_PROPERTY(float offsetX MEMBER m_offsetX)
37 Q_PROPERTY(float offsetY MEMBER m_offsetY)
38 Q_PROPERTY(float PA MEMBER m_PA)
39 Q_PROPERTY(QString color MEMBER m_color)
40 Q_PROPERTY(bool cpLock MEMBER m_lockCelestialPole)
41
42 public:
43 enum Shape
44 {
45 SQUARE,
46 CIRCLE,
47 CROSSHAIRS,
48 BULLSEYE,
49 SOLIDCIRCLE,
50 UNKNOWN
51 };
52
53 /** Default constructor */
54 FOV();
55 FOV(const QString &name, float a, float b = -1, float xoffset = 0, float yoffset = 0, float rot = 0,
56 Shape shape = SQUARE, const QString &color = "#FFFFFF", bool useLockedCP = false);
57 FOV(const FOV &other);
58
59 void sync(const FOV &other);
60
61 inline Q_SCRIPTABLE QString name() const { return m_name; }
62 void setName(const QString &n) { m_name = n; }
63
64 inline FOV::Shape shape() const { return m_shape; }
65 void setShape(FOV::Shape s) { m_shape = s; }
66 //void setShape(int s);
67
68 /** Sizes are in arcminutes */
69 inline float sizeX() const { return m_sizeX; }
70 inline float sizeY() const { return m_sizeY; }
71 void setSize(float s) { m_sizeX = m_sizeY = s; }
72 void setSize(float sx, float sy)
73 {
74 m_sizeX = sx;
75 m_sizeY = sy;
76 }
77
78 void setOffset(float fx, float fy)
79 {
80 m_offsetX = fx;
81 m_offsetY = fy;
82 }
83 inline float offsetX() const { return m_offsetX; }
84 inline float offsetY() const { return m_offsetY; }
85
86 // Position Angle
87 void setPA(float rt) { m_PA = rt; }
88 inline float PA() const { return m_PA; }
89
90 inline QString color() const { return m_color; }
91 void setColor(const QString &c) { m_color = c; }
92
93 /**
94 * @short draw the FOV symbol on a QPainter
95 * @param p reference to the target QPainter. The painter should already be started.
96 * @param zoomFactor is zoom factor as in SkyMap.
97 */
98 void draw(QPainter &p, float zoomFactor);
99
100 /**
101 * @short draw FOV symbol so it will be inside a rectangle
102 * @param p reference to the target QPainter. The painter should already be started.
103 * @param x is X size of rectangle
104 * @param y is Y size of rectangle
105 */
106 void draw(QPainter &p, float x, float y);
107
108 SkyPoint center() const;
109 void setCenter(const SkyPoint &center);
110
111 float northPA() const;
112 void setNorthPA(float northPA);
113
114 void setImage(const QImage &image);
115
116 void setImageDisplay(bool value);
117
118 bool lockCelestialPole() const;
119 void setLockCelestialPole(bool lockCelestialPole);
120
121private:
122 QString m_name, m_color;
123 FOV::Shape m_shape;
124 float m_sizeX { 0 }, m_sizeY { 0 };
125 float m_offsetX { 0 }, m_offsetY { 0 };
126 float m_PA { 0 };
127 float m_northPA { 0 };
128 SkyPoint m_center;
129 QImage m_image;
130 bool m_imageDisplay { false };
131 bool m_lockCelestialPole { false };
132
133 static int getID() { return m_ID++; }
134 static int m_ID;
135};
136
137/**
138 * @class FOVManager
139 * A simple class handling FOVs.
140 * @note Should migrate this from file (fov.dat) to using the user sqlite database
141 * @author Jasem Mutlaq
142 * @version 1.0
143 */
145{
146 public:
147 /** @short Read list of FOVs from "fov.dat" */
148 static const QList<FOV *> &readFOVs();
149 /** @short Release the FOV cache */
150 static void releaseCache();
151 static void addFOV(FOV *newFOV)
152 {
153 Q_ASSERT(newFOV);
154 m_FOVs.append(newFOV);
155 }
156 static void removeFOV(FOV *fov)
157 {
158 Q_ASSERT(fov);
159 m_FOVs.removeOne(fov);
160 }
161 static const QList<FOV *> &getFOVs() { return m_FOVs; }
162
163 /** @short Write list of FOVs to "fov.dat" */
164 static bool save();
165
166 private:
167 FOVManager() = default;
168 ~FOVManager();
169
170 /** @short Fill list with default FOVs*/
171 static QList<FOV *> defaults();
172
173 static QList<FOV *> m_FOVs;
174};
175
176// Shape
177Q_DECLARE_METATYPE(FOV::Shape)
178QDBusArgument &operator<<(QDBusArgument &argument, const FOV::Shape& source);
179const QDBusArgument &operator>>(const QDBusArgument &argument, FOV::Shape &dest);
A simple class handling FOVs.
Definition fov.h:145
static const QList< FOV * > & readFOVs()
Read list of FOVs from "fov.dat".
Definition fov.cpp:76
static bool save()
Write list of FOVs to "fov.dat".
Definition fov.cpp:49
static void releaseCache()
Release the FOV cache.
Definition fov.cpp:154
A simple class encapsulating a Field-of-View symbol.
Definition fov.h:28
FOV()
Default constructor.
Definition fov.cpp:185
void draw(QPainter &p, float zoomFactor)
draw the FOV symbol on a QPainter
Definition fov.cpp:230
float sizeX() const
Sizes are in arcminutes.
Definition fov.h:69
The sky coordinates of a point in the sky.
Definition skypoint.h:45
void append(QList< T > &&value)
bool removeOne(const AT &t)
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.