From b1dd4b02cac875c2fa87c5271a283606aceb9bfe Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Thu, 9 May 2019 11:00:47 +0300 Subject: Add vector4 support for datainputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QT3DS-3394 Change-Id: I2e0bea3e4b4e1490e33bc747d809779cd1228fe5 Reviewed-by: Miikka Heikkinen Reviewed-by: Jari Karppinen Reviewed-by: Janne Kangas Reviewed-by: Antti Määttä --- src/Authoring/Studio/Application/DataInputDlg.cpp | 43 ++++++++++------------ src/Authoring/Studio/Application/DataInputDlg.h | 11 ++++-- .../Studio/Application/DataInputListDlg.cpp | 7 +++- src/Authoring/Studio/Application/ProjectFile.cpp | 2 + src/Authoring/Studio/Application/StudioApp.cpp | 3 +- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/Authoring/Studio/Application/DataInputDlg.cpp b/src/Authoring/Studio/Application/DataInputDlg.cpp index 53f35326..f6255395 100644 --- a/src/Authoring/Studio/Application/DataInputDlg.cpp +++ b/src/Authoring/Studio/Application/DataInputDlg.cpp @@ -65,6 +65,7 @@ CDataInputDlg::CDataInputDlg(CDataInputDialogItem **datainput, QStandardItemMode m_ui->comboBoxTypeList->addItem(tr("Variant"), QVariant(DataTypeVariant)); m_ui->comboBoxTypeList->addItem(tr("Vector2"), QVariant(DataTypeVector2)); m_ui->comboBoxTypeList->addItem(tr("Vector3"), QVariant(DataTypeVector3)); + m_ui->comboBoxTypeList->addItem(tr("Vector4"), QVariant(DataTypeVector4)); QStandardItemModel *model = qobject_cast(m_ui->comboBoxTypeList->model()); @@ -274,29 +275,25 @@ void CDataInputDlg::updateVisibility(int type) } } -const bool CDataInputDlg::isEquivalentDataType(int dlgType, - qt3dsdm::DataModelDataType::Value dmType, - bool strict) +// static +bool CDataInputDlg::isEquivalentDataType(int dlgType, qt3dsdm::DataModelDataType::Value dmType, + bool strict) { - if ((dlgType == EDataType::DataTypeString - && dmType == qt3dsdm::DataModelDataType::String) - || (dlgType == EDataType::DataTypeRangedNumber - && dmType == qt3dsdm::DataModelDataType::RangedNumber) + using namespace qt3dsdm; + + if ((dlgType == EDataType::DataTypeString && dmType == DataModelDataType::String) + || (dlgType == EDataType::DataTypeRangedNumber && dmType == DataModelDataType::RangedNumber) || (dlgType == EDataType::DataTypeFloat - && (dmType == qt3dsdm::DataModelDataType::Float - || (dmType == qt3dsdm::DataModelDataType::String && !strict))) - || (dlgType == EDataType::DataTypeBoolean - && dmType == qt3dsdm::DataModelDataType::Bool) - || (dlgType == EDataType::DataTypeVector3 - && dmType == qt3dsdm::DataModelDataType::Float3) - || (dlgType == EDataType::DataTypeVector2 - && dmType == qt3dsdm::DataModelDataType::Float2) - // Variant can be bound to any property type except - // as timeline controller because only datainput of type Ranged Number - // has additional min/max information. For slide control, + && (dmType == DataModelDataType::Float + || (dmType == DataModelDataType::String && !strict))) + || (dlgType == EDataType::DataTypeBoolean && dmType == DataModelDataType::Bool) + || (dlgType == EDataType::DataTypeVector4 && dmType == DataModelDataType::Float4) + || (dlgType == EDataType::DataTypeVector3 && dmType == DataModelDataType::Float3) + || (dlgType == EDataType::DataTypeVector2 && dmType == DataModelDataType::Float2) + // Variant can be bound to any property type except timeline controller because only + // datainput of type Ranged Number has additional min/max information. For slide control, // we can allow variant type in addition to String type. - || (dlgType == EDataType::DataTypeVariant - && dmType != qt3dsdm::DataModelDataType::RangedNumber) + || (dlgType == EDataType::DataTypeVariant && dmType != DataModelDataType::RangedNumber) #ifdef DATAINPUT_EVALUATOR_ENABLED || dlgType == EDataType::DataTypeEvaluator #endif @@ -328,12 +325,10 @@ bool CDataInputDlg::eventFilter(QObject *obj, QEvent *ev) QKeyEvent *tabEv = new QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(m_ui->tableEditMetadata, tabEv); return true; - } else { - return false; } - } else { - return false; } + + return false; } void CDataInputDlg::populateMetadata(int rows) diff --git a/src/Authoring/Studio/Application/DataInputDlg.h b/src/Authoring/Studio/Application/DataInputDlg.h index 1ad2c5a7..9ae6bc6f 100644 --- a/src/Authoring/Studio/Application/DataInputDlg.h +++ b/src/Authoring/Studio/Application/DataInputDlg.h @@ -60,13 +60,15 @@ enum EDataType { DataTypeString, DataTypeVariant, DataTypeVector2, - DataTypeVector3 + DataTypeVector3, + DataTypeVector4 }; // The order also specifies the priority for default type in case of multiple accepted types static const QVector allDataTypes { EDataType::DataTypeString, EDataType::DataTypeFloat, + EDataType::DataTypeVector4, EDataType::DataTypeVector3, EDataType::DataTypeVector2, EDataType::DataTypeRangedNumber, @@ -80,14 +82,15 @@ static const QVector allDataTypes { class CDataInputDlg : public QDialog { Q_OBJECT + public: CDataInputDlg(CDataInputDialogItem **datainput, QStandardItemModel *data, QWidget* parent = nullptr, const QVector acceptedTypes = allDataTypes); - ~CDataInputDlg(); + ~CDataInputDlg() override; // Maps between DataModel datatypes and datainput dialog types - static const bool isEquivalentDataType(int dlgType, qt3dsdm::DataModelDataType::Value dmType, - bool strict = false); + static bool isEquivalentDataType(int dlgType, qt3dsdm::DataModelDataType::Value dmType, + bool strict = false); static QVector getAcceptedTypes(qt3dsdm::DataModelDataType::Value dmType, bool strict = false); diff --git a/src/Authoring/Studio/Application/DataInputListDlg.cpp b/src/Authoring/Studio/Application/DataInputListDlg.cpp index 5b9a69c8..c9782b40 100644 --- a/src/Authoring/Studio/Application/DataInputListDlg.cpp +++ b/src/Authoring/Studio/Application/DataInputListDlg.cpp @@ -55,7 +55,7 @@ CDataInputListDlg::CDataInputListDlg(QMap *data , m_actualDataInputs(datainputs) , m_currentDataInputIndex(-1) , m_tableContents(new QStandardItemModel(0, columnCount, this)) - , m_infoContents(new QStandardItemModel(0, 3, this)) + , m_infoContents(new QStandardItemModel(0, columnCount, this)) , m_goToAdd(goToAdd) , m_sortColumn(-1) , m_defaultType(defaultType) @@ -87,7 +87,7 @@ CDataInputListDlg::CDataInputListDlg(QMap *data m_ui->typeFilterCombo->addItems({tr("[All types]"), tr("Boolean"), tr("Float"), tr("Ranged Number"), tr("String"), tr("Variant"), - tr("Vector2"), tr("Vector3")}); + tr("Vector2"), tr("Vector3"), tr("Vector4")}); m_ui->typeFilterCombo->setToolTip(tr("Filter the list by Data Input type")); m_ui->searchField->setToolTip(tr("Search for Data Input")); @@ -224,6 +224,9 @@ void CDataInputListDlg::updateContents() } else if (dataInputType == DataTypeBoolean && (m_typeFilter == (int)DataTypeBoolean || m_typeFilter == -1)) { dataInput.append(new QStandardItem(tr("Boolean"))); + } else if (dataInputType == DataTypeVector4 + && (m_typeFilter == (int)DataTypeVector4 || m_typeFilter == -1)) { + dataInput.append(new QStandardItem(tr("Vector4"))); } else if (dataInputType == DataTypeVector3 && (m_typeFilter == (int)DataTypeVector3 || m_typeFilter == -1)) { dataInput.append(new QStandardItem(tr("Vector3"))); diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp index 809f3b70..9576211f 100644 --- a/src/Authoring/Studio/Application/ProjectFile.cpp +++ b/src/Authoring/Studio/Application/ProjectFile.cpp @@ -476,6 +476,8 @@ void ProjectFile::parseDataInputElem(const QDomElement &elem, item->type = EDataType::DataTypeFloat; } else if (type == QLatin1String("Boolean")) { item->type = EDataType::DataTypeBoolean; + } else if (type == QLatin1String("Vector4")) { + item->type = EDataType::DataTypeVector4; } else if (type == QLatin1String("Vector3")) { item->type = EDataType::DataTypeVector3; } else if (type == QLatin1String("Vector2")) { diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp index 23dd2d73..1ee1fc0d 100644 --- a/src/Authoring/Studio/Application/StudioApp.cpp +++ b/src/Authoring/Studio/Application/StudioApp.cpp @@ -1706,7 +1706,6 @@ void CStudioApp::saveDataInputsToProjectFile() // add the new dataInputs for (CDataInputDialogItem *item : qAsConst(m_dataInputDialogItems)) { - QDomElement diNode = doc.createElement(QStringLiteral("dataInput")); diNode.setAttribute(QStringLiteral("name"), item->name); @@ -1720,6 +1719,8 @@ void CStudioApp::saveDataInputsToProjectFile() diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Float")); } else if (item->type == EDataType::DataTypeBoolean) { diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Boolean")); + } else if (item->type == EDataType::DataTypeVector4) { + diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Vector4")); } else if (item->type == EDataType::DataTypeVector3) { diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Vector3")); } else if (item->type == EDataType::DataTypeVector2) { -- cgit v1.2.3