From a47e479b94cbd2cdc7493d0aeac9a5afc15407d8 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Wed, 15 May 2019 16:29:06 +0300 Subject: Fix wrong timeline rows placement after a Layer copy/paste - Material container is part of the scene graph but not the timeline. This caused wrong index to be sent from the graph to the timeline when an object is added. Fixed by keeping the material container in the timeline but hiding it. - Few relevant clean ups and removing useless code. Task-number: QT3DS-3406 Change-Id: I9ed8da3db4d935269650c00fc5b0a92349cf6fa3 Reviewed-by: Miikka Heikkinen --- .../Client/Code/Core/Doc/DocumentEditor.cpp | 16 ++-- .../Bindings/TimelineTranslationManager.cpp | 60 ++++++--------- .../Timeline/Bindings/TimelineTranslationManager.h | 32 ++------ .../Palettes/TimelineGraphicsView/RowManager.cpp | 87 +++------------------- .../Palettes/TimelineGraphicsView/RowManager.h | 4 - .../TimelineGraphicsView/TimelineWidget.cpp | 17 +---- .../Palettes/TimelineGraphicsView/ui/RowTree.cpp | 8 ++ 7 files changed, 55 insertions(+), 169 deletions(-) diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 71dc1de1..ba6e1fd9 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -3019,10 +3019,10 @@ public: } TInstanceHandleList PasteSceneGraphObject(const CFilePath &inFilePath, - TInstanceHandle inNewRoot, - bool inGenerateUniqueName, - DocumentEditorInsertType::Enum inInsertType, - const CPt &inPosition) override + TInstanceHandle inNewRoot, + bool inGenerateUniqueName, + DocumentEditorInsertType::Enum inInsertType, + const CPt &inPosition) override { qt3ds::QT3DSI32 theVersion = 0; std::shared_ptr theReader = m_Doc.CreateDOMReader( @@ -3116,9 +3116,9 @@ public: } void RearrangeObjects(const qt3dsdm::TInstanceHandleList &inInstances, - TInstanceHandle inDest, - DocumentEditorInsertType::Enum inInsertType, - bool checkUniqueName, bool notifyRename = true) override + TInstanceHandle inDest, + DocumentEditorInsertType::Enum inInsertType, + bool checkUniqueName, bool notifyRename = true) override { qt3dsdm::TInstanceHandleList sortableList(ToGraphOrdering(inInstances)); TInstanceHandle theParent(inDest); @@ -3126,7 +3126,7 @@ public: || inInsertType == DocumentEditorInsertType::NextSibling) theParent = GetParent(inDest); - // Moving object into into non-root component + // Moving object into non-root component if (m_Bridge.IsComponentInstance(theParent) && !m_Bridge.IsActiveComponent(theParent) && moveIntoComponent(inInstances, theParent, checkUniqueName, notifyRename)) { diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp index 1a191b19..c03867a7 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp @@ -27,7 +27,6 @@ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "TimelineTranslationManager.h" #include "SlideTimelineItemBinding.h" #include "GroupTimelineItemBinding.h" @@ -37,16 +36,12 @@ #include "PathAnchorPointTimelineItemBinding.h" #include "PathTimelineItemBinding.h" #include "LayerTimelineItemBinding.h" -#include "IDoc.h" #include "Qt3DSDMStudioSystem.h" -#include "Qt3DSDMSlides.h" - -// Link to Data model -#include "ClientDataModelBridge.h" -#include "Qt3DSDMDataCore.h" -#include "Doc.h" //Because we need to access Client Data Model Bridge +#include "StudioObjectTypes.h" #include "StudioApp.h" #include "Core.h" +#include "Doc.h" +#include "ClientDataModelBridge.h" using namespace qt3dsdm; @@ -65,58 +60,49 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa ITimelineItemBinding *theBinding = GetBinding(inInstance); if (!theBinding) { Qt3DSDMTimelineItemBinding *theReturn = nullptr; - qt3dsdm::IPropertySystem *thePropertySystem = GetStudioSystem()->GetPropertySystem(); - Qt3DSDMPropertyHandle theTypeProperty = - thePropertySystem->GetAggregateInstancePropertyByName(inInstance, L"type"); - SValue theTypeValue; - thePropertySystem->GetInstancePropertyValue(inInstance, theTypeProperty, theTypeValue); + EStudioObjectType objType = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() + ->GetClientDataModelBridge()->GetObjectType(inInstance); - std::wstring theWideTypeString(qt3dsdm::get(theTypeValue)->GetData()); - - if (theWideTypeString == L"Material" || theWideTypeString == L"CustomMaterial" - || theWideTypeString == L"ReferencedMaterial") + if (objType & OBJTYPE_IS_MATERIAL) { theReturn = new CMaterialTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Image") + } else if (objType == OBJTYPE_IMAGE) { theReturn = new CImageTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Group" || theWideTypeString == L"Component") + } else if (objType & (OBJTYPE_GROUP | OBJTYPE_COMPONENT)) { theReturn = new CGroupTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Behavior") + } else if (objType == OBJTYPE_BEHAVIOR) { theReturn = new CBehaviorTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Slide") + } else if (objType == OBJTYPE_SLIDE) { theReturn = new CSlideTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"PathAnchorPoint") + } else if (objType == OBJTYPE_PATHANCHORPOINT) { theReturn = new CPathAnchorPointTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Path") + } else if (objType == OBJTYPE_PATH) { theReturn = new CPathTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Layer") + } else if (objType == OBJTYPE_LAYER) { theReturn = new CLayerTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Model" || theWideTypeString == L"Text" - || theWideTypeString == L"Camera" || theWideTypeString == L"Effect" - || theWideTypeString == L"Light" || theWideTypeString == L"RenderPlugin" - || theWideTypeString == L"Alias" || theWideTypeString == L"SubPath") + } else if (objType & (OBJTYPE_MODEL | OBJTYPE_TEXT | OBJTYPE_CAMERA | OBJTYPE_EFFECT + | OBJTYPE_LIGHT | OBJTYPE_RENDERPLUGIN | OBJTYPE_ALIAS + | OBJTYPE_SUBPATH)) theReturn = new Qt3DSDMTimelineItemBinding(this, inInstance); else { // Add support for additional DataModel types here. Q_ASSERT(0); } - m_InstanceHandleBindingMap.insert( - std::make_pair(theReturn->GetInstanceHandle(), theReturn)); + m_InstanceBindingMap.insert({theReturn->GetInstanceHandle(), theReturn}); theBinding = theReturn; } return theBinding; } -//============================================================================== /** * Clear all bindings, typically when a presentation is closed. */ void CTimelineTranslationManager::Clear() { // clean up all bindings - m_InstanceHandleBindingMap.clear(); + m_InstanceBindingMap.clear(); } /** @@ -125,9 +111,10 @@ void CTimelineTranslationManager::Clear() Qt3DSDMTimelineItemBinding * CTimelineTranslationManager::GetBinding(Qt3DSDMInstanceHandle inHandle) const { - TInstanceHandleBindingMap::const_iterator theIter = m_InstanceHandleBindingMap.find(inHandle); - if (theIter != m_InstanceHandleBindingMap.end()) - return theIter->second; + auto it = m_InstanceBindingMap.find(inHandle); + if (it != m_InstanceBindingMap.end()) + return it->second; + return nullptr; } @@ -138,7 +125,6 @@ CDoc *CTimelineTranslationManager::GetDoc() const CStudioSystem *CTimelineTranslationManager::GetStudioSystem() const { - // TODO: figure if we can just deal with IDoc instead of CDoc - return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); + return GetDoc()->GetStudioSystem(); } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h index 18851b20..bbb3fa81 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h @@ -26,56 +26,36 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef INCLUDED_TIMELINE_TRANSLATIONMANAGER_H -#define INCLUDED_TIMELINE_TRANSLATIONMANAGER_H 1 -#pragma once +#ifndef TIMELINE_TRANSLATIONMANAGER_H +#define TIMELINE_TRANSLATIONMANAGER_H #include "Qt3DSDMHandles.h" -#include "Qt3DSDMTimeline.h" - -#include "Doc.h" class ITimelineItemBinding; class Qt3DSDMTimelineItemBinding; +class CDoc; -// DataModel namespace qt3dsdm { class CStudioSystem; } -class CDoc; - -/** - * There is a TranslationManager per presentation (project) - */ class CTimelineTranslationManager { -protected: // Typedefs - // DataModel support - typedef std::map - TInstanceHandleBindingMap; - - // Store expanded state - typedef std::map TInstanceHandleExpandedMap; // DataModel support - -protected: // Properties - // DataModel support - TInstanceHandleBindingMap m_InstanceHandleBindingMap; - public: CTimelineTranslationManager(); ~CTimelineTranslationManager(); -public: ITimelineItemBinding *GetOrCreate(qt3dsdm::Qt3DSDMInstanceHandle inInstance); void Clear(); Qt3DSDMTimelineItemBinding *GetBinding(qt3dsdm::Qt3DSDMInstanceHandle inHandle) const; qt3dsdm::CStudioSystem *GetStudioSystem() const; - CDoc *GetDoc() const; + +private: + std::map m_InstanceBindingMap; }; #endif // INCLUDED_TIMELINE_TRANSLATIONMANAGER_H diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp index 041b651d..2821cf8e 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp @@ -41,6 +41,7 @@ #include "StudioApp.h" #include "Core.h" #include "Doc.h" +#include "StudioObjectTypes.h" #include "Qt3DSDMStudioSystem.h" #include "ClientDataModelBridge.h" @@ -90,6 +91,14 @@ RowTree *RowManager::createRowFromBinding(ITimelineItemBinding *binding, RowTree binding->GetTimelineItem()->GetName().toQString(), QString(), index); + // hide if material container + const QString matContainerName = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() + ->GetClientDataModelBridge()->getMaterialContainerName(); + if (newRow->rowType() == OBJTYPE_MATERIAL && newRow->label() == matContainerName) { + newRow->setVisible(false); + newRow->rowTimeline()->setVisible(false); + } + // connect the new row and its binding binding->setRowTree(newRow); newRow->setBinding(binding); @@ -135,10 +144,6 @@ RowTree *RowManager::createRowFromBinding(ITimelineItemBinding *binding, RowTree void RowManager::createRowsFromBindingRecursive(ITimelineItemBinding *binding, RowTree *parentRow) { auto instance = static_cast(binding)->GetInstance(); - if (g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge()->isMaterialContainer(instance)) { - return; - } RowTree *newRow = createRowFromBinding(binding, parentRow); // create child rows recursively @@ -402,81 +407,7 @@ void RowManager::ensureRowExpandedAndVisible(RowTree *row, bool forceChildUpdate } } -int RowManager::getRowIndex(RowTree *row, int startAt) -{ - if (row) { - for (int i = startAt; i < m_layoutTree->count(); ++i) { - if (row == m_layoutTree->itemAt(i)->graphicsItem()) - return i; - } - } - - return -1; -} - -// Return the index of a direct child (not grand children) of a parent -int RowManager::getChildIndex(RowTree *parentRow, RowTree *childRow) -{ - int index = getRowIndex(parentRow); - - if (index != -1 && index < m_layoutTimeline->count() - 1) { - // make sure it is a direct child, not a grand child. - while (childRow->depth() > parentRow->depth() + 1) - childRow = childRow->parentRow(); - - int childIndex = -1; - for (int i = index + 1; i < m_layoutTree->count(); ++i) { - RowTree *childRow_i = - static_cast(m_layoutTree->itemAt(i)->graphicsItem()); - - if (childRow_i->depth() == parentRow->depth() + 1) - childIndex++; - else if (childRow_i->depth() <= parentRow->depth()) - break; - - if (childRow_i == childRow) - return childIndex; - } - } - - return -1; -} - -bool RowManager::isFirstChild(RowTree *parentRow, RowTree *childRow) -{ - int index = getRowIndex(parentRow); - - if (index != -1 && index < m_layoutTimeline->count() - 1) { - RowTree *firstChild = - static_cast(m_layoutTree->itemAt(index + 1)->graphicsItem()); - - if (firstChild == childRow && childRow->depth() == parentRow->depth() + 1) - return true; - } - - return false; -} - bool RowManager::isSingleSelected() const { return m_selectedRows.size() == 1; } - -int RowManager::getLastChildIndex(RowTree *row, int index) -{ - if (index == -1) - index = getRowIndex(row); - - if (index != -1) { - for (int i = index + 1; i < m_layoutTree->count(); ++i) { - if (static_cast(m_layoutTree->itemAt(i)->graphicsItem())->depth() - <= row->depth()) { - return i - 1; - } - } - - return m_layoutTree->count() - 1; // last row - } - - return -1; -} diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h index 953c1b82..3a018577 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h @@ -56,9 +56,6 @@ public: void updateFiltering(RowTree *rowTree = nullptr); void recreateRowsFromBinding(ITimelineItemBinding *rootBinding); void updateRulerDuration(bool updateMaxDuration = true); - int getChildIndex(RowTree *parentRow, RowTree *childRow); - int getRowIndex(RowTree *row, int startAt = 1); - bool isFirstChild(RowTree *parent, RowTree *child); bool isSingleSelected() const; RowTree *createRowFromBinding(ITimelineItemBinding *binding, RowTree *parentRow = nullptr, int index = -1); @@ -74,7 +71,6 @@ public: void ensureRowExpandedAndVisible(RowTree *row, bool forceChildUpdate) const; private: - int getLastChildIndex(RowTree *row, int index = -1); void deleteRowRecursive(RowTree *row, bool deferChildRows); void updateRowFilterRecursive(RowTree *row); void createRowsFromBindingRecursive(ITimelineItemBinding *binding, diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp index 78ed54ef..a9dba0c8 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp @@ -472,9 +472,6 @@ void TimelineWidget::onActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, void TimelineWidget::insertToHandlesMapRecursive(Qt3DSDMTimelineItemBinding *binding) { - if (m_bridge->isMaterialContainer(binding->GetInstance())) - return; - insertToHandlesMap(binding); const QList children = binding->GetChildren(); @@ -484,12 +481,6 @@ void TimelineWidget::insertToHandlesMapRecursive(Qt3DSDMTimelineItemBinding *bin void TimelineWidget::insertToHandlesMap(Qt3DSDMTimelineItemBinding *binding) { - if (m_bridge->isMaterialContainer(binding->GetInstance())) - return; - - if (m_bridge->isInsideMaterialContainer(binding->GetInstance())) - return; - m_handlesMap.insert(binding->GetInstance(), binding->getRowTree()); } @@ -523,12 +514,6 @@ void TimelineWidget::onAssetCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance) return; if (m_bridge->IsSceneGraphInstance(inInstance)) { - if (m_bridge->isMaterialContainer(inInstance)) - return; - - if (m_bridge->isInsideMaterialContainer(inInstance)) - return; - Qt3DSDMTimelineItemBinding *binding = getBindingForHandle(inInstance, m_binding); if (!binding) { @@ -1049,7 +1034,7 @@ void TimelineWidget::onChildAdded(int inParent, int inChild, long inIndex) if (m_fullReconstruct) return; - // Handle row moves asynch, as we won't be able to get the final order correct otherwise + // Handle row moves async, as we won't be able to get the final order correct otherwise m_moveMap.insert(inChild, inParent); m_actionChanges.insert(inParent); if (!m_asyncUpdateTimer.isActive()) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 69d6f1c2..1d54b64c 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -705,6 +705,10 @@ bool RowTree::isInVariantsFilter() const void RowTree::updateFilter() { + auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + if (m_rowType == OBJTYPE_MATERIAL && m_label == bridge->getMaterialContainerName()) + return; + bool parentOk = !m_parentRow || m_parentRow->isVisible(); bool shyOk = !m_shy || !m_scene->treeHeader()->filterShy(); bool visibleOk = m_visible || !m_scene->treeHeader()->filterHidden(); @@ -915,6 +919,10 @@ void RowTree::updateLabel() void RowTree::setRowVisible(bool visible) { + auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + if (m_rowType == OBJTYPE_MATERIAL && m_label == bridge->getMaterialContainerName()) + return; + if (visible) { setMaximumHeight(TimelineConstants::ROW_H); setOpacity(1.0); -- cgit v1.2.3