Stellarium 0.15.2
CustomObjectMgr.hpp
1 /*
2  * Copyright (C) 2016 Alexander Wolf
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef _CUSTOMOBJECTMGR_HPP_
20 #define _CUSTOMOBJECTMGR_HPP_
21 
22 #include "StelObjectModule.hpp"
23 #include "StelObject.hpp"
24 #include "StelTextureTypes.hpp"
25 #include "CustomObject.hpp"
26 
27 #include <QFont>
28 #include <QList>
29 
30 class StelPainter;
31 class QSettings;
32 
33 typedef QSharedPointer<CustomObject> CustomObjectP;
34 
36 {
37  Q_OBJECT
38 
39 public:
41  virtual ~CustomObjectMgr();
42 
44  // Methods defined in the StelModule class
45  virtual void init();
46  virtual void deinit();
47  virtual void update(double) {;}
48  virtual void draw(StelCore* core);
49  virtual void drawPointer(StelCore* core, StelPainter& painter);
50  virtual double getCallOrder(StelModuleActionName actionName) const;
51 
53  // Methods defined in StelObjectManager class
59  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
60 
63  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
64 
67  virtual StelObjectP searchByName(const QString& name) const;
68 
74  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const;
75  virtual QStringList listAllObjects(bool inEnglish) const;
76  virtual QString getName() const { return "Custom Objects"; }
77 
80  virtual void handleMouseClicks(class QMouseEvent* e);
81 
82 public slots:
84  // Other public methods
88  CustomObjectP searchByEnglishName(QString customObjectEnglishName) const;
89 
94  void addCustomObject(QString designation, Vec3d coordinates, bool isVisible=false);
104  void addCustomObject(QString designation, const QString& ra, const QString& dec, bool isVisible=false);
114  void addCustomObjectRaDec(QString designation, const QString& ra, const QString& dec, bool isVisible=false);
124  void addCustomObjectAltAzi(QString designation, const QString& alt, const QString& azi, bool isVisible=false);
126  void removeCustomObjects();
127 
134  void setMarkersColor(const Vec3f& c);
137  const Vec3f& getMarkersColor(void) const;
138 
145  void setMarkersSize(const float size);
148  float getMarkersSize(void) const;
149 
150 private slots:
152  void selectedObjectChange(StelModule::StelModuleSelectAction action);
153 
154 private:
155  // Font used for displaying our text
156  QFont font;
157  QSettings* conf;
158  StelTextureSP texPointer;
159  QList<CustomObjectP> customObjects;
160 
161  int countMarkers;
162 
165  void setSelected(const QString& englishName);
167  void setSelected(CustomObjectP obj);
169  CustomObjectP getSelected(void) const {return selected;}
171  CustomObjectP selected;
172 };
173 
174 #endif /*_CUSTOMOBJECTMGR_HPP_*/
virtual QStringList listAllObjects(bool inEnglish) const
List all StelObjects.
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching satellite object&#39;s pointer if exists or NULL.
virtual StelObjectP searchByName(const QString &name) const
Return the matching satellite if exists or NULL.
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
virtual void handleMouseClicks(class QMouseEvent *e)
Handle mouse clicks.
Define the StelTextureSP type.
void addCustomObjectAltAzi(QString designation, const QString &alt, const QString &azi, bool isVisible=false)
Add custom object on the sky.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
Specialization of StelModule which manages a collection of StelObject.
const Vec3f & getMarkersColor(void) const
Get the current color used to draw custom object markers.
void addCustomObjectRaDec(QString designation, const QString &ra, const QString &dec, bool isVisible=false)
Add custom object on the sky.
void addCustomObject(QString designation, Vec3d coordinates, bool isVisible=false)
Add custom object on the sky.
void removeCustomObjects()
Remove all custom objects.
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
CustomObjectP searchByEnglishName(QString customObjectEnglishName) const
Get a pointer to a custom object.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
void setMarkersColor(const Vec3f &c)
Set the color used to draw custom object markers.
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object name...
virtual void init()
Initialize itself.
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:111
void setMarkersSize(const float size)
Set the size of custom object markers.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
virtual QList< StelObjectP > searchAround(const Vec3d &v, double limitFov, const StelCore *core) const
Used to get a list of objects which are near to some position.
float getMarkersSize(void) const
Get the current size used to custom object markers.
virtual void update(double)
Update the module with respect to the time.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
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.