Files
qt-creator/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleRod.qml
Miikka Heikkinen c67965fb29 QmlDesigner: Add ScaleGizmo to 3D edit view
ScaleGizmo allows scaling in the direction of local or global axes,
as well as uniform scaling. Any scale component cannot be made
negative with ScaleGizmo.

Change-Id: I9b98d9593e07ded340178b07b73fa1b72421ba20
Fixes: QDS-1195
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2019-11-08 12:53:21 +00:00

73 lines
2.4 KiB
QML

/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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.
**
****************************************************************************/
import QtQuick 2.0
import QtQuick3D 1.0
import MouseArea3D 1.0
DirectionalDraggable {
id: scaleRod
source: "meshes/scalerod.mesh"
signal scaleCommit()
signal scaleChange()
property var _startScale
Model {
source: "#Cube"
y: 10
scale: Qt.vector3d(0.025, 0.025, 0.025)
materials: DefaultMaterial {
id: material
emissiveColor: scaleRod.color
lighting: DefaultMaterial.NoLighting
}
}
function localScale(mouseArea, sceneRelativeDistance)
{
return mouseArea.getNewScale(targetNode, _startScale, _pointerPosPressed,
sceneRelativeDistance, sceneScale.x);
}
onPressed: {
// Recreate vector so we don't follow the changes in targetNode.sceneScale
_startScale = Qt.vector3d(targetNode.sceneScale.x,
targetNode.sceneScale.y,
targetNode.sceneScale.z);
}
onDragged: {
targetNode.scale = localScale(mouseArea, sceneRelativeDistance);
scaleChange();
}
onReleased: {
targetNode.scale = localScale(mouseArea, sceneRelativeDistance);
scaleCommit();
}
}