// 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.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Copyright 2003 Liam Girdwood
#include "comet.hh"
#include <libnova/libnova.h>
#include <libgnomecanvasmm/group.h>
#include <libgnomecanvasmm/ellipse.h>
namespace Castor
{
Comet::Comet()
{
}
Comet::Comet(Glib::ustring& name, Glib::ustring& id, struct ln_ell_orbit& orbit,
double g, double k)
{
m_is_parabolic = false;
m_name = name;
m_cat_no = id;
m_eorbit = orbit;
m_g = g;
m_k = k;
}
Comet::Comet(Glib::ustring& name, Glib::ustring& id, struct ln_par_orbit& orbit,
double g, double k)
{
m_is_parabolic = true;
m_name = name;
m_cat_no = id;
m_porbit = orbit;
m_g = g;
m_k = k;
}
Comet::~Comet()
{
}
/*! \fn void Comet::get_equ_posn (double JD, ln_equ_posn* posn)
* \brief Get object equatorial position.
*/
void Comet::get_equ_posn (double JD, double& ra, double& dec)
{
struct ln_equ_posn posn;
if (m_is_parabolic)
ln_get_par_body_equ_coords (JD, &m_porbit, &posn);
else
ln_get_ell_body_equ_coords (JD, &m_eorbit, &posn);
ra = posn.ra;
dec = posn.dec;
}
/*! \fn void Comet::get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn)
* \brief Get object horizontal position
*/
void Comet::get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn)
{
struct ln_equ_posn equ_posn;
double ra, dec;
get_equ_posn(JD, ra, dec);
equ_posn.ra = ra;
equ_posn.dec = dec;
ln_get_hrz_from_equ (&equ_posn, observer, JD, posn);
}
/*! \fn void Comet::get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time)
* \brief Get object rise, transit and set time.
*/
void Comet::get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time)
{
if (m_is_parabolic)
ln_get_par_body_rst(JD, observer, &m_porbit, time);
else
ln_get_ell_body_rst(JD, observer, &m_eorbit, time);
}
/*! \fn double Comet::get_mag(double JD)
* \brief Get object Magnitude
*/
double Comet::get_mag(double JD)
{
if (m_is_parabolic)
return ln_get_par_comet_mag (JD, &m_porbit, m_g, m_k);
else
return ln_get_ell_comet_mag (JD, &m_eorbit, m_g, m_k);
}
/*! \fn void Comet::get_id(std::string& id)
* \brief Get object identification number.
*/
void Comet::get_id(std::string& id)
{
id = m_cat_no;
}
/*! \fn void Comet::get_name(std::string& name)
* \brief Get object name.
*/
void Comet::get_name(std::string& name)
{
name = m_name;
}
/*! \fn void Comet::get_info (std::list<Glib::ustring>& value)
* \brief Get object information
*/
void Comet::get_info (std::list<Glib::ustring>& value)
{
}
/*! \fn void Comet::render(double x, double y, double mag_max, Gnome::Canvas::Group& group)
* \brief Render object
*/
void Comet::render(double x, double y, double mag_max, Gnome::Canvas::Group& group, bool bright, double ppd)
{
// draw object on canvas
double size = (mag_max + 1) - ln_get_neptune_magnitude(m_render_JD);
double shadow = 1.1 * size;
Gnome::Canvas::Ellipse *ellipse_back, *ellipse;
if (!bright) {
// draw the background shadow object
ellipse_back = Gtk::manage (new Gnome::Canvas::Ellipse(group, x - shadow, y - shadow, x + shadow, y + shadow));
*ellipse_back << Gnome::Canvas::Properties::fill_color("black");
ellipse_back->show();
}
// draw real colour object
ellipse = Gtk::manage (new Gnome::Canvas::Ellipse(group, x - size, y - size, x + size, y + size));
ellipse->set_data (Glib::Quark("object"),(gpointer)this);
*ellipse << Gnome::Canvas::Properties::fill_color("blue");
ellipse->show();
}
void Comet::set_render_jd (double JD)
{
m_render_JD = JD;
}
double Comet::get_earth_dist (double JD)
{
if (m_is_parabolic)
return ln_get_par_body_earth_dist(JD, &m_porbit);
else
return ln_get_ell_body_earth_dist (JD, &m_eorbit);
}
double Comet::get_sun_dist (double JD)
{
if (m_is_parabolic)
return ln_get_par_body_solar_dist(JD, &m_porbit);
else
return ln_get_ell_body_solar_dist (JD, &m_eorbit);
}
}
syntax highlighted by Code2HTML, v. 0.9.1