Remove all references to old CGrid system (#672)
* add overload to ActionManager to support capturing an AZStd::function * move snapping settings to new settings registry * remove unneeded reference in ViewportSettings * move viewport setting function implementations to .cpp file * add more sensible default values for snapping * fix variable name for angle snapping * remove const from function prototype value parameters * add import/export api for free functions * change from std::bind to a lambda * remove redundant const for constexpr string_view * add AZStd alias for std::abs * restore grid and angle snapping * add overload to ActionManager to support capturing an AZStd::function * remove old legacy CGrid code * fix build after merge * review feedback changes - remove 1.0f multiplies
This commit is contained in:
committed by
GitHub
parent
b5e5a3bfee
commit
b185a94519
@@ -660,9 +660,7 @@ void Q2DViewport::Draw(DisplayContext& dc)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
float gridSize = pGrid->size;
|
||||
|
||||
float gridSize = 1.0f;
|
||||
if (gridSize < 0.00001f)
|
||||
{
|
||||
return;
|
||||
@@ -693,8 +691,6 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
while (pixelsPerGrid <= 5 && griditers++ < 20)
|
||||
{
|
||||
m_fGridZoom *= pGrid->majorLine;
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
}
|
||||
}
|
||||
@@ -743,7 +739,7 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Draw Major grid lines.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
gridSize = gridSize * 1.0f;
|
||||
|
||||
if (m_bAutoAdjustGrids)
|
||||
{
|
||||
|
||||
@@ -729,9 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
|
||||
viewportViewsMenuWrapper.AddAction(ID_WIREFRAME);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
if (CViewManager::IsMultiViewportEnabled())
|
||||
{
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT);
|
||||
|
||||
@@ -95,7 +95,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "Core/QtEditorApplication.h"
|
||||
#include "StringDlg.h"
|
||||
#include "NewLevelDialog.h"
|
||||
#include "GridSettingsDialog.h"
|
||||
#include "LayoutConfigDialog.h"
|
||||
#include "ViewManager.h"
|
||||
#include "FileTypeUtils.h"
|
||||
@@ -400,7 +399,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
|
||||
ON_COMMAND(ID_WIREFRAME, OnWireframe)
|
||||
|
||||
ON_COMMAND(ID_VIEW_GRIDSETTINGS, OnViewGridsettings)
|
||||
ON_COMMAND(ID_VIEW_CONFIGURELAYOUT, OnViewConfigureLayout)
|
||||
|
||||
ON_COMMAND(IDC_SELECTION, OnDummyCommand)
|
||||
@@ -3459,14 +3457,6 @@ void CCryEditApp::OnUpdateWireframe(QAction* action)
|
||||
action->setChecked(nWireframe == R_WIREFRAME_MODE);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnViewGridsettings()
|
||||
{
|
||||
CGridSettingsDialog dlg;
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnViewConfigureLayout()
|
||||
{
|
||||
|
||||
@@ -366,7 +366,6 @@ private:
|
||||
|
||||
void OnWireframe();
|
||||
void OnUpdateWireframe(QAction* action);
|
||||
void OnViewGridsettings();
|
||||
void OnViewConfigureLayout();
|
||||
|
||||
// Tag Locations.
|
||||
|
||||
@@ -587,15 +587,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
{
|
||||
viewportContext->SetCameraTransform(LYTransformToAZTransform(tm));
|
||||
}
|
||||
|
||||
// Load grid.
|
||||
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
|
||||
if (gridNode)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -621,11 +612,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
auto viewerAnglesName = QString("ViewerAngles%1").arg(i);
|
||||
view->setAttr(viewerAnglesName.toUtf8().constData(), angles);
|
||||
}
|
||||
|
||||
// Save grid.
|
||||
auto gridName = QString("Grid%1").arg(i);
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "Grid.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid::CGrid()
|
||||
{
|
||||
scale = 1;
|
||||
size = 1;
|
||||
majorLine = 16;
|
||||
bEnabled = true;
|
||||
rotationAngles = Ang3(0.0f, 0.0f, 0.0f);
|
||||
translation = Vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
bAngleSnapEnabled = true;
|
||||
angleSnap = 5;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Vec3 snapped;
|
||||
snapped.x = floor((vec.x / size) / scale + 0.5) * size * scale;
|
||||
snapped.y = floor((vec.y / size) / scale + 0.5) * size * scale;
|
||||
snapped.z = floor((vec.z / size) / scale + 0.5) * size * scale;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec, double fZoom) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001f)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
|
||||
Matrix34 tm = GetMatrix();
|
||||
|
||||
double zoomscale = scale * fZoom;
|
||||
Vec3 snapped;
|
||||
|
||||
Matrix34 invtm = tm.GetInverted();
|
||||
|
||||
snapped = invtm * vec;
|
||||
|
||||
snapped.x = floor((snapped.x / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.y = floor((snapped.y / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.z = floor((snapped.z / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
|
||||
snapped = tm * snapped;
|
||||
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
double CGrid::SnapAngle(double angle) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return angle;
|
||||
}
|
||||
return floor(angle / angleSnap + 0.5) * angleSnap;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Ang3 CGrid::SnapAngle(const Ang3& vec) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Ang3 snapped;
|
||||
snapped.x = floor(vec.x / angleSnap + 0.5) * angleSnap;
|
||||
snapped.y = floor(vec.y / angleSnap + 0.5) * angleSnap;
|
||||
snapped.z = floor(vec.z / angleSnap + 0.5) * angleSnap;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGrid::Serialize(XmlNodeRef& xmlNode, bool bLoading)
|
||||
{
|
||||
if (bLoading)
|
||||
{
|
||||
// Loading.
|
||||
xmlNode->getAttr("Size", size);
|
||||
xmlNode->getAttr("Scale", scale);
|
||||
xmlNode->getAttr("Enabled", bEnabled);
|
||||
xmlNode->getAttr("MajorSize", majorLine);
|
||||
xmlNode->getAttr("AngleSnap", angleSnap);
|
||||
xmlNode->getAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
if (size < 0.01)
|
||||
{
|
||||
size = 0.01;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Saving.
|
||||
xmlNode->setAttr("Size", size);
|
||||
xmlNode->setAttr("Scale", scale);
|
||||
xmlNode->setAttr("Enabled", bEnabled);
|
||||
xmlNode->setAttr("MajorSize", majorLine);
|
||||
xmlNode->setAttr("AngleSnap", angleSnap);
|
||||
xmlNode->setAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Matrix34 CGrid::GetMatrix() const
|
||||
{
|
||||
Matrix34 tm;
|
||||
|
||||
if (gSettings.snap.bGridUserDefined)
|
||||
{
|
||||
Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0);
|
||||
|
||||
tm = Matrix33::CreateRotationXYZ(angles);
|
||||
}
|
||||
else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL)
|
||||
{
|
||||
tm.SetIdentity();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.SetIdentity();
|
||||
}
|
||||
|
||||
return tm;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRID_H
|
||||
#define CRYINCLUDE_EDITOR_GRID_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/** Definition of grid used in 2D viewports.
|
||||
*/
|
||||
class SANDBOX_API CGrid
|
||||
{
|
||||
public:
|
||||
//! Resolution of grid, it must be multiply of 2.
|
||||
double size;
|
||||
//! Draw major lines every Nth grid line.
|
||||
int majorLine;
|
||||
//! True if grid enabled.
|
||||
bool bEnabled;
|
||||
//! Meters per grid unit.
|
||||
double scale;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Ang3 rotationAngles;
|
||||
Vec3 translation;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
//! If snap to angle.
|
||||
bool bAngleSnapEnabled;
|
||||
double angleSnap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid();
|
||||
|
||||
//! Snap vector to this grid.
|
||||
Vec3 Snap(const Vec3& vec) const;
|
||||
Vec3 Snap(const Vec3& vec, double fZoom) const;
|
||||
|
||||
//! Snap angle to current angle snapping value.
|
||||
double SnapAngle(double angle) const;
|
||||
//! Snap angle to current angle snapping value.
|
||||
Ang3 SnapAngle(const Ang3& angle) const;
|
||||
|
||||
//! Enable or disable grid.
|
||||
void Enable(bool enable) { bEnabled = enable; }
|
||||
//! Check if grid enabled.
|
||||
bool IsEnabled() const { return bEnabled; }
|
||||
|
||||
//! Enables or disable angle snapping.
|
||||
void EnableAngleSnap(bool enable) { bAngleSnapEnabled = enable; };
|
||||
|
||||
//! Return if snapping of angle is enabled.
|
||||
bool IsAngleSnapEnabled() const { return bAngleSnapEnabled; };
|
||||
//! Returns ammount of snapping for angle in degrees.
|
||||
double GetAngleSnap() const { return angleSnap; };
|
||||
|
||||
void Serialize(XmlNodeRef& xmlNode, bool bLoading);
|
||||
|
||||
//! Get transformation matrix of gird.
|
||||
Matrix34 GetMatrix() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRID_H
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "GridSettingsDialog.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_GridSettingsDialog.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
, ui(new Ui::CGridSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle(tr("Grid/Snap Settings"));
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject);
|
||||
|
||||
auto doubleSpinBoxValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
|
||||
|
||||
connect(ui->m_angleX, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleY, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleZ, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_gridSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_gridScale, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_CPSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_displayCP, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &CGridSettingsDialog::accept);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &CGridSettingsDialog::reject);
|
||||
}
|
||||
|
||||
CGridSettingsDialog::~CGridSettingsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnInitDialog()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
ui->m_userDefined->setChecked(gSettings.snap.bGridUserDefined);
|
||||
ui->m_getFromObject->setChecked(gSettings.snap.bGridGetFromSelected);
|
||||
|
||||
ui->m_angleX->setValue(pGrid->rotationAngles.x);
|
||||
ui->m_angleY->setValue(pGrid->rotationAngles.y);
|
||||
ui->m_angleZ->setValue(pGrid->rotationAngles.z);
|
||||
|
||||
ui->m_translationX->setValue(pGrid->translation.x);
|
||||
ui->m_translationY->setValue(pGrid->translation.y);
|
||||
ui->m_translationZ->setValue(pGrid->translation.z);
|
||||
|
||||
ui->m_gridSize->setValue(pGrid->size);
|
||||
ui->m_gridScale->setValue(pGrid->scale);
|
||||
ui->m_snapToGrid->setChecked(pGrid->IsEnabled());
|
||||
|
||||
ui->m_angleSnap->setChecked(pGrid->IsAngleSnapEnabled());
|
||||
ui->m_angleSnapScale->setValue(pGrid->GetAngleSnap());
|
||||
ui->m_displayCP->setChecked(gSettings.snap.constructPlaneDisplay);
|
||||
|
||||
ui->m_CPSize->setValue(gSettings.snap.constructPlaneSize);
|
||||
ui->m_displaySnapMarker->setChecked(gSettings.snap.markerDisplay);
|
||||
ui->m_snapMarkerSize->setValue(gSettings.snap.markerSize);
|
||||
|
||||
ui->m_snapMarkerColor->SetColor(gSettings.snap.markerColor);
|
||||
|
||||
EnableGridPropertyControls(gSettings.snap.bGridUserDefined, gSettings.snap.bGridGetFromSelected);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::accept()
|
||||
{
|
||||
UpdateValues();
|
||||
gSettings.Save();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnUserDefined()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
OnValueUpdate();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnGetFromObject()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject)
|
||||
{
|
||||
ui->m_getFromObject->setEnabled(isUserDefined == true);
|
||||
|
||||
ui->m_angleX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getAnglesFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getTranslationFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::UpdateValues()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
pGrid->Enable(ui->m_snapToGrid->isChecked());
|
||||
pGrid->size = ui->m_gridSize->value();
|
||||
pGrid->scale = ui->m_gridScale->value();
|
||||
|
||||
gSettings.snap.bGridUserDefined = ui->m_userDefined->isChecked();
|
||||
gSettings.snap.bGridGetFromSelected = ui->m_getFromObject->isChecked();
|
||||
pGrid->rotationAngles.x = ui->m_angleX->value();
|
||||
pGrid->rotationAngles.y = ui->m_angleY->value();
|
||||
pGrid->rotationAngles.z = ui->m_angleZ->value();
|
||||
pGrid->translation.x = ui->m_translationX->value();
|
||||
pGrid->translation.y = ui->m_translationY->value();
|
||||
pGrid->translation.z = ui->m_translationZ->value();
|
||||
|
||||
pGrid->bAngleSnapEnabled = ui->m_angleSnap->isChecked();
|
||||
pGrid->angleSnap = ui->m_angleSnapScale->value();
|
||||
|
||||
gSettings.snap.constructPlaneDisplay = ui->m_displayCP->isChecked();
|
||||
gSettings.snap.constructPlaneSize = ui->m_CPSize->value();
|
||||
|
||||
gSettings.snap.markerDisplay = ui->m_displaySnapMarker->isChecked();
|
||||
gSettings.snap.markerSize = ui->m_snapMarkerSize->value();
|
||||
gSettings.snap.markerColor = ui->m_snapMarkerColor->Color();
|
||||
|
||||
NotificationBus::Broadcast(&Notifications::OnGridValuesUpdated);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnValueUpdate()
|
||||
{
|
||||
UpdateValues();
|
||||
GetIEditor()->UpdateViews(eRedrawViewports);
|
||||
}
|
||||
|
||||
#include <moc_GridSettingsDialog.cpp>
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
#define CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#endif
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
namespace Ui {
|
||||
class CGridSettingsDialog;
|
||||
}
|
||||
|
||||
class CGridSettingsDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
class Notifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
virtual void OnGridValuesUpdated() {}
|
||||
};
|
||||
|
||||
using NotificationBus = AZ::EBus<Notifications>;
|
||||
|
||||
CGridSettingsDialog(QWidget* pParent = nullptr); // standard constructor
|
||||
virtual ~CGridSettingsDialog();
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
void OnBnUserDefined();
|
||||
void OnBnGetFromObject();
|
||||
void OnValueUpdate();
|
||||
|
||||
private:
|
||||
void EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject);
|
||||
|
||||
void OnInitDialog();
|
||||
void UpdateValues();
|
||||
|
||||
QScopedPointer<Ui::CGridSettingsDialog> ui;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
@@ -1,505 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CGridSettingsDialog</class>
|
||||
<widget class="QDialog" name="CGridSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>307</width>
|
||||
<height>707</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group1">
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_snapToGrid">
|
||||
<property name="text">
|
||||
<string>Snap to Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label1">
|
||||
<property name="text">
|
||||
<string>Grid Lines Every:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label2">
|
||||
<property name="text">
|
||||
<string>units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label3">
|
||||
<property name="text">
|
||||
<string>Units Per Meter:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label4">
|
||||
<property name="text">
|
||||
<string>meters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_userDefined">
|
||||
<property name="text">
|
||||
<string>User Defined Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="m_getFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles And Trans. From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label5">
|
||||
<property name="text">
|
||||
<string>Rotation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="label6">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label7">
|
||||
<property name="text">
|
||||
<string>Rotation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="label8">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label9">
|
||||
<property name="text">
|
||||
<string>Rotation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QLabel" name="label10">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label11">
|
||||
<property name="text">
|
||||
<string>Translation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label12">
|
||||
<property name="text">
|
||||
<string>Translation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label13">
|
||||
<property name="text">
|
||||
<string>Translation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getAnglesFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getTranslationFromObject">
|
||||
<property name="text">
|
||||
<string>Get Translation From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group2">
|
||||
<property name="title">
|
||||
<string>Angle Snapping</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="m_angleSnapScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label14">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="m_angleSnap">
|
||||
<property name="text">
|
||||
<string>Angle Snap</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label15">
|
||||
<property name="text">
|
||||
<string>Angle Snap:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group3">
|
||||
<property name="title">
|
||||
<string>Construction Plane</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label16">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displayCP">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_CPSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>m_displayCP</zorder>
|
||||
<zorder>m_CPSize</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group4">
|
||||
<property name="title">
|
||||
<string>Snap Marker</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_snapMarkerSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displaySnapMarker">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="ColorButton" name="m_snapMarkerColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label17">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header location="global">QtUI/ColorButton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -66,7 +66,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "AssetImporter/AssetImporterManager/AssetImporterDragAndDropHandler.h"
|
||||
#include "CryEdit.h"
|
||||
#include "Controls/ConsoleSCB.h"
|
||||
#include "Grid.h"
|
||||
#include "ViewManager.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "ToolBox.h"
|
||||
@@ -97,7 +96,6 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#include "AzAssetBrowser/AzAssetBrowserWindow.h"
|
||||
#include "AssetEditor/AssetEditorWindow.h"
|
||||
#include "GridSettingsDialog.h"
|
||||
#include "ActionManager.h"
|
||||
|
||||
// uncomment this to show thumbnail demo widget
|
||||
@@ -123,12 +121,6 @@ static const char* g_openLocationAttributeName = "OpenLocation"; //Indicates whe
|
||||
|
||||
static const char* g_assetImporterName = "AssetImporter";
|
||||
|
||||
static const char* g_snapToGridEnabled = "mainwindow/snapGridEnabled";
|
||||
static const char* g_snapToGridSize = "mainwindow/snapGridSize";
|
||||
static const char* g_snapAngleEnabled = "mainwindow/snapAngleEnabled";
|
||||
static const char* g_snapAngle = "mainwindow/snapAngle";
|
||||
static const char* g_terrainFollow = "mainwindow/terrainFollow";
|
||||
|
||||
class CEditorOpenViewCommand
|
||||
: public _i_reference_target_t
|
||||
{
|
||||
@@ -308,10 +300,8 @@ namespace
|
||||
|
||||
class SnapToWidget
|
||||
: public QWidget
|
||||
, public CGridSettingsDialog::NotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
typedef AZStd::function<void(double)> SetValueCallback;
|
||||
typedef AZStd::function<double()> GetValueCallback;
|
||||
|
||||
@@ -335,12 +325,13 @@ public:
|
||||
m_spinBox->setEnabled(defaultAction->isChecked());
|
||||
m_spinBox->setMinimum(1e-2f);
|
||||
|
||||
OnGridValuesUpdated();
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_spinBox);
|
||||
m_spinBox->setValue(m_getValueCallback());
|
||||
}
|
||||
|
||||
QObject::connect(m_spinBox, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), this, &SnapToWidget::OnValueChanged);
|
||||
QObject::connect(defaultAction, &QAction::changed, this, &SnapToWidget::OnActionChanged);
|
||||
|
||||
CGridSettingsDialog::NotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void SetIcon(QIcon icon)
|
||||
@@ -348,14 +339,6 @@ public:
|
||||
m_toolButton->setIcon(icon);
|
||||
}
|
||||
|
||||
void OnGridValuesUpdated() override
|
||||
{
|
||||
// Blocking signals to not trigger the valueChanged callback when we set the value on the spin box.
|
||||
QSignalBlocker signalBlocker(m_spinBox);
|
||||
double value = m_getValueCallback();
|
||||
m_spinBox->setValue(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnValueChanged(double value)
|
||||
@@ -543,7 +526,6 @@ void MainWindow::Initialize()
|
||||
RegisterStdViewClasses();
|
||||
InitCentralWidget();
|
||||
|
||||
LoadConfig();
|
||||
InitActions();
|
||||
|
||||
// load toolbars ("shelves") and macros
|
||||
@@ -673,31 +655,8 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::LoadConfig()
|
||||
{
|
||||
CGrid* grid = gSettings.pGrid;
|
||||
Q_ASSERT(grid);
|
||||
bool terrainValue;
|
||||
|
||||
ReadConfigValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
|
||||
ReadConfigValue(g_snapAngle, grid->angleSnap);
|
||||
ReadConfigValue(g_snapToGridEnabled, grid->bEnabled);
|
||||
ReadConfigValue(g_snapToGridSize, grid->size);
|
||||
ReadConfigValue(g_terrainFollow, terrainValue);
|
||||
GetIEditor()->SetTerrainAxisIgnoreObjects(terrainValue);
|
||||
}
|
||||
|
||||
void MainWindow::SaveConfig()
|
||||
{
|
||||
CGrid* grid = gSettings.pGrid;
|
||||
Q_ASSERT(grid);
|
||||
|
||||
m_settings.setValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
|
||||
m_settings.setValue(g_snapAngle, grid->angleSnap);
|
||||
m_settings.setValue(g_snapToGridEnabled, grid->bEnabled);
|
||||
m_settings.setValue(g_snapToGridSize, grid->size);
|
||||
m_settings.setValue(g_terrainFollow, GetIEditor()->IsTerrainAxisIgnoreObjects());
|
||||
|
||||
m_settings.setValue("mainWindowState", saveState());
|
||||
QtViewPaneManager::instance()->SaveLayout();
|
||||
if (m_pLayoutWnd)
|
||||
@@ -941,7 +900,6 @@ void MainWindow::InitActions()
|
||||
.SetStatusTip(tr("Render in Wireframe Mode."))
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateWireframe);
|
||||
|
||||
am->AddAction(ID_VIEW_GRIDSETTINGS, tr("Grid Settings..."));
|
||||
am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSwitchToDefaultCamera);
|
||||
am->AddAction(ID_SWITCHCAMERA_SEQUENCECAMERA, tr("Sequence Camera")).SetCheckable(true)
|
||||
@@ -1479,15 +1437,6 @@ MainStatusBar* MainWindow::StatusBar() const
|
||||
return static_cast<MainStatusBar*>(statusBar());
|
||||
}
|
||||
|
||||
void MainWindow::OnUpdateSnapToGrid(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
bool bEnabled = gSettings.pGrid->IsEnabled();
|
||||
action->setChecked(bEnabled);
|
||||
|
||||
action->setText(QObject::tr("Snap To Grid"));
|
||||
}
|
||||
|
||||
KeyboardCustomizationSettings* MainWindow::GetShortcutManager() const
|
||||
{
|
||||
return m_keyboardCustomization;
|
||||
|
||||
@@ -191,9 +191,7 @@ private:
|
||||
void InitToolActionHandlers();
|
||||
void InitToolBars();
|
||||
void InitStatusBar();
|
||||
void OnUpdateSnapToGrid(QAction* action);
|
||||
void OnViewPaneCreated(const QtViewPane* pane);
|
||||
void LoadConfig();
|
||||
|
||||
template <class TValue>
|
||||
void ReadConfigValue(const QString& key, TValue& value)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// Editor
|
||||
#include "Viewport.h"
|
||||
#include "GizmoManager.h"
|
||||
#include "Grid.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Settings.h"
|
||||
#include "RenderHelpers/AxisHelper.h"
|
||||
@@ -244,7 +243,8 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v
|
||||
break;
|
||||
case COORDS_USERDEFINED:
|
||||
{
|
||||
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
|
||||
Matrix34 userTM;
|
||||
userTM.SetIdentity();
|
||||
userTM.SetTranslation(m_object->GetWorldTM().GetTranslation());
|
||||
return userTM;
|
||||
}
|
||||
|
||||
@@ -1268,12 +1268,6 @@ int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint&
|
||||
if (event == eMouseWheel)
|
||||
{
|
||||
double angle = 1;
|
||||
|
||||
if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled())
|
||||
{
|
||||
angle = view->GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
}
|
||||
|
||||
Quat rot = GetRotation();
|
||||
rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
|
||||
SetRotation(rot);
|
||||
|
||||
@@ -342,7 +342,8 @@ void CSelectionGroup::Rotate(const Matrix34& rotateTM, int referenceCoordSys)
|
||||
|
||||
if (referenceCoordSys == COORDS_USERDEFINED)
|
||||
{
|
||||
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
|
||||
Matrix34 userTM;
|
||||
userTM.SetIdentity();
|
||||
Matrix34 invUserTM = userTM.GetInvertedFast();
|
||||
|
||||
ToOrigin = invUserTM * ToOrigin;
|
||||
|
||||
@@ -1993,28 +1993,27 @@ AzFramework::CameraState CRenderViewport::GetCameraState()
|
||||
|
||||
bool CRenderViewport::GridSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsEnabled();
|
||||
return false;
|
||||
}
|
||||
|
||||
float CRenderViewport::GridSize()
|
||||
{
|
||||
const CGrid* grid = GetViewManager()->GetGrid();
|
||||
return grid->scale * grid->size;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool CRenderViewport::ShowGrid()
|
||||
{
|
||||
return gSettings.viewports.bShowGridGuide;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CRenderViewport::AngleSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsAngleSnapEnabled();
|
||||
return false;
|
||||
}
|
||||
|
||||
float CRenderViewport::AngleStep()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point)
|
||||
@@ -3890,94 +3889,13 @@ void CRenderViewport::ActivateWindowAndSetFocus()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CRenderViewport::RenderConstructionPlane()
|
||||
{
|
||||
DisplayContext& dc = m_displayContext;
|
||||
|
||||
int prevState = dc.GetState();
|
||||
dc.DepthWriteOff();
|
||||
// Draw Construction plane.
|
||||
|
||||
CGrid* pGrid = GetViewManager()->GetGrid();
|
||||
|
||||
RefCoordSys coordSys = COORDS_WORLD;
|
||||
|
||||
Vec3 p = m_constructionMatrix[coordSys].GetTranslation();
|
||||
Vec3 n = m_constructionPlane.n;
|
||||
|
||||
Vec3 u = Vec3(1, 0, 0);
|
||||
Vec3 v = Vec3(0, 1, 0);
|
||||
|
||||
|
||||
if (gSettings.snap.bGridUserDefined)
|
||||
{
|
||||
Ang3 angles = Ang3(pGrid->rotationAngles.x * gf_PI / 180.0, pGrid->rotationAngles.y * gf_PI / 180.0, pGrid->rotationAngles.z * gf_PI / 180.0);
|
||||
Matrix34 tm = Matrix33::CreateRotationXYZ(angles);
|
||||
|
||||
u = tm * u;
|
||||
v = tm * v;
|
||||
}
|
||||
|
||||
float step = pGrid->scale * pGrid->size;
|
||||
float size = gSettings.snap.constructPlaneSize;
|
||||
|
||||
dc.SetColor(0, 0, 1, 0.1f);
|
||||
|
||||
float s = size;
|
||||
|
||||
dc.DrawQuad(p - u * s - v * s, p + u * s - v * s, p + u * s + v * s, p - u * s + v * s);
|
||||
|
||||
int nSteps = int(size / step);
|
||||
int i;
|
||||
// Draw X lines.
|
||||
dc.SetColor(1, 0, 0.2f, 0.3f);
|
||||
|
||||
for (i = -nSteps; i <= nSteps; i++)
|
||||
{
|
||||
dc.DrawLine(p - u * size + v * (step * i), p + u * size + v * (step * i));
|
||||
}
|
||||
// Draw Y lines.
|
||||
dc.SetColor(0.2f, 1.0f, 0, 0.3f);
|
||||
for (i = -nSteps; i <= nSteps; i++)
|
||||
{
|
||||
dc.DrawLine(p - v * size + u * (step * i), p + v * size + u * (step * i));
|
||||
}
|
||||
|
||||
// Draw origin lines.
|
||||
|
||||
dc.SetLineWidth(2);
|
||||
|
||||
//X
|
||||
dc.SetColor(1, 0, 0);
|
||||
dc.DrawLine(p - u * s, p + u * s);
|
||||
|
||||
//Y
|
||||
dc.SetColor(0, 1, 0);
|
||||
dc.DrawLine(p - v * s, p + v * s);
|
||||
|
||||
//Z
|
||||
dc.SetColor(0, 0, 1);
|
||||
dc.DrawLine(p - n * s, p + n * s);
|
||||
|
||||
dc.SetLineWidth(0);
|
||||
|
||||
dc.SetState(prevState);
|
||||
// noop
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CRenderViewport::RenderSnappingGrid()
|
||||
{
|
||||
// First, Check whether we should draw the grid or not.
|
||||
CGrid* pGrid = GetViewManager()->GetGrid();
|
||||
if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayContext& dc = m_displayContext;
|
||||
|
||||
int prevState = dc.GetState();
|
||||
dc.DepthWriteOff();
|
||||
|
||||
dc.SetState(prevState);
|
||||
// noop
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
#define ID_EDIT_HIDE 32898
|
||||
#define ID_EDIT_UNHIDEALL 32899
|
||||
#define ID_RELOAD_TERRAIN 32902
|
||||
#define ID_VIEW_GRIDSETTINGS 32904
|
||||
#define ID_VIEW_CONFIGURELAYOUT 32906
|
||||
#define ID_TOOLS_LOGMEMORYUSAGE 32908
|
||||
#define ID_TERRAIN_EXPORTBLOCK 32909
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/ToolBar.h>
|
||||
|
||||
class CGrid;
|
||||
|
||||
struct SGizmoSettings
|
||||
{
|
||||
float axisGizmoSize;
|
||||
@@ -393,9 +391,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
//! Keeps the editor active even if no focus is set
|
||||
int keepEditorActive;
|
||||
|
||||
//! Pointer to currently used grid.
|
||||
CGrid* pGrid;
|
||||
|
||||
SGizmoSettings gizmo;
|
||||
|
||||
// Settings of the snapping.
|
||||
|
||||
@@ -49,8 +49,6 @@ bool CViewManager::IsMultiViewportEnabled()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CViewManager::CViewManager()
|
||||
{
|
||||
gSettings.pGrid = &m_grid;
|
||||
|
||||
m_zoomFactor = 1;
|
||||
|
||||
m_origin2D(0, 0, 0);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Cry_Geo.h"
|
||||
#include "Grid.h"
|
||||
#include "Viewport.h"
|
||||
#include "Include/IViewPane.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
@@ -67,10 +66,6 @@ public:
|
||||
void SetUpdateRegion(const AABB& updateRegion) { m_updateRegion = updateRegion; };
|
||||
const AABB& GetUpdateRegion() { return m_updateRegion; };
|
||||
|
||||
/** Retrieve Grid used for viewes.
|
||||
*/
|
||||
CGrid* GetGrid() { return &m_grid; };
|
||||
|
||||
/** Get 2D viewports origin.
|
||||
*/
|
||||
Vec3 GetOrigin2D() const { return m_origin2D; }
|
||||
@@ -137,7 +132,6 @@ private:
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AABB m_updateRegion;
|
||||
|
||||
CGrid m_grid;
|
||||
//! Origin of 2d viewports.
|
||||
Vec3 m_origin2D;
|
||||
//! Zoom of 2d viewports.
|
||||
|
||||
@@ -1182,12 +1182,12 @@ float QtViewport::GetZoomFactor() const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 QtViewport::SnapToGrid(const Vec3& vec)
|
||||
{
|
||||
return m_viewManager->GetGrid()->Snap(vec, m_fGridZoom);
|
||||
return vec;
|
||||
}
|
||||
|
||||
float QtViewport::GetGridStep() const
|
||||
{
|
||||
return m_viewManager->GetGrid()->scale * m_viewManager->GetGrid()->size;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -437,9 +437,6 @@ set(FILES
|
||||
GotoPositionDlg.cpp
|
||||
GotoPositionDlg.h
|
||||
GotoPositionDlg.ui
|
||||
GridSettingsDialog.cpp
|
||||
GridSettingsDialog.h
|
||||
GridSettingsDialog.ui
|
||||
InfoBar.cpp
|
||||
InfoBar.qrc
|
||||
InfoBar.h
|
||||
@@ -835,8 +832,6 @@ set(FILES
|
||||
WelcomeScreen/WelcomeScreenDialog.qrc
|
||||
2DViewport.cpp
|
||||
2DViewport.h
|
||||
Grid.cpp
|
||||
Grid.h
|
||||
LayoutWnd.cpp
|
||||
LayoutWnd.h
|
||||
EditorViewportWidget.cpp
|
||||
|
||||
Reference in New Issue
Block a user