Skip to content

Commit

Permalink
VIX-3570 New Line Dance Effect
Browse files Browse the repository at this point in the history
VIX-3570 New Line Dance Effect
  • Loading branch information
johncbaur committed Aug 11, 2024
1 parent d5071b6 commit 0adf54c
Show file tree
Hide file tree
Showing 12 changed files with 743 additions and 670 deletions.
106 changes: 104 additions & 2 deletions src/Vixen.Modules/Effect/Effect/FixtureEffectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
using Vixen.Intent;
using Vixen.Module;
using Vixen.Sys;

using VixenModules.App.Curves;
using VixenModules.App.Fixture;
using VixenModules.Property.IntelligentFixture;

using ZedGraph;

namespace VixenModules.Effect.Effect
Expand All @@ -16,6 +18,7 @@ namespace VixenModules.Effect.Effect
/// </summary>
/// <typeparam name="T_Data">Type of data class associated with the effect</typeparam>
public abstract class FixtureEffectBase<T_Data> : BaseEffect
where T_Data : EffectTypeModuleData
{
#region Fields

Expand Down Expand Up @@ -50,7 +53,13 @@ public FixtureEffectBase(string helpURL)
/// <summary>
/// Module data associated with the effect.
/// </summary>
protected override EffectTypeModuleData EffectModuleData { get; }
protected override EffectTypeModuleData EffectModuleData
{
get
{
return (EffectTypeModuleData)Data;
}
}

/// <summary>
/// Collection of intents generated by the effect.
Expand Down Expand Up @@ -95,6 +104,78 @@ protected IEnumerable<IElementNode> GetLeafNodesWithIntelligentFixtureProperty(I
return node.GetLeafEnumerator().Where(x => x != null && x.Properties.Contains(IntelligentFixtureDescriptor._typeId));
}

/// <summary>
/// Retrieves the leaf nodes that support the specified function identity type.
/// </summary>
/// <param name="type">Function identity type to search for</param>
/// <param name="nodeToFunction">Dictionary of node to function information</param>
/// <returns>Collection of nodes that contain the specified function identity</returns>
protected List<IElementNode> GetRenderNodesForFunctionIdentity(
FunctionIdentity type,
IDictionary<IElementNode, (string label, string tag)> nodeToFunction)
{
// Create the return collection
List<IElementNode> renderNodes = new();

// Loop over the target nodes
foreach (IElementNode node in TargetNodes)
{
// Loop over the leaf nodes that contain an intelligent fixture property
foreach(IElementNode leafNode in GetLeafNodesWithIntelligentFixtureProperty(node))
{
// Add the render nodes that support the function identity
renderNodes.AddRange(GetRenderNodesForFunctionIdentity(type, leafNode, nodeToFunction));
}
}

return renderNodes;
}

/// <summary>
/// Retrieves the leaf nodes that support the specified function identity type.
/// </summary>
/// <param name="type">Function identity type to search for</param>
/// <param name="node">Node to analyze</param>
/// <param name="nodeToFunction">Dictionary of node to function information</param>
/// <returns>Collection of nodes that contain the specified function identity</returns>
protected List<IElementNode> GetRenderNodesForFunctionIdentity(
FunctionIdentity type,
IElementNode node,
IDictionary<IElementNode, (string label, string tag)> nodeToFunction)
{
// Create the return collection
List<IElementNode> renderNodes = new();

// If the node is NOT null then...
if (node != null)
{
// Retrieve all leaf nodes that have an intelligent fixture property
IEnumerable<IElementNode> leaves = GetLeafNodesWithIntelligentFixtureProperty(node);

// Loop over the leaves
foreach (IElementNode leafNode in leaves)
{
// Retrieve the fixture property associated with the node
IntelligentFixtureModule fixtureProperty = (IntelligentFixtureModule)leafNode.Properties.Single(x => x is IntelligentFixtureModule);

// If the fixture supports the specified function identity then...
if (fixtureProperty.FixtureSpecification.SupportsFunction(type))
{
// Find the function associated with the effect based on function identity enumeration
FixtureFunction func = fixtureProperty.FixtureSpecification.FunctionDefinitions.SingleOrDefault(function => function.FunctionIdentity == type);

// Add the node and function information to the dictionary
nodeToFunction.Add(leafNode, new (func.Label, func.Name));

// Add the node to collection of render nodes
renderNodes.Add(leafNode);
}
}
}

return renderNodes;
}

/// <summary>
/// Retrieves the leaf nodes that support the specified function identity type.
/// </summary>
Expand All @@ -104,11 +185,32 @@ protected IEnumerable<IElementNode> GetLeafNodesWithIntelligentFixtureProperty(I
protected IEnumerable<Tuple<IElementNode,string>> GetRenderNodesForFunctionIdentity(FunctionIdentity type, Dictionary<IElementNode, string> tags)
{
// Create the return collection
List<Tuple<IElementNode, string>> leavesThatSupportFunction = new List<Tuple<IElementNode, string>>();
IEnumerable<Tuple<IElementNode, string>> leavesThatSupportFunction = new List<Tuple<IElementNode, string>>();

// Retrieve the first node
IElementNode node = TargetNodes.FirstOrDefault();

// If the node is NOT null then...
if (node != null)
{
leavesThatSupportFunction = GetRenderNodesForFunctionIdentity(type, tags, node);
}

return leavesThatSupportFunction;
}

/// <summary>
/// Retrieves the leaf nodes that support the specified function identity type.
/// </summary>
/// <param name="type">Function identity type to search for</param>
/// <param name="tags">Dictionary of function tags to populate</param>
/// <param name="node">Node to analyze</param>
/// <returns>Nodes that contain the specified function identity type along with the optional label associated with the function</returns>
protected IEnumerable<Tuple<IElementNode, string>> GetRenderNodesForFunctionIdentity(FunctionIdentity type, Dictionary<IElementNode, string> tags, IElementNode node)
{
// Create the return collection
List<Tuple<IElementNode, string>> leavesThatSupportFunction = new List<Tuple<IElementNode, string>>();

// If the node is NOT null then...
if (node != null)
{
Expand Down
1 change: 1 addition & 0 deletions src/Vixen.Modules/Effect/Effect/FixtureIndexEffectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace VixenModules.Effect.Effect
/// </summary>
/// <typeparam name="T_Data">Type of effect module data</typeparam>
public abstract class FixtureIndexEffectBase<T_Data> : FixtureEffectBase<T_Data>
where T_Data : EffectTypeModuleData
{
#region Constructor

Expand Down
Loading

0 comments on commit 0adf54c

Please sign in to comment.