diff options
36 files changed, 535 insertions, 1246 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp index 1723976d..eeaeda66 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp @@ -323,6 +323,9 @@ qt3dsdm::Qt3DSDMPropertyHandle CClientDataModelBridge::getVariantsProperty(int i if (instanceType == OBJTYPE_GROUP) return m_Group.m_variants; + if (instanceType == OBJTYPE_COMPONENT) + return m_Component.m_variants; + return 0; } @@ -1737,12 +1740,8 @@ CClientDataModelBridge::GetObjectType(qt3dsdm::Qt3DSDMInstanceHandle inInstance) return OBJTYPE_SUBPATH; else if (theType == L"Lightmaps") return OBJTYPE_LIGHTMAPS; - else if (theType == L"Action") - return OBJTYPE_UNKNOWN; - else { - ASSERT(0); - return OBJTYPE_UNKNOWN; - } + + return OBJTYPE_UNKNOWN; } bool CClientDataModelBridge::IsBehaviorInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp index febacc42..adf94ed1 100644 --- a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp +++ b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp @@ -1612,10 +1612,10 @@ struct SComposerSerializerImpl : public IComposerSerializer IDOMWriter::Scope __instanceScope(inWriter, theType->wide_str()); inWriter.Att(L"id", GetInstanceId(inInstance)); - // For objects with a 'variants' property (layers, models and groups) save the variants - // property under the <Graph> node. + // For objects with a 'variants' property (layers, models, groups and components) save the + // variants property under the <Graph> node. if (theType.getValue() == L"Layer" || theType.getValue() == L"Model" - || theType.getValue() == L"Group") { + || theType.getValue() == L"Group" || theType.getValue() == L"Component") { auto prop = m_propertySystem.GetAggregateInstancePropertyByName(inInstance, L"variants"); SValue sVal; diff --git a/src/Authoring/Client/Code/Core/Doc/SelectedValue.h b/src/Authoring/Client/Code/Core/Doc/SelectedValue.h index 9e615266..9851b511 100644 --- a/src/Authoring/Client/Code/Core/Doc/SelectedValue.h +++ b/src/Authoring/Client/Code/Core/Doc/SelectedValue.h @@ -31,16 +31,13 @@ #include "foundation/Qt3DSOption.h" namespace Q3DStudio { -struct SelectedValueTypes -{ - enum Enum { - UnknownSelectedValueType = 0, - Instance, // Qt3DSDMInstanceHandle - Slide, // Qt3DSDMSlideHandle - SlideInsertion, // void* - Guide, // Qt3DSDMGuideHandle - MultipleInstances, // std::vector<Qt3DSDMInstanceHandle> - }; +enum class SelectedValueTypes { + Instance, // Qt3DSDMInstanceHandle + Slide, // Qt3DSDMSlideHandle + SlideInsertion, // void* + Guide, // Qt3DSDMGuideHandle + MultipleInstances, // std::vector<Qt3DSDMInstanceHandle> + Unknown }; // Defined in SelectedValueImpl.h diff --git a/src/Authoring/Client/Code/Core/Doc/SelectedValueImpl.h b/src/Authoring/Client/Code/Core/Doc/SelectedValueImpl.h index 72ce4b13..fbf311be 100644 --- a/src/Authoring/Client/Code/Core/Doc/SelectedValueImpl.h +++ b/src/Authoring/Client/Code/Core/Doc/SelectedValueImpl.h @@ -80,41 +80,41 @@ struct SSelectedValueTypeMap template <> struct SSelectedValueTypeMap<qt3dsdm::Qt3DSDMInstanceHandle> { - static SelectedValueTypes::Enum GetType() { return SelectedValueTypes::Instance; } + static SelectedValueTypes GetType() { return SelectedValueTypes::Instance; } }; template <> struct SSelectedValueTypeMap<SSlideInstanceWrapper> { - static SelectedValueTypes::Enum GetType() { return SelectedValueTypes::Slide; } + static SelectedValueTypes GetType() { return SelectedValueTypes::Slide; } }; template <> struct SSelectedValueTypeMap<qt3dsdm::Qt3DSDMGuideHandle> { - static SelectedValueTypes::Enum GetType() { return SelectedValueTypes::Guide; } + static SelectedValueTypes GetType() { return SelectedValueTypes::Guide; } }; template <> struct SSelectedValueTypeMap<SSlideInsertionWrapper> { - static SelectedValueTypes::Enum GetType() { return SelectedValueTypes::SlideInsertion; } + static SelectedValueTypes GetType() { return SelectedValueTypes::SlideInsertion; } }; template <> struct SSelectedValueTypeMap<qt3dsdm::TInstanceHandleList> { - static SelectedValueTypes::Enum GetType() { return SelectedValueTypes::MultipleInstances; } + static SelectedValueTypes GetType() { return SelectedValueTypes::MultipleInstances; } }; struct SSelectedValueTraits { - typedef SelectedValueTypes::Enum TIdType; + typedef SelectedValueTypes TIdType; enum { TBufferSize = sizeof(SSlideInstanceWrapper), }; - static TIdType getNoDataId() { return SelectedValueTypes::UnknownSelectedValueType; } + static TIdType getNoDataId() { return SelectedValueTypes::Unknown; } template <typename TDataType> static TIdType getType() @@ -138,7 +138,7 @@ struct SSelectedValueTraits return inVisitor(*qt3ds::NVUnionCast<qt3dsdm::TInstanceHandleList *>(inData)); default: QT3DS_ASSERT(false); - case SelectedValueTypes::UnknownSelectedValueType: + case SelectedValueTypes::Unknown: return inVisitor(); } } @@ -159,7 +159,7 @@ struct SSelectedValueTraits return inVisitor(*qt3ds::NVUnionCast<const qt3dsdm::TInstanceHandleList *>(inData)); default: QT3DS_ASSERT(false); - case SelectedValueTypes::UnknownSelectedValueType: + case SelectedValueTypes::Unknown: return inVisitor(); } } @@ -207,7 +207,7 @@ struct SSelectedValue : public TSelectedValueUnionType return *this; } - bool empty() const { return getType() == SelectedValueTypes::UnknownSelectedValueType; } + bool empty() const { return getType() == SelectedValueTypes::Unknown; } operator bool() const { return !empty(); } diff --git a/src/Authoring/Client/Code/Core/Types/PropertyPublishLevels.h b/src/Authoring/Client/Code/Core/Types/PropertyPublishLevels.h deleted file mode 100644 index 3b79f891..00000000 --- a/src/Authoring/Client/Code/Core/Types/PropertyPublishLevels.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PROPERTY_PUBLISH_LEVELS_H -#define INCLUDED_PROPERTY_PUBLISH_LEVELS_H 1 - -#pragma once - -enum EPublishLevel { - PUBLISH_LEVEL_UNKNOWN = 0, - PUBLISH_LEVEL_HIDDEN, ///< Hidden Property - PUBLISH_LEVEL_BASIC, ///< Basic Property - PUBLISH_LEVEL_INTERMEDIATE, ///< Not used - PUBLISH_LEVEL_ADVANCED, ///< Advance Property - PUBLISH_LEVEL_SHARED, ///< Shared (Buffer-only) Property -}; - -#endif // INCLUDED_PROPERTY_PUBLISH_LEVELS_H
\ No newline at end of file diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp index 0fbf52f9..121bd747 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp +++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp @@ -27,7 +27,6 @@ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "StudioObjectTypes.h" bool CStudioObjectTypes::AcceptableParent(EStudioObjectType inChild, EStudioObjectType inParent) diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h index ca82ca7d..f6a6fbdd 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h +++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h @@ -29,9 +29,6 @@ #ifndef INCLUDED_STUDIO_OBJECTTYPES_H #define INCLUDED_STUDIO_OBJECTTYPES_H -#pragma once - -#include "PropertyPublishLevels.h" #include "Qt3DSString.h" // // ******************************************************************* @@ -72,7 +69,7 @@ enum EStudioObjectType { OBJTYPE_MATERIALDATA = 0x08000000, // filters - OBJTYPE_IS_VARIANT = OBJTYPE_LAYER | OBJTYPE_MODEL | OBJTYPE_GROUP, + OBJTYPE_IS_VARIANT = OBJTYPE_LAYER | OBJTYPE_MODEL | OBJTYPE_GROUP | OBJTYPE_COMPONENT, OBJTYPE_IS_MATERIAL = OBJTYPE_MATERIAL | OBJTYPE_CUSTOMMATERIAL | OBJTYPE_REFERENCEDMATERIAL, OBJTYPE_IS_SINGULAR = OBJTYPE_SCENE | OBJTYPE_LAYER | OBJTYPE_BEHAVIOR | OBJTYPE_EFFECT | OBJTYPE_IS_MATERIAL, // Singular: cannot be multiselected diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h index d962c137..fc7cd4f5 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h @@ -108,6 +108,7 @@ class IPropertySystem; HANDLE_COMPOSER_PROPERTY_DUPLICATE(controlledproperty, m_ControlledProperty, TDataStrPtr, L"") #define ITERATE_COMPOSER_COMPONENT_PROPERTIES \ + HANDLE_COMPOSER_PROPERTY_DUPLICATE(variants, m_variants, TDataStrPtr, L"") \ HANDLE_COMPOSER_PROPERTY_DUPLICATE(controlledproperty, m_ControlledProperty, TDataStrPtr, L"") #define ITERATE_COMPOSER_NODE_PROPERTIES \ diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp index 29129931..888865f4 100644 --- a/src/Authoring/Studio/Application/StudioApp.cpp +++ b/src/Authoring/Studio/Application/StudioApp.cpp @@ -208,12 +208,10 @@ int main(int argc, char *argv[]) #include "Core.h" #include "HotKeys.h" #include "StudioTutorialWidget.h" -#include "GuideInspectable.h" #include "Qt3DSDMStudioSystem.h" #include "Qt3DSDMInspectable.h" #include "Qt3DSDMSlides.h" #include "Qt3DSDMMaterialInspectable.h" -#include "Qt3DSDMSceneInspectable.h" #include "Qt3DSDMAnimation.h" #include "Qt3DSDMDataCore.h" #include "IDirectoryWatchingSystem.h" @@ -1417,116 +1415,32 @@ void CStudioApp::PlaybackToggle() PlaybackPlay(); } -CInspectableBase *CStudioApp::GetInspectableFromSelectable(Q3DStudio::SSelectedValue inSelectable) -{ - CInspectableBase *theInspectableBase = nullptr; - if (inSelectable.empty() == false) { - switch (inSelectable.getType()) { - case Q3DStudio::SelectedValueTypes::Slide: - theInspectableBase = new Qt3DSDMInspectable( - *this, m_core, - inSelectable.getData<Q3DStudio::SSlideInstanceWrapper>().m_Instance); - break; - case Q3DStudio::SelectedValueTypes::MultipleInstances: - case Q3DStudio::SelectedValueTypes::Instance: { - - // We need to decide whether to display SlideInspectable or UICDMInspectable - // We display SlideInspectable if user selects a Scene or Component where the current - // active slide belongs, - // for example when user selects the Root in Timeline Palette - CDoc *theDoc = m_core->GetDoc(); - qt3dsdm::TInstanceHandleList theSelectedInstances = - theDoc->GetSelectedValue().GetSelectedInstances(); - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance; - if (theSelectedInstances.size() == 1) - theSelectedInstance = theSelectedInstances[0]; - - if (m_core->GetDoc()->GetDocumentReader().IsInstance(theSelectedInstance)) { - CClientDataModelBridge *theBridge = - theDoc->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::Qt3DSDMSlideHandle theCurrentActiveSlide = theDoc->GetActiveSlide(); - - // Slide, scene or component - if (theSelectedInstance - == theBridge->GetOwningComponentInstance(theCurrentActiveSlide)) { - Qt3DSDMInstanceHandle theCurrentActiveSlideInstance = - theDoc->GetStudioSystem()->GetSlideSystem()->GetSlideInstance( - theCurrentActiveSlide); - - if (theBridge->IsSceneInstance(theSelectedInstance)) - theInspectableBase = new Qt3DSDMSceneInspectable( - *this, m_core, theSelectedInstance, - theCurrentActiveSlideInstance); - else if (theBridge->IsComponentInstance(theSelectedInstance)) - theInspectableBase = new Qt3DSDMInspectable( - *this, m_core, theSelectedInstance, - theCurrentActiveSlideInstance); - } - if (theInspectableBase == nullptr) { - if (theBridge->IsMaterialBaseInstance(theSelectedInstance)) - theInspectableBase = - new Qt3DSDMMaterialInspectable(*this, m_core, theSelectedInstance); - else - theInspectableBase = - new Qt3DSDMInspectable(*this, m_core, theSelectedInstance); - } - } - } - break; - case Q3DStudio::SelectedValueTypes::Guide: { - qt3dsdm::Qt3DSDMGuideHandle theGuide - = inSelectable.getData<qt3dsdm::Qt3DSDMGuideHandle>(); - theInspectableBase = CGuideInspectable::CreateInspectable(*m_core, theGuide); - } - break; - default: - // Ignore slide insertion and unknown selectable types - break; - }; - } - - return theInspectableBase; -} - +// TODO: move to more appropriate place (InspectorControlModel.cpp) CInspectableBase *CStudioApp::getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) { - CInspectableBase *theInspectableBase = nullptr; - CDoc *theDoc = m_core->GetDoc(); + CInspectableBase *inspectableBase = nullptr; + CDoc *doc = m_core->GetDoc(); if (m_core->GetDoc()->GetDocumentReader().IsInstance(inInstance)) { - CClientDataModelBridge *theBridge = - theDoc->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::Qt3DSDMSlideHandle theCurrentActiveSlide = theDoc->GetActiveSlide(); + CClientDataModelBridge *theBridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide(); // Slide, scene or component - if (inInstance - == theBridge->GetOwningComponentInstance(theCurrentActiveSlide)) { - Qt3DSDMInstanceHandle theCurrentActiveSlideInstance = - theDoc->GetStudioSystem()->GetSlideSystem()->GetSlideInstance( - theCurrentActiveSlide); - - if (theBridge->IsSceneInstance(inInstance)) { - theInspectableBase = new Qt3DSDMSceneInspectable( - *this, m_core, inInstance, - theCurrentActiveSlideInstance); - } else if (theBridge->IsComponentInstance(inInstance)) { - theInspectableBase = new Qt3DSDMInspectable( - *this, m_core, inInstance, - theCurrentActiveSlideInstance); - } + if (inInstance == theBridge->GetOwningComponentInstance(activeSlide)) { + Qt3DSDMInstanceHandle activeSlideInstance = doc->GetStudioSystem()->GetSlideSystem() + ->GetSlideInstance(activeSlide); + + inspectableBase = new Qt3DSDMInspectable(inInstance, activeSlideInstance); } - if (theInspectableBase == nullptr) { - if (theBridge->IsMaterialBaseInstance(inInstance)) { - theInspectableBase = - new Qt3DSDMMaterialInspectable(*this, m_core, inInstance); - } else { - theInspectableBase = - new Qt3DSDMInspectable(*this, m_core, inInstance); - } + if (inspectableBase) { + if (theBridge->IsMaterialBaseInstance(inInstance)) + inspectableBase = new Qt3DSDMMaterialInspectable(inInstance); + else + inspectableBase = new Qt3DSDMInspectable(inInstance); } } - return theInspectableBase; + return inspectableBase; } void CStudioApp::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h index 6d5b696b..04e9f57d 100644 --- a/src/Authoring/Studio/Application/StudioApp.h +++ b/src/Authoring/Studio/Application/StudioApp.h @@ -198,7 +198,6 @@ public: void AdvanceUltraBigTime(); void ReduceUltraBigTime(); void PlaybackToggle(); - CInspectableBase *GetInspectableFromSelectable(Q3DStudio::SSelectedValue inSelectable); CInspectableBase *getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance); void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent); bool OnSave(bool autosave = false); diff --git a/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.cpp b/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.cpp deleted file mode 100644 index a954637e..00000000 --- a/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "Qt3DSCommonPrecompile.h" -#include "EasyInspectorGroup.h" - -//============================================================================== -/** - * Constructor - */ -CEasyInspectorGroup::CEasyInspectorGroup(const QString &inName) - : CInspectorGroup() -{ - SetName(inName); -} - -//============================================================================== -/** - * - */ -CEasyInspectorGroup::~CEasyInspectorGroup() -{ -} diff --git a/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.h b/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.h deleted file mode 100644 index 62cc35a5..00000000 --- a/src/Authoring/Studio/Palettes/Inspector/EasyInspectorGroup.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_EASYINSPECTORGROUP_H -#define INCLUDED_EASYINSPECTORGROUP_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "InspectorGroup.h" - -//============================================================================== -// Forwards -//============================================================================== - -//============================================================================== -/** - * Simplest possible inspector group - */ -class CEasyInspectorGroup : public CInspectorGroup -{ -public: // Construction - CEasyInspectorGroup(const QString &inName); - ~CEasyInspectorGroup(); -}; - -#endif diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp index 5c2af7ac..b10e4c1e 100644 --- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp @@ -26,13 +26,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "GuideInspectable.h" #include "InspectableBase.h" +#include "StudioApp.h" #include "Core.h" #include "Doc.h" #include "Qt3DSDMGuides.h" -#include "EasyInspectorGroup.h" +#include "InspectorGroup.h" #include "IDocumentEditor.h" #include "Qt3DSDMDataTypes.h" #include "IInspectableItem.h" @@ -173,50 +173,42 @@ struct SFloatIntItem : public IInspectableAttributeItem } }; - -CInspectableBase *CGuideInspectable::CreateInspectable(CCore &inCore, - qt3dsdm::Qt3DSDMGuideHandle inGuide) -{ - return new SGuideInspectableImpl(inCore, inGuide); -} - -SGuideInspectableImpl::SGuideInspectableImpl(CCore &inCore, qt3dsdm::Qt3DSDMGuideHandle inGuide) - : CInspectableBase(&inCore) - , m_Guide(inGuide) - , m_Editor(*inCore.GetDoc()) +GuideInspectable::GuideInspectable(qt3dsdm::Qt3DSDMGuideHandle inGuide) + : m_Guide(inGuide) + , m_Editor(*g_StudioApp.GetCore()->GetDoc()) { } -Q3DStudio::IDocumentReader &SGuideInspectableImpl::Reader() const +Q3DStudio::IDocumentReader &GuideInspectable::Reader() const { - return m_Core->GetDoc()->GetDocumentReader(); + return g_StudioApp.GetCore()->GetDoc()->GetDocumentReader(); } -EStudioObjectType SGuideInspectableImpl::GetObjectType() +EStudioObjectType GuideInspectable::getObjectType() const { return OBJTYPE_GUIDE; } -Q3DStudio::CString SGuideInspectableImpl::GetName() +Q3DStudio::CString GuideInspectable::getName() { return L"Guide"; } -long SGuideInspectableImpl::GetGroupCount() +long GuideInspectable::getGroupCount() const { return 1; } -CInspectorGroup *SGuideInspectableImpl::GetGroup(long) +CInspectorGroup *GuideInspectable::getGroup(long) { - TCommitFunc theCommiter = std::bind(&SGuideInspectableImpl::Commit, this); - TCancelFunc theCanceler = std::bind(&SGuideInspectableImpl::Rollback, this); + TCommitFunc theCommiter = std::bind(&GuideInspectable::Commit, this); + TCancelFunc theCanceler = std::bind(&GuideInspectable::Rollback, this); m_Properties.push_back( std::make_shared<SFloatIntItem>( SInspectableDataInfo(QStringLiteral("Position"), QObject::tr("Position"), QObject::tr("Position of the guide"), - std::bind(&SGuideInspectableImpl::GetPosition, this), - std::bind(&SGuideInspectableImpl::SetPosition, this, + std::bind(&GuideInspectable::GetPosition, this), + std::bind(&GuideInspectable::SetPosition, this, std::placeholders::_1), theCommiter, theCanceler), qt3dsdm::DataModelDataType::Float)); @@ -228,8 +220,8 @@ CInspectorGroup *SGuideInspectableImpl::GetGroup(long) std::make_shared<SComboAttItem>( SInspectableDataInfo(QStringLiteral("Orientation"), QObject::tr("Orientation"), QObject::tr("Orientation of the guide"), - std::bind(&SGuideInspectableImpl::GetDirection, this), - std::bind(&SGuideInspectableImpl::SetDirection, this, + std::bind(&GuideInspectable::GetDirection, this), + std::bind(&GuideInspectable::SetDirection, this, std::placeholders::_1), theCommiter, theCanceler), theComboItems)); @@ -238,27 +230,32 @@ CInspectorGroup *SGuideInspectableImpl::GetGroup(long) std::make_shared<SFloatIntItem>( SInspectableDataInfo(QStringLiteral("Width"), QObject::tr("Width"), QObject::tr("Width of the guide"), - std::bind(&SGuideInspectableImpl::GetWidth, this), - std::bind(&SGuideInspectableImpl::SetWidth, this, + std::bind(&GuideInspectable::GetWidth, this), + std::bind(&GuideInspectable::SetWidth, this, std::placeholders::_1), theCommiter, theCanceler), qt3dsdm::DataModelDataType::Long, 1.0f, 50.0f)); - CEasyInspectorGroup *theNewGroup = new CEasyInspectorGroup(QObject::tr("Basic")); + CInspectorGroup *theNewGroup = new CInspectorGroup(QObject::tr("Basic")); return theNewGroup; } -bool SGuideInspectableImpl::IsValid() const +bool GuideInspectable::isValid() const { return Reader().IsGuideValid(m_Guide); } -bool SGuideInspectableImpl::IsMaster() +bool GuideInspectable::isMaster() const { return true; } -void SGuideInspectableImpl::SetDirection(const qt3dsdm::SValue &inValue) +qt3dsdm::Qt3DSDMInstanceHandle GuideInspectable::getInstance() const +{ + return 0; // guide has no instance +} + +void GuideInspectable::SetDirection(const qt3dsdm::SValue &inValue) { qt3dsdm::TDataStrPtr theData = inValue.getData<qt3dsdm::TDataStrPtr>(); qt3dsdm::SGuideInfo theSetter(Reader().GetGuideInfo(m_Guide)); @@ -272,7 +269,7 @@ void SGuideInspectableImpl::SetDirection(const qt3dsdm::SValue &inValue) FireRefresh(); } -qt3dsdm::SValue SGuideInspectableImpl::GetDirection() +qt3dsdm::SValue GuideInspectable::GetDirection() { switch (Reader().GetGuideInfo(m_Guide).m_Direction) { case qt3dsdm::GuideDirections::Horizontal: @@ -284,7 +281,7 @@ qt3dsdm::SValue SGuideInspectableImpl::GetDirection() } } -void SGuideInspectableImpl::SetPosition(const qt3dsdm::SValue &inValue) +void GuideInspectable::SetPosition(const qt3dsdm::SValue &inValue) { float thePos = inValue.getData<float>(); qt3dsdm::SGuideInfo theSetter(Reader().GetGuideInfo(m_Guide)); @@ -293,13 +290,13 @@ void SGuideInspectableImpl::SetPosition(const qt3dsdm::SValue &inValue) FireRefresh(); } -qt3dsdm::SValue SGuideInspectableImpl::GetPosition() +qt3dsdm::SValue GuideInspectable::GetPosition() { qt3dsdm::SGuideInfo theSetter(Reader().GetGuideInfo(m_Guide)); return theSetter.m_Position; } -void SGuideInspectableImpl::SetWidth(const qt3dsdm::SValue &inValue) +void GuideInspectable::SetWidth(const qt3dsdm::SValue &inValue) { auto theData = inValue.getData<qt3ds::QT3DSI32>(); @@ -310,45 +307,45 @@ void SGuideInspectableImpl::SetWidth(const qt3dsdm::SValue &inValue) } -qt3dsdm::SValue SGuideInspectableImpl::GetWidth() +qt3dsdm::SValue GuideInspectable::GetWidth() { qt3dsdm::SGuideInfo theSetter(Reader().GetGuideInfo(m_Guide)); return theSetter.m_Width; } -Q3DStudio::IDocumentEditor &SGuideInspectableImpl::Editor() +Q3DStudio::IDocumentEditor &GuideInspectable::Editor() { return m_Editor.EnsureEditor(QObject::tr("Set Property"), __FILE__, __LINE__); } -void SGuideInspectableImpl::Commit() +void GuideInspectable::Commit() { m_Editor.CommitEditor(); } -void SGuideInspectableImpl::Rollback() +void GuideInspectable::Rollback() { m_Editor.RollbackEditor(); } -void SGuideInspectableImpl::FireRefresh() +void GuideInspectable::FireRefresh() { m_Editor.FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle()); } -void SGuideInspectableImpl::Destroy() +void GuideInspectable::Destroy() { m_Editor.EnsureEditor(QObject::tr("Delete Guide"), __FILE__, __LINE__).DeleteGuide(m_Guide); m_Editor.CommitEditor(); } -bool SGuideInspectableImpl::isHorizontal() const +bool GuideInspectable::isHorizontal() const { return Reader().GetGuideInfo(m_Guide).m_Direction == qt3dsdm::GuideDirections::Horizontal; } const std::vector<std::shared_ptr<IInspectableAttributeItem>> & -SGuideInspectableImpl::properties() const +GuideInspectable::properties() const { return m_Properties; } diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h index 66936ccd..7c9c0c77 100644 --- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h +++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h @@ -26,50 +26,37 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#pragma once -#ifndef __GUIDEINSPECTABLE_H__ -#define __GUIDEINSPECTABLE_H__ +#ifndef GUIDEINSPECTABLE_H +#define GUIDEINSPECTABLE_H + #include "Qt3DSDMHandles.h" -#include "Core.h" #include "InspectableBase.h" -#include "Doc.h" #include "IDocumentEditor.h" #include "IInspectableItem.h" -class CInspectableBase; - -class CGuideInspectable -{ -public: - static CInspectableBase *CreateInspectable(CCore &inCore, qt3dsdm::Qt3DSDMGuideHandle inGuide); -}; - -class SGuideInspectableImpl : public CInspectableBase +class GuideInspectable : public CInspectableBase { public: - SGuideInspectableImpl(CCore &inCore, qt3dsdm::Qt3DSDMGuideHandle inGuide); + GuideInspectable(qt3dsdm::Qt3DSDMGuideHandle inGuide); Q3DStudio::IDocumentReader &Reader() const; // Interface - EStudioObjectType GetObjectType() override; - Q3DStudio::CString GetName() override; - long GetGroupCount() override; - CInspectorGroup *GetGroup(long) override; - bool IsValid() const override; - bool IsMaster() override; + EStudioObjectType getObjectType() const override; + Q3DStudio::CString getName() override; + long getGroupCount() const override; + CInspectorGroup *getGroup(long) override; + bool isValid() const override; + bool isMaster() const override; + qt3dsdm::Qt3DSDMInstanceHandle getInstance() const override; // Implementation to get/set properties void SetDirection(const qt3dsdm::SValue &inValue); - - qt3dsdm::SValue GetDirection(); - void SetPosition(const qt3dsdm::SValue &inValue); - - qt3dsdm::SValue GetPosition(); - void SetWidth(const qt3dsdm::SValue &inValue); + qt3dsdm::SValue GetDirection(); + qt3dsdm::SValue GetPosition(); qt3dsdm::SValue GetWidth(); Q3DStudio::IDocumentEditor &Editor(); @@ -81,11 +68,11 @@ public: bool isHorizontal() const; const std::vector<std::shared_ptr<IInspectableAttributeItem>> &properties() const; + private: qt3dsdm::Qt3DSDMGuideHandle m_Guide; Q3DStudio::CUpdateableDocumentEditor m_Editor; std::vector<std::shared_ptr<IInspectableAttributeItem>> m_Properties; }; - #endif diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectableBase.cpp deleted file mode 100644 index 2b12fda6..00000000 --- a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "Qt3DSCommonPrecompile.h" -#include "InspectableBase.h" diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h b/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h index 34973393..fa21b57e 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h @@ -26,42 +26,29 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#pragma once -#ifndef __INSPECTABLEBASE_H__ -#define __INSPECTABLEBASE_H__ +#ifndef INSPECTABLEBASE_H +#define INSPECTABLEBASE_H -//============================================================================== -// Forwards -//============================================================================== class CInspectorGroup; -#include "Core.h" #include "StudioObjectTypes.h" +#include "Qt3DSString.h" +#include "Qt3DSDMHandles.h" -//============================================================================== -/** - * Parent class of Inspectable types that will appear in the Inspector Palette. - */ + // Parent class of Inspectable types that will appear in the Inspector Palette. class CInspectableBase { -protected: - CCore *m_Core; ///< - public: - CInspectableBase(CCore *inCore) - : m_Core(inCore) - { - } + CInspectableBase() {} virtual ~CInspectableBase() {} - // Interface - virtual EStudioObjectType GetObjectType() = 0; - // virtual std::wstring GetTypeString() const { return L""; } - virtual Q3DStudio::CString GetName() = 0; - virtual long GetGroupCount() = 0; - virtual CInspectorGroup *GetGroup(long inIndex) = 0; - virtual bool IsValid() const = 0; - virtual bool IsMaster() = 0; + virtual EStudioObjectType getObjectType() const = 0; + virtual Q3DStudio::CString getName() = 0; + virtual long getGroupCount() const = 0; + virtual CInspectorGroup *getGroup(long inIndex) = 0; + virtual bool isValid() const = 0; + virtual bool isMaster() const = 0; + virtual qt3dsdm::Qt3DSDMInstanceHandle getInstance() const = 0; }; -#endif // #ifndef __INSPECTABLEBASE_H__ +#endif // INSPECTABLEBASE_H diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index 01d8a3a1..ee6af48f 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "InspectorControlModel.h" +#include "StudioApp.h" #include "Core.h" #include "Doc.h" #include "InspectorGroup.h" @@ -35,7 +36,6 @@ #include "Qt3DSDMStudioSystem.h" #include "Qt3DSDMInspectable.h" #include "Qt3DSDMDataCore.h" -#include "StudioApp.h" #include "IDocumentEditor.h" #include "Qt3DSDMMetaData.h" #include "Qt3DSDMSignals.h" @@ -43,16 +43,11 @@ #include "GuideInspectable.h" #include "Qt3DSDMDataTypes.h" #include "IObjectReferenceHelper.h" -#include "Qt3DSDMXML.h" -#include "Qt3DSDMStringTable.h" -#include "Qt3DSFileTools.h" -#include "Qt3DSDMSlideCore.h" #include "SlideSystem.h" #include "Qt3DSDMMaterialInspectable.h" #include "ClientDataModelBridge.h" #include "IDocumentReader.h" #include "IStudioRenderer.h" -#include "foundation/Qt3DSLogging.h" #include "Dialogs.h" #include "Dispatch.h" #include "VariantsGroupModel.h" @@ -132,25 +127,24 @@ CInspectableBase *InspectorControlModel::inspectable() const return m_inspectableBase; } -qt3dsdm::Qt3DSDMInstanceHandle getReferenceMaterial(CInspectableBase *inspectBase) +qt3dsdm::Qt3DSDMInstanceHandle getReferenceMaterial(CInspectableBase *inspectable) { const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge(); - qt3dsdm::Qt3DSDMInstanceHandle refMaterial; - if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectBase)) - refMaterial = bridge->getMaterialReference(cdmInspectable->GetGroupInstance(0)); - return refMaterial; + ->GetClientDataModelBridge(); + + if (inspectable) + return bridge->getMaterialReference(inspectable->getInstance()); + + return 0; } -CInspectableBase *getReferenceMaterialInspectable(CInspectableBase *inspectBase) +CInspectableBase *getReferenceMaterialInspectable(CInspectableBase *inspectable) { - const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge(); - if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectBase)) { - auto refMaterial = bridge->getMaterialReference(cdmInspectable->GetGroupInstance(0)); - if (refMaterial.Valid()) - return g_StudioApp.getInspectableFromInstance(refMaterial); - } + auto refMaterial = getReferenceMaterial(inspectable); + + if (refMaterial.Valid()) + return g_StudioApp.getInspectableFromInstance(refMaterial); + return nullptr; } @@ -158,11 +152,10 @@ void InspectorControlModel::notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle qt3dsdm::Qt3DSDMPropertyHandle inProperty) { auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); - if (!bridge->IsSceneGraphInstance(inInstance)) + if (!getBridge()->IsSceneGraphInstance(inInstance)) return; - if (inProperty == bridge->getVariantsProperty(inInstance)) { + if (inProperty == getBridge()->getVariantsProperty(inInstance)) { // variants model is updated upon edit but this is needed to handle undoing m_variantsModel->refresh(); return; @@ -206,80 +199,55 @@ bool InspectorControlModel::hasInstanceProperty(long instance, int handle) bool InspectorControlModel::isInsideMaterialContainer() const { - return isInsideMaterialContainer(dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)); + return isInsideMaterialContainer(m_inspectableBase); } -bool InspectorControlModel::isInsideMaterialContainer(Qt3DSDMInspectable *inspectable) const +bool InspectorControlModel::isInsideMaterialContainer(CInspectableBase *inspectable) const { - if (!inspectable) + if (!inspectable || !inspectable->getInstance()) return false; - const auto instance = inspectable->GetGroupInstance(0); - - if (!instance.Valid()) - return false; - - const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge(); - return bridge->isInsideMaterialContainer(instance); + return getBridge()->isInsideMaterialContainer(inspectable->getInstance()); } bool InspectorControlModel::isDefaultMaterial() const { - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); - - qt3dsdm::Qt3DSDMInstanceHandle instance; - if (const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)) - instance = inspectable->GetGroupInstance(0); + if (m_inspectableBase) + return getBridge()->isDefaultMaterial(m_inspectableBase->getInstance()); - return bridge->isDefaultMaterial(instance); + return false; } bool InspectorControlModel::isAnimatableMaterial() const { - return isAnimatableMaterial(dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)); + return isAnimatableMaterial(m_inspectableBase); } -bool InspectorControlModel::isAnimatableMaterial(Qt3DSDMInspectable *inspectable) const +bool InspectorControlModel::isAnimatableMaterial(CInspectableBase *inspectable) const { if (!inspectable) return false; - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); - - const auto instance = inspectable->GetGroupInstance(0); - if (!instance.Valid()) - return false; - - const auto type = bridge->GetObjectType(instance); - - return type == OBJTYPE_CUSTOMMATERIAL || type == OBJTYPE_MATERIAL; + return inspectable->getObjectType() & (OBJTYPE_CUSTOMMATERIAL | OBJTYPE_MATERIAL); } bool InspectorControlModel::isBasicMaterial() const { - return isBasicMaterial(dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)); + return isBasicMaterial(m_inspectableBase); } -bool InspectorControlModel::isBasicMaterial(Qt3DSDMInspectable *inspectable) const +bool InspectorControlModel::isBasicMaterial(CInspectableBase *inspectable) const { if (!inspectable) return false; - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); + if (inspectable->getObjectType() == OBJTYPE_REFERENCEDMATERIAL) { + const auto instance = inspectable->getInstance(); + if (!instance.Valid()) + return false; - const auto instance = inspectable->GetGroupInstance(0); - if (!instance.Valid()) - return false; - - const auto type = bridge->GetObjectType(instance); - - if (type == OBJTYPE_REFERENCEDMATERIAL) { - const auto refMaterial = bridge->getMaterialReference(instance); - if (refMaterial.Valid() && bridge->isInsideMaterialContainer(refMaterial)) + const auto refMaterial = getBridge()->getMaterialReference(instance); + if (refMaterial.Valid() && getBridge()->isInsideMaterialContainer(refMaterial)) return true; } @@ -288,37 +256,20 @@ bool InspectorControlModel::isBasicMaterial(Qt3DSDMInspectable *inspectable) con bool InspectorControlModel::isMaterial() const { - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); + if (m_inspectableBase) + return m_inspectableBase->getObjectType() & OBJTYPE_IS_MATERIAL; - qt3dsdm::Qt3DSDMInstanceHandle instance; - if (const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)) - instance = inspectable->GetGroupInstance(0); - - if (!instance.Valid()) - return false; - - const auto type = bridge->GetObjectType(instance); - - return type == OBJTYPE_CUSTOMMATERIAL || type == OBJTYPE_MATERIAL - || type == OBJTYPE_REFERENCEDMATERIAL; + return false; } void InspectorControlModel::addMaterial() { const auto doc = g_StudioApp.GetCore()->GetDoc(); - qt3dsdm::Qt3DSDMInstanceHandle instance; - if (const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)) - instance = inspectable->GetGroupInstance(0); - + qt3dsdm::Qt3DSDMInstanceHandle instance = m_inspectableBase->getInstance(); if (!instance.Valid()) return; - const auto studio = doc->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); - - QString path = doc->getSceneEditor()->getMaterialDirectoryPath() - + QStringLiteral("/Material"); + QString path = doc->getSceneEditor()->getMaterialDirectoryPath() + QStringLiteral("/Material"); QString extension = QStringLiteral(".materialdef"); auto absPath = path + extension; @@ -330,8 +281,8 @@ void InspectorControlModel::addMaterial() qt3dsdm::Qt3DSDMInstanceHandle newMaterial; { - newMaterial = Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QString()) - ->getOrCreateMaterial(absPath, false); + newMaterial = Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, {}) + ->getOrCreateMaterial(absPath, false); } // Several aspects of the editor are not updated correctly // if the data core is changed without a transaction @@ -346,37 +297,30 @@ void InspectorControlModel::addMaterial() Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Material Type"))); doc->SelectDataModelObject(newMaterial); - const auto type = bridge->GetObjectType(instance); + const auto type = getBridge()->GetObjectType(instance); if (type == OBJTYPE_REFERENCEDMATERIAL) { sceneEditor->setMaterialReferenceByPath(instance, absPath); const auto relPath = QDir(doc->GetDocumentDirectory().toQString()) .relativeFilePath(absPath); sceneEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath)); - sceneEditor->SetName(instance, bridge->GetName(newMaterial, true)); - studio->GetFullSystemSignalSender()->SendInstancePropertyValue( - instance, bridge->GetNameProperty()); + sceneEditor->SetName(instance, getBridge()->GetName(newMaterial, true)); + + doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue( + instance, getBridge()->GetNameProperty()); } } void InspectorControlModel::duplicateMaterial() { - const auto doc = g_StudioApp.GetCore()->GetDoc(); - - qt3dsdm::Qt3DSDMInstanceHandle instance; - if (const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase)) - instance = inspectable->GetGroupInstance(0); - + qt3dsdm::Qt3DSDMInstanceHandle instance = m_inspectableBase->getInstance(); if (!instance.Valid()) return; - const auto studio = doc->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); - const auto type = bridge->GetObjectType(instance); + const auto doc = g_StudioApp.GetCore()->GetDoc(); + const auto type = m_inspectableBase->getObjectType(); - if (type != OBJTYPE_MATERIAL && type != OBJTYPE_CUSTOMMATERIAL - && type != OBJTYPE_REFERENCEDMATERIAL) { + if (type & ~OBJTYPE_IS_MATERIAL) return; - } auto material = instance; if (type == OBJTYPE_REFERENCEDMATERIAL) @@ -385,7 +329,7 @@ void InspectorControlModel::duplicateMaterial() if (material.Valid()) { const auto sceneEditor = doc->getSceneEditor(); auto originalMaterialName = sceneEditor->GetName(material).toQString() - + QStringLiteral(" Copy"); + + QStringLiteral(" Copy"); int slashIndex = originalMaterialName.lastIndexOf(QLatin1Char('/')); if (slashIndex != -1) originalMaterialName = originalMaterialName.mid(slashIndex + 1); @@ -401,7 +345,7 @@ void InspectorControlModel::duplicateMaterial() qt3dsdm::Qt3DSDMInstanceHandle duplicate; { Q3DStudio::ScopedDocumentEditor scopedEditor( - Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QString())); + Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, {})); duplicate = scopedEditor->getOrCreateMaterial(materialName, false); scopedEditor->copyMaterialProperties(material, duplicate); } @@ -421,11 +365,11 @@ void InspectorControlModel::duplicateMaterial() if (type == OBJTYPE_REFERENCEDMATERIAL) { scopedEditor->setMaterialReferenceByPath(instance, absPath); const auto relPath = QDir(doc->GetDocumentDirectory().toQString()) - .relativeFilePath(absPath); + .relativeFilePath(absPath); scopedEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath)); - scopedEditor->SetName(instance, bridge->GetName(duplicate, true)); - studio->GetFullSystemSignalSender()->SendInstancePropertyValue( - instance, bridge->GetNameProperty()); + scopedEditor->SetName(instance, getBridge()->GetName(duplicate, true)); + doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue( + instance, getBridge()->GetNameProperty()); } } } @@ -439,13 +383,13 @@ void InspectorControlModel::updateMaterialValues(const QStringList &values, int if (isReferenced && m_groupElements.count() > 0) startIndex = m_groupElements.count() - 1; // Update the last group for referenced materials for (int row = startIndex; row < m_groupElements.count(); ++row) { - const CInspectorGroup *inspectorGroup = m_inspectableBase->GetGroup(row); + const CInspectorGroup *inspectorGroup = m_inspectableBase->getGroup(row); const auto group = dynamic_cast<const Qt3DSDMInspectorGroup *>(inspectorGroup); const auto materialGroup = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group); if (materialGroup && (materialGroup->isMaterialGroup() || isReferenced)) { if (m_groupElements[row].controlElements.size()) { auto item = m_groupElements[row].controlElements[elementIndex] - .value<InspectorControlBase *>(); + .value<InspectorControlBase *>(); item->m_values = values; Q_EMIT item->valuesChanged(); // Changing values resets the selected index, so pretend the value has also changed @@ -483,8 +427,7 @@ void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &mate = Q3DStudio::CFilePath::CombineBaseAndRelative(base, path); const QString name = g_StudioApp.GetCore()->GetDoc()->GetDocumentReader() - .GetCustomMaterialName( - absolutePath.toCString()).toQString(); + .GetCustomMaterialName(absolutePath.toCString()).toQString(); m_materials.push_back({name, relativePath}); } @@ -609,12 +552,12 @@ QString InspectorControlModel::getDefaultMaterialString() const bool InspectorControlModel::isGroupCollapsed(int groupIdx) const { - const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase); - if (inspectable && groupIdx > -1 && groupIdx < m_groupElements.size()) { - auto instance = inspectable->GetGroupInstance(0); - - if (m_collapseMap.contains(instance)) + if (m_inspectableBase) { + auto instance = m_inspectableBase->getInstance(); + if (instance && groupIdx > -1 && groupIdx < m_groupElements.size() + && m_collapseMap.contains(instance)) { return m_collapseMap[instance].contains(groupIdx); + } } return false; @@ -622,13 +565,14 @@ bool InspectorControlModel::isGroupCollapsed(int groupIdx) const void InspectorControlModel::updateGroupCollapseState(int groupIdx, bool isCollapsed) { - const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(m_inspectableBase); - if (inspectable && groupIdx > -1 && groupIdx < m_groupElements.size()) { - auto instance = inspectable->GetGroupInstance(0); - if (isCollapsed) - m_collapseMap[instance][groupIdx] = true; - else - m_collapseMap[instance].remove(groupIdx); + if (m_inspectableBase) { + auto instance = m_inspectableBase->getInstance(); + if (instance && groupIdx > -1 && groupIdx < m_groupElements.size()) { + if (isCollapsed) + m_collapseMap[instance][groupIdx] = true; + else + m_collapseMap[instance].remove(groupIdx); + } } } @@ -707,27 +651,21 @@ QStringList InspectorControlModel::matDataValues() const InspectorControlBase *InspectorControlModel::createMaterialTypeItem( Qt3DSDMInspectable *inspectable, int groupIndex) { - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto instance = inspectable->GetGroupInstance(groupIndex); - const auto bridge = studio->GetClientDataModelBridge(); - const auto type = bridge->GetObjectType(instance); - InspectorControlBase *item = new InspectorControlBase; - item->m_instance = instance; + item->m_instance = inspectable->GetGroupInstance(groupIndex); item->m_title = tr("Material Type"); item->m_dataType = qt3dsdm::DataModelDataType::StringRef; item->m_propertyType = qt3dsdm::AdditionalMetaDataType::None; item->m_tooltip = tr("Type of material being used"); - item->m_animatable = false; const QStringList values = materialTypeValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); - switch (type) { + switch (inspectable->getObjectType()) { case OBJTYPE_MATERIAL: case OBJTYPE_CUSTOMMATERIAL: item->m_value = getAnimatableMaterialString(); @@ -735,7 +673,7 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem( case OBJTYPE_REFERENCEDMATERIAL: item->m_value = getReferencedMaterialString(); - if (sourcePath == bridge->getDefaultMaterialName()) + if (sourcePath == getBridge()->getDefaultMaterialName()) item->m_value = getBasicMaterialString(); for (int matIdx = 0, end = int(m_matDatas.size()); matIdx < end; ++matIdx) { if (QString::compare(m_matDatas[matIdx].m_relativePath, @@ -744,6 +682,9 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem( } } break; + + default: + break; } return item; @@ -752,24 +693,19 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem( InspectorControlBase *InspectorControlModel::createShaderItem( Qt3DSDMInspectable *inspectable, int groupIndex) { - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto instance = inspectable->GetGroupInstance(groupIndex); - const auto bridge = studio->GetClientDataModelBridge(); - InspectorControlBase *item = new InspectorControlBase; - item->m_instance = instance; + item->m_instance = inspectable->GetGroupInstance(groupIndex); item->m_title = tr("Shader"); item->m_dataType = qt3dsdm::DataModelDataType::StringRef; item->m_propertyType = qt3dsdm::AdditionalMetaDataType::Renderable; item->m_tooltip = tr("Shader being used"); - item->m_animatable = false; const QStringList values = shaderValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); item->m_value = values[0]; for (int matIdx = 0, end = int(m_materials.size()); matIdx < end; ++matIdx) { @@ -783,24 +719,19 @@ InspectorControlBase *InspectorControlModel::createShaderItem( InspectorControlBase *InspectorControlModel::createMatDataItem( Qt3DSDMInspectable *inspectable, int groupIndex) { - const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); - const auto instance = inspectable->GetGroupInstance(groupIndex); - const auto bridge = studio->GetClientDataModelBridge(); - InspectorControlBase *item = new InspectorControlBase; - item->m_instance = instance; + item->m_instance = inspectable->GetGroupInstance(groupIndex); item->m_title = tr("Source Material"); item->m_dataType = qt3dsdm::DataModelDataType::StringRef; item->m_propertyType = qt3dsdm::AdditionalMetaDataType::ObjectRef; item->m_tooltip = tr("Source material definitions used"); - item->m_animatable = false; const QStringList values = matDataValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); item->m_value = getDefaultMaterialString(); for (int matIdx = 0, end = int(m_matDatas.size()); matIdx < end; ++matIdx) { @@ -861,8 +792,8 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp item->m_controllable = item->m_animatable || metaProperty.m_Controllable; // disable IBL Override for reference materials - if (item->m_title == QLatin1String("IBL Override") && studio->GetClientDataModelBridge() - ->GetObjectType(item->m_instance) == OBJTYPE_REFERENCEDMATERIAL) { + if (item->m_title == QLatin1String("IBL Override") + && getBridge()->GetObjectType(item->m_instance) == OBJTYPE_REFERENCEDMATERIAL) { item->m_enabled = false; } auto signalProvider = studio->GetFullSystemSignalProvider(); @@ -897,10 +828,8 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp qt3dsdm::SValue InspectorControlModel::currentPropertyValue(long instance, int handle) const { + auto propertySystem = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetPropertySystem(); qt3dsdm::SValue value; - const auto doc = g_StudioApp.GetCore()->GetDoc(); - auto studioSystem = doc->GetStudioSystem(); - const auto propertySystem = studioSystem->GetPropertySystem(); propertySystem->GetInstancePropertyValue(instance, handle, value); return value; @@ -979,7 +908,7 @@ bool InspectorControlModel::isTreeRebuildRequired(CInspectableBase* inspectBase) if (inspectBase != m_inspectableBase || !inspectBase) return true; - long theCount = m_inspectableBase->GetGroupCount(); + long theCount = m_inspectableBase->getGroupCount(); auto refMaterial = getReferenceMaterial(inspectBase); if (refMaterial != m_refMaterial) return true; @@ -991,7 +920,7 @@ bool InspectorControlModel::isTreeRebuildRequired(CInspectableBase* inspectBase) return true; for (long theIndex = 0; theIndex < theCount; ++theIndex) { - const CInspectorGroup *theInspectorGroup = m_inspectableBase->GetGroup(theIndex); + const CInspectorGroup *theInspectorGroup = m_inspectableBase->getGroup(theIndex); if (m_groupElements.at(theIndex).groupTitle != theInspectorGroup->GetName()) return true; } @@ -999,10 +928,11 @@ bool InspectorControlModel::isTreeRebuildRequired(CInspectableBase* inspectBase) return false; } -bool InspectorControlModel::isGroupRebuildRequired(CInspectableBase* inspectable, int theIndex) const +bool InspectorControlModel::isGroupRebuildRequired(CInspectableBase *inspectable, + int theIndex) const { Q_ASSERT(theIndex < m_groupElements.size()); - const CInspectorGroup *theInspectorGroup = inspectable->GetGroup(theIndex); + const CInspectorGroup *theInspectorGroup = inspectable->getGroup(theIndex); const auto existingGroup = m_groupElements.at(theIndex); if (existingGroup.groupTitle != theInspectorGroup->GetName()) return true; @@ -1010,8 +940,7 @@ bool InspectorControlModel::isGroupRebuildRequired(CInspectableBase* inspectable if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectable)) { int existingIndex = 0; if (const auto group = dynamic_cast<const Qt3DSDMInspectorGroup *>(theInspectorGroup)) { - const auto materialGroup - = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group); + const auto materialGroup = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group); if (materialGroup && materialGroup->isMaterialGroup()) { auto i = existingGroup.controlElements.at(existingIndex++).value<InspectorControlBase*>(); if (i->m_instance != cdmInspectable->GetGroupInstance(theIndex)) @@ -1037,28 +966,22 @@ bool InspectorControlModel::isGroupRebuildRequired(CInspectableBase* inspectable return false; } -auto InspectorControlModel::computeTree(CInspectableBase* inspectBase) +CClientDataModelBridge *InspectorControlModel::getBridge() const +{ + return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); +} + +auto InspectorControlModel::computeTree(CInspectableBase *inspectBase) -> QVector<GroupInspectorControl> { QVector<GroupInspectorControl> result; if (inspectBase) { - bool isMaterialFromFile = false; - - const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge();; - - qt3dsdm::Qt3DSDMInstanceHandle instance; - if (const auto inspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectBase)) - instance = inspectable->GetGroupInstance(0); - - if (instance.Valid()) - isMaterialFromFile = bridge->isInsideMaterialContainer(instance); - - long theCount = inspectBase->GetGroupCount(); - for (long theIndex = 0; theIndex < theCount; ++theIndex) { - result.append(computeGroup(inspectBase, theIndex, isMaterialFromFile, false)); - } + qt3dsdm::Qt3DSDMInstanceHandle instance = inspectBase->getInstance(); + bool isMatFromFile = instance.Valid() && getBridge()->isInsideMaterialContainer(instance); + long groupCount = inspectBase->getGroupCount(); + for (long idx = 0; idx < groupCount; ++idx) + result.append(computeGroup(inspectBase, idx, isMatFromFile, false)); if (isDefaultMaterial() && result.size() > 0) { result[result.size() - 1].groupInfo = tr("\nDefault material cannot be edited.\n\n" @@ -1072,13 +995,13 @@ auto InspectorControlModel::computeTree(CInspectableBase* inspectBase) if (refMaterialInspectable) { QString materialSrcPath; if (instance.Valid()) - materialSrcPath = bridge->GetSourcePath(instance).toQString(); + materialSrcPath = getBridge()->GetSourcePath(instance).toQString(); - if (materialSrcPath != bridge->getDefaultMaterialName() - && bridge->GetSourcePath(refMaterial) != Q3DStudio::CString::fromQString( - bridge->getDefaultMaterialName())) { + if (materialSrcPath != getBridge()->getDefaultMaterialName() + && getBridge()->GetSourcePath(refMaterial) != Q3DStudio::CString::fromQString( + getBridge()->getDefaultMaterialName())) { result.append(computeGroup(refMaterialInspectable, - refMaterialInspectable->GetGroupCount() - 1, + refMaterialInspectable->getGroupCount() - 1, true, true)); } } @@ -1088,11 +1011,11 @@ auto InspectorControlModel::computeTree(CInspectableBase* inspectBase) return result; } -auto InspectorControlModel::computeGroup(CInspectableBase* inspectable, - int theIndex, bool disableAnimation, bool isReference) +auto InspectorControlModel::computeGroup(CInspectableBase *inspectable, int theIndex, + bool disableAnimation, bool isReference) -> GroupInspectorControl { - CInspectorGroup* theInspectorGroup = inspectable->GetGroup(theIndex); + CInspectorGroup *theInspectorGroup = inspectable->getGroup(theIndex); GroupInspectorControl result; result.groupTitle = theInspectorGroup->GetName(); result.groupInfo.clear(); @@ -1102,8 +1025,7 @@ auto InspectorControlModel::computeGroup(CInspectableBase* inspectable, if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectable)) { if (const auto group = dynamic_cast<Qt3DSDMInspectorGroup *>(theInspectorGroup)) { - const auto materialGroup - = dynamic_cast<Qt3DSDMMaterialInspectorGroup *>(group); + const auto materialGroup = dynamic_cast<Qt3DSDMMaterialInspectorGroup *>(group); bool isMatData = isBasicMaterial(cdmInspectable); if (materialGroup && materialGroup->isMaterialGroup()) { InspectorControlBase *item = nullptr; @@ -1137,7 +1059,7 @@ auto InspectorControlModel::computeGroup(CInspectableBase* inspectable, result.controlElements.push_back(QVariant::fromValue(item)); } } - } else if (const auto guideInspectable = dynamic_cast<SGuideInspectableImpl *>(inspectable)) { + } else if (const auto guideInspectable = dynamic_cast<GuideInspectable *>(inspectable)) { // Guide properties don't come from metadata as they are not actual objects m_guideInspectable = guideInspectable; const auto &properties = m_guideInspectable->properties(); @@ -1191,7 +1113,6 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c { const auto doc = g_StudioApp.GetCore()->GetDoc(); auto studioSystem = doc->GetStudioSystem(); - auto bridge = studioSystem->GetClientDataModelBridge(); const auto propertySystem = studioSystem->GetPropertySystem(); qt3dsdm::SValue value; const auto instance = element->m_instance; @@ -1216,7 +1137,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c switch (element->m_dataType) { case qt3dsdm::DataModelDataType::String: { QString stringValue = qt3dsdm::get<QString>(value); - if (bridge->isInsideMaterialContainer(element->m_instance)) { + if (getBridge()->isInsideMaterialContainer(element->m_instance)) { int index = stringValue.lastIndexOf(QLatin1Char('/')); if (index != -1) stringValue = stringValue.mid(index + 1); @@ -1233,7 +1154,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c for (auto &str : strings) stringlist.append(QString::fromWCharArray(str.wide_str())); } else { - stringlist = qt3dsdm::get<QStringList>(info->m_MetaDataData);; + stringlist = qt3dsdm::get<QStringList>(info->m_MetaDataData); } auto slideSystem = studioSystem->GetSlideSystem(); @@ -1278,7 +1199,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c auto currentSlide = slideSystem->GetSlideByIndex(masterSlide, slideIndex); auto currentInstance = slideSystem->GetSlideInstance(currentSlide); - QString slideName = bridge->GetName(currentInstance).toQString(); + QString slideName = getBridge()->GetName(currentInstance).toQString(); //hack to add a separator before the item if (slideIndex == 1 && itemCount > 0) slideName += "|separator"; @@ -1416,12 +1337,12 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c if (objRefHelper) { qt3dsdm::Qt3DSDMInstanceHandle refInstance = objRefHelper->Resolve(value, instance); QString refName = objRefHelper->LookupObjectFormalName(refInstance).toQString(); - if (bridge->IsReferencedMaterialInstance(instance) && !refName.isEmpty()) { + if (getBridge()->IsReferencedMaterialInstance(instance) && !refName.isEmpty()) { // get the material's object name (parent) - auto parentInstance = bridge->GetParentInstance(refInstance); + auto parentInstance = getBridge()->GetParentInstance(refInstance); qt3dsdm::SValue vParent; propertySystem->GetInstancePropertyValue(parentInstance, - bridge->GetObjectDefinitions().m_Named.m_NameProp, vParent); + getBridge()->GetObjectDefinitions().m_Named.m_NameProp, vParent); QString parentName = qt3dsdm::get<QString>(vParent); refName.append(QLatin1String(" (") + parentName + QLatin1String(")")); } @@ -1470,7 +1391,7 @@ void InspectorControlModel::refreshTree() } else { // group structure is intact, let's walk to see which rows changed QVector<QObject *> deleteVector; - long theCount = m_inspectableBase->GetGroupCount(); + long theCount = m_inspectableBase->getGroupCount(); for (long theIndex = 0; theIndex < theCount; ++theIndex) { if (isGroupRebuildRequired(m_inspectableBase, theIndex)) { auto group = m_groupElements[theIndex]; @@ -1510,8 +1431,7 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan const auto sceneEditor = doc->getSceneEditor(); const auto studio = doc->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); - EStudioObjectType type = bridge->GetObjectType(instance); + EStudioObjectType type = getBridge()->GetObjectType(instance); auto material = instance; if (type == EStudioObjectType::OBJTYPE_IMAGE) @@ -1520,20 +1440,20 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan if (!material.Valid()) return; - const auto refMaterial = bridge->getMaterialReference(material); + const auto refMaterial = getBridge()->getMaterialReference(material); if (refMaterial.Valid()) material = refMaterial; - if (!bridge->isInsideMaterialContainer(material)) + if (!getBridge()->isInsideMaterialContainer(material)) return; - type = bridge->GetObjectType(material); + type = getBridge()->GetObjectType(material); if (type == EStudioObjectType::OBJTYPE_MATERIAL || type == EStudioObjectType::OBJTYPE_CUSTOMMATERIAL) { qt3dsdm::SValue value; studio->GetPropertySystem()->GetInstancePropertyValue( - material, bridge->GetObjectDefinitions().m_Named.m_NameProp, value); + material, getBridge()->GetObjectDefinitions().m_Named.m_NameProp, value); qt3dsdm::TDataStrPtr namePtr(qt3dsdm::get<qt3dsdm::TDataStrPtr>(value)); QString materialName = QString::fromWCharArray(namePtr->GetData(), int(namePtr->GetLength())); @@ -1557,19 +1477,18 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons Q3DStudio::CString v; const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); const auto sceneEditor = doc->getSceneEditor(); const Q3DStudio::CString oldType = sceneEditor->GetObjectTypeName(instance); qt3dsdm::Qt3DSDMInstanceHandle refMaterial; if (oldType == "ReferencedMaterial") - refMaterial = bridge->getMaterialReference(instance); + refMaterial = getBridge()->getMaterialReference(instance); bool changeMaterialFile = false; bool canCopyProperties = false; if (typeValue == getAnimatableMaterialString()) { v = Q3DStudio::CString("Standard Material"); if (refMaterial.Valid()) { - const auto refSourcePath = bridge->GetSourcePath(refMaterial); + const auto refSourcePath = getBridge()->GetSourcePath(refMaterial); for (auto &material : m_materials) { if (refSourcePath.toQString() == material.m_relativePath) { v = Q3DStudio::CString::fromQString(material.m_relativePath); @@ -1596,7 +1515,7 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons if (refType == newType) scopedEditor->copyMaterialProperties(refMaterial, instance); - if (bridge->isInsideMaterialContainer(refMaterial)) { + if (getBridge()->isInsideMaterialContainer(refMaterial)) { const auto name = scopedEditor->GetName(instance); if (!name.toQString().endsWith(QLatin1String("_animatable"))) scopedEditor->SetName(instance, name + "_animatable"); @@ -1605,7 +1524,7 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons if (changeMaterialFile) { scopedEditor->setMaterialProperties(instance, Q3DStudio::CString::fromQString( - bridge->getDefaultMaterialName()), {}, {}); + getBridge()->getDefaultMaterialName()), {}, {}); // Select the original instance again since potentially creating a material selects the // created one @@ -1619,6 +1538,8 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons void InspectorControlModel::setShaderValue(long instance, int handle, const QVariant &value) { + Q_UNUSED(handle) + const QString typeValue = value.toString(); Q3DStudio::CString v("Standard Material"); for (size_t matIdx = 0, end = m_materials.size(); matIdx < end; ++matIdx) { @@ -1627,7 +1548,6 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar } const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Material Type")) ->SetMaterialType(instance, v); @@ -1636,7 +1556,7 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar QVector<qt3dsdm::Qt3DSDMInstanceHandle> refMats; doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats); for (auto &refMat : qAsConst(refMats)) { - const auto origMat = bridge->getMaterialReference(refMat); + const auto origMat = getBridge()->getMaterialReference(refMat); if (origMat.Valid() && (long)origMat == instance) dispatch->FireImmediateRefreshInstance(refMat); } @@ -1646,7 +1566,8 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar void InspectorControlModel::setMatDataValue(long instance, int handle, const QVariant &value) { - Q_UNUSED(handle); + Q_UNUSED(handle) + const QString typeValue = value.toString(); Q3DStudio::CString v; QString name; @@ -1655,12 +1576,11 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa QMap<QString, QMap<QString, QString>> textureValues; const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); bool changeMaterialFile = false; if (typeValue == getDefaultMaterialString()) { v = Q3DStudio::CString("Referenced Material"); - name = bridge->getDefaultMaterialName(); + name = getBridge()->getDefaultMaterialName(); srcPath = Q3DStudio::CString::fromQString(name); changeMaterialFile = true; } else { @@ -1746,9 +1666,8 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV { const auto doc = g_StudioApp.GetCore()->GetDoc(); const auto studio = doc->GetStudioSystem(); - const auto bridge = studio->GetClientDataModelBridge(); // Name property needs special handling - if (instance && handle == bridge->GetNameProperty()) { + if (instance && handle == getBridge()->GetNameProperty()) { // Ignore preview of name property change if (!commit) return; @@ -1757,22 +1676,23 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV m_modifiedProperty.second = 0; m_previouslyCommittedValue = {}; - Q3DStudio::CString currentName = bridge->GetName(instance, true); + Q3DStudio::CString currentName = getBridge()->GetName(instance, true); Q3DStudio::CString newName = Q3DStudio::CString::fromQString(value.toString()); if (!newName.IsEmpty()) { - if (bridge->isInsideMaterialContainer(instance) - && (newName.Find('/') != Q3DStudio::CString::ENDOFSTRING - || newName.Find('#') != Q3DStudio::CString::ENDOFSTRING - || newName.Find(':') != Q3DStudio::CString::ENDOFSTRING)) { + if (getBridge()->isInsideMaterialContainer(instance) + && (newName.Find('/') != Q3DStudio::CString::ENDOFSTRING + || newName.Find('#') != Q3DStudio::CString::ENDOFSTRING + || newName.Find(':') != Q3DStudio::CString::ENDOFSTRING)) { return; } - qt3dsdm::Qt3DSDMInstanceHandle parentInstance = bridge->GetParentInstance(instance); + qt3dsdm::Qt3DSDMInstanceHandle parentInstance = getBridge() + ->GetParentInstance(instance); if (parentInstance == doc->GetSceneInstance() - && newName.toQString() == bridge->getMaterialContainerName()) { + && newName.toQString() == getBridge()->getMaterialContainerName()) { QString theTitle = QObject::tr("Rename Object Error"); - QString theString = bridge->getMaterialContainerName() - + QObject::tr(" is a reserved name."); + QString theString = getBridge()->getMaterialContainerName() + + QObject::tr(" is a reserved name."); // Display error message box asynchronously so focus loss won't trigger setting // the name again g_StudioApp.GetDialogs()->asyncDisplayMessageBox(theTitle, theString, @@ -1781,18 +1701,19 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV } Q3DStudio::CString realNewName = newName; - if (bridge->isInsideMaterialContainer(instance)) { - Q3DStudio::CString realName = bridge->GetName(instance); + if (getBridge()->isInsideMaterialContainer(instance)) { + Q3DStudio::CString realName = getBridge()->GetName(instance); int slashIndex = realName.rfind('/'); if (slashIndex != Q3DStudio::CString::ENDOFSTRING) realNewName = realName.Left(slashIndex + 1) + newName; } - if (!bridge->CheckNameUnique(parentInstance, instance, realNewName)) { + if (!getBridge()->CheckNameUnique(parentInstance, instance, realNewName)) { QString origNewName = newName.toQString(); - realNewName = bridge->GetUniqueChildName(parentInstance, instance, realNewName); + realNewName = getBridge()->GetUniqueChildName(parentInstance, instance, + realNewName); newName = realNewName; - if (bridge->isInsideMaterialContainer(instance)) { + if (getBridge()->isInsideMaterialContainer(instance)) { int slashIndex = newName.rfind('/'); if (slashIndex != Q3DStudio::CString::ENDOFSTRING) newName = newName.substr(slashIndex + 1); @@ -1807,16 +1728,16 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV // A materialdef with the same name might exists as a file but not in the container, // so an additional check is needed for that case - if (bridge->isInsideMaterialContainer(instance)) { + if (getBridge()->isInsideMaterialContainer(instance)) { int i = 1; while (QFileInfo(sceneEditor->getFilePathFromMaterialName( realNewName.toQString())).exists()) { ++i; realNewName = Q3DStudio::CString::fromQString( realNewName.toQString() + QString::number(i)); - if (!bridge->CheckNameUnique(parentInstance, instance, realNewName)) { - realNewName = bridge->GetUniqueChildName( - parentInstance, instance, realNewName); + if (!getBridge()->CheckNameUnique(parentInstance, instance, realNewName)) { + realNewName = getBridge()->GetUniqueChildName(parentInstance, instance, + realNewName); } } newName = realNewName; @@ -1826,7 +1747,7 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV } if (newName != currentName) { - if (bridge->isInsideMaterialContainer(instance)) { + if (getBridge()->isInsideMaterialContainer(instance)) { const auto properOldName = sceneEditor->GetName(instance).toQString(); const auto dirPath = doc->GetDocumentDirectory().toQString(); for (size_t matIdx = 0, end = m_matDatas.size(); matIdx < end; ++matIdx) { @@ -1834,9 +1755,9 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV QFileInfo fileInfo(dirPath + QLatin1Char('/') + m_matDatas[matIdx].m_relativePath); const QString newFile = fileInfo.absolutePath() - + QLatin1Char('/') - + newName.toQString() - + QStringLiteral(".materialdef"); + + QLatin1Char('/') + + newName.toQString() + + QStringLiteral(".materialdef"); const auto properNewName = sceneEditor->getMaterialNameFromFilePath(newFile); newName = Q3DStudio::CString::fromQString(properNewName); @@ -1879,7 +1800,7 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV // is generally not useful anyway.) We could silently discard zero values also deeper in the // value setter code, but then the inspector panel value would not be updated as opposed // to both rejecting invalid and resetting the original value here. - EStudioObjectType theType = bridge->GetObjectType(instance); + EStudioObjectType theType = getBridge()->GetObjectType(instance); if (theType == EStudioObjectType::OBJTYPE_CAMERA && studio->GetPropertySystem()->GetName(handle) == Q3DStudio::CString("scale")) { @@ -2002,8 +1923,7 @@ void InspectorControlModel::setPropertyControlled(long instance, int property) bool InspectorControlModel::isLayer(long instance) const { - return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge() - ->GetObjectType(instance) == EStudioObjectType::OBJTYPE_LAYER; + return getBridge()->GetObjectType(instance) == EStudioObjectType::OBJTYPE_LAYER; } QString InspectorControlModel::renderableId(const QString &filePath) const diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h index 85c9c391..af88050d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h @@ -32,7 +32,6 @@ #include "Qt3DSDMValue.h" #include "Qt3DSDMMetaDataValue.h" #include "Qt3DSDMMetaDataTypes.h" -#include "Qt3DSFileTools.h" #include "IDocumentEditor.h" #include <QtCore/qabstractitemmodel.h> @@ -40,8 +39,9 @@ class CInspectableBase; class Qt3DSDMInspectable; -class SGuideInspectableImpl; +class GuideInspectable; class VariantsGroupModel; +class CClientDataModelBridge; namespace qt3dsdm { class ISignalConnection; @@ -174,7 +174,7 @@ private: QVector<GroupInspectorControl> m_groupElements; CInspectableBase *m_inspectableBase = nullptr; - SGuideInspectableImpl *m_guideInspectable = nullptr; + GuideInspectable *m_guideInspectable = nullptr; struct MaterialEntry { @@ -209,11 +209,11 @@ private: QString getStandardMaterialString() const; QString getDefaultMaterialString() const; bool isInsideMaterialContainer() const; - bool isInsideMaterialContainer(Qt3DSDMInspectable *inspectable) const; + bool isInsideMaterialContainer(CInspectableBase *inspectable) const; bool isAnimatableMaterial() const; - bool isAnimatableMaterial(Qt3DSDMInspectable *inspectable) const; + bool isAnimatableMaterial(CInspectableBase *inspectable) const; bool isBasicMaterial() const; - bool isBasicMaterial(Qt3DSDMInspectable *inspectable) const; + bool isBasicMaterial(CInspectableBase *inspectable) const; void updateMaterialValues(const QStringList &values, int elementIndex, bool updatingShaders = false); void updateShaderValues(); @@ -244,6 +244,8 @@ private: bool isReference = false); bool isGroupRebuildRequired(CInspectableBase *inspectable, int theIndex) const; + CClientDataModelBridge *getBridge() const; + static int handleToGuidePropIndex(int handle) { return handle - 1; } VariantsGroupModel *m_variantsModel = nullptr; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 0c04ba55..8ea1ffe5 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -62,6 +62,11 @@ #include "VariantTagDialog.h" #include "SlideView.h" #include "TimelineWidget.h" +#include "SelectedValue.h" +#include "Qt3DSDMInspectable.h" +#include "Qt3DSDMSlides.h" +#include "Qt3DSDMMaterialInspectable.h" +#include "GuideInspectable.h" #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> @@ -262,7 +267,7 @@ QAbstractItemModel *InspectorControlView::inspectorControlModel() const QString InspectorControlView::titleText() const { if (m_inspectableBase) { - Q3DStudio::CString theName = m_inspectableBase->GetName(); + Q3DStudio::CString theName = m_inspectableBase->getName(); if (theName == L"PathAnchorPoint") return tr("Anchor Point"); else @@ -332,7 +337,7 @@ void InspectorControlView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inIn // which will invalidate the inspectable anyway, so in reality we are only interested in name // property here if (inProperty == bridge->GetNameProperty() && m_inspectableBase - && m_inspectableBase->IsValid()) { + && m_inspectableBase->isValid()) { Q_EMIT titleChanged(); } } @@ -377,7 +382,7 @@ QColor InspectorControlView::titleColor(int instance, int handle) const QString InspectorControlView::titleIcon() const { if (m_inspectableBase) - return CStudioObjectTypes::GetNormalIconName(m_inspectableBase->GetObjectType()); + return CStudioObjectTypes::GetNormalIconName(m_inspectableBase->getObjectType()); return {}; } @@ -391,18 +396,65 @@ bool InspectorControlView::isEditable(int handle) const return true; } -void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue inSelectable) +void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue selectable) { - updateInspectable(g_StudioApp.GetInspectableFromSelectable(inSelectable)); + CInspectableBase *inspectable = createInspectableFromSelectable(selectable); + + if (inspectable && !inspectable->isValid()) + inspectable = nullptr; + + setInspectable(inspectable); } -void InspectorControlView::updateInspectable(CInspectableBase *inInspectable) +CInspectableBase *InspectorControlView::createInspectableFromSelectable( + Q3DStudio::SSelectedValue selectable) { - if (inInspectable != nullptr) { - if (inInspectable->IsValid() == false) - inInspectable = nullptr; + using namespace Q3DStudio; + + CInspectableBase *inspectableBase = nullptr; + if (!selectable.empty()) { + switch (selectable.getType()) { + case SelectedValueTypes::Slide: { + // TODO: seems like slides are not directly selectable, this should be removed. + auto selectableInstance = selectable.getData<SSlideInstanceWrapper>().m_Instance; + inspectableBase = new Qt3DSDMInspectable(selectableInstance); + } break; + + case SelectedValueTypes::MultipleInstances: + case SelectedValueTypes::Instance: { + CDoc *doc = g_StudioApp.GetCore()->GetDoc(); + // Note: Inspector doesn't support multiple selection + qt3dsdm::TInstanceHandleList selectedsInstances = selectable.GetSelectedInstances(); + Qt3DSDMInstanceHandle selectedInstance = selectedsInstances[0]; + if (selectedsInstances.size() == 1 + && doc->GetDocumentReader().IsInstance(selectedInstance)) { + CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide(); + + // Scene or Component (when being edited) + if (selectedInstance == bridge->GetOwningComponentInstance(activeSlide)) { + Qt3DSDMInstanceHandle activeSlideInstance = doc->GetStudioSystem() + ->GetSlideSystem()->GetSlideInstance(activeSlide); + inspectableBase = new Qt3DSDMInspectable(selectedInstance, activeSlideInstance); + } else if (bridge->IsMaterialBaseInstance(selectedInstance)) { + inspectableBase = new Qt3DSDMMaterialInspectable(selectedInstance); + } else { + inspectableBase = new Qt3DSDMInspectable(selectedInstance); + } + } + } break; + + case SelectedValueTypes::Guide: { + qt3dsdm::Qt3DSDMGuideHandle guide = selectable.getData<qt3dsdm::Qt3DSDMGuideHandle>(); + inspectableBase = new GuideInspectable(guide); + } break; + + default: + break; // Ignore slide insertion and unknown selectable types + }; } - setInspectable(inInspectable); + + return inspectableBase; } void InspectorControlView::setInspectable(CInspectableBase *inInspectable) @@ -810,7 +862,7 @@ void InspectorControlView::OnBeginDataModelNotifications() void InspectorControlView::OnEndDataModelNotifications() { CInspectableBase *inspectable = m_inspectorControlModel->inspectable(); - if (inspectable && !inspectable->IsValid()) + if (inspectable && !inspectable->isValid()) OnSelectionSet(Q3DStudio::SSelectedValue()); m_inspectorControlModel->refresh(); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h index cb852824..29cff25b 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h @@ -114,7 +114,6 @@ protected: private: void setInspectable(CInspectableBase *inInspectable); - void updateInspectable(CInspectableBase *inInspectable); void initialize(); void onFilesChanged(const Q3DStudio::TFileModificationList &inFileModificationList); void OnNewPresentation() override; @@ -122,6 +121,7 @@ private: void filterMaterials(std::vector<Q3DStudio::CFilePath> &materials); void filterMatDatas(std::vector<Q3DStudio::CFilePath> &matDatas); void setPropertyValueFromFilename(long instance, int handle, const QString &name); + CInspectableBase *createInspectableFromSelectable(Q3DStudio::SSelectedValue selectable); bool canLinkProperty(int instance, int handle) const; bool canOpenInInspector(int instance, int handle) const; void openInInspector(); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.cpp index c3ea86cb..84967f4c 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.cpp @@ -29,31 +29,15 @@ #include "InspectorGroup.h" -//============================================================================== -/** - * Constructor - */ -CInspectorGroup::CInspectorGroup() +CInspectorGroup::CInspectorGroup(const QString &inName) { + m_name = inName; } -//============================================================================== -/** - * Destructor - */ CInspectorGroup::~CInspectorGroup() { } -//============================================================================== -/** - * Set the name to show up in the title bar - */ -void CInspectorGroup::SetName(const QString &inName) -{ - m_name = inName; -} - QString CInspectorGroup::GetName() const { return m_name; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.h b/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.h index 98ac824d..18f56d79 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorGroup.h @@ -27,37 +27,22 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_INSPECTOR_GROUP_H -#define INCLUDED_INSPECTOR_GROUP_H 1 - -#pragma once +#define INCLUDED_INSPECTOR_GROUP_H #include <QString> -//============================================================================== /** - * @class CInspectorGroup - * @brief This is the base class for inspector groups. + * This is the base class for inspector groups. * - * Derive from this class in order to create a new group for the inspector - * palette. + * Derive from this class in order to create a new group for the inspector palette. */ class CInspectorGroup { public: - enum EGroupCommand { - EGroupCommandNone = 0, - EGroupCommandToggle, - }; - -public: - CInspectorGroup(); + CInspectorGroup(const QString &inName = {}); virtual ~CInspectorGroup(); - void SetName(const QString &inName); QString GetName() const; protected: diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp index 41be5767..87238847 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp @@ -75,7 +75,7 @@ void ObjectBrowserView::setModel(ObjectListModel *model) | Qt::MatchRecursive))); for (int i = list.size(); i > 0; i--) - m_model->removeRow(list.at(i - 1).row(), m_model->index(0, 0)); + m_model->removeRow(list.at(i - 1).row()); m_ownerInstance = 0; m_selection = -1; diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp index a8382be5..866ed29e 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp @@ -27,110 +27,90 @@ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "Qt3DSDMInspectable.h" #include "Qt3DSDMInspectorGroup.h" -#include "Qt3DSDMInspectorRow.h" #include "StudioApp.h" +#include "Core.h" #include "Doc.h" #include "Qt3DSDMStudioSystem.h" #include "ClientDataModelBridge.h" -#include "Qt3DSDMDataCore.h" -#include "Qt3DSDMPropertyDefinition.h" -#include "Core.h" -#include "StudioFullSystem.h" -#include "StudioCoreSystem.h" -#include "Qt3DSDMMetaData.h" #include "Qt3DSDMSlides.h" #include "IDocumentReader.h" using namespace qt3dsdm; -//============================================================================== -/** - * Constructor - */ -Qt3DSDMInspectable::Qt3DSDMInspectable(CStudioApp &inApp, CCore *inCore, - qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMInstanceHandle inDualPersonalityInstance) - : CInspectableBase(inCore) - , m_Instance(inInstance) - , m_DualPersonalityInstance((inDualPersonalityInstance != 0) ? inDualPersonalityInstance - : inInstance) - , m_App(inApp) +Qt3DSDMInspectable::Qt3DSDMInspectable(qt3dsdm::Qt3DSDMInstanceHandle instance, + qt3dsdm::Qt3DSDMInstanceHandle activeSlideInstance) + : m_instance(instance) + , m_activeSlideInstance(activeSlideInstance) { - QT3DS_ASSERT(inCore->GetDoc()->GetDocumentReader().IsInstance(m_Instance)); + QT3DS_ASSERT(getDoc()->GetDocumentReader().IsInstance(m_instance)); + + if (m_activeSlideInstance) { + // only active root scene or components set m_activeSlideInstance + auto *bridge = getDoc()->GetStudioSystem()->GetClientDataModelBridge(); + QT3DS_ASSERT(bridge->IsSceneInstance(instance) + || bridge->IsComponentInstance(instance)); + } } -//============================================================================== -/** - * Query the name of the inspectable item - */ -Q3DStudio::CString Qt3DSDMInspectable::GetName() +// Returns the name of this inspectable +Q3DStudio::CString Qt3DSDMInspectable::getName() { - CClientDataModelBridge *theBridge = - m_Core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + auto *bridge = getDoc()->GetStudioSystem()->GetClientDataModelBridge(); - if (m_Instance == m_DualPersonalityInstance) - return theBridge->GetName(m_Instance, true); + if (!m_activeSlideInstance) + return bridge->GetName(m_instance, true); - Q3DStudio::CString theName = theBridge->GetName(m_Instance, true); + Q3DStudio::CString theName = bridge->GetName(m_instance, true); theName += " ("; - theName += theBridge->GetName(m_DualPersonalityInstance, true); + theName += bridge->GetName(m_activeSlideInstance, true); theName += ")"; return theName; } -//============================================================================== -/** - * Query the number of groups to display - */ -long Qt3DSDMInspectable::GetGroupCount() +// Returns the number of groups in this inspectable +long Qt3DSDMInspectable::getGroupCount() const { - // If you have a dual personality inspectable then you may overwrite - QT3DS_ASSERT( - m_Instance == m_DualPersonalityInstance - || m_Core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge() - ->IsComponentInstance(m_Instance)); - IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); - long count = (long)theMetaData.GetGroupCountForInstance(m_Instance); + IMetaData &theMetaData = *getDoc()->GetStudioSystem()->GetActionMetaData(); + // In addition to a background group, Scene has a basic properties group (hidden in + // inspector) because it is derived from Asset. Until this is fixed properly, we force the + // Scene groups count to 1 (else an empty group will appear in the inspector). + long count = getObjectType() == OBJTYPE_SCENE ? 1 + : long(theMetaData.GetGroupCountForInstance(m_instance)); + + if (m_activeSlideInstance) + count += long(theMetaData.GetGroupCountForInstance(m_activeSlideInstance)); + return count; } -//============================================================================== -/** - * Return the property group for display - */ -CInspectorGroup *Qt3DSDMInspectable::GetGroup(long inIndex) +// Return the property group for display +CInspectorGroup *Qt3DSDMInspectable::getGroup(long inIndex) { - Qt3DSDMInspectorGroup *theGroup = - new Qt3DSDMInspectorGroup(m_App, GetGroupName(inIndex), *this, inIndex); + Qt3DSDMInspectorGroup *group = new Qt3DSDMInspectorGroup(GetGroupName(inIndex)); - TMetaDataPropertyHandleList theProperties = GetGroupProperties(inIndex); + TMetaDataPropertyHandleList properties = GetGroupProperties(inIndex); - size_t thePropertyCount = theProperties.size(); - for (size_t thePropertyIndex = 0; thePropertyIndex < thePropertyCount; ++thePropertyIndex) - theGroup->CreateRow(m_Core->GetDoc(), theProperties[thePropertyIndex]); + for (auto &prop : properties) + group->CreateRow(getDoc(), prop); - return theGroup; + return group; } -//============================================================================== -/** - * Return the property handles for display, given the group index - */ +// Return the property handles for display, given the group index TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex) { + long activeGroupIdx = activeGroupIndex(inIndex); TMetaDataPropertyHandleList retval; - IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); + IMetaData &theMetaData = *getDoc()->GetStudioSystem()->GetActionMetaData(); theMetaData.GetMetaDataProperties(GetGroupInstance(inIndex), retval); - qt3dsdm::IPropertySystem &thePropertySystem( - *m_Core->GetDoc()->GetStudioSystem()->GetPropertySystem()); - // get name of the current group fofr filtering + qt3dsdm::IPropertySystem &thePropertySystem(*getDoc()->GetStudioSystem()->GetPropertySystem()); + // get name of the current group for filtering Option<qt3dsdm::TCharStr> theGroupFilterName = - theMetaData.GetGroupFilterNameForInstance(GetGroupInstance(inIndex), inIndex); - long theGroupCount = GetGroupCount(); + theMetaData.GetGroupFilterNameForInstance(GetGroupInstance(inIndex), activeGroupIdx); + long theGroupCount = getGroupCount(); // end is explicitly required for (size_t idx = 0; idx < retval.size(); ++idx) { @@ -161,9 +141,7 @@ TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex) SValue theValue; thePropertySystem.GetInstancePropertyValue( GetGroupInstance(inIndex), theFilter.m_FilterProperty, theValue); - bool resultIfTrue = - theFilter.m_FilterType == PropertyFilterTypes::ShowIfEqual - ? true : false; + bool resultIfTrue = theFilter.m_FilterType == PropertyFilterTypes::ShowIfEqual; if (Equals(theValue.toOldSkool(), theFilter.m_Value.toOldSkool())) { keepProperty = resultIfTrue; break; @@ -181,117 +159,58 @@ TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex) return retval; } -//============================================================================== -/** - * Return the Resource String ID for the Group Name, given the group index - */ -QString Qt3DSDMInspectable::GetGroupName(long inGroupIndex) +// Return the Group Name, given the group index +QString Qt3DSDMInspectable::GetGroupName(long groupIndex) { std::vector<TCharStr> theGroupNames; - IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); - theMetaData.GetGroupNamesForInstance(GetGroupInstance(inGroupIndex), theGroupNames); + IMetaData &theMetaData = *getDoc()->GetStudioSystem()->GetActionMetaData(); + theMetaData.GetGroupNamesForInstance(GetGroupInstance(groupIndex), theGroupNames); - size_t theIndex = inGroupIndex; + long activeGroupIdx = activeGroupIndex(groupIndex); + if (activeGroupIdx < theGroupNames.size()) + return Q3DStudio::CString(theGroupNames[activeGroupIdx].wide_str()).toQString(); - if (theGroupNames.size() > theIndex) { - Q3DStudio::CString theName = theGroupNames[inGroupIndex].wide_str(); - return theName.toQString(); - } else { - return QObject::tr("Basic Properties"); - } + return QObject::tr("Basic Properties"); } -//============================================================================== -/** - * Return the Inspectable Instance Handle for the Group, given the group index - */ +// Return the Inspectable Instance Handle for the Group, given the group index Qt3DSDMInstanceHandle Qt3DSDMInspectable::GetGroupInstance(long inGroupIndex) { - Q_UNUSED(inGroupIndex); - return m_DualPersonalityInstance; -} + // if active root, return the slide instance at first index + if (m_activeSlideInstance && inGroupIndex == 0) + return m_activeSlideInstance; -EStudioObjectType Qt3DSDMInspectable::GetObjectType() -{ - IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); - Option<qt3dsdm::TCharStr> theObjTypeName = theMetaData.GetTypeForInstance(m_Instance); - if (theObjTypeName.hasValue()) { - ComposerObjectTypes::Enum theType = - ComposerObjectTypes::Convert(theObjTypeName->wide_str()); - switch (theType) { - case ComposerObjectTypes::Slide: { - CDoc *theDoc = m_Core->GetDoc(); - CClientDataModelBridge *theBridge = - theDoc->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::Qt3DSDMInstanceHandle theInstance = - theBridge->GetOwningComponentInstance(theDoc->GetActiveSlide()); - Option<TCharStr> theObjTypeName = theMetaData.GetTypeForInstance(theInstance); - if (theObjTypeName.hasValue()) { - ComposerObjectTypes::Enum theType = - ComposerObjectTypes::Convert(theObjTypeName->wide_str()); - if (theType == ComposerObjectTypes::Scene) - return OBJTYPE_SCENE; - else - return OBJTYPE_COMPONENT; - } - return OBJTYPE_UNKNOWN; - } - case ComposerObjectTypes::Scene: - return OBJTYPE_SCENE; - case ComposerObjectTypes::Layer: - return OBJTYPE_LAYER; - case ComposerObjectTypes::Behavior: - return OBJTYPE_BEHAVIOR; - case ComposerObjectTypes::Material: - return OBJTYPE_MATERIAL; - case ComposerObjectTypes::Camera: - return OBJTYPE_CAMERA; - case ComposerObjectTypes::Light: - return OBJTYPE_LIGHT; - case ComposerObjectTypes::Model: - return OBJTYPE_MODEL; - case ComposerObjectTypes::Group: - return OBJTYPE_GROUP; - case ComposerObjectTypes::Image: - return OBJTYPE_IMAGE; - case ComposerObjectTypes::Text: - return OBJTYPE_TEXT; - case ComposerObjectTypes::Component: - return OBJTYPE_COMPONENT; - case ComposerObjectTypes::Effect: - return OBJTYPE_EFFECT; - case ComposerObjectTypes::CustomMaterial: - return OBJTYPE_CUSTOMMATERIAL; - case ComposerObjectTypes::ReferencedMaterial: - return OBJTYPE_REFERENCEDMATERIAL; - case ComposerObjectTypes::Path: - return OBJTYPE_PATH; - case ComposerObjectTypes::SubPath: - return OBJTYPE_SUBPATH; - case ComposerObjectTypes::PathAnchorPoint: - return OBJTYPE_PATHANCHORPOINT; - case ComposerObjectTypes::Lightmaps: - return OBJTYPE_LIGHTMAPS; - default: - break; - } - } - return OBJTYPE_UNKNOWN; + return m_instance; } -bool Qt3DSDMInspectable::IsValid() const +EStudioObjectType Qt3DSDMInspectable::getObjectType() const { - return m_Core->GetDoc()->GetStudioSystem()->IsInstance(m_Instance) - && m_Core->GetDoc()->GetStudioSystem()->IsInstance(m_DualPersonalityInstance); + return getDoc()->GetStudioSystem()->GetClientDataModelBridge()->GetObjectType(m_instance); } -bool Qt3DSDMInspectable::IsMaster() +bool Qt3DSDMInspectable::isMaster() const { - ISlideSystem *theSlideSystem = m_Core->GetDoc()->GetStudioSystem()->GetSlideSystem(); - qt3dsdm::Qt3DSDMSlideHandle theSlideHandle = theSlideSystem->GetAssociatedSlide(m_Instance); + ISlideSystem *slideSystem = getDoc()->GetStudioSystem()->GetSlideSystem(); + qt3dsdm::Qt3DSDMSlideHandle theSlideHandle = slideSystem->GetAssociatedSlide(m_instance); if (theSlideHandle.Valid()) - return theSlideSystem->IsMasterSlide(theSlideHandle); + return slideSystem->IsMasterSlide(theSlideHandle); // Slide handle may not be valid if we are selecting the Scene or if we are inside Component and // we select the Component root. return false; } + +// Returns the group index taking into consideration that for active roots, first index is the slide +// group so need to decrement all index bigger than 1, by 1. For scene we decrement 1 more because +// the first group (Basic properties) is not in use. +long Qt3DSDMInspectable::activeGroupIndex(long groupIndex) const +{ + if (m_activeSlideInstance && groupIndex > 0 && getObjectType() != OBJTYPE_SCENE) + return groupIndex - 1; + + return groupIndex; +} + +CDoc *Qt3DSDMInspectable::getDoc() const +{ + return g_StudioApp.GetCore()->GetDoc(); +} diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h index 0f6dc626..69aae6f5 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h @@ -27,46 +27,38 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_QT3DSDM_INSPECTABLE_H -#define INCLUDED_QT3DSDM_INSPECTABLE_H 1 +#define INCLUDED_QT3DSDM_INSPECTABLE_H -//============================================================================== -// Includes -//============================================================================== #include "InspectableBase.h" #include "Qt3DSDMHandles.h" -#include "StudioApp.h" -//============================================================================== -/** -* For inspecting data model instances -*/ +class CDoc; + +// For inspecting data model instances class Qt3DSDMInspectable : public CInspectableBase { -protected: // Fields - qt3dsdm::Qt3DSDMInstanceHandle m_Instance; - qt3dsdm::Qt3DSDMInstanceHandle m_DualPersonalityInstance; - CStudioApp &m_App; - -public: // Constructor - Qt3DSDMInspectable(CStudioApp &inApp, CCore *inCore, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMInstanceHandle inDualPersonalityInstance = 0); +public: + Qt3DSDMInspectable(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + qt3dsdm::Qt3DSDMInstanceHandle activeSlideInstance = 0); -public: // CInspectableBase - Q3DStudio::CString GetName() override; - long GetGroupCount() override; - CInspectorGroup *GetGroup(long) override; - EStudioObjectType GetObjectType() override; - bool IsValid() const override; - bool IsMaster() override; + Q3DStudio::CString getName() override; + long getGroupCount() const override; + CInspectorGroup *getGroup(long) override; + EStudioObjectType getObjectType() const override; + bool isValid() const override { return true; } // asserted in the constructor + bool isMaster() const override; + qt3dsdm::Qt3DSDMInstanceHandle getInstance() const override { return m_instance; } virtual qt3dsdm::TMetaDataPropertyHandleList GetGroupProperties(long inGroupIndex); virtual qt3dsdm::Qt3DSDMInstanceHandle GetGroupInstance(long inGroupIndex); protected: + qt3dsdm::Qt3DSDMInstanceHandle m_instance; + qt3dsdm::Qt3DSDMInstanceHandle m_activeSlideInstance; + virtual QString GetGroupName(long inGroupIndex); + CDoc *getDoc() const; + long activeGroupIndex(long groupIndex) const; }; #endif diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp index 3cc9e5ff..f62812ac 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp @@ -27,50 +27,26 @@ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "Qt3DSDMInspectorGroup.h" #include "Qt3DSDMInspectorRow.h" #include "Qt3DSDMInspectable.h" -#include "StudioApp.h" -#include "Core.h" #include "Qt3DSDMMetaData.h" -#include "Doc.h" -#include "Qt3DSDMStudioSystem.h" -//============================================================================== -/** - * Constructor - */ -Qt3DSDMInspectorGroup::Qt3DSDMInspectorGroup(CStudioApp &inApp, const QString &inName, - Qt3DSDMInspectable &inInspectable, long inIndex) - : CEasyInspectorGroup(inName) - , m_App(inApp) - , m_Inspectable(inInspectable) - , m_Index(inIndex) +Qt3DSDMInspectorGroup::Qt3DSDMInspectorGroup(const QString &inName) + : CInspectorGroup(inName) { } -//============================================================================== -/** - * clean up - */ Qt3DSDMInspectorGroup::~Qt3DSDMInspectorGroup() { - std::vector<Q3DStudio::Qt3DSDMInspectorRow *>::iterator theIterator = - m_DMInspectorRows.begin(); - for (; theIterator != m_DMInspectorRows.end(); ++theIterator) - delete (*theIterator); + for (auto it = m_inspectorRows.begin(); it != m_inspectorRows.end(); ++it) + delete (*it); } -//============================================================================== -/** - * Method to create a new InspectorRowBase. - */ -void Qt3DSDMInspectorGroup::CreateRow(CDoc *inDoc, qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty) +// Create a new InspectorRowBase. +void Qt3DSDMInspectorGroup::CreateRow(CDoc *inDoc, + qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty) { - Q3DStudio::Qt3DSDMInspectorRow *theRow = - new Q3DStudio::Qt3DSDMInspectorRow(inDoc, inProperty); - m_DMInspectorRows.push_back( - theRow); // this Qt3DSDMInspectorRow is now owned by this class - + Q3DStudio::Qt3DSDMInspectorRow *theRow = new Q3DStudio::Qt3DSDMInspectorRow(inDoc, inProperty); + m_inspectorRows.push_back(theRow); // this Qt3DSDMInspectorRow is now owned by this class } diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.h index 203cf632..c2bbc9fc 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.h +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorGroup.h @@ -27,52 +27,31 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_QT3DSDM_INSPECTORGROUP_H -#define INCLUDED_QT3DSDM_INSPECTORGROUP_H 1 +#define INCLUDED_QT3DSDM_INSPECTORGROUP_H -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "EasyInspectorGroup.h" +#include "InspectorGroup.h" #include "Qt3DSDMHandles.h" -#include "StudioApp.h" +class Qt3DSDMInspectable; class CDoc; + namespace Q3DStudio { class Qt3DSDMInspectorRow; }; -class Qt3DSDMInspectable; - -//============================================================================== -/** - * - */ -class Qt3DSDMInspectorGroup: public CEasyInspectorGroup +class Qt3DSDMInspectorGroup : public CInspectorGroup { -protected: // Members - CStudioApp &m_App; - std::vector<Q3DStudio::Qt3DSDMInspectorRow *> m_DMInspectorRows; - Qt3DSDMInspectable &m_Inspectable; - long m_Index; - -public: // Construction - Qt3DSDMInspectorGroup(CStudioApp &inApp, const QString &inName, - Qt3DSDMInspectable &inInspectable, long inIndex); +public: + Qt3DSDMInspectorGroup(const QString &inName); ~Qt3DSDMInspectorGroup(); - const std::vector<Q3DStudio::Qt3DSDMInspectorRow *> &GetRows() const - { - return m_DMInspectorRows; - } - -public: // Use void CreateRow(CDoc *inDoc, qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty); + + const std::vector<Q3DStudio::Qt3DSDMInspectorRow *> &GetRows() const { return m_inspectorRows; } + +protected: + std::vector<Q3DStudio::Qt3DSDMInspectorRow *> m_inspectorRows; }; #endif diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.cpp index b71d515b..3f629df4 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.cpp @@ -26,33 +26,17 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" + #include "Qt3DSDMInspectorRow.h" #include "Qt3DSDMMetaData.h" #include "Doc.h" -#include "StudioApp.h" -#include "Qt3DSDMSlides.h" #include "Qt3DSDMStudioSystem.h" -#include "Qt3DSDMAnimation.h" -#include "Qt3DSDMSignals.h" -#include "CmdDataModelDeanimate.h" -#include "Qt3DSDMDataCore.h" -#include "Core.h" -#include "ClientDataModelBridge.h" -#include "IDocumentEditor.h" -//============================================================================== -// Namespace -//============================================================================== using namespace qt3dsdm; + namespace Q3DStudio { -//============================================================================== -/** - * Constructor - */ -Qt3DSDMInspectorRow::Qt3DSDMInspectorRow(CDoc *inDoc, - Qt3DSDMMetaDataPropertyHandle inProperty) +Qt3DSDMInspectorRow::Qt3DSDMInspectorRow(CDoc *inDoc, Qt3DSDMMetaDataPropertyHandle inProperty) : m_MetaProperty(inProperty) { IMetaData *theMetaData = inDoc->GetStudioSystem()->GetActionMetaData(); @@ -60,10 +44,6 @@ Qt3DSDMInspectorRow::Qt3DSDMInspectorRow(CDoc *inDoc, m_MetaDataPropertyInfo = theInfo; } -//============================================================================== -/** - * Destructor - */ Qt3DSDMInspectorRow::~Qt3DSDMInspectorRow() { } diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.h index 568d9d81..6c8156c1 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.h +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectorRow.h @@ -28,63 +28,30 @@ ****************************************************************************/ #pragma once -//============================================================================== -// Includes -//============================================================================== #include "Qt3DSDMHandles.h" -#include "DispatchListeners.h" #include "Qt3DSDMMetaDataTypes.h" -#include "CmdBatch.h" -//============================================================================== -// Forwards -//============================================================================== class CDoc; -class CEasyInspectorRow; -// DataModel -namespace qt3dsdm { -class ISignalConnection; -} - -class CGenericEdit; -//============================================================================== -// Namespace -//============================================================================== namespace Q3DStudio { -//============================================================================== -/** - * This is a binding between a DataModelInspectable and an EasyInspectorRow - */ +// This is a binding between a DataModelInspectable and an InspectorRow class Qt3DSDMInspectorRow { - //============================================================================== - // Members - //============================================================================== -protected: - qt3dsdm::Qt3DSDMMetaDataPropertyHandle m_MetaProperty; - qt3dsdm::SMetaDataPropertyInfo m_MetaDataPropertyInfo; - - //============================================================================== - // Methods - //============================================================================== -public: // Construction - Qt3DSDMInspectorRow(CDoc *inDoc, qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty); +public: + explicit Qt3DSDMInspectorRow(CDoc *inDoc, qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty); virtual ~Qt3DSDMInspectorRow(); -private: // Disabled parameterless construction - Qt3DSDMInspectorRow(); + qt3dsdm::Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty() const { return m_MetaProperty; } -public: // Use - qt3dsdm::Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty() const - { - return m_MetaProperty; - } const qt3dsdm::SMetaDataPropertyInfo &GetMetaDataPropertyInfo() const { return m_MetaDataPropertyInfo; } + +protected: + qt3dsdm::Qt3DSDMMetaDataPropertyHandle m_MetaProperty; + qt3dsdm::SMetaDataPropertyInfo m_MetaDataPropertyInfo; }; } // namespace Q3DStudio diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp index 45d3a105..69d86623 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp @@ -26,66 +26,25 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" + #include "Qt3DSDMMaterialInspectable.h" -#include "Qt3DSDMInspectorGroup.h" -#include "Qt3DSDMInspectorRow.h" -#include "Core.h" -#include "IDocumentEditor.h" -#include "Qt3DSDMHandles.h" -#include "Doc.h" -#include "GenericFunctor.h" -#include "StudioApp.h" -#include "Qt3DSDMStudioSystem.h" -#include "ClientDataModelBridge.h" -#include "IDocumentReader.h" -#include "Dispatch.h" -#include "IDirectoryWatchingSystem.h" -#include "Qt3DSDMSignals.h" -#include "Qt3DSString.h" using namespace qt3dsdm; -Qt3DSDMMaterialInspectorGroup::Qt3DSDMMaterialInspectorGroup( - CStudioApp &inApp, - const QString &inName, - Qt3DSDMInspectable &inInspectable, - long inIndex) - : Qt3DSDMInspectorGroup(inApp, inName, inInspectable, inIndex) +Qt3DSDMMaterialInspectorGroup::Qt3DSDMMaterialInspectorGroup(const QString &inName) + : Qt3DSDMInspectorGroup(inName) + , m_isMaterialGroup(inName == QLatin1String("Material")) { } -struct SQt3DSDMMaterialInspectorGroup : public Qt3DSDMMaterialInspectorGroup -{ - SQt3DSDMMaterialInspectorGroup(CStudioApp &inApp, const QString &inName, - Qt3DSDMInspectable &inInspectable, long inIndex) - : Qt3DSDMMaterialInspectorGroup(inApp, inName, inInspectable, inIndex) - { - QString theMaterialGroupName = QStringLiteral("Material"); - m_isMaterialGroup = (inName == theMaterialGroupName); - } - - bool isMaterialGroup() const override - { - return m_isMaterialGroup; - } - -private: - bool m_isMaterialGroup; -}; - -CInspectorGroup *Qt3DSDMMaterialInspectable::GetGroup(long inIndex) +CInspectorGroup *Qt3DSDMMaterialInspectable::getGroup(long inIndex) { - QString theGroupName = GetGroupName(inIndex); - - Qt3DSDMInspectorGroup *theGroup = - new SQt3DSDMMaterialInspectorGroup(m_App, theGroupName, *this, inIndex); + Qt3DSDMInspectorGroup *group = new Qt3DSDMMaterialInspectorGroup(GetGroupName(inIndex)); - TMetaDataPropertyHandleList theProperties = GetGroupProperties(inIndex); - size_t thePropertyCount = theProperties.size(); + TMetaDataPropertyHandleList properties = GetGroupProperties(inIndex); - for (size_t thePropertyIndex = 0; thePropertyIndex < thePropertyCount; ++thePropertyIndex) - theGroup->CreateRow(m_Core->GetDoc(), theProperties[thePropertyIndex]); + for (auto &prop : properties) + group->CreateRow(getDoc(), prop); - return theGroup; + return group; } diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.h index cfe09472..0367bb7a 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.h +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMMaterialInspectable.h @@ -27,11 +27,8 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_QT3DSDM_MATERIAL_INSPECTABLE_H -#define INCLUDED_QT3DSDM_MATERIAL_INSPECTABLE_H 1 +#define INCLUDED_QT3DSDM_MATERIAL_INSPECTABLE_H #include "Qt3DSDMInspectable.h" #include "Qt3DSDMInspectorGroup.h" @@ -39,22 +36,23 @@ class Qt3DSDMMaterialInspectorGroup : public Qt3DSDMInspectorGroup { public: - Qt3DSDMMaterialInspectorGroup(CStudioApp &inApp, const QString &inName, - Qt3DSDMInspectable &inInspectable, long inIndex); + Qt3DSDMMaterialInspectorGroup(const QString &inName); - virtual bool isMaterialGroup() const = 0; + bool isMaterialGroup() const { return m_isMaterialGroup; } + +private: + bool m_isMaterialGroup = false; }; class Qt3DSDMMaterialInspectable : public Qt3DSDMInspectable { public: - Qt3DSDMMaterialInspectable(CStudioApp &inApp, CCore *inCore, - qt3dsdm::Qt3DSDMInstanceHandle inInstance) - : Qt3DSDMInspectable(inApp, inCore, inInstance) + Qt3DSDMMaterialInspectable(qt3dsdm::Qt3DSDMInstanceHandle inInstance) + : Qt3DSDMInspectable(inInstance) { } - CInspectorGroup *GetGroup(long) override; + CInspectorGroup *getGroup(long) override; }; #endif diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.cpp deleted file mode 100644 index 7c4c7640..00000000 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "Qt3DSCommonPrecompile.h" -#include "Qt3DSDMSceneInspectable.h" -#include "Core.h" -#include "Doc.h" -#include "Qt3DSDMStudioSystem.h" - -Qt3DSDMSceneInspectable::Qt3DSDMSceneInspectable( - CStudioApp &inApp, CCore *inCore, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMInstanceHandle inCurrentActiveSlideInstance) - : Qt3DSDMInspectable(inApp, inCore, inInstance) - , m_CurrentActiveSlideInstance(inCurrentActiveSlideInstance) -{ -} - -bool Qt3DSDMSceneInspectable::IsValid() const -{ - return Qt3DSDMInspectable::IsValid() - && m_Core->GetDoc()->GetStudioSystem()->IsInstance(m_CurrentActiveSlideInstance); -} - -long Qt3DSDMSceneInspectable::GetGroupCount() -{ - return 2; // hard-coded to basic and shared -} - -//============================================================================== -/** - * Return the Resource String ID for the Group Name, given the group index - */ -QString Qt3DSDMSceneInspectable::GetGroupName(long inGroupIndex) -{ - return (inGroupIndex == 0) ? QObject::tr("Basic Properties") - : QObject::tr("Shared Properties"); -} - -qt3dsdm::Qt3DSDMInstanceHandle Qt3DSDMSceneInspectable::GetGroupInstance(long inGroupIndex) -{ - return (inGroupIndex == 0) ? m_CurrentActiveSlideInstance : m_Instance; -} diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.h deleted file mode 100644 index 515362e5..00000000 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMSceneInspectable.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_QT3DSDM_SCENE_INSPECTABLE_H -#define INCLUDED_QT3DSDM_SCENE_INSPECTABLE_H 1 - -//============================================================================== -// Includes -//============================================================================== -#include "Qt3DSDMInspectable.h" - -//============================================================================== -// Forwards -//============================================================================== - -//============================================================================== -/** -* For inspecting scene data model instances -*/ -class Qt3DSDMSceneInspectable : public Qt3DSDMInspectable -{ -public: - Qt3DSDMSceneInspectable(CStudioApp &inApp, CCore *inCore, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMInstanceHandle inCurrentActiveSlideInstance); - - bool IsValid() const override; - // Qt3DSDMInspectable - long GetGroupCount() override; - -protected: - inline QString GetGroupName(long inGroupIndex) override; - inline qt3dsdm::Qt3DSDMInstanceHandle GetGroupInstance(long inGroupIndex) override; - - qt3dsdm::Qt3DSDMInstanceHandle m_CurrentActiveSlideInstance; -}; - -#endif diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index 47e33461..df49701a 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -1042,10 +1042,13 @@ void TimelineGraphicsScene::updateHoverStatus(const QPointF &scenePos) tooltipStr.append("</td></tr>"); } tooltipStr.append("</table>"); + + int ttY = int(rowTree->y()) + + widgetTimeline()->navigationBar()->height(); + m_variantsToolTip->setText(tooltipStr); m_variantsToolTip->adjustSize(); - m_variantsToolTip->move(m_widgetTimeline->mapToGlobal( - {right, (int)rowTree->y()})); + m_variantsToolTip->move(m_widgetTimeline->mapToGlobal({right, ttY})); m_variantsToolTip->raise(); m_variantsToolTip->show(); m_variantsRowTree = rowTree; diff --git a/src/Authoring/Studio/Qt3DStudio.pro b/src/Authoring/Studio/Qt3DStudio.pro index 3ad5697e..722ee49c 100644 --- a/src/Authoring/Studio/Qt3DStudio.pro +++ b/src/Authoring/Studio/Qt3DStudio.pro @@ -297,13 +297,11 @@ SOURCES += \ Palettes/BasicObjects/BasicObjectsModel.cpp \ Palettes/BasicObjects/BasicObjectsView.cpp \ Palettes/Inspector/ChooserModelBase.cpp \ - Palettes/Inspector/EasyInspectorGroup.cpp \ Palettes/Inspector/FileChooserModel.cpp \ Palettes/Inspector/FileChooserView.cpp \ Palettes/Inspector/GuideInspectable.cpp \ Palettes/Inspector/ImageChooserModel.cpp \ Palettes/Inspector/ImageChooserView.cpp \ - Palettes/Inspector/InspectableBase.cpp \ Palettes/Inspector/InspectorControlModel.cpp \ Palettes/Inspector/InspectorControlView.cpp \ Palettes/Inspector/InspectorGroup.cpp \ @@ -316,7 +314,6 @@ SOURCES += \ Palettes/Inspector/Qt3DSDMInspectorGroup.cpp \ Palettes/Inspector/Qt3DSDMInspectorRow.cpp \ Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp \ - Palettes/Inspector/Qt3DSDMSceneInspectable.cpp \ Palettes/Inspector/TabOrderHandler.cpp \ Palettes/Inspector/TextureChooserView.cpp \ Palettes/PaletteManager.cpp \ diff --git a/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml b/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml index 2df33774..c5b99119 100644 --- a/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml +++ b/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml @@ -55,7 +55,17 @@ <Property name="scaleanchor" formalName="Scale Anchor" description="Corner of the content to pin as the\nlayer size changes" list="Center:N:NE:E:SE:S:SW:W:NW" default="Center"/> </Camera> <Component> - <!--<Property name="name" formalName="Name" description="Object name" type="String" default="Component" hidden="False" />--> + <!-- Basic Properties --> + <Property name="name" formalName="Name" type="String" default="Model" category="Basic Properties" description="Object name" /> + <Property name="eyeball" formalName="Visible" type="Boolean" default="True" category="Basic Properties" description="Item visibility" /> + <Property name="position" formalName="Position" type="Vector" category="Basic Properties" description="Location in local space" /> + <Property name="rotation" formalName="Rotation" type="Rotation" category="Basic Properties" description="Rotation around local axes" /> + <Property name="scale" formalName="Scale" type="Vector" default="1 1 1" category="Basic Properties" description="Size adjustments along local axes" /> + <Property name="pivot" formalName="Pivot" type="Vector" category="Basic Properties" description="Offset of the contents away from the local center" /> + <Property name="opacity" formalName="Opacity" min="0" max="100" default="100" category="Basic Properties" /> + + <!-- Variant Tags --> + <Property name="variants" type="String" animatable="False" category="Variant Tags" /> </Component> <Effect> <Property name="name" formalName="Name" type="String" default="Effect" hidden="False" /> @@ -432,13 +442,17 @@ <Property name="name" formalName="Name" description="Object name" type="String" default="RenderPlugin" hidden="True" /> </RenderPlugin> <Scene> - <Property name="name" formalName="Name" type="String" default="Scene" hidden="True" /> - <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="True" /> - <Property name="bgcolorenable" formalName="Use Background" description="Clear the contents to a solid color\nbefore each frame?" type="Boolean" default="True" /> - <Property name="backgroundcolor" formalName="Background Color" description="Color to use for the background" type="Color" animatable="False" /> + <!-- Background --> + <Property name="bgcolorenable" formalName="Use Background" category="Background" type="Boolean" default="True" description="Clear the contents to a solid color\nbefore each frame?" /> + <Property name="backgroundcolor" formalName="Background Color" category="Background" type="Color" animatable="False" description="Color to use for the background" /> + <Event name="onPressureDown" category="Gesture" /> - <Event name="onPressureUp" category="Gesture" /> - <Event name="onTap" category="Gesture" /> + <Event name="onPressureUp" category="Gesture" /> + <Event name="onTap" category="Gesture" /> + + <!-- Hidden and commented out props --> + <Property name="name" formalName="Name" category="Basic Properties" type="String" default="Scene" hidden="True" /> + <Property name="eyeball" formalName="Visible" category="Basic Properties" type="Boolean" default="True" hidden="True" description="Item visibility" /> <!-- <Event name="onDoubleTap" category="Gesture" /> <Event name="onSingleTap" category="Gesture" /> @@ -459,11 +473,12 @@ --> </Scene> <Slide> - <Property name="playmode" formalName="Play Mode" description="Action to take when reaching the end of\nall timebars on this slide" list="Stop at end:Looping:PingPong:Ping:Play Through To..." default="Stop at end" animatable="False" /> - <Property name="playthroughto" formalName="Play Through To" description="Slide to go to after this one" type="StringListOrInt" list="Next:Previous" default="Next" animatable="False"> + <!-- Play Mode --> + <Property name="playmode" formalName="Play Mode" category="Play Mode" default="Stop at end" animatable="False" list="Stop at end:Looping:PingPong:Ping:Play Through To..." description="Action to take when reaching the end of\nall timebars on this slide" /> + <Property name="playthroughto" formalName="Play Through To" category="Play Mode" default="Next" animatable="False" type="StringListOrInt" list="Next:Previous" description="Slide to go to after this one"> <ShowIfEqual property="playmode" value="Play Through To..."/> </Property> - <Property name="initialplaystate" formalName="Initial Play State" description="Do animations start when coming to\nthis slide?" list="Play:Pause" default="Play" animatable="False" /> + <Property name="initialplaystate" formalName="Initial Play State" category="Play Mode" default="Play" animatable="False" list="Play:Pause" description="Do animations start when coming to\nthis slide?" /> </Slide> <SlideOwner> <Event name="onSlideEnter" category="Slide" description="Fired when the slide is changing" /> |