Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelObjectMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2007 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef _STELOBJECTMGR_HPP_
00021 #define _STELOBJECTMGR_HPP_
00022 
00023 #include <QList>
00024 #include <QString>
00025 #include "VecMath.hpp"
00026 #include "StelModule.hpp"
00027 #include "StelObject.hpp"
00028 
00029 class StelObjectModule;
00030 class StelCore;
00031 
00035 class StelObjectMgr : public StelModule
00036 {
00037     Q_OBJECT
00038 public:
00039     StelObjectMgr();
00040     virtual ~StelObjectMgr();
00041 
00043     // Methods defined in the StelModule class
00044     virtual void init() {;}
00045     virtual void draw(StelCore*) {;}
00046     virtual void update(double) {;}
00047 
00051     void registerStelObjectMgr(StelObjectModule* mgr);
00052 
00058     bool findAndSelect(const StelCore* core, const Vec3d& pos, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00059 
00066     bool findAndSelect(const StelCore* core, int x, int y, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00067 
00072     bool findAndSelectI18n(const QString &nameI18n, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00073 
00078     bool findAndSelect(const QString &name, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00079 
00084     QStringList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5) const;
00085 
00087     bool getWasSelected(void) const {return !lastSelectedObjects.empty();}
00088 
00090     void unSelect(void);
00091 
00096     bool setSelectedObject(const StelObjectP obj, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00097 
00102     bool setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00103 
00105     const QList<StelObjectP>& getSelectedObject() const {return lastSelectedObjects;}
00106 
00109     QList<StelObjectP> getSelectedObject(const QString& type);
00110 
00112     void setFlagSelectedObjectPointer(bool b) {objectPointerVisibility=b;}
00114     bool getFlagSelectedObjectPointer(void) {return objectPointerVisibility;}
00115 
00117     StelObjectP searchByNameI18n(const QString &name) const;
00118 
00120     StelObjectP searchByName(const QString &name) const;
00121 
00123     void setObjectSearchRadius(float radius) {searchRadiusPixel=radius;}
00124 
00127     void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
00128 
00129 signals:
00132     void selectedObjectChanged(StelModule::StelModuleSelectAction);
00133 
00134 private:
00135     // The list of StelObjectModule that are referenced in Stellarium
00136     QList<StelObjectModule*> objectsModule;
00137     // The last selected object in stellarium
00138     QList<StelObjectP> lastSelectedObjects;
00139     // Should selected object pointer be drawn
00140     bool objectPointerVisibility;
00141 
00143     StelObjectP cleverFind(const StelCore* core, const Vec3d& pos) const;
00144 
00146     StelObjectP cleverFind(const StelCore* core, int x, int y) const;
00147 
00148     // Radius in pixel in which objects will be searched when clicking on a point in sky.
00149     float searchRadiusPixel;
00150 
00151     // Weight of the distance factor when choosing the best object to select.
00152     float distanceWeight;
00153 };
00154 
00155 #endif // _SELECTIONMGR_HPP_
Generated on Sat Aug 25 22:13:30 2012 for Stellarium by  doxygen 1.6.3