diff --git a/src/starsphere/StarsphereRadio.cpp b/src/starsphere/StarsphereRadio.cpp index 2df045968923f7fcf0d52180e7df886294527a5b..e7894c8271743bf222bfee58f51eaee4afc5b5e6 100644 --- a/src/starsphere/StarsphereRadio.cpp +++ b/src/starsphere/StarsphereRadio.cpp @@ -158,10 +158,10 @@ void StarsphereRadio::refreshBOINCInformation() buffer.str(""); // show WU's total CPU time (previously accumulated + current session) - const double cputime = m_BoincAdapter.wuCPUTimeSpent() + m_EinsteinAdapter.wuCPUTime(); - const int hrs = cputime / 3600; - const int min = (cputime - hrs*3600) / 60; - const int sec = cputime - (hrs*3600 + min*60); + const double time = m_BoincAdapter.wuCPUTimeSpent() + m_EinsteinAdapter.wuCPUTime(); + const int hrs = time / 3600; + const int min = fmod(time, 3600) / 60; + const int sec = fmod(time, 60); buffer << "WU CPU Time: " << right << setw(2) << hrs << ":" << right << setw(2) << min << ":" diff --git a/src/starsphere/StarsphereS5R3.cpp b/src/starsphere/StarsphereS5R3.cpp index b9b4b6d41bd80549413bf661f8c9f6a9f5239ee7..f175249f822d074a7f17271ced1c7dab448035b8 100644 --- a/src/starsphere/StarsphereS5R3.cpp +++ b/src/starsphere/StarsphereS5R3.cpp @@ -24,6 +24,7 @@ StarsphereS5R3::StarsphereS5R3() : Starsphere(EinsteinS5R3Adapter::SharedMemoryIdentifier), m_EinsteinAdapter(&m_BoincAdapter) { + m_CurrentTime = ""; } StarsphereS5R3::~StarsphereS5R3() @@ -40,6 +41,7 @@ void StarsphereS5R3::initialize(const int width, const int height, const Resourc // adjust HUD config m_YOffsetMedium = 15; m_XStartPosRight = width - 125; + m_XStartPosClock = width - 115; m_YStartPosBottom = 70; m_Y1StartPosBottom = m_YStartPosBottom - m_YOffsetMedium; m_Y2StartPosBottom = m_Y1StartPosBottom - m_YOffsetMedium; @@ -54,6 +56,7 @@ void StarsphereS5R3::resize(const int width, const int height) // adjust HUD config m_XStartPosRight = width - 125; + m_XStartPosClock = width - 115; } void StarsphereS5R3::refreshBOINCInformation() @@ -76,39 +79,56 @@ void StarsphereS5R3::refreshBOINCInformation() // we've got a new position, update search marker and HUD m_CurrentRightAscension = m_EinsteinAdapter.wuSkyPosRightAscension(); m_RefreshSearchMarker = true; + buffer.str(""); buffer << "Ascension: " << fixed << m_CurrentRightAscension << " deg" << ends; m_WUSkyPosRightAscension = buffer.str(); - buffer.str(""); } if(m_CurrentDeclination != m_EinsteinAdapter.wuSkyPosDeclination()) { // we've got a new position, update search marker and HUD m_CurrentDeclination = m_EinsteinAdapter.wuSkyPosDeclination(); m_RefreshSearchMarker = true; + buffer.str(""); buffer << "Declination: " << fixed << m_CurrentDeclination << " deg" << ends; m_WUSkyPosDeclination = buffer.str(); - buffer.str(""); } + buffer.str(""); buffer << "Completed: " << fixed << m_EinsteinAdapter.wuFractionDone() * 100 << " %" << ends; m_WUPercentDone = buffer.str(); - buffer.str(""); // show WU's total CPU time (previously accumulated + current session) - const double cputime = m_BoincAdapter.wuCPUTimeSpent() + m_EinsteinAdapter.wuCPUTime(); - const int hrs = cputime / 3600; - const int min = (cputime - hrs*3600) / 60; - const int sec = cputime - (hrs*3600 + min*60); + double time = m_BoincAdapter.wuCPUTimeSpent() + m_EinsteinAdapter.wuCPUTime(); + int hrs = time / 3600; + int min = fmod(time, 3600) / 60; + int sec = fmod(time, 60); + buffer.str(""); buffer << "CPU Time: " << right << setw(2) << hrs << ":" << right << setw(2) << min << ":" << right << setw(2) << sec << ends; m_WUCPUTime = buffer.str(); + + // update current time string (clock) + time = dtime() - dday(); + hrs = time / 3600; + min = fmod(time, 3600) / 60; + sec = fmod(time, 60); + + buffer.str(""); + buffer << right << setw(2) << hrs << ":" + << right << setw(2) << min << ":" + << right << setw(2) << sec << ends; + + m_CurrentTime = buffer.str(); } void StarsphereS5R3::renderSearchInformation() { + // clock + m_FontLogo1->draw(m_XStartPosClock, m_YStartPosTop, m_CurrentTime.c_str()); + // left info block m_FontHeader->draw(m_XStartPosLeft, m_YStartPosBottom, "BOINC Statistics"); m_FontText->draw(m_XStartPosLeft, m_Y1StartPosBottom, m_UserName.c_str()); diff --git a/src/starsphere/StarsphereS5R3.h b/src/starsphere/StarsphereS5R3.h index f37b8732e917dea9a6bcb898ee8ffca850af37f7..b02eb52845315fb856e8bb0eeac238d93dcfc067 100644 --- a/src/starsphere/StarsphereS5R3.h +++ b/src/starsphere/StarsphereS5R3.h @@ -35,14 +35,14 @@ using namespace std; /** * \brief Specialized rendering engine for the S5R3 science run - * + * * This class comprises the specialized parts of the Starsphere rendering engine. * The main differences stem from the fact that most science runs differ in their * search configuration and parameters. Thus the parameters exposed by the HUD * (head-up display) are positioned and rendered here. For the time being the * "BOINC Statistics" are top-aligned to the "Search Parameters", hence they're * also positioned and rendered here. - * + * * \author Oliver Bock\n * Max-Planck-Institute for Gravitational Physics\n * Hannover, Germany @@ -52,88 +52,94 @@ class StarsphereS5R3 : public Starsphere public: /// Default contructor StarsphereS5R3(); - + /// Destructor virtual ~StarsphereS5R3(); - + /** * \brief This method is called to initialize the engine - * + * * As this method overrides its parent's implementation, it calls Starsphere::initialize() * first in order to "add" the sepcialized parts afterwards. - * + * * \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 + * \param font A pointer to a Resource object containing TTF font faces for text rendering * \param recycle This flag indicates whether we initialize (FALSE) or reinitialize (TRUE) the context */ virtual void initialize(const int width, const int height, const Resource *font, const bool recycle = false); - + /** * \brief This method is called when the windowing system encounters a window resize event - * + * * As this method overrides its parent's implementation, it calls Starsphere::resize() * first in order to "add" the sepcialized parts afterwards. - * + * * \param width The new width of the display surface * \param height The new height of the display surface */ void resize(const int width, const int height); - + /** * \brief This method is called when the BOINC client information should be updated - * + * * This method implements AbstractGraphicsEngine::refreshBOINCInformation() and calls * Starsphere::refreshLocalBOINCInformation() first and "adds" the sepcialized * parts afterwards. - * + * * \see AbstractGraphicsEngine::refreshBOINCInformation() * \see Starsphere::refreshLocalBOINCInformation() */ void refreshBOINCInformation(); - + private: /** * \brief Render science run specific search information - * + * * For this specific implementation this also includes the "BOINC Statistics" * as it is top-aligned to the "Search Information". */ void renderSearchInformation(); - + /// Specialized BOINC client adapter instance for information retrieval EinsteinS5R3Adapter m_EinsteinAdapter; - + /// Local copy of the current WU's search parameter "Right-Ascension" (degrees) string m_WUSkyPosRightAscension; - + /// Local copy of the current WU's search parameter "Declination" (degrees) string m_WUSkyPosDeclination; - + /// Local copy of the current WU's search parameter "Percent done" string m_WUPercentDone; - + /// Local copy of the current WU's search parameter "CPU Time" string m_WUCPUTime; - + + /// String representation of the current time + string m_CurrentTime; + /// HUD configuration setting (line offset for medium sized font) GLfloat m_YOffsetMedium; - + /// HUD configuration setting (horizontal start position for the right part) GLfloat m_XStartPosRight; - + + /// HUD configuration setting (horizontal start position for the clock display) + GLfloat m_XStartPosClock; + /// HUD configuration setting (vertical start postion for the bottom part, header) GLfloat m_YStartPosBottom; - + /// HUD configuration setting (vertical start postion for the bottom part, line 1) GLfloat m_Y1StartPosBottom; - + /// HUD configuration setting (vertical start postion for the bottom part, line 2) GLfloat m_Y2StartPosBottom; - + /// HUD configuration setting (vertical start postion for the bottom part, line 3) GLfloat m_Y3StartPosBottom; - + /// HUD configuration setting (vertical start postion for the bottom part, line 4) GLfloat m_Y4StartPosBottom; };