Kstars

imagingplanner.h
1/*
2 SPDX-FileCopyrightText: 2024 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_imagingplanner.h"
10#include "catalogsdb.h"
11#include <QPointer>
12#include <QDialog>
13#include <QDir>
14#include <QFuture>
15#include <QFutureWatcher>
16#include <QSortFilterProxyModel>
17#include <QMenu>
18
20class QStandardItem;
21class ImagingPlannerPopup;
22class KSMoon;
23
24// These are used to communicate with the database.
25class ImagingPlannerDBEntry
26{
27public:
28 enum EntryFlag
29 {
30 PickedBit = 0x1,
31 ImagedBit = 0x2,
32 //AddedBit = 0x4,
33 IgnoredBit = 0x8
34 };
35
36 QString m_Name;
37 int m_Flags;
38 QString m_Notes;
39 ImagingPlannerDBEntry() {};
40 ImagingPlannerDBEntry(const QString &name, int flags, const QString &notes);
41 ImagingPlannerDBEntry(const QString &name, bool picked, bool imaged, bool ignored, const QString &notes);
42 void setFlags(bool picked, bool imaged, bool ignored);
43 void getFlags(bool *picked, bool *imaged, bool *ignored);
44 QString name() { return m_Name; }
45};
46
47class ImagingPlannerUI : public QFrame, public Ui::ImagingPlanner
48{
50
51 public:
52 explicit ImagingPlannerUI(QWidget *parent);
53private:
54 void setupIcons();
55};
56
57class CatalogImageInfo
58{
59 public:
60 CatalogImageInfo() {}
61 CatalogImageInfo(const QString &csv);
62 QString m_Name, m_Filename, m_Author, m_Link, m_License;
63};
64
65class CatalogFilter : public QSortFilterProxyModel
66{
68 public:
69 CatalogFilter(QObject* parent = 0);
70 bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
71 bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const override;
72 void setMinHours(double hours);
73 void setImagedConstraints(bool enabled, bool required);
74 void setPickedConstraints(bool enabled, bool required);
75 void setIgnoredConstraints(bool enabled, bool required);
76 void setKeywordConstraints(bool enabled, bool required, const QString &keyword);
77 void setSortColumn(int column);
78
79private:
80 double m_MinHours = 0;
81 bool m_ImagedConstraintsEnabled = false;
82 bool m_ImagedRequired = false;
83 bool m_PickedConstraintsEnabled = false;
84 bool m_PickedRequired = false;
85 bool m_IgnoredConstraintsEnabled = false;
86 bool m_IgnoredRequired = false;
87 bool m_KeywordConstraintsEnabled = false;
88 bool m_KeywordRequired = false;
89 QString m_Keyword;
90 QRegularExpression m_KeywordRE;
91 int m_SortColumn = 1; // HOURS
92 bool m_ReverseSort = false;
93};
94
95class ImagingPlanner : public QDialog
96{
98
99 public:
100 ImagingPlanner();
101 virtual ~ImagingPlanner() override = default;
102
103 bool eventFilter(QObject *obj, QEvent *event) override;
104
105 public slots:
106 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
107 void setSelection(int flag, bool enabled);
108
109 void setSelectionIgnored();
110 void setSelectionNotIgnored();
111
112 void setSelectionImaged();
113 void setSelectionNotImaged();
114
115 void setSelectionPicked();
116 void setSelectionNotPicked();
117
118 void centerOnSkymap();
119 void reallyCenterOnSkymap();
120
121protected slots:
122 void slotClose();
123 void searchAstrobin();
124 void searchWikipedia();
125 void searchSimbad();
126 void searchNGCICImages();
127 void recompute();
128 void sorry(const QString &message);
129
130signals:
131 void popupSorry(const QString &message);
132 void addRow(QList<QStandardItem *> itemList);
133
134protected:
135 void showEvent(QShowEvent *) override;
136
137 private slots:
138 void userNotesEditFinished();
139 void keywordEditFinished();
140 void loadImagedFile();
141 void searchSlot();
142 void loadCatalogViaMenu();
143 void getHelp();
144 void openOptionsMenu();
145 void addRowSlot(QList<QStandardItem *> itemList);
146
147
148 private:
149 void initialize();
150 void catalogLoaded();
151 void loadCatalog(const QString &path);
152 void installEventFilters();
153 void removeEventFilters();
154
155
156 // Methods for setting up buttons and options.
157 void setupHideButtons(bool(*option)(), void(*setOption)(bool),
158 QPushButton *hideButton, QPushButton *showButton,
159 QFrame *widget, QFrame *hiddenWidget);
160 void setupFilterButton(QCheckBox *checkbox, bool(*option)(), void(*setOption)(bool));
161 void setupFilter2Buttons(
162 QCheckBox *yes, QCheckBox *no, QCheckBox *dontCare,
163 bool(*yesOption)(), bool(*noOption)(), bool(*dontCareOption)(),
164 void(*setYesOption)(bool), void(*setNoOption)(bool), void(*setDontCareOption)(bool));
165
166 void updateSortConstraints();
167
168 GeoLocation *getGeo();
169 QDate getDate() const;
170
171 void loadInitialCatalog();
172 QString defaultDirectory() const;
173 QString findDefaultCatalog() const;
174 bool getKStarsCatalogObject(const QString &name, CatalogObject *catObject);
175 bool addCatalogItem(const KSAlmanac &ksal, const QString &name, int flags = 0);
176 QUrl getAstrobinUrl(const QString &target, bool requireAwards, bool requireSomeFilters, double minRadius, double maxRadius);
177 void popupAstrobin(const QString &target);
178 void plotAltitudeGraph(const QDate &date, const dms &ra, const dms &dec);
179
180 void moveBackOneDay();
181 void moveForwardOneDay();
182 bool scrollToName(const QString &name);
183
184 void setStatus(const QString &message);
185 void updateStatus();
186
187 void updateDetails(const CatalogObject &object, int flags);
188 void updateNotes(const QString &notes);
189 void initUserNotes();
190 void disableUserNotes();
191 void setupNotesLinks(const QString &notes);
192
193 void setDefaultImage();
194
195 QString currentObjectName() const;
196 int currentObjectFlags();
197 QString currentObjectNotes();
198 void setCurrentObjectNotes(const QString &notes);
199
200 CatalogObject *currentCatalogObject();
201 CatalogObject *getObject(const QString &name);
202 CatalogObject *addObject(const QString &name);
203 void clearObjects();
204
205 void loadCatalogFromFile(QString filename = "", bool reset=true);
206 bool findCatalogImageInfo(const QString &name, CatalogImageInfo *info);
207 void addCatalogImageInfo(const CatalogImageInfo &info);
208
209 void objectDetails();
210 void updateDisplays();
211 void updateCounts();
212 KSMoon *getMoon();
213 void updateMoon();
214
215 // Database utilities.
216 void saveToDB(const QString &name, bool picked, bool imaged, bool ignored, const QString &notes);
217 void saveToDB(const QString &name, int flags, const QString &notes);
218 void loadFromDB();
219
220 void highlightImagedObject(const QModelIndex &index, bool imaged);
221 void highlightPickedObject(const QModelIndex &index, bool picked);
222
223 void focusOnTable();
224 void adjustWindowSize();
225
226 // Used for debugging the object lists.
227 void checkTargets();
228
229 ImagingPlannerUI *ui { nullptr };
230
231 bool m_initialShow { false };
232 bool m_InitialLoad = true;
233
234 CatalogsDB::DBManager m_manager;
235 QPointer<QStandardItemModel> m_CatalogModel;
236 QPointer<CatalogFilter> m_CatalogSortModel;
237
238 QFuture<void> m_LoadCatalogs;
239 QFutureWatcher<void> *m_LoadCatalogsWatcher;
240
241 QHash<QString, CatalogObject> m_CatalogHash;
242 QPixmap m_NoImagePixmap;
243
245
246 double m_MinMoon = 30.0;
247 double m_MinAltitude = 30.0;
248 double m_MinHours = 0;
249 bool m_UseArtificialHorizon = true;
250 QString m_Keyword;
251
252 int m_numWithImage = 0;
253 int m_numMissingImage = 0;
254 bool m_loadingCatalog = false;
255
256 QMap<QString, CatalogImageInfo> m_CatalogImageInfoMap;
257};
258
259class ImagingPlannerPopup : public QMenu
260{
262 public:
263 ImagingPlannerPopup();
264 virtual ~ImagingPlannerPopup() override = default;
265
266 void init(ImagingPlanner *planner, const QStringList &names,
267 const bool *imaged, const bool *picked, const bool *ignored);
268};
269
270
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
Manages the catalog database and provides an interface to provide an interface to query and modify th...
Definition catalogsdb.h:183
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A class that implements methods to find sun rise, sun set, twilight begin / end times,...
Definition ksalmanac.h:27
Provides necessary information about the Moon.
Definition ksmoon.h:26
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Q_OBJECTQ_OBJECT
QObject * parent() const const
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.