aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorSamuel Ghinet <samuel.ghinet@qt.io>2022-06-08 18:00:09 +0300
committerSamuel Ghinet <samuel.ghinet@qt.io>2022-06-16 10:17:01 +0000
commit50aadacb6e670597fc308d409bcdae96e7efa9c0 (patch)
treeb854694e4cea5fcefacb4c908d563ccfe1abd66e /share
parentb307182e7694c433dbd31caa491696c1321c1361 (diff)
QDS Editor 3D: Allow the user to select (and reset) the color of grid lines
Task-number: QDS-7122 Change-Id: I686269e61b53bd5e3d5d1225376930612d869072 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h7
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h1
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml18
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml1
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml1
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml18
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml1
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml1
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp30
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h2
10 files changed, 62 insertions, 18 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h b/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h
index c69d478875d..47196df8d24 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h
+++ b/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h
@@ -61,7 +61,8 @@ public:
QSize captureImageMinimumSize,
QSize captureImageMaximumSize,
qint32 stateInstanceId,
- const QList<QColor> &edit3dBackgroundColor)
+ const QList<QColor> &edit3dBackgroundColor,
+ const QColor &edit3dGridColor)
: instances(instanceContainer)
, reparentInstances(reparentContainer)
, ids(idVector)
@@ -78,6 +79,7 @@ public:
, captureImageMaximumSize(captureImageMaximumSize)
, stateInstanceId{stateInstanceId}
, edit3dBackgroundColor{edit3dBackgroundColor}
+ , edit3dGridColor{edit3dGridColor}
{}
friend QDataStream &operator<<(QDataStream &out, const CreateSceneCommand &command)
@@ -98,6 +100,7 @@ public:
out << command.captureImageMinimumSize;
out << command.captureImageMaximumSize;
out << command.edit3dBackgroundColor;
+ out << command.edit3dGridColor;
return out;
}
@@ -120,6 +123,7 @@ public:
in >> command.captureImageMinimumSize;
in >> command.captureImageMaximumSize;
in >> command.edit3dBackgroundColor;
+ in >> command.edit3dGridColor;
return in;
}
@@ -141,6 +145,7 @@ public:
QSize captureImageMaximumSize;
qint32 stateInstanceId = 0;
QList<QColor> edit3dBackgroundColor;
+ QColor edit3dGridColor;
};
QDebug operator<<(QDebug debug, const CreateSceneCommand &command);
diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h
index cc3611df764..a1dc133032e 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h
+++ b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h
@@ -57,6 +57,7 @@ public:
ParticlesRestart,
ParticlesSeek,
SelectBackgroundColor,
+ SelectGridColor,
ResetBackgroundColor,
};
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml
index 9a95ca34b98..09a4ebdc3f3 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml
@@ -47,6 +47,7 @@ Item {
property alias contentItem: contentItem
property color backgroundGradientColorStart: "#222222"
property color backgroundGradientColorEnd: "#999999"
+ property color gridColor: "#aaaaaa"
enum SelectionMode { Item, Group }
enum TransformMode { Move, Rotate, Scale }
@@ -96,12 +97,14 @@ Item {
{"usePerspective": usePerspective,
"showSceneLight": showEditLight,
"showGrid": showGrid,
+ "gridColor": gridColor,
"importScene": activeScene,
"cameraZoomFactor": cameraControl._zoomFactor,
"z": 1});
editView.usePerspective = Qt.binding(function() {return usePerspective;});
editView.showSceneLight = Qt.binding(function() {return showEditLight;});
editView.showGrid = Qt.binding(function() {return showGrid;});
+ editView.gridColor = Qt.binding(function() {return gridColor;});
editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;});
selectionBoxes.length = 0;
@@ -217,10 +220,19 @@ Item {
function updateViewStates(viewStates)
{
if ("selectBackgroundColor" in viewStates) {
- var color = viewStates.selectBackgroundColor
- backgroundGradientColorStart = color[0];
- backgroundGradientColorEnd = color[1];
+ if (Array.isArray(viewStates.selectBackgroundColor)) {
+ var colors = viewStates.selectBackgroundColor
+ backgroundGradientColorStart = colors[0];
+ backgroundGradientColorEnd = colors[1];
+ } else {
+ var color = viewStates.selectBackgroundColor
+ backgroundGradientColorStart = color;
+ backgroundGradientColorEnd = color;
+ }
}
+
+ if ("selectGridColor" in viewStates)
+ viewRoot.gridColor = viewStates.selectGridColor
}
// If resetToDefault is true, tool states not specifically set to anything will be reset to
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml
index e450a5a796c..d9df67fe7c4 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml
@@ -33,6 +33,7 @@ Node {
property alias lines: gridGeometry.lines
property alias step: gridGeometry.step
property alias subdivAlpha: subGridMaterial.opacity
+ property alias gridColor: mainGridMaterial.diffuseColor
eulerRotation.x: 90
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml
index 7a376179d82..4032e245ed0 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml
@@ -32,6 +32,7 @@ View3D {
property bool usePerspective: false
property alias showSceneLight: sceneLight.visible
property alias showGrid: helperGrid.visible
+ property alias gridColor: helperGrid.gridColor
property alias sceneHelpers: sceneHelpers
property alias perspectiveCamera: scenePerspectiveCamera
property alias orthoCamera: sceneOrthoCamera
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml
index 228154a9a49..a3f14e9d113 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml
@@ -48,6 +48,7 @@ Item {
property alias contentItem: contentItem
property color backgroundGradientColorStart: "#222222"
property color backgroundGradientColorEnd: "#999999"
+ property color gridColor: "#aaaaaa"
enum SelectionMode { Item, Group }
enum TransformMode { Move, Rotate, Scale }
@@ -100,12 +101,14 @@ Item {
{"usePerspective": usePerspective,
"showSceneLight": showEditLight,
"showGrid": showGrid,
+ "gridColor": gridColor,
"importScene": activeScene,
"cameraZoomFactor": cameraControl._zoomFactor,
"z": 1});
editView.usePerspective = Qt.binding(function() {return usePerspective;});
editView.showSceneLight = Qt.binding(function() {return showEditLight;});
editView.showGrid = Qt.binding(function() {return showGrid;});
+ editView.gridColor = Qt.binding(function() {return gridColor;});
editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;});
selectionBoxes.length = 0;
@@ -211,10 +214,19 @@ Item {
function updateViewStates(viewStates)
{
if ("selectBackgroundColor" in viewStates) {
- var color = viewStates.selectBackgroundColor
- backgroundGradientColorStart = color[0];
- backgroundGradientColorEnd = color[1];
+ if (Array.isArray(viewStates.selectBackgroundColor)) {
+ var colors = viewStates.selectBackgroundColor
+ backgroundGradientColorStart = colors[0];
+ backgroundGradientColorEnd = colors[1];
+ } else {
+ var color = viewStates.selectBackgroundColor
+ backgroundGradientColorStart = color;
+ backgroundGradientColorEnd = color;
+ }
}
+
+ if ("selectGridColor" in viewStates)
+ viewRoot.gridColor = viewStates.selectGridColor
}
// If resetToDefault is true, tool states not specifically set to anything will be reset to
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml
index 66f383518eb..ef10818eedc 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml
@@ -33,6 +33,7 @@ Node {
property alias lines: gridGeometry.lines
property alias step: gridGeometry.step
property alias subdivAlpha: subGridMaterial.opacity
+ property alias gridColor: mainGridMaterial.diffuseColor
eulerRotation.x: 90
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml
index e59392b1ee2..1d0e0377d3b 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml
@@ -32,6 +32,7 @@ View3D {
property bool usePerspective: false
property alias showSceneLight: sceneLight.visible
property alias showGrid: helperGrid.visible
+ property alias gridColor: helperGrid.gridColor
property alias sceneHelpers: sceneHelpers
property alias perspectiveCamera: scenePerspectiveCamera
property alias orthoCamera: sceneOrthoCamera
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index effa871ce6d..d614901ca97 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -1742,7 +1742,7 @@ QObject *Qt5InformationNodeInstanceServer::find3DSceneRoot(QObject *obj) const
}
void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeInstance> &instanceList,
- const QHash<QString, QVariantMap> &toolStates)
+ const CreateSceneCommand &command)
{
#ifdef QUICK3D_MODULE
if (!m_editView3DData.rootItem)
@@ -1775,6 +1775,7 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D(true);
});
+ const QHash<QString, QVariantMap> &toolStates = command.edit3dToolStates;
QString lastSceneId;
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
if (helper) {
@@ -1828,11 +1829,23 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
createCameraAndLightGizmos(instanceList);
+ if (!command.edit3dBackgroundColor.isEmpty()) {
+ View3DActionCommand backgroundColorCommand(View3DActionCommand::SelectBackgroundColor,
+ QVariant::fromValue(command.edit3dBackgroundColor));
+ view3DAction(backgroundColorCommand);
+ }
+
+ if (command.edit3dGridColor.isValid()) {
+ View3DActionCommand backgroundColorCommand(View3DActionCommand::SelectGridColor,
+ QVariant::fromValue(command.edit3dGridColor));
+ view3DAction(backgroundColorCommand);
+ }
+
// Queue two renders to make sure icon gizmos update properly
render3DEditView(2);
#else
Q_UNUSED(instanceList)
- Q_UNUSED(toolStates)
+ Q_UNUSED(command)
#endif
}
@@ -1954,7 +1967,7 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
nodeInstanceClient()->componentCompleted(createComponentCompletedCommand(instanceList));
if (ViewConfig::isQuick3DMode()) {
- setup3DEditView(instanceList, command.edit3dToolStates);
+ setup3DEditView(instanceList, command);
updateRotationBlocks(command.auxiliaryChanges);
}
@@ -1963,12 +1976,6 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
#ifdef IMPORT_QUICK3D_ASSETS
QTimer::singleShot(0, this, &Qt5InformationNodeInstanceServer::resolveImportSupport);
#endif
-
- if (!command.edit3dBackgroundColor.isEmpty()) {
- View3DActionCommand backgroundColorCommand(View3DActionCommand::SelectBackgroundColor,
- QVariant::fromValue(command.edit3dBackgroundColor));
- view3DAction(backgroundColorCommand);
- }
}
void Qt5InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<ServerNodeInstance> &childList)
@@ -2233,9 +2240,12 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
case View3DActionCommand::ShowCameraFrustum:
updatedToolState.insert("showCameraFrustum", command.isEnabled());
break;
- case View3DActionCommand::SelectBackgroundColor: {
+ case View3DActionCommand::SelectBackgroundColor:
updatedViewState.insert("selectBackgroundColor", command.value());
break;
+ case View3DActionCommand::SelectGridColor: {
+ updatedViewState.insert("selectGridColor", command.value());
+ break;
}
#ifdef QUICK3D_PARTICLES_MODULE
case View3DActionCommand::ShowParticleEmitter:
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
index 291b2c3eecd..9f6e4506908 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
@@ -114,7 +114,7 @@ private:
void createEditView3D();
void create3DPreviewView();
void setup3DEditView(const QList<ServerNodeInstance> &instanceList,
- const QHash<QString, QVariantMap> &toolStates);
+ const CreateSceneCommand &command);
void createCameraAndLightGizmos(const QList<ServerNodeInstance> &instanceList) const;
void add3DViewPorts(const QList<ServerNodeInstance> &instanceList);
void add3DScenes(const QList<ServerNodeInstance> &instanceList);