10.08.2013 Views

Bachelor Thesis - Computer Graphics Group

Bachelor Thesis - Computer Graphics Group

Bachelor Thesis - Computer Graphics Group

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

only. Now that the application has been finished, it allows adjustment of advanced<br />

parameters, which are not accessible from the user interface. To achieve<br />

the concept, classes that need to retain persistent state have to implement:<br />

• constructor accepting an XML element (in some cases a separate method<br />

loadFromXml is provided)<br />

• a method returning the actual state represented by a hierarchy of XML<br />

elements (toXmlElement / saveToXml)<br />

Hierarchical object structure used in the application maps perfectly to the<br />

tree-like structure of XML documents. State of an object corresponds to an<br />

XML element, which is a sub-tree in the document. The root of the document<br />

represents the state of the whole application. While saving or loading the<br />

state, parent objects delegate the XML parsing / assembling to their child<br />

elements. It is also possible to store only a part of the configuration to a<br />

separate document. This is used in the user interface to implement export and<br />

import functions.<br />

5.2 Gesture capture library wrapper<br />

The gesture capture library communicates with the main application using<br />

callback functions. This is a low-level interface provided by the library. The<br />

capture library has been designed to be independent of any frameworks or<br />

toolkits that could be used in the hosting application. The callback interface<br />

had to be wrapped for two main reasons:<br />

• it is reasonable to translate the low-level library events into Qt events, to<br />

allow further processing using standard Qt event loop mechanism. This<br />

also makes the dependency on the capture library modular. The rest of<br />

the application would not be affected, if we decided to replace the gesture<br />

capture library. Only the wrapping code would have to be modified<br />

• the callback function is executed in the context of the message thread<br />

created by the capture library. By posting an event to the default Qt<br />

event loop running in the main thread, we switch the context in which<br />

the event is being actually handled to the main thread. Thus, we prevent<br />

possible synchronization problems and the limitation of Qt, which does<br />

not allow certain operations to be performed outside the main thread<br />

Only the gesture-event callback function posts events to the main event loop.<br />

The window-ignored callback has to be processed immediately. As the operation<br />

is constant and thread-safe, the decision can be delegated directly to the<br />

ActionMapping class, mentioned later.<br />

30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!