Stellarium  0.16.1
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 
69  virtual StelObjectP searchByID(const QString &id) const { return qSharedPointerCast<StelObject>(searchByEnglishName(id)); }
70 
76  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const;
77  virtual QStringList listAllObjects(bool inEnglish) const;
78  virtual QString getName() const { return "Custom Objects"; }
79  virtual QString getStelObjectType() const { return CustomObject::CUSTOMOBJECT_TYPE; }
80 
83  virtual void handleMouseClicks(class QMouseEvent* e);
84 
85 public slots:
87  // Other public methods
91  CustomObjectP searchByEnglishName(QString customObjectEnglishName) const;
92 
97  void addCustomObject(QString designation, Vec3d coordinates, bool isVisible=false);
107  void addCustomObject(QString designation, const QString& ra, const QString& dec, bool isVisible=false);
117  void addCustomObjectRaDec(QString designation, const QString& ra, const QString& dec, bool isVisible=false);
127  void addCustomObjectAltAzi(QString designation, const QString& alt, const QString& azi, bool isVisible=false);
129  void removeCustomObjects();
131  void removeCustomObject(QString englishName);
132 
139  void setMarkersColor(const Vec3f& c);
142  const Vec3f& getMarkersColor(void) const;
143 
150  void setMarkersSize(const float size);
153  float getMarkersSize(void) const;
154 
155 private slots:
157  void selectedObjectChange(StelModule::StelModuleSelectAction action);
158 
160  void removeCustomObject(CustomObjectP);
161 
162 private:
163  // Font used for displaying our text
164  QFont font;
165  QSettings* conf;
166  StelTextureSP texPointer;
167  QList<CustomObjectP> customObjects;
168 
169  int countMarkers;
170  int radiusLimit;
171 
173  void setActiveRadiusLimit(const int radius);
174 
177  void setSelected(const QString& englishName);
179  void setSelected(CustomObjectP obj);
181  CustomObjectP getSelected(void) const {return selected;}
183  CustomObjectP selected;
184 };
185 
186 #endif /*_CUSTOMOBJECTMGR_HPP_*/
virtual QString getName() const
Gets a user-displayable name of the object category.
virtual StelObjectP searchByID(const QString &id) const
Return the StelObject with the given ID if exists or the empty StelObject if not found.
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 Q_NULLPTR.
virtual StelObjectP searchByName(const QString &name) const
Return the matching satellite if exists or Q_NULLPTR.
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 removeCustomObject(QString englishName)
Remove just one custom object by English name.
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
virtual QString getStelObjectType() const
Returns the name that will be returned by StelObject::getType() for the objects this module manages...
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.