Stellarium  0.16.1
SolarSystemEditor.hpp
1 /*
2  * Solar System editor plug-in for Stellarium
3  *
4  * Copyright (C) 2010 Bogdan Marinov
5  * Copyright (C) 2017 Georg Zotti (changes for 0.16)
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  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
20  */
21 
22 #ifndef _SOLAR_SYSTEM_EDITOR_HPP_
23 #define _SOLAR_SYSTEM_EDITOR_HPP_
24 
25 #include "StelGui.hpp"
26 #include "StelModule.hpp"
27 //#include "CAIMainWindow.hpp"
28 
29 #include <QHash>
30 #include <QList>
31 #include <QString>
32 #include <QVariant>
33 
35 class SolarSystem;
36 class QSettings;
37 
49 typedef QHash<QString, QVariant> SsoElements;
50 
61 {
62  Q_OBJECT
63 
64 public:
66  virtual ~SolarSystemEditor();
67 
69  // Methods inherited from the StelModule class
72  virtual void init();
75  virtual void deinit(){}
77  virtual void update(double deltaTime){Q_UNUSED(deltaTime)}
80  virtual void draw(StelCore * core){Q_UNUSED(core)}
81  virtual double getCallOrder(StelModuleActionName actionName) const;
83  virtual bool configureGui(bool show);
84 
96  SsoElements readMpcOneLineCometElements(QString oneLineElements) const;
97 
107  SsoElements readMpcOneLineMinorPlanetElements(QString oneLineElements) const;
108 /* DEAD CODE. MAYBE REACTIVATE as scripting function (public slot)?
119  SsoElements readXEphemOneLineElements(QString oneLineElements);
120 */
128  QList<SsoElements> readMpcOneLineCometElementsFromFile(QString filePath) const;
129 
137  QList<SsoElements> readMpcOneLineMinorPlanetElementsFromFile(QString filePath) const;
138 
139  /*
140  * GZ identified as DEAD CODE as of 0.16pre. Maybe reactivate as public slot for scripting use?
151  QList<SsoElements> readXEphemOneLineElementsFromFile(QString filePath);
152  */
153 
160  bool appendToSolarSystemConfigurationFile(SsoElements object);
161 
185  bool appendToSolarSystemConfigurationFile(QList<SsoElements>);
186 
188  enum UpdateFlag {
190  UpdateType = 0x02,
193  };
194  Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
195 
196 
197  bool updateSolarSystemConfigurationFile(QList<SsoElements> objects, UpdateFlags flags);
201 
205  QHash<QString,QString> getDefaultSsoIdentifiers() const {return defaultSsoIdentifiers;}
206 
209  QHash<QString,QString> listAllLoadedSsoIdentifiers() const;
210 
217  bool removeSsoWithName(QString name);
218 
220  bool copySolarSystemConfigurationFileTo(QString filePath);
223  bool replaceSolarSystemConfigurationFileWith(QString filePath);
227  bool addFromSolarSystemConfigurationFile(QString filePath);
228 
230  QString getCustomSolarSystemFilePath() const {return customSolarSystemFilePath;}
231 
232 public slots:
236 
237 signals:
238  //TODO: This should be part of SolarSystem::reloadPlanets()
239  void solarSystemChanged();
240 
241 private slots:
242  void updateI18n();
243 
244 private:
245  bool isInitialized;
246 
248  SolarSystemManagerWindow * mainWindow;
249 
250  QSettings * solarSystemConfigurationFile;
251  SolarSystem * solarSystem;
252 
253  QString customSolarSystemFilePath;
254  QString defaultSolarSystemFilePath;
255  QString majorSolarSystemFilePath; // install dir's ssystem_major.ini
256 
259 
263  QHash<QString,QString> defaultSsoIdentifiers;
264 
269  QHash<QString,QString> listAllLoadedObjectsInFile(QString filePath) const;
270 
273  bool cloneSolarSystemConfigurationFile() const;
274 
279  bool resetSolarSystemConfigurationFile() const;
280 
287  static int unpackDayOrMonthNumber (QChar digit);
292  static int unpackYearNumber (QChar prefix, int lastTwoDigits);
296  static int unpackAlphanumericNumber (QChar prefix, int lastDigit);
297 
298  //TODO: This should be public, perhaps?
303  static QString unpackMinorPlanetProvisionalDesignation(QString packedDesignation);
304 
306  static void updateSsoProperty(QSettings& configuration, SsoElements& properties, QString key);
307 
309  static QString convertToGroupName(QString& name, int minorPlanetNumber = 0);
311  static QString fixGroupName(QString &name);
312 };
313 
314 
315 
316 #include <QObject>
317 #include "StelPluginInterface.hpp"
318 
321 {
322  Q_OBJECT
323  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
324  Q_INTERFACES(StelPluginInterface)
325 public:
326  virtual StelModule* getStelModule() const;
327  virtual StelPluginInfo getPluginInfo() const;
328  virtual QObjectList getExtensionList() const { return QObjectList(); }
329 };
330 
331 #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)
Does nothing.
bool removeSsoWithName(QString name)
Removes an object from the user Solar System configuration file.
QList< SsoElements > readMpcOneLineCometElementsFromFile(QString filePath) const
Reads a list of comet orbital elements from a file.
QList< SsoElements > readMpcOneLineMinorPlanetElementsFromFile(QString filePath) const
Reads a list of minor planet orbital elements from a file.
bool copySolarSystemConfigurationFileTo(QString filePath)
Export current minor bodies file from user data directory (if it exists) to filePath. Return true on success.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
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.
bool addFromSolarSystemConfigurationFile(QString filePath)
(new 0.16) Loads all new objects from filePath (an .ini file).
QHash< QString, QString > getDefaultSsoIdentifiers() const
Returns the names of the objects listed in the default ssystem_major.ini.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
QHash< QString, QString > listAllLoadedSsoIdentifiers() const
Lists the objects listed in the current user ssystem.ini.
SsoElements readMpcOneLineCometElements(QString oneLineElements) const
Reads a single comet&#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 which allows editing (add, delete, update) of the minor...
SsoElements readMpcOneLineMinorPlanetElements(QString oneLineElements) const
Reads a single minor planet&#39;s orbital elements from a string.
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
bool replaceSolarSystemConfigurationFileWith(QString filePath)
Replace current minor bodies file in the user data directory.
Update the values in the two parameter system, or add them if they are missing and the type allows...
Update the name and minor planet number, if any.
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
virtual void draw(StelCore *core)
draws on the view port.
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.