Skip to content
Snippets Groups Projects
Commit 05f25a43 authored by Oliver Bock's avatar Oliver Bock
Browse files

A few fixes

* Proper use of enum types
* Current values of ascension/declination properly initialized (have to get a value outside the valid range)
parent 341cbce9
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,17 @@ public: ...@@ -46,6 +46,17 @@ public:
*/ */
virtual void render(const double timeOfDay) = 0; 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 * \brief This method is called when the windowing system encounters a mouse button event
* *
...@@ -56,7 +67,7 @@ public: ...@@ -56,7 +67,7 @@ public:
* *
* \see MouseButton * \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 * \brief This method is called when the windowing system encounters a mouse move event
...@@ -68,39 +79,7 @@ public: ...@@ -68,39 +79,7 @@ public:
* *
* \see MouseButton * \see MouseButton
*/ */
virtual void mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed) = 0; virtual void mouseMoveEvent(const int deltaX, const int deltaY, const MouseButton 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
};
/** /**
* \brief Defined keyboard identifiers * \brief Defined keyboard identifiers
...@@ -138,6 +117,27 @@ public: ...@@ -138,6 +117,27 @@ public:
KeyEscape = 0x8000000 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: protected:
/// Default constructor (protected since this is an abstract class) /// Default constructor (protected since this is an abstract class)
AbstractGraphicsEngine(); AbstractGraphicsEngine();
......
...@@ -27,6 +27,8 @@ Starsphere::Starsphere() : AbstractGraphicsEngine() ...@@ -27,6 +27,8 @@ Starsphere::Starsphere() : AbstractGraphicsEngine()
rotation_offset = 0.0; rotation_offset = 0.0;
rotation_speed = 180.0; rotation_speed = 180.0;
m_CurrentRightAscension = -1.0;
m_CurrentDeclination = -1.0;
m_RefreshSearchMarker = true; m_RefreshSearchMarker = true;
m_XStartPosLeft = 0.008; m_XStartPosLeft = 0.008;
...@@ -758,12 +760,14 @@ void Starsphere::render(const double timeOfDay) ...@@ -758,12 +760,14 @@ void Starsphere::render(const double timeOfDay)
SDL_GL_SwapBuffers(); 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) { switch(buttonPressed) {
case MouseButtonLeft: case MouseButtonLeft:
...@@ -777,7 +781,7 @@ void Starsphere::mouseMoveEvent(const int deltaX, const int deltaY, const int bu ...@@ -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) { switch(keyPressed) {
case KeyS: case KeyS:
...@@ -848,12 +852,12 @@ void Starsphere::zoomSphere(const int relativeZoom) ...@@ -848,12 +852,12 @@ void Starsphere::zoomSphere(const int relativeZoom)
/** /**
* Feature control * 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); featureFlags = enable ? (featureFlags | feature) : (featureFlags & ~feature);
} }
bool Starsphere::isFeature(const int feature) bool Starsphere::isFeature(const Features feature)
{ {
return ((featureFlags & feature) == feature ? true : false); return ((featureFlags & feature) == feature ? true : false);
} }
......
...@@ -46,9 +46,11 @@ public: ...@@ -46,9 +46,11 @@ public:
void render(const double timeOfDay); void render(const double timeOfDay);
// event handling // event handling
void mouseButtonEvent(const int positionX, const int positionY, const int buttonPressed); void mouseButtonEvent(const int positionX, const int positionY,
void mouseMoveEvent(const int deltaX, const int deltaY, const int buttonPressed); const AbstractGraphicsEngine::MouseButton buttonPressed);
void keyboardPressEvent(const int keyPressed); void mouseMoveEvent(const int deltaX, const int deltaY,
const AbstractGraphicsEngine::MouseButton buttonPressed);
void keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey keyPressed);
// update HUD content // update HUD content
virtual void refreshBOINCInformation(); virtual void refreshBOINCInformation();
...@@ -139,9 +141,6 @@ private: ...@@ -139,9 +141,6 @@ private:
void zoomSphere(const int relativeZoom); void zoomSphere(const int relativeZoom);
// feature control // feature control
void setFeature(const int features, const bool enable);
bool isFeature(const int features);
enum Features { enum Features {
STARS = 1, STARS = 1,
CONSTELLATIONS = 2, CONSTELLATIONS = 2,
...@@ -156,6 +155,9 @@ private: ...@@ -156,6 +155,9 @@ private:
MARKER = 1024 MARKER = 1024
}; };
void setFeature(const Features features, const bool enable);
bool isFeature(const Features features);
// observatory movement // observatory movement
// (in seconds since 1970 with usec precision) // (in seconds since 1970 with usec precision)
double m_ObservatoryDrawTimeLocal; double m_ObservatoryDrawTimeLocal;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment