summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2018-09-05 14:09:33 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2018-09-06 12:21:08 +0000
commit6b84d6f2aa1378cf5d23c6dd80eb0ab4ff0c01d3 (patch)
treee11da64c58121bbb98fbb55fc63529ad1543a41e /src/Authoring/Studio/Palettes
parent462df7ade37f2600aabbb84e7c440b0dcdb741d9 (diff)
Add a 'Detach material' check box to the ChooseImagePropertyDlg
When setting a sub-presentation to a ref material, a new check box option appears in the ChooseImagePropertyDlg, if checked the ref material will be changed to a Standard material so that the sub-presentation setting only affects this material instance. Task-number: QT3DS-2233 Change-Id: Iafff41f6994715289b13c30acf1226a4dfe86d08 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes')
-rw-r--r--src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp9
-rw-r--r--src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.h2
-rw-r--r--src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.ui10
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h5
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp21
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp21
7 files changed, 59 insertions, 17 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp
index f81357a8..77dbd4b9 100644
--- a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp
@@ -34,6 +34,7 @@
// This dialog displays all texture properties of an object and allows the user to choose one
ChooseImagePropertyDlg::ChooseImagePropertyDlg(qt3dsdm::Qt3DSDMInstanceHandle inTarget,
+ bool isRefMaterial,
QWidget *parent)
: QDialog(parent)
, m_instance(inTarget)
@@ -50,6 +51,9 @@ ChooseImagePropertyDlg::ChooseImagePropertyDlg(qt3dsdm::Qt3DSDMInstanceHandle in
QDialog::accept();
});
+ if (!isRefMaterial)
+ m_ui->cbDetach->setVisible(false);
+
fillList();
}
@@ -58,6 +62,11 @@ ChooseImagePropertyDlg::~ChooseImagePropertyDlg()
delete m_ui;
}
+bool ChooseImagePropertyDlg::detachMaterial() const
+{
+ return m_ui->cbDetach->checkState() == Qt::Checked;
+}
+
// fill the list with all material properties of type image
void ChooseImagePropertyDlg::fillList()
{
diff --git a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.h b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.h
index 5d723348..e644643c 100644
--- a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.h
+++ b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.h
@@ -48,10 +48,12 @@ class ChooseImagePropertyDlg : public QDialog
public:
explicit ChooseImagePropertyDlg(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ bool isRefMaterial = false,
QWidget *parent = 0);
~ChooseImagePropertyDlg();
int getSelectedPropertyHandle() const;
+ bool detachMaterial() const;
private:
Ui::ChooseImagePropertyDlg *m_ui;
diff --git a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.ui b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.ui
index f3084163..a6780539 100644
--- a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.ui
+++ b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.ui
@@ -43,6 +43,16 @@
<widget class="QListWidget" name="listProps"/>
</item>
<item>
+ <widget class="QCheckBox" name="cbDetach">
+ <property name="toolTip">
+ <string>Detach from referenced material</string>
+ </property>
+ <property name="text">
+ <string>Detach Material</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
index 73a23354..3908c255 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
@@ -74,7 +74,7 @@ void RowMover::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
RowTree *RowMover::insertionTarget() const
{
- return m_insertionTarget;
+ return m_insertionTarget.data();
}
RowTree *RowMover::insertionParent() const
@@ -112,7 +112,7 @@ void RowMover::resetInsertionParent(RowTree *newParent)
}
}
-bool RowMover::isActive()
+bool RowMover::isActive() const
{
return m_active;
}
@@ -153,7 +153,7 @@ void RowMover::end(bool force)
m_sourceRows.clear();
- if (m_insertionTarget)
+ if (!m_insertionTarget.isNull())
m_insertionTarget->setDnDState(RowTree::DnDState::None);
setVisible(false);
@@ -207,7 +207,7 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp
{
// DnD a presentation / Qml stream from the project panel (to set it as a subpresentation)
if (rowType == OBJTYPE_PRESENTATION || rowType == OBJTYPE_QML_STREAM) {
- if (m_insertionTarget)
+ if (!m_insertionTarget.isNull())
m_insertionTarget->setDnDState(RowTree::DnDState::None, RowTree::DnDState::SP_TARGET);
RowTree *rowAtMouse = m_scene->rowManager()->getRowAtPos(scenePos);
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
index b9fe59d9..da268968 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
@@ -34,6 +34,7 @@
#include "DocumentEditorEnumerations.h"
#include "StudioObjectTypes.h"
#include <QtCore/qtimer.h>
+#include <QtCore/qpointer.h>
class RowTree;
class TimelineGraphicsScene;
@@ -48,7 +49,7 @@ public:
void start(const QVector<RowTree *> &rows);
void end(bool force = false);
void updateTargetRow(const QPointF &scenePos, EStudioObjectType rowType = OBJTYPE_UNKNOWN);
- bool isActive();
+ bool isActive() const;
RowTree *insertionTarget() const;
RowTree *insertionParent() const;
QVector<RowTree *> sourceRows() const;
@@ -65,7 +66,7 @@ private:
bool isNextSiblingRow(RowTree *r1, RowTree *r2) const;
TimelineGraphicsScene *m_scene = nullptr;
- RowTree *m_insertionTarget = nullptr; // insertion target
+ QPointer<RowTree> m_insertionTarget; // insertion target
RowTree *m_insertionParent = nullptr; // insertion parent
RowTree *m_rowAutoExpand = nullptr;
QVector<RowTree *> m_sourceRows; // dragged rows
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
index 2c4b3b28..230a9c0c 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
@@ -504,14 +504,21 @@ void TimelineWidget::onAssetCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
if (m_bridge->IsSceneGraphInstance(inInstance)) {
Qt3DSDMTimelineItemBinding *binding = getBindingForHandle(inInstance, m_binding);
- bool rowExists = binding && binding->getRowTree();
- if (binding && !rowExists) {
- Qt3DSDMTimelineItemBinding *bindingParent = getBindingForHandle(m_bridge
+ if (!binding) {
+ // if binding is not found, refresh it (so far the only known case where this is needed
+ // is when setting a subpresentation on a ref mat row and checking 'Detach material')
+ m_fullReconstruct = true;
+ if (!m_asyncUpdateTimer.isActive())
+ m_asyncUpdateTimer.start();
+ } else {
+ if (!binding->getRowTree()) { // row doesn't exist
+ Qt3DSDMTimelineItemBinding *bindingParent = getBindingForHandle(m_bridge
->GetParentInstance(inInstance), m_binding);
- RowTree *row = m_graphicsScene->rowManager()
- ->createRowFromBinding(binding, bindingParent->getRowTree());
- row->updateSubpresentations();
- insertToHandlesMap(binding);
+ RowTree *row = m_graphicsScene->rowManager()
+ ->createRowFromBinding(binding, bindingParent->getRowTree());
+ row->updateSubpresentations();
+ insertToHandlesMap(binding);
+ }
}
}
}
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
index 446f4e04..473cfad9 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
@@ -193,19 +193,32 @@ void RowTreeContextMenu::addSubPresentation(QAction *action)
} else if (m_RowTree->rowType() == OBJTYPE_MATERIAL) {
auto &bridge(*doc.GetStudioSystem()->GetClientDataModelBridge());
// if this is a ref material, update the material it references
+
+ qt3dsdm::Qt3DSDMInstanceHandle refInstance = 0;
if (bridge.GetObjectType(instance) == OBJTYPE_REFERENCEDMATERIAL) {
auto optValue = doc.getSceneEditor()->GetInstancePropertyValue(instance,
bridge.GetObjectDefinitions().m_ReferencedMaterial
.m_ReferencedMaterial.m_Property);
if (optValue.hasValue())
- instance = bridge.GetInstance(doc.GetSceneInstance(), optValue.getValue());
+ refInstance = bridge.GetInstance(doc.GetSceneInstance(), optValue.getValue());
}
- ChooseImagePropertyDlg dlg(instance);
+ ChooseImagePropertyDlg dlg(refInstance ? refInstance : instance, refInstance != 0);
if (dlg.exec() == QDialog::Accepted) {
qt3dsdm::Qt3DSDMPropertyHandle propHandle = dlg.getSelectedPropertyHandle();
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc, tr("Set material sub-presentation"))
- ->setInstanceImagePropertyValueAsRenderable(instance, propHandle, presentationId);
+ if (dlg.detachMaterial()) {
+ Q3DStudio::ScopedDocumentEditor editor(Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc,
+ tr("Set material sub-presentation")));
+ editor->BeginAggregateOperation();
+ editor->SetMaterialType(instance, "Standard Material");
+ editor->setInstanceImagePropertyValueAsRenderable(instance, propHandle,
+ presentationId);
+ editor->EndAggregateOperation();
+ } else {
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc, tr("Set material sub-presentation"))
+ ->setInstanceImagePropertyValueAsRenderable(refInstance ? refInstance : instance,
+ propHandle, presentationId);
+ }
}
} else if (m_RowTree->rowType() == OBJTYPE_IMAGE) {
qt3dsdm::Qt3DSDMPropertyHandle propHandle = doc.GetPropertySystem()