2002-11-03 13:33:30 -07:00
|
|
|
/***************************************************************************
|
|
|
|
url.h - description
|
|
|
|
-------------------
|
|
|
|
begin : Wed Aug 7 2002
|
|
|
|
copyright : (C) 2002 by chris
|
|
|
|
email : chris@tux.teyssier.org
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
#ifndef _URL_H_
|
|
|
|
#define _URL_H_
|
|
|
|
|
|
|
|
#include <string>
|
2008-05-05 13:09:31 -06:00
|
|
|
#include <map>
|
2002-11-03 13:33:30 -07:00
|
|
|
#include "celestiacore.h"
|
|
|
|
#include "celengine/astro.h"
|
|
|
|
|
|
|
|
class CelestiaCore;
|
2008-05-05 13:09:31 -06:00
|
|
|
class CelestiaState;
|
2002-11-03 13:33:30 -07:00
|
|
|
|
|
|
|
class Url
|
|
|
|
{
|
|
|
|
public:
|
2008-10-22 15:12:05 -06:00
|
|
|
enum UrlType
|
|
|
|
{
|
2003-01-23 15:46:46 -07:00
|
|
|
Absolute = 0,
|
2003-05-31 11:40:19 -06:00
|
|
|
Relative = 1,
|
|
|
|
Settings = 2,
|
2003-01-23 15:46:46 -07:00
|
|
|
};
|
2008-10-22 15:12:05 -06:00
|
|
|
|
|
|
|
/*! The TimeSource specifies what the time will be set to when the user
|
|
|
|
* activates the URL.
|
|
|
|
* - UseUrlTime indicates that the simulation time should be set to whatever
|
|
|
|
* value was stored in the URL.
|
|
|
|
* - UseSimulationTime means that the simulation time at activation is not
|
|
|
|
* changed.
|
|
|
|
* - UseSystemTime means that the simulation time will be set to whatever the
|
|
|
|
* current system time is when the URL is activated.
|
|
|
|
*/
|
2008-05-05 13:09:31 -06:00
|
|
|
enum TimeSource
|
|
|
|
{
|
|
|
|
UseUrlTime = 0,
|
|
|
|
UseSimulationTime = 1,
|
|
|
|
UseSystemTime = 2,
|
|
|
|
TimeSourceCount = 3,
|
|
|
|
};
|
|
|
|
|
2003-01-23 15:46:46 -07:00
|
|
|
Url();
|
|
|
|
|
2002-11-03 13:33:30 -07:00
|
|
|
// parses str
|
|
|
|
Url(const std::string& str, CelestiaCore *core);
|
|
|
|
// current url of appCore
|
2003-01-23 15:46:46 -07:00
|
|
|
Url(CelestiaCore* appCore, UrlType type = Absolute);
|
2008-05-05 13:09:31 -06:00
|
|
|
Url(const CelestiaState& appState,
|
|
|
|
unsigned int version = CurrentVersion,
|
|
|
|
TimeSource _timeSource = UseUrlTime);
|
2002-11-03 13:33:30 -07:00
|
|
|
~Url();
|
|
|
|
|
|
|
|
std::string getAsString() const;
|
|
|
|
std::string getName() const;
|
|
|
|
void goTo();
|
|
|
|
|
2008-05-05 13:09:31 -06:00
|
|
|
static const unsigned int CurrentVersion;
|
2009-03-17 15:57:23 -06:00
|
|
|
|
|
|
|
static std::string decodeString(const std::string& str);
|
|
|
|
static std::string encodeString(const std::string& str);
|
2003-01-23 15:46:46 -07:00
|
|
|
|
2002-11-03 13:33:30 -07:00
|
|
|
private:
|
2008-05-05 13:09:31 -06:00
|
|
|
void initVersion2(std::map<std::string, std::string>& params, const std::string& timeString);
|
|
|
|
void initVersion3(std::map<std::string, std::string>& params, const std::string& timeString);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string urlStr;
|
|
|
|
std::string name;
|
2002-11-03 13:33:30 -07:00
|
|
|
std::string modeStr;
|
2008-05-05 13:09:31 -06:00
|
|
|
std::string body1;
|
|
|
|
std::string body2;
|
|
|
|
std::string selectedStr;
|
|
|
|
std::string trackedStr;
|
2002-11-03 13:33:30 -07:00
|
|
|
|
|
|
|
CelestiaCore *appCore;
|
|
|
|
|
2008-02-08 14:46:02 -07:00
|
|
|
ObserverFrame ref;
|
2002-11-03 13:33:30 -07:00
|
|
|
Selection selected;
|
|
|
|
Selection tracked;
|
|
|
|
|
2008-02-08 14:46:02 -07:00
|
|
|
ObserverFrame::CoordinateSystem mode;
|
2002-11-03 13:33:30 -07:00
|
|
|
int nbBodies;
|
|
|
|
float fieldOfView;
|
|
|
|
float timeScale;
|
|
|
|
int renderFlags;
|
|
|
|
int labelMode;
|
2003-05-06 16:13:33 -06:00
|
|
|
bool lightTimeDelay;
|
2007-11-03 03:49:29 -06:00
|
|
|
bool pauseState;
|
2002-11-03 13:33:30 -07:00
|
|
|
|
|
|
|
std::map<std::string, std::string> parseUrlParams(const std::string& url) const;
|
2008-02-08 14:46:02 -07:00
|
|
|
std::string getCoordSysName(ObserverFrame::CoordinateSystem mode) const;
|
2002-11-03 13:33:30 -07:00
|
|
|
std::string getBodyShortName(const std::string& body) const;
|
2009-03-17 15:57:23 -06:00
|
|
|
std::string getEncodedObjectName(const Selection& selection);
|
2002-11-03 13:33:30 -07:00
|
|
|
|
|
|
|
bool fromString;
|
2003-01-23 15:46:46 -07:00
|
|
|
UrlType type;
|
2008-05-05 13:09:31 -06:00
|
|
|
TimeSource timeSource;
|
|
|
|
unsigned int version;
|
2003-01-23 15:46:46 -07:00
|
|
|
|
|
|
|
void evalName();
|
|
|
|
|
|
|
|
// Variables specific to Global Urls
|
|
|
|
UniversalCoord coord;
|
|
|
|
astro::Date date;
|
|
|
|
Quatf orientation;
|
|
|
|
|
|
|
|
// Variables specific to Relative Urls
|
|
|
|
double distance, longitude, latitude;
|
2002-11-03 13:33:30 -07:00
|
|
|
};
|
|
|
|
|
2008-05-05 13:09:31 -06:00
|
|
|
|
|
|
|
/*! The CelestiaState class holds the current observer position, orientation,
|
|
|
|
* frame, time, and render settings. It is designed to be serialized as a cel
|
|
|
|
* URL, thus strings are stored for bodies instead of Selections.
|
|
|
|
*
|
|
|
|
* Some information is *not* stored in cel URLs, including the current
|
|
|
|
* lists of reference marks and markers. Such lists can be arbitrarily long,
|
|
|
|
* and thus not practical to store in a URL.
|
|
|
|
*/
|
|
|
|
class CelestiaState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CelestiaState();
|
|
|
|
|
|
|
|
bool loadState(std::map<std::string, std::string>& params);
|
|
|
|
void saveState(std::map<std::string, std::string>& params);
|
|
|
|
void captureState(CelestiaCore* appCore);
|
|
|
|
|
|
|
|
// Observer frame, position, and orientation. For multiview, there needs
|
|
|
|
// be one instance of these parameters per view saved.
|
|
|
|
ObserverFrame::CoordinateSystem coordSys;
|
|
|
|
string refBodyName;
|
|
|
|
string targetBodyName;
|
|
|
|
string trackedBodyName;
|
|
|
|
UniversalCoord observerPosition;
|
|
|
|
Quatf observerOrientation;
|
|
|
|
float fieldOfView;
|
|
|
|
|
|
|
|
// Time parameters
|
|
|
|
double tdb;
|
|
|
|
float timeScale;
|
|
|
|
bool pauseState;
|
|
|
|
bool lightTimeDelay;
|
|
|
|
|
|
|
|
string selectedBodyName;
|
|
|
|
|
|
|
|
int labelMode;
|
|
|
|
int renderFlags;
|
|
|
|
};
|
|
|
|
|
2002-11-03 13:33:30 -07:00
|
|
|
#endif
|