// 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 "galaxy.hh" #include namespace Castor { Galaxy::Galaxy() { } Galaxy::~Galaxy() { } /*! \fn bool Galaxy::add_element (std::string& name, element_type type, std::string& value); * \param name Name of the element type * \param type Type of element INT, DOUBLE or STRING * \param value Value of element * \return True, if the element type is known * * Add the data element to this object. The element type is specified as either an * int, double or a string. If the element is unknown to this object, * it is passed down through to the next layer. * * Elements known to this class are * */ bool Galaxy::add_element (std::string& name, element_type type, std::string& value) { switch (type) { case DOUBLE: { double val = strtod (value.c_str(), 0); if (name == "Btot") { m_mag = val; return true; } if (name == "PA") { m_pa = val; return true; } if (name == "RadVel") { m_radvel = val; return true; } if (name == "MinAxis") { m_min_axis = val; return true; } if (name == "MajAxis") { m_maj_axis = val; return true; } } case STRING: { if (name == "MType") { m_mtype = value; return true; } } } return DeepObject::add_element (name, type, value); } /*! \fn bool Galaxy::check_element (std::string& name); * \param name Name of the element type * \return True, if the element type is known * * Is the element type known to the object. * * Elements known to this class are * */ bool Galaxy::check_element (std::string& name) { if (name == "Btot") return true; if (name == "MType") return true; if (name == "PA") return true; if (name == "RadVel") return true; if (name == "MajAxis") return true; if (name == "MinAxis") return true; return DeepObject::check_element(name); } /*! \fn void Galaxy::get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn) * \param JD Jualian Day * \param observer Observers position * \param posn Pointer to return position * * Get the horizontal position of the galaxy */ void Galaxy::get_hrz_posn (double JD, ln_lnlat_posn* observer, ln_hrz_posn* posn) { struct ln_equ_posn equ_posn; ln_get_solar_equ_coords(JD, &equ_posn); ln_get_hrz_from_equ (&equ_posn, observer, JD, posn); } /*! \fn void Galaxy::get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time) * \param JD Jualin Day * \param observer Observers position * \param time Pointer to store RST times * * Get object rise, transit and set time. */ void Galaxy::get_rst_time (double JD, ln_lnlat_posn* observer, ln_rst_time* time) { } /*! \fn double Galaxy::get_posn (double& ra, double& dec) * \param ra Right Ascension * \param dec Declination * * Get the Right Ascension and Declination. */ void Galaxy::get_posn(double& ra, double& dec) { ra = m_ra; dec = m_dec; } /*! \fn void Galaxy::get_id(std::string& id) * \param id Galaxy ID * * Get Galaxy identification number. */ void Galaxy::get_id(std::string& id) { id = m_cat_no; } /*! \fn void Galaxy::get_name(std::string& name) * \param name Galaxy Name * * Get Galaxy name. */ void Galaxy::get_name(std::string& name) { //name = m_name; } /*! \fn void Galaxy::get_info (std::list& value) * \brief Get object information */ void Galaxy::get_info (std::list& value) { } /*! \fn void Galaxy::get_axis (double& maj, double& min); * \param maj Major axis (arcmin) * \param min Minor axis (arcmin) * * Get the major and minor axis */ void Galaxy::get_axis (double& maj, double& min) { maj = m_maj_axis; min = m_min_axis; } /*! \fn double Galaxy::get_pa (); * \return The position angle (degrees) * * Get position angle. Position angle measured in the * conventional manner from North through East. */ double Galaxy::get_pa () { return m_pa; } /*! \fn double Galaxy::get_radvel(); * \return Radial Velocity (km/s) * * Get the radial velocity of the galaxy */ double Galaxy::get_radvel() { return m_radvel; } /*! \fn void Galaxy::render(double x, double y, double mag_max, Gnome::Canvas::Group& group, bool bright) * \param x Sky x position * \param y Sky y position * \param mag_max Sky maximum visible magnitude * \param Gnome canvas group * \param bright Render only with less detail (faster) * * Render galaxy. Galaxies will be rendered as green ovals. */ void Galaxy::render(double x, double y, double mag_max, Gnome::Canvas::Group& group, bool bright, double ppd) { #if 0 // draw galaxy on canvas double x_size = ; double x_shadow = 1.1 * x_size; double y_shadow = 1.1 * y_sizel 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(Gdk::Color("green")); ellipse->show(); #endif } int Galaxy::save (std::ofstream* file) { save_item (file, m_mtype); DeepObject::save(file); } int Galaxy::load (std::ifstream* file) { load_item (file, m_mtype); DeepObject::load(file); } }