Skip to content
Snippets Groups Projects
Select Git revision
  • master default
  • mingw_gcc44
  • release_ABP1_012
  • release_ABP1_008
  • release_ABP1_006
  • release_ABP1_007
  • release_ABP1_005
  • release_ABP1_004
  • release_ABP1_003
  • pre_release_0.15
  • release_ABP1_001
  • release_ABP1_002
  • pre_release_0.13
  • pre_release_0.14
  • pre_release_0.11
  • pre_release_0.12
  • pre_release_0.10
  • pre_release_0.09
  • pre_release_0.08
19 results

Starsphere.h

Blame
  • Forked from einsteinathome / graphicsframework
    249 commits behind the upstream repository.
    Starsphere.h 6.31 KiB
    #ifndef STARSPHERE_H_
    #define STARSPHERE_H_
    
    #include <cmath>
    #include <cstdio>
    #include <ctime>
    #include <string>
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    #include <SDL.h>
    #include <SDL_opengl.h>
    
    #include <oglft/OGLFT.h>
    
    #include <util.h>
    
    #include "AbstractGraphicsEngine.h"
    
    
    /* SIN and COS take arguments in DEGREES */
    #define PI 3.14159265
    #define PI2 (2*PI)
    #define COS(X)   cos( (X) * PI2/360.0 )
    #define SIN(X)   sin( (X) * PI2/360.0 )
    
    /* search marker status */
    #define MARKER_NONE 0
    #define MARKER_SHOW 1
    #define MARKER_NEW  2
    
    // needed to find OpenGL 1.4 prototypes in glext.h (alternatives?)
    #define GL_GLEXT_PROTOTYPES
    
    using namespace std;
    
    
    /**
     * \brief %Starsphere rendering engine for \b Einstein\@Home
     * 
     * This class comprises the generic parts of the %Starsphere rendering engine.
     * %Starsphere displays the celestial sphere indicating a fixed set of stars with
     * their constellations as well as known pulsars and supernova remnants. Apart from
     * that the four main gravitational wave observatory locations are shown at their actual
     * real-time position. Furthermore a head-up display (HUD) shows relevant BOINC
     * statistics as well as information on the current workunit (WU) being processed.
     * 
     * For more details please refer to http://einstein.phys.uwm.edu/starsphere.php
     * 
     * Note: all science run specific parts are implemented in specialized subclasses
     * of this engine.
     * 
     * \todo The code of this implementaion is based on the former version of %Starsphere
     * by Bruce Allen, David Hammer and Eric Myers. Due to this there's still
     * some refactoring and code cleanup left to be done.
     * 
     * \author Oliver Bock\n
     * Max-Planck-Institute for Gravitational Physics\n
     * Hannover, Germany
     */
    class Starsphere : public AbstractGraphicsEngine
    {
    public:
    	/// Destructor
    	virtual ~Starsphere();
    
    	/**
    	 * \brief This method is called to initialize the engine
    	 * 
    	 * \param width The current width of the display surface
    	 * \param height The current height of the display surface
    	 * \param font A pointer to a Resource object containing TTF font faces for text rendering 
    	 */
    	virtual void initialize(const int width, const int height, const Resource *font);
    	
    	/**
    	 * \brief This method is called when the windowing system encounters a window resize event
    	 * 
    	 * \param width The new width of the display surface
    	 * \param height The new height of the display surface
    	 */
    	virtual void resize(const int width, const int height);
    	void render(const double timeOfDay);
    
    	// event handling
    	void mouseButtonEvent(const int positionX, const int positionY,
    						  const AbstractGraphicsEngine::MouseButton buttonPressed);
    	void mouseMoveEvent(const int deltaX, const int deltaY,
    						const AbstractGraphicsEngine::MouseButton buttonPressed);
    	void keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey keyPressed);
    	
    	/**
    	 * \brief This method is called when the BOINC client information should be updated
    	 */
    	virtual void refreshBOINCInformation();
    	
    protected:
    	/**
    	 * \brief Default contructor
    	 * 
    	 * The constructor is protected since this an abstract class.
    	 */	
    	Starsphere();
    	
    	/**
    	 * \brief Render science run specific search information
    	 * 
    	 * This abtract method is to be defined by derived classes implementing
    	 * the science run specific search information handling and rendering.
    	 * 
    	 * Note: for this engine this also includes the "BOINC Statistics"
    	 * as it is top-aligned to the "Search Information".
    	 */
    	virtual void renderSearchInformation() = 0;
    	
    
    	// resource handling
    	OGLFT::TranslucentTexture* m_FontLogo1;
    	OGLFT::TranslucentTexture* m_FontLogo2;
    	OGLFT::TranslucentTexture* m_FontHeader;
    	OGLFT::TranslucentTexture* m_FontText;
    	
    	// Graphics state info:
    	int m_CurrentWidth;
    	int m_CurrentHeight;
    	float aspect;
    	
    	// HUD text rendering config (maybe overridden in subclasses)
    	GLfloat m_XStartPosLeft;
    	GLfloat m_YStartPosTop;
    	GLfloat m_YOffsetLarge;
    	
    	// local HUD contents
    	string m_UserName;
    	string m_TeamName;
    	string m_UserCredit;
    	string m_UserRACredit;
    	
    	// search marker info
    	double m_CurrentRightAscension;
    	double m_CurrentDeclination;
    	bool m_RefreshSearchMarker;
    	
    private:
    	void make_stars();
    	void make_pulsars();
    	void make_snrs();
    	void make_constellations();
    	void make_obs();
    	void make_axes();
    	void make_globe();
    	void make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size);
    
    	GLfloat RAofZenith(double T, GLfloat LONdeg);
    	void sphVertex3D(GLfloat RAdeg, GLfloat DEdeg, GLfloat radius);
    	void sphVertex(GLfloat RAdeg, GLfloat DEdeg);
    	void star_marker(float RAdeg, float DEdeg, float size);
    
    	/**
    	 * Object ID's  and on/off switches.
    	 * (someday the keyboard can be used to turn display of items on/off)
    	 */
    	GLuint Axes, Stars, Constellations, Pulsars;
    	GLuint LLOmarker, LHOmarker, GEOmarker, VIRGOmarker;
    	GLuint sphGrid, SNRs, SearchMarker;
    
    	/**
    	 * Parameters and State info:
    	 */
    	GLfloat sphRadius;
    	int featureFlags;
    
    	/**
    	 * Viewpoint (can be changed with mouse)
    	 */
    	GLfloat viewpt_azimuth; // azimuth, in degrees
    	GLfloat viewpt_elev; // elevation angle, in degrees
    	GLfloat viewpt_radius; // distance out
    
    	GLfloat wobble_amp; // wobble amplitude, in degrees
    	GLfloat wobble_period; // wobble up/down period, in minutes
    	GLfloat zoom_amp; // radial zoom amplitude
    	GLfloat zoom_period; // zoom in/out period, in minutes
    
    	GLfloat rotation_offset; // so that we can rotate sphere
    	GLfloat rotation_speed; // degrees per minute
    
    	//------------ new clean members -----
    	
    	// view control
    	void rotateSphere(const int relativeRotation, const int relativeElevation);
    	void zoomSphere(const int relativeZoom);
    	
    	// feature control
    	enum Features {
    		STARS = 1,
    		CONSTELLATIONS = 2,
    		OBSERVATORIES = 4,
    		XRAYS = 8,
    		PULSARS = 16,
    		SNRS = 32,
    		GLOBE = 64,
    		AXES = 128,
    		SEARCHINFO = 256,
    		LOGO = 512,
    		MARKER = 1024
    	};	
    	
    	void setFeature(const Features features, const bool enable);
    	bool isFeature(const Features features);
    
    	// observatory movement
    	// (in seconds since 1970 with usec precision)
    	double m_ObservatoryDrawTimeLocal;
    };
    
    /* Constellation & star coordinates are in starlist.C */
    extern "C" float star_info[][2];
    extern "C" int Nstars;
    
    /* Pulsar coordinates are in pulsar_list.C */
    extern "C" float pulsar_info[][2];
    extern "C" int Npulsars;
    
    /* SNR coordinates are in snr_list.C */
    extern "C" float SNR_info[][2];
    extern "C" int NSNRs;
    
    #endif /*STARSPHERE_H_*/