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 <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 inline float sizeX() const { return m_sizeX; }
69 inline float sizeY() const { return m_sizeY; }
70 void setSize(float s) { m_sizeX = m_sizeY = s; }
71 void setSize(float sx, float sy)
72 {
73 m_sizeX = sx;
74 m_sizeY = sy;
75 }
76
77 void setOffset(float fx, float fy)
78 {
79 m_offsetX = fx;
80 m_offsetY = fy;
81 }
82 inline float offsetX() const { return m_offsetX; }
83 inline float offsetY() const { return m_offsetY; }
84
85 // Position Angle
86 void setPA(float rt) { m_PA = rt; }
87 inline float PA() const { return m_PA; }
88
89 inline QString color() const { return m_color; }
90 void setColor(const QString &c) { m_color = c; }
91
92 /**
93 * @short draw the FOV symbol on a QPainter
94 * @param p reference to the target QPainter. The painter should already be started.
95 * @param zoomFactor is zoom factor as in SkyMap.
96 */
97 void draw(QPainter &p, float zoomFactor);
98
99 /**
100 * @short draw FOV symbol so it will be inside a rectangle
101 * @param p reference to the target QPainter. The painter should already be started.
102 * @param x is X size of rectangle
103 * @param y is Y size of rectangle
104 */
105 void draw(QPainter &p, float x, float y);
106
107 SkyPoint center() const;
108 void setCenter(const SkyPoint &center);
109
110 float northPA() const;
111 void setNorthPA(float northPA);
112
113 void setImage(const QImage &image);
114
115 void setImageDisplay(bool value);
116
117 bool lockCelestialPole() const;
118 void setLockCelestialPole(bool lockCelestialPole);
119
120private:
121 QString m_name, m_color;
122 FOV::Shape m_shape;
123 float m_sizeX { 0 }, m_sizeY { 0 };
124 float m_offsetX { 0 }, m_offsetY { 0 };
125 float m_PA { 0 };
126 float m_northPA { 0 };
127 SkyPoint m_center;
128 QImage m_image;
129 bool m_imageDisplay { false };
130 bool m_lockCelestialPole { false };
131
132 static int getID() { return m_ID++; }
133 static int m_ID;
134};
135
136/**
137 * @class FOVManager
138 * A simple class handling FOVs.
139 * @note Should migrate this from file (fov.dat) to using the user sqlite database
140 * @author Jasem Mutlaq
141 * @version 1.0
142 */
144{
145 public:
146 /** @short Read list of FOVs from "fov.dat" */
147 static const QList<FOV *> &readFOVs();
148 /** @short Release the FOV cache */
149 static void releaseCache();
150 static void addFOV(FOV *newFOV)
151 {
153 m_FOVs.append(newFOV);
154 }
155 static void removeFOV(FOV *fov)
156 {
157 Q_ASSERT(fov);
158 m_FOVs.removeOne(fov);
159 }
160 static const QList<FOV *> &getFOVs() { return m_FOVs; }
161
162 /** @short Write list of FOVs to "fov.dat" */
163 static bool save();
164
165 private:
166 FOVManager() = default;
167 ~FOVManager();
168
169 /** @short Fill list with default FOVs*/
170 static QList<FOV *> defaults();
171
172 static QList<FOV *> m_FOVs;
173};
174
175// Shape
176Q_DECLARE_METATYPE(FOV::Shape)
177QDBusArgument &operator<<(QDBusArgument &argument, const FOV::Shape& source);
178const QDBusArgument &operator>>(const QDBusArgument &argument, FOV::Shape &dest);
A simple class handling FOVs.
Definition fov.h:144
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
The sky coordinates of a point in the sky.
Definition skypoint.h:45
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 Tue Mar 26 2024 11:19:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.