Stellarium 0.15.2
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);
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  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 
301 #include <QObject>
302 #include "StelPluginInterface.hpp"
303 
306 {
307  Q_OBJECT
308  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
309  Q_INTERFACES(StelPluginInterface)
310 public:
311  virtual StelModule* getStelModule() const;
312  virtual StelPluginInfo getPluginInfo() const;
313 };
314 
315 #endif //_SOLAR_SYSTEM_EDITOR_HPP_
Update objects that lack the "type" parameter.
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations.
Define the interface to implement when creating a plugin.
virtual void update(double deltaTime)
Update the module with respect to the time.
bool removeSsoWithName(QString name)
Removes an object from the user Solar System configuration file.
QHash< QString, QString > listAllLoadedSsoIdentifiers()
Lists the objects listed in the current user ssystem.ini.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
QList< SsoElements > readMpcOneLineMinorPlanetElementsFromFile(QString filePath)
Reads a list of minor planet orbital elements from a file.
Update the orbital elements, including the orbit function.
QString getCustomSolarSystemFilePath() const
returns the path
void resetSolarSystemToDefault()
Resets the Solar System configuration file and reloads the Solar System.
QHash< QString, QString > getDefaultSsoIdentifiers()
Returns the names of the objects listed in the default ssystem.ini.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
QList< SsoElements > readXEphemOneLineElementsFromFile(QString filePath)
Reads a list of Solar System object orbital elements from a file.
SsoElements readXEphemOneLineElements(QString oneLineElements)
Reads a single object&#39;s orbital elements from a string.
virtual void deinit()
called before the plug-in is un-loaded.
Main class of the Solar System Editor plug-in.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
Main window for handling Solar System objects.
virtual bool configureGui(bool show)
called when the "configure" button in the "Plugins" tab is pressed
Update the values in the two parameter system, or add them if they are missing and the type allows...
QList< SsoElements > readMpcOneLineCometElementsFromFile(QString filePath)
Reads a list of comet orbital elements from a file.
Update the name and minor planet number, if any.
SsoElements readMpcOneLineMinorPlanetElements(QString oneLineElements)
Reads a single minor planet&#39;s orbital elements from a string.
virtual void draw(StelCore *core)
draws on the view port.
SsoElements readMpcOneLineCometElements(QString oneLineElements)
Reads a single comet&#39;s orbital elements from a string.
bool updateSolarSystemConfigurationFile(QList< SsoElements > objects, UpdateFlags flags)
Updates entries in the user solar system configuration file.
This class is used by Qt to manage a plug-in interface.
UpdateFlag
Flags to control the updateSolarSystemConfigurationFile() function.
virtual void init()
called when the plug-in is loaded.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.
bool appendToSolarSystemConfigurationFile(SsoElements object)
Adds a new entry at the end of the user solar system configuration file.