Skip to content

Commit

Permalink
qmlui: a few improvements on rotations and bars
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 16, 2018
1 parent 9ee0aae commit 3754389
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 15 deletions.
26 changes: 18 additions & 8 deletions qmlui/fixturemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,31 +1159,41 @@ bool FixtureManager::addRGBPanel(QString name, qreal xPos, qreal yPos)
}

QVector3D pos;
QVector3D rot;
QVector3D rot = QVector3D(0, 0, 0);
float gridUnits = m_monProps->gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8;

switch (m_monProps->pointOfView())
{
case MonitorProperties::TopView:
pos = QVector3D(xPos, 0, yPos);
rot.setY(180);
pos = QVector3D(xPos, 1000, yPos);
if (displacement == Snake && i % 2)
rot.setY(180);
break;
case MonitorProperties::LeftSideView:
pos = QVector3D(0, yPos, xPos);
rot.setX(180);
if (displacement == Snake && i % 2)
rot.setY(-90);
else
rot.setY(90);
rot.setZ(-90);
break;
case MonitorProperties::RightSideView:
pos = QVector3D(0, yPos, (m_monProps->gridSize().z() * gridUnits) - xPos);
rot.setX(180);
if (displacement == Snake && i % 2)
rot.setY(90);
else
rot.setY(-90);
rot.setZ(90);
break;
default:
pos = QVector3D(xPos, (m_monProps->gridSize().y() * gridUnits) - yPos, 0);
rot.setZ(180);
if (displacement == Snake && i % 2)
rot.setZ(180);
rot.setX(-90);
break;
}
m_monProps->setFixturePosition(fxi->id(), 0, 0, pos);
if (displacement == Snake && i % 2)
m_monProps->setFixtureRotation(fxi->id(), 0, 0, rot);
m_monProps->setFixtureRotation(fxi->id(), 0, 0, rot);
slotFixtureAdded(fxi->id(), QVector3D(pos.x(), pos.y(), pos.z()));
yPos += (qreal)phyHeight;
currRow += rowInc;
Expand Down
32 changes: 31 additions & 1 deletion qmlui/mainview2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ void MainView2D::createFixtureItem(quint32 fxID, quint16 headIndex, quint16 link
QVector3D newPos = FixtureUtils::item3DPosition(m_monProps, itemPos, 1000.0);
m_monProps->setFixturePosition(fxID, headIndex, linkedIndex, newPos);
m_monProps->setFixtureFlags(fxID, headIndex, linkedIndex, 0);
if (fixture->type() == QLCFixtureDef::LEDBarPixels)
{
switch (m_monProps->pointOfView())
{
case MonitorProperties::FrontView:
m_monProps->setFixtureRotation(fxID, headIndex, linkedIndex, QVector3D(90, 0, 0));
break;
case MonitorProperties::LeftSideView:
m_monProps->setFixtureRotation(fxID, headIndex, linkedIndex, QVector3D(0, -90, 0));
break;
case MonitorProperties::RightSideView:
m_monProps->setFixtureRotation(fxID, headIndex, linkedIndex, QVector3D(0, 90, 0));
break;
default:
break;
}
}
Tardis::instance()->enqueueAction(Tardis::FixtureSetPosition, itemID, QVariant(QVector3D(0, 0, 0)), QVariant(newPos));
}

Expand Down Expand Up @@ -561,7 +578,20 @@ void MainView2D::updateFixtureRotation(quint32 itemID, QVector3D degrees)
return;

QQuickItem *fxItem = m_itemsMap[itemID];
fxItem->setProperty("rotation", degrees.y());

switch(m_monProps->pointOfView())
{
case MonitorProperties::FrontView:
fxItem->setProperty("rotation", degrees.z());
break;
case MonitorProperties::LeftSideView:
case MonitorProperties::RightSideView:
fxItem->setProperty("rotation", degrees.x());
break;
default:
fxItem->setProperty("rotation", degrees.y());
break;
}
}

void MainView2D::updateFixturePosition(quint32 itemID, QVector3D pos)
Expand Down
41 changes: 35 additions & 6 deletions qmlui/qml/fixturesfunctions/SettingsView2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,34 @@ Rectangle
lastRotation = Qt.vector3d(0, 0, 0)
}

function updateRotation(x, y, z)
function updateRotation(degrees)
{
if (visible == false)
return;

var rot
switch (View2D.pointOfView)
{
case MonitorProperties.LeftSideView:
case MonitorProperties.RightSideView:
rot = Qt.vector3d(degrees, fxRotation.y, fxRotation.z)
break;
case MonitorProperties.FrontView:
rot = Qt.vector3d(fxRotation.x, fxRotation.y, degrees)
break;
default:
rot = Qt.vector3d(fxRotation.x, degrees, fxRotation.z)
break;
}

if (selFixturesCount == 1)
{
contextManager.fixturesRotation = Qt.vector3d(x, y, z)
contextManager.fixturesRotation = Qt.vector3d(rot.x, rot.y, rot.z)
}
else
{
contextManager.fixturesRotation = Qt.vector3d(x - lastRotation.x, y - lastRotation.y, z - lastRotation.z)
lastRotation = Qt.vector3d(x, y, z)
contextManager.fixturesRotation = Qt.vector3d(rot.x - lastRotation.x, rot.y - lastRotation.y, rot.z - lastRotation.z)
lastRotation = Qt.vector3d(rot.x, rot.y, rot.z)
}
}

Expand Down Expand Up @@ -237,8 +252,22 @@ Rectangle
from: -359
to: 359
suffix: "°"
value: fxRotation.y
onValueChanged: updateRotation(fxRotation.x, value, fxRotation.z)
value:
{
switch (View2D.pointOfView)
{
case MonitorProperties.LeftSideView:
case MonitorProperties.RightSideView:
return fxRotation.x

case MonitorProperties.FrontView:
return fxRotation.z

default:
return fxRotation.y
}
}
onValueChanged: updateRotation(value)
}

// row 3
Expand Down

0 comments on commit 3754389

Please sign in to comment.