Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure
Public Slots | Signals | Public Member Functions

LandscapeMgr Class Reference

Manages all the rendering at the level of the observer's surroundings. More...

#include <LandscapeMgr.hpp>

List of all members.

Public Slots

QStringList getAllLandscapeNames () const
QStringList getAllLandscapeIDs () const
QStringList getUserLandscapeIDs () const
const QString & getCurrentLandscapeID () const
bool setCurrentLandscapeID (const QString &id)
QString getCurrentLandscapeName () const
bool setCurrentLandscapeName (const QString &name)
const QString & getDefaultLandscapeID () const
bool setDefaultLandscapeID (const QString &id)
QString getCurrentLandscapeHtmlDescription () const
bool getFlagLandscape () const
void setFlagLandscape (bool b)
bool getFlagFog () const
void setFlagFog (bool b)
bool getFlagLandscapeSetsLocation () const
void setFlagLandscapeSetsLocation (bool b)
bool getFlagCardinalsPoints () const
void setFlagCardinalsPoints (bool b)
Vec3f getColorCardinalPoints () const
void setColorCardinalPoints (const Vec3f &v)
bool getFlagAtmosphere () const
void setFlagAtmosphere (bool b)
float getAtmosphereFadeDuration () const
void setAtmosphereFadeDuration (float f)
void setAtmosphereBortleLightPollution (int bIndex)
int getAtmosphereBortleLightPollution ()
void setZRotation (float d)
QString installLandscapeFromArchive (QString pathToSourceArchive, bool display=false, bool forAllUsers=false)
bool removeLandscape (QString landscapeID)
QString loadLandscapeName (QString landscapeID)
quint64 loadLandscapeSize (QString landscapeID)

Signals

void landscapesChanged ()
void errorUnableToOpen (QString path)
void errorNotArchive ()
void errorNotUnique (QString nameOrID)
void errorRemoveManually (QString path)

Public Member Functions

virtual void init ()
virtual void draw (StelCore *core)
virtual void update (double deltaTime)
virtual void updateI18n ()
virtual void setStelStyle (const QString &section)
virtual double getCallOrder (StelModuleActionName actionName) const
float getLuminance ()
bool loadLandscape (QMap< QString, QString > &param)
LandscapecreateFromFile (const QString &landscapeFile, const QString &landscapeId)

Detailed Description

Manages all the rendering at the level of the observer's surroundings.

This includes landscape textures, fog, atmosphere and cardinal points. I decided to put all these elements together in a single class because they are inherently linked, especially when we start moving the observer in altitude.


Member Function Documentation

Landscape* LandscapeMgr::createFromFile ( const QString &  landscapeFile,
const QString &  landscapeId 
)

Create a new landscape from the files which describe it.

Reads a landscape.ini file which is passed as the first parameter, determines the landscape type, and creates a new object for the landscape of the proper type. The load member is then called, passing both parameters.

Parameters:
landscapeFile This is the path to a landscape.ini file.
landscapeId This is the landscape ID, which is also the name of the directory in which the files (textures and so on) for the landscape reside.
Returns:
A pointer to the newly created landscape object.
void LandscapeMgr::errorNotArchive (  )  [signal]

Emitted when the file passed to installLandscapeFromArchive() is not a ZIP archive or does not contain a valid landscape.

(A way of moving the need for translatable error messages to the GUI.)

void LandscapeMgr::errorNotUnique ( QString  nameOrID  )  [signal]

Emitted when installLandscapeFromArchive() tries to install a landscape with the same name or identifier as an already installed one.

(A way of moving the need for translatable error messages to the GUI.)

Parameters:
nameOrID the name or the identifier of the landscape
void LandscapeMgr::errorRemoveManually ( QString  path  )  [signal]

Emitted when removeLandscape() is unable to remove all the files of a landscape.

(A way of moving the need for translatable error messages to the GUI.)

Parameters:
path the path to the landscape's directory
void LandscapeMgr::errorUnableToOpen ( QString  path  )  [signal]

Emitted when installLandscapeFromArchive() can't read from, write to or create a file or a directory.

(A way of moving the need for translatable error messages to the GUI.)

Parameters:
path path to the file or directory
QStringList LandscapeMgr::getAllLandscapeIDs (  )  const [slot]

Retrieve a list of the identifiers of all the available landscapes in the file search path sub-directories of the landscape area.

Returns:
the identifiers of the landscapes, which are the names of the directories containing the landscapes' files
QStringList LandscapeMgr::getAllLandscapeNames (  )  const [slot]

Retrieve a list of the names of all the available landscapes in the file search path sub-directories of the landscape area.

Returns:
the names of the landscapes, which are the values of the name parameter in the landscape.ini files
QStringList LandscapeMgr::getUserLandscapeIDs (  )  const [slot]

Retrieve a list of the identifiers of all user-installed landscapes.

Effectively, this returns the results of getAllLandscapeIDs() without the landscapes specified in the packagedLandscapeIDs list.

virtual void LandscapeMgr::init (  )  [virtual]

Initialize the LandscapeManager class.

Operations performed:

  • Load the default landscape as specified in the application configuration
  • Set up landscape-releated display flags from ini parser object

Implements StelModule.

QString LandscapeMgr::installLandscapeFromArchive ( QString  pathToSourceArchive,
bool  display = false,
bool  forAllUsers = false 
) [slot]

Install a landscape from a ZIP archive.

This function searches for a file named "landscape.ini" in the root directory of the archive. If it is not found there, the function searches inside the topmost sub-directories (if any), but no deeper. If a landscape configuration file is found:

  • if a "landscapes" directory does not exist in the user data directory, it is created;
  • inside it, a sub-directory is created with the landscape identifier for a name;
  • all files in the archive directory that contains the "landscape.ini" file are extracted to the new sub-directory of "landscapes";
  • all sub-directories of that archive directory will be skipped along with any other files or directories in the archive.

The landscape identifier is either:

  • the name of the folder in the archive that contains "landscape.ini",
  • or the first 65 (or less) characters of the archive name, if the "landscape.ini" file is in the nameless root directory of the archive.

The landscape identifier must be unique.

Parameters:
pathToSourceArchive path to the source archive file.
display If true, the landscape will be set to be the current landscape after installation.
forAllUsers If true, this function will try to install the landscape in a way that meakes it is available to all users of this computer. May require running Stellarium as an administrator (root) on some Windows or *nix systems. (NOT IMPLEMENTED!)
Returns:
the installed landscape's identifier, or an empty string on failure.
void LandscapeMgr::landscapesChanged (  )  [signal]

Emitted when a landscape has been installed or un-installed.

For example, it is used to update the list of landscapes in the Sky and viewing options window (the ViewDialog class)

bool LandscapeMgr::loadLandscape ( QMap< QString, QString > &  param  ) 

Load a landscape based on a hash of parameters mirroring the landscape.ini file and make it the current landscape.

QString LandscapeMgr::loadLandscapeName ( QString  landscapeID  )  [slot]

This function reads a landscape's name from its configuration file.

Parameters:
landscapeID an installed landscape's identifier (the folder name)
Returns:
an empty string if there is no such landscape or some other error occurs
quint64 LandscapeMgr::loadLandscapeSize ( QString  landscapeID  )  [slot]

This function calculates and returns a landscape's disc size in bytes.

It adds up the sizes of all files in the landscape's folder. It assumes that there are no sub-directories. (There shouldn't be any anyway.)

Parameters:
landscapeID an installed landscape's identifier (the folder name)
bool LandscapeMgr::removeLandscape ( QString  landscapeID  )  [slot]

Install a landscape from a directory.

Expected directory structure: the name of the directory that contains a landscape.ini file is assumed to be the landscape ID and should be unique. This directory and all files in it will be installed, but its subdirectories will be skipped along with any other files or directories in the archive.

Parameters:
pathToSourceLandscapeIni path to a landscape.ini file. Its parent directory is assumed to be the landscape source directory.
display If true, the landscape will be set to be the current landscape after installation.
forAllUsers If true, this function will try to install the landscape in a way that meakes it is available to all users of this computer. May require running Stellarium as an administrator (root) on some Windows or *nix systems. (NOT IMPLEMENTED!)
Returns:
the installed landscape's identifier (the folder name), or an empty string on failure. This function removes a landscape from the user data directory. It tries to recursively delete all files in the landscape directory and then remove it from the list of available landscapes. If the function encounters any file that can't be deleted it aborts the operation (previously deleted files are not restored). Landscapes that were packaged with Stellarium can't be removed, thanks to the packagedtLandscapeIDs list.
Parameters:
landscapeID an installed landscape's identifier (the folder name)
bool LandscapeMgr::setCurrentLandscapeID ( const QString &  id  )  [slot]

Change the current landscape to the landscape with the ID specified.

Parameters:
id the ID of the new landscape
Returns:
false if the new landscape could not be set (e.g. no landscape of that ID was found).
bool LandscapeMgr::setCurrentLandscapeName ( const QString &  name  )  [slot]

Change the current landscape to the landscape with the name specified.

Parameters:
name the name of the new landscape, as found in the landscape:name key of the landscape.ini file.
bool LandscapeMgr::setDefaultLandscapeID ( const QString &  id  )  [slot]

Change the default landscape to the landscape with the ID specified.

Parameters:
id the ID of the landscape to use by default
Returns:
false if the new landscape could not be set (e.g. no landscape of that ID was found). True on success.
void LandscapeMgr::setZRotation ( float  d  )  [slot]

Set the rotation of the landscape about the z-axis.

This is intended for special uses such as when the landscape consists of a vehicle which might change orientation over time (e.g. a ship).

Parameters:
d the rotation angle in degrees as an offset from the originally loaded value.
virtual void LandscapeMgr::update ( double  deltaTime  )  [virtual]

Update time-dependent state.

Includes:

  • Landscape, atmosphere and cardinal point on/off fading.
  • Atmophere colour calulation based on location, position of sun and moon.
  • updates adaptation lumenescence lased on visible bright objects.

Implements StelModule.