Lumiverse  2.5
A framework for creating lighting control applications
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Lumiverse::ShowControl::Layer Class Reference

A Layer stores a state of the Rig. More...

#include <Layer.h>

Collaboration diagram for Lumiverse::ShowControl::Layer:
Collaboration graph
[legend]

Public Types

enum  BlendMode { ALPHA, OVERWRITE, MAX, MIN }
 

Public Member Functions

 Layer (Rig *rig, Playback *pb, string name, int priority, BlendMode mode=ALPHA)
 Constructs a Layer. More...
 
 Layer (Rig *rig, Playback *pb, string name, int priority, float opacity)
 Constructs a Layer using the ALPHA mode with specified opacity. More...
 
 Layer (DeviceSet set, Playback *pb, string name, int priority, BlendMode mode=ALPHA)
 Constructs a Layer using the selected devices and all of their parameters.
 
 Layer (Playback *pb, string name, int priority, BlendMode mode=ALPHA)
 Constructs an empty Layer.
 
 Layer (Playback *pb, JSONNode node)
 Constructs a Layer from a JSON node.
 
 ~Layer ()
 Destroys a layer.
 
void play (string id)
 Plays a Timeline on the layer. More...
 
void pause ()
 Pauses playback of the current Timeline(s). More...
 
void resume ()
 Resumes playback of the current Timeline(s). More...
 
void stop ()
 Stops and clears all current playback information from the Layer. More...
 
BlendMode getMode ()
 Gets the layer's blend mode.
 
void setMode (BlendMode mode)
 Sets the Layer's blend mode.
 
float getOpacity ()
 Get the layer's opacity.
 
void setOpacity (float val)
 Set the layer's opactiy.
 
bool isActive ()
 Retrieves the visibility of the layer.
 
void activate ()
 Set m_active to true.
 
void deactivate ()
 Set m_active to false.
 
void setName (string name)
 Set the layer name.
 
string getName ()
 Get the layer name.
 
void setPriority (int priority)
 Sets the priority.
 
int getPriority ()
 Gets the priority.
 
bool addDevices (DeviceSet d)
 Adds the selected devices and all parameters to the Layer state. More...
 
bool addDevice (Device *d, string param)
 Adds a single device and parameter to the layer. More...
 
bool addDevicesWithParams (DeviceSet d, set< string > params)
 Adds the selected devices and selected parameters to the Layer state. More...
 
bool addParamToAllDevices (string param, LumiverseType *type)
 Adds the specified parameter with the specified type to the existing devices in the Layer. More...
 
bool deleteParameter (string id, string param)
 Deletes a single parameter from a single device in the layer.
 
bool deleteDevices (DeviceSet d)
 Deletes the selected devices from the layer along with all of their parameters. More...
 
bool deleteParametersFromDevices (DeviceSet d, set< string > params)
 Deletes the selected parameter values from the layer.
 
bool deleteParametersFromAllDevices (set< string > params)
 Deletes all parameters from all devices in the layer.
 
string getRecentTimeline ()
 Returns the ID of the Timeline most being played on the Layer. More...
 
map< string, map< string, LumiverseType * > > & getLayerState ()
 Gets the layer state. More...
 
void update (chrono::time_point< chrono::high_resolution_clock > updateStart)
 Updates the Layer. If cues a running, the cues get updated. More...
 
void blend (map< string, Device * > currentState)
 Blends this layer with the given state. More...
 
JSONNode toJSON ()
 Returns the JSON representation of a Layer.
 
void reset ()
 Restores the layer state to defaults and gets out of the current cue.
 
void setCueList (shared_ptr< CueList > list, bool resetCurrentCue=true)
 Assigns a CueList to the Layer.
 
void removeCueList ()
 Remvoes a CueList from the Layer.
 
bool hasCueList ()
 Indicates whether or not the Layer has a CueList assigned to it.
 
const shared_ptr< CueList > & getCueList ()
 Retrieves the CueList assigned to the layer.
 
float getCurrentCue ()
 Gets the most recently played cue on the Layer.
 
void go ()
 Goes to the next cue in the list.
 
void back ()
 Goes to the previous cue in the list.
 
void goToCue (float num, float up=3, float down=3, float delay=0)
 Goes to the selected cue in the selected time.
 

Private Member Functions

void init (Rig *rig)
 Copies the devices and does other Layer initialization.
 

Private Attributes

map< string, map< string, LumiverseType * > > m_layerState
 Holds the information on the current state of the layer. More...
 
Playbackm_pb
 Playback object associated with the Layer. More...
 
string m_name
 Layer Name.
 
int m_priority
 Layer priority. High priority layers are on top of low priority ones.
 
bool m_active
 Layer visibility flag.
 
BlendMode m_mode
 Layer blend mode.
 
float m_opacity
 If using alpha blending, the opacity of the layer.
 
bool m_pause
 Indicates if playback is paused on this layer.
 
bool m_stop
 Indicates that the Layer is stopping playback. More...
 
bool m_playing
 Indicates if the layer is currently playing back a timeline.
 
chrono::time_point< chrono::high_resolution_clock > m_previousLoopStart
 Stores the previous loop start time in milliseconds. More...
 
string m_lastPlayedTimeline
 Stores the ID of the most recently played back Timeline.
 
shared_ptr< CueListm_cueList
 
float m_currentCue
 
PlaybackDatam_playbackData
 Returns the set of parameters to animate. More...
 
PlaybackDatam_queuedPlayback
 Next timeline to run.
 
mutex m_queue
 

Detailed Description

A Layer stores a state of the Rig.

Layers can contain a CueList, a static state, or an Effect (effects to be added later). Layers maintain their current state, blend mode, and visibility settings. The Playback object will interpret these settings and perform the appropriate functions to flatten the layers. Layers work by creating duplicates of the devices in a Rig and manipulating their state.

Member Enumeration Documentation

Enumerator
ALPHA 

Blend all parameters using traditional alpha blending.

OVERWRITE 

Overwrite all previous parameter values

MAX 

Highest parameter value takes precedence

MIN 

Lowest parameter value takes precedence

Constructor & Destructor Documentation

Lumiverse::ShowControl::Layer::Layer ( Rig rig,
Playback pb,
string  name,
int  priority,
BlendMode  mode = ALPHA 
)

Constructs a Layer.

Copies all devices from the Rig, resets them to defaults, and sets the mode. By default the Layer will be set to ALPHA. A Layer is set to inactive on construction.

Lumiverse::ShowControl::Layer::Layer ( Rig rig,
Playback pb,
string  name,
int  priority,
float  opacity 
)

Constructs a Layer using the ALPHA mode with specified opacity.

Creates an empty layer using the selected opacity.

Member Function Documentation

bool Lumiverse::ShowControl::Layer::addDevice ( Device d,
string  param 
)

Adds a single device and parameter to the layer.

Returns
True on success, false on failure
bool Lumiverse::ShowControl::Layer::addDevices ( DeviceSet  d)

Adds the selected devices and all parameters to the Layer state.

Returns
True on success, false on failure
bool Lumiverse::ShowControl::Layer::addDevicesWithParams ( DeviceSet  d,
set< string >  params 
)

Adds the selected devices and selected parameters to the Layer state.

Returns
True on success, false on failure
bool Lumiverse::ShowControl::Layer::addParamToAllDevices ( string  param,
LumiverseType type 
)

Adds the specified parameter with the specified type to the existing devices in the Layer.

Use with caution, it's better to use addDevicesWithParams instead of using this

Returns
True on success, false on failure
void Lumiverse::ShowControl::Layer::blend ( map< string, Device * >  currentState)

Blends this layer with the given state.

Generally you'll let the Playback update call this function automatically. Layers are blended from bottom to top according to the priorities (low -> high) and adhere to their given BlendMode.

The return type is void since the memory pointed to by the Device* parameter will be modified, and thus we don't have to write the results into a separate return data structure.

bool Lumiverse::ShowControl::Layer::deleteDevices ( DeviceSet  d)

Deletes the selected devices from the layer along with all of their parameters.

Returns
True on success, false on failure
map<string, map<string, LumiverseType*> >& Lumiverse::ShowControl::Layer::getLayerState ( )
inline

Gets the layer state.

The layer state can be manipulated through this map.

string Lumiverse::ShowControl::Layer::getRecentTimeline ( )

Returns the ID of the Timeline most being played on the Layer.

Returns
ID of the Timeline that's being played back.
void Lumiverse::ShowControl::Layer::pause ( )

Pauses playback of the current Timeline(s).

If there are no Timelines being played back, this function does nothing.

void Lumiverse::ShowControl::Layer::play ( string  id)

Plays a Timeline on the layer.

This is the main function to actually get things to animate. You can hand in any Timeline you want as long as it's in the Playback object.

Layers can play multiple timelines back at once, however there won't be much in the way of intelligent blending. System should do a latest takes precedence merge for multiple timelines.

void Lumiverse::ShowControl::Layer::resume ( )

Resumes playback of the current Timeline(s).

Note that if there are no Timelines being played back, this function does nothing.

void Lumiverse::ShowControl::Layer::stop ( )

Stops and clears all current playback information from the Layer.

The Layer state will remain in whatever state the Timeline it was playing left it. Calling this with no active playbacks will have no effect.

void Lumiverse::ShowControl::Layer::update ( chrono::time_point< chrono::high_resolution_clock >  updateStart)

Updates the Layer. If cues a running, the cues get updated.

Parameters
updateStartThe time at which the update loop started. Used to make sure each cue updates to the same point at this update.

Member Data Documentation

map<string, map<string, LumiverseType*> > Lumiverse::ShowControl::Layer::m_layerState
private

Holds the information on the current state of the layer.

Note that the Layer will only update the parameters contained within this data structure. Shortcuts have been provided for layers that use all parameters, however you can create layers that manage a handful of parameters for a small number of devices.

Playback* Lumiverse::ShowControl::Layer::m_pb
private

Playback object associated with the Layer.

This object contains the Timeline objects used by the Layer during playback.

PlaybackData* Lumiverse::ShowControl::Layer::m_playbackData
private

Returns the set of parameters to animate.

Parameters
aStarting Cue.
bEnding Cue.
assertMake sure that the Rig state at cue B is exactly cue B

Stores the data used during playback.

Layers can only play back one timeline at a time.

chrono::time_point<chrono::high_resolution_clock> Lumiverse::ShowControl::Layer::m_previousLoopStart
private

Stores the previous loop start time in milliseconds.

Can be used to calculate elapsed time since last loop.

bool Lumiverse::ShowControl::Layer::m_stop
private

Indicates that the Layer is stopping playback.

This allows the update function to finish a full update and then clear the playback queue.


The documentation for this class was generated from the following files: