[LYN-3160] Removed IEditor::Get/SetEditMode and some additional unused (related) content in the InfoBar.
This commit is contained in:
@@ -30,6 +30,8 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_InfoBar.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
#include <AzQtComponents/Components/Style.h>
|
||||
|
||||
#include "CryPhysicsDeprecation.h"
|
||||
@@ -52,10 +54,6 @@ CInfoBar::CInfoBar(QWidget* parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_enabledVector = false;
|
||||
m_bVectorLock = false;
|
||||
m_prevEditMode = 0;
|
||||
m_bSelectionLocked = false;
|
||||
m_bSelectionChanged = false;
|
||||
m_bDragMode = false;
|
||||
m_prevMoveSpeed = 0;
|
||||
@@ -70,25 +68,14 @@ CInfoBar::CInfoBar(QWidget* parent)
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(ui->m_vectorLock, &QToolButton::clicked, this, &CInfoBar::OnVectorLock);
|
||||
connect(ui->m_lockSelection, &QToolButton::clicked, this, &CInfoBar::OnLockSelection);
|
||||
|
||||
auto comboBoxTextChanged = static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged);
|
||||
connect(ui->m_moveSpeed, comboBoxTextChanged, this, &CInfoBar::OnUpdateMoveSpeedText);
|
||||
connect(ui->m_moveSpeed->lineEdit(), &QLineEdit::returnPressed, this, &CInfoBar::OnSpeedComboBoxEnter);
|
||||
|
||||
connect(ui->m_posCtrl, &AzQtComponents::VectorInput::valueChanged, this, &CInfoBar::OnVectorChanged);
|
||||
|
||||
// Hide some buttons from the expander menu
|
||||
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
|
||||
AzQtComponents::Style::addClass(ui->m_physDoStepBtn, "expanderMenu_hide");
|
||||
AzQtComponents::Style::addClass(ui->m_physSingleStepBtn, "expanderMenu_hide");
|
||||
|
||||
// posCtrl is a VectorInput initialized via UI; as such, we can't construct it to have only 3 elements.
|
||||
// We can just hide the W element as it is unused.
|
||||
ui->m_posCtrl->getElements()[3]->setVisible(false);
|
||||
|
||||
connect(ui->m_setVector, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSetVector);
|
||||
connect(ui->m_physicsBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedPhysics);
|
||||
connect(ui->m_physSingleStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSingleStepPhys);
|
||||
connect(ui->m_physDoStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedDoStepPhys);
|
||||
@@ -99,12 +86,6 @@ CInfoBar::CInfoBar(QWidget* parent)
|
||||
|
||||
connect(this, &CInfoBar::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered);
|
||||
|
||||
connect(ui->m_lockSelection, &QAbstractButton::toggled, ui->m_lockSelection, [this](bool checked) {
|
||||
ui->m_lockSelection->setToolTip(checked ? tr("Unlock Object Selection") : tr("Lock Object Selection"));
|
||||
});
|
||||
connect(ui->m_vectorLock, &QAbstractButton::toggled, ui->m_vectorLock, [this](bool checked) {
|
||||
ui->m_vectorLock->setToolTip(checked ? tr("Unlock Axis Vectors") : tr("Lock Axis Vectors"));
|
||||
});
|
||||
connect(ui->m_physicsBtn, &QAbstractButton::toggled, ui->m_physicsBtn, [this](bool checked) {
|
||||
ui->m_physicsBtn->setToolTip(checked ? tr("Stop Simulation (Ctrl+P)") : tr("Simulate (Ctrl+P)"));
|
||||
});
|
||||
@@ -121,27 +102,6 @@ CInfoBar::CInfoBar(QWidget* parent)
|
||||
ui->m_vrBtn->setToolTip(checked ? tr("Disable VR Preview") : tr("Enable VR Preview"));
|
||||
});
|
||||
|
||||
// hide old ui elements that are not valid with the new viewport interaction model
|
||||
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
{
|
||||
ui->m_lockSelection->setVisible(false);
|
||||
AzQtComponents::Style::addClass(ui->m_lockSelection, "expanderMenu_hide");
|
||||
ui->m_posCtrl->setVisible(false);
|
||||
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
|
||||
ui->m_setVector->setVisible(false);
|
||||
AzQtComponents::Style::addClass(ui->m_setVector, "expanderMenu_hide");
|
||||
ui->m_vectorLock->setVisible(false);
|
||||
AzQtComponents::Style::addClass(ui->m_vectorLock, "expanderMenu_hide");
|
||||
|
||||
// As we're hiding some of the icons, we have an extra spacer to deal with.
|
||||
// We cannot set the visibility of separators, so we'll have to take it out.
|
||||
int separatorIndex = layout()->indexOf(ui->verticalSpacer_2);
|
||||
QLayoutItem* separator = layout()->takeAt(separatorIndex);
|
||||
|
||||
// takeAt() removes the item from the layout; delete to avoid memory leaks.
|
||||
delete separator;
|
||||
}
|
||||
|
||||
ui->m_moveSpeed->setValidator(new QDoubleValidator(m_minSpeed, m_maxSpeed, m_numDecimals, ui->m_moveSpeed));
|
||||
|
||||
// Save off the move speed here since setting up the combo box can cause it to update values in the background.
|
||||
@@ -207,150 +167,6 @@ void CInfoBar::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
m_bSelectionChanged = true;
|
||||
}
|
||||
else if (event == eNotify_OnEditModeChange)
|
||||
{
|
||||
int emode = GetIEditor()->GetEditMode();
|
||||
switch (emode)
|
||||
{
|
||||
case eEditModeMove:
|
||||
ui->m_setVector->setToolTip(tr("Set Position of Selected Objects"));
|
||||
break;
|
||||
case eEditModeRotate:
|
||||
ui->m_setVector->setToolTip(tr("Set Rotation of Selected Objects"));
|
||||
break;
|
||||
case eEditModeScale:
|
||||
ui->m_setVector->setToolTip(tr("Set Scale of Selected Objects"));
|
||||
break;
|
||||
default:
|
||||
ui->m_setVector->setToolTip(tr("Set Position/Rotation/Scale of Selected Objects (None Selected)"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CInfoBar::OnVectorChanged()
|
||||
{
|
||||
SetVector(GetVector());
|
||||
OnVectorUpdate(false);
|
||||
}
|
||||
|
||||
void CInfoBar::OnVectorUpdate(bool followTerrain)
|
||||
{
|
||||
int emode = GetIEditor()->GetEditMode();
|
||||
if (emode != eEditModeMove && emode != eEditModeRotate && emode != eEditModeScale)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 v = GetVector();
|
||||
|
||||
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
|
||||
if (pManipulator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CSelectionGroup* selection = GetIEditor()->GetObjectManager()->GetSelection();
|
||||
if (selection->IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetIEditor()->RestoreUndo();
|
||||
|
||||
int referenceCoordSys = GetIEditor()->GetReferenceCoordSys();
|
||||
|
||||
CBaseObject* obj = GetIEditor()->GetSelectedObject();
|
||||
|
||||
Matrix34 tm;
|
||||
AffineParts ap;
|
||||
if (obj)
|
||||
{
|
||||
tm = obj->GetWorldTM();
|
||||
ap.SpectralDecompose(tm);
|
||||
}
|
||||
|
||||
if (emode == eEditModeMove)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
if (referenceCoordSys == COORDS_WORLD)
|
||||
{
|
||||
tm.SetTranslation(v);
|
||||
obj->SetWorldTM(tm);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->SetPos(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetIEditor()->GetSelection()->MoveTo(v, followTerrain ? CSelectionGroup::eMS_FollowTerrain : CSelectionGroup::eMS_None, referenceCoordSys);
|
||||
}
|
||||
}
|
||||
if (emode == eEditModeRotate)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
AZ::Vector3 av = LYVec3ToAZVec3(v);
|
||||
AZ::Transform tr = AZ::ConvertEulerDegreesToTransform(av);
|
||||
Matrix34 lyTransform = AZTransformToLYTransform(tr);
|
||||
|
||||
AffineParts newap;
|
||||
newap.SpectralDecompose(lyTransform);
|
||||
|
||||
if (referenceCoordSys == COORDS_WORLD)
|
||||
{
|
||||
tm = Matrix34::Create(ap.scale, newap.rot, ap.pos);
|
||||
obj->SetWorldTM(tm);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->SetRotation(newap.rot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CBaseObject *refObj;
|
||||
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
|
||||
if (pGroup && pGroup->GetCount() > 0)
|
||||
{
|
||||
refObj = pGroup->GetObject(0);
|
||||
AffineParts ap2;
|
||||
ap2.SpectralDecompose(refObj->GetWorldTM());
|
||||
Vec3 oldEulerRotation = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(ap2.rot)));
|
||||
Vec3 diff = v - oldEulerRotation;
|
||||
GetIEditor()->GetSelection()->Rotate((Ang3)diff, referenceCoordSys);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (emode == eEditModeScale)
|
||||
{
|
||||
if (v.x == 0 || v.y == 0 || v.z == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj)
|
||||
{
|
||||
if (referenceCoordSys == COORDS_WORLD)
|
||||
{
|
||||
tm = Matrix34::Create(v, ap.rot, ap.pos);
|
||||
obj->SetWorldTM(tm);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->SetScale(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetIEditor()->GetSelection()->SetScale(v, referenceCoordSys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBar::IdleUpdate()
|
||||
@@ -375,21 +191,6 @@ void CInfoBar::IdleUpdate()
|
||||
|
||||
Vec3 marker = GetIEditor()->GetMarkerPosition();
|
||||
|
||||
/*
|
||||
// Get active viewport.
|
||||
int hx = marker.x / 2;
|
||||
int hy = marker.y / 2;
|
||||
if (m_heightMapX != hx || m_heightMapY != hy)
|
||||
{
|
||||
m_heightMapX = hx;
|
||||
m_heightMapY = hy;
|
||||
updateUI = true;
|
||||
}
|
||||
*/
|
||||
|
||||
RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys();
|
||||
bool bWorldSpace = GetIEditor()->GetReferenceCoordSys() == COORDS_WORLD;
|
||||
|
||||
CSelectionGroup* selection = GetIEditor()->GetSelection();
|
||||
if (selection->GetCount() != m_numSelected)
|
||||
{
|
||||
@@ -447,198 +248,11 @@ void CInfoBar::IdleUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
bool bSelLocked = GetIEditor()->IsSelectionLocked();
|
||||
if (bSelLocked != m_bSelectionLocked)
|
||||
{
|
||||
m_bSelectionLocked = bSelLocked;
|
||||
ui->m_lockSelection->setChecked(m_bSelectionLocked);
|
||||
}
|
||||
|
||||
|
||||
if (GetIEditor()->GetSelection()->IsEmpty())
|
||||
{
|
||||
if (ui->m_lockSelection->isEnabled())
|
||||
{
|
||||
ui->m_lockSelection->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ui->m_lockSelection->isEnabled())
|
||||
{
|
||||
ui->m_lockSelection->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Update vector.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 v(0, 0, 0);
|
||||
bool enable = false;
|
||||
float min = 0, max = 10000;
|
||||
|
||||
int emode = GetIEditor()->GetEditMode();
|
||||
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
|
||||
|
||||
if (pManipulator)
|
||||
{
|
||||
AffineParts ap;
|
||||
ap.SpectralDecompose(pManipulator->GetTransformation(coordSys));
|
||||
|
||||
if (emode == eEditModeMove)
|
||||
{
|
||||
v = ap.pos;
|
||||
enable = true;
|
||||
|
||||
min = -64000;
|
||||
max = 64000;
|
||||
}
|
||||
if (emode == eEditModeRotate)
|
||||
{
|
||||
v = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot))));
|
||||
enable = true;
|
||||
min = -10000;
|
||||
max = 10000;
|
||||
}
|
||||
if (emode == eEditModeScale)
|
||||
{
|
||||
v = ap.scale;
|
||||
enable = true;
|
||||
min = -10000;
|
||||
max = 10000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selection->IsEmpty())
|
||||
{
|
||||
// Show marker position.
|
||||
EnableVector(false);
|
||||
SetVector(marker);
|
||||
SetVectorRange(-100000, 100000);
|
||||
return;
|
||||
}
|
||||
|
||||
CBaseObject* obj = GetIEditor()->GetSelectedObject();
|
||||
if (!obj)
|
||||
{
|
||||
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
|
||||
if (pGroup && pGroup->GetCount() > 0)
|
||||
{
|
||||
obj = pGroup->GetObject(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (obj)
|
||||
{
|
||||
v = obj->GetWorldPos();
|
||||
}
|
||||
|
||||
if (emode == eEditModeMove)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
if (bWorldSpace)
|
||||
{
|
||||
v = obj->GetWorldTM().GetTranslation();
|
||||
}
|
||||
else
|
||||
{
|
||||
v = obj->GetPos();
|
||||
}
|
||||
}
|
||||
enable = true;
|
||||
min = -64000;
|
||||
max = 64000;
|
||||
}
|
||||
if (emode == eEditModeRotate)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
Quat objRot;
|
||||
if (bWorldSpace)
|
||||
{
|
||||
AffineParts ap;
|
||||
ap.SpectralDecompose(obj->GetWorldTM());
|
||||
objRot = ap.rot;
|
||||
}
|
||||
else
|
||||
{
|
||||
objRot = obj->GetRotation();
|
||||
}
|
||||
|
||||
// Always convert objRot to v in order to ensure that the inspector and info bar are always in sync
|
||||
v = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(objRot)));
|
||||
}
|
||||
enable = true;
|
||||
min = -10000;
|
||||
max = 10000;
|
||||
}
|
||||
if (emode == eEditModeScale)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
if (bWorldSpace)
|
||||
{
|
||||
AffineParts ap;
|
||||
ap.SpectralDecompose(obj->GetWorldTM());
|
||||
v = ap.scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = obj->GetScale();
|
||||
}
|
||||
}
|
||||
enable = true;
|
||||
min = -10000;
|
||||
max = 10000;
|
||||
}
|
||||
}
|
||||
|
||||
bool updateDisplayVector = (m_currValue != v);
|
||||
|
||||
// If Edit mode changed.
|
||||
if (m_prevEditMode != emode)
|
||||
{
|
||||
// Scale mode enables vector lock.
|
||||
SetVectorLock(emode == eEditModeScale);
|
||||
|
||||
// Change undo strings.
|
||||
QString undoString("Modify Object(s)");
|
||||
int mode = GetIEditor()->GetEditMode();
|
||||
switch (mode)
|
||||
{
|
||||
case eEditModeMove:
|
||||
undoString = QStringLiteral("Move Object(s)");
|
||||
break;
|
||||
case eEditModeRotate:
|
||||
undoString = QStringLiteral("Rotate Object(s)");
|
||||
break;
|
||||
case eEditModeScale:
|
||||
undoString = QStringLiteral("Scale Object(s)");
|
||||
break;
|
||||
}
|
||||
|
||||
// edit mode changed, we must update the number values
|
||||
updateDisplayVector = true;
|
||||
}
|
||||
|
||||
SetVectorRange(min, max);
|
||||
EnableVector(enable);
|
||||
|
||||
// if our selection changed, or if our display values are out of date
|
||||
if (m_bSelectionChanged)
|
||||
{
|
||||
updateDisplayVector = true;
|
||||
m_bSelectionChanged = false;
|
||||
}
|
||||
|
||||
if (updateDisplayVector)
|
||||
{
|
||||
SetVector(v);
|
||||
}
|
||||
|
||||
m_prevEditMode = emode;
|
||||
}
|
||||
|
||||
inline double Round(double fVal, double fStep)
|
||||
@@ -650,71 +264,6 @@ inline double Round(double fVal, double fStep)
|
||||
return fVal;
|
||||
}
|
||||
|
||||
void CInfoBar::SetVector(const Vec3& v)
|
||||
{
|
||||
if (!m_bDragMode)
|
||||
{
|
||||
m_lastValue = m_currValue;
|
||||
}
|
||||
|
||||
if (m_currValue != v)
|
||||
{
|
||||
ui->m_posCtrl->setValuebyIndex(v.x, 0);
|
||||
ui->m_posCtrl->setValuebyIndex(v.y, 1);
|
||||
ui->m_posCtrl->setValuebyIndex(v.z, 2);
|
||||
m_currValue = v;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3 CInfoBar::GetVector()
|
||||
{
|
||||
Vec3 v;
|
||||
v.x = ui->m_posCtrl->getElements()[0]->getValue();
|
||||
v.y = ui->m_posCtrl->getElements()[1]->getValue();
|
||||
v.z = ui->m_posCtrl->getElements()[2]->getValue();
|
||||
m_currValue = v;
|
||||
return v;
|
||||
}
|
||||
|
||||
void CInfoBar::EnableVector(bool enable)
|
||||
{
|
||||
if (m_enabledVector != enable)
|
||||
{
|
||||
m_enabledVector = enable;
|
||||
ui->m_posCtrl->setEnabled(enable);
|
||||
ui->m_vectorLock->setEnabled(enable);
|
||||
ui->m_setVector->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBar::SetVectorLock(bool bVectorLock)
|
||||
{
|
||||
m_bVectorLock = bVectorLock;
|
||||
ui->m_vectorLock->setChecked(bVectorLock);
|
||||
GetIEditor()->SetAxisVectorLock(bVectorLock);
|
||||
}
|
||||
|
||||
void CInfoBar::SetVectorRange(float min, float max)
|
||||
{
|
||||
// Worth noting that this gets called every IdleUpdate, so it is necessary to make sure
|
||||
// setting the min/max doesn't result in the Qt event queue being pumped
|
||||
ui->m_posCtrl->setMinimum(min);
|
||||
ui->m_posCtrl->setMaximum(max);
|
||||
}
|
||||
|
||||
void CInfoBar::OnVectorLock()
|
||||
{
|
||||
SetVectorLock(!m_bVectorLock);
|
||||
}
|
||||
|
||||
void CInfoBar::OnLockSelection()
|
||||
{
|
||||
bool newLockSelectionValue = !m_bSelectionLocked;
|
||||
m_bSelectionLocked = newLockSelectionValue;
|
||||
ui->m_lockSelection->setChecked(newLockSelectionValue);
|
||||
GetIEditor()->LockSelection(newLockSelectionValue);
|
||||
}
|
||||
|
||||
void CInfoBar::OnUpdateMoveSpeedText(const QString& text)
|
||||
{
|
||||
gSettings.cameraMoveSpeed = aznumeric_cast<float>(Round(text.toDouble(), m_speedStep));
|
||||
@@ -730,12 +279,6 @@ void CInfoBar::OnInitDialog()
|
||||
QFontMetrics metrics({});
|
||||
int width = metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier;
|
||||
|
||||
ui->m_posCtrl->setEnabled(false);
|
||||
ui->m_posCtrl->getElements()[0]->setFixedWidth(width);
|
||||
ui->m_posCtrl->getElements()[1]->setFixedWidth(width);
|
||||
ui->m_posCtrl->getElements()[2]->setFixedWidth(width);
|
||||
ui->m_setVector->setEnabled(false);
|
||||
|
||||
ui->m_moveSpeed->setFixedWidth(width);
|
||||
|
||||
ui->m_physicsBtn->setEnabled(false);
|
||||
@@ -809,12 +352,6 @@ void CInfoBar::OnBnClickedGotoPosition()
|
||||
emit ActionTriggered(ID_DISPLAY_GOTOPOSITION);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInfoBar::OnBnClickedSetVector()
|
||||
{
|
||||
emit ActionTriggered(ID_DISPLAY_SETVECTOR);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInfoBar::OnBnClickedMuteAudio()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user