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     
00097     virtual void updateSkyCulture();
00098     
00100     virtual void setStelStyle(const StelStyle& style);
00101     
00103     virtual double getCallOrder(StelModuleActionName actionName) const;
00104     
00106     // Methods defined in StelObjectManager class
00108     virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
00109     
00113     virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;    
00114 
00117     virtual StelObjectP searchByName(const QString& name) const;
00118 
00123     virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
00124     
00125 public slots:
00127     // Methods callable from script and GUI
00129     void setLabelColor(const Vec3f& c) {labelColor = c;}
00131     Vec3f getLabelColor(void) const {return labelColor;}
00132     
00134     void setFlagStars(bool b) {starsFader=b;}
00136     bool getFlagStars(void) const {return starsFader==true;}
00137     
00139     void setFlagLabels(bool b) {labelsFader=b;}
00141     bool getFlagLabels(void) const {return labelsFader==true;}
00142     
00146     void setLabelsAmount(float a) {labelsAmount=a;}
00149     float getLabelsAmount(void) const {return labelsAmount;}
00150     
00152     void setFontSize(double newFontSize);
00153     
00155     static void setFlagSciNames(bool f) {flagSciNames = f;}
00156     static bool getFlagSciNames(void) {return flagSciNames;}
00157     
00158     QSettings* getStarSettings(void) {return starSettings;}
00159 
00160 public:
00162     // Other methods
00167     StelObjectP search(Vec3d Pos) const;
00168     
00173     StelObjectP search(const QString& id) const;
00174     
00179     StelObjectP searchHP(int num) const;
00180     
00183     static QString getCommonName(int hip);
00184     
00187     static QString getSciName(int hip);
00188     
00189     static double getCurrentJDay(void) {return currentJDay;}
00190     
00191     static QString convertToSpectralType(int index);
00192     static QString convertToComponentIds(int index);
00193     
00194 private:
00195     
00199     int loadCommonNames(const QString& commonNameFile);
00200     
00204     void loadSciNames(const QString& sciNameFile);
00205     
00207     // TODO: add a non-lame description - what is the purpose of the max search level?
00208     int getMaxSearchLevel() const;
00209     
00211     void loadData();
00212     
00214     void loadStarSettings(void);
00215     
00217     void drawPointer(const StelProjectorP& prj, const StelNavigator * nav);
00218     
00219     LinearFader labelsFader;
00220     LinearFader starsFader;
00221     
00222     bool flagStarName;
00223     float labelsAmount;
00224     bool gravityLabel;
00225     
00226     int maxGeodesicGridLevel;
00227     int lastMaxSearchLevel;
00228     typedef std::map<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
00229     ZoneArrayMap zoneArrays; // index is the grid level
00230     static void initTriangleFunc(int lev, int index,
00231                                  const Vec3d &c0,
00232                                  const Vec3d &c1,
00233                                  const Vec3d &c2,
00234                                  void *context)
00235     {
00236         reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
00237     }
00238     
00239     void initTriangle(int lev, int index,
00240                       const Vec3d &c0,
00241                       const Vec3d &c1,
00242                       const Vec3d &c2);
00243     
00244     BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
00245     
00246     static std::map<int, QString> commonNamesMap;
00247     static std::map<int, QString> commonNamesMapI18n;
00248     static std::map<QString, int> commonNamesIndex;
00249     static std::map<QString, int> commonNamesIndexI18n;
00250     
00251     static std::map<int, QString> sciNamesMapI18n;
00252     static std::map<QString, int> sciNamesIndexI18n;
00253 
00254     static double currentJDay;
00255     
00256     double fontSize;
00257     StelFont *starFont;
00258     static bool flagSciNames;
00259     Vec3f labelColor;
00260     
00261     StelTextureSP texPointer;       // The selection pointer texture
00262     
00263     QSettings* starSettings;
00264 };
00265 
00266 
00267 #endif // _STARMGR_HPP_
00268 

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