Skip to content

Commit

Permalink
qmlui: more Tardis actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 5, 2023
1 parent 6acd398 commit ae6fbb7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
23 changes: 16 additions & 7 deletions qmlui/mainview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ void MainView3D::setItemSelection(int itemID, bool enable, int keyModifiers)

if (enable && keyModifiers == 0)
{
for (int id : m_genericSelectedItems)
for (int &id : m_genericSelectedItems)
{
SceneItem *meshRef = m_genericMap.value(id, nullptr);
if (meshRef)
Expand Down Expand Up @@ -1662,7 +1662,7 @@ int MainView3D::genericSelectedCount() const

void MainView3D::removeSelectedGenericItems()
{
for (int id : m_genericSelectedItems)
for (int &id : m_genericSelectedItems)
{
SceneItem *meshRef = m_genericMap.take(id);
if (meshRef)
Expand All @@ -1679,7 +1679,7 @@ void MainView3D::removeSelectedGenericItems()

void MainView3D::normalizeSelectedGenericItems()
{
for (int id : m_genericSelectedItems)
for (int &id : m_genericSelectedItems)
{
SceneItem *meshRef = m_genericMap.value(id, nullptr);
if (meshRef)
Expand Down Expand Up @@ -1711,7 +1711,7 @@ void MainView3D::updateGenericItemsList()
{
m_genericItemsList->clear();

for (quint32 itemID : m_monProps->genericItemsID())
for (quint32 &itemID : m_monProps->genericItemsID())
{
QVariantMap itemMap;
itemMap.insert("itemID", itemID);
Expand All @@ -1733,6 +1733,9 @@ void MainView3D::updateGenericItemPosition(quint32 itemID, QVector3D pos)
if (isEnabled() == false)
return;

QVector3D currPos = m_monProps->itemPosition(itemID);
Tardis::instance()->enqueueAction(Tardis::GenericItemSetPosition, itemID, QVariant(currPos), QVariant(pos));

m_monProps->setItemPosition(itemID, pos);

SceneItem *item = m_genericMap.value(itemID, nullptr);
Expand Down Expand Up @@ -1765,7 +1768,7 @@ void MainView3D::setGenericItemsPosition(QVector3D pos)
else
{
// relative position change
for (int itemID : m_genericSelectedItems)
for (int &itemID : m_genericSelectedItems)
{
QVector3D newPos = m_monProps->itemPosition(itemID) + pos;
updateGenericItemPosition(itemID, newPos);
Expand All @@ -1780,6 +1783,9 @@ void MainView3D::updateGenericItemRotation(quint32 itemID, QVector3D rot)
if (isEnabled() == false)
return;

QVector3D currRot = m_monProps->itemRotation(itemID);
Tardis::instance()->enqueueAction(Tardis::GenericItemSetRotation, itemID, QVariant(currRot), QVariant(rot));

m_monProps->setItemRotation(itemID, rot);
SceneItem *item = m_genericMap.value(itemID, nullptr);
if (item == nullptr || item->m_rootTransform == nullptr)
Expand Down Expand Up @@ -1812,7 +1818,7 @@ void MainView3D::setGenericItemsRotation(QVector3D rot)
else
{
// relative position change
for (int itemID : m_genericSelectedItems)
for (int &itemID : m_genericSelectedItems)
{
QVector3D newRot = m_monProps->itemRotation(itemID) + rot;

Expand All @@ -1837,6 +1843,9 @@ void MainView3D::updateGenericItemScale(quint32 itemID, QVector3D scale)
if (isEnabled() == false)
return;

QVector3D currScale = m_monProps->itemScale(itemID);
Tardis::instance()->enqueueAction(Tardis::GenericItemSetScale, itemID, QVariant(currScale), QVariant(scale));

m_monProps->setItemScale(itemID, scale);
SceneItem *item = m_genericMap.value(itemID, nullptr);
if (item == nullptr || item->m_rootTransform == nullptr)
Expand Down Expand Up @@ -1870,7 +1879,7 @@ void MainView3D::setGenericItemsScale(QVector3D scale)
}
else
{
for (int itemID : m_genericSelectedItems)
for (int &itemID : m_genericSelectedItems)
{
QVector3D newScale = m_monProps->itemScale(itemID) + normScale;
updateGenericItemScale(itemID, newScale);
Expand Down
16 changes: 16 additions & 0 deletions qmlui/tardis/tardis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "functionmanager.h"
#include "contextmanager.h"
#include "mainview2d.h"
#include "mainview3d.h"
#include "simpledesk.h"
#include "collection.h"
#include "rgbmatrix.h"
Expand Down Expand Up @@ -561,6 +562,21 @@ int Tardis::processAction(TardisAction &action, bool undo)
m_contextManager->setFixtureRotation(action.m_objID, rotation);
}
break;
case GenericItemSetPosition:
{
m_contextManager->get3DView()->updateGenericItemPosition(action.m_objID, value->value<QVector3D>());
}
break;
case GenericItemSetRotation:
{
m_contextManager->get3DView()->updateGenericItemRotation(action.m_objID, value->value<QVector3D>());
}
break;
case GenericItemSetScale:
{
m_contextManager->get3DView()->updateGenericItemScale(action.m_objID, value->value<QVector3D>());
}
break;

/* *********************** Input/Output manager actions ************************ */
case IOAddUniverse:
Expand Down

0 comments on commit ae6fbb7

Please sign in to comment.