Skip to content

Commit

Permalink
qmlui: add center position helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Dec 28, 2023
1 parent 5edb371 commit 3d891a8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 31 deletions.
9 changes: 6 additions & 3 deletions qmlui/contextmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,12 @@ void ContextManager::setPositionValue(int type, int degrees, bool isRelative)
}
}

void ContextManager::setPositionCenter()
{
setChannelValueByType((int)QLCChannel::Pan, 127);
setChannelValueByType((int)QLCChannel::Tilt, 127);
}

void ContextManager::setBeamDegrees(float degrees, bool isRelative)
{
// list to keep track of the already processed Fixture IDs
Expand Down Expand Up @@ -1529,9 +1535,6 @@ void ContextManager::highlightFixtureSelection()
setChannelValueByType((int)QLCChannel::Blue, UCHAR_MAX);
setChannelValueByType((int)QLCChannel::White, UCHAR_MAX);

setChannelValueByType((int)QLCChannel::Pan, 127);
setChannelValueByType((int)QLCChannel::Tilt, 127);

setChannelValueByType((int)QLCChannel::Intensity, UCHAR_MAX);

// search for shutter open and lamp on
Expand Down
3 changes: 3 additions & 0 deletions qmlui/contextmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public slots:
/** Set a Pan/Tilt position in degrees */
Q_INVOKABLE void setPositionValue(int type, int degrees, bool isRelative);

/** Set Pan/Tilt values at half position */
Q_INVOKABLE void setPositionCenter();

/** Set a zoom channel in degrees */
Q_INVOKABLE void setBeamDegrees(float degrees, bool isRelative);

Expand Down
85 changes: 57 additions & 28 deletions qmlui/qml/fixturesfunctions/PositionTool.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,41 @@ Rectangle

signal close()

onVisibleChanged:
function updatePanTiltDegrees()
{
if (visible)
previousPanDegrees = 0
previousTiltDegrees = 0

var pan = contextManager.getCurrentValue(QLCChannel.Pan, true)
if (pan === -1)
{
relativePanValue = true
panDegrees = 0
}
else
{
previousPanDegrees = 0
previousTiltDegrees = 0
relativePanValue = false
panDegrees = Math.round(pan)
}

var pan = contextManager.getCurrentValue(QLCChannel.Pan, true)
if (pan === -1)
{
relativePanValue = true
panDegrees = 0
}
else
{
relativePanValue = false
panDegrees = Math.round(pan)
}
var tilt = contextManager.getCurrentValue(QLCChannel.Tilt, true)
if (tilt === -1)
{
relativeTiltValue = true
tiltDegrees = 0
}
else
{
relativeTiltValue = false
tiltDegrees = Math.round(tilt)
}
}

var tilt = contextManager.getCurrentValue(QLCChannel.Tilt, true)
if (tilt === -1)
{
relativeTiltValue = true
tiltDegrees = 0
}
else
{
relativeTiltValue = false
tiltDegrees = Math.round(tilt)
}
onVisibleChanged:
{
if (visible)
{
updatePanTiltDegrees()
}
else
{
Expand Down Expand Up @@ -229,12 +234,11 @@ Rectangle

IconButton
{
id: rotateButton
x: parent.width - width - 2
y: posToolBar.height
z: 2
imgSource: "qrc:/rotate-right.svg"
tooltip: qsTr("Rotate 90° clockwise")
tooltip: qsTr("Rotate preview 90° clockwise")
onClicked:
{
gCanvas.rotation += 90
Expand All @@ -243,6 +247,31 @@ Rectangle
}
}

Timer
{
id: updTimer
running: false
interval: 100
repeat: false
onTriggered: updatePanTiltDegrees()
}

IconButton
{
x: parent.width - width - 2
y: gCanvas.y + gCanvas.height - width
z: 2
//width: iconSize
//height: iconSize
faSource: FontAwesome.fa_bullseye
tooltip: qsTr("Center Pan/Tilt halfway")
onClicked:
{
contextManager.setPositionCenter()
updTimer.restart()
}
}

Canvas
{
id: gCanvas
Expand Down

0 comments on commit 3d891a8

Please sign in to comment.