Skip to content

Commit

Permalink
Merge pull request #577 from johncbaur/VIX-3519
Browse files Browse the repository at this point in the history
VIX-3519 Set strobe min and max rates
  • Loading branch information
jeffu231 authored Jan 29, 2024
2 parents d86ea9d + 7be960a commit 62149fa
Show file tree
Hide file tree
Showing 10 changed files with 642 additions and 75 deletions.
12 changes: 12 additions & 0 deletions src/Vixen.Core/Commands/Named8BitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public Named8BitCommand(double value)
/// </summary>
public string Label { get; set; }

/// <summary>
/// Minimum value of the index type range.
/// </summary>
/// <remarks>This property only applies if the index type is part of a range</remarks>
public byte RangeMinimum { get; set; }

/// <summary>
/// Maximum value of the index type range.
/// </summary>
/// <remarks>This property only applies if the index type is part of a range</remarks>
public byte RangeMaximum { get; set; }

#endregion
}
}
5 changes: 5 additions & 0 deletions src/Vixen.Modules/Editor/FixtureGraphics/IMovingHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,10 @@ public interface IMovingHead
/// </summary>
/// <returns>+1 or -1 based on the orientation of the fixture</returns>
double GetOrientationSign();

/// <summary>
/// Strobe rate represented in milliseconds between pulses.
/// </summary>
int StrobeRate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public MovingHeadSettings()
/// </summary>
public int FixtureIntensity { get; set; }

/// <inheritdoc/>
public int StrobeRate { get; set; }

/// <summary>
/// Refer to interface documentation.
/// </summary>
Expand All @@ -130,6 +133,7 @@ public IMovingHead Clone()
EnableGDI = EnableGDI,
FixtureIntensity = FixtureIntensity,
MountingPosition = MountingPosition,
StrobeRate = StrobeRate,
};
}

Expand Down Expand Up @@ -181,7 +185,8 @@ public override bool Equals(object obj)
movingHead.IncludeLegend == IncludeLegend &&
movingHead.LegendColor == LegendColor &&
movingHead.FixtureIntensity == FixtureIntensity &&
movingHead.MountingPosition == MountingPosition);
movingHead.MountingPosition == MountingPosition &&
movingHead.StrobeRate == StrobeRate);
}

#endregion
Expand Down
12 changes: 12 additions & 0 deletions src/Vixen.Modules/Effect/Effect/FixtureEffectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ protected void RenderIndex(
// Declare the index value to use for the command
int indexValue;

// Default the index range
int minValue = 0;
int maxValue = 0;

// If the index uses a curve then...
if (fixtureIndex.UseCurve)
{
Expand All @@ -542,6 +546,10 @@ protected void RenderIndex(

// Scale the value based on the start and stop values of the index
indexValue = (int)Math.Round(ScaleCurveToValue(curve.GetValue(intervalPosFactor), fixtureIndex.EndValue, fixtureIndex.StartValue));

// Save off the index range
minValue = fixtureIndex.StartValue;
maxValue = fixtureIndex.EndValue;
}
else
{
Expand All @@ -561,6 +569,10 @@ protected void RenderIndex(
// Assign the label to the command
namedCommand.Label = function.Label;

// Assign the index range to the command
namedCommand.RangeMinimum = (byte)minValue;
namedCommand.RangeMaximum = (byte)maxValue;

// Create the command value from the tagged command
CommandValue commandValue = new CommandValue(namedCommand);

Expand Down
47 changes: 34 additions & 13 deletions src/Vixen.Modules/Preview/VixenPreview/OpenGL/OpenGLPreviewForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics;
using System.Timers;

using Common.Controls;
using Common.Controls.Scaling;
using Common.Controls.Theme;
Expand Down Expand Up @@ -592,20 +594,24 @@ private Matrix4 CreatePerspective()
/// <summary>
/// Initializes the moving head render strategy with shapes that are made up of graphical volumes.
/// </summary>
private void InitializeMovingHeadRenderStrategy()
/// <param name="redraw">Method to redraw the preview</param>
private void InitializeMovingHeadRenderStrategy(Action redraw)
{
// If the moving head render strategy has not been created then...
if (_movingHeadRenderStrategy == null)
{
// Reset all strobe timers
MovingHeadIntentHandler.ResetStrobeTimers();

// Create the moving head render strategy
_movingHeadRenderStrategy = new MovingHeadRenderStrategy();

// Loop over the moving heads
foreach (IOpenGLMovingHeadShape movingHeadVolumes in GetMovingHeadShapes())
{
// Initialize the moving head with the reference height
// Initialize the moving head with the reference height and redraw delegate
int referenceHeight = _background.HasBackground ? _background.Height : Height;
movingHeadVolumes.Initialize(referenceHeight);
movingHeadVolumes.Initialize(referenceHeight, redraw);

// Give the shape to the render strategy
_movingHeadRenderStrategy.Shapes.Add(movingHeadVolumes.MovingHead);
Expand Down Expand Up @@ -679,13 +685,26 @@ private void RenderStaticPreviewShapes(Matrix4 perspective)
}
}

/// <summary>
/// Renders the preview on the GUI thread.
/// </summary>
private void OnRenderFrameOnGUIThread()
{
// Render the preview on the GUI thread
BeginInvoke(() =>
{
OnRenderFrame();
});
}

private void OnRenderFrame()
{
{
//Logging.Debug("Entering RenderFrame");
if (_isRendering || _formLoading || WindowState == FormWindowState.Minimized) return;

// Initialize the moving head render strategy with the applicable display item shapes
InitializeMovingHeadRenderStrategy();
InitializeMovingHeadRenderStrategy(OnRenderFrameOnGUIThread);

//Logging.Debug("Entering RenderFrame");
if (_isRendering || _formLoading || WindowState==FormWindowState.Minimized) return;
UpdateStatusDistance(_camera.Position.Z);
_isRendering = true;
_sw.Restart();
Expand All @@ -702,18 +721,18 @@ private void OnRenderFrame()
{
glControl.MakeCurrent();
ClearScreen();

_sw2.Restart();
_background.Draw(perspective, _camera.ViewMatrix);
_backgroundDraw.Set(_sw2.ElapsedMilliseconds);
//Logging.Info($"GL Error: {GL.GetError()}");
_sw2.Restart();

// Render static preview shapes (moving heads)
RenderStaticPreviewShapes(perspective);

DrawPoints(mvp);

_pointsDraw.Set(_sw2.ElapsedMilliseconds);

glControl.SwapBuffers();
Expand All @@ -726,21 +745,23 @@ private void OnRenderFrame()
{
glControl.MakeCurrent();
ClearScreen();

_sw2.Restart();
_background.Draw(perspective, _camera.ViewMatrix);
_backgroundDraw.Set(_sw2.ElapsedMilliseconds);

// Render static preview shapes (moving heads)
RenderStaticPreviewShapes(perspective);

glControl.SwapBuffers();
//glControl.Context.MakeCurrent();
}
}

_isRendering = false;
_previewUpdate.Set(_sw.ElapsedMilliseconds);
UpdateFrameRate();

//Logging.Debug("Exiting RenderFrame");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public interface IOpenGLMovingHeadShape
/// </summary>
/// <remarks>The reference height is used to determine the maximum beam length</remarks>
/// <param name="referenceHeight">Height of the drawing area / background image</param>
void Initialize(int referenceHeight);
/// <param name="redraw">Delegate that redraws the preview</param>
void Initialize(int referenceHeight, Action redraw);

/// <summary>
/// Gets the OpenGL moving head associated with the shape.
Expand Down
Loading

0 comments on commit 62149fa

Please sign in to comment.