From f327579e6731af4aff293312de2fcf21093ed9fc Mon Sep 17 00:00:00 2001 From: Oliver Bock <oliver.bock@aei.mpg.de> Date: Tue, 6 May 2008 11:14:33 +0200 Subject: [PATCH] Fixed BOINC information update * The interface declared in AbstractGraphicsEngine is now implemented in the most specialized class only (to make sure it's called, down the inheritance hierarchy) * The abstract or generelized classes (up the hierarchy) got local implementation (protected) which are called by their respective children. * Fixed a bug in the old starsphere code. Search marker rendering deleted to much (memory corruption)! Does OpenGL do any boundary checking? --- AbstractGraphicsEngine.cpp | 2 +- AbstractGraphicsEngine.h | 18 +++++++++++++++--- BOINCClientAdapter.cpp | 3 +++ Starsphere.cpp | 10 +++++----- Starsphere.h | 17 +++++++++++------ StarsphereS5R3.cpp | 6 +++++- StarsphereS5R3.h | 8 ++++++-- 7 files changed, 46 insertions(+), 18 deletions(-) diff --git a/AbstractGraphicsEngine.cpp b/AbstractGraphicsEngine.cpp index 6276baf..73eefad 100644 --- a/AbstractGraphicsEngine.cpp +++ b/AbstractGraphicsEngine.cpp @@ -8,7 +8,7 @@ AbstractGraphicsEngine::~AbstractGraphicsEngine() { } -void AbstractGraphicsEngine::refreshBOINCInformation() +void AbstractGraphicsEngine::refreshLocalBOINCInformation() { m_BoincAdapter.refresh(); } diff --git a/AbstractGraphicsEngine.h b/AbstractGraphicsEngine.h index 33c4c70..2f033e1 100644 --- a/AbstractGraphicsEngine.h +++ b/AbstractGraphicsEngine.h @@ -133,10 +133,13 @@ public: /** * \brief This method is called when the BOINC client information should be updated * - * When you inherit from this class and override this method, please make sure you call this (base) - * method anyway as it already has a default implementation which refreshes \ref m_BoincAdapter. + * When you inherit from this class and implement this method, please make sure you call + * \ref refreshLocalBOINCInformation() to invoke the generic default implementation which + * refreshes \ref m_BoincAdapter. + * + * \see refreshLocalBOINCInformation() */ - virtual void refreshBOINCInformation(); + virtual void refreshBOINCInformation() = 0; protected: /** @@ -145,6 +148,15 @@ protected: * The constructor is protected since this is an abstract class. */ AbstractGraphicsEngine(); + + /** + * \brief This method has to be called in order to update the BOINC client information + * + * This is the local/generic implementation which refreshes \ref m_BoincAdapter. + * + * \see refreshBOINCInformation() + */ + virtual void refreshLocalBOINCInformation(); /// BOINC client adapter instance for information retrieval BOINCClientAdapter m_BoincAdapter; diff --git a/BOINCClientAdapter.cpp b/BOINCClientAdapter.cpp index 4f301b8..6245478 100644 --- a/BOINCClientAdapter.cpp +++ b/BOINCClientAdapter.cpp @@ -23,7 +23,10 @@ void BOINCClientAdapter::initialize(string sharedMemoryIdentifier) void BOINCClientAdapter::refresh() { if(m_Initialized) { + readUserInfo(); readSharedMemoryArea(); + + /// \todo Check that we're still watching our own WU (or science app)! } else { cerr << "The BOINC Client Adapter has not yet been initialized!"; diff --git a/Starsphere.cpp b/Starsphere.cpp index a59afb1..650dbf3 100644 --- a/Starsphere.cpp +++ b/Starsphere.cpp @@ -379,9 +379,9 @@ void Starsphere::make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size) // r1 is inner circle, r2 is outer circle, r3 is crosshairs r1 = size, r2=3*size, r3=4*size; - // delete any existing marker, then create a new one + // delete existing marker, then create a new one if (SearchMarker) { - glDeleteLists(SearchMarker, SearchMarker); + glDeleteLists(SearchMarker, 1); } SearchMarker = glGenLists(1); @@ -432,8 +432,8 @@ void Starsphere::make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size) // West arm: sphVertex(+r1, 0.0); sphVertex(+r3, 0.0); - glEnd(); + glPopMatrix(); // searchlight line out to marker (OFF!) @@ -896,10 +896,10 @@ bool Starsphere::isFeature(const Features feature) return ((featureFlags & feature) == feature ? true : false); } -void Starsphere::refreshBOINCInformation() +void Starsphere::refreshLocalBOINCInformation() { // call base class implementation - AbstractGraphicsEngine::refreshBOINCInformation(); + AbstractGraphicsEngine::refreshLocalBOINCInformation(); // prepare conversion buffer stringstream buffer; diff --git a/Starsphere.h b/Starsphere.h index 312bb7e..5eaa0c5 100644 --- a/Starsphere.h +++ b/Starsphere.h @@ -90,11 +90,6 @@ public: 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 @@ -114,7 +109,17 @@ protected: */ virtual void renderSearchInformation() = 0; - + /** + * \brief This method has to be called in order to update the BOINC client information + * + * This is the local/generic implementation which calls + * AbstractGraphicsEngine::refreshLocalBOINCInformation() first and + * refreshes the "BOINC Statistics" afterwards. + * + * \see AbstractGraphicsEngine::refreshLocalBOINCInformation() + */ + virtual void refreshLocalBOINCInformation(); + // resource handling OGLFT::TranslucentTexture* m_FontLogo1; OGLFT::TranslucentTexture* m_FontLogo2; diff --git a/StarsphereS5R3.cpp b/StarsphereS5R3.cpp index c93bed2..3d21a5d 100644 --- a/StarsphereS5R3.cpp +++ b/StarsphereS5R3.cpp @@ -32,7 +32,11 @@ void StarsphereS5R3::resize(const int width, const int height) void StarsphereS5R3::refreshBOINCInformation() { - Starsphere::refreshBOINCInformation(); + // call base class implementation + Starsphere::refreshLocalBOINCInformation(); + + // update local/specific content + m_EinsteinAdapter.refresh(); // prepare conversion buffer stringstream buffer; diff --git a/StarsphereS5R3.h b/StarsphereS5R3.h index d2880ca..0bd5a24 100644 --- a/StarsphereS5R3.h +++ b/StarsphereS5R3.h @@ -57,8 +57,12 @@ public: /** * \brief This method is called when the BOINC client information should be updated * - * As this method overrides its parent's implementation, it calls Starsphere::refreshBOINCInformation() - * first in order to "add" the sepcialized parts afterwards. + * This method implements AbstractGraphicsEngine::refreshBOINCInformation() and calls + * Starsphere::refreshLocalBOINCInformation() first and "adds" the sepcialized + * parts afterwards. + * + * \see AbstractGraphicsEngine::refreshBOINCInformation() + * \see Starsphere::refreshLocalBOINCInformation() */ void refreshBOINCInformation(); -- GitLab