File indexing completed on 2024-04-14 03:43:24

0001 /*
0002     SPDX-FileCopyrightText: 2005 Jason Harris <jharris@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ui_obslistwizard.h"
0010 #include "skyobjects/skypoint.h"
0011 
0012 #include <QDialog>
0013 
0014 class QListWidget;
0015 class QPushButton;
0016 
0017 class SkyObject;
0018 class GeoLocation;
0019 
0020 struct FilterParameters
0021 {
0022     double maglimit;
0023     bool needMagnitude;
0024     bool needNoMagnitude;
0025     bool needRegion;
0026     bool needDate;
0027     bool doBuildList;
0028 };
0029 
0030 class ObsListWizardUI : public QFrame, public Ui::ObsListWizard
0031 {
0032     Q_OBJECT
0033 
0034   public:
0035     explicit ObsListWizardUI(QWidget *p);
0036 };
0037 
0038 /**
0039  * @class ObsListWizard
0040  * @short Wizard for constructing observing lists
0041  *
0042  * @author Jason Harris
0043  */
0044 class ObsListWizard : public QDialog
0045 {
0046     Q_OBJECT
0047   public:
0048     explicit ObsListWizard(QWidget *parent);
0049     virtual ~ObsListWizard() override = default;
0050 
0051     /** @return reference to QPtrList of objects selected by the wizard */
0052     QList<SkyObject *> &obsList() { return ObsList; }
0053 
0054   private slots:
0055     void slotNextPage();
0056     void slotPrevPage();
0057     void slotAllButton();
0058     void slotNoneButton();
0059     void slotDeepSkyButton();
0060     void slotSolarSystemButton();
0061     void slotChangeLocation();
0062     void slotToggleDateWidgets();
0063     void slotToggleMagWidgets();
0064 
0065     void slotParseRegion();
0066 
0067     /** @short Construct the observing list by applying the selected filters */
0068     void slotObjectCountDirty();
0069     void slotUpdateObjectCount();
0070     void slotApplyFilters() { applyFilters(true); }
0071 
0072   private:
0073     void initialize();
0074     void applyFilters(bool doBuildList);
0075 
0076     /** @return true if the object passes the filter region constraints, false otherwise.*/
0077     bool applyMagnitudeAndRegionAndObservableFilter(SkyObject *o, FilterParameters filterParameters);
0078     bool applyMagnitudeFilter(SkyObject *o, FilterParameters filterParameters);
0079     bool applyRegionFilter(SkyObject *o, bool doBuildList);
0080     bool applyObservableFilter(SkyObject *o, bool doBuildList);
0081 
0082     /**
0083      * Convenience function for safely getting the selected state of a QListWidget item by name.
0084      * QListWidget has no method for easily selecting a single item based on its text.
0085      * @return true if the named QListWidget item is selected.
0086      * @param name the QListWidget item to be queried is the one whose text matches this string
0087      * @param listWidget pointer to the QListWidget whose item is to be queried
0088      * @param ok pointer to a bool, which if present will return true if a matching list item was found
0089      */
0090     bool isItemSelected(const QString &name, QListWidget *listWidget);
0091     /**
0092      * Convenience function for safely setting the selected state of a QListWidget item by name.
0093      * QListWidget has no method for easily selecting a single item based on its text.
0094      * @param name the QListWidget item to be (de)selected is the one whose text matches this string
0095      * @param listWidget pointer to the QListWidget whose item is to be (de)selected
0096      * @param value set the item's selected state to this bool value
0097      */
0098     void setItemSelected(const QString &name, QListWidget *listWidget, bool value);
0099 
0100     QList<SkyObject *> ObsList;
0101     ObsListWizardUI *olw { nullptr };
0102     uint ObjectCount { 0 };
0103     uint StarCount { 0 };
0104     uint PlanetCount { 0 };
0105     uint CometCount { 0 };
0106     uint AsteroidCount { 0 };
0107     uint GalaxyCount { 0 };
0108     uint OpenClusterCount { 0 };
0109     uint GlobClusterCount { 0 };
0110     uint GasNebCount { 0 };
0111     uint PlanNebCount { 0 };
0112     const char* sun_moon_planets_list[9] = { // Move this def? And pNames in modCalcPlanets.cpp etc...
0113         "Sun" ,"Moon" ,"Mercury" ,"Venus" ,"Mars" ,"Jupiter" ,"Saturn" ,"Uranus" ,"Neptune" };
0114     const char* ALL_OVER_THE_SKY = "all over the sky";
0115     const char* BY_CONSTELLATION = "by constellation";
0116     const char* IN_A_RECTANGULAR_REGION = "in a rectangular region";
0117     const char* IN_A_CIRCULAR_REGION = "in a circular region";
0118     const int PAGE_ID_MAIN          = 0;
0119     const int PAGE_ID_OBJECT_TYPE   = 1;
0120     const int PAGE_ID_REGION_TYPE   = 2;
0121     const int PAGE_ID_CONSTELLATION = 3;
0122     const int PAGE_ID_RECTANGULAR   = 4;
0123     const int PAGE_ID_CIRCULAR      = 5;
0124     const int PAGE_ID_DATE          = 6;
0125     const int PAGE_ID_MAGNITUDE     = 7;
0126 
0127     double xRect1 { 0 };
0128     double xRect2 { 0 };
0129     double yRect1 { 0 };
0130     double yRect2 { 0 };
0131     double rCirc { 0 };
0132     SkyPoint pCirc;
0133     GeoLocation *geo { nullptr };
0134     QPushButton *nextB { nullptr };
0135     QPushButton *backB { nullptr };
0136 
0137 };
0138