Kstars

observinglist.h
1/*
2 SPDX-FileCopyrightText: 2004 Jeff Woods Jason Harris <jcwoods@bellsouth.net, jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ksalmanac.h"
10#include "kstarsdatetime.h"
11#include "ui_observinglist.h"
12#include "catalogsdb.h"
13
14#include <QAbstractTableModel>
15#include <QDialog>
16#include <QFrame>
17#include <QList>
18#include <QPixmap>
19#include <QTime>
20
21#include <functional>
22#include <memory>
23
25class QStandardItem;
27class QTimer;
28
29class GeoLocation;
30class KSDssDownloader;
31class KStars;
32class KStarsDateTime;
34class SkyObject;
35class SkyPoint;
36
37class ObservingListUI : public QFrame, public Ui::ObservingList
38{
40
41 public:
42 explicit ObservingListUI(QWidget *parent);
43};
44
45/** @class ObservingList
46 *Tool window for managing a custom list of objects. The window
47 *displays the Name, RA, Dec, mag, and type of each object in the list.
48 *
49 *By selecting an object in the list, you can perform a number of functions
50 *on that object:
51 *+ Center it in the display
52 *+ Examine its Details Window
53 *+ Point the telescope at it
54 *+ Attach a custom icon or name label (TBD)
55 *+ Attach a trail (solar system only) (TBD)
56 *+ Open the AltVsTime tool
57 *
58 *The user can also save/load their observing lists, and can export
59 *list data (TBD: as HTML table? CSV format? plain text?)
60 *
61 *The observing notes associated with the selected object are displayed
62 *below the list.
63 *
64 *TODO:
65 *+ Implement a "shaded" state, in which the UI is compressed to
66 * make it easier to float on the KStars window. Displays only
67 * object names, and single-letter action buttons, and no user log.
68 *+ Implement an InfoBox version (the ultimate shaded state)
69 *
70 *@short Tool for managing a custom list of objects
71 *@author Jeff Woods, Jason Harris
72 *@version 1.0
73 */
74
75class ObservingList : public QDialog
76{
78
79 public:
81 virtual ~ObservingList() override = default;
82
83 /** @return reference to the current observing list
84 */
85 QList<QSharedPointer<SkyObject>> &obsList() { return m_WishList; }
86
87 /** @return reference to the current observing list
88 */
89 QList<QSharedPointer<SkyObject>> &sessionList() { return m_SessionList; }
90
91 /** @return pointer to the currently-selected object in the observing list
92 *@note if more than one object is selected, this function returns 0.
93 */
94 inline SkyObject *currentObject() const { return m_CurrentObject; }
95
96 /** @short If the current list has unsaved changes, ask the user about saving it.
97 *@note also clears the list in preparation of opening a new one
98 */
99 void saveCurrentList();
100
101 /** @short Plot the SkyObject's Altitude vs Time in the AVTPlotWidget.
102 *@p o pointer to the object to be plotted
103 */
104 void plot(SkyObject *o);
105
106 /** @short Return the altitude of the given SkyObject for the given hour.
107 *@p p pointer to the SkyObject
108 *@p hour time at which altitude has to be found
109 */
110 double findAltitude(SkyPoint *p, double hour = 0);
111
112 /** @short Sets the image parameters for the current object
113 *@p o The passed object for setting the parameters
114 */
115 void setCurrentImage(const SkyObject *o);
116
117 /**
118 * @short Returns a path to the current image, or a writable image.
119 */
121
122 /** @short Save the user log text to a file.
123 *@note the log is attached to the current object in obsList.
124 */
125 void saveCurrentUserLog();
126
127 /** @short decides on whether to enable the SaveImages button or not
128 */
129 void setSaveImagesButton();
130
131 /** @short This is the declaration of the event filter function
132 * which is installed on the KImageFilePreview and the TabeView
133 */
134 bool eventFilter(QObject *obj, QEvent *event) override;
135
136 /** @short saves a thumbnail image for the details dialog
137 * from the downloaded image
138 */
139 void saveThumbImage();
140
141 QString getTime(const SkyObject *o) const;
142
143 QTime scheduledTime(SkyObject *o) const;
144
145 void setTime(const SkyObject *o, QTime t);
146
147 inline GeoLocation *geoLocation() { return geo; }
148
149 inline KStarsDateTime dateTime() const { return dt; }
150
151 /** @short return the object with the name as the passed
152 * QString from the Session List, return null otherwise
153 */
155
156 /** @short make a selection in the session view
157 */
158 void selectObject(const SkyObject *o);
159
160 /** @short set the default image in the image preview.
161 */
162 void setDefaultImage();
163
164 /** @short get object name. If sky object has no name, generate a name based on catalog number.
165 * @param o pointer to the sky object
166 * @param translated set to true if the translated name is required.
167 */
168 QString getObjectName(const SkyObject *o, bool translated = true);
169
170 /**
171 * @return true if the selected list contains the given object
172 */
173 inline bool contains(const SkyObject *o, bool session = false) { return bool(findObject(o, session)); }
174
175 QSharedPointer<SkyObject> findObject(const SkyObject *o, bool session = false);
176
177 public slots:
178 /** @short add a new object to list
179 *@p o pointer to the object to add to the list
180 *@p session flag toggle adding the object to the session list
181 *@p update flag to toggle the call of slotSaveList
182 */
183 void slotAddObject(const SkyObject *o = nullptr, bool session = false, bool update = false);
184
185 /** @short Remove skyobjects which are highlighted in the
186 *observing list tool from the observing list.
187 */
189
190 /** @short Remove skyobject from the observing list.
191 *@p o pointer to the SkyObject to be removed.
192 *@p session flag to tell it whether to remove the object
193 *from the sessionlist or from the wishlist
194 *@p update flag to toggle the call of slotSaveList
195 *Use SkyMap::clickedObject() if o is nullptr (default)
196 */
197 void slotRemoveObject(const SkyObject *o = nullptr, bool session = false, bool update = false);
198
199 /** @short center the selected object in the display
200 */
201 void slotCenterObject();
202
203 /** @short slew the telescope to the selected object
204 */
205 void slotSlewToObject();
206
207 /**
208 * @brief slotAddToEkosScheduler Add object to Ekos scheduler
209 */
211
212 /** @short Show the details window for the selected object
213 */
214 void slotDetails();
215
216 /** @short Show the Altitude vs Time for selecteld objects
217 */
218 void slotAVT();
219
220 /** @short Open the WUT dialog
221 */
222 void slotWUT();
223
224 /** @short Add the object to the Session List
225 */
226 void slotAddToSession();
227
228 /** @short Open the Find Dialog
229 */
230 void slotFind();
231
232 /** @short Batch add from a list of objects */
233 void slotBatchAdd();
234
235 /** @short Tasks needed when changing the selected object
236 *Save the user log of the previous selected object,
237 *find the new selected object in the obsList, and
238 *show the notes associated with the new selected object
239 */
240 void slotNewSelection();
241
242 /** @short load an observing list from disk.
243 */
244 void slotOpenList();
245
246 /** @short save the current observing list to disk.
247 */
248 void slotSaveList();
249
250 /** @short Load the Wish list from disk.
251 */
252 void slotLoadWishList();
253
254 /** @short save the current observing session plan to disk, specify filename.
255 */
256 void slotSaveSessionAs(bool nativeSave = true);
257
258 /** @short save the current session
259 */
260 void slotSaveSession(bool nativeSave = true);
261
262 /** @short construct a new observing list using the wizard.
263 */
264 void slotWizard();
265
266 /** @short toggle the setEnabled flags according to current view
267 *set the m_currentItem to nullptr and clear selections
268 *@p index captures the integer value sent by the signal
269 *which is the currentIndex of the table
270 */
271 void slotChangeTab(int index);
272
273 /** @short Opens the Location dialog to set the GeoLocation
274 *for the sessionlist.
275 */
276 void slotLocation();
277
278 /** @short Updates the tableviews for the new geolocation and date
279 */
280 void slotUpdate();
281
282 /** @short Takes the time from the QTimeEdit box and sets it as the
283 *time parameter in the tableview of the SessionList.
284 */
285 void slotSetTime();
286
287 /** @short Downloads the corresponding DSS or SDSS image from the web and
288 *displays it
289 */
290 void slotGetImage(bool _dss = false, const SkyObject *o = nullptr);
291
292 void slotSearchImage();
293
294 /** @short Downloads the images of all the objects in the session list
295 *Note: This downloads the SDSS image, checks if the size is > default image
296 *and gets the DSS image if that's the case
297 */
298 void slotSaveAllImages();
299
300 /** @short saves the image synchronously from a given URL into a given file
301 *@p url the url from which the image has to be downloaded
302 *@p filename the file onto which the url has to be copied to
303 *NOTE: This is not a generic image saver, it is specific to the current object
304 */
305 void saveImage(QUrl url, QString filename, const SkyObject *o = nullptr);
306
307 /** @short Shows the image in a ImageViewer window.
308 */
309 void slotImageViewer();
310
311 /** @short Remove the current image
312 */
314
315 /** @short Removes all the save DSS/SDSS images from the disk.
316 */
317 void slotDeleteAllImages();
318
319 /** @short download the DSS image and show it
320 */
321 void slotDSS() { slotGetImage(true); }
322
323 /**
324 *@short Present the user with options to get the right DSS image for the job
325 */
326 void slotCustomDSS();
327
328 /** @short Export a target list to the oal compliant format
329 */
330 void slotOALExport();
331
332 void slotAddVisibleObj();
333
334 /**
335 * @short Recalculate and update the values of the altitude in the wishlist for the current time
336 */
337 void slotUpdateAltitudes();
338
339 /**
340 * @brief slotClearList Remove all objects from current list
341 */
342 void slotClearList();
343
344 protected slots:
345 void slotClose();
346 void downloadReady(bool success);
347
348 protected:
349 void showEvent(QShowEvent *) override;
350
351 private:
352 /**
353 * @short Return the active list
354 * @return The session list or the wish list depending on which tab is currently being viewed.
355 */
356 inline QList<QSharedPointer<SkyObject>> &getActiveList() { return ((sessionView) ? m_SessionList : m_WishList); }
357
358 /**
359 * @short Return the active itemmodel
360 * @return the session model or the wishlist model depending on which tab is currently being viewed.
361 */
362 inline QStandardItemModel *getActiveModel() const { return (sessionView ? m_SessionModel.get() : m_WishListModel.get()); }
363
364 /**
365 * @short Return the active sort model
366 * @return the session sort model or the wishlist sort model depending on which tab is currently being viewed.
367 */
368 inline QSortFilterProxyModel *getActiveSortModel() const
369 {
370 return (sessionView ? m_SessionSortModel.get() : m_WishListSortModel.get());
371 }
372
373 /**
374 * @short Return the active view
375 * @return the active view in the UI -- session view or wishlist view depending on which one is active.
376 */
377 inline QTableView *getActiveView() const { return ((sessionView) ? (ui->SessionView) : (ui->WishListView)); }
378
379 /**
380 * @short Get the currently selected item indexes
381 * @return a QModelIndexList containing the selected rows in the active QTableView
382 */
383 inline QModelIndexList getSelectedItems() const { return getActiveView()->selectionModel()->selectedRows(); }
384
385 std::unique_ptr<KSAlmanac> ksal;
386 ObservingListUI *ui { nullptr };
387 QList<QSharedPointer<SkyObject>> m_WishList, m_SessionList;
388 SkyObject *LogObject { nullptr };
389 SkyObject *m_CurrentObject { nullptr };
390 bool isModified { false };
391 bool sessionView { false };
392 bool dss { false };
393 bool singleSelection { false };
394 bool showScope { false };
395 bool noSelection { false };
396 QString m_listFileName, m_currentImageFileName, m_currentThumbImageFileName;
398 GeoLocation *geo { nullptr };
399 std::unique_ptr<QStandardItemModel> m_WishListModel;
400 std::unique_ptr<QStandardItemModel> m_SessionModel;
401 std::unique_ptr<QSortFilterProxyModel> m_WishListSortModel;
402 std::unique_ptr<QSortFilterProxyModel> m_SessionSortModel;
403 QHash<QString, QTime> TimeHash;
404 std::unique_ptr<ObsListPopupMenu> pmenu;
405 KSDssDownloader *m_dl { nullptr };
406 QHash<SkyObject *, QPixmap> ImagePreviewHash;
407 QPixmap m_NoImagePixmap;
408 QTimer *m_altitudeUpdater { nullptr };
409 std::function<QStandardItem *(const SkyPoint &)> m_altCostHelper;
410 bool m_initialWishlistLoad { false };
411 CatalogsDB::DBManager m_manager;
412};
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
Helps download a DSS image.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
This is the main window for KStars.
Definition kstars.h:89
The Popup Menu for the observing list in KStars.
Tool window for managing a custom list of objects.
void slotUpdateAltitudes()
Recalculate and update the values of the altitude in the wishlist for the current time.
void saveThumbImage()
saves a thumbnail image for the details dialog from the downloaded image
void slotLoadWishList()
Load the Wish list from disk.
void saveCurrentList()
If the current list has unsaved changes, ask the user about saving it.
void slotSaveSessionAs(bool nativeSave=true)
save the current observing session plan to disk, specify filename.
void slotDSS()
download the DSS image and show it
void slotOALExport()
Export a target list to the oal compliant format.
QString getCurrentImagePath()
Returns a path to the current image, or a writable image.
QList< QSharedPointer< SkyObject > > & sessionList()
void slotFind()
Open the Find Dialog.
void setDefaultImage()
set the default image in the image preview.
void setCurrentImage(const SkyObject *o)
Sets the image parameters for the current object o The passed object for setting the parameters.
void slotUpdate()
Updates the tableviews for the new geolocation and date.
QString getObjectName(const SkyObject *o, bool translated=true)
get object name.
void slotImageViewer()
Shows the image in a ImageViewer window.
QList< QSharedPointer< SkyObject > > & obsList()
void slotSaveAllImages()
Downloads the images of all the objects in the session list Note: This downloads the SDSS image,...
void slotAddToSession()
Add the object to the Session List.
void slotAVT()
Show the Altitude vs Time for selecteld objects.
void slotWizard()
construct a new observing list using the wizard.
void setSaveImagesButton()
decides on whether to enable the SaveImages button or not
void slotAddObject(const SkyObject *o=nullptr, bool session=false, bool update=false)
add a new object to list o pointer to the object to add to the list session flag toggle adding the ob...
void slotOpenList()
load an observing list from disk.
void slotGetImage(bool _dss=false, const SkyObject *o=nullptr)
Downloads the corresponding DSS or SDSS image from the web and displays it.
void slotLocation()
Opens the Location dialog to set the GeoLocation for the sessionlist.
void slotRemoveSelectedObjects()
Remove skyobjects which are highlighted in the observing list tool from the observing list.
bool contains(const SkyObject *o, bool session=false)
void slotAddToEkosScheduler()
slotAddToEkosScheduler Add object to Ekos scheduler
void slotClearList()
slotClearList Remove all objects from current list
void slotDeleteAllImages()
Removes all the save DSS/SDSS images from the disk.
void slotBatchAdd()
Batch add from a list of objects.
SkyObject * currentObject() const
void saveImage(QUrl url, QString filename, const SkyObject *o=nullptr)
saves the image synchronously from a given URL into a given file url the url from which the image has...
void slotWUT()
Open the WUT dialog.
void slotCustomDSS()
Present the user with options to get the right DSS image for the job.
void selectObject(const SkyObject *o)
make a selection in the session view
void saveCurrentUserLog()
Save the user log text to a file.
SkyObject * findObjectByName(QString name)
return the object with the name as the passed QString from the Session List, return null otherwise
void slotCenterObject()
center the selected object in the display
void slotDeleteCurrentImage()
Remove the current image.
void slotSlewToObject()
slew the telescope to the selected object
double findAltitude(SkyPoint *p, double hour=0)
Return the altitude of the given SkyObject for the given hour.
void slotSetTime()
Takes the time from the QTimeEdit box and sets it as the time parameter in the tableview of the Sessi...
void slotDetails()
Show the details window for the selected object.
void slotNewSelection()
Tasks needed when changing the selected object Save the user log of the previous selected object,...
void plot(SkyObject *o)
Plot the SkyObject's Altitude vs Time in the AVTPlotWidget.
void slotChangeTab(int index)
toggle the setEnabled flags according to current view set the m_currentItem to nullptr and clear sele...
bool eventFilter(QObject *obj, QEvent *event) override
This is the declaration of the event filter function which is installed on the KImageFilePreview and ...
void slotSaveList()
save the current observing list to disk.
void slotSaveSession(bool nativeSave=true)
save the current session
void slotRemoveObject(const SkyObject *o=nullptr, bool session=false, bool update=false)
Remove skyobject from the observing list.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
QItemSelectionModel * selectionModel() const const
QModelIndexList selectedRows(int column) const const
Q_OBJECTQ_OBJECT
QObject * parent() const const
virtual bool event(QEvent *event) override
void update()
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.