little refactoring
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
#include <opencv2/viz/types.hpp>
|
||||
|
||||
namespace cv
|
||||
namespace temp_viz
|
||||
{
|
||||
class KeyboardEvent
|
||||
{
|
||||
@@ -13,13 +13,13 @@ namespace cv
|
||||
static const unsigned int Shift = 4;
|
||||
|
||||
/** \brief Constructor
|
||||
* \param[in] action true for key was pressed, false for released
|
||||
* \param[in] key_sym the key-name that caused the action
|
||||
* \param[in] key the key code that caused the action
|
||||
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
|
||||
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
|
||||
* \param[in] shift whether the shift was pressed at the time where this event was triggered
|
||||
*/
|
||||
* \param[in] action true for key was pressed, false for released
|
||||
* \param[in] key_sym the key-name that caused the action
|
||||
* \param[in] key the key code that caused the action
|
||||
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
|
||||
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
|
||||
* \param[in] shift whether the shift was pressed at the time where this event was triggered
|
||||
*/
|
||||
KeyboardEvent (bool action, const std::string& key_sym, unsigned char key, bool alt, bool ctrl, bool shift);
|
||||
|
||||
bool isAltPressed () const;
|
||||
@@ -28,7 +28,7 @@ namespace cv
|
||||
|
||||
unsigned char getKeyCode () const;
|
||||
|
||||
const std::string& getKeySym () const;
|
||||
const String& getKeySym () const;
|
||||
bool keyDown () const;
|
||||
bool keyUp () const;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace cv
|
||||
bool action_;
|
||||
unsigned int modifiers_;
|
||||
unsigned char key_code_;
|
||||
std::string key_sym_;
|
||||
String key_sym_;
|
||||
};
|
||||
|
||||
class MouseEvent
|
||||
@@ -75,7 +75,7 @@ namespace cv
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// Implementation
|
||||
|
||||
inline cv::KeyboardEvent::KeyboardEvent (bool _action, const std::string& _key_sym, unsigned char key, bool alt, bool ctrl, bool shift)
|
||||
inline temp_viz::KeyboardEvent::KeyboardEvent (bool _action, const std::string& _key_sym, unsigned char key, bool alt, bool ctrl, bool shift)
|
||||
: action_ (_action), modifiers_ (0), key_code_(key), key_sym_ (_key_sym)
|
||||
{
|
||||
if (alt)
|
||||
@@ -88,15 +88,15 @@ inline cv::KeyboardEvent::KeyboardEvent (bool _action, const std::string& _key_s
|
||||
modifiers_ |= Shift;
|
||||
}
|
||||
|
||||
inline bool cv::KeyboardEvent::isAltPressed () const { return (modifiers_ & Alt) != 0; }
|
||||
inline bool cv::KeyboardEvent::isCtrlPressed () const { return (modifiers_ & Ctrl) != 0; }
|
||||
inline bool cv::KeyboardEvent::isShiftPressed () const { return (modifiers_ & Shift) != 0; }
|
||||
inline unsigned char cv::KeyboardEvent::getKeyCode () const { return key_code_; }
|
||||
inline const std::string& cv::KeyboardEvent::getKeySym () const { return (key_sym_); }
|
||||
inline bool cv::KeyboardEvent::keyDown () const { return action_; }
|
||||
inline bool cv::KeyboardEvent::keyUp () const { return !action_; }
|
||||
inline bool temp_viz::KeyboardEvent::isAltPressed () const { return (modifiers_ & Alt) != 0; }
|
||||
inline bool temp_viz::KeyboardEvent::isCtrlPressed () const { return (modifiers_ & Ctrl) != 0; }
|
||||
inline bool temp_viz::KeyboardEvent::isShiftPressed () const { return (modifiers_ & Shift) != 0; }
|
||||
inline unsigned char temp_viz::KeyboardEvent::getKeyCode () const { return key_code_; }
|
||||
inline const temp_viz::String& temp_viz::KeyboardEvent::getKeySym () const { return key_sym_; }
|
||||
inline bool temp_viz::KeyboardEvent::keyDown () const { return action_; }
|
||||
inline bool temp_viz::KeyboardEvent::keyUp () const { return !action_; }
|
||||
|
||||
inline cv::MouseEvent::MouseEvent (const Type& _type, const MouseButton& _button, const Point& _p, bool alt, bool ctrl, bool shift)
|
||||
inline temp_viz::MouseEvent::MouseEvent (const Type& _type, const MouseButton& _button, const Point& _p, bool alt, bool ctrl, bool shift)
|
||||
: type(_type), button(_button), pointer(_p), key_state(0)
|
||||
{
|
||||
if (alt)
|
||||
|
@@ -53,8 +53,8 @@ namespace temp_viz
|
||||
void spin ();
|
||||
void spinOnce (int time = 1, bool force_redraw = false);
|
||||
|
||||
void registerKeyboardCallback(void (*callback)(const cv::KeyboardEvent&, void*), void* cookie = 0);
|
||||
void registerMouseCallback(void (*callback)(const cv::MouseEvent&, void*), void* cookie = 0);
|
||||
void registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void* cookie = 0);
|
||||
void registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie = 0);
|
||||
|
||||
bool wasStopped() const;
|
||||
private:
|
||||
|
Reference in New Issue
Block a user