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

core/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 <QFont>
00024 #include <QVariantMap>
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 StelPainter;
00035 class QSettings;
00036 
00037 namespace BigStarCatalogExtension {
00038   class ZoneArray;
00039   class HipIndexStruct;
00040 }
00041 
00065 class StarMgr : public StelObjectModule
00066 {
00067     Q_OBJECT
00068 
00069 public:
00070     StarMgr(void);
00071     ~StarMgr(void);
00072 
00074     // Methods defined in the StelModule class
00082     virtual void init();
00083 
00085     virtual void draw(StelCore* core); 
00086 
00089     virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
00090 
00092     virtual double getCallOrder(StelModuleActionName actionName) const;
00093 
00095     // Methods defined in StelObjectManager class
00097     virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
00098 
00102     virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
00103 
00106     virtual StelObjectP searchByName(const QString& name) const;
00107 
00112     virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
00113 
00114 public slots:
00116     // Methods callable from script and GUI
00118     void setLabelColor(const Vec3f& c) {labelColor = c;}
00120     Vec3f getLabelColor(void) const {return labelColor;}
00121 
00123     void setFlagStars(bool b) {starsFader=b;}
00125     bool getFlagStars(void) const {return starsFader==true;}
00126 
00128     void setFlagLabels(bool b) {labelsFader=b;}
00130     bool getFlagLabels(void) const {return labelsFader==true;}
00131 
00135     void setLabelsAmount(float a) {labelsAmount=a;}
00138     float getLabelsAmount(void) const {return labelsAmount;}
00139 
00141     void setFontSize(double newFontSize);
00142 
00144     static void setFlagSciNames(bool f) {flagSciNames = f;}
00145     static bool getFlagSciNames(void) {return flagSciNames;}
00146 
00147 public:
00149     // Other methods
00154     StelObjectP searchHP(int hip) const;
00155 
00158     static QString getCommonName(int hip);
00159 
00162     static QString getSciName(int hip);
00163 
00164     static QString convertToSpectralType(int index);
00165     static QString convertToComponentIds(int index);
00166 
00167     QVariantList getCatalogsDescription() const {return catalogsDescription;}
00168 
00172     bool checkAndLoadCatalog(QVariantMap m);
00173 
00174 private slots:
00175     void setStelStyle(const QString& section);
00177     void updateI18n();
00178 
00182     void updateSkyCulture(const QString& skyCultureDir);
00183 
00184 private:
00185 
00186     void setCheckFlag(const QString& catalogId, bool b);
00187 
00188     void copyDefaultConfigFile();
00189 
00193     int loadCommonNames(const QString& commonNameFile);
00194 
00198     void loadSciNames(const QString& sciNameFile);
00199 
00201     // TODO: add a non-lame description - what is the purpose of the max search level?
00202     int getMaxSearchLevel() const;
00203 
00205     void loadData(QVariantMap starsConfigFile);
00206 
00208     void drawPointer(StelPainter& sPainter, const StelCore* core);
00209 
00210     LinearFader labelsFader;
00211     LinearFader starsFader;
00212 
00213     bool flagStarName;
00214     float labelsAmount;
00215     bool gravityLabel;
00216 
00217     int maxGeodesicGridLevel;
00218     int lastMaxSearchLevel;
00219     typedef QHash<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
00220     ZoneArrayMap zoneArrays; // index is the grid level
00221     static void initTriangleFunc(int lev, int index,
00222                                  const Vec3f &c0,
00223                                  const Vec3f &c1,
00224                                  const Vec3f &c2,
00225                                  void *context)
00226     {
00227         reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
00228     }
00229 
00230     void initTriangle(int lev, int index,
00231                       const Vec3f &c0,
00232                       const Vec3f &c1,
00233                       const Vec3f &c2);
00234 
00235     BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
00236 
00237     static QHash<int, QString> commonNamesMap;
00238     static QHash<int, QString> commonNamesMapI18n;
00239     static QMap<QString, int> commonNamesIndexI18n;
00240 
00241     static QHash<int, QString> sciNamesMapI18n;
00242     static QMap<QString, int> sciNamesIndexI18n;
00243 
00244     QFont starFont;
00245     static bool flagSciNames;
00246     Vec3f labelColor;
00247 
00248     StelTextureSP texPointer;       // The selection pointer texture
00249 
00250     class StelObjectMgr* objectMgr;
00251 
00252     QString starConfigFileFullPath;
00253     QVariantMap starSettings;
00254     QVariantList catalogsDescription;
00255 };
00256 
00257 
00258 #endif // _STARMGR_HPP_
00259