diff --git a/AbstractGraphicsEngine.h b/AbstractGraphicsEngine.h index b7105f7f2ce25856b9aa56108430960d426b5c43..7bf88f708e9b2afe64d5193b679907657c15b72c 100644 --- a/AbstractGraphicsEngine.h +++ b/AbstractGraphicsEngine.h @@ -46,6 +46,17 @@ public: */ virtual void render(const double timeOfDay) = 0; + /** + * \brief Defined mouse button identifiers + * + * \see mouseButtonEvent + * \see mouseMoveEvent + */ + enum MouseButton { + MouseButtonLeft = 1, + MouseButtonRight = 2 + }; + /** * \brief This method is called when the windowing system encounters a mouse button event * @@ -56,7 +67,7 @@ public: * * \see MouseButton */ - virtual void mouseButtonEvent(const int positionX, const int positionY, const int buttonPressed) = 0; + virtual void mouseButtonEvent(const int positionX, const int positionY, const MouseButton buttonPressed) = 0; /** * \brief This method is called when the windowing system encounters a mouse move event @@ -68,39 +79,7 @@ public: * * \see MouseButton */ - virtual void mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed) = 0; - - /** - * \brief This method is called when the windowing system encounters a key press event - * - * \attention Please note that not all key events are currently forwarded (this should be change - * as soon as the need arises). Please see WindowManager::eventLoop for details. - * - * \param keyPressed The keyboard key pressed. It can be identified using the elements of \ref KeyBoardKey. - * - * \see KeyBoardKey - * \see WindowManager::eventLoop - */ - virtual void keyboardPressEvent(const int keyPressed) = 0; - - /** - * \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. - */ - virtual void refreshBOINCInformation(); - - /** - * \brief Defined mouse button identifiers - * - * \see mouseButtonEvent - * \see mouseMoveEvent - */ - enum MouseButton { - MouseButtonLeft = 1, - MouseButtonRight = 2 - }; + virtual void mouseMoveEvent(const int deltaX, const int deltaY, const MouseButton buttonPressed) = 0; /** * \brief Defined keyboard identifiers @@ -137,6 +116,27 @@ public: KeyEnter = 0x4000000, KeyEscape = 0x8000000 }; + + /** + * \brief This method is called when the windowing system encounters a key press event + * + * \attention Please note that not all key events are currently forwarded (this should be change + * as soon as the need arises). Please see WindowManager::eventLoop for details. + * + * \param keyPressed The keyboard key pressed. It can be identified using the elements of \ref KeyBoardKey. + * + * \see KeyBoardKey + * \see WindowManager::eventLoop + */ + virtual void keyboardPressEvent(const KeyBoardKey keyPressed) = 0; + + /** + * \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. + */ + virtual void refreshBOINCInformation(); protected: /// Default constructor (protected since this is an abstract class) diff --git a/Starsphere.cpp b/Starsphere.cpp index 7d506b5a4d25531cbea6fae674ef288c9934ade9..4f494ef760d501176f9e05c0c32f59b5e38aac10 100644 --- a/Starsphere.cpp +++ b/Starsphere.cpp @@ -27,6 +27,8 @@ Starsphere::Starsphere() : AbstractGraphicsEngine() rotation_offset = 0.0; rotation_speed = 180.0; + m_CurrentRightAscension = -1.0; + m_CurrentDeclination = -1.0; m_RefreshSearchMarker = true; m_XStartPosLeft = 0.008; @@ -758,12 +760,14 @@ void Starsphere::render(const double timeOfDay) SDL_GL_SwapBuffers(); } -void Starsphere::mouseButtonEvent(const int positionX, const int positionY, const int buttonPressed) +void Starsphere::mouseButtonEvent(const int positionX, const int positionY, + const AbstractGraphicsEngine::MouseButton buttonPressed) { } -void Starsphere::mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed) +void Starsphere::mouseMoveEvent(const int deltaX, const int deltaY, + const AbstractGraphicsEngine::MouseButton buttonPressed) { switch(buttonPressed) { case MouseButtonLeft: @@ -777,7 +781,7 @@ void Starsphere::mouseMoveEvent(const int deltaX, const int deltaY, const int bu } } -void Starsphere::keyboardPressEvent(const int keyPressed) +void Starsphere::keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey keyPressed) { switch(keyPressed) { case KeyS: @@ -848,12 +852,12 @@ void Starsphere::zoomSphere(const int relativeZoom) /** * Feature control */ -void Starsphere::setFeature(const int feature, const bool enable) +void Starsphere::setFeature(const Features feature, const bool enable) { featureFlags = enable ? (featureFlags | feature) : (featureFlags & ~feature); } -bool Starsphere::isFeature(const int feature) +bool Starsphere::isFeature(const Features feature) { return ((featureFlags & feature) == feature ? true : false); } diff --git a/Starsphere.h b/Starsphere.h index bfef8d882412a989595bc03552dca78656ea4f1c..1ec5c45e4e64289511026a25e9ea83ed1b09139b 100644 --- a/Starsphere.h +++ b/Starsphere.h @@ -46,9 +46,11 @@ public: void render(const double timeOfDay); // event handling - void mouseButtonEvent(const int positionX, const int positionY, const int buttonPressed); - void mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed); - void keyboardPressEvent(const int keyPressed); + 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); // update HUD content virtual void refreshBOINCInformation(); @@ -139,9 +141,6 @@ private: void zoomSphere(const int relativeZoom); // feature control - void setFeature(const int features, const bool enable); - bool isFeature(const int features); - enum Features { STARS = 1, CONSTELLATIONS = 2, @@ -154,7 +153,10 @@ private: 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)