Stellarium 0.12.3
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 <QList>
24 #include <QString>
25 #include "VecMath.hpp"
26 #include "StelModule.hpp"
27 #include "StelObject.hpp"
28 
29 class StelObjectModule;
30 class StelCore;
31 
35 class StelObjectMgr : public StelModule
36 {
37  Q_OBJECT
38 public:
39  StelObjectMgr();
40  virtual ~StelObjectMgr();
41 
43  // Methods defined in the StelModule class
44  virtual void init() {;}
45  virtual void draw(StelCore*, class StelRenderer*) {;}
46  virtual void update(double) {;}
47 
52 
59 
67 
73 
79 
84  QStringList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5) const;
85 
90  QStringList listMatchingObjects(const QString& objPrefix, unsigned int maxNbItem=5) const;
91 
92  QStringList listAllModuleObjects(const QString& moduleId, bool inEnglish) const;
93  QMap<QString, QString> objectModulesMap() const;
94 
96  bool getWasSelected(void) const {return !lastSelectedObjects.empty();}
97 
99  void unSelect(void);
100 
106 
111  bool setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
112 
114  const QList<StelObjectP>& getSelectedObject() const {return lastSelectedObjects;}
115 
118  QList<StelObjectP> getSelectedObject(const QString& type);
119 
121  void setFlagSelectedObjectPointer(bool b) {objectPointerVisibility=b;}
123  bool getFlagSelectedObjectPointer(void) {return objectPointerVisibility;}
124 
126  StelObjectP searchByNameI18n(const QString &name) const;
127 
129  StelObjectP searchByName(const QString &name) const;
130 
132  void setObjectSearchRadius(float radius) {searchRadiusPixel=radius;}
133 
136  void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
137 
138 signals:
142 
143 private:
144  // The list of StelObjectModule that are referenced in Stellarium
145  QList<StelObjectModule*> objectsModule;
146  // The last selected object in stellarium
147  QList<StelObjectP> lastSelectedObjects;
148  // Should selected object pointer be drawn
149  bool objectPointerVisibility;
150 
152  StelObjectP cleverFind(const StelCore* core, const Vec3d& pos) const;
153 
155  StelObjectP cleverFind(const StelCore* core, int x, int y) const;
156 
157  // Radius in pixel in which objects will be searched when clicking on a point in sky.
158  float searchRadiusPixel;
159 
160  // Weight of the distance factor when choosing the best object to select.
161  float distanceWeight;
162 };
163 
164 #endif // _SELECTIONMGR_HPP_