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
134 protected:
135 void showEvent(QShowEvent *) override;
136 void resizeEvent(QResizeEvent *) override;
137
138 private slots:
139 void userNotesEditFinished();
140 void keywordEditFinished();
141 void loadImagedFile();
142 void searchSlot();
143 void loadCatalogViaMenu();
144 void getHelp();
145 void openOptionsMenu();
146 void addRowSlot(QList<QStandardItem *> itemList);
147
148
149 private:
150 void initialize();
151 void catalogLoaded();
152 void loadCatalog(const QString &path);
153
154
155 // Methods for setting up buttons and options.
156 void setupHideButtons(bool(*option)(), void(*setOption)(bool),
157 QPushButton *hideButton, QPushButton *showButton,
158 QFrame *widget, QFrame *hiddenWidget);
159 void setupFilterButton(QCheckBox *checkbox, bool(*option)(), void(*setOption)(bool));
160 void setupFilter2Buttons(
161 QCheckBox *yes, QCheckBox *no, QCheckBox *dontCare,
162 bool(*yesOption)(), bool(*noOption)(), bool(*dontCareOption)(),
163 void(*setYesOption)(bool), void(*setNoOption)(bool), void(*setDontCareOption)(bool));
164
165 void updateSortConstraints();
166
167 GeoLocation *getGeo();
168 QDate getDate() const;
169
170 void loadInitialCatalog();
171 QString defaultDirectory() const;
172 QString findDefaultCatalog() const;
173 bool getKStarsCatalogObject(const QString &name, CatalogObject *catObject);
174 bool addCatalogItem(const KSAlmanac &ksal, const QString &name, int flags = 0);
175 QUrl getAstrobinUrl(const QString &target, bool requireAwards, bool requireSomeFilters, double minRadius, double maxRadius);
176 void popupAstrobin(const QString &target);
177 void plotAltitudeGraph(const QDate &date, const dms &ra, const dms &dec);
178
179 void moveBackOneDay();
180 void moveForwardOneDay();
181 bool scrollToName(const QString &name);
182
183 void setStatus(const QString &message);
184 void updateStatus();
185
186 void updateDetails(const CatalogObject &object, int flags);
187 void updateNotes(const QString &notes);
188 void initUserNotes();
189 void disableUserNotes();
190 void setupNotesLinks(const QString &notes);
191
192 void setDefaultImage();
193
194 QString currentObjectName() const;
195 int currentObjectFlags();
196 QString currentObjectNotes();
197 void setCurrentObjectNotes(const QString &notes);
198
199 CatalogObject *currentCatalogObject();
200 CatalogObject *getObject(const QString &name);
201 CatalogObject *addObject(const QString &name);
202 void clearObjects();
203
204 void loadCatalogFromFile(QString filename = "", bool reset=true);
205 bool findCatalogImageInfo(const QString &name, CatalogImageInfo *info);
206 void addCatalogImageInfo(const CatalogImageInfo &info);
207
208 void objectDetails();
209 void updateDisplays();
210 void updateCounts();
211 KSMoon *getMoon();
212 void updateMoon();
213
214 // Database utilities.
215 void saveToDB(const QString &name, bool picked, bool imaged, bool ignored, const QString &notes);
216 void saveToDB(const QString &name, int flags, const QString &notes);
217 void loadFromDB();
218
219 void highlightImagedObject(const QModelIndex &index, bool imaged);
220 void highlightPickedObject(const QModelIndex &index, bool picked);
221
222 void focusOnTable();
223 void adjustWindowSize();
224
225 // Used for debugging the object lists.
226 void checkTargets();
227
228 ImagingPlannerUI *ui { nullptr };
229
230 bool m_initialResultsLoad { false };
231 bool m_InitialLoad = true;
232
233 CatalogsDB::DBManager m_manager;
234 QPointer<QStandardItemModel> m_CatalogModel;
235 QPointer<CatalogFilter> m_CatalogSortModel;
236
237 QFuture<void> m_LoadCatalogs;
238 QFutureWatcher<void> *m_LoadCatalogsWatcher;
239
240 QHash<QString, CatalogObject> m_CatalogHash;
241 QPixmap m_NoImagePixmap;
242
244
245 double m_MinMoon = 30.0;
246 double m_MinAltitude = 30.0;
247 double m_MinHours = 0;
248 bool m_UseArtificialHorizon = true;
249 QString m_Keyword;
250
251 int m_numWithImage = 0;
252 int m_numMissingImage = 0;
253
254 QMap<QString, CatalogImageInfo> m_CatalogImageInfoMap;
255};
256
257class ImagingPlannerPopup : public QMenu
258{
260 public:
261 ImagingPlannerPopup();
262 virtual ~ImagingPlannerPopup() override = default;
263
264 void init(ImagingPlanner *planner, const QStringList &names,
265 const bool *imaged, const bool *picked, const bool *ignored);
266};
267
268
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 Mon Nov 18 2024 12:16:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.