2021-03-02 11:10:18 -07:00
|
|
|
// url.h
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002-present, the Celestia Development Team
|
|
|
|
// Original version written by Chris Teyssier (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.
|
|
|
|
|
|
|
|
#pragma once
|
2002-11-03 13:33:30 -07:00
|
|
|
|
2008-05-05 13:09:31 -06:00
|
|
|
#include <map>
|
2021-03-02 11:10:18 -07:00
|
|
|
#include <string>
|
2021-12-22 10:45:22 -07:00
|
|
|
#include <string_view>
|
2009-07-25 16:18:51 -06:00
|
|
|
#include <Eigen/Geometry>
|
2021-03-02 11:10:18 -07:00
|
|
|
#include <celengine/observer.h>
|
|
|
|
#include <celengine/astro.h>
|
|
|
|
#include "celestiastate.h"
|
2002-11-03 13:33:30 -07:00
|
|
|
|
|
|
|
class CelestiaCore;
|
2009-07-25 16:18:51 -06:00
|
|
|
|
2002-11-03 13:33:30 -07:00
|
|
|
class Url
|
|
|
|
{
|
2021-03-02 11:10:18 -07:00
|
|
|
public:
|
|
|
|
constexpr static int CurrentVersion = 3;
|
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,
|
|
|
|
};
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
Url(CelestiaCore *core);
|
2008-05-05 13:09:31 -06:00
|
|
|
Url(const CelestiaState& appState,
|
2021-03-02 11:10:18 -07:00
|
|
|
int version = CurrentVersion,
|
|
|
|
TimeSource timeSource = UseUrlTime);
|
|
|
|
Url(const Url&) = default;
|
|
|
|
Url(Url&&) = default;
|
|
|
|
Url& operator=(const Url&) = default;
|
|
|
|
Url& operator=(Url&&) = default;
|
2018-09-22 07:13:49 -06:00
|
|
|
~Url() = default;
|
2002-11-03 13:33:30 -07:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
static std::string getEncodedObjectName(const Selection& sel, const CelestiaCore* appCore);
|
2021-12-22 10:45:22 -07:00
|
|
|
static constexpr std::string_view proto();
|
|
|
|
static std::string decodeString(std::string_view);
|
|
|
|
static std::string encodeString(std::string_view);
|
2002-11-03 13:33:30 -07:00
|
|
|
|
2021-12-22 10:45:22 -07:00
|
|
|
bool parse(std::string_view);
|
2021-03-02 11:10:18 -07:00
|
|
|
bool goTo();
|
|
|
|
std::string getAsString() const;
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
private:
|
2021-12-22 10:45:22 -07:00
|
|
|
bool initVersion3(std::map<std::string_view, std::string> ¶ms, std::string_view timeStr);
|
|
|
|
bool initVersion4(std::map<std::string_view, std::string> ¶ms, std::string_view timeStr);
|
2003-01-23 15:46:46 -07:00
|
|
|
void evalName();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
CelestiaState m_state;
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
std::string m_url;
|
|
|
|
std::string m_name;
|
|
|
|
astro::Date m_date;
|
|
|
|
CelestiaCore *m_appCore { nullptr };
|
2009-07-25 16:18:51 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
ObserverFrame m_ref;
|
|
|
|
Selection m_selected;
|
|
|
|
Selection m_tracked;
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
int m_version { CurrentVersion };
|
|
|
|
TimeSource m_timeSource { UseUrlTime };
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
int m_nBodies { -1 };
|
|
|
|
bool m_valid { false };
|
2008-05-05 13:09:31 -06:00
|
|
|
};
|
|
|
|
|
2021-12-22 10:45:22 -07:00
|
|
|
constexpr std::string_view Url::proto()
|
2021-03-02 11:10:18 -07:00
|
|
|
{
|
|
|
|
return "cel://";
|
|
|
|
}
|