#include <LargeDisplayManager.h>
Collaboration diagram for LargeDisplayManager:
Public Member Functions | |
LargeDisplayManager (FrameTimer *timer) | |
virtual | ~LargeDisplayManager (void) |
void | renderAll (bool enablePicking=false) |
void | renderOtherComponents (unsigned long exceptionId, bool enablePicking=false) |
void | renderOtherComponents (const std::vector< unsigned long > &exceptionIds, bool enablePicking=false) |
void | renderContainers (bool enablePicking=false) |
void | renderOtherContainers (unsigned long exceptionId, bool enablePicking) |
void | renderAllTouchIndicators () |
void | renderTouchIndicator (unsigned int indicatorIndex) |
bool | addComponent (VisComponent *comp) |
void | removeComponent (unsigned long id) |
void | deleteComponent (unsigned long id) |
VisComponent * | getComponent (unsigned long id) |
bool | updateComposition (VisComponent *component) |
void | addToUpdateList (unsigned long componentId) |
unsigned long | getNumberComponents () |
void | processEvent (LargeDisplayEvent *evt, VisComponent *target=NULL) |
void | multicastEvent (LargeDisplayEvent *evt, std::vector< unsigned long > targetIDs) |
void | broadcastEvent (LargeDisplayEvent *evt) |
virtual void | resize (unsigned int width, unsigned int height) |
unsigned long | getBuffersMemorySizeKBytes () |
void | replaceSelectedID (unsigned long currentID, unsigned long newID) |
VisComponent * | getComponentAt (unsigned int x, unsigned int y) |
void | unselectComponent (unsigned long userID=0) |
void | unselectAllComponent () |
bool | isComponentSelected (unsigned long componentId) |
VisComponent * | getRootComponent () |
void | setRootComponent (VisComponent *root) |
FrameTimer * | getFrameTimer () |
void | setFrameTimer (FrameTimer *timer) |
double | getFPS () |
unsigned int | getDisplayWidth () |
void | setDisplayWidth (unsigned int w) |
unsigned int | getDisplayHeight () |
void | setDisplayHeight (unsigned int h) |
std::vector< unsigned long > | getSelectedComponentIds () |
unsigned long | getSelectedComponentId (unsigned long userID) |
Static Public Attributes | |
static const unsigned int | ANIMATION_STARTED = 1 |
static const unsigned int | ANIMATION_OVER = 2 |
static const unsigned int | LAST_RESERVED_EVENT_TYPE = 2 |
Protected Member Functions | |
unsigned long | obtainId () |
void | initialize () |
virtual void | initTouchIndicators ()=0 |
virtual void | initComponents ()=0 |
virtual unsigned long | pickComponent (unsigned int x, unsigned int y)=0 |
virtual unsigned long | pickContainer (unsigned int x, unsigned int y, unsigned long excludeComponentId)=0 |
Protected Attributes | |
HASH_MAP_EXTENSION::hash_map< unsigned long, VisComponent * > | components |
VisComponent * | rootComponent |
unsigned int | nUsers |
std::vector< VisComponent * > | touchIndicators |
std::vector< unsigned long > | selectedComponentIds |
std::vector< unsigned long > | componentsToUpdate |
FrameTimer * | frameTimer |
double | fps |
unsigned int | displayWidth |
unsigned int | displayHeight |
This class should be extended in order to define which objects are created during initialization. In this manner, the specification of an application that makes use of the framework consists in basically extending this class and providing the involved visualization objects together with their behavior strategies.
This class also keeps track of the frame rate, of memory usage by the component's properties/buffers, of the assignment of unique IDs to the components, and of multiple-user interaction and their touch indicators.
The selection/picking mechanism used is based on a back-buffer rendering of the components using colors calculated from their IDs. However, since it uses graphics package specific code (e.g., OpenGL), it should be implemented in a concrete subclass. The color-ID conversion mechanism (if used) is defined in the VisComponent class.
This class is based on the refactoring of the TabletopVis class created by A. Miede and T. Isenberg in the Interactions Lab at the University of Calgary, Canada.
LargeDisplayManager::LargeDisplayManager | ( | FrameTimer * | timer | ) |
Default constructor for a LargeDisplayManager object. It takes a pointer to a timer object in order to keep track of frame rates and animation timing. If such functionality is not required, timer can be NULL.
timer | the frame timer to be used when calculating the fps rate when rendering the components. |
LargeDisplayManager::~LargeDisplayManager | ( | void | ) | [virtual] |
Destructor for a LargeDisplayManager object.
void LargeDisplayManager::renderAll | ( | bool | enablePicking = false |
) |
Renders all the components attached to the root component and all touch indicators.
enablePicking | if true, draws for picking mode. |
void LargeDisplayManager::renderOtherComponents | ( | unsigned long | exceptionId, | |
bool | enablePicking = false | |||
) |
Renders all the components attached to the root component, except by the one with the given identifier (no touch indicators are rendered).
exceptionId | the id of the component that should not be rendered. | |
enablePicking | if true, draws for picking mode. |
void LargeDisplayManager::renderOtherComponents | ( | const std::vector< unsigned long > & | exceptionIds, | |
bool | enablePicking = false | |||
) |
Renders all the components attached to the root component, except by the ones with the identifier given in the list of exceptions (no touch indicators are rendered).
exceptionIds | the list of ids of the components that should not be rendered. | |
enablePicking | if true, draws for picking mode. |
void LargeDisplayManager::renderContainers | ( | bool | enablePicking = false |
) |
Renders all the components attached to the root component that are containers (i. e., that are not leaves).
enablePicking | if true, draws for picking mode. |
void LargeDisplayManager::renderOtherContainers | ( | unsigned long | exceptionId, | |
bool | enablePicking | |||
) |
Renders all the components attached to the root component that are containers (i. e., that are not leaves), except by the one with the given identifier.
exceptionId | the id of the container that should not be rendered. | |
enablePicking | if true, draws for picking mode. |
void LargeDisplayManager::renderAllTouchIndicators | ( | ) |
Renders all the touch indicators.
void LargeDisplayManager::renderTouchIndicator | ( | unsigned int | indicatorIndex | ) |
Renders only the specified touch indicator.
bool LargeDisplayManager::addComponent | ( | VisComponent * | comp | ) |
Adds a component to this manager. Returns true if the component was successfully added and false if a component with the same id is already in (in this case, nothing is added). To avoid conflict, it sets the id of the component being added so that it is unique. If the maximum number of components is reached, an exception is thrown. Additionally, if the given component doesn't have a parent, it is made a child of the root component.
comp | the component to be added. |
std::overflow_error | when trying to add more elements than the maximum allowed. |
void LargeDisplayManager::removeComponent | ( | unsigned long | id | ) |
Removes a component from this manager. If there is no component with the given ID, nothing is done. The component is not destroyed, just removed from the manager (to destroy it, see the deleteComponent() method). The component is also removed from its parent children list and its children are made children of its parent node.
id | the ID of the component to be deleted. |
void LargeDisplayManager::deleteComponent | ( | unsigned long | id | ) |
Deletes a component from this manager. If there is no component with the given ID, nothing is done. If the component is deleted, its id is freed. The component is also removed from its parent children list and its children are made children of its parent node.
id | the ID of the component to be deleted. |
VisComponent * LargeDisplayManager::getComponent | ( | unsigned long | id | ) |
Returns the component with the given identifier. If there is no component with the given identifier in the collection, NULL is returned.
id | the id of the component to be returned. |
bool LargeDisplayManager::updateComposition | ( | VisComponent * | component | ) |
Checks if the given component is inside or outside a container and makes the proper updates in the composition tree. The passive buffers of all components in the component branch are updated if the component is moved inside the composition tree. Returns true if the component was moved (i. e., changed its parent component) during the update.
component | the component that was moved around. |
void LargeDisplayManager::addToUpdateList | ( | unsigned long | componentId | ) | [inline] |
Adds the given component id to the list of the components that should be updated when rendering the next frame. The update moves the component branch in the composition tree and triggers the corresponding animations, if necessary.
componentId | the id of the component that should be updated. |
unsigned long LargeDisplayManager::getNumberComponents | ( | ) | [inline] |
Returns the current number of components.
void LargeDisplayManager::processEvent | ( | LargeDisplayEvent * | evt, | |
VisComponent * | target = NULL | |||
) |
Processes the given event. If no target component is specified, the coordinate values from the event object are used to pick a target component.
evt | the event to be processed. |
void LargeDisplayManager::multicastEvent | ( | LargeDisplayEvent * | evt, | |
std::vector< unsigned long > | targetIDs | |||
) |
Sends the given event to the components whose ID is in the given list.
evt | the event to be multicast. | |
targetIDs | the collection of the IDs of the targets of the multicast. |
void LargeDisplayManager::broadcastEvent | ( | LargeDisplayEvent * | evt | ) |
Sends the given event to all the current components.
evt | the event to be broadcast. |
void LargeDisplayManager::resize | ( | unsigned int | width, | |
unsigned int | height | |||
) | [virtual] |
Resizes the display. Here, it only forwards the resizing to the root component. More specific actions should be taken by the subclasses.
width | the new width. | |
hright | the new height. |
unsigned long LargeDisplayManager::getBuffersMemorySizeKBytes | ( | ) |
Returns the amount of memory in KyloBytes allocated by the active buffers of all components, that is the amount of memory used by all i-buffers.
void LargeDisplayManager::replaceSelectedID | ( | unsigned long | currentID, | |
unsigned long | newID | |||
) |
Replaces the currently selected component ID for a user by the given ID. If the ID passed for the currently selected component is not found in association with a user, nothing is done.
currentID | the currently selected ID. | |
newID | the ID of the component to be selected. |
VisComponent* LargeDisplayManager::getComponentAt | ( | unsigned int | x, | |
unsigned int | y | |||
) | [inline] |
Returns the component that is currently at the given coordinates. If there is no component at the specified position, NULL is returned.
x | the x-coordinate of the position of component picking. | |
y | the y-coordinate of the position of component picking. |
void LargeDisplayManager::unselectComponent | ( | unsigned long | userID = 0 |
) | [inline] |
Unselects the component associated the given user.
userID | the ID of the user of the selected component to be unselected. |
void LargeDisplayManager::unselectAllComponent | ( | ) | [inline] |
Unselects the component associated all users.
bool LargeDisplayManager::isComponentSelected | ( | unsigned long | componentId | ) | [inline] |
Returns true if the component with the given ID is currently selected by a user.
componentId | the id of the component being checked. |
VisComponent* LargeDisplayManager::getRootComponent | ( | ) | [inline] |
Returns the component that is the root of the composition.
void LargeDisplayManager::setRootComponent | ( | VisComponent * | root | ) | [inline] |
Sets the given component to be the root of the composition.
root | the component to be set as the root of the composition. |
FrameTimer* LargeDisplayManager::getFrameTimer | ( | ) | [inline] |
Returns the timer that measures the frame rate for rendering the components.
void LargeDisplayManager::setFrameTimer | ( | FrameTimer * | timer | ) | [inline] |
Sets the timer that measures the frame rate for rendering the components.
root | the frame timer to be set to measure the rendering frame rates. |
double LargeDisplayManager::getFPS | ( | ) | [inline] |
Returns the value of the frames per second rate to render the components.
unsigned int LargeDisplayManager::getDisplayWidth | ( | ) | [inline] |
Returns the current display width.
void LargeDisplayManager::setDisplayWidth | ( | unsigned int | w | ) | [inline] |
Sets the current display width.
w | the value to be set as the current display width. |
unsigned int LargeDisplayManager::getDisplayHeight | ( | ) | [inline] |
Returns the current display height.
void LargeDisplayManager::setDisplayHeight | ( | unsigned int | h | ) | [inline] |
Sets the current display height.
h | the value to be set as the current display height. |
std::vector<unsigned long> LargeDisplayManager::getSelectedComponentIds | ( | ) | [inline] |
Returns the list of currently selected component IDs by user.
unsigned long LargeDisplayManager::getSelectedComponentId | ( | unsigned long | userID | ) | [inline] |
Returns the ID of the currently selected component by the given user.
userID | the ID of the user of the selected component. |
unsigned long LargeDisplayManager::obtainId | ( | ) | [protected] |
Returns the identifier to be used by the next added component. It may reuse the identifier of a deleted component, if any is available.
std::overflow_error | when trying to obtain an id above the maximum |
void LargeDisplayManager::initialize | ( | ) | [protected] |
Initializes the manager.
virtual void LargeDisplayManager::initTouchIndicators | ( | ) | [protected, pure virtual] |
Initializes the list of touch indicators.
virtual void LargeDisplayManager::initComponents | ( | ) | [protected, pure virtual] |
Initializes the component collection by creating and adding application specific components.
virtual unsigned long LargeDisplayManager::pickComponent | ( | unsigned int | x, | |
unsigned int | y | |||
) | [protected, pure virtual] |
Returns the id of the component at the given coordinates or zero if no component was picked.
x | the x-coordinate of the selection. | |
y | the y-coordinate of the selection. |
virtual unsigned long LargeDisplayManager::pickContainer | ( | unsigned int | x, | |
unsigned int | y, | |||
unsigned long | excludeComponentId | |||
) | [protected, pure virtual] |
Returns the id of the container component (i. e., a component that is not a leaf in the composition tree) at the given coordinates or zero if no component was picked.
x | the x-coordinate of the selection. | |
y | the y-coordinate of the selection. | |
excludeComponentId | the id of the component that should be excluded from the picking domain. |
const unsigned int LargeDisplayManager::ANIMATION_STARTED = 1 [static] |
The type for an animation started event.
const unsigned int LargeDisplayManager::ANIMATION_OVER = 2 [static] |
The type for an animation over event.
const unsigned int LargeDisplayManager::LAST_RESERVED_EVENT_TYPE = 2 [static] |
The last reserved event type.
HASH_MAP_EXTENSION::hash_map<unsigned long, VisComponent*> LargeDisplayManager::components [protected] |
The collection of all visualization components.
VisComponent* LargeDisplayManager::rootComponent [protected] |
The component that is the root of the composition tree. It doesn't need to be visible.
unsigned int LargeDisplayManager::nUsers [protected] |
The number of concurrent users.
std::vector<VisComponent*> LargeDisplayManager::touchIndicators [protected] |
The list of touch indicators that can be shown on the screen.
std::vector<unsigned long> LargeDisplayManager::selectedComponentIds [protected] |
The list of the ids of the currently selected component by each user (if zero, there is no selection).
std::vector<unsigned long> LargeDisplayManager::componentsToUpdate [protected] |
List of component ids to have their composition structure (tree) updated.
FrameTimer* LargeDisplayManager::frameTimer [protected] |
The timer that measures the frame rate to render the components.
double LargeDisplayManager::fps [protected] |
The current value of the FPS rate for rendering the components.
unsigned int LargeDisplayManager::displayWidth [protected] |
The width of the display.
unsigned int LargeDisplayManager::displayHeight [protected] |
The height of the display.