Redo the selection class to use a single pointer and a type field.
parent
28d7af9428
commit
d7b3afc866
|
@ -599,11 +599,11 @@ CommandPreloadTextures::CommandPreloadTextures(const string& _name) :
|
|||
void CommandPreloadTextures::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Selection target = env.getSimulation()->findObjectFromPath(name);
|
||||
if (target.body == NULL)
|
||||
if (target.body() == NULL)
|
||||
return;
|
||||
|
||||
if (env.getRenderer() != NULL)
|
||||
env.getRenderer()->loadTextures(target.body);
|
||||
env.getRenderer()->loadTextures(target.body());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,29 +21,43 @@ RigidTransform FrameOfReference::toUniversal(const RigidTransform& xform,
|
|||
if (coordSys == astro::Geographic)
|
||||
{
|
||||
Quatd rotation(1, 0, 0, 0);
|
||||
if (refObject.body != NULL)
|
||||
rotation = refObject.body->getEclipticalToGeographic(t);
|
||||
else if (refObject.star != NULL)
|
||||
switch (refObject.getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
rotation = refObject.body()->getEclipticalToGeographic(t);
|
||||
break;
|
||||
case Selection::Type_Star:
|
||||
rotation = Quatd(1, 0, 0, 0);
|
||||
Point3d p = (Point3d) xform.translation * rotation.toMatrix4();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Point3d p = (Point3d) xform.translation * rotation.toMatrix4();
|
||||
return RigidTransform(origin + Vec3d(p.x, p.y, p.z),
|
||||
xform.rotation * rotation);
|
||||
}
|
||||
else if (coordSys == astro::PhaseLock)
|
||||
{
|
||||
Mat3d m;
|
||||
if (refObject.body != NULL)
|
||||
|
||||
switch (refObject.getType())
|
||||
{
|
||||
Body* body = refObject.body;
|
||||
Vec3d lookDir = refObject.getPosition(t) -
|
||||
targetObject.getPosition(t);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = axisDir ^ lookDir;
|
||||
v.normalize();
|
||||
Vec3d u = lookDir ^ v;
|
||||
m = Mat3d(v, u, lookDir);
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
Body* body = refObject.body();
|
||||
Vec3d lookDir = refObject.getPosition(t) -
|
||||
targetObject.getPosition(t);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = axisDir ^ lookDir;
|
||||
v.normalize();
|
||||
Vec3d u = lookDir ^ v;
|
||||
m = Mat3d(v, u, lookDir);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Point3d p = (Point3d) xform.translation * m;
|
||||
|
@ -54,17 +68,24 @@ RigidTransform FrameOfReference::toUniversal(const RigidTransform& xform,
|
|||
else if (coordSys == astro::Chase)
|
||||
{
|
||||
Mat3d m;
|
||||
if (refObject.body != NULL)
|
||||
|
||||
switch (refObject.getType())
|
||||
{
|
||||
Body* body = refObject.body;
|
||||
Vec3d lookDir = body->getOrbit()->positionAtTime(t) -
|
||||
body->getOrbit()->positionAtTime(t - 1.0 / 1440.0);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = lookDir ^ axisDir;
|
||||
v.normalize();
|
||||
Vec3d u = v ^ lookDir;
|
||||
m = Mat3d(v, u, -lookDir);
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
Body* body = refObject.body();
|
||||
Vec3d lookDir = body->getOrbit()->positionAtTime(t) -
|
||||
body->getOrbit()->positionAtTime(t - 1.0 / 1440.0);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = lookDir ^ axisDir;
|
||||
v.normalize();
|
||||
Vec3d u = v ^ lookDir;
|
||||
m = Mat3d(v, u, -lookDir);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Point3d p = (Point3d) xform.translation * m;
|
||||
|
@ -90,10 +111,17 @@ RigidTransform FrameOfReference::fromUniversal(const RigidTransform& xform,
|
|||
if (coordSys == astro::Geographic)
|
||||
{
|
||||
Quatd rotation(1, 0, 0, 0);
|
||||
if (refObject.body != NULL)
|
||||
rotation = refObject.body->getEclipticalToGeographic(t);
|
||||
else if (refObject.star != NULL)
|
||||
switch (refObject.getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
rotation = refObject.body()->getEclipticalToGeographic(t);
|
||||
break;
|
||||
case Selection::Type_Star:
|
||||
rotation = Quatd(1, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Vec3d v = (xform.translation - origin) * (~rotation).toMatrix4();
|
||||
|
||||
return RigidTransform(UniversalCoord(v.x, v.y, v.z),
|
||||
|
@ -102,17 +130,25 @@ RigidTransform FrameOfReference::fromUniversal(const RigidTransform& xform,
|
|||
else if (coordSys == astro::PhaseLock)
|
||||
{
|
||||
Mat3d m;
|
||||
if (refObject.body != NULL)
|
||||
|
||||
switch (refObject.getType())
|
||||
{
|
||||
Body* body = refObject.body;
|
||||
Vec3d lookDir = refObject.getPosition(t) -
|
||||
targetObject.getPosition(t);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = axisDir ^ lookDir;
|
||||
v.normalize();
|
||||
Vec3d u = lookDir ^ v;
|
||||
m = Mat3d(v, u, lookDir);
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
Body* body = refObject.body();
|
||||
Vec3d lookDir = refObject.getPosition(t) -
|
||||
targetObject.getPosition(t);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = axisDir ^ lookDir;
|
||||
v.normalize();
|
||||
Vec3d u = lookDir ^ v;
|
||||
m = Mat3d(v, u, lookDir);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Vec3d v = (xform.translation - origin) * m.transpose();
|
||||
|
@ -123,17 +159,25 @@ RigidTransform FrameOfReference::fromUniversal(const RigidTransform& xform,
|
|||
else if (coordSys == astro::Chase)
|
||||
{
|
||||
Mat3d m;
|
||||
if (refObject.body != NULL)
|
||||
|
||||
switch (refObject.getType())
|
||||
{
|
||||
Body* body = refObject.body;
|
||||
Vec3d lookDir = body->getOrbit()->positionAtTime(t) -
|
||||
body->getOrbit()->positionAtTime(t - 1.0 / 1440.0);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = lookDir ^ axisDir;
|
||||
v.normalize();
|
||||
Vec3d u = v ^ lookDir;
|
||||
m = Mat3d(v, u, -lookDir);
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
Body* body = refObject.body();
|
||||
Vec3d lookDir = body->getOrbit()->positionAtTime(t) -
|
||||
body->getOrbit()->positionAtTime(t - 1.0 / 1440.0);
|
||||
Vec3d axisDir = Vec3d(0, 1, 0) * body->getEclipticalToEquatorial(t).toMatrix3();
|
||||
lookDir.normalize();
|
||||
Vec3d v = lookDir ^ axisDir;
|
||||
v.normalize();
|
||||
Vec3d u = v ^ lookDir;
|
||||
m = Mat3d(v, u, -lookDir);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Vec3d v = (xform.translation - origin) * m.transpose();
|
||||
|
|
|
@ -159,16 +159,16 @@ Vec3d toUniversal(const Vec3d& v,
|
|||
}
|
||||
|
||||
case astro::Geographic:
|
||||
if (sel.body == NULL)
|
||||
if (sel.getType() != Selection::Type_Body)
|
||||
return v;
|
||||
else
|
||||
return v * sel.body->getGeographicToHeliocentric(t);
|
||||
return v * sel.body()->getGeographicToHeliocentric(t);
|
||||
|
||||
case astro::Equatorial:
|
||||
if (sel.body == NULL)
|
||||
if (sel.getType() != Selection::Type_Body)
|
||||
return v;
|
||||
else
|
||||
return v * sel.body->getLocalToHeliocentric(t);
|
||||
return v * sel.body()->getLocalToHeliocentric(t);
|
||||
|
||||
case astro::Ecliptical:
|
||||
// TODO: Multiply this by the planetary system's ecliptic orientation,
|
||||
|
@ -669,14 +669,26 @@ void Observer::gotoSelection(const Selection& selection,
|
|||
double distance = v.length();
|
||||
|
||||
double maxOrbitDistance;
|
||||
if (selection.body != NULL)
|
||||
maxOrbitDistance = astro::kilometersToMicroLightYears(5.0f * selection.body->getRadius());
|
||||
else if (selection.deepsky != NULL)
|
||||
maxOrbitDistance = 5.0f * selection.deepsky->getRadius() * 1e6f;
|
||||
else if (selection.star != NULL)
|
||||
maxOrbitDistance = astro::kilometersToMicroLightYears(100.0f * selection.star->getRadius());
|
||||
else
|
||||
switch (selection.getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
maxOrbitDistance = astro::kilometersToMicroLightYears(5.0f * selection.body()->getRadius());
|
||||
break;
|
||||
case Selection::Type_DeepSky:
|
||||
maxOrbitDistance = 5.0f * selection.deepsky()->getRadius() * 1e6f;
|
||||
break;
|
||||
case Selection::Type_Star:
|
||||
maxOrbitDistance = astro::kilometersToMicroLightYears(100.0f * selection.star()->getRadius());
|
||||
break;
|
||||
case Selection::Type_Location:
|
||||
maxOrbitDistance = selection.location()->getSize() / 2.0f;
|
||||
if (maxOrbitDistance == 0.0f)
|
||||
maxOrbitDistance = 1.0f;
|
||||
break;
|
||||
default:
|
||||
maxOrbitDistance = 0.5f;
|
||||
break;
|
||||
}
|
||||
|
||||
double radius = selection.radius();
|
||||
double minOrbitDistance = astro::kilometersToMicroLightYears(1.01 * radius);
|
||||
|
@ -776,7 +788,7 @@ void Observer::getSelectionLongLat(const Selection& selection,
|
|||
// respect to currently selected object.
|
||||
if (!selection.empty())
|
||||
{
|
||||
FrameOfReference refFrame(astro::Geographic, selection.body);
|
||||
FrameOfReference refFrame(astro::Geographic, selection);
|
||||
RigidTransform xform = refFrame.fromUniversal(RigidTransform(getPosition(), getOrientation()),
|
||||
getTime());
|
||||
|
||||
|
@ -851,7 +863,7 @@ void Observer::geosynchronousFollow(const Selection& selection)
|
|||
{
|
||||
if (selection.body != NULL)
|
||||
{
|
||||
setFrame(FrameOfReference(astro::Geographic, selection.body));
|
||||
setFrame(FrameOfReference(astro::Geographic, selection));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -862,7 +874,7 @@ void Observer::phaseLock(const Selection& selection)
|
|||
if (selection == frame.refObject)
|
||||
{
|
||||
setFrame(FrameOfReference(astro::PhaseLock, selection,
|
||||
Selection(selection.body->getSystem()->getStar())));
|
||||
Selection(selection.body()->getSystem()->getStar())));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -875,7 +887,7 @@ void Observer::chase(const Selection& selection)
|
|||
{
|
||||
if (selection.body != NULL)
|
||||
{
|
||||
setFrame(FrameOfReference(astro::Chase, selection.body));
|
||||
setFrame(FrameOfReference(astro::Chase, selection));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -840,9 +840,9 @@ void Renderer::renderOrbits(PlanetarySystem* planets,
|
|||
Body* body = planets->getBody(i);
|
||||
|
||||
// Only show orbits for major bodies or selected objects
|
||||
if ((body->getClassification() & OrbitMask) != 0 || body == sel.body)
|
||||
if ((body->getClassification() & OrbitMask) != 0 || body == sel.body())
|
||||
{
|
||||
if (body == sel.body)
|
||||
if (body == sel.body())
|
||||
glColor4f(1, 0, 0, 1);
|
||||
else
|
||||
glColor4f(0, 0.4f, 1.0f, 1);
|
||||
|
|
|
@ -16,46 +16,57 @@ using namespace std;
|
|||
|
||||
double Selection::radius() const
|
||||
{
|
||||
if (star != NULL)
|
||||
return star->getRadius();
|
||||
else if (body != NULL)
|
||||
return body->getRadius();
|
||||
else if (deepsky != NULL)
|
||||
return astro::lightYearsToKilometers(deepsky->getRadius());
|
||||
else
|
||||
switch (type)
|
||||
{
|
||||
case Type_Star:
|
||||
return star()->getRadius();
|
||||
case Type_Body:
|
||||
return body()->getRadius();
|
||||
case Type_DeepSky:
|
||||
return astro::lightYearsToKilometers(deepsky()->getRadius());
|
||||
case Type_Location:
|
||||
// The size of a location is its diameter, so divide by 2.
|
||||
return location()->getSize() / 2.0f;
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UniversalCoord Selection::getPosition(double t) const
|
||||
{
|
||||
if (body != NULL)
|
||||
switch (type)
|
||||
{
|
||||
Point3f sunPos(0.0f, 0.0f, 0.0f);
|
||||
PlanetarySystem* system = body->getSystem();
|
||||
if (system != NULL)
|
||||
case Type_Body:
|
||||
{
|
||||
const Star* sun = system->getStar();
|
||||
if (sun != NULL)
|
||||
sunPos = sun->getPosition();
|
||||
}
|
||||
Point3f sunPos(0.0f, 0.0f, 0.0f);
|
||||
PlanetarySystem* system = body()->getSystem();
|
||||
if (system != NULL)
|
||||
{
|
||||
const Star* sun = system->getStar();
|
||||
if (sun != NULL)
|
||||
sunPos = sun->getPosition();
|
||||
}
|
||||
|
||||
return astro::universalPosition(body->getHeliocentricPosition(t),
|
||||
sunPos);
|
||||
}
|
||||
else if (star != NULL)
|
||||
{
|
||||
return astro::universalPosition(body()->getHeliocentricPosition(t),
|
||||
sunPos);
|
||||
}
|
||||
|
||||
case Type_Star:
|
||||
return astro::universalPosition(Point3d(0.0, 0.0, 0.0),
|
||||
star->getPosition());
|
||||
}
|
||||
else if (deepsky != NULL)
|
||||
{
|
||||
Point3d p = deepsky->getPosition();
|
||||
return astro::universalPosition(Point3d(0.0, 0.0, 0.0),
|
||||
Point3f((float) p.x, (float) p.y, (float) p.z));
|
||||
}
|
||||
else
|
||||
{
|
||||
star()->getPosition());
|
||||
|
||||
case Type_DeepSky:
|
||||
{
|
||||
Point3d p = deepsky()->getPosition();
|
||||
return astro::universalPosition(Point3d(0.0, 0.0, 0.0),
|
||||
Point3f((float) p.x, (float) p.y, (float) p.z));
|
||||
}
|
||||
|
||||
case Type_Location:
|
||||
return UniversalCoord(Point3d(0.0, 0.0, 0.0));
|
||||
|
||||
default:
|
||||
return UniversalCoord(Point3d(0.0, 0.0, 0.0));
|
||||
}
|
||||
}
|
||||
|
@ -63,44 +74,47 @@ UniversalCoord Selection::getPosition(double t) const
|
|||
|
||||
string Selection::getName() const
|
||||
{
|
||||
if (star != NULL)
|
||||
switch (type)
|
||||
{
|
||||
case Type_Star:
|
||||
char buf[20];
|
||||
sprintf(buf, "#%d", star->getCatalogNumber());
|
||||
sprintf(buf, "#%d", star()->getCatalogNumber());
|
||||
return string(buf);
|
||||
}
|
||||
else if (deepsky != NULL)
|
||||
{
|
||||
return deepsky->getName();
|
||||
}
|
||||
else if (body != NULL)
|
||||
{
|
||||
string name = body->getName();
|
||||
PlanetarySystem* system = body->getSystem();
|
||||
while (system != NULL)
|
||||
|
||||
case Type_DeepSky:
|
||||
return deepsky()->getName();
|
||||
|
||||
case Type_Body:
|
||||
{
|
||||
Body* parent = system->getPrimaryBody();
|
||||
if (parent != NULL)
|
||||
string name = body()->getName();
|
||||
PlanetarySystem* system = body()->getSystem();
|
||||
while (system != NULL)
|
||||
{
|
||||
name = parent->getName() + '/' + name;
|
||||
system = parent->getSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
const Star* parentStar = system->getStar();
|
||||
if (parentStar != NULL)
|
||||
Body* parent = system->getPrimaryBody();
|
||||
if (parent != NULL)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "#%d", parentStar->getCatalogNumber());
|
||||
name = string(buf) + '/' + name;
|
||||
name = parent->getName() + '/' + name;
|
||||
system = parent->getSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
const Star* parentStar = system->getStar();
|
||||
if (parentStar != NULL)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "#%d", parentStar->getCatalogNumber());
|
||||
name = string(buf) + '/' + name;
|
||||
}
|
||||
system = NULL;
|
||||
}
|
||||
system = NULL;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
case Type_Location:
|
||||
return "";
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,41 +14,77 @@
|
|||
#include <celengine/star.h>
|
||||
#include <celengine/body.h>
|
||||
#include <celengine/deepskyobj.h>
|
||||
#include <celengine/location.h>
|
||||
#include <celengine/univcoord.h>
|
||||
|
||||
class Selection
|
||||
{
|
||||
public:
|
||||
Selection() : star(NULL), body(NULL), deepsky(NULL) {};
|
||||
Selection(Star* _star) : star(_star), body(NULL), deepsky(NULL) {};
|
||||
Selection(Body* _body) : star(NULL), body(_body), deepsky(NULL) {};
|
||||
Selection(DeepSkyObject* _deepsky) : star(NULL), body(NULL), deepsky(_deepsky) {};
|
||||
Selection(const Selection& sel) :
|
||||
star(sel.star), body(sel.body), deepsky(sel.deepsky) {};
|
||||
enum Type {
|
||||
Type_Nil,
|
||||
Type_Star,
|
||||
Type_Body,
|
||||
Type_DeepSky,
|
||||
Type_Location,
|
||||
};
|
||||
|
||||
public:
|
||||
Selection() : type(Type_Nil), obj(NULL) {};
|
||||
Selection(Star* star) : type(Type_Star), obj(star) { checkNull(); };
|
||||
Selection(Body* body) : type(Type_Body), obj(body) { checkNull(); };
|
||||
Selection(DeepSkyObject* deepsky) : type(Type_DeepSky), obj(deepsky) {checkNull(); };
|
||||
Selection(Location* location) : type(Type_Location), obj(location) { checkNull(); };
|
||||
Selection(const Selection& sel) : type(sel.type), obj(sel.obj) {};
|
||||
~Selection() {};
|
||||
|
||||
#if 0
|
||||
void select(Star* _star) {star=_star; body=NULL; deepsky=NULL;}
|
||||
void select(Body* _body) {star=NULL; body=_body; deepsky=NULL;}
|
||||
void select(DeepSkyObject* _deepsky) {star=NULL; body=NULL; deepsky=_deepsky;}
|
||||
bool empty() const { return star == NULL && body == NULL && deepsky == NULL; };
|
||||
#endif
|
||||
bool empty() const { return type == Type_Nil; }
|
||||
double radius() const;
|
||||
UniversalCoord getPosition(double t) const;
|
||||
std::string getName() const;
|
||||
|
||||
Star* star;
|
||||
Body* body;
|
||||
DeepSkyObject* deepsky;
|
||||
|
||||
Star* star() const
|
||||
{
|
||||
return type == Type_Star ? static_cast<Star*>(obj) : NULL;
|
||||
}
|
||||
|
||||
Body* body() const
|
||||
{
|
||||
return type == Type_Body ? static_cast<Body*>(obj) : NULL;
|
||||
}
|
||||
|
||||
DeepSkyObject* deepsky() const
|
||||
{
|
||||
return type == Type_DeepSky ? static_cast<DeepSkyObject*>(obj) : NULL;
|
||||
}
|
||||
|
||||
Location* location() const
|
||||
{
|
||||
return type == Type_Location ? static_cast<Location*>(obj) : NULL;
|
||||
}
|
||||
|
||||
Type getType() const { return type; }
|
||||
|
||||
// private:
|
||||
Type type;
|
||||
void* obj;
|
||||
|
||||
void checkNull() { if (obj == NULL) type = Type_Nil; }
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(const Selection& s0, const Selection& s1)
|
||||
{
|
||||
return s0.star == s1.star && s0.body == s1.body && s0.deepsky == s1.deepsky;
|
||||
return s0.type == s1.type && s0.obj == s1.obj;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Selection& s0, const Selection& s1)
|
||||
{
|
||||
return s0.star != s1.star || s0.body != s1.body || s0.deepsky != s1.deepsky;
|
||||
return s0.type != s1.type || s0.obj != s1.obj;
|
||||
}
|
||||
|
||||
#endif // _CELENGINE_SELECTION_H_
|
||||
|
|
|
@ -366,9 +366,9 @@ void Simulation::selectPlanet(int index)
|
|||
{
|
||||
if (index < 0)
|
||||
{
|
||||
if (selection.body != NULL)
|
||||
if (selection.getType() == Selection::Type_Body)
|
||||
{
|
||||
PlanetarySystem* system = selection.body->getSystem();
|
||||
PlanetarySystem* system = selection.body()->getSystem();
|
||||
if (system != NULL)
|
||||
setSelection(system->getStar());
|
||||
}
|
||||
|
@ -376,10 +376,10 @@ void Simulation::selectPlanet(int index)
|
|||
else
|
||||
{
|
||||
const Star* star = NULL;
|
||||
if (selection.star != NULL)
|
||||
star = selection.star;
|
||||
else if (selection.body != NULL)
|
||||
star = getSun(selection.body);
|
||||
if (selection.getType() == Selection::Type_Star)
|
||||
star = selection.star();
|
||||
else if (selection.getType() == Selection::Type_Body)
|
||||
star = getSun(selection.body());
|
||||
|
||||
SolarSystem* solarSystem = NULL;
|
||||
if (star != NULL)
|
||||
|
@ -407,18 +407,27 @@ Selection Simulation::findObject(string s)
|
|||
PlanetarySystem* path[2];
|
||||
int nPathEntries = 0;
|
||||
|
||||
if (selection.star != NULL)
|
||||
switch (selection.getType())
|
||||
{
|
||||
SolarSystem* sys = universe->getSolarSystem(selection.star);
|
||||
if (sys != NULL)
|
||||
path[nPathEntries++] = sys->getPlanets();
|
||||
}
|
||||
else if (selection.body != NULL)
|
||||
{
|
||||
PlanetarySystem* sys = selection.body->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
SolarSystem* sys = universe->getSolarSystem(selection.star());
|
||||
if (sys != NULL)
|
||||
path[nPathEntries++] = sys->getPlanets();
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
PlanetarySystem* sys = selection.body()->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (closestSolarSystem != NULL)
|
||||
|
@ -436,18 +445,27 @@ Selection Simulation::findObjectFromPath(string s)
|
|||
PlanetarySystem* path[2];
|
||||
int nPathEntries = 0;
|
||||
|
||||
if (selection.star != NULL)
|
||||
switch (selection.getType())
|
||||
{
|
||||
SolarSystem* sys = universe->getSolarSystem(selection.star);
|
||||
if (sys != NULL)
|
||||
path[nPathEntries++] = sys->getPlanets();
|
||||
}
|
||||
else if (selection.body != NULL)
|
||||
{
|
||||
PlanetarySystem* sys = selection.body->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
SolarSystem* sys = universe->getSolarSystem(selection.star());
|
||||
if (sys != NULL)
|
||||
path[nPathEntries++] = sys->getPlanets();
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
PlanetarySystem* sys = selection.body()->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (closestSolarSystem != NULL)
|
||||
|
@ -462,18 +480,27 @@ std::vector<std::string> Simulation::getObjectCompletion(string s)
|
|||
int nPathEntries = 0;
|
||||
PlanetarySystem* sys = NULL;
|
||||
|
||||
if (selection.star != NULL)
|
||||
switch (selection.getType())
|
||||
{
|
||||
SolarSystem* solsys = universe->getSolarSystem(selection.star);
|
||||
if (solsys != NULL)
|
||||
sys = path[nPathEntries++] = solsys->getPlanets();
|
||||
}
|
||||
else if (selection.body != NULL)
|
||||
{
|
||||
sys = selection.body->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
SolarSystem* solsys = universe->getSolarSystem(selection.star());
|
||||
if (solsys != NULL)
|
||||
sys = path[nPathEntries++] = solsys->getPlanets();
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
sys = selection.body()->getSystem();
|
||||
while (sys != NULL && sys->getPrimaryBody() != NULL)
|
||||
sys = sys->getPrimaryBody()->getSystem();
|
||||
path[nPathEntries++] = sys;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (closestSolarSystem != NULL && closestSolarSystem->getPlanets() != sys)
|
||||
|
|
|
@ -556,27 +556,27 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
if (itemType == "Body")
|
||||
{
|
||||
bool orbitsPlanet = false;
|
||||
if (parent.star != NULL)
|
||||
if (parent.star() != NULL)
|
||||
{
|
||||
SolarSystem* solarSystem = universe.getSolarSystem(parent.star);
|
||||
SolarSystem* solarSystem = universe.getSolarSystem(parent.star());
|
||||
if (solarSystem == NULL)
|
||||
{
|
||||
// No solar system defined for this star yet, so we need
|
||||
// to create it.
|
||||
solarSystem = universe.createSolarSystem(parent.star);
|
||||
solarSystem = universe.createSolarSystem(parent.star());
|
||||
}
|
||||
parentSystem = solarSystem->getPlanets();
|
||||
}
|
||||
else if (parent.body != NULL)
|
||||
else if (parent.body() != NULL)
|
||||
{
|
||||
// Parent is a planet or moon
|
||||
parentSystem = parent.body->getSatellites();
|
||||
parentSystem = parent.body()->getSatellites();
|
||||
if (parentSystem == NULL)
|
||||
{
|
||||
// If the planet doesn't already have any satellites, we
|
||||
// have to create a new planetary system for it.
|
||||
parentSystem = new PlanetarySystem(parent.body);
|
||||
parent.body->setSatellites(parentSystem);
|
||||
parentSystem = new PlanetarySystem(parent.body());
|
||||
parent.body()->setSatellites(parentSystem);
|
||||
}
|
||||
orbitsPlanet = true;
|
||||
}
|
||||
|
@ -604,20 +604,20 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
else if (itemType == "AltSurface")
|
||||
{
|
||||
Surface* surface = CreateSurface(objectData, directory);
|
||||
if (surface != NULL && parent.body != NULL)
|
||||
parent.body->addAlternateSurface(name, surface);
|
||||
if (surface != NULL && parent.body() != NULL)
|
||||
parent.body()->addAlternateSurface(name, surface);
|
||||
else
|
||||
DPRINTF(0, "Bad alternate surface\n");
|
||||
}
|
||||
else if (itemType == "Location")
|
||||
{
|
||||
if (parent.body != NULL)
|
||||
if (parent.body() != NULL)
|
||||
{
|
||||
Location* location = CreateLocation(objectData, parent.body);
|
||||
Location* location = CreateLocation(objectData, parent.body());
|
||||
if (location != NULL)
|
||||
{
|
||||
location->setName(name);
|
||||
parent.body->addLocation(location);
|
||||
parent.body()->addLocation(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -728,17 +728,17 @@ Selection Universe::findPath(const string& s,
|
|||
if (sel.empty())
|
||||
return sel;
|
||||
|
||||
if (sel.deepsky != NULL)
|
||||
if (sel.getType() == Selection::Type_DeepSky)
|
||||
return Selection();
|
||||
|
||||
const PlanetarySystem* worlds = NULL;
|
||||
if (sel.body != NULL)
|
||||
if (sel.getType() == Selection::Type_Body)
|
||||
{
|
||||
worlds = sel.body->getSatellites();
|
||||
worlds = sel.body()->getSatellites();
|
||||
}
|
||||
else if (sel.star != NULL)
|
||||
else if (sel.getType() == Selection::Type_Star)
|
||||
{
|
||||
SolarSystem* ssys = getSolarSystem(sel.star);
|
||||
SolarSystem* ssys = getSolarSystem(sel.star());
|
||||
if (ssys != NULL)
|
||||
worlds = ssys->getPlanets();
|
||||
}
|
||||
|
@ -823,20 +823,20 @@ std::vector<std::string> Universe::getCompletionPath(const string& s,
|
|||
if (sel.empty())
|
||||
return completion;
|
||||
|
||||
if (sel.deepsky != NULL)
|
||||
if (sel.getType() == Selection::Type_DeepSky)
|
||||
{
|
||||
completion.push_back(sel.deepsky->getName());
|
||||
completion.push_back(sel.deepsky()->getName());
|
||||
return completion;
|
||||
}
|
||||
|
||||
PlanetarySystem* worlds = NULL;
|
||||
if (sel.body != NULL)
|
||||
if (sel.getType() == Selection::Type_Body)
|
||||
{
|
||||
worlds = sel.body->getSatellites();
|
||||
worlds = sel.body()->getSatellites();
|
||||
}
|
||||
else if (sel.star != NULL)
|
||||
else if (sel.getType() == Selection::Type_Star)
|
||||
{
|
||||
SolarSystem* ssys = getSolarSystem(sel.star);
|
||||
SolarSystem* ssys = getSolarSystem(sel.star());
|
||||
if (ssys != NULL)
|
||||
worlds = ssys->getPlanets();
|
||||
}
|
||||
|
|
|
@ -398,12 +398,12 @@ const DestinationList* CelestiaCore::getDestinations()
|
|||
// Used in the super-secret edit mode
|
||||
void showSelectionInfo(const Selection& sel)
|
||||
{
|
||||
if (sel.deepsky != NULL)
|
||||
if (sel.deepsky() != NULL)
|
||||
{
|
||||
cout << sel.deepsky->getName() << '\n';
|
||||
cout << sel.deepsky()->getName() << '\n';
|
||||
Vec3f axis;
|
||||
float angle;
|
||||
sel.deepsky->getOrientation().getAxisAngle(axis, angle);
|
||||
sel.deepsky()->getOrientation().getAxisAngle(axis, angle);
|
||||
cout << "Orientation: " << '[' << axis.x << ',' << axis.y << ',' << axis.z << "], " << radToDeg(angle) << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -718,25 +718,25 @@ void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
|
|||
// Rotate the selected object
|
||||
Selection sel = sim->getSelection();
|
||||
Quatf q(1);
|
||||
if (sel.deepsky != NULL)
|
||||
q = sel.deepsky->getOrientation();
|
||||
else if (sel.body != NULL)
|
||||
q = sel.body->getOrientation();
|
||||
if (sel.getType() == Selection::Type_DeepSky)
|
||||
q = sel.deepsky()->getOrientation();
|
||||
else if (sel.getType() == Selection::Type_Body)
|
||||
q = sel.body()->getOrientation();
|
||||
|
||||
q.yrotate(dx / width);
|
||||
q.xrotate(dy / height);
|
||||
|
||||
if (sel.deepsky != NULL)
|
||||
sel.deepsky->setOrientation(q);
|
||||
else if (sel.body != NULL)
|
||||
sel.body->setOrientation(q);
|
||||
if (sel.getType() == Selection::Type_DeepSky)
|
||||
sel.deepsky()->setOrientation(q);
|
||||
else if (sel.getType() == Selection::Type_Body)
|
||||
sel.body()->setOrientation(q);
|
||||
}
|
||||
else if (editMode && checkMask(modifiers, RightButton | ShiftKey | ControlKey))
|
||||
{
|
||||
// Rotate the selected object about an axis from its center to the
|
||||
// viewer.
|
||||
Selection sel = sim->getSelection();
|
||||
if (sel.deepsky != NULL)
|
||||
if (sel.deepsky() != NULL)
|
||||
{
|
||||
double t = sim->getTime();
|
||||
Vec3d v = sel.getPosition(t) - sim->getObserver().getPosition();
|
||||
|
@ -746,8 +746,8 @@ void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
|
|||
Quatf r;
|
||||
r.setAxisAngle(axis, dx / width);
|
||||
|
||||
Quatf q = sel.deepsky->getOrientation();
|
||||
sel.deepsky->setOrientation(r * q);
|
||||
Quatf q = sel.deepsky()->getOrientation();
|
||||
sel.deepsky()->setOrientation(r * q);
|
||||
}
|
||||
}
|
||||
else if (checkMask(modifiers, LeftButton | RightButton) ||
|
||||
|
@ -1271,7 +1271,7 @@ void CelestiaCore::charEntered(char c)
|
|||
case '-':
|
||||
addToHistory();
|
||||
|
||||
if (sim->getSelection().body &&
|
||||
if (sim->getSelection().body() &&
|
||||
(sim->getTargetSpeed() < 0.99 *
|
||||
astro::kilometersToMicroLightYears(astro::speedOfLight)))
|
||||
{
|
||||
|
@ -2296,12 +2296,23 @@ static void displaySelectionName(Overlay& overlay,
|
|||
const Selection& sel,
|
||||
const Universe& univ)
|
||||
{
|
||||
if (sel.body != NULL)
|
||||
overlay << sel.body->getName();
|
||||
else if (sel.deepsky != NULL)
|
||||
overlay << sel.deepsky->getName();
|
||||
else if (sel.star != NULL)
|
||||
displayStarNames(overlay, *sel.star, *univ.getStarCatalog(), 1);
|
||||
switch (sel.getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
overlay << sel.body()->getName();
|
||||
break;
|
||||
case Selection::Type_DeepSky:
|
||||
overlay << sel.deepsky()->getName();
|
||||
break;
|
||||
case Selection::Type_Star:
|
||||
displayStarNames(overlay, *(sel.star()), *univ.getStarCatalog(), 1);
|
||||
break;
|
||||
case Selection::Type_Location:
|
||||
overlay << sel.location()->getName();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2378,7 +2389,7 @@ void CelestiaCore::renderOverlay()
|
|||
bool time_displayed = false;
|
||||
double lt = 0.0;
|
||||
|
||||
if (sim->getSelection().body &&
|
||||
if (sim->getSelection().getType() == Selection::Type_Body &&
|
||||
(sim->getTargetSpeed() < 0.99 *
|
||||
astro::kilometersToMicroLightYears(astro::speedOfLight)))
|
||||
{
|
||||
|
@ -2589,46 +2600,58 @@ void CelestiaCore::renderOverlay()
|
|||
overlay->beginText();
|
||||
Vec3d v = sel.getPosition(sim->getTime()) -
|
||||
sim->getObserver().getPosition();
|
||||
if (sel.star != NULL)
|
||||
switch (sel.getType())
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
displayStarNames(*overlay,
|
||||
*sel.star,
|
||||
*(sim->getUniverse()->getStarCatalog()));
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
displayStarInfo(*overlay,
|
||||
hudDetail,
|
||||
*sel.star,
|
||||
*(sim->getUniverse()),
|
||||
v.length() * 1e-6);
|
||||
}
|
||||
else if (sel.body != NULL)
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
*overlay << sel.body->getName();
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
displayPlanetInfo(*overlay,
|
||||
hudDetail,
|
||||
*sel.body,
|
||||
sim->getTime(),
|
||||
v.length() * 1e-6);
|
||||
}
|
||||
else if (sel.deepsky != NULL)
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
*overlay << sel.deepsky->getName();
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
*overlay << "Distance: ";
|
||||
displayDistance(*overlay, v.length() * 1e-6);
|
||||
*overlay << '\n';
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
displayStarNames(*overlay,
|
||||
*(sel.star()),
|
||||
*(sim->getUniverse()->getStarCatalog()));
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
displayStarInfo(*overlay,
|
||||
hudDetail,
|
||||
*(sel.star()),
|
||||
*(sim->getUniverse()),
|
||||
v.length() * 1e-6);
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
*overlay << sel.body()->getName();
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
displayPlanetInfo(*overlay,
|
||||
hudDetail,
|
||||
*(sel.body()),
|
||||
sim->getTime(),
|
||||
v.length() * 1e-6);
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
{
|
||||
overlay->setFont(titleFont);
|
||||
*overlay << sel.deepsky()->getName();
|
||||
overlay->setFont(font);
|
||||
*overlay << '\n';
|
||||
*overlay << "Distance: ";
|
||||
displayDistance(*overlay, v.length() * 1e-6);
|
||||
*overlay << '\n';
|
||||
#if 0
|
||||
displayGalaxyInfo(*overlay, hudDetail, *sel.galaxy,
|
||||
v.length() * 1e-6);
|
||||
displayGalaxyInfo(*overlay, hudDetail, *sel.galaxy,
|
||||
v.length() * 1e-6);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Location:
|
||||
break;
|
||||
}
|
||||
|
||||
overlay->endText();
|
||||
|
||||
glPopMatrix();
|
||||
|
|
|
@ -739,27 +739,35 @@ static int object_type(lua_State* l)
|
|||
if (sel != NULL)
|
||||
{
|
||||
const char* tname = "unknown";
|
||||
if (sel->body != NULL)
|
||||
switch (sel->getType())
|
||||
{
|
||||
int cl = sel->body->getClassification();
|
||||
switch (cl)
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
case Body::Planet : tname = "planet"; break;
|
||||
case Body::Moon : tname = "moon"; break;
|
||||
case Body::Asteroid : tname = "asteroid"; break;
|
||||
case Body::Comet : tname = "comet"; break;
|
||||
case Body::Spacecraft : tname = "spacecraft"; break;
|
||||
case Body::Invisible : tname = "invisible"; break;
|
||||
int cl = sel->body()->getClassification();
|
||||
switch (cl)
|
||||
{
|
||||
case Body::Planet : tname = "planet"; break;
|
||||
case Body::Moon : tname = "moon"; break;
|
||||
case Body::Asteroid : tname = "asteroid"; break;
|
||||
case Body::Comet : tname = "comet"; break;
|
||||
case Body::Spacecraft : tname = "spacecraft"; break;
|
||||
case Body::Invisible : tname = "invisible"; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sel->star != NULL)
|
||||
{
|
||||
break;
|
||||
|
||||
case Selection::Type_Star:
|
||||
tname = "star";
|
||||
}
|
||||
else if (sel->deepsky != NULL)
|
||||
{
|
||||
break;
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
// TODO: return cluster, galaxy, or nebula as appropriate
|
||||
tname = "deepsky";
|
||||
break;
|
||||
|
||||
case Selection::Type_Location:
|
||||
tname = "location";
|
||||
break;
|
||||
}
|
||||
|
||||
lua_pushstring(l, tname);
|
||||
|
@ -786,18 +794,24 @@ static int object_name(lua_State* l)
|
|||
Selection* sel = to_object(l, 1);
|
||||
if (sel != NULL)
|
||||
{
|
||||
if (sel->body != NULL)
|
||||
{
|
||||
lua_pushstring(l, sel->body->getName().c_str());
|
||||
}
|
||||
else if (sel->deepsky != NULL)
|
||||
{
|
||||
lua_pushstring(l, sel->deepsky->getName().c_str());
|
||||
}
|
||||
else
|
||||
switch (sel->getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
lua_pushstring(l, sel->body()->getName().c_str());
|
||||
break;
|
||||
case Selection::Type_DeepSky:
|
||||
lua_pushstring(l, sel->deepsky()->getName().c_str());
|
||||
break;
|
||||
case Selection::Type_Star:
|
||||
lua_pushstring(l, getAppCore(l)->getSimulation()->getUniverse()
|
||||
->getStarCatalog()->getStarName(*(sel->star)).c_str());
|
||||
->getStarCatalog()->getStarName(*(sel->star())).c_str());
|
||||
break;
|
||||
case Selection::Type_Location:
|
||||
lua_pushstring(l, sel->location()->getName().c_str());
|
||||
break;
|
||||
default:
|
||||
lua_pushstring(l, "?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -825,7 +839,7 @@ static int object_spectraltype(lua_State* l)
|
|||
if (sel->star != NULL)
|
||||
{
|
||||
char buf[16];
|
||||
StellarClass sc = sel->star->getStellarClass();
|
||||
StellarClass sc = sel->star()->getStellarClass();
|
||||
if (sc.str(buf, sizeof(buf)))
|
||||
{
|
||||
lua_pushstring(l, buf);
|
||||
|
@ -867,7 +881,7 @@ static int object_absmag(lua_State* l)
|
|||
if (sel != NULL)
|
||||
{
|
||||
if (sel->star != NULL)
|
||||
lua_pushnumber(l, sel->star->getAbsoluteMagnitude());
|
||||
lua_pushnumber(l, sel->star()->getAbsoluteMagnitude());
|
||||
else
|
||||
lua_pushnil(l);
|
||||
}
|
||||
|
@ -1018,10 +1032,10 @@ static int object_getchildren(lua_State* l)
|
|||
Simulation* sim = appCore->getSimulation();
|
||||
|
||||
lua_newtable(l);
|
||||
if (sel->star != NULL)
|
||||
if (sel->star() != NULL)
|
||||
{
|
||||
SolarSystemCatalog* solarSystemCatalog = sim->getUniverse()->getSolarSystemCatalog();
|
||||
SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel->star->getCatalogNumber());
|
||||
SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel->star()->getCatalogNumber());
|
||||
if (iter != solarSystemCatalog->end())
|
||||
{
|
||||
SolarSystem* solarSys = iter->second;
|
||||
|
@ -1034,9 +1048,9 @@ static int object_getchildren(lua_State* l)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (sel->body != NULL)
|
||||
else if (sel->body() != NULL)
|
||||
{
|
||||
const PlanetarySystem* satellites = sel->body->getSatellites();
|
||||
const PlanetarySystem* satellites = sel->body()->getSatellites();
|
||||
if (satellites != NULL && satellites->getSystemSize() != 0)
|
||||
{
|
||||
for (int i = 0; i < satellites->getSystemSize(); i++)
|
||||
|
|
|
@ -361,31 +361,43 @@ std::string Url::getCoordSysName(astro::CoordinateSystem mode) const
|
|||
std::string Url::getSelectionName(const Selection& selection) const
|
||||
{
|
||||
Universe *universe = appCore->getSimulation()->getUniverse();
|
||||
if (selection.body != 0)
|
||||
|
||||
switch (selection.getType())
|
||||
{
|
||||
std::string name=selection.body->getName();
|
||||
if (selection.body->getSystem() != 0)
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
if (selection.body->getSystem()->getPrimaryBody() != 0)
|
||||
std::string name = selection.body()->getName();
|
||||
if (selection.body()->getSystem() != NULL)
|
||||
{
|
||||
name=selection.body->getSystem()->getPrimaryBody()->getName() + ":" + name;
|
||||
}
|
||||
if (selection.body->getSystem()->getStar() != 0)
|
||||
{
|
||||
name=universe->getStarCatalog()->getStarName(*(selection.body->getSystem()->getStar()))
|
||||
+ ":" + name;
|
||||
if (selection.body()->getSystem()->getPrimaryBody() != NULL)
|
||||
{
|
||||
name = selection.body()->getSystem()->getPrimaryBody()->getName() + ":" + name;
|
||||
}
|
||||
if (selection.body()->getSystem()->getStar() != NULL)
|
||||
{
|
||||
name=universe->getStarCatalog()->getStarName(*(selection.body()->getSystem()->getStar()))
|
||||
+ ":" + name;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
return name;
|
||||
case Selection::Type_Star:
|
||||
return universe->getStarCatalog()->getStarName(*selection.star());
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
return selection.deepsky()->getName();
|
||||
|
||||
case Selection::Type_Location:
|
||||
return "";
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
if (selection.star != 0) return universe->getStarCatalog()->getStarName(*selection.star);
|
||||
if (selection.deepsky != 0) return selection.deepsky->getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
void Url::goTo()
|
||||
{
|
||||
{
|
||||
Selection sel;
|
||||
|
||||
if (urlStr == "")
|
||||
|
|
|
@ -63,13 +63,13 @@ static BOOL APIENTRY GotoObjectProc(HWND hDlg,
|
|||
sim->getSelectionLongLat(distance, longitude, latitude);
|
||||
|
||||
//Display information in format appropriate for object
|
||||
if (sim->getSelection().body != NULL)
|
||||
if (sim->getSelection().body() != NULL)
|
||||
{
|
||||
distance = distance - (double)sim->getSelection().body->getRadius();
|
||||
distance = distance - (double) sim->getSelection().body()->getRadius();
|
||||
SetDialogFloat(hDlg, IDC_EDIT_DISTANCE, "%.1f", (float)distance);
|
||||
SetDialogFloat(hDlg, IDC_EDIT_LONGITUDE, "%.5f", (float)longitude);
|
||||
SetDialogFloat(hDlg, IDC_EDIT_LATITUDE, "%.5f", (float)latitude);
|
||||
SetDlgItemText(hDlg, IDC_EDIT_OBJECTNAME, (char*)sim->getSelection().body->getName().c_str());
|
||||
SetDlgItemText(hDlg, IDC_EDIT_OBJECTNAME, (char*) sim->getSelection().body()->getName().c_str());
|
||||
}
|
||||
// else if (sim->getSelection().star != NULL)
|
||||
// {
|
||||
|
|
|
@ -821,15 +821,22 @@ BOOL APIENTRY AddBookmarkProc(HWND hDlg,
|
|||
RemoveButtonDefaultStyle(hOK);
|
||||
AddButtonDefaultStyle(hCancel);
|
||||
|
||||
//Set bookmark text to selection text
|
||||
// Set bookmark text to selection text
|
||||
if (hCtrl = GetDlgItem(hDlg, IDC_BOOKMARK_EDIT))
|
||||
{
|
||||
//If this is a body, set the text.
|
||||
Selection sel = appCore->getSimulation()->getSelection();
|
||||
if (sel.body != NULL)
|
||||
{
|
||||
string name = sel.body->getName();
|
||||
SetWindowText(hCtrl, (char*)name.c_str());
|
||||
switch (sel.getType())
|
||||
{
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
string name = sel.body()->getName();
|
||||
SetWindowText(hCtrl, (char*)name.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1437,63 +1444,79 @@ VOID APIENTRY handlePopupMenu(HWND hwnd,
|
|||
|
||||
hMenu = CreatePopupMenu();
|
||||
|
||||
if (sel.body != NULL)
|
||||
switch (sel.getType())
|
||||
{
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER, sel.body->getName().c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "&Follow");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_SYNCORBIT, "S&ync Orbit");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
|
||||
const PlanetarySystem* satellites = sel.body->getSatellites();
|
||||
if (satellites != NULL && satellites->getSystemSize() != 0)
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
HMENU satMenu = CreatePlanetarySystemMenu(satellites);
|
||||
AppendMenu(hMenu, MF_POPUP | MF_STRING, (DWORD) satMenu,
|
||||
"&Satellites");
|
||||
}
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER,
|
||||
sel.body()->getName().c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "&Follow");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_SYNCORBIT, "S&ync Orbit");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
|
||||
vector<string>* altSurfaces = sel.body->getAlternateSurfaceNames();
|
||||
if (altSurfaces != NULL)
|
||||
{
|
||||
if (altSurfaces->size() != NULL)
|
||||
const PlanetarySystem* satellites = sel.body()->getSatellites();
|
||||
if (satellites != NULL && satellites->getSystemSize() != 0)
|
||||
{
|
||||
HMENU surfMenu = CreateAlternateSurfaceMenu(*altSurfaces);
|
||||
AppendMenu(hMenu, MF_POPUP | MF_STRING, (DWORD) surfMenu,
|
||||
"&Alternate Surfaces");
|
||||
HMENU satMenu = CreatePlanetarySystemMenu(satellites);
|
||||
AppendMenu(hMenu, MF_POPUP | MF_STRING, (DWORD) satMenu,
|
||||
"&Satellites");
|
||||
}
|
||||
delete altSurfaces;
|
||||
}
|
||||
}
|
||||
else if (sel.star != NULL)
|
||||
{
|
||||
Simulation* sim = appCore->getSimulation();
|
||||
name = sim->getUniverse()->getStarCatalog()->getStarName(*sel.star);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER, name.c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
|
||||
SolarSystemCatalog* solarSystemCatalog = sim->getUniverse()->getSolarSystemCatalog();
|
||||
SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel.star->getCatalogNumber());
|
||||
if (iter != solarSystemCatalog->end())
|
||||
{
|
||||
SolarSystem* solarSys = iter->second;
|
||||
HMENU planetsMenu = CreatePlanetarySystemMenu(solarSys->getPlanets());
|
||||
AppendMenu(hMenu,
|
||||
MF_POPUP | MF_STRING,
|
||||
(DWORD) planetsMenu,
|
||||
"&Planets");
|
||||
vector<string>* altSurfaces = sel.body()->getAlternateSurfaceNames();
|
||||
if (altSurfaces != NULL)
|
||||
{
|
||||
if (altSurfaces->size() != NULL)
|
||||
{
|
||||
HMENU surfMenu = CreateAlternateSurfaceMenu(*altSurfaces);
|
||||
AppendMenu(hMenu, MF_POPUP | MF_STRING, (DWORD) surfMenu,
|
||||
"&Alternate Surfaces");
|
||||
}
|
||||
delete altSurfaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sel.deepsky != NULL)
|
||||
{
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER, sel.deepsky->getName().c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "&Follow");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
break;
|
||||
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
Simulation* sim = appCore->getSimulation();
|
||||
name = sim->getUniverse()->getStarCatalog()->getStarName(*(sel.star()));
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER, name.c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
|
||||
SolarSystemCatalog* solarSystemCatalog = sim->getUniverse()->getSolarSystemCatalog();
|
||||
SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel.star()->getCatalogNumber());
|
||||
if (iter != solarSystemCatalog->end())
|
||||
{
|
||||
SolarSystem* solarSys = iter->second;
|
||||
HMENU planetsMenu = CreatePlanetarySystemMenu(solarSys->getPlanets());
|
||||
AppendMenu(hMenu,
|
||||
MF_POPUP | MF_STRING,
|
||||
(DWORD) planetsMenu,
|
||||
"&Planets");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
{
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_CENTER,
|
||||
sel.deepsky()->getName().c_str());
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "&Follow");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_Location:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (appCore->getSimulation()->getUniverse()->isMarked(sel, 1))
|
||||
|
@ -1522,28 +1545,40 @@ VOID APIENTRY handlePopupMenu(HWND hwnd,
|
|||
void ShowWWWInfo(const Selection& sel)
|
||||
{
|
||||
string url;
|
||||
if (sel.body != NULL)
|
||||
switch (sel.getType())
|
||||
{
|
||||
url = sel.body->getInfoURL();
|
||||
if (url.empty())
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
string name = sel.body->getName();
|
||||
for (int i = 0; i < name.size(); i++)
|
||||
name[i] = tolower(name[i]);
|
||||
url = sel.body()->getInfoURL();
|
||||
if (url.empty())
|
||||
{
|
||||
string name = sel.body()->getName();
|
||||
for (int i = 0; i < name.size(); i++)
|
||||
name[i] = tolower(name[i]);
|
||||
|
||||
url = string("http://www.nineplanets.org/") + name + ".html";
|
||||
url = string("http://www.nineplanets.org/") + name + ".html";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sel.star != NULL)
|
||||
{
|
||||
char name[32];
|
||||
sprintf(name, "HIP%d", sel.star->getCatalogNumber() & ~0xf0000000);
|
||||
break;
|
||||
|
||||
url = string("http://simbad.u-strasbg.fr/sim-id.pl?protocol=html&Ident=") + name;
|
||||
}
|
||||
else if (sel.deepsky != NULL)
|
||||
{
|
||||
url = sel.deepsky->getInfoURL();
|
||||
case Selection::Type_Star:
|
||||
{
|
||||
char name[32];
|
||||
sprintf(name, "HIP%d", sel.star()->getCatalogNumber() & ~0xf0000000);
|
||||
|
||||
url = string("http://simbad.u-strasbg.fr/sim-id.pl?protocol=html&Ident=") + name;
|
||||
}
|
||||
break;
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
url = sel.deepsky()->getInfoURL();
|
||||
break;
|
||||
|
||||
case Selection::Type_Location:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShellExecute(mainWindow,
|
||||
|
@ -3574,19 +3609,29 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
{
|
||||
// Handle the satellite/child object submenu
|
||||
Selection sel = appCore->getSimulation()->getSelection();
|
||||
if (sel.star != NULL)
|
||||
switch (sel.getType())
|
||||
{
|
||||
case Selection::Type_Star:
|
||||
appCore->getSimulation()->selectPlanet(LOWORD(wParam) - MENU_CHOOSE_PLANET);
|
||||
}
|
||||
else if (sel.body != NULL)
|
||||
{
|
||||
PlanetarySystem* satellites = (PlanetarySystem*)sel.body->getSatellites();
|
||||
appCore->getSimulation()->setSelection(Selection(satellites->getBody(LOWORD(wParam) - MENU_CHOOSE_PLANET)));
|
||||
}
|
||||
else if (sel.deepsky != NULL)
|
||||
{
|
||||
break;
|
||||
|
||||
case Selection::Type_Body:
|
||||
{
|
||||
PlanetarySystem* satellites = (PlanetarySystem*) sel.body()->getSatellites();
|
||||
appCore->getSimulation()->setSelection(Selection(satellites->getBody(LOWORD(wParam) - MENU_CHOOSE_PLANET)));
|
||||
break;
|
||||
}
|
||||
|
||||
case Selection::Type_DeepSky:
|
||||
// Current deep sky object/galaxy implementation does
|
||||
// not have children to select.
|
||||
break;
|
||||
|
||||
case Selection::Type_Location:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (LOWORD(wParam) >= MENU_CHOOSE_SURFACE &&
|
||||
|
@ -3594,10 +3639,10 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
{
|
||||
// Handle the alternate surface submenu
|
||||
Selection sel = appCore->getSimulation()->getSelection();
|
||||
if (sel.body != NULL)
|
||||
if (sel.body() != NULL)
|
||||
{
|
||||
int index = (int) LOWORD(wParam) - MENU_CHOOSE_SURFACE - 1;
|
||||
vector<string>* surfNames = sel.body->getAlternateSurfaceNames();
|
||||
vector<string>* surfNames = sel.body()->getAlternateSurfaceNames();
|
||||
if (surfNames != NULL)
|
||||
{
|
||||
string surfName;
|
||||
|
|
Loading…
Reference in New Issue