Kstars

skymapview.h
1/*
2 SPDX-FileCopyrightText: 2024 Akarsh Simha <akarsh@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QString>
10#include <QJsonObject>
11#include <QList>
12#include <optional>
13
14/**
15 * @struct SkyMapView
16 * Carries parameters of a sky map view
17 */
19{
20 explicit SkyMapView(const QString &name_, const QJsonObject &jsonData);
21 SkyMapView() = default;
22 QJsonObject toJson() const;
23
24 QString name; // Name of this view (can be empty)
25 bool useAltAz; // Mount type is alt-az when true
26 double viewAngle; // Focuser rotation in degrees, within [-90°, 90°]
27 bool mirror; // Mirrored left-right
28 bool inverted; // 180° rotation if true
29 double fov; // fov in degrees, NaN when disabled
30 bool erectObserver; // Erect observer correction
31};
32
33/**
34 * @class SkyMapViewManager
35 * Manages a list of sky map views
36 * @author Akarsh Simha
37 * @version 1.0
38 */
40{
41 public:
42 /** @short Read the list of views from the database */
43 static const QList<SkyMapView> &readViews();
44
45 /** @short Drop the list */
46 static void drop();
47
48 /** @short Add a view */
49 inline static void addView(const SkyMapView &newView)
50 {
51 m_views.append(newView);
52 }
53
54 /** @short Remove a view
55 * Note: This is currently an O(N) operation
56 */
57 static bool removeView(const QString &name);
58
59 /**
60 * @short Get the view with the given name
61 * @note This is currently an O(N) operation
62 */
63 static std::optional<SkyMapView> viewNamed(const QString &name);
64
65 /** @short Get the list of available views */
67 {
68 return m_views;
69 }
70
71 /** @short Commit the list of views to the database */
72 static bool save();
73
74 private:
75 SkyMapViewManager() = default;
76 ~SkyMapViewManager() = default;
77 static QList<SkyMapView> m_views;
78
79 /** @short Fill list with standard views */
80 static QList<SkyMapView> defaults();
81};
Manages a list of sky map views.
Definition skymapview.h:40
static void drop()
Drop the list.
static bool save()
Commit the list of views to the database.
static bool removeView(const QString &name)
Remove a view Note: This is currently an O(N) operation.
static const QList< SkyMapView > & getViews()
Get the list of available views.
Definition skymapview.h:66
static std::optional< SkyMapView > viewNamed(const QString &name)
Get the view with the given name.
static const QList< SkyMapView > & readViews()
Read the list of views from the database.
static void addView(const SkyMapView &newView)
Add a view.
Definition skymapview.h:49
void append(QList< T > &&value)
Carries parameters of a sky map view.
Definition skymapview.h:19
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.