Stellarium 0.11.2
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., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, 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 StelPainter;
00034 class QSettings;
00035 
00036 namespace BigStarCatalogExtension {
00037   class ZoneArray;
00038   class HipIndexStruct;
00039 }
00040 
00064 class StarMgr : public StelObjectModule
00065 {
00066     Q_OBJECT
00067 
00068 public:
00069     StarMgr(void);
00070     ~StarMgr(void);
00071 
00073     // Methods defined in the StelModule class
00081     virtual void init();
00082 
00084     virtual void draw(StelCore* core);
00085 
00088     virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
00089 
00091     virtual double getCallOrder(StelModuleActionName actionName) const;
00092 
00094     // Methods defined in StelObjectManager class
00096     virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
00097 
00101     virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
00102 
00105     virtual StelObjectP searchByName(const QString& name) const;
00106 
00111     virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
00112 
00113 public slots:
00115     // Methods callable from script and GUI
00117     void setLabelColor(const Vec3f& c) {labelColor = c;}
00119     Vec3f getLabelColor(void) const {return labelColor;}
00120 
00122     void setFlagStars(bool b) {starsFader=b;}
00124     bool getFlagStars(void) const {return starsFader==true;}
00125 
00127     void setFlagLabels(bool b) {labelsFader=b;}
00129     bool getFlagLabels(void) const {return labelsFader==true;}
00130 
00134     void setLabelsAmount(float a) {labelsAmount=a;}
00137     float getLabelsAmount(void) const {return labelsAmount;}
00138 
00140     void setFontSize(double newFontSize);
00141 
00143     static void setFlagSciNames(bool f) {flagSciNames = f;}
00144     static bool getFlagSciNames(void) {return flagSciNames;}
00145 
00146 public:
00148     // Other methods
00153     StelObjectP searchHP(int hip) const;
00154 
00157     static QString getCommonName(int hip);
00158 
00161     static QString getSciName(int hip);
00162 
00163     static QString convertToSpectralType(int index);
00164     static QString convertToComponentIds(int index);
00165 
00166     QVariantList getCatalogsDescription() const {return catalogsDescription;}
00167 
00171     bool checkAndLoadCatalog(QVariantMap m);
00172 
00173 private slots:
00174     void setStelStyle(const QString& section);
00176     void updateI18n();
00177 
00181     void updateSkyCulture(const QString& skyCultureDir);
00182 
00183 private:
00184 
00185     void setCheckFlag(const QString& catalogId, bool b);
00186 
00187     void copyDefaultConfigFile();
00188 
00192     int loadCommonNames(const QString& commonNameFile);
00193 
00197     void loadSciNames(const QString& sciNameFile);
00198 
00200     // TODO: add a non-lame description - what is the purpose of the max search level?
00201     int getMaxSearchLevel() const;
00202 
00204     void loadData(QVariantMap starsConfigFile);
00205 
00207     void drawPointer(StelPainter& sPainter, const StelCore* core);
00208 
00209     LinearFader labelsFader;
00210     LinearFader starsFader;
00211 
00212     bool flagStarName;
00213     float labelsAmount;
00214     bool gravityLabel;
00215 
00216     int maxGeodesicGridLevel;
00217     int lastMaxSearchLevel;
00218     typedef QHash<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
00219     ZoneArrayMap zoneArrays; // index is the grid level
00220     static void initTriangleFunc(int lev, int index,
00221                                  const Vec3f &c0,
00222                                  const Vec3f &c1,
00223                                  const Vec3f &c2,
00224                                  void *context)
00225     {
00226         reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
00227     }
00228 
00229     void initTriangle(int lev, int index,
00230                       const Vec3f &c0,
00231                       const Vec3f &c1,
00232                       const Vec3f &c2);
00233 
00234     BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
00235 
00236     static QHash<int, QString> commonNamesMap;
00237     static QHash<int, QString> commonNamesMapI18n;
00238     static QMap<QString, int> commonNamesIndexI18n;
00239 
00240     static QHash<int, QString> sciNamesMapI18n;
00241     static QMap<QString, int> sciNamesIndexI18n;
00242 
00243     QFont starFont;
00244     static bool flagSciNames;
00245     Vec3f labelColor;
00246 
00247     StelTextureSP texPointer;       // The selection pointer texture
00248 
00249     class StelObjectMgr* objectMgr;
00250 
00251     QString starConfigFileFullPath;
00252     QVariantMap starSettings;
00253     QVariantList catalogsDescription;
00254 };
00255 
00256 
00257 #endif // _STARMGR_HPP_
00258