Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

modules/StarMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2002 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 _STARMGR_HPP_
00021 #define _STARMGR_HPP_
00022 
00023 #include <vector>
00024 #include <map>
00025 #include "StelFader.hpp"
00026 #include "StelObjectModule.hpp"
00027 #include "StelTextureTypes.hpp"
00028 #include "StelProjectorType.hpp"
00029 
00030 class StelObject;
00031 class StelToneReproducer;
00032 class StelProjector;
00033 class StelNavigator;
00034 class StelLoadingBar;
00035 class StelFont;
00036 class QSettings;
00037 
00038 namespace BigStarCatalogExtension {
00039   class ZoneArray;
00040   class HipIndexStruct;
00041 }
00042 
00066 class StarMgr : public StelObjectModule
00067 {   
00068     Q_OBJECT
00069     
00070 public:
00071     StarMgr(void);
00072     ~StarMgr(void);
00073     
00075     // Methods defined in the StelModule class
00083     virtual void init();
00084     
00086     virtual void draw(StelCore* core); 
00087     
00090     virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
00091     
00093     virtual void updateI18n();
00094     
00098     virtual void updateSkyCulture(const QString& skyCultureDir);
00099     
00101     virtual void setStelStyle(const StelStyle& style);
00102     
00104     virtual double getCallOrder(StelModuleActionName actionName) const;
00105     
00107     // Methods defined in StelObjectManager class
00109     virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
00110     
00114     virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;    
00115 
00118     virtual StelObjectP searchByName(const QString& name) const;
00119 
00124     virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
00125     
00126 public slots:
00128     // Methods callable from script and GUI
00130     void setLabelColor(const Vec3f& c) {labelColor = c;}
00132     Vec3f getLabelColor(void) const {return labelColor;}
00133     
00135     void setFlagStars(bool b) {starsFader=b;}
00137     bool getFlagStars(void) const {return starsFader==true;}
00138     
00140     void setFlagLabels(bool b) {labelsFader=b;}
00142     bool getFlagLabels(void) const {return labelsFader==true;}
00143     
00147     void setLabelsAmount(float a) {labelsAmount=a;}
00150     float getLabelsAmount(void) const {return labelsAmount;}
00151     
00153     void setFontSize(double newFontSize);
00154     
00156     static void setFlagSciNames(bool f) {flagSciNames = f;}
00157     static bool getFlagSciNames(void) {return flagSciNames;}
00158     
00159     QSettings* getStarSettings(void) {return starSettings;}
00160 
00161 public:
00163     // Other methods
00168     StelObjectP searchHP(int hip) const;
00169     
00172     static QString getCommonName(int hip);
00173     
00176     static QString getSciName(int hip);
00177     
00178     static QString convertToSpectralType(int index);
00179     static QString convertToComponentIds(int index);
00180     
00181 private:
00182     
00186     int loadCommonNames(const QString& commonNameFile);
00187     
00191     void loadSciNames(const QString& sciNameFile);
00192     
00194     // TODO: add a non-lame description - what is the purpose of the max search level?
00195     int getMaxSearchLevel() const;
00196     
00198     void loadData();
00199     
00201     void loadStarSettings(void);
00202     
00204     void drawPointer(const StelProjectorP& prj, const StelNavigator * nav);
00205     
00206     LinearFader labelsFader;
00207     LinearFader starsFader;
00208     
00209     bool flagStarName;
00210     float labelsAmount;
00211     bool gravityLabel;
00212     
00213     int maxGeodesicGridLevel;
00214     int lastMaxSearchLevel;
00215     typedef std::map<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
00216     ZoneArrayMap zoneArrays; // index is the grid level
00217     static void initTriangleFunc(int lev, int index,
00218                                  const Vec3d &c0,
00219                                  const Vec3d &c1,
00220                                  const Vec3d &c2,
00221                                  void *context)
00222     {
00223         reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
00224     }
00225     
00226     void initTriangle(int lev, int index,
00227                       const Vec3d &c0,
00228                       const Vec3d &c1,
00229                       const Vec3d &c2);
00230     
00231     BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
00232     
00233     static std::map<int, QString> commonNamesMap;
00234     static std::map<int, QString> commonNamesMapI18n;
00235     static std::map<QString, int> commonNamesIndex;
00236     static std::map<QString, int> commonNamesIndexI18n;
00237     
00238     static std::map<int, QString> sciNamesMapI18n;
00239     static std::map<QString, int> sciNamesIndexI18n;
00240     
00241     double fontSize;
00242     StelFont *starFont;
00243     static bool flagSciNames;
00244     Vec3f labelColor;
00245     
00246     StelTextureSP texPointer;       // The selection pointer texture
00247     
00248     QSettings* starSettings;
00249     class StelObjectMgr* objectMgr;
00250 };
00251 
00252 
00253 #endif // _STARMGR_HPP_
00254 

Generated on Mon Mar 9 16:16:16 2009 for Stellarium by  doxygen 1.5.5