Added radius method.
This commit is contained in:
parent
7cd3279581
commit
22deda23c2
24
src/selection.cpp
Normal file
24
src/selection.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
// selection.cpp
|
||||
//
|
||||
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include "astro.h"
|
||||
#include "selection.h"
|
||||
|
||||
|
||||
double Selection::radius() const
|
||||
{
|
||||
if (star != NULL)
|
||||
return star->getRadius();
|
||||
else if (body != NULL)
|
||||
return body->getRadius();
|
||||
else if (galaxy != NULL)
|
||||
return astro::lightYearsToKilometers(galaxy->getRadius());
|
||||
else
|
||||
return 0.0;
|
||||
}
|
|
@ -10,6 +10,11 @@
|
|||
#ifndef _SELECTION_H_
|
||||
#define _SELECTION_H_
|
||||
|
||||
#include "star.h"
|
||||
#include "body.h"
|
||||
#include "galaxy.h"
|
||||
|
||||
|
||||
class Selection
|
||||
{
|
||||
public:
|
||||
|
@ -20,12 +25,14 @@ class Selection
|
|||
~Selection() {};
|
||||
|
||||
bool empty() { return star == NULL && body == NULL && galaxy == NULL; };
|
||||
double radius() const;
|
||||
|
||||
Star* star;
|
||||
Body* body;
|
||||
Galaxy* galaxy;
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(const Selection& s0, const Selection& s1)
|
||||
{
|
||||
return s0.star == s1.star && s0.body == s1.body && s0.galaxy == s1.galaxy;
|
||||
|
|
Loading…
Reference in a new issue