Stellarium 0.13.2
LandscapeMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
4  * Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature)
5  * Copyright (C) 2012 Timothy Reaves
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
20  */
21 
22 #ifndef _LANDSCAPEMGR_HPP_
23 #define _LANDSCAPEMGR_HPP_
24 
25 #include "StelModule.hpp"
26 #include "StelUtils.hpp"
27 
28 #include <QMap>
29 #include <QStringList>
30 
31 class Landscape;
32 class Atmosphere;
33 class Cardinals;
34 class QSettings;
35 
41 class LandscapeMgr : public StelModule
42 {
43  Q_OBJECT
44  Q_PROPERTY(bool atmosphereDisplayed
46  WRITE setFlagAtmosphere
47  NOTIFY atmosphereDisplayedChanged)
48  Q_PROPERTY(bool cardinalsPointsDisplayed
51  NOTIFY cardinalsPointsDisplayedChanged)
52  Q_PROPERTY(bool fogDisplayed
53  READ getFlagFog
54  WRITE setFlagFog
55  NOTIFY fogDisplayedChanged)
56  Q_PROPERTY(bool landscapeDisplayed
57  READ getFlagLandscape
58  WRITE setFlagLandscape
59  NOTIFY landscapeDisplayedChanged)
60  Q_PROPERTY(bool illuminationDisplayed
63  NOTIFY illuminationDisplayedChanged)
64  Q_PROPERTY(bool databaseUsage
67  NOTIFY lightPollutionUsageChanged)
68 
69 public:
70  LandscapeMgr();
71  virtual ~LandscapeMgr();
72 
74  // Methods defined in the StelModule class
79  virtual void init();
80 
82  virtual void draw(StelCore* core);
83 
90  virtual void update(double deltaTime);
91 
93  virtual double getCallOrder(StelModuleActionName actionName) const;
94 
95 
97  // Method specific to the landscape manager
101  float getLuminance() const;
103  float getAtmosphereAverageLuminance() const;
104 
107  bool loadLandscape(QMap<QString, QString>& param);
108 
117  Landscape* createFromFile(const QString& landscapeFile, const QString& landscapeId);
118 
119  // GZ: implement StelModule's method. For test purposes only, we implement a manual transparency sampler.
120  // TODO: comment this away for final builds
121  // virtual void handleMouseClicks(class QMouseEvent*);
122 
123 public slots:
125  // Methods callable from script and GUI
129  QStringList getAllLandscapeNames() const;
130 
134  QStringList getAllLandscapeIDs() const;
135 
139  QStringList getUserLandscapeIDs() const;
140 
142  const QString& getCurrentLandscapeID() const {return currentLandscapeID;}
146  bool setCurrentLandscapeID(const QString& id);
147 
149  QString getCurrentLandscapeName() const;
152  bool setCurrentLandscapeName(const QString& name);
153 
155  const QString& getDefaultLandscapeID() const {return defaultLandscapeID;}
159  bool setDefaultLandscapeID(const QString& id);
160 
162  QString getCurrentLandscapeHtmlDescription() const;
163 
165  QString getDescription() const;
166 
168  bool getFlagLandscape() const;
170  void setFlagLandscape(const bool displayed);
171 
173  bool getIsLandscapeFullyVisible() const;
174 
176  bool getFlagFog() const;
178  void setFlagFog(const bool displayed);
180  bool getFlagIllumination() const;
182  void setFlagIllumination(const bool on);
183 
185  bool getFlagLandscapeSetsLocation() const {return flagLandscapeSetsLocation;}
187  void setFlagLandscapeSetsLocation(bool b) {flagLandscapeSetsLocation=b;}
188 
190  bool getFlagLandscapeUseMinimalBrightness() const {return flagLandscapeUseMinimalBrightness; }
192  void setFlagLandscapeUseMinimalBrightness(bool b) {flagLandscapeUseMinimalBrightness=b; }
194  bool getFlagLandscapeSetsMinimalBrightness() const {return flagLandscapeSetsMinimalBrightness;}
196  void setFlagLandscapeSetsMinimalBrightness(bool b) {flagLandscapeSetsMinimalBrightness=b;}
198  double getDefaultMinimalBrightness() const {return defaultMinimalBrightness;}
200  void setDefaultMinimalBrightness(const double b) {defaultMinimalBrightness=b;}
202  void setFlagUseLightPollutionFromDatabase(const bool usage);
205 
207  bool getFlagCardinalsPoints() const;
209  void setFlagCardinalsPoints(const bool displayed);
210 
214  void setColorCardinalPoints(const Vec3f& v);
215 
217  bool getFlagAtmosphere() const;
219  void setFlagAtmosphere(const bool displayed);
220 
222  float getAtmosphereFadeDuration() const;
224  void setAtmosphereFadeDuration(const float f);
225 
227  void setAtmosphereBortleLightPollution(const int bIndex);
230 
235  void setZRotation(const float d);
236 
267  QString installLandscapeFromArchive(QString pathToSourceArchive, const bool display = false, const bool forAllUsers = false);
268 
269  /* GZ: leaving doc without the method confuses Doxygen. Commenting out completely.
287  //QString installLandscapeFromDirectory(QString pathToSourceLandscapeIni, bool display = false, bool forAllUsers = false);
288  */
289 
299  bool removeLandscape(const QString landscapeID);
300 
305  QString loadLandscapeName(const QString landscapeID);
306 
311  quint64 loadLandscapeSize(const QString landscapeID) const;
312 
314  bool getFlagLandscapeAutoSelection() const;
316  void setFlagLandscapeAutoSelection(bool enableAutoSelect);
317 
319  bool getFlagAtmosphereAutoEnable() const;
321  void setFlagAtmosphereAutoEnable(bool b);
322 
323 
324 
325 signals:
326  void atmosphereDisplayedChanged(const bool displayed);
327  void cardinalsPointsDisplayedChanged(const bool displayed);
328  void fogDisplayedChanged(const bool displayed);
329  void landscapeDisplayedChanged(const bool displayed);
330  void illuminationDisplayedChanged(const bool displayed);
331  void lightPollutionUsageChanged(const bool usage);
332 
336  void landscapesChanged();
337 
338  void lightPollutionChanged();
339 
344  void errorUnableToOpen(QString path);
348  void errorNotArchive();
353  void errorNotUnique(QString nameOrID);
358  void errorRemoveManually(QString path);
359 
360 private slots:
362  void setStelStyle(const QString& section);
363 
365  void updateI18n();
366 
367 private:
369  float getAtmosphereLightPollutionLuminance() const;
371  void setAtmosphereLightPollutionLuminance(const float f);
372 
373 
377  QString nameToID(const QString& name) const;
378 
380  QMap<QString,QString> getNameToDirMap() const;
381 
386  QString getLandscapePath(const QString landscapeID) const;
387 
388  Atmosphere* atmosphere; // Atmosphere
389  Cardinals* cardinalsPoints; // Cardinals points
390  Landscape* landscape; // The landscape i.e. the fog, the ground and "decor"
391 
392  // Define whether the observer location is to be updated when the landscape is updated.
393  bool flagLandscapeSetsLocation;
394 
395  bool flagLandscapeAutoSelection;
396 
397  bool flagLightPollutionFromDatabase;
398 
400  bool flagLandscapeUseMinimalBrightness;
402  float defaultMinimalBrightness;
404  bool flagLandscapeSetsMinimalBrightness;
406  bool flagAtmosphereAutoEnabling;
407 
408  // The ID of the currently loaded landscape
409  QString currentLandscapeID;
410 
411  // The ID of the default landscape
412  QString defaultLandscapeID;
413 
419  QStringList packagedLandscapeIDs;
420 
421 };
422 
423 #endif // _LANDSCAPEMGR_HPP_
void setFlagUseLightPollutionFromDatabase(const bool usage)
Sets the value of the flag usage light pollution (and bortle index) from locations database...
void setZRotation(const float d)
Set the rotation of the landscape about the z-axis.
void setFlagLandscape(const bool displayed)
Set flag for displaying Landscape.
float getAtmosphereFadeDuration() const
Get atmosphere fade duration in s.
bool loadLandscape(QMap< QString, QString > &param)
Load a landscape based on a hash of parameters mirroring the landscape.ini file and make it the curre...
QString installLandscapeFromArchive(QString pathToSourceArchive, const bool display=false, const bool forAllUsers=false)
Install a landscape from a ZIP archive.
QStringList getUserLandscapeIDs() const
Retrieve a list of the identifiers of all user-installed landscapes.
bool removeLandscape(const QString landscapeID)
This function removes a landscape from the user data directory.
Store and manages the displaying of the Landscape.
Definition: Landscape.hpp:60
void errorNotArchive()
Emitted when the file passed to installLandscapeFromArchive() is not a ZIP archive or does not contai...
virtual void update(double deltaTime)
Update time-dependent state.
QString getCurrentLandscapeName() const
Get the current landscape name.
Compute and display the daylight sky color using openGL.
Definition: Atmosphere.hpp:39
void setAtmosphereBortleLightPollution(const int bIndex)
Set the light pollution following the Bortle Scale.
bool setCurrentLandscapeID(const QString &id)
Change the current landscape to the landscape with the ID specified.
void landscapesChanged()
Emitted when a landscape has been installed or un-installed.
bool getFlagIllumination() const
Get flag for displaying illumination layer.
Vec3f getColorCardinalPoints() const
Get Cardinals Points color.
Manages all the rendering at the level of the observer's surroundings.
bool getFlagUseLightPollutionFromDatabase() const
Return the value of flag usage light pollution (and bortle index) from locations database.
void setFlagFog(const bool displayed)
Set flag for displaying Fog.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
void setFlagLandscapeUseMinimalBrightness(bool b)
Set the value of the flag determining if a minimal brightness should be used to keep landscape visibl...
bool getFlagAtmosphereAutoEnable() const
Get flag for auto-enable of atmospheres for planets.
bool getFlagFog() const
Get flag for displaying Fog.
void setDefaultMinimalBrightness(const double b)
Set the minimal brightness value of the landscape.
QStringList getAllLandscapeNames() const
Retrieve a list of the names of all the available landscapes in the file search path sub-directories ...
bool getFlagLandscapeUseMinimalBrightness() const
Return the value of the flag determining if a minimal brightness should be used to keep landscape vis...
QStringList getAllLandscapeIDs() const
Retrieve a list of the identifiers of all the available landscapes in the file search path sub-direct...
bool getFlagLandscape() const
Get flag for displaying Landscape.
void setFlagCardinalsPoints(const bool displayed)
Set flag for displaying Cardinals Points.
QString getDescription() const
Return a pseudo HTML formatted string with information from description or ini file.
float getAtmosphereAverageLuminance() const
return average luminance [cd/m^2] of atmosphere. Around 10 at sunset, 6400 in daylight, >0 in dark night.
bool getFlagLandscapeAutoSelection() const
Get flag for autoselect of landscapes for planets.
bool setCurrentLandscapeName(const QString &name)
Change the current landscape to the landscape with the name specified.
void setFlagLandscapeSetsMinimalBrightness(bool b)
Sets the value of the flag determining if the minimal brightness should be taken from landscape...
quint64 loadLandscapeSize(const QString landscapeID) const
This function calculates and returns a landscape's disc size in bytes.
void setFlagLandscapeSetsLocation(bool b)
Set the value of the flag determining if a change of landscape will update the observer location...
const QString & getDefaultLandscapeID() const
Get the default landscape ID.
double getDefaultMinimalBrightness() const
Return the minimal brightness value of the landscape.
const QString & getCurrentLandscapeID() const
Get the current landscape ID.
Landscape * createFromFile(const QString &landscapeFile, const QString &landscapeId)
Create a new landscape from the files which describe it.
bool getFlagLandscapeSetsLocation() const
Return the value of the flag determining if a change of landscape will update the observer location...
virtual double getCallOrder(StelModuleActionName actionName) const
Get the order in which this module will draw its objects relative to other modules.
void setFlagIllumination(const bool on)
Set flag for displaying illumination layer.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:117
QString loadLandscapeName(const QString landscapeID)
This function reads a landscape's name from its configuration file.
bool getFlagCardinalsPoints() const
Get flag for displaying Cardinals Points.
virtual void init()
Initialize the LandscapeManager class.
void errorNotUnique(QString nameOrID)
Emitted when installLandscapeFromArchive() tries to install a landscape with the same name or identif...
void setColorCardinalPoints(const Vec3f &v)
Set Cardinals Points color.
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:31
bool getFlagAtmosphere() const
Get flag for displaying Atmosphere.
void setFlagAtmosphereAutoEnable(bool b)
Set flag for auto-enable atmosphere for planets with atmospheres in location window.
void setFlagAtmosphere(const bool displayed)
Set flag for displaying Atmosphere.
void errorRemoveManually(QString path)
Emitted when removeLandscape() is unable to remove all the files of a landscape.
void setAtmosphereFadeDuration(const float f)
Set atmosphere fade duration in s.
void errorUnableToOpen(QString path)
Emitted when installLandscapeFromArchive() can't read from, write to or create a file or a directory...
bool getFlagLandscapeSetsMinimalBrightness() const
Return the value of the flag determining if the minimal brightness should be taken from landscape...
bool getIsLandscapeFullyVisible() const
Get whether the landscape is currently visible. If true, object below landscape must be rendered...
float getLuminance() const
Return the global landscape luminance [0..1], for being used e.g for setting eye adaptation.
virtual void draw(StelCore *core)
Draw the landscape graphics, cardinal points and atmosphere.
int getAtmosphereBortleLightPollution() const
Get the light pollution following the Bortle Scale.
QString getCurrentLandscapeHtmlDescription() const
Return a pseudo HTML formatted string with all informations on the current landscape.
bool setDefaultLandscapeID(const QString &id)
Change the default landscape to the landscape with the ID specified.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
void setFlagLandscapeAutoSelection(bool enableAutoSelect)
Set flag for autoselect of landscapes for planets.