diff --git a/Starsphere.cpp b/Starsphere.cpp index 138ad39c762ea7ea8e738f187eb45358faba8b09..123fd74e6352b1d0a7e403ca1ff7198e511b465a 100644 --- a/Starsphere.cpp +++ b/Starsphere.cpp @@ -593,7 +593,7 @@ void Starsphere::render(const double timeOfDay) if(isFeature(LOGO) || isFeature(SEARCHINFO)) { static const GLfloat xStartPosLeft = 0.008; - const GLfloat xStartPosRight = 1 * aspect - 0.205; + const GLfloat xStartPosRight = 1 * aspect - 0.145; static const GLfloat yStartPosTop = 0.975; static const GLfloat yStartPosBottom = 0.07; static const GLfloat fontScaleLarge = 0.0225; @@ -647,22 +647,22 @@ void Starsphere::render(const double timeOfDay) glColor4f(1.0, 1.0, 1.0, 0.5); glTranslatef(xStartPosLeft, yStartPosBottom - yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("User: Oliver"); + m_PolygonFont->Render(string("User: " + m_UserName).c_str()); glLoadIdentity(); glTranslatef(xStartPosLeft, yStartPosBottom - 2*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Team: Albert-Einstein-Institut"); + m_PolygonFont->Render(string("Team: " + m_TeamName).c_str()); glLoadIdentity(); glTranslatef(xStartPosLeft, yStartPosBottom - 3*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Project credits: 12.000"); + m_PolygonFont->Render(string("Project Credit: " + m_UserCredit).c_str()); glLoadIdentity(); glTranslatef(xStartPosLeft, yStartPosBottom - 4*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Project RAC: 145.00"); + m_PolygonFont->Render(string("Project RAC: " + m_UserRACredit).c_str()); glPopMatrix(); @@ -678,22 +678,22 @@ void Starsphere::render(const double timeOfDay) glColor4f(1.0, 1.0, 1.0, 0.5); glTranslatef(xStartPosRight, yStartPosBottom - yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Right ascension: 180.00 deg"); + m_PolygonFont->Render(string("Ascension: " + m_WUSkyPosRightAscension + " deg").c_str()); glLoadIdentity(); glTranslatef(xStartPosRight, yStartPosBottom - 2*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Declination: 45.00 deg"); + m_PolygonFont->Render(string("Declination: " + m_WUSkyPosDeclination + " deg").c_str()); glLoadIdentity(); glTranslatef(xStartPosRight, yStartPosBottom - 3*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Frequency: 850.05 Hz"); + m_PolygonFont->Render(string("Completed: " + m_WUPercentDone + " %").c_str()); glLoadIdentity(); glTranslatef(xStartPosRight, yStartPosBottom - 4*yOffsetMedium, 0); glScalef(fontScaleSmall, fontScaleSmall, 1.0); - m_PolygonFont->Render("Spindown rate: 3.25 * 10^-10 Hz/s"); + m_PolygonFont->Render(string("CPU Time: " + m_WUCPUTime).c_str()); glPopMatrix(); } @@ -811,3 +811,49 @@ bool Starsphere::isFeature(const int feature) { return ((featureFlags & feature) == feature ? true : false); } + +void Starsphere::refreshBOINCInformation() +{ + // call base class implementation + AbstractGraphicsEngine::refreshBOINCInformation(); + + // prepare conversion buffer + stringstream buffer; + buffer.precision(2); + buffer.setf(ios::fixed, ios::floatfield); + + // store content required for our HUD + m_UserName = boincAdapter.userName(); + m_TeamName = boincAdapter.teamName(); + + buffer << fixed << boincAdapter.userCredit(); + m_UserCredit = buffer.str(); + buffer.str(""); + + buffer << fixed << boincAdapter.userRACredit(); + m_UserRACredit = buffer.str(); + buffer.str(""); + + buffer << fixed << boincAdapter.wuSkyPosRightAscension() * 360/PI2; + m_WUSkyPosRightAscension = buffer.str(); + buffer.str(""); + + buffer << fixed << boincAdapter.wuSkyPosDeclination() * 360/PI2; + m_WUSkyPosDeclination = buffer.str(); + buffer.str(""); + + buffer << fixed << boincAdapter.wuFractionDone() * 100; + m_WUPercentDone = buffer.str(); + buffer.str(""); + + double cputime = boincAdapter.wuCPUTime(); + int day = cputime / 86400; + int hrs = (cputime - day*86400) / 3600; + int min = (cputime - (day*86400 + hrs*3600)) / 60; + int sec = cputime - (day*86400 + hrs*3600 + min*60); + // TODO: get rid of sprintf ;-) + char duration[] = "00:00:00:00"; + sprintf(duration, "%.2i:%.2i:%.2i:%.2i", day, hrs, min, sec); + buffer << string(duration); + m_WUCPUTime = buffer.str(); +} diff --git a/Starsphere.h b/Starsphere.h index 0a4bc98b295be193703986fcf4c4911ab4be7ab3..d138884e756d4ee072f5707835a06a8c37514da6 100644 --- a/Starsphere.h +++ b/Starsphere.h @@ -3,8 +3,9 @@ #include <cmath> #include <cstdio> -#include <cstring> +#include <string> #include <iostream> +#include <sstream> #include <SDL.h> #include <SDL_opengl.h> @@ -12,8 +13,6 @@ #include "AbstractGraphicsEngine.h" -#define EAH_SHMEM_APP_NAME "Einstein@Home" - /* SIN and COS take arguments in DEGREES */ #define PI 3.14159265 #define PI2 (2*PI) @@ -46,6 +45,9 @@ public: void mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed); void keyboardPressEvent(const int keyPressed); + // update HUD content + void refreshBOINCInformation(); + private: void make_stars(); void make_pulsars(); @@ -120,8 +122,19 @@ private: LOGO=512 }; + // resource handling const Resource *m_FontResource; FTFont *m_PolygonFont; + + // local HUD contents + string m_UserName; + string m_TeamName; + string m_UserCredit; + string m_UserRACredit; + string m_WUSkyPosRightAscension; + string m_WUSkyPosDeclination; + string m_WUPercentDone; + string m_WUCPUTime; }; /* Constellation & star coordinates are in starlist.C */