Home · All Namespaces · All Classes · Functions · Coding Style · 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 
00037 class StelObjectMgr : public StelModule
00038 {
00039 public:
00040     StelObjectMgr();
00041     virtual ~StelObjectMgr();
00042     
00044     // Methods defined in the StelModule class
00045     virtual void init() {;}
00046     virtual void draw(StelCore* core) {;}
00047     virtual void update(double deltaTime) {;}
00049     virtual void handleMouseClicks(class QMouseEvent* event);
00050     
00052     
00055     void registerStelObjectMgr(StelObjectModule* mgr);
00056 
00062     bool findAndSelect(const StelCore* core, const Vec3d& pos, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00063 
00070     bool findAndSelect(const StelCore* core, int x, int y, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00071 
00076     bool findAndSelectI18n(const QString &nameI18n, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00077 
00082     bool findAndSelect(const QString &name, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00083 
00088     QStringList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5) const;
00089 
00091     bool getWasSelected(void) const {return !lastSelectedObjects.empty();}
00092 
00094     void unSelect(void);
00095 
00100     bool setSelectedObject(const StelObjectP obj, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00101     
00106     bool setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection);
00107 
00109     const QList<StelObjectP>& getSelectedObject() const {return lastSelectedObjects;}
00110     
00113     QList<StelObjectP> getSelectedObject(const QString& type);
00114 
00116     void setFlagSelectedObjectPointer(bool b) { objectPointerVisibility = b; }
00117     
00119     StelObjectP searchByNameI18n(const QString &name) const;
00120 
00122     StelObjectP searchByName(const QString &name) const;
00123 
00124 private:
00125     // The list of StelObjectModule that are referenced in Stellarium
00126     QList<StelObjectModule*> objectsModule; 
00127     // The last selected object in stellarium
00128     QList<StelObjectP> lastSelectedObjects;
00129     // Should selected object pointer be drawn
00130     bool objectPointerVisibility;   
00131 
00133     StelObjectP cleverFind(const StelCore* core, const Vec3d& pos) const;
00134     
00136     StelObjectP cleverFind(const StelCore* core, int x, int y) const;   
00137 };
00138 
00139 #endif // _SELECTIONMGR_HPP_

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5