// 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 Liam Girdwood 2003

#ifndef _VIRTUAL_SKY_HH
#define _VIRTUAL_SKY_HH

#include <libgnomecanvasmm/canvas.h>
#include "nova_page.hh"
#include "astro_object.hh"
#include "constellation.hh"
#include "library.hh"
#include "grid.hh"
#include "sky_proj.hh"
#include "sky_flat.hh"
#include "sky_spherical.hh"
#include "sky_appbar.hh"
#include <libxml++/libxml++.h>
#include <libnova/libnova.h>

/*! \namespace Vega
* \brief Nova Virtual Sky Engine
*/
namespace Vega
{

	
/*! \class VirtualSky
* \brief Nova Virtual Sky
*
* This class manages the sky view. It can display display
* different sky projections (only a flat and basic spherical
* at the moment).
*
* This class carries out all file/print IO for the sky view.
*/	
class VirtualSky : public Polaris::NovaPage
{
	public:
	
		/*! \enum Proj Sky projection type
		*/
		enum Proj {
			FLAT = 0, 	/*!< Flat sky projection */
			SPHERICAL,	/*!< Spherical sky projection */
		};				
	
		VirtualSky();
		~VirtualSky();
	
		// nova page IO
		bool save();
		bool save_as(Glib::ustring file);
		bool print();
		bool open(Glib::ustring file);
	
		// signals from app
		bool zoom (double zoom);
		void move_ra(double move);
		void move_dec(double move);
		bool change_projection();
		void set_size(int width, int height);
		
		/*! \fn bool create_sky ();
		* \brief Create and display virtual sky
		*/
		bool create_sky ();

		// sky info
		void set_jd(double JD);
		void set_elevation(double m);
		double get_elevation();
		void set_epoch(double m);
		double get_epoch();
		double get_latitude();
		void set_latitude(double latitude);
		double get_longitude();
		void set_longitude(double longitude);
		void get_location(Glib::ustring& location);
		void set_location(Glib::ustring& location);
		void set_live(bool live);

	private:
		SkyProj* m_projection;			/*!< Virtual sky projection */
		Pollux::Library* m_library; 	/*!< VSky object library */
		Pollux::Catalog* m_default_cat;	/*!< Default object catalog */
		SkyAppbar m_appbar;				/*!< Virtual sky appbar */
	
		int m_width;					/*!< Sky width */
		int m_height;					/*!< Sky height */
		Proj m_proj_type;				/*!< Sky projection type */
	
		// sky/observer details
		double m_JD;					/*!< Julian Day */
		double m_epoch;					/*!< Observing Epoch */
		Glib::ustring m_location;		/*!< Observer location name */
		double m_elevation;				/*!< Observer elevation */
		ln_lnlat_posn m_observer;		/*!< Observer posn */
		bool m_live;					/*!< Sky view is current system time */
		
		
		/*! \fn void parse_node(const xmlpp::Node* node);
		* \brief Parse XML virtual sky file
		*/
		void parse_node(const xmlpp::Node* node);
	
		// appbar 
		
		/*! \fn void appbar_set_equ (double x, double y, bool transform = true);
		* \brief Set RA and DEC on appbar
		*/
		void appbar_set_equ (double x, double y, bool transform = true);
		
		/*! \fn void appbar_set_hrz (double x, double y, bool transform = true);
		* \brief Set ALT and AZ on appbar
		*/
		void appbar_set_hrz (double x, double y, bool transform = true);
		
		/*! \fn void appbar_set_fov ();
		* \brief Set FOV on appbar
		*/
		void appbar_set_fov ();
		
		/*! \fn void  appbar_set_object (Castor::AstroObject* object);
		* \brief Set Object details on appbar
		*/
		void appbar_set_object (Castor::AstroObject* object);
		
		// signal handlers
		
		/*! \fn bool on_canvas_button_press_event(GdkEventButton *ev);
		* \brief Sky mouse key press event handler
		*/
        bool on_canvas_button_press_event(GdkEventButton *ev);
		
		/*! \fn bool on_canvas_button_release_event(GdkEventButton *ev);
		* \brief Sky mouse key release event handler
		*/
        bool on_canvas_button_release_event(GdkEventButton *ev);
		
		/*! \fn bool on_canvas_motion_event(GdkEventMotion *ev);
		* \brief Sky mouse motion event handler
		*/
		bool on_canvas_motion_event(GdkEventMotion *ev);
		
		/*! \fn bool on_canvas_enter_notify_event(GdkEventCrossing *ev);
		* \brief Sky pointer enter event handler
		*/
		bool on_canvas_enter_notify_event(GdkEventCrossing *ev);
		
		/*! \fn bool on_canvas_leave_notify_event(GdkEventCrossing *ev);
		* \brief Sky pointer leave event handler
		*/
		bool on_canvas_leave_notify_event(GdkEventCrossing *ev);
		
		/*! \fn bool on_canvas_key_press_event(GdkEventKey *ev);
		* \brief Sky key press event handler
		*/
		bool on_canvas_key_press_event(GdkEventKey *ev);
		
		/*! \fn bool on_canvas_key_release_event(GdkEventKey *ev);
		* \brief Sky key release event handler
		*/
		bool on_canvas_key_release_event(GdkEventKey *ev);
};

};

#endif


syntax highlighted by Code2HTML, v. 0.9.1