LandscapeMgr.hpp   LandscapeMgr.hpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2006 Fabien Chereau * Copyright (C) 2006 Fabien Chereau
* Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 35 skipping to change at line 36
#include <QMap> #include <QMap>
#include <QStringList> #include <QStringList>
class Landscape; class Landscape;
class Atmosphere; class Atmosphere;
class Cardinals; class Cardinals;
class QSettings; class QSettings;
//! @class LandscapeMgr //! @class LandscapeMgr
//! Manages all the rendering a the level of the observer's surrounding. //! Manages all the rendering at the level of the observer's surroundings.
//! This includes landscape textures, fog, atmosphere and cardinal points //! This includes landscape textures, fog, atmosphere and cardinal points.
//! I decided to put all these elements together in a single class because they are //! 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 alti tude. //! inherently linked, especially when we start moving the observer in alti tude.
class LandscapeMgr : public StelModule class LandscapeMgr : public StelModule
{ {
Q_OBJECT Q_OBJECT
public: public:
LandscapeMgr(); LandscapeMgr();
virtual ~LandscapeMgr(); virtual ~LandscapeMgr();
skipping to change at line 97 skipping to change at line 98
//! type. The load member is then called, passing both parameters. //! type. The load member is then called, passing both parameters.
//! @param landscapeFile This is the path to a landscape.ini file. //! @param landscapeFile This is the path to a landscape.ini file.
//! @param landscapeId This is the landscape ID, which is also the n ame of the //! @param landscapeId This is the landscape ID, which is also the n ame of the
//! directory in which the files (textures and so on) for the landsc ape reside. //! directory in which the files (textures and so on) for the landsc ape reside.
//! @return A pointer to the newly created landscape object. //! @return A pointer to the newly created landscape object.
Landscape* createFromFile(const QString& landscapeFile, const QStrin g& landscapeId); Landscape* createFromFile(const QString& landscapeFile, const QStrin g& landscapeId);
public slots: public slots:
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods callable from script and GUI // Methods callable from script and GUI
//! Retrieve list of the names of all the available landscape in the //! Retrieve a list of the names of all the available landscapes in
//! file search path sub-directories of the landscape area //! the file search path sub-directories of the landscape area
//! @return the names of the landscapes, which are the values of the name parameter in the landscape.ini files //! @return the names of the landscapes, which are the values of the name parameter in the landscape.ini files
QStringList getAllLandscapeNames() const; QStringList getAllLandscapeNames() const;
//! Retrieve list of the names of all the available landscape in the //! Retrieve a list of the identifiers of all the available landscap
//! file search path sub-directories of the landscape area es in
//! @return the names of the landscapes, which are the values of the //! the file search path sub-directories of the landscape area
name parameter in the landscape.ini files //! @return the identifiers of the landscapes, which are the names o
f the directories containing the landscapes' files
QStringList getAllLandscapeIDs() const; QStringList getAllLandscapeIDs() const;
//! Retrieve a list of the identifiers of all user-installed landsca
pes.
//! Effectively, this returns the results of getAllLandscapeIDs() wi
thout
//! the landscapes specified in the #packagedLandscapeIDs list.
QStringList getUserLandscapeIDs() const;
//! Get the current landscape ID. //! Get the current landscape ID.
const QString& getCurrentLandscapeID() const {return currentLandscap eID;} const QString& getCurrentLandscapeID() const {return currentLandscap eID;}
//! Change the current landscape to the landscape with the ID specif ied. //! Change the current landscape to the landscape with the ID specif ied.
//! @param id the ID of the new landscape //! @param id the ID of the new landscape
//! @return false if the new landscape could not be set (e.g. no lan dscape of that ID was found). //! @return false if the new landscape could not be set (e.g. no lan dscape of that ID was found).
bool setCurrentLandscapeID(const QString& id); bool setCurrentLandscapeID(const QString& id);
//! Get the current landscape name. //! Get the current landscape name.
QString getCurrentLandscapeName() const; QString getCurrentLandscapeName() const;
//! Change the current landscape to the landscape with the name spec ified. //! Change the current landscape to the landscape with the name spec ified.
skipping to change at line 176 skipping to change at line 182
void setAtmosphereBortleLightPollution(int bIndex); void setAtmosphereBortleLightPollution(int bIndex);
//! Get the light pollution following the Bortle Scale //! Get the light pollution following the Bortle Scale
int getAtmosphereBortleLightPollution(); int getAtmosphereBortleLightPollution();
//! Set the rotation of the landscape about the z-axis. //! Set the rotation of the landscape about the z-axis.
//! This is intended for special uses such as when the landscape con sists of //! This is intended for special uses such as when the landscape con sists of
//! a vehicle which might change orientation over time (e.g. a ship) . //! a vehicle which might change orientation over time (e.g. a ship) .
//! @param d the rotation angle in degrees as an offset from the ori ginally loaded value. //! @param d the rotation angle in degrees as an offset from the ori ginally loaded value.
void setZRotation(float d); void setZRotation(float d);
//! Install a landscape from a ZIP archive.
//! This function searches for a file named "landscape.ini" in the r
oot
//! directory of the archive. If it is not found there, the function
//! searches inside the topmost sub-directories (if any), but no dee
per.
//! 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 iden
tifier
//! for a name;
//! - all files in the archive directory that contains the "landsca
pe.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 "landscap
e.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 ar
chive.
//!
//! The landscape identifier must be unique.
//! @param pathToSourceArchive path to the source archive file.
//! @param display If true, the landscape will be set to be the curr
ent
//! landscape after installation.
//! @param forAllUsers If true, this function will try to install th
e
//! landscape in a way that meakes it is available to all users of t
his
//! computer. May require running Stellarium as an administrator (ro
ot)
//! on some Windows or *nix systems. (NOT IMPLEMENTED!)
//! @returns the installed landscape's identifier, or
//! an empty string on failure.
//! @todo Find a better way to pass error messages.
QString installLandscapeFromArchive(QString pathToSourceArchive, boo
l display = false, bool forAllUsers = false);
//! Install a landscape from a directory.
//! Expected directory structure: the name of the directory that con
tains
//! a landscape.ini file is assumed to be the landscape ID and shoul
d 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.
//! @param pathToSourceLandscapeIni path to a landscape.ini file. It
s parent
//! directory is assumed to be the landscape source directory.
//! @param display If true, the landscape will be set to be the curr
ent
//! landscape after installation.
//! @param forAllUsers If true, this function will try to install th
e
//! landscape in a way that meakes it is available to all users of t
his
//! computer. May require running Stellarium as an administrator (ro
ot)
//! on some Windows or *nix systems. (NOT IMPLEMENTED!)
//! @returns the installed landscape's identifier (the folder name),
or
//! an empty string on failure.
//QString installLandscapeFromDirectory(QString pathToSourceLandscap
eIni, bool display = false, bool forAllUsers = false);
//! This function removes a landscape from the user data directory.
//! It tries to recursively delete all files in the landscape direct
ory
//! 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 restor
ed).
//! Landscapes that were packaged with Stellarium can't be removed,
//! thanks to the #packagedtLandscapeIDs list.
//! @param landscapeID an installed landscape's identifier (the fold
er name)
//! @todo Find a better way to pass error messages.
bool removeLandscape(QString landscapeID);
//! This function reads a landscape's name from its configuration fi
le.
//! @param landscapeID an installed landscape's identifier (the fold
er name)
//! @returns an empty string if there is no such landscape or some o
ther
//! error occurs
QString loadLandscapeName(QString landscapeID);
//! 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 anywa
y.)
//! @param landscapeID an installed landscape's identifier (the fold
er name)
quint64 loadLandscapeSize(QString landscapeID);
signals:
//! 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)
void landscapesChanged();
//! Emitted when installLandscapeFromArchive() can't read from, writ
e to or
//! create a file or a directory.
//! (A way of moving the need for translatable error messages to the
GUI.)
//! \param path path to the file or directory
void errorUnableToOpen(QString path);
//! 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 errorNotArchive();
//! Emitted when installLandscapeFromArchive() tries to install a la
ndscape
//! with the same name or identifier as an already installed one.
//! (A way of moving the need for translatable error messages to the
GUI.)
//! \param nameOrID the name or the identifier of the landscape
void errorNotUnique(QString nameOrID);
//! 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.)
//! \param path the path to the landscape's directory
void errorRemoveManually(QString path);
private: private:
//! Get light pollution luminance level. //! Get light pollution luminance level.
float getAtmosphereLightPollutionLuminance() const; float getAtmosphereLightPollutionLuminance() const;
//! Set light pollution luminance level. //! Set light pollution luminance level.
void setAtmosphereLightPollutionLuminance(float f); void setAtmosphereLightPollutionLuminance(float f);
//! For a given landscape name, return the landscape ID. //! For a given landscape name, return the landscape ID.
//! This takes a name of the landscape, as described in the landscap e:name item in the //! This takes a name of the landscape, as described in the landscap e:name item in the
//! landscape.ini, and returns the landscape ID which corresponds to that name. //! landscape.ini, and returns the landscape ID which corresponds to that name.
QString nameToID(const QString& name); QString nameToID(const QString& name);
//! Return a map of landscape name to landscape ID (directory name). //! Return a map of landscape name to landscape ID (directory name).
QMap<QString,QString> getNameToDirMap() const; QMap<QString,QString> getNameToDirMap() const;
//! Returns the path to an installed landscape's directory.
//! It uses StelFileMgr to look for it in the possible directories.
//! @param landscapeID an installed landscape's identifier (the fold
er name)
//! @returns an empty string, if no such landscape was found.
QString getLandscapePath(QString landscapeID);
Atmosphere* atmosphere; // Atmosphere Atmosphere* atmosphere; // Atmosphere
Cardinals* cardinalsPoints; // Cardinals points Cardinals* cardinalsPoints; // Cardinals points
Landscape* landscape; // The landscape i.e. the fo g, the ground and "decor" Landscape* landscape; // The landscape i.e. the fo g, the ground and "decor"
// Define whether the observer location is to be updated when the la ndscape is updated. // Define whether the observer location is to be updated when the la ndscape is updated.
bool flagLandscapeSetsLocation; bool flagLandscapeSetsLocation;
// The ID of the currently loaded landscape // The ID of the currently loaded landscape
QString currentLandscapeID; QString currentLandscapeID;
// The ID of the default landscape // The ID of the default landscape
QString defaultLandscapeID; QString defaultLandscapeID;
//! List of the IDs of the landscapes packaged by default with Stell
arium.
//! (So that they can't be removed.)
//! It is populated in LandscapeMgr() and has to be updated
//! manually on changes.
//! @todo Find a way to update it automatically.
QStringList packagedLandscapeIDs;
}; };
#endif // _LANDSCAPEMGR_HPP_ #endif // _LANDSCAPEMGR_HPP_
 End of changes. 8 change blocks. 
8 lines changed or deleted 172 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/