Skip to content

Commit

Permalink
qmlui: finally started to apply shutter presets (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed May 2, 2018
1 parent ec2faa5 commit 1fe4148
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 18 deletions.
22 changes: 22 additions & 0 deletions qmlui/fixtureutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

#include "monitorproperties.h"
#include "qlcfixturemode.h"
#include "qlccapability.h"
#include "fixtureutils.h"
#include "fixture.h"
#include "doc.h"

#define MIN_STROBE_FREQ_HZ 0.5
#define MAX_STROBE_FREQ_HZ 10.0

FixtureUtils::FixtureUtils()
{

Expand Down Expand Up @@ -311,3 +315,21 @@ QColor FixtureUtils::headColor(Doc *doc, Fixture *fixture, int headIndex)

return finalColor;
}

void FixtureUtils::shutterTimings(int capPreset, uchar value, int &highTime, int &lowTime)
{
switch (capPreset)
{
case QLCCapability::StrobeSlowToFast:
case QLCCapability::StrobeFastToSlow:
case QLCCapability::PulseInSlowToFast:
case QLCCapability::PulseInFastToSlow:
{
float freq = qMax(((float)value * MAX_STROBE_FREQ_HZ) / 255.0, MIN_STROBE_FREQ_HZ);
//qDebug() << "Frequency:" << freq << "Hz";
highTime = qBound(50.0, 500.0 / freq, 200.0);
lowTime = (1000.0 / freq) - highTime;
}
break;
}
}
2 changes: 2 additions & 0 deletions qmlui/fixtureutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class FixtureUtils
* This considers: RGB / CMY / WAUVLI channels, dimmers and gel color */
static QColor headColor(Doc *doc, Fixture *fixture, int headIndex = 0);

static void shutterTimings(int capPreset, uchar value, int &highTime, int &lowTime);

private:
/** Perform a linear blending of $b over $a with the given $mix amount */
static QColor blendColors(QColor a, QColor b, float mix);
Expand Down
60 changes: 57 additions & 3 deletions qmlui/mainview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "doc.h"
#include "tardis.h"
#include "qlcfile.h"
#include "qlcmacros.h"
#include "qlcconfig.h"
#include "mainview3d.h"
#include "fixtureutils.h"
Expand Down Expand Up @@ -696,11 +697,11 @@ void MainView3D::updateFixture(Fixture *fixture)
int tiltValue = 0;

quint32 headDimmerIndex = fixture->channelNumber(QLCChannel::Intensity, QLCChannel::MSB);
qreal intValue = 1.0;
qreal intensityValue = 1.0;
if (headDimmerIndex != QLCChannel::invalid())
intValue = (qreal)fixture->channelValueAt(headDimmerIndex) / 255;
intensityValue = (qreal)fixture->channelValueAt(headDimmerIndex) / 255;

fixtureItem->setProperty("intensity", intValue);
fixtureItem->setProperty("intensity", intensityValue);

color = FixtureUtils::headColor(m_doc, fixture);

Expand Down Expand Up @@ -755,6 +756,59 @@ void MainView3D::updateFixture(Fixture *fixture)
Q_ARG(QVariant, value));
}
break;
case QLCChannel::Shutter:
{
int high = 200, low = 800;
int capPreset = QLCCapability::ShutterOpen;

switch (ch->preset())
{
case QLCChannel::ShutterStrobeSlowFast:
if (value)
{
capPreset = QLCCapability::StrobeSlowToFast;
FixtureUtils::shutterTimings(capPreset, value, high, low);
}
break;
case QLCChannel::ShutterStrobeFastSlow:
if (value)
{
capPreset = QLCCapability::StrobeFastToSlow;
FixtureUtils::shutterTimings(capPreset, 255 - value, high, low);
}
break;
default:
{
QLCCapability *cap = ch->searchCapability(value);
capPreset = cap->preset();
switch (capPreset)
{
case QLCCapability::StrobeSlowToFast:
case QLCCapability::PulseInSlowToFast:
case QLCCapability::PulseOutSlowToFast:
FixtureUtils::shutterTimings(capPreset,
SCALE(value, cap->min(), cap->max(), 1, 255),
high, low);
break;
case QLCCapability::StrobeFastToSlow:
case QLCCapability::PulseInFastToSlow:
case QLCCapability::PulseOutFastToSlow:
FixtureUtils::shutterTimings(capPreset,
255 - SCALE(value, cap->min(), cap->max(), 1, 255),
high, low);
break;
default:
break;
}
}
break;
}

QMetaObject::invokeMethod(fixtureItem, "setShutter",
Q_ARG(QVariant, capPreset),
Q_ARG(QVariant, low), Q_ARG(QVariant, high));
}
break;
default:
break;
}
Expand Down
79 changes: 64 additions & 15 deletions qmlui/qml/fixturesfunctions/3DView/Fixture3DItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Entity
property vector3d direction: Qt.vector3d(0, -1, 0)
property real cutOff: focusMinDegrees / 2

property real intensityOrigValue: intensity

onFixtureIDChanged: isSelected = contextManager.isFixtureSelected(fixtureID)

//onPanTransformChanged: console.log("Pan transform changed " + panTransform)
Expand All @@ -62,12 +64,28 @@ Entity
//onPositionChanged: console.log("Light position changed: " + position)
//onDirectionChanged: console.log("Light direction changed: " + direction)

function bindPanTransform(t, maxDegrees)
{
console.log("Binding pan ----")
fixtureEntity.panTransform = t
fixtureEntity.panMaxDegrees = maxDegrees
t.rotationY = Qt.binding(function() { return panRotation })
}

function bindTiltTransform(t, maxDegrees)
{
console.log("Binding tilt ----")
fixtureEntity.tiltTransform = t
fixtureEntity.tiltMaxDegrees = maxDegrees
tiltRotation = maxDegrees / 2
t.rotationX = Qt.binding(function() { return tiltRotation })
}

function setPosition(pan, tilt)
{
//console.log("[3Ditem] set position " + pan + ", " + tilt)
if (panMaxDegrees)
{

panAnim.stop()
panAnim.from = panRotation
panAnim.to = (panMaxDegrees / 0xFFFF) * pan
Expand All @@ -92,21 +110,40 @@ Entity
cutOff = ((((focusMaxDegrees - focusMinDegrees) / 255) * value) + focusMinDegrees) / 2
}

function bindPanTransform(t, maxDegrees)
{
console.log("Binding pan ----")
fixtureEntity.panTransform = t
fixtureEntity.panMaxDegrees = maxDegrees
t.rotationY = Qt.binding(function() { return panRotation })
}

function bindTiltTransform(t, maxDegrees)
function setShutter(type, low, high)
{
console.log("Binding tilt ----")
fixtureEntity.tiltTransform = t
fixtureEntity.tiltMaxDegrees = maxDegrees
tiltRotation = maxDegrees / 2
t.rotationX = Qt.binding(function() { return tiltRotation })
console.log("Shutter " + low + ", " + high)
shutterAnim.stop()
inPhase.duration = 0
highPhase.duration = 0
outPhase.duration = 0
lowPhase.duration = low

switch(type)
{
case QLCCapability.ShutterOpen:
intensity = intensityOrigValue
break;
case QLCCapability.ShutterClose:
intensityOrigValue = intensity
intensity = 0
break;
case QLCCapability.StrobeFastToSlow:
case QLCCapability.StrobeSlowToFast:
highPhase.duration = high
shutterAnim.start()
break;
case QLCCapability.PulseInFastToSlow:
case QLCCapability.PulseInSlowToFast:
inPhase.duration = high
shutterAnim.start()
break;
case QLCCapability.PulseOutSlowToFast:
case QLCCapability.PulseOutFastToSlow:
outPhase.duration = high
shutterAnim.start()
break;
}
}

QQ2.NumberAnimation on panRotation
Expand All @@ -123,6 +160,18 @@ Entity
easing.type: Easing.Linear
}

// strobe/pulse effect
QQ2.SequentialAnimation on intensity
{
id: shutterAnim
running: true
loops: QQ2.Animation.Infinite
QQ2.NumberAnimation { id: inPhase; from: 0; to: 1.0; duration: 0; easing.type: Easing.Linear }
QQ2.NumberAnimation { id: highPhase; from: 1.0; to: 1.0; duration: 200; easing.type: Easing.Linear }
QQ2.NumberAnimation { id: outPhase; from: 1.0; to: 0; duration: 0; easing.type: Easing.Linear }
QQ2.NumberAnimation { id: lowPhase; from: 0; to: 0; duration: 800; easing.type: Easing.Linear }
}

property Transform transform: Transform { }

SceneLoader
Expand Down

0 comments on commit 1fe4148

Please sign in to comment.