forked from qt-creator/qt-creator
Update EditView3D when selecting a 3D object in the navigator
Task-number: QDS-1124 Change-Id: I8d7bf73612b07592cd9beb85a5249895a400316b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -47,6 +47,10 @@ Window {
|
|||||||
signal objectClicked(var object)
|
signal objectClicked(var object)
|
||||||
signal commitObjectPosition(var object)
|
signal commitObjectPosition(var object)
|
||||||
|
|
||||||
|
function selectObject(object) {
|
||||||
|
selectedNode = object;
|
||||||
|
}
|
||||||
|
|
||||||
Node {
|
Node {
|
||||||
id: overlayScene
|
id: overlayScene
|
||||||
|
|
||||||
@@ -94,7 +98,7 @@ Window {
|
|||||||
var pickResult = editView.pick(eventPoint.scenePosition.x,
|
var pickResult = editView.pick(eventPoint.scenePosition.x,
|
||||||
eventPoint.scenePosition.y);
|
eventPoint.scenePosition.y);
|
||||||
viewWindow.objectClicked(pickResult.objectHit);
|
viewWindow.objectClicked(pickResult.objectHit);
|
||||||
selectedNode = pickResult.objectHit; // TODO selection needs to come from studio
|
selectObject(pickResult.objectHit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -267,17 +267,17 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node) { // If we found a scene we create the edit view
|
if (node) { // If we found a scene we create the edit view
|
||||||
QObject *view = createEditView3D(engine());
|
m_editView3D = createEditView3D(engine());
|
||||||
|
|
||||||
if (!view)
|
if (!m_editView3D)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QQmlProperty sceneProperty(view, "scene", context());
|
QQmlProperty sceneProperty(m_editView3D, "scene", context());
|
||||||
node->setParent(view);
|
node->setParent(m_editView3D);
|
||||||
sceneProperty.write(objectToVariant(node));
|
sceneProperty.write(objectToVariant(node));
|
||||||
QQmlProperty parentProperty(node, "parent", context());
|
QQmlProperty parentProperty(node, "parent", context());
|
||||||
parentProperty.write(objectToVariant(view));
|
parentProperty.write(objectToVariant(m_editView3D));
|
||||||
QQmlProperty completeSceneProperty(view, "showLight", context());
|
QQmlProperty completeSceneProperty(m_editView3D, "showLight", context());
|
||||||
completeSceneProperty.write(showCustomLight);
|
completeSceneProperty.write(showCustomLight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,8 +452,23 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml
|
|||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
|
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
|
||||||
{
|
{
|
||||||
// keep track of selection.
|
if (!m_editView3D)
|
||||||
qDebug() << Q_FUNC_INFO << command;
|
return;
|
||||||
|
|
||||||
|
const QVector<qint32> instanceIds = command.instanceIds();
|
||||||
|
for (qint32 id : instanceIds) {
|
||||||
|
if (hasInstanceForId(id)) {
|
||||||
|
ServerNodeInstance instance = instanceForId(id);
|
||||||
|
QObject *object = nullptr;
|
||||||
|
if (instance.isSubclassOf("QQuick3DModel") || instance.isSubclassOf("QQuick3DCamera")
|
||||||
|
|| instance.isSubclassOf("QQuick3DAbstractLight")) {
|
||||||
|
object = instance.internalObject();
|
||||||
|
}
|
||||||
|
QMetaObject::invokeMethod(m_editView3D, "selectObject", Q_ARG(QVariant,
|
||||||
|
objectToVariant(object)));
|
||||||
|
return; // TODO: support multi-selection
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -65,6 +65,7 @@ private:
|
|||||||
const PropertyName &propertyName,
|
const PropertyName &propertyName,
|
||||||
const QVariant &variant);
|
const QVariant &variant);
|
||||||
|
|
||||||
|
QObject *m_editView3D = nullptr;
|
||||||
QSet<ServerNodeInstance> m_parentChangedSet;
|
QSet<ServerNodeInstance> m_parentChangedSet;
|
||||||
QList<ServerNodeInstance> m_completedComponentList;
|
QList<ServerNodeInstance> m_completedComponentList;
|
||||||
QList<TokenCommand> m_tokenList;
|
QList<TokenCommand> m_tokenList;
|
||||||
|
Reference in New Issue
Block a user