Stellarium 0.15.2
AstroCalcDialog.hpp
1 /*
2  * Stellarium
3  *
4  * Copyright (C) 2015 Alexander Wolf
5  * Copyright (C) 2016 Nick Fedoseev (visualization of ephemeris)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19 */
20 
21 #ifndef _ASTROCALCDIALOG_HPP_
22 #define _ASTROCALCDIALOG_HPP_
23 
24 #include <QObject>
25 #include <QTreeWidget>
26 #include <QTreeWidgetItem>
27 #include <QMap>
28 #include <QVector>
29 #include <QTimer>
30 
31 #include "StelDialog.hpp"
32 #include "StelCore.hpp"
33 #include "Planet.hpp"
34 #include "SolarSystem.hpp"
35 #include "Nebula.hpp"
36 #include "NebulaMgr.hpp"
37 #include "StarMgr.hpp"
38 
39 class Ui_astroCalcDialogForm;
40 class QListWidgetItem;
41 
43 {
44  Q_OBJECT
45 
46 public:
50  ColumnName,
56  };
57 
61  EphemerisDate,
67  };
68 
72  PhenomenaType,
78  };
79 
80  AstroCalcDialog(QObject* parent);
81  virtual ~AstroCalcDialog();
82 
84  void styleChanged();
85 
86  static QVector<Vec3d> EphemerisListJ2000;
87  static QVector<QString> EphemerisListDates;
88  static int DisplayedPositionIndex;
89 
90 public slots:
91  void retranslate();
92 
93 protected:
95  virtual void createDialogContent();
96  Ui_astroCalcDialogForm *ui;
97 
98 private slots:
100  void currentPlanetaryPositions();
101  void selectCurrentPlanetaryPosition(const QModelIndex &modelIndex);
102  void onChangedEphemerisPosition(const QModelIndex &modelIndex);
103 
105  void generateEphemeris();
106  void cleanupEphemeris();
107  void selectCurrentEphemeride(const QModelIndex &modelIndex);
108  void saveEphemeris();
109 
111  void calculatePhenomena();
112  void selectCurrentPhenomen(const QModelIndex &modelIndex);
113  void savePhenomena();
114 
115  void drawAltVsTimeDiagram();
116  void drawCurrentTimeDiagram();
117  void mouseOverLine(QMouseEvent *event);
118 
119  void changePage(QListWidgetItem *current, QListWidgetItem *previous);
120 
121  void updateSolarSystemData();
122 
123 private:
124  class StelCore* core;
125  class SolarSystem* solarSystem;
126  class NebulaMgr* dsoMgr;
127  class StarMgr* starMgr;
128  class StelObjectMgr* objectMgr;
129  QTimer *currentTimeLine;
130 
132  void setPlanetaryPositionsHeaderNames();
134  void setEphemerisHeaderNames();
136  void setPhenomenaHeaderNames();
137 
139  void initListPlanetaryPositions();
141  void initListEphemeris();
143  void initListPhenomena();
144 
149  void populateCelestialBodyList();
151  void populateEphemerisTimeStepsList();
153  void populateMajorPlanetList();
155  void populateGroupCelestialBodyList();
157  void prepareAxesAndGraph();
158 
163  QMap<double, double> findClosestApproach(PlanetP& object1, PlanetP& object2, double startJD, double stopJD, double maxSeparation, bool opposition);
164  double findDistance(double JD, PlanetP object1, PlanetP object2, bool opposition);
165  bool findPrecise(QPair<double, double>* out, PlanetP object1, PlanetP object2, double JD, double step, int prevSign, bool opposition);
166  void fillPhenomenaTable(const QMap<double, double> list, const PlanetP object1, const PlanetP object2, bool opposition);
167 
168  QMap<double, double> findClosestApproach(PlanetP& object1, NebulaP& object2, double startJD, double stopJD, double maxSeparation);
169  double findDistance(double JD, PlanetP object1, NebulaP object2);
170  bool findPrecise(QPair<double, double>* out, PlanetP object1, NebulaP object2, double JD, double step, int prevSign);
171  void fillPhenomenaTable(const QMap<double, double> list, const PlanetP object1, const NebulaP object2);
172 
173  QMap<double, double> findClosestApproach(PlanetP& object1, StelObjectP& object2, double startJD, double stopJD, double maxSeparation);
174  double findDistance(double JD, PlanetP object1, StelObjectP object2);
175  bool findPrecise(QPair<double, double>* out, PlanetP object1, StelObjectP object2, double JD, double step, int prevSign);
176  void fillPhenomenaTable(const QMap<double, double> list, const PlanetP object1, const StelObjectP object2);
177 
178  QString delimiter, acEndl;
179  QStringList ephemerisHeader, phenomenaHeader, planetaryPositionsHeader;
180  static float brightLimit;
181  static float minY, maxY;
182 
185  void updateTabBarListWidgetWidth();
186 };
187 
188 // Reimplements the QTreeWidgetItem class to fix the sorting bug
189 class ACTreeWidgetItem : public QTreeWidgetItem
190 {
191 public:
192  ACTreeWidgetItem(QTreeWidget* parent)
193  : QTreeWidgetItem(parent)
194  {
195  }
196 
197 private:
198  bool operator < (const QTreeWidgetItem &other) const
199  {
200  int column = treeWidget()->sortColumn();
201 
202  if (column == AstroCalcDialog::ColumnMagnitude)
203  {
204  return text(column).toFloat() < other.text(column).toFloat();
205  }
206  else
207  {
208  return text(column).toLower() < other.text(column).toLower();
209  }
210  }
211 };
212 
213 #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:72
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:47
virtual void createDialogContent()
Initialize the dialog widgets and connect the signals/slots.
date and time of ephemeris
Stores the star catalogue data.
Definition: StarMgr.hpp:88
Manage the selection and queries on one or more StelObjects.
void styleChanged()
Notify that the application style changed.
PlanetaryPositionsColumns
Defines the number and the order of the columns in the table that lists planetary positions...
Manage a collection of nebulae.
Definition: NebulaMgr.hpp:48