Observability.hpp   Observability.hpp 
skipping to change at line 33 skipping to change at line 33
#include <QString> #include <QString>
#include "VecMath.hpp" #include "VecMath.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
class QPixmap; class QPixmap;
class StelButton; class StelButton;
class ObservabilityDialog; class ObservabilityDialog;
//! Main class of the %Observability Analysis plug-in.
//! It provides an observability report for the currently selected object,
//! or for the point in the center of the screen if no object is selected.
//! The output is drawn directly onto the viewport. The color and font size
can
//! be selected by the user from the plug-in's configuration window.
//! @see ObservabilityDialog
//! @todo Find a way to (optionally) put the report in the upper left corne
r
//! infobox.
//! @todo Decide whether to use flags or separate getters/setters to commun
icate
//! with the configuration window; if using flags, implement them properly
w Qt.
//! @todo Handle re-loading of the Solar System at runtime.
//! @todo For each suspicious member variable, check if it can't be actuall
y
//! a local variable.
class Observability : public StelModule class Observability : public StelModule
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool flagShowReport READ isShownReport WRITE showReport)
public: public:
Observability(); Observability();
virtual ~Observability(); virtual ~Observability();
virtual void init(); virtual void init();
virtual void update(double) {;} virtual void update(double) {;}
virtual void draw(StelCore* core, class StelRenderer* renderer); virtual void draw(StelCore* core);
virtual double getCallOrder(StelModuleActionName actionName) const; virtual double getCallOrder(StelModuleActionName actionName) const;
//! Implement this to tell the main Stellarium GUI that there is a G UI element to configure this plugin. //! Implement this to tell the main Stellarium GUI that there is a G UI element to configure this plugin.
virtual bool configureGui(bool show=true); virtual bool configureGui(bool show=true);
//! Set up the plugin with default values. //! Read (or re-read) settings from the main config file.
void restoreDefaults(void); //! Default values are provided for all settings.
void restoreDefaultConfigIni(void); //! Called in init() and resetConfiguration().
void loadConfiguration();
//! Read (or re-read) settings from the main config file. This will
be called from init and also
//! when restoring defaults (i.e. from the configuration dialog / re
store defaults button).
void readSettingsFromConfig(void);
//! Save the settings to the main configuration file.
void saveSettingsToConfig(void);
//! Set which output is shown.
//! @param output is the index of the output (e.g., 1 for today's ep
hemeris, 5 for Full Moon).
//! @param show is a boolean (true to show the output; false to hide
it).
void setShow(int output, bool show);
//! Set the font colors. Color is (0,1,2) for (R,G,B):
void setFontColor(int Color, int Value);
//! Set the font size:
void setFontSize(int);
//! Set the Sun altitude at twilight:
void setSunAltitude(int);
//! Set the Sun altitude at twilight:
void setHorizAltitude(int);
//! get Show Flags from current configuration: //! get Show Flags from current configuration:
bool getShowFlags(int); bool getShowFlags(int);
//! get the current font color: //! get the current font color:
Vec3f getFontColor(void); Vec3f getFontColor(void);
//! get current font size: //! get current font size:
int getFontSize(void); int getFontSize(void);
//! get current Sun altitude at twilight: //! Get the user-defined Sun altitude at twilight.
int getSunAltitude(void); //! @returns A value in degrees.
int getTwilightAltitude();
//! get current Horizon altitude: //! Get the user-defined altitude of the visual horizon.
int getHorizAltitude(void); int getHorizonAltitude();
bool isShownReport() const {return flagShowReport;}
public slots: public slots:
//! Set whether observability will execute or not: //! Restore and reload the default plug-in settings.
void enableObservability(bool b); void resetConfiguration();
//! Save the plug-in's configuration to the main configuration file.
void saveConfiguration();
//! @name Fields displayed in the observability report.
//! @{
//! Display today's events (rise, set and transit times).
void enableTodayField(bool enabled = true);
//! Display acronychal and cosmical rising/setting.
void enableAcroCosField(bool enabled = true);
//! Display nights when the object is above the horizon after darkne
ss.
void enableGoodNightsField(bool enabled = true);
//! Display when selected object is in opposition.
void enableOppositionField(bool enabled = true);
//! Display date of the full moon.
//! Has any effect only if the Moon is selected.
void enableFullMoonField(bool enabled = true);
//! @}
//! Set the color of the font used to display the report.
//! Applies only to what is drawn on the viewport.
//! @param color Color vector in Stellarium's RGB format.
void setFontColor(const Vec3f& color);
//! Set the size of the font used to display the report.
//! Applies only to what is drawn on the viewport.
void setFontSize(int size);
//! Set the angular altitude below the horizon of the Sun at twiligh
t.
//! This determines the boundaries of day/night for observation purp
oses.
//! @param altitude An angle in degrees; as this is altitude below
//! the horizon, it should be negative.
//! @note If you want the slider in the configuration dialog to be i
nverted,
//! you can use the @c invertedAppearance property of QSlider.
//! @todo Check if parameter is in the acceptable range?
void setTwilightAltitude(int altitude);
//! Set the angular altitude of the visual horizon.
//! @param altitude An angle in degrees.
//! @todo Check if parameter is in the acceptable range?
void setHorizonAltitude(int altitude);
//! Controls whether an observability report will be displayed.
void showReport(bool b);
private slots: private slots:
//! Retranslates the user-visible strings when the language is chang ed.
void updateMessageText(); void updateMessageText();
private: private:
//! Configuration window.
//! Stuff for the configuration GUI:
ObservabilityDialog* configDialog; ObservabilityDialog* configDialog;
QByteArray normalStyleSheet;
QByteArray nightStyleSheet;
void setDateFormat(bool b) { dmyFormat=b; } void setDateFormat(bool b) { dmyFormat=b; }
bool getDateFormat(void) { return dmyFormat; } bool getDateFormat(void) { return dmyFormat; }
//! Computes the Hour Angle (culmination=0h) in absolute value (from 0h to 12h). //! Computes the Hour Angle (culmination=0h) in absolute value (from 0h to 12h).
//! @todo The hour angle of what, exactly? --BM
//! @param latitude latitude of the observer (in radians). //! @param latitude latitude of the observer (in radians).
//! @param elevation elevation angle of the object (horizon=0) in radians. //! @param elevation elevation angle of the object (horizon=0) in radians.
//! @param declination declination of the object in radians. //! @param declination declination of the object in radians.
virtual double HourAngle(double latitude,double elevation,double dec double calculateHourAngle(double latitude,
lination); double elevation,
double declination);
//! Computes the Hour Angle for a given Right Ascension and Sidereal Time. //! Computes the Hour Angle for a given Right Ascension and Sidereal Time.
//! @param RA right ascension (hours). //! @param RA right ascension (hours).
//! @param ST sidereal time (degrees). //! @param ST sidereal time (degrees).
virtual double HourAngle2(double RA, double ST); double HourAngle2(double RA, double ST);
//! Solves Moon/Sun/Planet Rise/Set/Transit times for the current Julian da //! Solves Moon/Sun/Planet Rise/Set/Transit times for the current Julian da
y. This function updates the variables MoonRise, MoonSet, MoonCulm. Returns y.
success status. //! This function updates the variables MoonRise, MoonSet, MoonCulm.
//! @param Kind is 1 for Sun, 2 for Moon, 3 for Solar-System planet. //! Returns success status.
virtual bool SolarSystemSolve(StelCore* core, int Kind); //! @param[in] bodyType is 1 for Sun, 2 for Moon, 3 for Solar System object
.
bool calculateSolarSystemEvents(StelCore* core, int bodyType);
//! Finds the heliacal rise/set dates of the year for the currently-selecte d object. //! Finds the heliacal rise/set dates of the year for the currently-selecte d object.
//! @param Rise day of year of the Acronycal rise. //! @param[out] acroRise day of year of the Acronycal rise.
//! @param Set day of year of the Acronycal set. //! @param[out] acroSet day of year of the Acronycal set.
//! @param Rise2 day of year of the Cosmical rise. //! @param[out] cosRise day of year of the Cosmical rise.
//! @param Set2 day of year of the Cosmical set. //! @param[out] cosSet day of year of the Cosmical set.
virtual int CheckAcro(int &Rise, int &Set, int &Rise2, int &Set2); //! @returns 0 if no dates found, 1 if acronycal dates exist,
//! 2 if cosmical dates exist, and 3 if both are found.
int calculateAcroCos(int& acroRise, int& acroSet,
int& cosRise, int& cosSet);
//! computes the Sun or Moon coordinates at a given Julian date. //! Computes the Sun or Moon coordinates at a given Julian date.
//! @param core the stellarium core. //! @param core the stellarium core.
//! @param JD double for the Julian date. //! @param JD double for the Julian date.
//! @param RASun right ascension of the Sun (in hours). //! @param RASun right ascension of the Sun (in hours).
//! @param DecSun declination of the Sun (in radians). //! @param DecSun declination of the Sun (in radians).
//! @param RAMoon idem for the Moon. //! @param RAMoon idem for the Moon.
//! @param DecMoon idem for the Moon. //! @param DecMoon idem for the Moon.
//! @param EclLon is the module of the vector product of Heliocentric Eclip tic Coordinates of Sun and Moon (projected over the Ecliptic plane). Useful to derive the dates of Full Moon. //! @param EclLon is the module of the vector product of Heliocentric Eclip tic Coordinates of Sun and Moon (projected over the Ecliptic plane). Useful to derive the dates of Full Moon.
//! @param getBack controls whether Earth and Moon must be returned to thei r original positions after computation. //! @param getBack controls whether Earth and Moon must be returned to thei r original positions after computation.
virtual void getSunMoonCoords(StelCore* core, double JD, double &RAS void getSunMoonCoords(StelCore* core, double jd,
un, double &DecSun, double &RAMoon, double &DecMoon, double &EclLon, bool g double& raSun, double& decSun,
etBack); double& raMoon, double& decMoon,
double& eclLon, bool getBack);
//! computes the selected-planet coordinates at a given Julian date. //! computes the selected-planet coordinates at a given Julian date.
//! @param core the stellarium core. //! @param core the stellarium core.
//! @param JD double for the Julian date. //! @param JD double for the Julian date.
//! @param RA right ascension of the planet (in hours). //! @param RA right ascension of the planet (in hours).
//! @param Dec declination of the planet (in radians). //! @param Dec declination of the planet (in radians).
//! @param getBack controls whether the planet must be returned to its orig inal positions after computation. //! @param getBack controls whether the planet must be returned to its orig inal positions after computation.
virtual void getPlanetCoords(StelCore* core, double JD, double &RA, double &Dec, bool getBack); void getPlanetCoords(StelCore* core, double JD, double &RA, double & Dec, bool getBack);
//! Comptues the Earth-Moon distance (in AU) at a given Julian date. The pa //! Comptues the Earth-Moon distance (in AU) at a given Julian date.
rameters are similar to those of getSunMoonCoords or getPlanetCoords. //! The parameters are similar to those of getSunMoonCoords or getPlanetCoo
virtual void getMoonDistance(StelCore* core, double JD, double &Dist rds.
ance, bool getBack); void getMoonDistance(StelCore* core,
double jd,
double& distance,
bool getBack);
//! Returns the angular separation (in radians) between two points. //! Returns the angular separation (in radians) between two points.
//! @param RA1 right ascension of point 1 (in hours) //! @param RA1 right ascension of point 1 (in hours)
//! @param Dec1 declination of point 1 (in radians) //! @param Dec1 declination of point 1 (in radians)
//! @param RA2 idem for point 2 //! @param RA2 idem for point 2
//! @param Dec2 idem for point 2 //! @param Dec2 idem for point 2
virtual double Lambda(double RA1, double Dec1, double RA2, double De c2); double Lambda(double RA1, double Dec1, double RA2, double Dec2);
//! Converts a time span in hours (given as double) in hh:mm:ss (integers). //! Converts a time span in hours (given as double) in hh:mm:ss (integers).
//! @param t time span (double, in hours). //! @param t time span (double, in hours).
//! @param h hour (integer). //! @param h hour (integer).
//! @param m minute (integer). //! @param m minute (integer).
//! @param s second (integer). //! @param s second (integer).
virtual void double2hms(double t, int &h,int &m,int &s); void double2hms(double t, int &h,int &m,int &s);
//! Just returns the sign of a double; //! Just returns the sign of a double;
virtual double sign(double d); double sign(double d);
//! Returns a string of date (e.g. "25 Apr") from a Day of Year (integer). //! Get a date string ("25 Apr") from an ordinal date (Xth day of the year)
//! @param DoY Day of the year. .
virtual QString CalenDate(int DoY); //! @param dayNumber The ordinal number of a day of the year. (For example,
//! 25 April is the 115 or 116 day of the year.)
//! Returns a string of range dates (e.g. "25 Apr - 10 May") from a two Day //! @todo Determine the exact format - leap year handling, etc.
s of Year (integer). QString formatAsDate(int dayNumber);
//! @param fDoY first Day of the year.
//! @param sDoY second Day of the year. //! Get a date range string ("25 Apr - 10 May") from two ordinal dates.
virtual QString RangeCalenDates(int fDoY, int sDoY); //! @see formatAsDate()
//! @param startDay number of the first day in the period.
//! @param endDay number of the last day in the period.
QString formatAsDateRange(int startDay, int endDay);
//! Just subtracts/adds 24h to a RA (or HA), to make it fall within 0-24h. //! Just subtracts/adds 24h to a RA (or HA), to make it fall within 0-24h.
//! @param RA right ascension (in hours). //! @param RA right ascension (in hours).
virtual double toUnsignedRA(double RA); double toUnsignedRA(double RA);
//! Computes the RA, Dec and Rise/Set Sid. times of the selected planet for //! Prepare arrays with data for the selected object for each day of the ye
each day of the current year. ar.
//! Computes the RA, Dec and rise/set sidereal times of the selected planet
//! for each day of the current year.
//! @param core the current Stellarium core. //! @param core the current Stellarium core.
virtual void PlanetRADec(StelCore *core); void updatePlanetData(StelCore* core);
//! Computes the Sun's RA and Dec for each day of a given year. //! Computes the Sun's RA and Dec for each day of a given year.
//! @param core current Stellarium core. //! @param core current Stellarium core.
virtual void SunRADec(StelCore* core); void updateSunData(StelCore* core);
//! Computes the Sun's Sid. Times at astronomical twilight (for each year's day) //! Computes the Sun's Sid. Times at astronomical twilight (for each year's day)
virtual void SunHTwi(); void updateSunH();
//! Just convert the Vec3d named TempLoc into RA/Dec: //! Convert an equatorial position vector to RA/Dec.
virtual void toRADec(Vec3d TempLoc, double &RA, double &Dec); void toRADec(Vec3d vec3d, double& ra, double& dec);
//! Vector to store the Julian Dates for the current year: //! Table containing the Julian Dates of the days of the current yea r.
double yearJD[366]; double yearJD[366];
//! Check if a source is observable during a given date: //! Check if a source is observable during a given date.
//! @aparm i the day of the year. //! @param i the day of the year.
virtual bool CheckRise(int i); bool CheckRise(int day);
//! Some useful constants and variables(almost self-explanatory). //! Some useful constants and variables(almost self-explanatory).
double Rad2Deg, Rad2Hr, AstroTwiAlti, UA, TFrac, JDsec, Jan1stJD, ha double Rad2Deg, Rad2Hr, UA, TFrac, JDsec, Jan1stJD, halfpi, MoonT, n
lfpi, MoonT, nextFullMoon, prevFullMoon, RefFullMoon, GMTShift, MoonPerilun extFullMoon, prevFullMoon, RefFullMoon, GMTShift, MoonPerilune;
e,RefracHoriz,HorizAlti;
//! User-defined angular altitude of astronomical twilight in radian
s.
//! See setTwilightAltitude() and getTwilightAltitude().
double twilightAltRad;
//! User-defined angular altitude of astronomical twilight in degree
s.
//! See setTwilightAltitude() and getTwilightAltitude().
int twilightAltDeg;
//! Geometric altitude at refraction-corrected horizon.
double refractedHorizonAlt;
//! User-defined angular altitude of the visual horizon in radians.
double horizonAltitude;
//! User-defined angular altitude of the visual horizon in degrees.
int horizonAltDeg;
//! RA, Dec, observer latitude, object's elevation, and Hour Angle at horiz on. //! RA, Dec, observer latitude, object's elevation, and Hour Angle at horiz on.
double selRA, selDec, mylat, mylon, alti, horizH, culmAlt, myJD; double selRA, selDec, mylat, mylon, alti, horizH, culmAlt, myJD;
//! Vectors to store Sun's RA, Dec, and Sid. Time at twilight and rise/set. //! Vectors to store Sun's RA, Dec, and Sid. Time at twilight and rise/set.
double SunRA[366], SunDec[366], SunSidT[4][366]; double sunRA[366];
double sunDec[366];
//! Sidereal time of the Sun at twilight and rise/set through the ye
ar.
double sunSidT[4][366];
//! Vectors to store planet's RA, Dec, and Sid. Time at rise/set. //! Vectors to store planet's RA, Dec, and Sid. Time at rise/set.
double ObjectRA[366], ObjectDec[366], ObjectH0[366], ObjectSidT[2][3 double objectRA[366];
66]; double objectDec[366];
double objectH0[366];
//! Table of the sidereal time of the object's rising/setting.
double objectSidT[2][366];
//! Rise/Set/Transit times for the Moon at current day: //! Rise/Set/Transit times for the Moon at current day:
double MoonRise, MoonSet, MoonCulm, lastJDMoon; double MoonRise, MoonSet, MoonCulm, lastJDMoon;
//! Vector of Earth position through the year. //! Vector of Earth position through the year.
Vec3d EarthPos[366]; Vec3d EarthPos[366];
//! Position of the observer relative to the Earth Center or other coordina tes: //! Position of the observer relative to the Earth Center or other coordina tes:
Vec3d ObserverLoc, Pos0, Pos1, Pos2, RotObserver; //, Pos3; Vec3d ObserverLoc, Pos1, Pos2, RotObserver; //, Pos3;
//! Matrix to transform coordinates for Sun/Moon ephemeris: //! Matrix to transform coordinates for Sun/Moon ephemeris:
Mat4d LocTrans; Mat4d LocTrans;
//! Pointer to the Earth, Moon, and planet: //! Pointer to the Earth, Moon, and planet:
Planet* myEarth; Planet* myEarth;
Planet* myMoon; Planet* myMoon;
Planet* myPlanet; Planet* myPlanet;
//! Current simulation year and number of days in the year.; //! Current simulation year.
int currYear, nDays, iAltitude, iHorizAltitude; int curYear;
//! Days in the current year (366 on leap years).
//! Useful auxiliary strings, to help checking changes in source/observer. int nDays;
Also to store results that must survive between iterations.
QString selName, bestNight, ObsRange, objname, AcroCos; //! Untranslated name of the currently selected object.
//! Used to check if the selection has changed.
QString selName;
//! Cached copy of the "best night" line in the report.
QString lineBestNight;
//! Cached copy of the line reporting when the target is observable.
QString lineObservableRange;
//! Cached copy of the line reporting the acronical/cosmical rise an
d set.
QString lineAcroCos;
//! Strings to save ephemeris Times: //! Strings to save ephemeris Times:
QString RiseTime, SetTime, CulmTime; QString RiseTime, SetTime, CulmTime;
//! Just the names of the months. //! Just the names of the months.
QString months[12]; QStringList monthNames;
//! Using for storage date format [i18n] //! Using for storage date format [i18n]
bool dmyFormat; bool dmyFormat;
//! Equatorial and local coordinates of currently-selected source. //! Equatorial and local coordinates of currently-selected source.
Vec3d EquPos, LocPos; Vec3d EquPos, LocPos;
//! Some booleans to check the kind of source selected and the kind of outp ut to produce. //! Some booleans to check the kind of source selected and the kind of outp ut to produce.
bool isStar,isMoon,isSun,isScreen, raised, configChanged, souChanged bool isStar, isMoon, isSun, isScreen;
;
int LastObject; //! This really shouldn't be handled like this...
bool hasRisen;
bool configChanged;
bool souChanged;
//! The last object type for which calculateSolarSystemEvents() was
called.
int lastType;
//! Some booleans to select the kind of output. //! @name Flags controlling report contents.
//! @{
bool show_AcroCos, show_Good_Nights, show_Best_Night, show_Today, sh ow_FullMoon; //, show_Crescent, show_SuperMoon; bool show_AcroCos, show_Good_Nights, show_Best_Night, show_Today, sh ow_FullMoon; //, show_Crescent, show_SuperMoon;
//! @}
//! Parameters for the graphics (i.e., font, icons, etc.): //! @name GUI elements
//! @{
//! Parameters for the graphics.
QFont font; QFont font;
Vec3f fontColor; Vec3f fontColor;
bool flagShowObservability; bool flagShowReport;
int fontSize; int fontSize;
QPixmap* OnIcon; StelButton* button;
QPixmap* OffIcon; //! @}
QPixmap* GlowIcon;
StelButton* toolbarButton;
//! @name Cached translated GUI strings.
//! @todo Decide whether to keep translation caching.
//! @{
QString msgSetsAt, msgRoseAt, msgSetAt, msgRisesAt, msgCircumpolar, msgNoRise, msgCulminatesAt, msgCulminatedAt, msgH, msgM, msgS; QString msgSetsAt, msgRoseAt, msgSetAt, msgRisesAt, msgCircumpolar, msgNoRise, msgCulminatesAt, msgCulminatedAt, msgH, msgM, msgS;
QString msgSrcNotObs, msgNoACRise, msgGreatElong, msgLargSSep, msgAt Deg, msgNone, msgAcroRise, msgNoAcroRise, msgCosmRise, msgNoCosmRise; QString msgSrcNotObs, msgNoACRise, msgGreatElong, msgLargSSep, msgNo ne, msgAcroRise, msgNoAcroRise, msgCosmRise, msgNoCosmRise;
QString msgWholeYear, msgNotObs, msgAboveHoriz, msgToday, msgThisYea r, msgPrevFullMoon, msgNextFullMoon; QString msgWholeYear, msgNotObs, msgAboveHoriz, msgToday, msgThisYea r, msgPrevFullMoon, msgNextFullMoon;
//! @}
}; };
#include "fixx11h.h"
#include <QObject> #include <QObject>
#include "StelPluginInterface.hpp" #include "StelPluginInterface.hpp"
class ObservabilityStelPluginInterface : public QObject, public StelPluginI nterface class ObservabilityStelPluginInterface : public QObject, public StelPluginI nterface
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "stellarium.StelGuiPluginInterface/1.0")
Q_INTERFACES(StelPluginInterface) Q_INTERFACES(StelPluginInterface)
public: public:
virtual StelModule* getStelModule() const; virtual StelModule* getStelModule() const;
virtual StelPluginInfo getPluginInfo() const; virtual StelPluginInfo getPluginInfo() const;
}; };
#endif /*OBSERVABILITY_HPP_*/ #endif /*OBSERVABILITY_HPP_*/
 End of changes. 50 change blocks. 
116 lines changed or deleted 214 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/