Stellarium 0.14.3
AstroCalcDialog.hpp
1 /*
2  * Stellarium
3  *
4  * Copyright (C) 2015 Alexander Wolf
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18 */
19 
20 #ifndef _ASTROCALCDIALOG_HPP_
21 #define _ASTROCALCDIALOG_HPP_
22 
23 #include <QObject>
24 #include <QTreeWidget>
25 #include <QTreeWidgetItem>
26 #include <QMap>
27 
28 #include "StelDialog.hpp"
29 #include "StelCore.hpp"
30 #include "Planet.hpp"
31 
32 class Ui_astroCalcDialogForm;
33 
35 {
36  Q_OBJECT
37 
38 public:
42  ColumnName,
48  };
49 
53  EphemerisDate,
59  };
60 
64  PhenomenaType,
70  };
71 
72  AstroCalcDialog(QObject* parent);
73  virtual ~AstroCalcDialog();
74 
75 public slots:
76  void retranslate();
77 
78 protected:
80  virtual void createDialogContent();
81  Ui_astroCalcDialogForm *ui;
82 
83 private slots:
85  void currentPlanetaryPositions();
86  void selectCurrentPlanetaryPosition(const QModelIndex &modelIndex);
87 
89  void generateEphemeris();
90  void selectCurrentEphemeride(const QModelIndex &modelIndex);
91 
93  void calculatePhenomena();
94  void selectCurrentPhenomen(const QModelIndex &modelIndex);
95 
96 private:
97  class StelCore* core;
98  class SolarSystem* solarSystem;
99  class StelObjectMgr* objectMgr;
100 
102  void setPlanetaryPositionsHeaderNames();
104  void setEphemerisHeaderNames();
106  void setPhenomenaHeaderNames();
107 
109  void initListPlanetaryPositions();
111  void initListEphemeris();
113  void initListPhenomena();
114 
119  void populateCelestialBodyList();
121  void populateEphemerisTimeStepsList();
123  void populateMajorPlanetList();
125  void populateGroupCelestialBodyList();
126 
131  QMap<double, double> findClosestApproach(PlanetP& object1, PlanetP& object2, double startJD, double stopJD, float maxSeparation, bool opposition);
132  double findDistance(double JD, PlanetP object1, PlanetP object2, bool opposition);
133  bool findPrecise(QPair<double, double>* out, PlanetP object1, PlanetP object2, double JD, double step, int prevSign, bool opposition);
134  void fillPhenomenaTable(const QMap<double, double> list, const PlanetP object1, const PlanetP object2, bool opposition);
135 };
136 
137 // Reimplements the QTreeWidgetItem class to fix the sorting bug
138 class ACTreeWidgetItem : public QTreeWidgetItem
139 {
140 public:
141  ACTreeWidgetItem(QTreeWidget* parent)
142  : QTreeWidgetItem(parent)
143  {
144  }
145 
146 private:
147  bool operator < (const QTreeWidgetItem &other) const
148  {
149  int column = treeWidget()->sortColumn();
150 
151  if (column == AstroCalcDialog::ColumnMagnitude)
152  {
153  return text(column).toFloat() < other.text(column).toFloat();
154  }
155  else
156  {
157  return text(column).toLower() < other.text(column).toLower();
158  }
159  }
160 };
161 
162 #endif // _ASTROCALCDIALOG_HPP_
EphemerisColumns
Defines the number and the order of the columns in the ephemeris table.
date and time of ephemeris
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:44
PhenomenaColumns
Defines the number and the order of the columns in the phenomena table.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:46
virtual void createDialogContent()
Initialize the dialog widgets and connect the signals/slots.
date and time of ephemeris
Manage the selection and queries on one or more StelObjects.
PlanetaryPositionsColumns
Defines the number and the order of the columns in the table that lists planetary positions...