Stellarium 0.12.4
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 
85  QStringList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const;
86 
92  QStringList listMatchingObjects(const QString& objPrefix, unsigned int maxNbItem=5, bool useStartOfWords=false) const;
93 
94  QStringList listAllModuleObjects(const QString& moduleId, bool inEnglish) const;
95  QMap<QString, QString> objectModulesMap() const;
96 
98  bool getWasSelected(void) const {return !lastSelectedObjects.empty();}
99 
101  void unSelect(void);
102 
108 
113  bool setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
114 
116  const QList<StelObjectP>& getSelectedObject() const {return lastSelectedObjects;}
117 
120  QList<StelObjectP> getSelectedObject(const QString& type);
121 
123  void setFlagSelectedObjectPointer(bool b) {objectPointerVisibility=b;}
125  bool getFlagSelectedObjectPointer(void) {return objectPointerVisibility;}
126 
128  StelObjectP searchByNameI18n(const QString &name) const;
129 
131  StelObjectP searchByName(const QString &name) const;
132 
134  void setObjectSearchRadius(float radius) {searchRadiusPixel=radius;}
135 
138  void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
139 
140 signals:
144 
145 private:
146  // The list of StelObjectModule that are referenced in Stellarium
147  QList<StelObjectModule*> objectsModule;
148  // The last selected object in stellarium
149  QList<StelObjectP> lastSelectedObjects;
150  // Should selected object pointer be drawn
151  bool objectPointerVisibility;
152 
154  StelObjectP cleverFind(const StelCore* core, const Vec3d& pos) const;
155 
157  StelObjectP cleverFind(const StelCore* core, int x, int y) const;
158 
159  // Radius in pixel in which objects will be searched when clicking on a point in sky.
160  float searchRadiusPixel;
161 
162  // Weight of the distance factor when choosing the best object to select.
163  float distanceWeight;
164 };
165 
166 #endif // _SELECTIONMGR_HPP_