ot::OTQt Class Reference
[OTQt Classes]
OTQt main class
More...
#include <OTQt.h>
Inheritance diagram for ot::OTQt:


Public Member Functions | |
| virtual | ~OTQt () |
| void | init (std::string &cfg_filename) |
| bool | isInitialized () const |
| void | startTimer (unsigned int timeout=DEFAULT_TIMER_TIMEOUT_MSEC) |
| bool | isTimerActive () const |
| void | stopTimer () |
| bool | enableMouseEvents (bool enable) |
Static Public Member Functions | |
| static OTQt & | getInstance () |
| static bool | triggerMEM (std::string cfg_filename) |
Static Public Attributes | |
| static int const | DEFAULT_TIMER_TIMEOUT_MSEC = 20 |
Protected Slots | |
| void | driveOT () |
Protected Member Functions | |
| OTQt () | |
| QtMouseEventModule & | getMEM () |
| QtMouseEventCalibModule & | getMECM () |
Private Member Functions | |
| OTQt (OTQt const &ref) | |
| OTQt | operator= (OTQt const &ref) |
Private Attributes | |
| bool | is_initialized_ |
| Context | context_ |
| QtMouseEventModule * | me_mod_ |
| QtMouseEventCalibModule * | mec_mod_ |
| std::string | cfg_filename_ |
| QMutex * | mutex_ |
| QTimer * | timer_ |
| unsigned int | cycle_counter_ |
Static Private Attributes | |
| static OTQt * | the_instance_ = NULL |
Detailed Description
OTQt main classProvides the public interface towards target Qt applications and offers some protected members to deriving classes. Internally the class is responsible for initializing the OpenTracker context and adding the MEM and MECM to a context factory.
It provides the necessary interface to exectute both OTQt modes. Calibration and operation mode differ in the way how the OpenTracker data flow is driven. Basically OTQt drives the OpenTracker data flow in cycles. Performing an OpenTracker cycle means one execution of the data flow graph: source nodes import adjacent tracking events from "outside", filter nodes queue events or perform their operations and forward the modified events according to the OpenTracker push pattern until the events arrive at the OTQt sinks nodes. The method driveOT() abstracts the procedure of such an OpenTracker cycle. The two modes use this method differently. In operation mode, driveOT() method is called periodically by a timer thread, a tradeoff between in-time delivery (accuracy) of mouse events and processing overhead of OTQt. For the calibration procedure, executed in a dedicated command line tool as separate process, the processing overhead restrictions do not apply. Therefore the driveOT() method is called from within the calibration procedure code directly often nested in busy-waiting while-loops.
The OTQt class provides a singleton pattern to the target Qt application. With the getInstance() method the singleton instance can be retrieved from any point in Qt code allowing the access of the OTQt class public interface. The triggerMEM() method abstracts the initialization and startup of OTQt reducing the effort of implementation within a Qt application to one line of code.
Definition at line 107 of file OTQt.h.
Constructor & Destructor Documentation
| ot::OTQt::~OTQt | ( | ) | [virtual] |
| ot::OTQt::OTQt | ( | ) | [protected] |
Initializes member variables.
Does NOT initialize the OpenTracker context, thus returns an object in not intialized state.
Definition at line 57 of file OTQt.cxx.
Referenced by getInstance().
| ot::OTQt::OTQt | ( | OTQt const & | ref | ) | [private] |
Member Function Documentation
| void ot::OTQt::driveOT | ( | ) | [protected, slot] |
Performs one OpenTracker cycle.
Performing an OpenTracker cycle means one execution of the data flow graph: source nodes import adjacent tracking events from "outside", filter nodes queue events or perform their operations and forward the modified events according to the OpenTracker push pattern until the events arrive at the OTQt sinks nodes.
The method body is treated as critical section secured with a mutex lock. A thread calling the method trying to acquire the locked mutex returns immediately, thus the method is non-blocking. Otherwise the mutex is acquired at the beginning and released at the end of the critical section implementing the OpenTracker cycle.
Disables the pending event flags set in the previous OT cycle. All sinks in both modules are reseted. The reset is done at the beginning of the new cycle BEFORE the sinks and modules are processed. Thus, when this method returns, the pending event flags set in the current cycle are still enabled and accessible.
Definition at line 131 of file OTQt.cxx.
References ot::Context::close(), context_, QTime::currentTime(), cycle_counter_, me_mod_, mec_mod_, QTime::msec(), mutex_, OTQT_DEBUG(), OTQT_ERROR(), ot::Context::pullEvents(), ot::Context::pushEvents(), ot::QtMouseEventModuleBase::resetPendingEventBitAllSinks(), ot::Context::stop(), stopTimer(), QMutex::tryLock(), and QMutex::unlock().
Referenced by init(), ot::OTQtMEMCalibProc::trackASCorner(), ot::OTQtMEMCalibProc::trackASCornerMain(), ot::OTQtMEMCalibProc::trackASPos(), ot::OTQtMEMCalibProc::trackMBDButtonOne(), and ot::OTQtMEMCalibProc::trackMPD().
| bool ot::OTQt::enableMouseEvents | ( | bool | enable | ) | [inline] |
Enables or disables the distribution of mouse events to the target Qt application in the MEM depending on the given boolean argument.
Returns the current state of the mouse event distribution, thus returns true if mouse event distribution is enabled and false if disabled.
- Parameters:
-
enable true means enable, false means disable mouse event distribution
- Returns:
- current state of MEM mouse event distribution, true if enabled, false if disabled
Definition at line 207 of file OTQt.h.
Referenced by triggerMEM().
| OTQt & ot::OTQt::getInstance | ( | ) | [static] |
Returns the OTQt singleton instance.
Creates the singleton instance if it currently does not exist.
- Returns:
- singleton instance
Definition at line 82 of file OTQt.cxx.
References OTQt(), and the_instance_.
Referenced by triggerMEM().
| QtMouseEventCalibModule& ot::OTQt::getMECM | ( | ) | [inline, protected] |
Returns the MECM object added to the OpenTracker context.
- Returns:
- MECM object
Definition at line 221 of file OTQt.h.
Referenced by ot::OTQtMEMCalibProc::exec(), ot::OTQtMEMCalibProc::trackASCorner(), ot::OTQtMEMCalibProc::trackASCornerMain(), ot::OTQtMEMCalibProc::trackASPos(), ot::OTQtMEMCalibProc::trackMBDButtonOne(), and ot::OTQtMEMCalibProc::trackMPD().
| QtMouseEventModule& ot::OTQt::getMEM | ( | ) | [inline, protected] |
| void ot::OTQt::init | ( | std::string & | cfg_filename | ) |
Creates and initializes the OpenTracker context.
Adds the MEM and MECM to a context factory. Parses the given configuration file. During parsing the node graph is created. Switches state of object to initialized.
- Parameters:
-
cfg_filename XML configuration filename
Definition at line 91 of file OTQt.cxx.
References ot::Context::addFactory(), ot::Context::addModule(), cfg_filename_, QObject::connect(), context_, driveOT(), ot::initializeContext(), is_initialized_, me_mod_, mec_mod_, ot::Context::parseConfiguration(), ot::Context::start(), and timer_.
Referenced by ot::OTQtMEMCalibProc::exec(), and triggerMEM().
| bool ot::OTQt::isInitialized | ( | ) | const [inline] |
| bool ot::OTQt::isTimerActive | ( | ) | const [inline] |
| void ot::OTQt::startTimer | ( | unsigned int | timeout = DEFAULT_TIMER_TIMEOUT_MSEC |
) |
Starts the operation mode timer thread with given timeout.
If the timer argument is omitted, the default timeout is used. Does nothing if the timer thread is already running.
- Parameters:
-
timeout timer thread timeout in milliseconds
Definition at line 117 of file OTQt.cxx.
References QTimer::isActive(), QTimer::start(), QTimer::stop(), and timer_.
Referenced by triggerMEM().
| void ot::OTQt::stopTimer | ( | ) |
Stops the timer thread if it is currently running.
Otherwise does nothing.
Definition at line 125 of file OTQt.cxx.
References QTimer::isActive(), QTimer::stop(), and timer_.
Referenced by driveOT().
| bool ot::OTQt::triggerMEM | ( | std::string | cfg_filename | ) | [static] |
Initializes the OTQt MEM module.
Designed to be implemented in target Qt applications. Initializes the OpenTracker context, adds MEM to the context factory, parses the given configuration file, enables the mouse event generation and finally starts the timer thread with the default timeout. Returns true if OTQt startup was successful, otherwise returns false (eg in case of an exception).
- Parameters:
-
cfg_filename XML configuration filename
- Returns:
- true if OTQt startup successful
Definition at line 190 of file OTQt.cxx.
References enableMouseEvents(), getInstance(), init(), OTQT_ERROR(), and startTimer().
Member Data Documentation
std::string ot::OTQt::cfg_filename_ [private] |
Context ot::OTQt::context_ [private] |
unsigned int ot::OTQt::cycle_counter_ [private] |
int const ot::OTQt::DEFAULT_TIMER_TIMEOUT_MSEC = 20 [static] |
bool ot::OTQt::is_initialized_ [private] |
QtMouseEventModule* ot::OTQt::me_mod_ [private] |
QtMouseEventCalibModule* ot::OTQt::mec_mod_ [private] |
QMutex* ot::OTQt::mutex_ [private] |
OTQt * ot::OTQt::the_instance_ = NULL [static, private] |
QTimer* ot::OTQt::timer_ [private] |
operation mode timer thread
Definition at line 257 of file OTQt.h.
Referenced by init(), startTimer(), stopTimer(), and ~OTQt().
The documentation for this class was generated from the following files: