Stellarium 0.13.2
StelObjectMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2007 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELOBJECTMGR_HPP_
21 #define _STELOBJECTMGR_HPP_
22 
23 #include "VecMath.hpp"
24 #include "StelModule.hpp"
25 #include "StelObject.hpp"
26 
27 #include <QList>
28 #include <QString>
29 
30 class StelObjectModule;
31 class StelCore;
32 
36 class StelObjectMgr : public StelModule
37 {
38  Q_OBJECT
39 public:
40  StelObjectMgr();
41  virtual ~StelObjectMgr();
42 
44  // Methods defined in the StelModule class
45  virtual void init() {;}
46  virtual void draw(StelCore*) {;}
47  virtual void update(double) {;}
48 
53 
60 
68 
74 
80 
86  QStringList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const;
87 
93  QStringList listMatchingObjects(const QString& objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const;
94 
95  QStringList listAllModuleObjects(const QString& moduleId, bool inEnglish) const;
96  QMap<QString, QString> objectModulesMap() const;
97 
99  bool getWasSelected(void) const {return !lastSelectedObjects.empty();}
100 
102  void unSelect(void);
103 
109 
114  bool setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
115 
117  const QList<StelObjectP>& getSelectedObject() const {return lastSelectedObjects;}
118 
121  QList<StelObjectP> getSelectedObject(const QString& type);
122 
124  void setFlagSelectedObjectPointer(bool b) {objectPointerVisibility=b;}
126  bool getFlagSelectedObjectPointer(void) {return objectPointerVisibility;}
127 
129  StelObjectP searchByNameI18n(const QString &name) const;
130 
132  StelObjectP searchByName(const QString &name) const;
133 
135  void setObjectSearchRadius(float radius) {searchRadiusPixel=radius;}
136 
139  void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
140 
141 signals:
145 
146 private:
147  // The list of StelObjectModule that are referenced in Stellarium
148  QList<StelObjectModule*> objectsModule;
149  // The last selected object in stellarium
150  QList<StelObjectP> lastSelectedObjects;
151  // Should selected object pointer be drawn
152  bool objectPointerVisibility;
153 
155  StelObjectP cleverFind(const StelCore* core, const Vec3d& pos) const;
156 
158  StelObjectP cleverFind(const StelCore* core, int x, int y) const;
159 
160  // Radius in pixel in which objects will be searched when clicking on a point in sky.
161  float searchRadiusPixel;
162 
163  // Weight of the distance factor when choosing the best object to select.
164  float distanceWeight;
165 };
166 
167 #endif // _SELECTIONMGR_HPP_
bool getFlagSelectedObjectPointer(void)
Get whether a pointer is to be drawn over selected object.
StelObjectP searchByNameI18n(const QString &name) const
Find any kind of object by its translated name.
bool getWasSelected(void) const
Return whether an object was selected during last selection related event.
void selectedObjectChanged(StelModule::StelModuleSelectAction)
Indicate that the selected StelObjects has changed.
void setFlagSelectedObjectPointer(bool b)
Set whether a pointer is to be drawn over selected object.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
void unSelect(void)
Notify that we want to unselect any object.
QStringList listMatchingObjectsI18n(const QString &objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object I18n name...
Specialization of StelModule which manages a collection of StelObject.
virtual void draw(StelCore *)
Execute all the drawing functions for this module.
StelObjectP searchByName(const QString &name) const
Find any kind of object by its standard program name.
QStringList listMatchingObjects(const QString &objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object English name...
bool findAndSelectI18n(const QString &nameI18n, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
Find and select an object from its translated name.
const QList< StelObjectP > & getSelectedObject() const
Get the list objects which was recently selected by the user.
virtual void update(double)
Update the module with respect to the time.
void setDistanceWeight(float newDistanceWeight)
Set the weight of the distance factor when choosing the best object to select.
void registerStelObjectMgr(StelObjectModule *mgr)
Add a new StelObject manager into the list of supported modules.
Manage the selection and queries on one or more StelObjects.
virtual void init()
Initialize itself.
bool setSelectedObject(const StelObjectP obj, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
Notify that we want to select the given object.
bool findAndSelect(const StelCore *core, const Vec3d &pos, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
Find and select an object near given equatorial J2000 position.
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:111
Set the StelObject as the new list of selected ones.
Definition: StelModule.hpp:114
void setObjectSearchRadius(float radius)
Set the radius in pixel in which objects will be searched when clicking on a point in sky...
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:51