Stellarium 0.12.3
SolarSystemEditor.hpp
1 /*
2  * Solar System editor plug-in for Stellarium
3  *
4  * Copyright (C) 2010 Bogdan Marinov
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  *
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 _SOLAR_SYSTEM_EDITOR_HPP_
22 #define _SOLAR_SYSTEM_EDITOR_HPP_
23 
24 #include "StelGui.hpp"
25 #include "StelModule.hpp"
26 //#include "CAIMainWindow.hpp"
27 
28 #include <QHash>
29 #include <QList>
30 #include <QString>
31 #include <QVariant>
32 
34 class SolarSystem;
35 class QSettings;
36 
48 typedef QHash<QString, QVariant> SsoElements;
49 
60 {
61  Q_OBJECT
62 
63 public:
65  virtual ~SolarSystemEditor();
66 
68  // Methods inherited from the StelModule class
71  virtual void init();
74  virtual void deinit();
75  virtual void update(double deltaTime);
80  virtual void draw(StelCore * core, class StelRenderer* renderer);
81  virtual double getCallOrder(StelModuleActionName actionName) const;
83  virtual bool configureGui(bool show);
84 
96  SsoElements readMpcOneLineCometElements(QString oneLineElements);
97 
107  SsoElements readMpcOneLineMinorPlanetElements(QString oneLineElements);
108 
119  SsoElements readXEphemOneLineElements(QString oneLineElements);
120 
128  QList<SsoElements> readMpcOneLineCometElementsFromFile(QString filePath);
129 
137  QList<SsoElements> readMpcOneLineMinorPlanetElementsFromFile(QString filePath);
138 
149  QList<SsoElements> readXEphemOneLineElementsFromFile(QString filePath);
150 
157  bool appendToSolarSystemConfigurationFile(SsoElements object);
158 
178  bool appendToSolarSystemConfigurationFile(QList<SsoElements>);
179 
181  enum UpdateFlag {
183  UpdateType = 0x02,
186  };
187  Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
188 
189 
190 
191 
192 
193  bool updateSolarSystemConfigurationFile(QList<SsoElements> objects, UpdateFlags flags);
194 
198  QHash<QString,QString> getDefaultSsoIdentifiers() {return defaultSsoIdentifiers;}
199 
202  QHash<QString,QString> listAllLoadedSsoIdentifiers();
203 
210  bool removeSsoWithName(QString name);
211 
213  bool copySolarSystemConfigurationFileTo(QString filePath);
215  bool replaceSolarSystemConfigurationFileWith(QString filePath);
216 
218  QString getCustomSolarSystemFilePath() const {return customSolarSystemFilePath;}
219 
220 public slots:
224 
225 signals:
226  //TODO: This should be part of SolarSystem::reloadPlanets()
227  void solarSystemChanged();
228 
229 private slots:
230  void updateI18n();
231 
232 private:
233  bool isInitialized;
234 
236  SolarSystemManagerWindow * mainWindow;
237 
238  QSettings * solarSystemConfigurationFile;
239  SolarSystem * solarSystemManager;
240 
241  QString customSolarSystemFilePath;
242  QString defaultSolarSystemFilePath;
243 
246 
250  QHash<QString,QString> defaultSsoIdentifiers;
251 
256  QHash<QString,QString> listAllLoadedObjectsInFile(QString filePath);
257 
260  bool cloneSolarSystemConfigurationFile();
261 
266  bool resetSolarSystemConfigurationFile();
267 
274  int unpackDayOrMonthNumber (QChar digit);
279  int unpackYearNumber (QChar prefix, int lastTwoDigits);
283  int unpackAlphanumericNumber (QChar prefix, int lastDigit);
284 
285  //TODO: This should be public and static, perhaps?
290  QString unpackMinorPlanetProvisionalDesignation(QString packedDesignation);
291 
293  void updateSsoProperty(QSettings& configuration, SsoElements& properties, QString key);
294 
296  QString convertToGroupName(QString& name, int minorPlanetNumber = 0);
297 };
298 
299 
300 #include "fixx11h.h"
301 #include <QObject>
302 #include "StelPluginInterface.hpp"
303 
306 {
307  Q_OBJECT
308  Q_INTERFACES(StelPluginInterface)
309 public:
310  virtual StelModule* getStelModule() const;
311  virtual StelPluginInfo getPluginInfo() const;
312 };
313 
314 #endif //_SOLAR_SYSTEM_EDITOR_HPP_