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

core/modules/LandscapeMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2006 Fabien Chereau
00004  * Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  */
00020 
00021 #ifndef _LANDSCAPEMGR_HPP_
00022 #define _LANDSCAPEMGR_HPP_
00023 
00024 #include "StelModule.hpp"
00025 #include "StelUtils.hpp"
00026 
00027 #include <QMap>
00028 #include <QStringList>
00029 
00030 class Landscape;
00031 class Atmosphere;
00032 class Cardinals;
00033 class QSettings;
00034 
00040 class LandscapeMgr : public StelModule
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045     LandscapeMgr();
00046     virtual ~LandscapeMgr();
00047 
00049     // Methods defined in the StelModule class
00054     virtual void init();
00055 
00057     virtual void draw(StelCore* core);
00058 
00065     virtual void update(double deltaTime);
00066 
00068     virtual void updateI18n();
00069 
00071     virtual void setStelStyle(const QString& section);
00072 
00074     virtual double getCallOrder(StelModuleActionName actionName) const;
00075 
00076 
00078     // Method specific to the landscape manager
00080     float getLuminance();
00081 
00084     bool loadLandscape(QMap<QString, QString>& param);
00085 
00094     Landscape* createFromFile(const QString& landscapeFile, const QString& landscapeId);
00095 
00096 public slots:
00098     // Methods callable from script and GUI
00102     QStringList getAllLandscapeNames() const;
00103 
00107     QStringList getAllLandscapeIDs() const;
00108 
00112     QStringList getUserLandscapeIDs() const;
00113 
00115     const QString& getCurrentLandscapeID() const {return currentLandscapeID;}
00119     bool setCurrentLandscapeID(const QString& id);
00120     
00122     QString getCurrentLandscapeName() const;
00125     bool setCurrentLandscapeName(const QString& name);
00126 
00128     const QString& getDefaultLandscapeID() const {return defaultLandscapeID;}
00132     bool setDefaultLandscapeID(const QString& id);
00133 
00135     QString getCurrentLandscapeHtmlDescription() const;
00136 
00138     bool getFlagLandscape() const;
00140     void setFlagLandscape(bool b);
00141 
00143     bool getFlagFog() const;
00145     void setFlagFog(bool b);
00146 
00148     bool getFlagLandscapeSetsLocation() const {return flagLandscapeSetsLocation;}
00150     void setFlagLandscapeSetsLocation(bool b) {flagLandscapeSetsLocation=b;}
00151 
00153     bool getFlagCardinalsPoints() const;
00155     void setFlagCardinalsPoints(bool b);
00156 
00158     Vec3f getColorCardinalPoints() const;
00160     void setColorCardinalPoints(const Vec3f& v);
00161 
00163     bool getFlagAtmosphere() const;
00165     void setFlagAtmosphere(bool b);
00166 
00168     float getAtmosphereFadeDuration() const;
00170     void setAtmosphereFadeDuration(float f);
00171 
00173     void setAtmosphereBortleLightPollution(int bIndex);
00175     int getAtmosphereBortleLightPollution();
00176 
00181     void setZRotation(float d);
00182 
00213     QString installLandscapeFromArchive(QString pathToSourceArchive, bool display = false, bool forAllUsers = false);
00214 
00232     //QString installLandscapeFromDirectory(QString pathToSourceLandscapeIni, bool display = false, bool forAllUsers = false);
00233 
00243     bool removeLandscape(QString landscapeID);
00244 
00249     QString loadLandscapeName(QString landscapeID);
00250 
00255     quint64 loadLandscapeSize(QString landscapeID);
00256 
00257 signals:
00261     void landscapesChanged();
00262 
00267     void errorUnableToOpen(QString path);
00271     void errorNotArchive();
00276     void errorNotUnique(QString nameOrID);
00281     void errorRemoveManually(QString path);
00282 
00283 private:
00285     float getAtmosphereLightPollutionLuminance() const;
00287     void setAtmosphereLightPollutionLuminance(float f);
00288 
00292     QString nameToID(const QString& name);
00293 
00295     QMap<QString,QString> getNameToDirMap() const;
00296 
00301     QString getLandscapePath(QString landscapeID);
00302 
00303     Atmosphere* atmosphere;         // Atmosphere
00304     Cardinals* cardinalsPoints;     // Cardinals points
00305     Landscape* landscape;           // The landscape i.e. the fog, the ground and "decor"
00306 
00307     // Define whether the observer location is to be updated when the landscape is updated.
00308     bool flagLandscapeSetsLocation;
00309 
00310     // The ID of the currently loaded landscape
00311     QString currentLandscapeID;
00312 
00313     // The ID of the default landscape
00314     QString defaultLandscapeID;
00315 
00321     QStringList packagedLandscapeIDs;
00322 };
00323 
00324 #endif // _LANDSCAPEMGR_HPP_