forked from qt-creator/qt-creator
QmlDesigner: Cleanup puppet and related versioned code
QDS requires minimum Qt version 6.4.3 to build at all, so removed all code and files from puppet that were relevant only for prior versions. Fixes: QDS-10556 Change-Id: I58a151fc25f733d4815869e749f77fe30072c19b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -166,23 +166,6 @@ void ItemLibraryAssetImporter::importProcessFinished([[maybe_unused]] int exitCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemLibraryAssetImporter::iconProcessFinished([[maybe_unused]] int exitCode,
|
|
||||||
[[maybe_unused]] QProcess::ExitStatus exitStatus)
|
|
||||||
{
|
|
||||||
m_puppetProcess.reset();
|
|
||||||
|
|
||||||
int finishedCount = m_parseData.size() - m_puppetQueue.size();
|
|
||||||
if (!m_puppetQueue.isEmpty())
|
|
||||||
startNextIconProcess();
|
|
||||||
|
|
||||||
if (m_puppetQueue.isEmpty() && !m_puppetProcess) {
|
|
||||||
notifyProgress(100);
|
|
||||||
QTimer::singleShot(0, this, &ItemLibraryAssetImporter::finalizeQuick3DImport);
|
|
||||||
} else {
|
|
||||||
notifyProgress(int(100. * (double(finishedCount) / double(m_parseData.size()))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemLibraryAssetImporter::notifyFinished()
|
void ItemLibraryAssetImporter::notifyFinished()
|
||||||
{
|
{
|
||||||
m_isImporting = false;
|
m_isImporting = false;
|
||||||
@@ -277,18 +260,8 @@ bool ItemLibraryAssetImporter::preParseQuick3DAsset(const QString &file, ParseDa
|
|||||||
addWarning(tr("Skipped import of existing asset: \"%1\".").arg(pd.assetName));
|
addWarning(tr("Skipped import of existing asset: \"%1\".").arg(pd.assetName));
|
||||||
return false;
|
return false;
|
||||||
} else if (result == OverwriteResult::Update) {
|
} else if (result == OverwriteResult::Update) {
|
||||||
// Add generated icons and existing source asset file, as those will always need
|
// Add existing source asset file, as that will always need to be overwritten
|
||||||
// to be overwritten
|
|
||||||
QSet<QString> alwaysOverwrite;
|
QSet<QString> alwaysOverwrite;
|
||||||
QString iconPath = pd.targetDirPath + '/' + Constants::QUICK_3D_ASSET_ICON_DIR;
|
|
||||||
// Note: Despite the name, QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX is not a traditional file
|
|
||||||
// suffix. It's guaranteed to be in the generated icon filename, though.
|
|
||||||
QStringList filters {QStringLiteral("*%1*").arg(Constants::QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX)};
|
|
||||||
QDirIterator iconIt(iconPath, filters, QDir::Files);
|
|
||||||
while (iconIt.hasNext()) {
|
|
||||||
iconIt.next();
|
|
||||||
alwaysOverwrite.insert(iconIt.fileInfo().absoluteFilePath());
|
|
||||||
}
|
|
||||||
alwaysOverwrite.insert(sourceSceneTargetFilePath(pd));
|
alwaysOverwrite.insert(sourceSceneTargetFilePath(pd));
|
||||||
alwaysOverwrite.insert(pd.targetDirPath + '/' + Constants::QUICK_3D_ASSET_IMPORT_DATA_NAME);
|
alwaysOverwrite.insert(pd.targetDirPath + '/' + Constants::QUICK_3D_ASSET_IMPORT_DATA_NAME);
|
||||||
|
|
||||||
@@ -353,7 +326,6 @@ void ItemLibraryAssetImporter::postParseQuick3DAsset(ParseData &pd)
|
|||||||
// subdirs assume they are used within the context of the toplevel qml files.
|
// subdirs assume they are used within the context of the toplevel qml files.
|
||||||
QDirIterator qmlIt(outDir.path(), {QStringLiteral("*.qml")}, QDir::Files);
|
QDirIterator qmlIt(outDir.path(), {QStringLiteral("*.qml")}, QDir::Files);
|
||||||
if (qmlIt.hasNext()) {
|
if (qmlIt.hasNext()) {
|
||||||
outDir.mkdir(Constants::QUICK_3D_ASSET_ICON_DIR);
|
|
||||||
if (qmldirFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (qmldirFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
QString qmlInfo;
|
QString qmlInfo;
|
||||||
qmlInfo.append("module ");
|
qmlInfo.append("module ");
|
||||||
@@ -375,10 +347,6 @@ void ItemLibraryAssetImporter::postParseQuick3DAsset(ParseData &pd)
|
|||||||
|
|
||||||
QFile qmlFile(qmlIt.filePath());
|
QFile qmlFile(qmlIt.filePath());
|
||||||
if (qmlFile.open(QIODevice::ReadOnly)) {
|
if (qmlFile.open(QIODevice::ReadOnly)) {
|
||||||
QString iconFileName = outDir.path() + '/'
|
|
||||||
+ Constants::QUICK_3D_ASSET_ICON_DIR + '/' + fi.baseName()
|
|
||||||
+ Constants::QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX;
|
|
||||||
QString iconFileName2x = iconFileName + "@2x";
|
|
||||||
QByteArray content = qmlFile.readAll();
|
QByteArray content = qmlFile.readAll();
|
||||||
int braceIdx = content.indexOf('{');
|
int braceIdx = content.indexOf('{');
|
||||||
QString impVersionStr;
|
QString impVersionStr;
|
||||||
@@ -421,16 +389,6 @@ void ItemLibraryAssetImporter::postParseQuick3DAsset(ParseData &pd)
|
|||||||
if (impVersionMajor > 0 && m_requiredImports.first() != "QtQuick3D")
|
if (impVersionMajor > 0 && m_requiredImports.first() != "QtQuick3D")
|
||||||
m_requiredImports.prepend("QtQuick3D");
|
m_requiredImports.prepend("QtQuick3D");
|
||||||
}
|
}
|
||||||
if (impVersionMajor > 0 && impVersionMajor < 6) {
|
|
||||||
pd.iconFile = iconFileName;
|
|
||||||
pd.iconSource = qmlIt.filePath();
|
|
||||||
m_puppetQueue.append(pd.importId);
|
|
||||||
// Since icon is generated by external process, the file won't be
|
|
||||||
// ready for asset gathering below, so assume its generation succeeds
|
|
||||||
// and add it now.
|
|
||||||
insertAsset(iconFileName);
|
|
||||||
insertAsset(iconFileName2x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,42 +560,6 @@ void ItemLibraryAssetImporter::startNextImportProcess()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemLibraryAssetImporter::startNextIconProcess()
|
|
||||||
{
|
|
||||||
if (m_puppetQueue.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto view = QmlDesignerPlugin::viewManager().view();
|
|
||||||
auto doc = QmlDesignerPlugin::instance()->currentDesignDocument();
|
|
||||||
Model *model = doc ? doc->currentModel() : nullptr;
|
|
||||||
|
|
||||||
if (model && view) {
|
|
||||||
bool done = false;
|
|
||||||
while (!m_puppetQueue.isEmpty() && !done) {
|
|
||||||
const ParseData pd = m_parseData.value(m_puppetQueue.takeLast());
|
|
||||||
QStringList puppetArgs;
|
|
||||||
puppetArgs << "--rendericon" << QString::number(24) << pd.iconFile << pd.iconSource;
|
|
||||||
m_puppetProcess = PuppetStarter::createPuppetProcess(
|
|
||||||
view->externalDependencies().puppetStartData(*model),
|
|
||||||
"custom",
|
|
||||||
{},
|
|
||||||
[&] {},
|
|
||||||
[&](int exitCode, QProcess::ExitStatus exitStatus) {
|
|
||||||
iconProcessFinished(exitCode, exitStatus);
|
|
||||||
},
|
|
||||||
puppetArgs);
|
|
||||||
|
|
||||||
if (m_puppetProcess->waitForStarted(10000)) {
|
|
||||||
done = true;
|
|
||||||
} else {
|
|
||||||
addError(tr("Failed to start icon generation process."),
|
|
||||||
pd.sourceInfo.absoluteFilePath());
|
|
||||||
m_puppetProcess.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemLibraryAssetImporter::postImport()
|
void ItemLibraryAssetImporter::postImport()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_puppetQueue.isEmpty() && !m_puppetProcess, return);
|
QTC_ASSERT(m_puppetQueue.isEmpty() && !m_puppetProcess, return);
|
||||||
@@ -645,19 +567,10 @@ void ItemLibraryAssetImporter::postImport()
|
|||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
for (auto &pd : m_parseData)
|
for (auto &pd : m_parseData)
|
||||||
postParseQuick3DAsset(pd);
|
postParseQuick3DAsset(pd);
|
||||||
startNextIconProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCancelled()) {
|
if (!isCancelled())
|
||||||
// Wait for icon generation processes to finish
|
|
||||||
if (m_puppetQueue.isEmpty() && !m_puppetProcess) {
|
|
||||||
finalizeQuick3DImport();
|
finalizeQuick3DImport();
|
||||||
} else {
|
|
||||||
const QString progressTitle = tr("Generating icons.");
|
|
||||||
addInfo(progressTitle);
|
|
||||||
notifyProgress(0, progressTitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemLibraryAssetImporter::finalizeQuick3DImport()
|
void ItemLibraryAssetImporter::finalizeQuick3DImport()
|
||||||
|
@@ -53,7 +53,6 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void importProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
void importProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void iconProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ParseData {
|
struct ParseData {
|
||||||
@@ -65,8 +64,6 @@ private:
|
|||||||
QString assetName;
|
QString assetName;
|
||||||
QString originalAssetName;
|
QString originalAssetName;
|
||||||
int importId;
|
int importId;
|
||||||
QString iconFile;
|
|
||||||
QString iconSource;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void notifyFinished();
|
void notifyFinished();
|
||||||
@@ -91,7 +88,6 @@ private:
|
|||||||
|
|
||||||
OverwriteResult confirmAssetOverwrite(const QString &assetName);
|
OverwriteResult confirmAssetOverwrite(const QString &assetName);
|
||||||
void startNextImportProcess();
|
void startNextImportProcess();
|
||||||
void startNextIconProcess();
|
|
||||||
void postImport();
|
void postImport();
|
||||||
void finalizeQuick3DImport();
|
void finalizeQuick3DImport();
|
||||||
QString sourceSceneTargetFilePath(const ParseData &pd);
|
QString sourceSceneTargetFilePath(const ParseData &pd);
|
||||||
|
@@ -434,11 +434,6 @@ void SubComponentManager::parseQuick3DAssetsItem(const QString &importUrl, const
|
|||||||
itemLibraryEntry.setCategory(::QmlDesigner::SubComponentManager::tr("My 3D Components"));
|
itemLibraryEntry.setCategory(::QmlDesigner::SubComponentManager::tr("My 3D Components"));
|
||||||
itemLibraryEntry.setCustomComponentSource(qmlIt.fileInfo().absoluteFilePath());
|
itemLibraryEntry.setCustomComponentSource(qmlIt.fileInfo().absoluteFilePath());
|
||||||
itemLibraryEntry.setRequiredImport(importUrl);
|
itemLibraryEntry.setRequiredImport(importUrl);
|
||||||
QString iconPath = qmlIt.fileInfo().absolutePath() + '/'
|
|
||||||
+ Constants::QUICK_3D_ASSET_ICON_DIR + '/' + name
|
|
||||||
+ Constants::QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX;
|
|
||||||
if (QFileInfo::exists(iconPath))
|
|
||||||
itemLibraryEntry.setLibraryEntryIconPath(iconPath);
|
|
||||||
itemLibraryEntry.setTypeIcon(QIcon(defaultIconPath));
|
itemLibraryEntry.setTypeIcon(QIcon(defaultIconPath));
|
||||||
|
|
||||||
// load hints file if exists
|
// load hints file if exists
|
||||||
|
@@ -72,7 +72,6 @@ const char COMPONENT_BUNDLES_FOLDER[] = "/ComponentBundles";
|
|||||||
const char COMPONENT_BUNDLES_ASSET_REF_FILE[] = "_asset_ref.json";
|
const char COMPONENT_BUNDLES_ASSET_REF_FILE[] = "_asset_ref.json";
|
||||||
const char QUICK_3D_ASSETS_FOLDER[] = "/Quick3DAssets";
|
const char QUICK_3D_ASSETS_FOLDER[] = "/Quick3DAssets";
|
||||||
const char QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX[] = "_libicon";
|
const char QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX[] = "_libicon";
|
||||||
const char QUICK_3D_ASSET_ICON_DIR[] = "_icons";
|
|
||||||
const char QUICK_3D_ASSET_IMPORT_DATA_NAME[] = "_importdata.json";
|
const char QUICK_3D_ASSET_IMPORT_DATA_NAME[] = "_importdata.json";
|
||||||
const char QUICK_3D_ASSET_IMPORT_DATA_OPTIONS_KEY[] = "import_options";
|
const char QUICK_3D_ASSET_IMPORT_DATA_OPTIONS_KEY[] = "import_options";
|
||||||
const char QUICK_3D_ASSET_IMPORT_DATA_SOURCE_KEY[] = "source_scene";
|
const char QUICK_3D_ASSET_IMPORT_DATA_SOURCE_KEY[] = "source_scene";
|
||||||
|
@@ -17,9 +17,6 @@ if (NOT QT_CREATOR_API_DEFINED)
|
|||||||
include(QtCreatorIDEBranding)
|
include(QtCreatorIDEBranding)
|
||||||
include(QtCreatorAPI)
|
include(QtCreatorAPI)
|
||||||
|
|
||||||
find_package(QT 5.15.0 NAMES Qt6 Qt5
|
|
||||||
COMPONENTS Core REQUIRED
|
|
||||||
)
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR}
|
find_package(Qt${QT_VERSION_MAJOR}
|
||||||
COMPONENTS Concurrent Core Gui Network PrintSupport Qml Quick Sql Widgets Xml
|
COMPONENTS Concurrent Core Gui Network PrintSupport Qml Quick Sql Widgets Xml
|
||||||
REQUIRED
|
REQUIRED
|
||||||
@@ -78,12 +75,6 @@ extend_qtc_executable(qml2puppet
|
|||||||
editor3d_qt6.qrc
|
editor3d_qt6.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_executable(qml2puppet
|
|
||||||
CONDITION Qt5_VERSION VERSION_LESS 6.0.0
|
|
||||||
SOURCES
|
|
||||||
editor3d_qt5.qrc
|
|
||||||
)
|
|
||||||
|
|
||||||
extend_qtc_executable(qml2puppet
|
extend_qtc_executable(qml2puppet
|
||||||
CONDITION UNIX AND (NOT APPLE)
|
CONDITION UNIX AND (NOT APPLE)
|
||||||
DEPENDS rt
|
DEPENDS rt
|
||||||
@@ -140,19 +131,6 @@ extend_qtc_executable(qml2puppet
|
|||||||
DEFINES QUICK3D_ASSET_UTILS_MODULE
|
DEFINES QUICK3D_ASSET_UTILS_MODULE
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_executable(qml2puppet
|
|
||||||
CONDITION Qt6_VERSION
|
|
||||||
SOURCES_PREFIX qml2puppet/editor3d/qt5compat
|
|
||||||
SOURCES
|
|
||||||
qquick3darealight.cpp qquick3darealight_p.h
|
|
||||||
)
|
|
||||||
|
|
||||||
extend_qtc_executable(qml2puppet
|
|
||||||
SOURCES_PREFIX qml2puppet/iconrenderer
|
|
||||||
SOURCES
|
|
||||||
iconrenderer.cpp iconrenderer.h
|
|
||||||
)
|
|
||||||
|
|
||||||
extend_qtc_executable(qml2puppet
|
extend_qtc_executable(qml2puppet
|
||||||
SOURCES_PREFIX qml2puppet/import3d
|
SOURCES_PREFIX qml2puppet/import3d
|
||||||
SOURCES
|
SOURCES
|
||||||
|
@@ -1,58 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/qtquickplugin">
|
|
||||||
<file>mockfiles/meshes/arrow.mesh</file>
|
|
||||||
<file>mockfiles/meshes/scalerod.mesh</file>
|
|
||||||
<file>mockfiles/meshes/ring.mesh</file>
|
|
||||||
<file>mockfiles/meshes/ringselect.mesh</file>
|
|
||||||
<file>mockfiles/meshes/axishelper.mesh</file>
|
|
||||||
<file>mockfiles/images/editor_camera.png</file>
|
|
||||||
<file>mockfiles/images/editor_camera@2x.png</file>
|
|
||||||
<file>mockfiles/images/area.png</file>
|
|
||||||
<file>mockfiles/images/area@2x.png</file>
|
|
||||||
<file>mockfiles/images/directional.png</file>
|
|
||||||
<file>mockfiles/images/directional@2x.png</file>
|
|
||||||
<file>mockfiles/images/point.png</file>
|
|
||||||
<file>mockfiles/images/point@2x.png</file>
|
|
||||||
<file>mockfiles/images/static_floor.png</file>
|
|
||||||
<file>mockfiles/images/spot.png</file>
|
|
||||||
<file>mockfiles/images/spot@2x.png</file>
|
|
||||||
<file>mockfiles/images/preview_landscape.hdr</file>
|
|
||||||
<file>mockfiles/images/preview_studio.hdr</file>
|
|
||||||
<file>mockfiles/qt5/AdjustableArrow.qml</file>
|
|
||||||
<file>mockfiles/qt5/AreaLightHandle.qml</file>
|
|
||||||
<file>mockfiles/qt5/Arrow.qml</file>
|
|
||||||
<file>mockfiles/qt5/AutoScaleHelper.qml</file>
|
|
||||||
<file>mockfiles/qt5/AxisHelper.qml</file>
|
|
||||||
<file>mockfiles/qt5/AxisHelperArm.qml</file>
|
|
||||||
<file>mockfiles/qt5/CameraFrustum.qml</file>
|
|
||||||
<file>mockfiles/qt5/CameraGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/DirectionalDraggable.qml</file>
|
|
||||||
<file>mockfiles/qt5/EditCameraController.qml</file>
|
|
||||||
<file>mockfiles/qt5/EditView3D.qml</file>
|
|
||||||
<file>mockfiles/qt5/FadeHandle.qml</file>
|
|
||||||
<file>mockfiles/qt5/HelperGrid.qml</file>
|
|
||||||
<file>mockfiles/qt5/IconGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/IconRenderer3D.qml</file>
|
|
||||||
<file>mockfiles/qt5/LightGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/LightIconGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/LightModel.qml</file>
|
|
||||||
<file>mockfiles/qt5/Line3D.qml</file>
|
|
||||||
<file>mockfiles/qt5/MaterialNodeView.qml</file>
|
|
||||||
<file>mockfiles/qt5/ModelNode2DImageView.qml</file>
|
|
||||||
<file>mockfiles/qt5/ModelNode3DImageView.qml</file>
|
|
||||||
<file>mockfiles/qt5/ModelNodeView.qml</file>
|
|
||||||
<file>mockfiles/qt5/MoveGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/NodeNodeView.qml</file>
|
|
||||||
<file>mockfiles/qt5/Overlay2D.qml</file>
|
|
||||||
<file>mockfiles/qt5/PlanarDraggable.qml</file>
|
|
||||||
<file>mockfiles/qt5/PlanarMoveHandle.qml</file>
|
|
||||||
<file>mockfiles/qt5/PlanarScaleHandle.qml</file>
|
|
||||||
<file>mockfiles/qt5/RotateGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/RotateRing.qml</file>
|
|
||||||
<file>mockfiles/qt5/ScaleGizmo.qml</file>
|
|
||||||
<file>mockfiles/qt5/ScaleRod.qml</file>
|
|
||||||
<file>mockfiles/qt5/SceneView3D.qml</file>
|
|
||||||
<file>mockfiles/qt5/SelectionBox.qml</file>
|
|
||||||
<file>mockfiles/qt5/SpotLightHandle.qml</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
@@ -9,8 +9,6 @@
|
|||||||
<file>mockfiles/images/editor_camera@2x.png</file>
|
<file>mockfiles/images/editor_camera@2x.png</file>
|
||||||
<file>mockfiles/images/editor_particlesystem.png</file>
|
<file>mockfiles/images/editor_particlesystem.png</file>
|
||||||
<file>mockfiles/images/editor_particlesystem@2x.png</file>
|
<file>mockfiles/images/editor_particlesystem@2x.png</file>
|
||||||
<file>mockfiles/images/area.png</file>
|
|
||||||
<file>mockfiles/images/area@2x.png</file>
|
|
||||||
<file>mockfiles/images/directional.png</file>
|
<file>mockfiles/images/directional.png</file>
|
||||||
<file>mockfiles/images/directional@2x.png</file>
|
<file>mockfiles/images/directional@2x.png</file>
|
||||||
<file>mockfiles/images/point.png</file>
|
<file>mockfiles/images/point.png</file>
|
||||||
@@ -21,7 +19,6 @@
|
|||||||
<file>mockfiles/images/preview_landscape.hdr</file>
|
<file>mockfiles/images/preview_landscape.hdr</file>
|
||||||
<file>mockfiles/images/preview_studio.hdr</file>
|
<file>mockfiles/images/preview_studio.hdr</file>
|
||||||
<file>mockfiles/qt6/AdjustableArrow.qml</file>
|
<file>mockfiles/qt6/AdjustableArrow.qml</file>
|
||||||
<file>mockfiles/qt6/AreaLightHandle.qml</file>
|
|
||||||
<file>mockfiles/qt6/Arrow.qml</file>
|
<file>mockfiles/qt6/Arrow.qml</file>
|
||||||
<file>mockfiles/qt6/AutoScaleHelper.qml</file>
|
<file>mockfiles/qt6/AutoScaleHelper.qml</file>
|
||||||
<file>mockfiles/qt6/AxisHelper.qml</file>
|
<file>mockfiles/qt6/AxisHelper.qml</file>
|
||||||
|
@@ -69,11 +69,7 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
|
||||||
= &QLocalSocket::error;
|
|
||||||
#else
|
|
||||||
= &QLocalSocket::errorOccurred;
|
= &QLocalSocket::errorOccurred;
|
||||||
#endif
|
|
||||||
|
|
||||||
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
|
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import QtQuick 2.6
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
property int x
|
|
||||||
property int y
|
|
||||||
property int width
|
|
||||||
property int height
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,29 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import LineGeometry 1.0
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: arrowRoot
|
|
||||||
|
|
||||||
Model {
|
|
||||||
geometry: LineGeometry {
|
|
||||||
id: lineGeometry
|
|
||||||
name: "Edit 3D ScalableArrow"
|
|
||||||
startPos: Qt.vector3d(0, 0, 0)
|
|
||||||
endPos: Qt.vector3d(0, 1, 0)
|
|
||||||
}
|
|
||||||
scale: Qt.vector3d(1, arrowRoot.length, 1)
|
|
||||||
materials: [ arrowRoot.material ]
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: arrowHead
|
|
||||||
source: "#Cone"
|
|
||||||
materials: [ arrowRoot.material ]
|
|
||||||
y: arrowRoot.length - 3
|
|
||||||
scale: Qt.vector3d(0.02, 0.035, 0.02)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: handleRoot
|
|
||||||
|
|
||||||
property string currentLabel
|
|
||||||
property point currentMousePos
|
|
||||||
property string propName
|
|
||||||
property real propValue: 0
|
|
||||||
property real newValue: 0
|
|
||||||
property real baseScale: 5
|
|
||||||
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale))
|
|
||||||
length: 3
|
|
||||||
offset: -1.5
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: handle
|
|
||||||
source: "#Sphere"
|
|
||||||
materials: [ handleRoot.material ]
|
|
||||||
scale: Qt.vector3d(0.02, 0.02, 0.02)
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScaler
|
|
||||||
active: handleRoot.active
|
|
||||||
view3D: handleRoot.view3D
|
|
||||||
}
|
|
||||||
|
|
||||||
property real _startValue
|
|
||||||
property real _startScale
|
|
||||||
|
|
||||||
signal valueCommit()
|
|
||||||
signal valueChange()
|
|
||||||
|
|
||||||
function updateValue(relativeDistance, screenPos)
|
|
||||||
{
|
|
||||||
handleRoot.newValue = Math.round(Math.min(999999, Math.max(0, _startValue + (relativeDistance * _startScale))));
|
|
||||||
var l = Qt.locale();
|
|
||||||
handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0);
|
|
||||||
handleRoot.currentMousePos = screenPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouseArea, screenPos)=> {
|
|
||||||
_startScale = autoScaler.relativeScale * baseScale;
|
|
||||||
_startValue = propValue;
|
|
||||||
updateValue(0, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateValue(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateValue(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,41 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: arrow
|
|
||||||
source: "../meshes/arrow.mesh"
|
|
||||||
|
|
||||||
signal positionCommit()
|
|
||||||
signal positionMove()
|
|
||||||
|
|
||||||
function localPos(sceneRelativeDistance)
|
|
||||||
{
|
|
||||||
var newScenePos = Qt.vector3d(
|
|
||||||
_targetStartPos.x + sceneRelativeDistance.x,
|
|
||||||
_targetStartPos.y + sceneRelativeDistance.y,
|
|
||||||
_targetStartPos.z + sceneRelativeDistance.z);
|
|
||||||
return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance)=> {
|
|
||||||
targetNode.position = localPos(sceneRelativeDistance);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.moveMultiSelection(false);
|
|
||||||
positionMove();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance)=> {
|
|
||||||
targetNode.position = localPos(sceneRelativeDistance);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.moveMultiSelection(true);
|
|
||||||
positionCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,52 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: overlayNode
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property Camera camera: view3D.camera
|
|
||||||
property bool active: true
|
|
||||||
|
|
||||||
// Read-only
|
|
||||||
property real relativeScale: 1
|
|
||||||
|
|
||||||
onActiveChanged: updateScale()
|
|
||||||
onSceneTransformChanged: updateScale()
|
|
||||||
// Trigger delayed update on camera change to ensure camera values are correct
|
|
||||||
onCameraChanged: _generalHelper.requestOverlayUpdate();
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: camera
|
|
||||||
function onSceneTransformChanged() { updateScale() }
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: _generalHelper
|
|
||||||
function onOverlayUpdateNeeded() { updateScale() }
|
|
||||||
}
|
|
||||||
|
|
||||||
function getScale(baseScale)
|
|
||||||
{
|
|
||||||
return Qt.vector3d(baseScale.x * relativeScale, baseScale.y * relativeScale,
|
|
||||||
baseScale.z * relativeScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateScale()
|
|
||||||
{
|
|
||||||
if (active)
|
|
||||||
relativeScale = helper.getRelativeScale(overlayNode);
|
|
||||||
else
|
|
||||||
relativeScale = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: helper
|
|
||||||
active: false
|
|
||||||
view3D: overlayNode.view3D
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,111 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: axisHelperView
|
|
||||||
|
|
||||||
property var editCameraCtrl
|
|
||||||
property Node selectedNode
|
|
||||||
|
|
||||||
camera: axisHelperCamera
|
|
||||||
|
|
||||||
Node {
|
|
||||||
OrthographicCamera {
|
|
||||||
id: axisHelperCamera
|
|
||||||
rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.quaternion(1, 0, 0, 0)
|
|
||||||
position: editCameraCtrl.camera ? editCameraCtrl.camera.position.minus(editCameraCtrl._lookAtPoint)
|
|
||||||
.normalized().times(600) : Qt.vector3d(0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScale
|
|
||||||
view3D: axisHelperView
|
|
||||||
position: axisHelperGizmo.scenePosition
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: axisHelperGizmo
|
|
||||||
scale: autoScale.getScale(Qt.vector3d(4, 4, 4))
|
|
||||||
|
|
||||||
AxisHelperArm {
|
|
||||||
id: armX
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
|
||||||
color: Qt.rgba(1, 0, 0, 1)
|
|
||||||
hoverColor: Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
|
||||||
view3D: axisHelperView
|
|
||||||
camRotPos: Qt.vector3d(0, 90, 0)
|
|
||||||
camRotNeg: Qt.vector3d(0, -90, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
AxisHelperArm {
|
|
||||||
id: armY
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
color: Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
hoverColor: Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
|
||||||
view3D: axisHelperView
|
|
||||||
camRotPos: Qt.vector3d(-90, 0, 0)
|
|
||||||
camRotNeg: Qt.vector3d(90, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
AxisHelperArm {
|
|
||||||
id: armZ
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
color: Qt.rgba(0, 0, 1, 1)
|
|
||||||
hoverColor: Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
|
||||||
view3D: axisHelperView
|
|
||||||
camRotPos: Qt.vector3d(0, 0, 0)
|
|
||||||
camRotNeg: Qt.vector3d(0, 180, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
acceptedButtons: Qt.LeftButton
|
|
||||||
|
|
||||||
property var pickObj: null
|
|
||||||
|
|
||||||
function cancelHover()
|
|
||||||
{
|
|
||||||
if (pickObj) {
|
|
||||||
pickObj.hovering = false;
|
|
||||||
pickObj = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pick(mouse)
|
|
||||||
{
|
|
||||||
var result = axisHelperView.pick(mouse.x, mouse.y);
|
|
||||||
if (result.objectHit) {
|
|
||||||
if (result.objectHit !== pickObj) {
|
|
||||||
cancelHover();
|
|
||||||
pickObj = result.objectHit;
|
|
||||||
pickObj.hovering = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cancelHover();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: (mouse)=> {
|
|
||||||
pick(mouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouse)=> {
|
|
||||||
pick(mouse);
|
|
||||||
if (pickObj) {
|
|
||||||
axisHelperView.editCameraCtrl.focusObject(axisHelperView.selectedNode,
|
|
||||||
pickObj.cameraRotation, false, false);
|
|
||||||
} else {
|
|
||||||
mouse.accepted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: cancelHover()
|
|
||||||
onCanceled: cancelHover()
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,48 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: armRoot
|
|
||||||
property alias posModel: posModel
|
|
||||||
property alias negModel: negModel
|
|
||||||
property View3D view3D
|
|
||||||
property color hoverColor
|
|
||||||
property color color
|
|
||||||
property vector3d camRotPos
|
|
||||||
property vector3d camRotNeg
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: posModel
|
|
||||||
|
|
||||||
property bool hovering: false
|
|
||||||
property vector3d cameraRotation: armRoot.camRotPos
|
|
||||||
|
|
||||||
source: "../meshes/axishelper.mesh"
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: posMat
|
|
||||||
diffuseColor: posModel.hovering ? armRoot.hoverColor : armRoot.color
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
pickable: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: negModel
|
|
||||||
|
|
||||||
property bool hovering: false
|
|
||||||
property vector3d cameraRotation: armRoot.camRotNeg
|
|
||||||
|
|
||||||
source: "#Sphere"
|
|
||||||
y: -6
|
|
||||||
scale: Qt.vector3d(0.025, 0.025, 0.025)
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: negMat
|
|
||||||
diffuseColor: negModel.hovering ? armRoot.hoverColor : armRoot.color
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
pickable: true
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import CameraGeometry 1.0
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: cameraFrustum
|
|
||||||
|
|
||||||
property alias geometryName: cameraGeometry.name // Name must be unique for each geometry
|
|
||||||
property alias viewPortRect: cameraGeometry.viewPortRect
|
|
||||||
property Node targetNode: null
|
|
||||||
property Node scene: null
|
|
||||||
property bool selected: false
|
|
||||||
|
|
||||||
function updateGeometry()
|
|
||||||
{
|
|
||||||
cameraGeometry.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
|
||||||
rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0)
|
|
||||||
|
|
||||||
geometry: cameraGeometry
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: defaultMaterial
|
|
||||||
diffuseColor: cameraFrustum.selected ? "#FF0000" : "#555555"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
CameraGeometry {
|
|
||||||
id: cameraGeometry
|
|
||||||
camera: cameraFrustum.scene && cameraFrustum.targetNode ? cameraFrustum.targetNode : null
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
IconGizmo {
|
|
||||||
id: cameraGizmo
|
|
||||||
|
|
||||||
property Model frustumModel: null
|
|
||||||
property bool globalShowFrustum: false
|
|
||||||
|
|
||||||
iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_camera.png"
|
|
||||||
|
|
||||||
function connectFrustum(frustum)
|
|
||||||
{
|
|
||||||
frustumModel = frustum;
|
|
||||||
|
|
||||||
frustum.selected = selected;
|
|
||||||
frustum.selected = Qt.binding(function() {return selected;});
|
|
||||||
|
|
||||||
frustum.scene = scene;
|
|
||||||
frustum.scene = Qt.binding(function() {return scene;});
|
|
||||||
|
|
||||||
frustum.targetNode = targetNode;
|
|
||||||
frustum.targetNode = Qt.binding(function() {return targetNode;});
|
|
||||||
|
|
||||||
frustum.visible = (canBeVisible && globalShowFrustum)
|
|
||||||
|| (targetNode && selected && activeScene === scene);
|
|
||||||
frustum.visible = Qt.binding(function() {
|
|
||||||
return (canBeVisible && globalShowFrustum)
|
|
||||||
|| (targetNode && selected && activeScene === scene);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onActiveSceneChanged: {
|
|
||||||
if (frustumModel && activeScene == scene)
|
|
||||||
frustumModel.updateGeometry();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,122 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: rootModel
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property alias color: material.diffuseColor
|
|
||||||
property Node targetNode: null
|
|
||||||
property bool dragging: mouseAreaYZ.dragging || mouseAreaXZ.dragging
|
|
||||||
property bool active: false
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property alias material: material
|
|
||||||
property real length: 12
|
|
||||||
property real offset: 0
|
|
||||||
|
|
||||||
readonly property bool hovering: mouseAreaYZ.hovering || mouseAreaXZ.hovering
|
|
||||||
|
|
||||||
property vector3d _scenePosPressed
|
|
||||||
property real _posPressed
|
|
||||||
property vector3d _targetStartPos
|
|
||||||
|
|
||||||
signal pressed(var mouseArea, point screenPos)
|
|
||||||
signal dragged(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos)
|
|
||||||
signal released(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos)
|
|
||||||
|
|
||||||
DefaultMaterial {
|
|
||||||
id: material
|
|
||||||
diffuseColor: "white"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
|
|
||||||
materials: [ material ]
|
|
||||||
|
|
||||||
function handlePressed(mouseArea, planePos, screenPos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var maskedPosition = Qt.vector3d(planePos.x, 0, 0);
|
|
||||||
_posPressed = planePos.x;
|
|
||||||
_scenePosPressed = mouseArea.dragHelper.mapPositionToScene(maskedPosition);
|
|
||||||
_targetStartPos = mouseArea.pivotScenePosition(targetNode);
|
|
||||||
pressed(mouseArea, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcRelativeDistance(mouseArea, planePos)
|
|
||||||
{
|
|
||||||
var maskedPosition = Qt.vector3d(planePos.x, 0, 0);
|
|
||||||
var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(maskedPosition);
|
|
||||||
return scenePointerPos.minus(_scenePosPressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDragged(mouseArea, planePos, screenPos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dragged(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleReleased(mouseArea, planePos, screenPos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
released(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: mouseAreaYZ
|
|
||||||
view3D: rootModel.view3D
|
|
||||||
x: rootModel.offset
|
|
||||||
y: -1.5
|
|
||||||
width: rootModel.length
|
|
||||||
height: 3
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 90)
|
|
||||||
grabsMouse: targetNode
|
|
||||||
active: rootModel.active
|
|
||||||
dragHelper: rootModel.dragHelper
|
|
||||||
priority: 5
|
|
||||||
|
|
||||||
onPressed: (planePos, screenPos)=> {
|
|
||||||
rootModel.handlePressed(mouseAreaYZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
onDragged: (planePos, screenPos)=> {
|
|
||||||
rootModel.handleDragged(mouseAreaYZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
onReleased: (planePos, screenPos)=> {
|
|
||||||
rootModel.handleReleased(mouseAreaYZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: mouseAreaXZ
|
|
||||||
view3D: rootModel.view3D
|
|
||||||
x: rootModel.offset
|
|
||||||
y: -1.5
|
|
||||||
width: rootModel.length
|
|
||||||
height: 3
|
|
||||||
eulerRotation: Qt.vector3d(0, 90, 90)
|
|
||||||
grabsMouse: targetNode
|
|
||||||
active: rootModel.active
|
|
||||||
dragHelper: rootModel.dragHelper
|
|
||||||
priority: 5
|
|
||||||
|
|
||||||
onPressed: (planePos, screenPos)=> {
|
|
||||||
rootModel.handlePressed(mouseAreaXZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
onDragged: (planePos, screenPos)=> {
|
|
||||||
rootModel.handleDragged(mouseAreaXZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
onReleased: (planePos, screenPos)=> {
|
|
||||||
rootModel.handleReleased(mouseAreaXZ, planePos, screenPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,231 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: cameraCtrl
|
|
||||||
|
|
||||||
property Camera camera: null
|
|
||||||
property View3D view3d: null
|
|
||||||
property string sceneId
|
|
||||||
property vector3d _lookAtPoint
|
|
||||||
property vector3d _pressPoint
|
|
||||||
property vector3d _prevPoint
|
|
||||||
property vector3d _startRotation
|
|
||||||
property vector3d _startPosition
|
|
||||||
property vector3d _startLookAtPoint
|
|
||||||
property matrix4x4 _startTransform
|
|
||||||
property bool _dragging
|
|
||||||
property int _button
|
|
||||||
property real _zoomFactor: 1
|
|
||||||
property Camera _prevCamera: null
|
|
||||||
readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, 600)
|
|
||||||
readonly property vector3d _defaultCameraRotation: Qt.vector3d(-45, 0, 0)
|
|
||||||
readonly property real _defaultCameraLookAtDistance: _defaultCameraPosition.length()
|
|
||||||
readonly property real _keyPanAmount: 5
|
|
||||||
property bool ignoreToolState: false
|
|
||||||
|
|
||||||
function restoreCameraState(cameraState)
|
|
||||||
{
|
|
||||||
if (!camera || ignoreToolState)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_lookAtPoint = cameraState[0];
|
|
||||||
_zoomFactor = cameraState[1];
|
|
||||||
camera.position = cameraState[2];
|
|
||||||
camera.rotation = cameraState[3];
|
|
||||||
_generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint,
|
|
||||||
_zoomFactor, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function restoreDefaultState()
|
|
||||||
{
|
|
||||||
if (!camera)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_lookAtPoint = Qt.vector3d(0, 0, 0);
|
|
||||||
_zoomFactor = 1;
|
|
||||||
camera.position = _defaultCameraPosition;
|
|
||||||
camera.eulerRotation = _defaultCameraRotation;
|
|
||||||
_generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint,
|
|
||||||
_zoomFactor, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function storeCameraState(delay)
|
|
||||||
{
|
|
||||||
if (!camera || ignoreToolState)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var cameraState = [];
|
|
||||||
cameraState[0] = _lookAtPoint;
|
|
||||||
cameraState[1] = _zoomFactor;
|
|
||||||
cameraState[2] = camera.position;
|
|
||||||
cameraState[3] = camera.rotation;
|
|
||||||
_generalHelper.storeToolState(sceneId, "editCamState", cameraState, delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function focusObject(targetNodes, rotation, updateZoom, closeUp)
|
|
||||||
{
|
|
||||||
if (!camera)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// targetNodes could be a list of nodes or a single node
|
|
||||||
var nodes = [];
|
|
||||||
if (targetNodes instanceof Node)
|
|
||||||
nodes.push(targetNodes);
|
|
||||||
else
|
|
||||||
nodes = targetNodes
|
|
||||||
|
|
||||||
camera.eulerRotation = rotation;
|
|
||||||
var newLookAtAndZoom = _generalHelper.focusNodesToCamera(
|
|
||||||
camera, _defaultCameraLookAtDistance, nodes, view3d, _zoomFactor,
|
|
||||||
updateZoom, closeUp);
|
|
||||||
_lookAtPoint = newLookAtAndZoom.toVector3d();
|
|
||||||
_zoomFactor = newLookAtAndZoom.w;
|
|
||||||
storeCameraState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function alignCameras(targetNodes)
|
|
||||||
{
|
|
||||||
if (!camera)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// targetNodes could be a list of nodes or a single node
|
|
||||||
var nodes = [];
|
|
||||||
if (targetNodes instanceof Node)
|
|
||||||
nodes.push(targetNodes);
|
|
||||||
else
|
|
||||||
nodes = targetNodes
|
|
||||||
|
|
||||||
_generalHelper.alignCameras(camera, nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function alignView(targetNodes)
|
|
||||||
{
|
|
||||||
if (!camera)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// targetNodes could be a list of nodes or a single node
|
|
||||||
var nodes = [];
|
|
||||||
if (targetNodes instanceof Node)
|
|
||||||
nodes.push(targetNodes);
|
|
||||||
else
|
|
||||||
nodes = targetNodes
|
|
||||||
|
|
||||||
_lookAtPoint = _generalHelper.alignView(camera, nodes, _lookAtPoint);
|
|
||||||
storeCameraState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function zoomRelative(distance)
|
|
||||||
{
|
|
||||||
if (!camera)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_zoomFactor = _generalHelper.zoomCamera(view3d, camera, distance, _defaultCameraLookAtDistance,
|
|
||||||
_lookAtPoint, _zoomFactor, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
onCameraChanged: {
|
|
||||||
if (camera && _prevCamera) {
|
|
||||||
// Reset zoom on previous camera to ensure it's properties are good to copy to new cam
|
|
||||||
_generalHelper.zoomCamera(view3d, _prevCamera, 0, _defaultCameraLookAtDistance, _lookAtPoint,
|
|
||||||
1, false);
|
|
||||||
|
|
||||||
camera.position = _prevCamera.position;
|
|
||||||
camera.rotation = _prevCamera.rotation;
|
|
||||||
|
|
||||||
// Apply correct zoom to new camera
|
|
||||||
_generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint,
|
|
||||||
_zoomFactor, false);
|
|
||||||
}
|
|
||||||
_prevCamera = camera;
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseHandler
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
|
||||||
hoverEnabled: false
|
|
||||||
anchors.fill: parent
|
|
||||||
onPositionChanged: (mouse)=> {
|
|
||||||
if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier && cameraCtrl._dragging) {
|
|
||||||
var currentPoint = Qt.vector3d(mouse.x, mouse.y, 0);
|
|
||||||
if (cameraCtrl._button == Qt.LeftButton) {
|
|
||||||
_generalHelper.orbitCamera(cameraCtrl.camera, cameraCtrl._startRotation,
|
|
||||||
cameraCtrl._lookAtPoint, cameraCtrl._pressPoint,
|
|
||||||
currentPoint);
|
|
||||||
} else if (cameraCtrl._button == Qt.MiddleButton) {
|
|
||||||
cameraCtrl._lookAtPoint = _generalHelper.panCamera(
|
|
||||||
cameraCtrl.camera, cameraCtrl._startTransform,
|
|
||||||
cameraCtrl._startPosition, cameraCtrl._startLookAtPoint,
|
|
||||||
cameraCtrl._pressPoint, currentPoint, _zoomFactor);
|
|
||||||
} else if (cameraCtrl._button == Qt.RightButton) {
|
|
||||||
cameraCtrl.zoomRelative(currentPoint.y - cameraCtrl._prevPoint.y)
|
|
||||||
cameraCtrl._prevPoint = currentPoint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPressed: (mouse)=> {
|
|
||||||
if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier) {
|
|
||||||
cameraCtrl._dragging = true;
|
|
||||||
cameraCtrl._startRotation = cameraCtrl.camera.eulerRotation;
|
|
||||||
cameraCtrl._startPosition = cameraCtrl.camera.position;
|
|
||||||
cameraCtrl._startLookAtPoint = _lookAtPoint;
|
|
||||||
cameraCtrl._pressPoint = Qt.vector3d(mouse.x, mouse.y, 0);
|
|
||||||
cameraCtrl._prevPoint = cameraCtrl._pressPoint;
|
|
||||||
cameraCtrl._button = mouse.button;
|
|
||||||
cameraCtrl._startTransform = cameraCtrl.camera.sceneTransform;
|
|
||||||
} else {
|
|
||||||
mouse.accepted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRelease() {
|
|
||||||
cameraCtrl._dragging = false;
|
|
||||||
cameraCtrl.storeCameraState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: handleRelease()
|
|
||||||
onCanceled: handleRelease()
|
|
||||||
|
|
||||||
onWheel: (wheel)=> {
|
|
||||||
if (cameraCtrl.camera) {
|
|
||||||
// Empirically determined divisor for nice zoom
|
|
||||||
cameraCtrl.zoomRelative(wheel.angleDelta.y / -40);
|
|
||||||
cameraCtrl.storeCameraState(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onPressed: {
|
|
||||||
var pressPoint = Qt.vector3d(view3d.width / 2, view3d.height / 2, 0);
|
|
||||||
var currentPoint;
|
|
||||||
|
|
||||||
switch (event.key) {
|
|
||||||
case Qt.Key_Left:
|
|
||||||
currentPoint = pressPoint.plus(Qt.vector3d(_keyPanAmount, 0, 0));
|
|
||||||
break;
|
|
||||||
case Qt.Key_Right:
|
|
||||||
currentPoint = pressPoint.plus(Qt.vector3d(-_keyPanAmount, 0, 0));
|
|
||||||
break;
|
|
||||||
case Qt.Key_Up:
|
|
||||||
currentPoint = pressPoint.plus(Qt.vector3d(0, _keyPanAmount, 0));
|
|
||||||
break;
|
|
||||||
case Qt.Key_Down:
|
|
||||||
currentPoint = pressPoint.plus(Qt.vector3d(0, -_keyPanAmount, 0));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentPoint) {
|
|
||||||
_lookAtPoint = _generalHelper.panCamera(
|
|
||||||
camera, cameraCtrl.camera.sceneTransform,
|
|
||||||
cameraCtrl.camera.position, _lookAtPoint,
|
|
||||||
pressPoint, currentPoint, _zoomFactor);
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,981 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: viewRoot
|
|
||||||
width: 1024
|
|
||||||
height: 768
|
|
||||||
visible: true
|
|
||||||
|
|
||||||
property Node activeScene: null
|
|
||||||
property View3D editView: null
|
|
||||||
property string sceneId
|
|
||||||
|
|
||||||
property bool showEditLight: false
|
|
||||||
property bool showGrid: true
|
|
||||||
property bool showSelectionBox: true
|
|
||||||
property bool showIconGizmo: true
|
|
||||||
property bool showCameraFrustum: false
|
|
||||||
property bool usePerspective: true
|
|
||||||
property bool globalOrientation: false
|
|
||||||
property alias contentItem: contentItem
|
|
||||||
property color backgroundGradientColorStart: "#222222"
|
|
||||||
property color backgroundGradientColorEnd: "#999999"
|
|
||||||
property color gridColor: "#aaaaaa"
|
|
||||||
property bool syncBackgroundColor: false
|
|
||||||
|
|
||||||
enum SelectionMode { Item, Group }
|
|
||||||
enum TransformMode { Move, Rotate, Scale }
|
|
||||||
|
|
||||||
property int selectionMode: EditView3D.SelectionMode.Item
|
|
||||||
property int transformMode: EditView3D.TransformMode.Move
|
|
||||||
|
|
||||||
property Node selectedNode: null // This is multiSelectionNode in multi-selection case
|
|
||||||
property var selectedNodes: [] // All selected nodes
|
|
||||||
|
|
||||||
property var lightIconGizmos: []
|
|
||||||
property var cameraGizmos: []
|
|
||||||
property var selectionBoxes: []
|
|
||||||
property rect viewPortRect: Qt.rect(0, 0, 1000, 1000)
|
|
||||||
|
|
||||||
property bool shuttingDown: false
|
|
||||||
|
|
||||||
property real fps: 0
|
|
||||||
|
|
||||||
signal selectionChanged(var selectedNodes)
|
|
||||||
signal commitObjectProperty(var objects, var propNames)
|
|
||||||
signal changeObjectProperty(var objects, var propNames)
|
|
||||||
signal notifyActiveSceneChange()
|
|
||||||
|
|
||||||
onUsePerspectiveChanged: _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective)
|
|
||||||
onShowEditLightChanged: _generalHelper.storeToolState(sceneId, "showEditLight", showEditLight)
|
|
||||||
onGlobalOrientationChanged: _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation)
|
|
||||||
onShowGridChanged: _generalHelper.storeToolState(sceneId, "showGrid", showGrid);
|
|
||||||
onSyncBackgroundColorChanged: _generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor);
|
|
||||||
onShowSelectionBoxChanged: _generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox);
|
|
||||||
onShowIconGizmoChanged: _generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo);
|
|
||||||
onShowCameraFrustumChanged: _generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum);
|
|
||||||
onSelectionModeChanged: _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode);
|
|
||||||
onTransformModeChanged: _generalHelper.storeToolState(sceneId, "transformMode", transformMode);
|
|
||||||
|
|
||||||
onActiveSceneChanged: updateActiveScene()
|
|
||||||
|
|
||||||
function aboutToShutDown()
|
|
||||||
{
|
|
||||||
shuttingDown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createEditView()
|
|
||||||
{
|
|
||||||
var component = Qt.createComponent("SceneView3D.qml");
|
|
||||||
if (component.status === Component.Ready) {
|
|
||||||
editView = component.createObject(viewRect,
|
|
||||||
{"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;
|
|
||||||
cameraControl.forceActiveFocus();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateActiveScene()
|
|
||||||
{
|
|
||||||
if (editView) {
|
|
||||||
// Destroy is async, so make sure we don't get any more updates for the old editView
|
|
||||||
_generalHelper.enableItemUpdate(editView, false);
|
|
||||||
editView.visible = false;
|
|
||||||
editView.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// importScene cannot be updated after initial set, so we need to reconstruct entire View3D
|
|
||||||
if (createEditView()) {
|
|
||||||
if (activeScene) {
|
|
||||||
var toolStates = _generalHelper.getToolStates(sceneId);
|
|
||||||
if (Object.keys(toolStates).length > 0) {
|
|
||||||
updateToolStates(toolStates, true);
|
|
||||||
} else {
|
|
||||||
// Don't inherit the edit light state from the previous scene, but rather
|
|
||||||
// turn the edit light on for scenes that do not have any scene
|
|
||||||
// lights, and turn it off for scenes that have.
|
|
||||||
var hasSceneLight = false;
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].scene === activeScene) {
|
|
||||||
hasSceneLight = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showEditLight = !hasSceneLight;
|
|
||||||
storeCurrentToolStates();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// When active scene is deleted, this function gets called by object deletion
|
|
||||||
// handlers without going through setActiveScene, so make sure sceneId is cleared.
|
|
||||||
// This is skipped during application shutdown, as calling QQuickText::setText()
|
|
||||||
// during application shutdown can crash the application.
|
|
||||||
if (!shuttingDown) {
|
|
||||||
sceneId = "";
|
|
||||||
storeCurrentToolStates();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyActiveSceneChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setActiveScene(newScene, newSceneId)
|
|
||||||
{
|
|
||||||
var needExplicitUpdate = !activeScene && !newScene;
|
|
||||||
|
|
||||||
sceneId = newSceneId;
|
|
||||||
activeScene = newScene;
|
|
||||||
|
|
||||||
if (needExplicitUpdate)
|
|
||||||
updateActiveScene();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disables edit view update if scene doesn't match current activeScene.
|
|
||||||
// If it matches, updates are enabled.
|
|
||||||
function enableEditViewUpdate(scene)
|
|
||||||
{
|
|
||||||
if (editView)
|
|
||||||
_generalHelper.enableItemUpdate(editView, (scene && scene === activeScene));
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleActiveSceneIdChange(newId)
|
|
||||||
{
|
|
||||||
if (sceneId !== newId) {
|
|
||||||
sceneId = newId;
|
|
||||||
storeCurrentToolStates();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fitToView()
|
|
||||||
{
|
|
||||||
if (editView) {
|
|
||||||
var boxModels = [];
|
|
||||||
if (selectedNodes.length > 1) {
|
|
||||||
for (var i = 0; i < selectedNodes.length; ++i) {
|
|
||||||
if (selectionBoxes.length > i)
|
|
||||||
boxModels.push(selectionBoxes[i].model)
|
|
||||||
}
|
|
||||||
} else if (selectedNodes.length > 0 && selectionBoxes.length > 0) {
|
|
||||||
boxModels.push(selectionBoxes[0].model);
|
|
||||||
}
|
|
||||||
cameraControl.focusObject(boxModels, editView.camera.eulerRotation, true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function alignCamerasToView(cameraNodes)
|
|
||||||
{
|
|
||||||
if (editView) {
|
|
||||||
cameraControl.alignCameras(cameraNodes);
|
|
||||||
var propertyNames = ["position", "eulerRotation"];
|
|
||||||
viewRoot.changeObjectProperty(cameraNodes, propertyNames);
|
|
||||||
viewRoot.commitObjectProperty(cameraNodes, propertyNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function alignViewToCamera(cameraNodes)
|
|
||||||
{
|
|
||||||
if (editView)
|
|
||||||
cameraControl.alignView(cameraNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateViewStates(viewStates)
|
|
||||||
{
|
|
||||||
if ("selectBackgroundColor" in viewStates) {
|
|
||||||
if (Array.isArray(viewStates.selectBackgroundColor)) {
|
|
||||||
var colors = viewStates.selectBackgroundColor
|
|
||||||
if (colors.length === 1) {
|
|
||||||
backgroundGradientColorStart = colors[0];
|
|
||||||
backgroundGradientColorEnd = colors[0];
|
|
||||||
} else {
|
|
||||||
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
|
|
||||||
// their default state.
|
|
||||||
function updateToolStates(toolStates, resetToDefault)
|
|
||||||
{
|
|
||||||
if ("showEditLight" in toolStates)
|
|
||||||
showEditLight = toolStates.showEditLight;
|
|
||||||
else if (resetToDefault)
|
|
||||||
showEditLight = false;
|
|
||||||
|
|
||||||
if ("showGrid" in toolStates)
|
|
||||||
showGrid = toolStates.showGrid;
|
|
||||||
else if (resetToDefault)
|
|
||||||
showGrid = true;
|
|
||||||
|
|
||||||
if ("syncBackgroundColor" in toolStates) {
|
|
||||||
syncBackgroundColor = toolStates.syncBackgroundColor;
|
|
||||||
if (syncBackgroundColor) {
|
|
||||||
var color = _generalHelper.sceneEnvironmentColor(sceneId);
|
|
||||||
updateViewStates({"selectBackgroundColor": color})
|
|
||||||
}
|
|
||||||
} else if (resetToDefault) {
|
|
||||||
syncBackgroundColor = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("showSelectionBox" in toolStates)
|
|
||||||
showSelectionBox = toolStates.showSelectionBox;
|
|
||||||
else if (resetToDefault)
|
|
||||||
showSelectionBox = true;
|
|
||||||
|
|
||||||
if ("showIconGizmo" in toolStates)
|
|
||||||
showIconGizmo = toolStates.showIconGizmo;
|
|
||||||
else if (resetToDefault)
|
|
||||||
showIconGizmo = true;
|
|
||||||
|
|
||||||
if ("showCameraFrustum" in toolStates)
|
|
||||||
showCameraFrustum = toolStates.showCameraFrustum;
|
|
||||||
else if (resetToDefault)
|
|
||||||
showCameraFrustum = false;
|
|
||||||
|
|
||||||
if ("usePerspective" in toolStates)
|
|
||||||
usePerspective = toolStates.usePerspective;
|
|
||||||
else if (resetToDefault)
|
|
||||||
usePerspective = true;
|
|
||||||
|
|
||||||
if ("globalOrientation" in toolStates)
|
|
||||||
globalOrientation = toolStates.globalOrientation;
|
|
||||||
else if (resetToDefault)
|
|
||||||
globalOrientation = false;
|
|
||||||
|
|
||||||
if ("selectionMode" in toolStates)
|
|
||||||
selectionMode = toolStates.selectionMode;
|
|
||||||
else if (resetToDefault)
|
|
||||||
selectionMode = EditView3D.SelectionMode.Item;
|
|
||||||
|
|
||||||
if ("transformMode" in toolStates)
|
|
||||||
transformMode = toolStates.transformMode;
|
|
||||||
else if (resetToDefault)
|
|
||||||
transformMode = EditView3D.TransformMode.Move;
|
|
||||||
|
|
||||||
if ("editCamState" in toolStates)
|
|
||||||
cameraControl.restoreCameraState(toolStates.editCamState);
|
|
||||||
else if (resetToDefault)
|
|
||||||
cameraControl.restoreDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
function storeCurrentToolStates()
|
|
||||||
{
|
|
||||||
_generalHelper.storeToolState(sceneId, "showEditLight", showEditLight)
|
|
||||||
_generalHelper.storeToolState(sceneId, "showGrid", showGrid)
|
|
||||||
_generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor)
|
|
||||||
_generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox)
|
|
||||||
_generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo)
|
|
||||||
_generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum)
|
|
||||||
_generalHelper.storeToolState(sceneId, "usePerspective", usePerspective)
|
|
||||||
_generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation)
|
|
||||||
_generalHelper.storeToolState(sceneId, "selectionMode", selectionMode);
|
|
||||||
_generalHelper.storeToolState(sceneId, "transformMode", transformMode);
|
|
||||||
|
|
||||||
cameraControl.storeCameraState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ensureSelectionBoxes(count)
|
|
||||||
{
|
|
||||||
var needMore = count - selectionBoxes.length
|
|
||||||
if (needMore > 0) {
|
|
||||||
var component = Qt.createComponent("SelectionBox.qml");
|
|
||||||
if (component.status === Component.Ready) {
|
|
||||||
for (var i = 0; i < needMore; ++i) {
|
|
||||||
var geometryName = _generalHelper.generateUniqueName("SelectionBoxGeometry");
|
|
||||||
var boxParent = null;
|
|
||||||
if (editView)
|
|
||||||
boxParent = editView.sceneHelpers;
|
|
||||||
var box = component.createObject(boxParent, {"view3D": editView,
|
|
||||||
"geometryName": geometryName});
|
|
||||||
selectionBoxes[selectionBoxes.length] = box;
|
|
||||||
box.view3D = Qt.binding(function() {return editView;});
|
|
||||||
box.visible = Qt.binding(function() {return showSelectionBox;});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectObjects(objects)
|
|
||||||
{
|
|
||||||
// Create selection boxes as necessary. One more box than is actually needed is created, so
|
|
||||||
// that we always have a previously created box to use for new selection.
|
|
||||||
// This fixes an occasional visual glitch when creating a new box.
|
|
||||||
ensureSelectionBoxes(objects.length + 1)
|
|
||||||
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < objects.length; ++i)
|
|
||||||
selectionBoxes[i].targetNode = objects[i];
|
|
||||||
for (i = objects.length; i < selectionBoxes.length; ++i)
|
|
||||||
selectionBoxes[i].targetNode = null;
|
|
||||||
|
|
||||||
selectedNodes = objects;
|
|
||||||
if (objects.length === 0) {
|
|
||||||
selectedNode = null;
|
|
||||||
} else if (objects.length > 1) {
|
|
||||||
selectedNode = multiSelectionNode;
|
|
||||||
_generalHelper.setMultiSelectionTargets(multiSelectionNode, objects);
|
|
||||||
} else {
|
|
||||||
selectedNode = objects[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleObjectClicked(object, button, multi)
|
|
||||||
{
|
|
||||||
if (object instanceof View3D) {
|
|
||||||
// View3D can be the resolved pick target in case the 3D editor is showing content
|
|
||||||
// of a component that has View3D as root. In that case locking is resolved on C++ side
|
|
||||||
// and we ignore multiselection.
|
|
||||||
selectObjects([]);
|
|
||||||
selectionChanged([object]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var clickedObject;
|
|
||||||
|
|
||||||
// Click on locked object is treated same as click on empty space
|
|
||||||
if (!_generalHelper.isLocked(object))
|
|
||||||
clickedObject = object;
|
|
||||||
|
|
||||||
if (selectionMode === EditView3D.SelectionMode.Group) {
|
|
||||||
while (clickedObject && clickedObject !== activeScene
|
|
||||||
&& (activeScene instanceof Model || clickedObject.parent !== activeScene)) {
|
|
||||||
clickedObject = clickedObject.parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Object selection logic:
|
|
||||||
// Regular click: Clear any multiselection, single-selects the clicked object
|
|
||||||
// Ctrl-click: No objects selected: Act as single select
|
|
||||||
// One or more objects selected: Multiselect
|
|
||||||
// Null object always clears entire selection
|
|
||||||
var newSelection = [];
|
|
||||||
if (clickedObject) {
|
|
||||||
if (button === Qt.RightButton) {
|
|
||||||
// Right-clicking does only single selection (when clickedObject is unselected)
|
|
||||||
// This is needed for selecting a target for the context menu
|
|
||||||
if (!selectedNodes.includes(clickedObject))
|
|
||||||
newSelection[0] = clickedObject;
|
|
||||||
else
|
|
||||||
newSelection = selectedNodes;
|
|
||||||
} else if (multi && selectedNodes.length > 0) {
|
|
||||||
var deselect = false;
|
|
||||||
for (var i = 0; i < selectedNodes.length; ++i) {
|
|
||||||
// Multiselecting already selected object clears that object from selection
|
|
||||||
if (selectedNodes[i] !== clickedObject)
|
|
||||||
newSelection[newSelection.length] = selectedNodes[i];
|
|
||||||
else
|
|
||||||
deselect = true;
|
|
||||||
}
|
|
||||||
if (!deselect)
|
|
||||||
newSelection[newSelection.length] = clickedObject;
|
|
||||||
} else {
|
|
||||||
newSelection[0] = clickedObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selectObjects(newSelection);
|
|
||||||
selectionChanged(newSelection);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLightGizmo(scene, obj)
|
|
||||||
{
|
|
||||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
|
||||||
var slotFound = -1;
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (!lightIconGizmos[i].targetNode) {
|
|
||||||
slotFound = i;
|
|
||||||
} else if (lightIconGizmos[i].targetNode === obj) {
|
|
||||||
lightIconGizmos[i].scene = scene;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slotFound !== -1) {
|
|
||||||
lightIconGizmos[slotFound].scene = scene;
|
|
||||||
lightIconGizmos[slotFound].targetNode = obj;
|
|
||||||
lightIconGizmos[slotFound].locked = _generalHelper.isLocked(obj);
|
|
||||||
lightIconGizmos[slotFound].hidden = _generalHelper.isHidden(obj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No free gizmos available, create a new one
|
|
||||||
var gizmoComponent = Qt.createComponent("LightIconGizmo.qml");
|
|
||||||
if (gizmoComponent.status === Component.Ready) {
|
|
||||||
var gizmo = gizmoComponent.createObject(overlayView,
|
|
||||||
{"view3D": overlayView, "targetNode": obj,
|
|
||||||
"selectedNodes": selectedNodes, "scene": scene,
|
|
||||||
"activeScene": activeScene,
|
|
||||||
"locked": _generalHelper.isLocked(obj),
|
|
||||||
"hidden": _generalHelper.isHidden(obj),
|
|
||||||
"globalShow": showIconGizmo});
|
|
||||||
lightIconGizmos[lightIconGizmos.length] = gizmo;
|
|
||||||
gizmo.clicked.connect(handleObjectClicked);
|
|
||||||
gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;});
|
|
||||||
gizmo.activeScene = Qt.binding(function() {return activeScene;});
|
|
||||||
gizmo.globalShow = Qt.binding(function() {return showIconGizmo;});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addCameraGizmo(scene, obj)
|
|
||||||
{
|
|
||||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
|
||||||
var slotFound = -1;
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (!cameraGizmos[i].targetNode) {
|
|
||||||
slotFound = i;
|
|
||||||
} else if (cameraGizmos[i].targetNode === obj) {
|
|
||||||
cameraGizmos[i].scene = scene;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slotFound !== -1) {
|
|
||||||
cameraGizmos[slotFound].scene = scene;
|
|
||||||
cameraGizmos[slotFound].targetNode = obj;
|
|
||||||
cameraGizmos[slotFound].locked = _generalHelper.isLocked(obj);
|
|
||||||
cameraGizmos[slotFound].hidden = _generalHelper.isHidden(obj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No free gizmos available, create a new one
|
|
||||||
var gizmoComponent = Qt.createComponent("CameraGizmo.qml");
|
|
||||||
var frustumComponent = Qt.createComponent("CameraFrustum.qml");
|
|
||||||
if (gizmoComponent.status === Component.Ready && frustumComponent.status === Component.Ready) {
|
|
||||||
var geometryName = _generalHelper.generateUniqueName("CameraGeometry");
|
|
||||||
var frustum = frustumComponent.createObject(
|
|
||||||
overlayScene,
|
|
||||||
{"geometryName": geometryName, "viewPortRect": viewPortRect});
|
|
||||||
var gizmo = gizmoComponent.createObject(
|
|
||||||
overlayView,
|
|
||||||
{"view3D": overlayView, "targetNode": obj,
|
|
||||||
"selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene,
|
|
||||||
"locked": _generalHelper.isLocked(obj), "hidden": _generalHelper.isHidden(obj),
|
|
||||||
"globalShow": showIconGizmo, "globalShowFrustum": showCameraFrustum});
|
|
||||||
|
|
||||||
cameraGizmos[cameraGizmos.length] = gizmo;
|
|
||||||
gizmo.clicked.connect(handleObjectClicked);
|
|
||||||
gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;});
|
|
||||||
gizmo.activeScene = Qt.binding(function() {return activeScene;});
|
|
||||||
gizmo.globalShow = Qt.binding(function() {return showIconGizmo;});
|
|
||||||
gizmo.globalShowFrustum = Qt.binding(function() {return showCameraFrustum;});
|
|
||||||
frustum.viewPortRect = Qt.binding(function() {return viewPortRect;});
|
|
||||||
gizmo.connectFrustum(frustum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function releaseLightGizmo(obj)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].targetNode === obj) {
|
|
||||||
lightIconGizmos[i].scene = null;
|
|
||||||
lightIconGizmos[i].targetNode = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function releaseCameraGizmo(obj)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (cameraGizmos[i].targetNode === obj) {
|
|
||||||
cameraGizmos[i].scene = null;
|
|
||||||
cameraGizmos[i].targetNode = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateLightGizmoScene(scene, obj)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].targetNode === obj) {
|
|
||||||
lightIconGizmos[i].scene = scene;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateCameraGizmoScene(scene, obj)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (cameraGizmos[i].targetNode === obj) {
|
|
||||||
cameraGizmos[i].scene = scene;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gizmoAt(x, y)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].visible && lightIconGizmos[i].hasPoint(x, y))
|
|
||||||
return lightIconGizmos[i].targetNode;
|
|
||||||
}
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (cameraGizmos[i].visible && cameraGizmos[i].hasPoint(x, y))
|
|
||||||
return cameraGizmos[i].targetNode;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
createEditView();
|
|
||||||
selectObjects([]);
|
|
||||||
// Work-around the fact that the projection matrix for the camera is not calculated until
|
|
||||||
// the first frame is rendered, so any initial calls to mapFrom3DScene() will fail.
|
|
||||||
_generalHelper.requestOverlayUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onWidthChanged: _generalHelper.requestOverlayUpdate()
|
|
||||||
onHeightChanged: _generalHelper.requestOverlayUpdate()
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: _generalHelper
|
|
||||||
function onLockedStateChanged(node)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (cameraGizmos[i].targetNode === node) {
|
|
||||||
cameraGizmos[i].locked = _generalHelper.isLocked(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].targetNode === node) {
|
|
||||||
lightIconGizmos[i].locked = _generalHelper.isLocked(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function onHiddenStateChanged(node)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
|
||||||
if (cameraGizmos[i].targetNode === node) {
|
|
||||||
cameraGizmos[i].hidden = _generalHelper.isHidden(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
|
||||||
if (lightIconGizmos[i].targetNode === node) {
|
|
||||||
lightIconGizmos[i].hidden = _generalHelper.isHidden(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: overlayScene
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: overlayPerspectiveCamera
|
|
||||||
clipFar: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipFar : 1000
|
|
||||||
clipNear: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipNear : 1
|
|
||||||
position: viewRoot.editView ? viewRoot.editView.perspectiveCamera.position : Qt.vector3d(0, 0, 0)
|
|
||||||
rotation: viewRoot.editView ? viewRoot.editView.perspectiveCamera.rotation : Qt.quaternion(1, 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
OrthographicCamera {
|
|
||||||
id: overlayOrthoCamera
|
|
||||||
clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000
|
|
||||||
clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1
|
|
||||||
position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0)
|
|
||||||
rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0)
|
|
||||||
scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: gizmoDragHelper
|
|
||||||
view3D: overlayView
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: multiSelectionNode
|
|
||||||
objectName: "multiSelectionNode"
|
|
||||||
}
|
|
||||||
|
|
||||||
MoveGizmo {
|
|
||||||
id: moveGizmo
|
|
||||||
scale: autoScale.getScale(Qt.vector3d(5, 5, 5))
|
|
||||||
highlightOnHover: true
|
|
||||||
targetNode: viewRoot.selectedNode
|
|
||||||
globalOrientation: viewRoot.globalOrientation
|
|
||||||
visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Move
|
|
||||||
view3D: overlayView
|
|
||||||
dragHelper: gizmoDragHelper
|
|
||||||
property var propertyNames: ["position"]
|
|
||||||
|
|
||||||
onPositionCommit: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames);
|
|
||||||
else
|
|
||||||
viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
onPositionMove: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames);
|
|
||||||
else
|
|
||||||
viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScaleGizmo {
|
|
||||||
id: scaleGizmo
|
|
||||||
scale: autoScale.getScale(Qt.vector3d(5, 5, 5))
|
|
||||||
highlightOnHover: true
|
|
||||||
targetNode: viewRoot.selectedNode
|
|
||||||
visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Scale
|
|
||||||
view3D: overlayView
|
|
||||||
dragHelper: gizmoDragHelper
|
|
||||||
property var propertyNames: ["scale"]
|
|
||||||
property var propertyNamesMulti: ["position", "scale"]
|
|
||||||
|
|
||||||
onScaleCommit: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti);
|
|
||||||
else
|
|
||||||
viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
onScaleChange: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti);
|
|
||||||
else
|
|
||||||
viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateGizmo {
|
|
||||||
id: rotateGizmo
|
|
||||||
scale: autoScale.getScale(Qt.vector3d(7, 7, 7))
|
|
||||||
highlightOnHover: true
|
|
||||||
targetNode: viewRoot.selectedNode
|
|
||||||
globalOrientation: viewRoot.globalOrientation
|
|
||||||
visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Rotate
|
|
||||||
view3D: overlayView
|
|
||||||
dragHelper: gizmoDragHelper
|
|
||||||
property var propertyNames: ["eulerRotation"]
|
|
||||||
property var propertyNamesMulti: ["position", "eulerRotation"]
|
|
||||||
|
|
||||||
onRotateCommit: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti);
|
|
||||||
else
|
|
||||||
viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
onRotateChange: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti);
|
|
||||||
else
|
|
||||||
viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LightGizmo {
|
|
||||||
id: lightGizmo
|
|
||||||
targetNode: viewRoot.selectedNode != multiSelectionNode ? viewRoot.selectedNode : null
|
|
||||||
view3D: overlayView
|
|
||||||
dragHelper: gizmoDragHelper
|
|
||||||
|
|
||||||
onPropertyValueCommit: (propName) => {
|
|
||||||
viewRoot.commitObjectProperty([targetNode], [propName]);
|
|
||||||
}
|
|
||||||
onPropertyValueChange: (propName) => {
|
|
||||||
viewRoot.changeObjectProperty([targetNode], [propName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScale
|
|
||||||
view3D: overlayView
|
|
||||||
position: moveGizmo.scenePosition
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: pivotAutoScale
|
|
||||||
view3D: overlayView
|
|
||||||
position: pivotLine.startPos
|
|
||||||
}
|
|
||||||
|
|
||||||
Line3D {
|
|
||||||
id: pivotLine
|
|
||||||
visible: viewRoot.selectedNode && viewRoot.selectedNode != multiSelectionNode
|
|
||||||
name: "3D Edit View Pivot Line"
|
|
||||||
color: "#ddd600"
|
|
||||||
|
|
||||||
startPos: viewRoot.selectedNode ? viewRoot.selectedNode.scenePosition
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
Connections {
|
|
||||||
target: viewRoot
|
|
||||||
function onSelectedNodeChanged()
|
|
||||||
{
|
|
||||||
pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Connections {
|
|
||||||
target: viewRoot.selectedNode
|
|
||||||
function onSceneTransformChanged()
|
|
||||||
{
|
|
||||||
pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: pivotCap
|
|
||||||
source: "#Sphere"
|
|
||||||
scale: pivotAutoScale.getScale(Qt.vector3d(0.03, 0.03, 0.03))
|
|
||||||
position: pivotLine.startPos
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: lineMat
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
diffuseColor: pivotLine.color
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contentItem
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: viewRect
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
gradient: Gradient {
|
|
||||||
GradientStop { position: 1.0; color: backgroundGradientColorStart }
|
|
||||||
GradientStop { position: 0.0; color: backgroundGradientColorEnd }
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
||||||
hoverEnabled: false
|
|
||||||
|
|
||||||
property MouseArea3D freeDraggerArea
|
|
||||||
property point pressPoint
|
|
||||||
property bool initialMoveBlock: false
|
|
||||||
|
|
||||||
onPressed: (mouse) => {
|
|
||||||
if (viewRoot.editView) {
|
|
||||||
var pickResult = viewRoot.editView.pick(mouse.x, mouse.y);
|
|
||||||
handleObjectClicked(_generalHelper.resolvePick(pickResult.objectHit), mouse.button,
|
|
||||||
mouse.modifiers & Qt.ControlModifier);
|
|
||||||
|
|
||||||
if (pickResult.objectHit && pickResult.objectHit instanceof Node) {
|
|
||||||
if (transformMode === EditView3D.TransformMode.Move)
|
|
||||||
freeDraggerArea = moveGizmo.freeDraggerArea;
|
|
||||||
else if (transformMode === EditView3D.TransformMode.Rotate)
|
|
||||||
freeDraggerArea = rotateGizmo.freeDraggerArea;
|
|
||||||
else if (transformMode === EditView3D.TransformMode.Scale)
|
|
||||||
freeDraggerArea = scaleGizmo.freeDraggerArea;
|
|
||||||
pressPoint.x = mouse.x;
|
|
||||||
pressPoint.y = mouse.y;
|
|
||||||
initialMoveBlock = true;
|
|
||||||
} else {
|
|
||||||
mouse.accepted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPositionChanged: (mouse) => {
|
|
||||||
if (freeDraggerArea) {
|
|
||||||
if (initialMoveBlock && Math.abs(pressPoint.x - mouse.x) + Math.abs(pressPoint.y - mouse.y) > 10) {
|
|
||||||
// Don't force press event at actual press, as that puts the gizmo
|
|
||||||
// in free-dragging state, which is bad UX if drag is not actually done
|
|
||||||
freeDraggerArea.forcePressEvent(pressPoint.x, pressPoint.y);
|
|
||||||
freeDraggerArea.forceMoveEvent(mouse.x, mouse.y);
|
|
||||||
initialMoveBlock = false;
|
|
||||||
} else {
|
|
||||||
freeDraggerArea.forceMoveEvent(mouse.x, mouse.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRelease(mouse)
|
|
||||||
{
|
|
||||||
if (freeDraggerArea) {
|
|
||||||
if (initialMoveBlock)
|
|
||||||
freeDraggerArea.forceReleaseEvent(pressPoint.x, pressPoint.y);
|
|
||||||
else
|
|
||||||
freeDraggerArea.forceReleaseEvent(mouse.x, mouse.y);
|
|
||||||
freeDraggerArea = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouse) => {
|
|
||||||
handleRelease(mouse);
|
|
||||||
}
|
|
||||||
onCanceled: (mouse) => {
|
|
||||||
handleRelease(mouse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DropArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: overlayView
|
|
||||||
anchors.fill: parent
|
|
||||||
camera: viewRoot.usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera
|
|
||||||
importScene: overlayScene
|
|
||||||
z: 2
|
|
||||||
}
|
|
||||||
|
|
||||||
Overlay2D {
|
|
||||||
id: gizmoLabel
|
|
||||||
targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo
|
|
||||||
targetView: overlayView
|
|
||||||
visible: targetNode.dragging
|
|
||||||
z: 3
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
color: "white"
|
|
||||||
x: -width / 2
|
|
||||||
y: -height - 8
|
|
||||||
width: gizmoLabelText.width + 4
|
|
||||||
height: gizmoLabelText.height + 4
|
|
||||||
border.width: 1
|
|
||||||
Text {
|
|
||||||
id: gizmoLabelText
|
|
||||||
text: {
|
|
||||||
// This is skipped during application shutdown, as calling QQuickText::setText()
|
|
||||||
// during application shutdown can crash the application.
|
|
||||||
if (shuttingDown)
|
|
||||||
return text;
|
|
||||||
var l = Qt.locale();
|
|
||||||
var targetProperty;
|
|
||||||
if (viewRoot.selectedNode) {
|
|
||||||
if (gizmoLabel.targetNode === moveGizmo)
|
|
||||||
targetProperty = viewRoot.selectedNode.position;
|
|
||||||
else
|
|
||||||
targetProperty = viewRoot.selectedNode.scale;
|
|
||||||
return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1)
|
|
||||||
+ qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1)
|
|
||||||
+ qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: rotateGizmoLabel
|
|
||||||
color: "white"
|
|
||||||
x: rotateGizmo.currentMousePos.x - (10 + width)
|
|
||||||
y: rotateGizmo.currentMousePos.y - (10 + height)
|
|
||||||
width: rotateGizmoLabelText.width + 4
|
|
||||||
height: rotateGizmoLabelText.height + 4
|
|
||||||
border.width: 1
|
|
||||||
visible: rotateGizmo.dragging
|
|
||||||
parent: rotateGizmo.view3D
|
|
||||||
z: 3
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: rotateGizmoLabelText
|
|
||||||
text: {
|
|
||||||
// This is skipped during application shutdown, as calling QQuickText::setText()
|
|
||||||
// during application shutdown can crash the application.
|
|
||||||
if (shuttingDown)
|
|
||||||
return text;
|
|
||||||
var l = Qt.locale();
|
|
||||||
if (rotateGizmo.targetNode) {
|
|
||||||
var degrees = rotateGizmo.currentAngle * (180 / Math.PI);
|
|
||||||
return Number(degrees).toLocaleString(l, 'f', 1);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: lightGizmoLabel
|
|
||||||
color: "white"
|
|
||||||
x: lightGizmo.currentMousePos.x - (10 + width)
|
|
||||||
y: lightGizmo.currentMousePos.y - (10 + height)
|
|
||||||
width: lightGizmoLabelText.width + 4
|
|
||||||
height: lightGizmoLabelText.height + 4
|
|
||||||
border.width: 1
|
|
||||||
visible: lightGizmo.dragging
|
|
||||||
parent: lightGizmo.view3D
|
|
||||||
z: 3
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: lightGizmoLabelText
|
|
||||||
text: lightGizmo.currentLabel
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditCameraController {
|
|
||||||
id: cameraControl
|
|
||||||
camera: viewRoot.editView ? viewRoot.editView.camera : null
|
|
||||||
anchors.fill: parent
|
|
||||||
view3d: viewRoot.editView
|
|
||||||
sceneId: viewRoot.sceneId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AxisHelper {
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
width: 100
|
|
||||||
height: width
|
|
||||||
editCameraCtrl: cameraControl
|
|
||||||
selectedNode: viewRoot.selectedNodes.length === 1 ? viewRoot.selectionBoxes[0].model
|
|
||||||
: viewRoot.selectedNode
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: sceneLabel
|
|
||||||
text: viewRoot.sceneId
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.margins: 4
|
|
||||||
font.pixelSize: 14
|
|
||||||
color: "white"
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: fpsLabel
|
|
||||||
text: viewRoot.fps
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.margins: 4
|
|
||||||
font.pixelSize: 12
|
|
||||||
color: "white"
|
|
||||||
visible: viewRoot.fps > 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,106 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: handleRoot
|
|
||||||
|
|
||||||
property string currentLabel
|
|
||||||
property point currentMousePos
|
|
||||||
property real fadeScale
|
|
||||||
property real baseScale: 5
|
|
||||||
property real dragScale: 1
|
|
||||||
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale))
|
|
||||||
length: 3
|
|
||||||
offset: -1.5
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: handle
|
|
||||||
source: "#Sphere"
|
|
||||||
materials: [ handleRoot.material ]
|
|
||||||
scale: Qt.vector3d(0.02, 0.02, 0.02)
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScaler
|
|
||||||
active: handleRoot.active
|
|
||||||
view3D: handleRoot.view3D
|
|
||||||
}
|
|
||||||
|
|
||||||
property real _q // quadratic fade
|
|
||||||
property real _l // linear fade
|
|
||||||
property real _c // constant fade
|
|
||||||
property real _d: 20 // Divisor from fadeScale calc in lightGizmo
|
|
||||||
property real _startScale
|
|
||||||
property real _startFadeScale
|
|
||||||
property string _currentProp
|
|
||||||
|
|
||||||
signal valueCommit(string propName)
|
|
||||||
signal valueChange(string propName)
|
|
||||||
|
|
||||||
function updateFade(relativeDistance, screenPos)
|
|
||||||
{
|
|
||||||
// Solved from fadeScale equation in LightGizmo
|
|
||||||
var newValue = 0;
|
|
||||||
var _x = Math.max(0, (_startFadeScale - (relativeDistance * _startScale)) / 100);
|
|
||||||
|
|
||||||
// Fades capped to range 0-10 because property editor caps them to that range
|
|
||||||
if (_currentProp === "quadraticFade") {
|
|
||||||
if (_x === 0)
|
|
||||||
newValue = 10;
|
|
||||||
else
|
|
||||||
newValue = Math.max(0, Math.min(10, -(_c - _d + (_l * _x)) / (_x * _x)));
|
|
||||||
if (newValue < 0.01)
|
|
||||||
newValue = 0; // To avoid having tiny positive value when UI shows 0.00
|
|
||||||
targetNode.quadraticFade = newValue;
|
|
||||||
} else if (_currentProp === "linearFade") {
|
|
||||||
if (_x === 0)
|
|
||||||
newValue = 10;
|
|
||||||
else
|
|
||||||
newValue = Math.max(0, Math.min(10, -(_c - _d) / _x));
|
|
||||||
if (newValue < 0.01)
|
|
||||||
newValue = 0; // To avoid having tiny positive value when UI shows 0.00
|
|
||||||
targetNode.linearFade = newValue;
|
|
||||||
} else {
|
|
||||||
// Since pure constant fade equates to infinitely long cone, fadeScale calc assumes
|
|
||||||
// linear fade of one in this case.
|
|
||||||
newValue = Math.max(0, Math.min(10, _d - _x));
|
|
||||||
targetNode.constantFade = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var l = Qt.locale();
|
|
||||||
handleRoot.currentLabel = _currentProp + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 2);
|
|
||||||
handleRoot.currentMousePos = screenPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouseArea, screenPos)=> {
|
|
||||||
_startScale = autoScaler.relativeScale * baseScale * dragScale;
|
|
||||||
_startFadeScale = fadeScale;
|
|
||||||
_l = targetNode.linearFade;
|
|
||||||
_c = targetNode.constantFade;
|
|
||||||
_q = targetNode.quadraticFade;
|
|
||||||
if (targetNode.quadraticFade === 0) {
|
|
||||||
if (targetNode.linearFade === 0) {
|
|
||||||
_currentProp = "constantFade";
|
|
||||||
} else {
|
|
||||||
_currentProp = "linearFade";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_currentProp = "quadraticFade";
|
|
||||||
}
|
|
||||||
updateFade(0, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateFade(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueChange(_currentProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateFade(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueCommit(_currentProp);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,95 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import GridGeometry 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: grid
|
|
||||||
|
|
||||||
property alias lines: gridGeometry.lines
|
|
||||||
property alias step: gridGeometry.step
|
|
||||||
property alias subdivAlpha: subGridMaterial.opacity
|
|
||||||
property alias gridColor: mainGridMaterial.diffuseColor
|
|
||||||
|
|
||||||
eulerRotation.x: 90
|
|
||||||
|
|
||||||
// Note: Only one instance of HelperGrid is supported, as the geometry names are fixed
|
|
||||||
|
|
||||||
Model { // Main grid lines
|
|
||||||
castsShadows: false
|
|
||||||
receivesShadows: false
|
|
||||||
geometry: GridGeometry {
|
|
||||||
id: gridGeometry
|
|
||||||
name: "3D Edit View Helper Grid"
|
|
||||||
}
|
|
||||||
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: mainGridMaterial
|
|
||||||
diffuseColor: "#aaaaaa"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
Model { // Subdivision lines
|
|
||||||
castsShadows: false
|
|
||||||
receivesShadows: false
|
|
||||||
geometry: GridGeometry {
|
|
||||||
lines: gridGeometry.lines
|
|
||||||
step: gridGeometry.step
|
|
||||||
isSubdivision: true
|
|
||||||
name: "3D Edit View Helper Grid subdivisions"
|
|
||||||
}
|
|
||||||
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: subGridMaterial
|
|
||||||
diffuseColor: mainGridMaterial.diffuseColor
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
Model { // Z Axis
|
|
||||||
castsShadows: false
|
|
||||||
receivesShadows: false
|
|
||||||
geometry: GridGeometry {
|
|
||||||
lines: gridGeometry.lines
|
|
||||||
step: gridGeometry.step
|
|
||||||
isCenterLine: true
|
|
||||||
name: "3D Edit View Helper Grid Z Axis"
|
|
||||||
}
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: vCenterLineMaterial
|
|
||||||
diffuseColor: "#00a1d2"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Model { // X Axis
|
|
||||||
castsShadows: false
|
|
||||||
receivesShadows: false
|
|
||||||
eulerRotation.z: 90
|
|
||||||
geometry: GridGeometry {
|
|
||||||
lines: gridGeometry.lines
|
|
||||||
step: gridGeometry.step
|
|
||||||
isCenterLine: true
|
|
||||||
name: "3D Edit View Helper Grid X Axis"
|
|
||||||
}
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: hCenterLineMaterial
|
|
||||||
diffuseColor: "#cb211a"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,112 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: iconGizmo
|
|
||||||
|
|
||||||
property Node activeScene: null
|
|
||||||
property Node scene: null
|
|
||||||
property View3D view3D
|
|
||||||
property bool highlightOnHover: true
|
|
||||||
property Node targetNode: null
|
|
||||||
property var selectedNodes: []
|
|
||||||
readonly property bool selected: {
|
|
||||||
for (var i = 0; i < selectedNodes.length; ++i) {
|
|
||||||
if (selectedNodes[i] === targetNode)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
property bool hasMouse: false
|
|
||||||
property bool hidden: false
|
|
||||||
property bool locked: false
|
|
||||||
property bool globalShow: true
|
|
||||||
property bool canBeVisible: activeScene === scene && !hidden && (targetNode ? targetNode.visible : false)
|
|
||||||
|
|
||||||
property alias iconSource: iconImage.source
|
|
||||||
|
|
||||||
signal clicked(Node node, bool multi)
|
|
||||||
|
|
||||||
function hasPoint(x, y)
|
|
||||||
{
|
|
||||||
if (!view3D || !targetNode)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var point = view3D.mapToItem(iconMouseArea, x, y);
|
|
||||||
|
|
||||||
return point.x >= iconMouseArea.x && (point.x <= iconMouseArea.x + iconMouseArea.width)
|
|
||||||
&& point.y >= iconMouseArea.y && (point.y <= iconMouseArea.y + iconMouseArea.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSelectedChanged: {
|
|
||||||
if (selected)
|
|
||||||
hasMouse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
visible: canBeVisible && globalShow
|
|
||||||
|
|
||||||
Overlay2D {
|
|
||||||
id: iconOverlay
|
|
||||||
targetNode: iconGizmo.targetNode
|
|
||||||
targetView: view3D
|
|
||||||
visible: iconGizmo.visible && !isBehindCamera
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: iconRect
|
|
||||||
|
|
||||||
width: iconImage.width
|
|
||||||
height: iconImage.height
|
|
||||||
x: -width / 2
|
|
||||||
y: -height / 2
|
|
||||||
color: "transparent"
|
|
||||||
border.color: "#7777ff"
|
|
||||||
border.width: !iconGizmo.locked && iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0
|
|
||||||
radius: 5
|
|
||||||
opacity: iconGizmo.selected ? 0.2 : 1
|
|
||||||
Image {
|
|
||||||
id: iconImage
|
|
||||||
fillMode: Image.Pad
|
|
||||||
MouseArea {
|
|
||||||
id: iconMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
onPressed: (mouse)=> {
|
|
||||||
// Ignore singleselection mouse presses when we have single object selected
|
|
||||||
// so that the icon gizmo doesn't hijack mouse clicks meant for other gizmos
|
|
||||||
if (iconGizmo.selected && !(mouse.modifiers & Qt.ControlModifier)
|
|
||||||
&& selectedNodes.length === 1) {
|
|
||||||
mouse.accepted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: (mouse)=> {
|
|
||||||
iconGizmo.clicked(iconGizmo.targetNode,
|
|
||||||
mouse.modifiers & Qt.ControlModifier);
|
|
||||||
}
|
|
||||||
hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected
|
|
||||||
acceptedButtons: Qt.LeftButton
|
|
||||||
|
|
||||||
// onPositionChanged, onContainsMouseAreaChanged, and hasMouse are used instead
|
|
||||||
// of just using containsMouse directly, because containsMouse
|
|
||||||
// cannot be relied upon to update correctly in some situations.
|
|
||||||
// This is likely because the overlapping 3D mouse areas of the gizmos get
|
|
||||||
// the mouse events instead of this area, so mouse leaving the area
|
|
||||||
// doesn't always update containsMouse property.
|
|
||||||
onPositionChanged: {
|
|
||||||
if (!iconGizmo.selected)
|
|
||||||
iconGizmo.hasMouse = containsMouse;
|
|
||||||
}
|
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
|
||||||
if (!iconGizmo.selected)
|
|
||||||
iconGizmo.hasMouse = containsMouse;
|
|
||||||
else
|
|
||||||
iconGizmo.hasMouse = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,66 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: viewRoot
|
|
||||||
width: 1024
|
|
||||||
height: 1024
|
|
||||||
visible: true
|
|
||||||
|
|
||||||
property alias view3D: view3D
|
|
||||||
property alias camPos: viewCamera.position
|
|
||||||
|
|
||||||
function setSceneToBox()
|
|
||||||
{
|
|
||||||
selectionBox.targetNode = view3D.importScene;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fitAndHideBox()
|
|
||||||
{
|
|
||||||
cameraControl.focusObject(selectionBox.model, viewCamera.eulerRotation, true, true);
|
|
||||||
if (cameraControl._zoomFactor < 0.1)
|
|
||||||
view3D.importScene.scale = view3D.importScene.scale.times(10);
|
|
||||||
if (cameraControl._zoomFactor > 10)
|
|
||||||
view3D.importScene.scale = view3D.importScene.scale.times(0.1);
|
|
||||||
|
|
||||||
selectionBox.visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: view3D
|
|
||||||
camera: viewCamera
|
|
||||||
environment: sceneEnv
|
|
||||||
|
|
||||||
SceneEnvironment {
|
|
||||||
id: sceneEnv
|
|
||||||
antialiasingMode: SceneEnvironment.MSAA
|
|
||||||
antialiasingQuality: SceneEnvironment.VeryHigh
|
|
||||||
}
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: viewCamera
|
|
||||||
position: Qt.vector3d(-200, 200, 200)
|
|
||||||
eulerRotation: Qt.vector3d(-45, -45, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectionalLight {
|
|
||||||
rotation: viewCamera.rotation
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectionBox {
|
|
||||||
id: selectionBox
|
|
||||||
view3D: view3D
|
|
||||||
geometryName: "SB"
|
|
||||||
}
|
|
||||||
|
|
||||||
EditCameraController {
|
|
||||||
id: cameraControl
|
|
||||||
camera: view3D.camera
|
|
||||||
view3d: view3D
|
|
||||||
ignoreToolState: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,334 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
import LightUtils 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: lightGizmo
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property Node targetNode: null
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property color color: Qt.rgba(1, 1, 0, 1)
|
|
||||||
property real fadeScale: {
|
|
||||||
// Value indicates area where intensity is above certain percent of total brightness.
|
|
||||||
if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) {
|
|
||||||
var l = targetNode.linearFade;
|
|
||||||
var q = targetNode.quadraticFade;
|
|
||||||
var c = targetNode.constantFade;
|
|
||||||
var d = 20; // divisor to target intensity value. E.g. 20 = 1/20 = 5%
|
|
||||||
if (l === 0 && q === 0)
|
|
||||||
l = 1; // For pure constant fade, cone would be infinite, so pretend we have linear fade
|
|
||||||
// Solved from equation in shader:
|
|
||||||
// 1 / d = 1 / (c + (l + q * dist) * dist);
|
|
||||||
if (q === 0)
|
|
||||||
return 100 * Math.max(((d - c) / l), 1);
|
|
||||||
else
|
|
||||||
return 100 * ((Math.sqrt(4 * q * (d - c) + (l * l)) - l) / (2 * q));
|
|
||||||
} else {
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
readonly property bool dragging: primaryArrow.dragging
|
|
||||||
|| spotLightHandle.dragging
|
|
||||||
|| spotLightInnerHandle.dragging
|
|
||||||
|| spotLightFadeHandle.dragging
|
|
||||||
|| areaHeightHandle.dragging
|
|
||||||
|| areaWidthHandle.dragging
|
|
||||||
|| pointLightFadeHandle.dragging
|
|
||||||
property point currentMousePos
|
|
||||||
property string currentLabel
|
|
||||||
property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2;
|
|
||||||
property real brightnessMultiplier: Math.pow(10, brightnessDecimals);
|
|
||||||
|
|
||||||
signal propertyValueCommit(string propName)
|
|
||||||
signal propertyValueChange(string propName)
|
|
||||||
|
|
||||||
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
|
||||||
visible: lightGizmo.targetNode instanceof SpotLight
|
|
||||||
|| lightGizmo.targetNode instanceof AreaLight
|
|
||||||
|| lightGizmo.targetNode instanceof DirectionalLight
|
|
||||||
|| lightGizmo.targetNode instanceof PointLight
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScaler
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: pointLightParts
|
|
||||||
rotation: lightGizmo.view3D.camera.rotation
|
|
||||||
visible: lightGizmo.targetNode instanceof PointLight
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: pointModel
|
|
||||||
geometryName: "Edit 3D PointLight"
|
|
||||||
geometryType: LightGeometry.Point
|
|
||||||
material: lightMaterial
|
|
||||||
scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale)
|
|
||||||
}
|
|
||||||
|
|
||||||
FadeHandle {
|
|
||||||
id: pointLightFadeHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof PointLight ? Qt.vector3d(-pointModel.scale.x, 0, 0)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof PointLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof PointLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
fadeScale: lightGizmo.fadeScale
|
|
||||||
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: (propName)=> {
|
|
||||||
lightGizmo.propertyValueChange(propName);
|
|
||||||
}
|
|
||||||
onValueCommit: (propName)=> {
|
|
||||||
lightGizmo.propertyValueCommit(propName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Node {
|
|
||||||
rotation: !lightGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0)
|
|
||||||
: lightGizmo.targetNode.sceneRotation
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: spotParts
|
|
||||||
visible: lightGizmo.targetNode instanceof SpotLight
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: spotModel
|
|
||||||
|
|
||||||
property real coneXYScale: spotParts.visible && lightGizmo.targetNode
|
|
||||||
? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.coneAngle / 180)
|
|
||||||
: 1
|
|
||||||
|
|
||||||
geometryName: "Edit 3D SpotLight Cone"
|
|
||||||
geometryType: LightGeometry.Spot
|
|
||||||
material: lightMaterial
|
|
||||||
scale: Qt.vector3d(coneXYScale, coneXYScale,
|
|
||||||
spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.coneAngle > 90
|
|
||||||
? -lightGizmo.fadeScale : lightGizmo.fadeScale)
|
|
||||||
}
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: spotInnerModel
|
|
||||||
|
|
||||||
property real coneXYScale: spotParts.visible && lightGizmo.targetNode
|
|
||||||
? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.innerConeAngle / 180)
|
|
||||||
: 1
|
|
||||||
|
|
||||||
geometryName: "Edit 3D SpotLight Inner Cone"
|
|
||||||
geometryType: LightGeometry.Spot
|
|
||||||
material: lightMaterial
|
|
||||||
scale: Qt.vector3d(coneXYScale, coneXYScale,
|
|
||||||
spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.innerConeAngle > 90
|
|
||||||
? -lightGizmo.fadeScale : lightGizmo.fadeScale)
|
|
||||||
}
|
|
||||||
|
|
||||||
SpotLightHandle {
|
|
||||||
id: spotLightHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, spotModel.scale.y, -spotModel.scale.z)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof SpotLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "coneAngle"
|
|
||||||
propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.coneAngle : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.coneAngle = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: {
|
|
||||||
if (targetNode.innerConeAngle > targetNode.coneAngle)
|
|
||||||
targetNode.innerConeAngle = targetNode.coneAngle;
|
|
||||||
lightGizmo.propertyValueCommit(propName)
|
|
||||||
lightGizmo.propertyValueCommit(spotLightInnerHandle.propName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SpotLightHandle {
|
|
||||||
id: spotLightInnerHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, -spotInnerModel.scale.y, -spotInnerModel.scale.z)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(180, 0, 0)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof SpotLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "innerConeAngle"
|
|
||||||
propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.innerConeAngle : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.innerConeAngle = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: {
|
|
||||||
if (targetNode.coneAngle < targetNode.innerConeAngle)
|
|
||||||
targetNode.coneAngle = targetNode.innerConeAngle;
|
|
||||||
lightGizmo.propertyValueCommit(propName)
|
|
||||||
lightGizmo.propertyValueCommit(spotLightHandle.propName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FadeHandle {
|
|
||||||
id: spotLightFadeHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(spotModel.scale.x / 2, 0, -spotInnerModel.scale.z / 2)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof SpotLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
fadeScale: lightGizmo.fadeScale
|
|
||||||
dragScale: 2
|
|
||||||
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: (propName)=> {
|
|
||||||
lightGizmo.propertyValueChange(propName);
|
|
||||||
}
|
|
||||||
onValueCommit: (propName)=> {
|
|
||||||
lightGizmo.propertyValueCommit(propName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Node {
|
|
||||||
id: areaParts
|
|
||||||
visible: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: areaModel
|
|
||||||
geometryName: "Edit 3D AreaLight"
|
|
||||||
geometryType: LightGeometry.Area
|
|
||||||
material: lightMaterial
|
|
||||||
scale: areaParts.visible ? Qt.vector3d(lightGizmo.targetNode.width / 2,
|
|
||||||
lightGizmo.targetNode.height / 2, 1)
|
|
||||||
.times(lightGizmo.targetNode.scale)
|
|
||||||
: Qt.vector3d(1, 1, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
AreaLightHandle {
|
|
||||||
id: areaWidthHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(-areaModel.scale.x, 0, 0)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 90)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "width"
|
|
||||||
propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.width : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.width = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
|
||||||
}
|
|
||||||
|
|
||||||
AreaLightHandle {
|
|
||||||
id: areaHeightHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(0, -areaModel.scale.y, 0)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 180)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "height"
|
|
||||||
propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.height : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.height = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: directionalModel
|
|
||||||
geometryName: "Edit 3D DirLight"
|
|
||||||
geometryType: LightGeometry.Directional
|
|
||||||
material: lightMaterial
|
|
||||||
visible: lightGizmo.targetNode instanceof DirectionalLight
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(50, 50, 50))
|
|
||||||
}
|
|
||||||
|
|
||||||
AdjustableArrow {
|
|
||||||
id: primaryArrow
|
|
||||||
eulerRotation: Qt.vector3d(-90, 0, 0)
|
|
||||||
targetNode: lightGizmo.targetNode
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
active: lightGizmo.visible
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
|
||||||
length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10
|
|
||||||
|
|
||||||
property real _startBrightness
|
|
||||||
|
|
||||||
function updateBrightness(relativeDistance, screenPos)
|
|
||||||
{
|
|
||||||
var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0));
|
|
||||||
currentValue *= brightnessMultiplier;
|
|
||||||
currentValue = Math.round(currentValue);
|
|
||||||
currentValue /= brightnessMultiplier;
|
|
||||||
|
|
||||||
var l = Qt.locale();
|
|
||||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals);
|
|
||||||
lightGizmo.currentMousePos = screenPos;
|
|
||||||
targetNode.brightness = currentValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouseArea, screenPos)=> {
|
|
||||||
_startBrightness = targetNode.brightness;
|
|
||||||
updateBrightness(0, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateBrightness(relativeDistance, screenPos);
|
|
||||||
lightGizmo.propertyValueChange("brightness");
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateBrightness(relativeDistance, screenPos);
|
|
||||||
lightGizmo.propertyValueCommit("brightness");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultMaterial {
|
|
||||||
id: lightMaterial
|
|
||||||
diffuseColor: lightGizmo.color
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import LightUtils 1.0
|
|
||||||
|
|
||||||
IconGizmo {
|
|
||||||
id: lightIconGizmo
|
|
||||||
|
|
||||||
property color overlayColor: targetNode ? targetNode.color : "transparent"
|
|
||||||
|
|
||||||
iconSource: targetNode
|
|
||||||
? targetNode instanceof DirectionalLight
|
|
||||||
? "image://IconGizmoImageProvider/directional.png:" + overlayColor
|
|
||||||
: targetNode instanceof AreaLight
|
|
||||||
? "image://IconGizmoImageProvider/area.png:" + overlayColor
|
|
||||||
: targetNode instanceof PointLight
|
|
||||||
? "image://IconGizmoImageProvider/point.png:" + overlayColor
|
|
||||||
: "image://IconGizmoImageProvider/spot.png:" + overlayColor
|
|
||||||
: "image://IconGizmoImageProvider/point.png:" + overlayColor
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import LightUtils 1.0
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: lightModel
|
|
||||||
|
|
||||||
property alias geometryName: lightGeometry.name // Name must be unique for each geometry
|
|
||||||
property alias geometryType: lightGeometry.lightType
|
|
||||||
property Material material
|
|
||||||
|
|
||||||
function updateGeometry()
|
|
||||||
{
|
|
||||||
lightGeometry.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
scale: Qt.vector3d(50, 50, 50)
|
|
||||||
|
|
||||||
geometry: lightGeometry
|
|
||||||
materials: [ material ]
|
|
||||||
|
|
||||||
LightGeometry {
|
|
||||||
id: lightGeometry
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import LineGeometry 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: pivotLine
|
|
||||||
|
|
||||||
property alias startPos: lineGeometry.startPos
|
|
||||||
property alias endPos: lineGeometry.endPos
|
|
||||||
property alias name: lineGeometry.name // Name must be unique for each line
|
|
||||||
property alias color: lineMat.diffuseColor
|
|
||||||
|
|
||||||
Model {
|
|
||||||
geometry: LineGeometry {
|
|
||||||
id: lineGeometry
|
|
||||||
}
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
id: lineMat
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,81 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: root
|
|
||||||
anchors.fill: parent
|
|
||||||
environment: sceneEnv
|
|
||||||
camera: envMode === "SkyBox" && envValue === "preview_studio" ? studioCamera : defaultCamera
|
|
||||||
|
|
||||||
property Material previewMaterial
|
|
||||||
property string envMode
|
|
||||||
property string envValue
|
|
||||||
property string modelSrc: "#Sphere"
|
|
||||||
|
|
||||||
function fitToViewPort(closeUp)
|
|
||||||
{
|
|
||||||
// No need to zoom this view, this is here just to avoid runtime warnings
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneEnvironment {
|
|
||||||
id: sceneEnv
|
|
||||||
antialiasingMode: SceneEnvironment.MSAA
|
|
||||||
antialiasingQuality: SceneEnvironment.High
|
|
||||||
backgroundMode: envMode === "Color" ? SceneEnvironment.Color
|
|
||||||
: envMode === "SkyBox" ? SceneEnvironment.SkyBox
|
|
||||||
: SceneEnvironment.Transparent
|
|
||||||
clearColor: envMode === "Color" ? envValue : "#000000"
|
|
||||||
lightProbe: envMode === "SkyBox" ? skyBoxTex : null
|
|
||||||
|
|
||||||
Texture {
|
|
||||||
id: skyBoxTex
|
|
||||||
source: envMode === "SkyBox" ? "../images/" + envValue + ".hdr"
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
DirectionalLight {
|
|
||||||
eulerRotation.x: -26
|
|
||||||
eulerRotation.y: modelSrc === "#Cube" ? -10 : -50
|
|
||||||
brightness: envMode !== "SkyBox" ? 100 : 0
|
|
||||||
}
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: defaultCamera
|
|
||||||
y: 70
|
|
||||||
z: 200
|
|
||||||
eulerRotation.x: -5.71
|
|
||||||
clipNear: 1
|
|
||||||
clipFar: 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: studioCamera
|
|
||||||
y: 232
|
|
||||||
z: 85
|
|
||||||
eulerRotation.x: -64.98
|
|
||||||
clipNear: 1
|
|
||||||
clipFar: 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
rotation: root.camera.rotation
|
|
||||||
y: 50
|
|
||||||
Node {
|
|
||||||
y: modelSrc === "#Cone" ? -40 : 10
|
|
||||||
eulerRotation.x: 35
|
|
||||||
Model {
|
|
||||||
id: model
|
|
||||||
source: modelSrc ? modelSrc : "#Sphere"
|
|
||||||
eulerRotation.y: 45
|
|
||||||
materials: previewMaterial
|
|
||||||
scale: !modelSrc || modelSrc === "#Sphere"
|
|
||||||
? Qt.vector3d(1.7, 1.7, 1.7) : Qt.vector3d(1.2, 1.2, 1.2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
width: 150
|
|
||||||
height: 150
|
|
||||||
|
|
||||||
property alias contentItem: contentItem
|
|
||||||
|
|
||||||
/*
|
|
||||||
View3D {
|
|
||||||
// Dummy view to hold the context in case View3D items are used in the component
|
|
||||||
// TODO remove when QTBUG-87678 is fixed
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contentItem
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,116 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
width: 150
|
|
||||||
height: 150
|
|
||||||
visible: true
|
|
||||||
|
|
||||||
property View3D view: null
|
|
||||||
property alias contentItem: contentItem
|
|
||||||
|
|
||||||
property var previewObject
|
|
||||||
|
|
||||||
property var materialViewComponent
|
|
||||||
property var modelViewComponent
|
|
||||||
property var nodeViewComponent
|
|
||||||
|
|
||||||
property bool closeUp: false
|
|
||||||
|
|
||||||
function destroyView()
|
|
||||||
{
|
|
||||||
previewObject = null;
|
|
||||||
if (view)
|
|
||||||
view.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
function createViewForObject(obj, env, envValue, model)
|
|
||||||
{
|
|
||||||
if (obj instanceof Material)
|
|
||||||
createViewForMaterial(obj, env, envValue, model);
|
|
||||||
else if (obj instanceof Model)
|
|
||||||
createViewForModel(obj);
|
|
||||||
else if (obj instanceof Node)
|
|
||||||
createViewForNode(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createViewForMaterial(material, env, envValue, model)
|
|
||||||
{
|
|
||||||
if (!materialViewComponent)
|
|
||||||
materialViewComponent = Qt.createComponent("MaterialNodeView.qml");
|
|
||||||
|
|
||||||
// Always recreate the view to ensure material is up to date
|
|
||||||
if (materialViewComponent.status === Component.Ready) {
|
|
||||||
view = materialViewComponent.createObject(viewRect, {"previewMaterial": material,
|
|
||||||
"envMode": env,
|
|
||||||
"envValue": envValue,
|
|
||||||
"modelSrc": model});
|
|
||||||
}
|
|
||||||
previewObject = material;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createViewForModel(model)
|
|
||||||
{
|
|
||||||
if (!modelViewComponent)
|
|
||||||
modelViewComponent = Qt.createComponent("ModelNodeView.qml");
|
|
||||||
|
|
||||||
// Always recreate the view to ensure model is up to date
|
|
||||||
if (modelViewComponent.status === Component.Ready)
|
|
||||||
view = modelViewComponent.createObject(viewRect, {"sourceModel": model});
|
|
||||||
|
|
||||||
previewObject = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createViewForNode(node)
|
|
||||||
{
|
|
||||||
if (!nodeViewComponent)
|
|
||||||
nodeViewComponent = Qt.createComponent("NodeNodeView.qml");
|
|
||||||
|
|
||||||
// Always recreate the view to ensure node is up to date
|
|
||||||
if (nodeViewComponent.status === Component.Ready)
|
|
||||||
view = nodeViewComponent.createObject(viewRect, {"importScene": node});
|
|
||||||
|
|
||||||
previewObject = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fitToViewPort()
|
|
||||||
{
|
|
||||||
view.fitToViewPort(closeUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enables/disables icon mode. When in icon mode, camera is zoomed bit closer to reduce margins
|
|
||||||
// and the background is removed, in order to generate a preview suitable for library icons.
|
|
||||||
function setIconMode(enable)
|
|
||||||
{
|
|
||||||
closeUp = enable;
|
|
||||||
backgroundRect.visible = !enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
// Dummy view to hold the context
|
|
||||||
// TODO remove when QTBUG-87678 is fixed
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contentItem
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: viewRect
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can use static image in Qt5 as only small previews will be generated
|
|
||||||
Image {
|
|
||||||
id: backgroundRect
|
|
||||||
anchors.fill: parent
|
|
||||||
z: -1
|
|
||||||
source: "../images/static_floor.png"
|
|
||||||
fillMode: Image.Stretch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: root
|
|
||||||
anchors.fill: parent
|
|
||||||
environment: sceneEnv
|
|
||||||
camera: theCamera
|
|
||||||
|
|
||||||
property Model sourceModel
|
|
||||||
|
|
||||||
function fitToViewPort(closeUp)
|
|
||||||
{
|
|
||||||
// The magic number is the distance from camera default pos to origin
|
|
||||||
_generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, model, root,
|
|
||||||
1040, closeUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneEnvironment {
|
|
||||||
id: sceneEnv
|
|
||||||
antialiasingMode: SceneEnvironment.MSAA
|
|
||||||
antialiasingQuality: SceneEnvironment.High
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectionalLight {
|
|
||||||
eulerRotation.x: -30
|
|
||||||
eulerRotation.y: -30
|
|
||||||
}
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: theCamera
|
|
||||||
z: 600
|
|
||||||
y: 600
|
|
||||||
x: 600
|
|
||||||
eulerRotation.x: -45
|
|
||||||
eulerRotation.y: -45
|
|
||||||
clipFar: 10000
|
|
||||||
clipNear: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: model
|
|
||||||
source: sourceModel.source
|
|
||||||
geometry: sourceModel.geometry
|
|
||||||
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
diffuseColor: "#999999"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,153 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: moveGizmo
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property bool highlightOnHover: false
|
|
||||||
property Node targetNode: null
|
|
||||||
property bool globalOrientation: true
|
|
||||||
readonly property bool dragging: arrowX.dragging || arrowY.dragging || arrowZ.dragging
|
|
||||||
|| planeX.dragging || planeY.dragging || planeZ.dragging
|
|
||||||
|| centerBall.dragging
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property alias freeDraggerArea: centerBall.mouseArea
|
|
||||||
|
|
||||||
position: dragHelper.pivotScenePosition(targetNode)
|
|
||||||
|
|
||||||
onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode)
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: moveGizmo.targetNode
|
|
||||||
function onSceneTransformChanged()
|
|
||||||
{
|
|
||||||
moveGizmo.position = moveGizmo.dragHelper.pivotScenePosition(moveGizmo.targetNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal positionCommit()
|
|
||||||
signal positionMove()
|
|
||||||
|
|
||||||
Node {
|
|
||||||
rotation: globalOrientation || !moveGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0)
|
|
||||||
: moveGizmo.targetNode.sceneRotation
|
|
||||||
Arrow {
|
|
||||||
id: arrowX
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
|
||||||
: Qt.rgba(1, 0, 0, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
|
|
||||||
Arrow {
|
|
||||||
id: arrowY
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
|
||||||
: Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
|
|
||||||
Arrow {
|
|
||||||
id: arrowZ
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
|
||||||
: Qt.rgba(0, 0, 1, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarMoveHandle {
|
|
||||||
id: planeX
|
|
||||||
|
|
||||||
y: 10
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
|
||||||
: Qt.rgba(1, 0, 0, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarMoveHandle {
|
|
||||||
id: planeY
|
|
||||||
|
|
||||||
x: 10
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
|
||||||
: Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarMoveHandle {
|
|
||||||
id: planeZ
|
|
||||||
|
|
||||||
x: 10
|
|
||||||
y: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
|
||||||
: Qt.rgba(0, 0, 1, 1)
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarMoveHandle {
|
|
||||||
id: centerBall
|
|
||||||
|
|
||||||
source: "#Sphere"
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1))
|
|
||||||
: Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
rotation: view3D.camera.rotation
|
|
||||||
priority: 10
|
|
||||||
targetNode: moveGizmo.targetNode
|
|
||||||
|
|
||||||
view3D: moveGizmo.view3D
|
|
||||||
active: moveGizmo.visible
|
|
||||||
dragHelper: moveGizmo.dragHelper
|
|
||||||
|
|
||||||
onPositionCommit: moveGizmo.positionCommit()
|
|
||||||
onPositionMove: moveGizmo.positionMove()
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,41 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: root
|
|
||||||
anchors.fill: parent
|
|
||||||
environment: sceneEnv
|
|
||||||
camera: theCamera
|
|
||||||
|
|
||||||
function fitToViewPort(closeUp)
|
|
||||||
{
|
|
||||||
// The magic number is the distance from camera default pos to origin
|
|
||||||
_generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, importScene, root,
|
|
||||||
1040, closeUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneEnvironment {
|
|
||||||
id: sceneEnv
|
|
||||||
antialiasingMode: SceneEnvironment.MSAA
|
|
||||||
antialiasingQuality: SceneEnvironment.High
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectionalLight {
|
|
||||||
eulerRotation.x: -30
|
|
||||||
eulerRotation.y: -30
|
|
||||||
}
|
|
||||||
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: theCamera
|
|
||||||
z: 600
|
|
||||||
y: 600
|
|
||||||
x: 600
|
|
||||||
eulerRotation.x: -45
|
|
||||||
eulerRotation.y: -45
|
|
||||||
clipFar: 10000
|
|
||||||
clipNear: 1
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
property Node targetNode
|
|
||||||
property View3D targetView
|
|
||||||
|
|
||||||
property vector3d offset: Qt.vector3d(0, 0, 0)
|
|
||||||
|
|
||||||
property bool isBehindCamera
|
|
||||||
|
|
||||||
onTargetNodeChanged: updateOverlay()
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: targetNode
|
|
||||||
function onSceneTransformChanged() { updateOverlay() }
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: targetView.camera
|
|
||||||
function onSceneTransformChanged() { updateOverlay() }
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: _generalHelper
|
|
||||||
function onOverlayUpdateNeeded() { updateOverlay() }
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateOverlay()
|
|
||||||
{
|
|
||||||
var scenePos = targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0);
|
|
||||||
// Need separate variable as scenePos is reference to read-only property
|
|
||||||
var scenePosWithOffset = Qt.vector3d(scenePos.x + offset.x,
|
|
||||||
scenePos.y + offset.y,
|
|
||||||
scenePos.z + offset.z);
|
|
||||||
var viewPos = targetView ? targetView.mapFrom3DScene(scenePosWithOffset)
|
|
||||||
: Qt.vector3d(0, 0, 0);
|
|
||||||
root.x = viewPos.x;
|
|
||||||
root.y = viewPos.y;
|
|
||||||
|
|
||||||
isBehindCamera = viewPos.z <= 0;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,97 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: rootModel
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property alias color: gizmoMaterial.diffuseColor
|
|
||||||
property alias priority: mouseArea.priority
|
|
||||||
property Node targetNode: null
|
|
||||||
property bool dragging: mouseArea.dragging
|
|
||||||
property bool active: false
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property alias mouseArea: mouseArea
|
|
||||||
|
|
||||||
readonly property bool hovering: mouseArea.hovering
|
|
||||||
|
|
||||||
property vector3d _scenePosPressed
|
|
||||||
property vector2d _planePosPressed
|
|
||||||
property vector3d _targetStartPos
|
|
||||||
|
|
||||||
signal pressed(var mouseArea)
|
|
||||||
signal dragged(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance)
|
|
||||||
signal released(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance)
|
|
||||||
|
|
||||||
source: "#Rectangle"
|
|
||||||
|
|
||||||
DefaultMaterial {
|
|
||||||
id: gizmoMaterial
|
|
||||||
diffuseColor: "white"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
materials: gizmoMaterial
|
|
||||||
|
|
||||||
function handlePressed(mouseArea, planePos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_planePosPressed = planePos;
|
|
||||||
_scenePosPressed = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d());
|
|
||||||
_targetStartPos = mouseArea.pivotScenePosition(targetNode);
|
|
||||||
pressed(mouseArea);
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcRelativeDistance(mouseArea, planePos)
|
|
||||||
{
|
|
||||||
var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d());
|
|
||||||
return scenePointerPos.minus(_scenePosPressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDragged(mouseArea, planePos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dragged(mouseArea, calcRelativeDistance(mouseArea, planePos),
|
|
||||||
planePos.minus(_planePosPressed));
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleReleased(mouseArea, planePos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
released(mouseArea, calcRelativeDistance(mouseArea, planePos),
|
|
||||||
planePos.minus(_planePosPressed));
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: mouseArea
|
|
||||||
view3D: rootModel.view3D
|
|
||||||
x: -60
|
|
||||||
y: -60
|
|
||||||
width: 120
|
|
||||||
height: 120
|
|
||||||
grabsMouse: targetNode
|
|
||||||
active: rootModel.active
|
|
||||||
dragHelper: rootModel.dragHelper
|
|
||||||
|
|
||||||
onPressed: (planePos)=> {
|
|
||||||
rootModel.handlePressed(mouseArea, planePos);
|
|
||||||
}
|
|
||||||
onDragged: (planePos)=> {
|
|
||||||
rootModel.handleDragged(mouseArea, planePos);
|
|
||||||
}
|
|
||||||
onReleased: (planePos)=> {
|
|
||||||
rootModel.handleReleased(mouseArea, planePos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,42 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
PlanarDraggable {
|
|
||||||
id: planarHandle
|
|
||||||
scale: Qt.vector3d(0.024, 0.024, 0.024)
|
|
||||||
|
|
||||||
signal positionCommit()
|
|
||||||
signal positionMove()
|
|
||||||
|
|
||||||
function localPos(sceneRelativeDistance)
|
|
||||||
{
|
|
||||||
var newScenePos = Qt.vector3d(
|
|
||||||
_targetStartPos.x + sceneRelativeDistance.x,
|
|
||||||
_targetStartPos.y + sceneRelativeDistance.y,
|
|
||||||
_targetStartPos.z + sceneRelativeDistance.z);
|
|
||||||
return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance)=> {
|
|
||||||
targetNode.position = localPos(sceneRelativeDistance);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.moveMultiSelection(false);
|
|
||||||
positionMove();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance)=> {
|
|
||||||
targetNode.position = localPos(sceneRelativeDistance);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.moveMultiSelection(true);
|
|
||||||
positionCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
PlanarDraggable {
|
|
||||||
id: planarHandle
|
|
||||||
scale: Qt.vector3d(0.024, 0.024, 0.024)
|
|
||||||
|
|
||||||
property bool globalOrientation: false
|
|
||||||
property vector3d axisX
|
|
||||||
property vector3d axisY
|
|
||||||
|
|
||||||
signal scaleCommit()
|
|
||||||
signal scaleChange()
|
|
||||||
|
|
||||||
property vector3d _startScale
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
_startScale = targetNode.scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> {
|
|
||||||
targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x),
|
|
||||||
axisX, axisY);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(false);
|
|
||||||
scaleChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> {
|
|
||||||
targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x),
|
|
||||||
axisX, axisY);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(true);
|
|
||||||
scaleCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,271 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: rotateGizmo
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property bool highlightOnHover: true
|
|
||||||
property Node targetNode: null
|
|
||||||
property bool globalOrientation: true
|
|
||||||
readonly property bool dragging: cameraRing.dragging
|
|
||||||
|| rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property real currentAngle
|
|
||||||
property point currentMousePos
|
|
||||||
property alias freeDraggerArea: mouseAreaFree
|
|
||||||
property bool blocked: false
|
|
||||||
|
|
||||||
position: dragHelper.pivotScenePosition(targetNode)
|
|
||||||
|
|
||||||
onTargetNodeChanged: {
|
|
||||||
position = dragHelper.pivotScenePosition(targetNode);
|
|
||||||
blocked = _generalHelper.isRotationBlocked(targetNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: rotateGizmo.targetNode
|
|
||||||
function onSceneTransformChanged()
|
|
||||||
{
|
|
||||||
rotateGizmo.position = dragHelper.pivotScenePosition(targetNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: _generalHelper
|
|
||||||
function onRotationBlocksChanged()
|
|
||||||
{
|
|
||||||
blocked = _generalHelper.isRotationBlocked(targetNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal rotateCommit()
|
|
||||||
signal rotateChange()
|
|
||||||
|
|
||||||
function copyRingProperties(srcRing) {
|
|
||||||
draggingRing.rotation = srcRing.sceneRotation;
|
|
||||||
draggingRing.color = srcRing.color;
|
|
||||||
draggingRing.scale = srcRing.scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
onDraggingChanged: {
|
|
||||||
if (rotRingX.dragging)
|
|
||||||
copyRingProperties(rotRingX)
|
|
||||||
else if (rotRingY.dragging)
|
|
||||||
copyRingProperties(rotRingY)
|
|
||||||
else if (rotRingZ.dragging)
|
|
||||||
copyRingProperties(rotRingZ)
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: rotNode
|
|
||||||
rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0)
|
|
||||||
: rotateGizmo.targetNode.sceneRotation
|
|
||||||
visible: !rotateGizmo.dragging && !freeRotator.dragging
|
|
||||||
|
|
||||||
RotateRing {
|
|
||||||
id: rotRingX
|
|
||||||
objectName: "Rotate Ring X"
|
|
||||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
|
||||||
targetNode: rotateGizmo.targetNode
|
|
||||||
color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
: highlightOnHover && (hovering || dragging)
|
|
||||||
? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1)
|
|
||||||
priority: 40
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
active: rotateGizmo.visible && !rotateGizmo.blocked
|
|
||||||
dragHelper: rotateGizmo.dragHelper
|
|
||||||
|
|
||||||
onRotateCommit: rotateGizmo.rotateCommit()
|
|
||||||
onRotateChange: rotateGizmo.rotateChange()
|
|
||||||
onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle
|
|
||||||
onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateRing {
|
|
||||||
id: rotRingY
|
|
||||||
objectName: "Rotate Ring Y"
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
targetNode: rotateGizmo.targetNode
|
|
||||||
color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
: highlightOnHover && (hovering || dragging)
|
|
||||||
? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
// Just a smidge smaller than higher priority rings so that it doesn't obscure them
|
|
||||||
scale: Qt.vector3d(0.998, 0.998, 0.998)
|
|
||||||
priority: 30
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
active: rotateGizmo.visible && !rotateGizmo.blocked
|
|
||||||
dragHelper: rotateGizmo.dragHelper
|
|
||||||
|
|
||||||
onRotateCommit: rotateGizmo.rotateCommit()
|
|
||||||
onRotateChange: rotateGizmo.rotateChange()
|
|
||||||
onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle
|
|
||||||
onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateRing {
|
|
||||||
id: rotRingZ
|
|
||||||
objectName: "Rotate Ring Z"
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
targetNode: rotateGizmo.targetNode
|
|
||||||
color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
: highlightOnHover && (hovering || dragging)
|
|
||||||
? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1)
|
|
||||||
// Just a smidge smaller than higher priority rings so that it doesn't obscure them
|
|
||||||
scale: Qt.vector3d(0.996, 0.996, 0.996)
|
|
||||||
priority: 20
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
active: rotateGizmo.visible && !rotateGizmo.blocked
|
|
||||||
dragHelper: rotateGizmo.dragHelper
|
|
||||||
|
|
||||||
onRotateCommit: rotateGizmo.rotateCommit()
|
|
||||||
onRotateChange: rotateGizmo.rotateChange()
|
|
||||||
onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle
|
|
||||||
onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateRing {
|
|
||||||
// This ring is used as visual proxy during dragging to display the currently dragged
|
|
||||||
// plane in static position, as rotation planes can wobble when ancestors don't have
|
|
||||||
// uniform scaling.
|
|
||||||
// Camera ring doesn't need dragging proxy as it doesn't wobble.
|
|
||||||
id: draggingRing
|
|
||||||
objectName: "draggingRing"
|
|
||||||
targetNode: rotateGizmo.targetNode
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
active: false
|
|
||||||
visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateRing {
|
|
||||||
id: cameraRing
|
|
||||||
objectName: "cameraRing"
|
|
||||||
rotation: rotateGizmo.view3D.camera.rotation
|
|
||||||
targetNode: rotateGizmo.targetNode
|
|
||||||
color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
: highlightOnHover && (hovering || dragging)
|
|
||||||
? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1))
|
|
||||||
: Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
scale: Qt.vector3d(1.1, 1.1, 1.1)
|
|
||||||
priority: 10
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
active: rotateGizmo.visible && !rotateGizmo.blocked
|
|
||||||
dragHelper: rotateGizmo.dragHelper
|
|
||||||
visible: !rotRingX.dragging && !rotRingY.dragging && !rotRingZ.dragging && !freeRotator.dragging
|
|
||||||
|
|
||||||
onRotateCommit: rotateGizmo.rotateCommit()
|
|
||||||
onRotateChange: rotateGizmo.rotateChange()
|
|
||||||
onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle
|
|
||||||
onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: freeRotator
|
|
||||||
|
|
||||||
source: "#Sphere"
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: material
|
|
||||||
diffuseColor: "black"
|
|
||||||
opacity: mouseAreaFree.hovering && !rotateGizmo.blocked ? 0.15 : 0
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
scale: Qt.vector3d(0.15, 0.15, 0.15)
|
|
||||||
visible: !rotateGizmo.dragging && !dragging
|
|
||||||
|
|
||||||
property bool dragging: false
|
|
||||||
property vector3d _pointerPosPressed
|
|
||||||
property vector3d _startRotation
|
|
||||||
|
|
||||||
function handlePressed(screenPos)
|
|
||||||
{
|
|
||||||
if (!rotateGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
|
|
||||||
// Need to recreate vector as we need to adjust it and we can't do that on reference of
|
|
||||||
// scenePosition, which is read-only property
|
|
||||||
var scenePos = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode);
|
|
||||||
_pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0);
|
|
||||||
|
|
||||||
// Recreate vector so we don't follow the changes in targetNode.rotation
|
|
||||||
_startRotation = Qt.vector3d(rotateGizmo.targetNode.eulerRotation.x,
|
|
||||||
rotateGizmo.targetNode.eulerRotation.y,
|
|
||||||
rotateGizmo.targetNode.eulerRotation.z);
|
|
||||||
// Ensure we never set NaN values for rotation, even if target node originally has them
|
|
||||||
if (isNaN(_startRotation.x))
|
|
||||||
_startRotation.x = 0;
|
|
||||||
if (isNaN(_startRotation.y))
|
|
||||||
_startRotation.y = 0;
|
|
||||||
if (isNaN(_startRotation.z))
|
|
||||||
_startRotation.z = 0;
|
|
||||||
|
|
||||||
dragging = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDragged(screenPos)
|
|
||||||
{
|
|
||||||
if (!rotateGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mouseAreaFree.applyFreeRotation(
|
|
||||||
rotateGizmo.targetNode, _startRotation, _pointerPosPressed,
|
|
||||||
Qt.vector3d(screenPos.x, screenPos.y, 0));
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.rotateMultiSelection(false);
|
|
||||||
|
|
||||||
rotateGizmo.rotateChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleReleased(screenPos)
|
|
||||||
{
|
|
||||||
if (!rotateGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mouseAreaFree.applyFreeRotation(
|
|
||||||
rotateGizmo.targetNode, _startRotation, _pointerPosPressed,
|
|
||||||
Qt.vector3d(screenPos.x, screenPos.y, 0));
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.rotateMultiSelection(true);
|
|
||||||
|
|
||||||
rotateGizmo.rotateCommit();
|
|
||||||
dragging = false;
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.resetMultiSelectionNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: mouseAreaFree
|
|
||||||
view3D: rotateGizmo.view3D
|
|
||||||
rotation: rotateGizmo.view3D.camera.rotation
|
|
||||||
objectName: "Free rotator plane"
|
|
||||||
x: -50
|
|
||||||
y: -50
|
|
||||||
width: 100
|
|
||||||
height: 100
|
|
||||||
circlePickArea: Qt.point(25, 50)
|
|
||||||
grabsMouse: rotateGizmo.targetNode
|
|
||||||
active: rotateGizmo.visible && !rotateGizmo.blocked
|
|
||||||
dragHelper: rotateGizmo.dragHelper
|
|
||||||
|
|
||||||
onPressed: (planePos, screenPos)=> {
|
|
||||||
freeRotator.handlePressed(screenPos);
|
|
||||||
}
|
|
||||||
onDragged: (planePos, screenPos)=> {
|
|
||||||
freeRotator.handleDragged(screenPos);
|
|
||||||
}
|
|
||||||
onReleased: (planePos, screenPos)=> {
|
|
||||||
freeRotator.handleReleased(screenPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,142 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: rotateRing
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property alias color: material.diffuseColor
|
|
||||||
property Node targetNode: null
|
|
||||||
property bool dragging: mouseAreaMain.dragging
|
|
||||||
property bool active: false
|
|
||||||
property alias hovering: mouseAreaMain.hovering
|
|
||||||
property alias priority: mouseAreaMain.priority
|
|
||||||
property real currentAngle
|
|
||||||
property point currentMousePos
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
|
|
||||||
property vector3d _pointerPosPressed
|
|
||||||
property vector3d _targetPosOnScreen
|
|
||||||
property vector3d _startRotation
|
|
||||||
property bool _trackBall
|
|
||||||
|
|
||||||
signal rotateCommit()
|
|
||||||
signal rotateChange()
|
|
||||||
|
|
||||||
source: "../meshes/ring.mesh"
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: pickModel
|
|
||||||
objectName: "PickModel for " + rotateRing.objectName
|
|
||||||
source: "../meshes/ringselect.mesh"
|
|
||||||
pickable: true
|
|
||||||
}
|
|
||||||
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: material
|
|
||||||
diffuseColor: "white"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyLocalRotation(screenPos)
|
|
||||||
{
|
|
||||||
currentAngle = mouseAreaMain.dragHelper.getNewRotationAngle(
|
|
||||||
targetNode, _pointerPosPressed, Qt.vector3d(screenPos.x, screenPos.y, 0),
|
|
||||||
_targetPosOnScreen, currentAngle, _trackBall);
|
|
||||||
mouseAreaMain.dragHelper.applyRotationAngleToNode(targetNode, _startRotation, currentAngle);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePressed(screenPos, angle)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
|
|
||||||
// Need to recreate vector as we need to adjust it and we can't do that on reference of
|
|
||||||
// scenePosition, which is read-only property
|
|
||||||
var scenePos = mouseAreaMain.pivotScenePosition(targetNode);
|
|
||||||
|
|
||||||
_targetPosOnScreen = view3D.mapFrom3DScene(scenePos);
|
|
||||||
_targetPosOnScreen.z = 0;
|
|
||||||
_pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0);
|
|
||||||
_trackBall = angle < 0.1;
|
|
||||||
|
|
||||||
// Recreate vector so we don't follow the changes in targetNode.eulerRotation
|
|
||||||
_startRotation = Qt.vector3d(targetNode.eulerRotation.x,
|
|
||||||
targetNode.eulerRotation.y,
|
|
||||||
targetNode.eulerRotation.z);
|
|
||||||
// Ensure we never set NaN values for rotation, even if target node originally has them
|
|
||||||
if (isNaN(_startRotation.x))
|
|
||||||
_startRotation.x = 0;
|
|
||||||
if (isNaN(_startRotation.y))
|
|
||||||
_startRotation.y = 0;
|
|
||||||
if (isNaN(_startRotation.z))
|
|
||||||
_startRotation.z = 0;
|
|
||||||
currentAngle = 0;
|
|
||||||
currentMousePos = screenPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDragged(screenPos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
applyLocalRotation(screenPos);
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.rotateMultiSelection(false);
|
|
||||||
|
|
||||||
currentMousePos = screenPos;
|
|
||||||
rotateChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleReleased(screenPos)
|
|
||||||
{
|
|
||||||
if (!targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
applyLocalRotation(screenPos);
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.rotateMultiSelection(true);
|
|
||||||
|
|
||||||
rotateCommit();
|
|
||||||
currentAngle = 0;
|
|
||||||
currentMousePos = screenPos;
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.resetMultiSelectionNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: mouseAreaMain
|
|
||||||
view3D: rotateRing.view3D
|
|
||||||
objectName: "Main plane of " + rotateRing.objectName
|
|
||||||
x: -30
|
|
||||||
y: -30
|
|
||||||
width: 60
|
|
||||||
height: 60
|
|
||||||
circlePickArea: Qt.point(9.2, 1.4)
|
|
||||||
grabsMouse: targetNode
|
|
||||||
active: rotateRing.active
|
|
||||||
pickNode: pickModel
|
|
||||||
minAngle: 0.05
|
|
||||||
dragHelper: rotateRing.dragHelper
|
|
||||||
|
|
||||||
onPressed: (planePos, screenPos, angle)=> {
|
|
||||||
rotateRing.handlePressed(screenPos, angle);
|
|
||||||
}
|
|
||||||
onDragged: (planePos, screenPos)=> {
|
|
||||||
rotateRing.handleDragged(screenPos);
|
|
||||||
}
|
|
||||||
onReleased: (planePos, screenPos)=> {
|
|
||||||
rotateRing.handleReleased(screenPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,219 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: scaleGizmo
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property bool highlightOnHover: false
|
|
||||||
property Node targetNode: null
|
|
||||||
readonly property bool dragging: scaleRodX.dragging || scaleRodY.dragging || scaleRodZ.dragging
|
|
||||||
|| planeX.dragging || planeY.dragging || planeZ.dragging
|
|
||||||
|| centerMouseArea.dragging
|
|
||||||
property MouseArea3D dragHelper: null
|
|
||||||
property alias freeDraggerArea: centerMouseArea
|
|
||||||
|
|
||||||
position: dragHelper.pivotScenePosition(targetNode)
|
|
||||||
|
|
||||||
onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode)
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: scaleGizmo.targetNode
|
|
||||||
function onSceneTransformChanged()
|
|
||||||
{
|
|
||||||
scaleGizmo.position = scaleGizmo.dragHelper.pivotScenePosition(scaleGizmo.targetNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal scaleCommit()
|
|
||||||
signal scaleChange()
|
|
||||||
|
|
||||||
Node {
|
|
||||||
rotation: !targetNode ? Qt.quaternion(1, 0, 0, 0) : targetNode.sceneRotation
|
|
||||||
|
|
||||||
ScaleRod {
|
|
||||||
id: scaleRodX
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
|
||||||
axis: Qt.vector3d(1, 0, 0)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
|
||||||
: Qt.rgba(1, 0, 0, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
ScaleRod {
|
|
||||||
id: scaleRodY
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
axis: Qt.vector3d(0, 1, 0)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
|
||||||
: Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
ScaleRod {
|
|
||||||
id: scaleRodZ
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
axis: Qt.vector3d(0, 0, 1)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
|
||||||
: Qt.rgba(0, 0, 1, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarScaleHandle {
|
|
||||||
id: planeX
|
|
||||||
|
|
||||||
y: 10
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
|
||||||
axisX: Qt.vector3d(0, 0, -1)
|
|
||||||
axisY: Qt.vector3d(0, 1, 0)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
|
||||||
: Qt.rgba(1, 0, 0, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarScaleHandle {
|
|
||||||
id: planeY
|
|
||||||
|
|
||||||
x: 10
|
|
||||||
z: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
|
||||||
axisX: Qt.vector3d(1, 0, 0)
|
|
||||||
axisY: Qt.vector3d(0, 0, 1)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
|
||||||
: Qt.rgba(0, 0.6, 0, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
PlanarScaleHandle {
|
|
||||||
id: planeZ
|
|
||||||
|
|
||||||
x: 10
|
|
||||||
y: 10
|
|
||||||
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
|
||||||
axisX: Qt.vector3d(1, 0, 0)
|
|
||||||
axisY: Qt.vector3d(0, 1, 0)
|
|
||||||
targetNode: scaleGizmo.targetNode
|
|
||||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
|
||||||
: Qt.rgba(0, 0, 1, 1)
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
onScaleCommit: scaleGizmo.scaleCommit()
|
|
||||||
onScaleChange: scaleGizmo.scaleChange()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: centerCube
|
|
||||||
|
|
||||||
source: "#Cube"
|
|
||||||
scale: Qt.vector3d(0.024, 0.024, 0.024)
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: material
|
|
||||||
diffuseColor: highlightOnHover
|
|
||||||
&& (centerMouseArea.hovering || centerMouseArea.dragging)
|
|
||||||
? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1))
|
|
||||||
: Qt.rgba(0.5, 0.5, 0.5, 1)
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea3D {
|
|
||||||
id: centerMouseArea
|
|
||||||
view3D: scaleGizmo.view3D
|
|
||||||
x: -60
|
|
||||||
y: -60
|
|
||||||
width: 120
|
|
||||||
height: 120
|
|
||||||
rotation: view3D.camera.rotation
|
|
||||||
grabsMouse: scaleGizmo.targetNode
|
|
||||||
priority: 10
|
|
||||||
active: scaleGizmo.visible
|
|
||||||
dragHelper: scaleGizmo.dragHelper
|
|
||||||
|
|
||||||
property vector3d _startScale
|
|
||||||
property point _startScreenPos
|
|
||||||
|
|
||||||
function localScale(screenPos)
|
|
||||||
{
|
|
||||||
var yDelta = screenPos.y - _startScreenPos.y;
|
|
||||||
if (yDelta === 0)
|
|
||||||
return _startScale;
|
|
||||||
var scaler = 1.0 + (yDelta * 0.025);
|
|
||||||
if (scaler === 0)
|
|
||||||
scaler = 0.0001;
|
|
||||||
return Qt.vector3d(scaler * _startScale.x,
|
|
||||||
scaler * _startScale.y,
|
|
||||||
scaler * _startScale.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (planePos, screenPos)=> {
|
|
||||||
if (!scaleGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
|
|
||||||
// Recreate vector so we don't follow the changes in targetNode.scale
|
|
||||||
_startScale = Qt.vector3d(scaleGizmo.targetNode.scale.x,
|
|
||||||
scaleGizmo.targetNode.scale.y,
|
|
||||||
scaleGizmo.targetNode.scale.z);
|
|
||||||
_startScreenPos = screenPos;
|
|
||||||
}
|
|
||||||
onDragged: (planePos, screenPos)=> {
|
|
||||||
if (!scaleGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
scaleGizmo.targetNode.scale = localScale(screenPos);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(false);
|
|
||||||
scaleGizmo.scaleChange();
|
|
||||||
}
|
|
||||||
onReleased: (planePos, screenPos)=> {
|
|
||||||
if (!scaleGizmo.targetNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
scaleGizmo.targetNode.scale = localScale(screenPos);
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(true);
|
|
||||||
scaleGizmo.scaleCommit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import MouseArea3D 1.0
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: scaleRod
|
|
||||||
source: "../meshes/scalerod.mesh"
|
|
||||||
|
|
||||||
property vector3d axis
|
|
||||||
|
|
||||||
signal scaleCommit()
|
|
||||||
signal scaleChange()
|
|
||||||
|
|
||||||
property vector3d _startScale
|
|
||||||
|
|
||||||
Model {
|
|
||||||
source: "#Cube"
|
|
||||||
y: 10
|
|
||||||
scale: Qt.vector3d(0.020, 0.020, 0.020)
|
|
||||||
materials: DefaultMaterial {
|
|
||||||
id: material
|
|
||||||
diffuseColor: scaleRod.color
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.restartMultiSelection();
|
|
||||||
_startScale = targetNode.scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> {
|
|
||||||
targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0),
|
|
||||||
axis, Qt.vector3d(0, 0, 0));
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(false);
|
|
||||||
scaleChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> {
|
|
||||||
targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0),
|
|
||||||
axis, Qt.vector3d(0, 0, 0));
|
|
||||||
if (targetNode == multiSelectionNode)
|
|
||||||
_generalHelper.scaleMultiSelection(true);
|
|
||||||
scaleCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
View3D {
|
|
||||||
id: sceneView
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
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
|
|
||||||
property double cameraZoomFactor: .55;
|
|
||||||
|
|
||||||
// Empirical cameraZoomFactor values at which the grid zoom level is doubled. The values are
|
|
||||||
// approximately uniformally distributed over the non-linear range of cameraZoomFactor.
|
|
||||||
readonly property var grid_thresholds: [0.55, 1.10, 2.35, 4.9, 10.0, 20.5, 42.0, 85.0, 999999.0]
|
|
||||||
property var thresIdx: 1
|
|
||||||
property var thresPerc: 1.0 // percentage of cameraZoomFactor to the current grid zoom threshold (0.0 - 1.0)
|
|
||||||
|
|
||||||
camera: usePerspective ? scenePerspectiveCamera : sceneOrthoCamera
|
|
||||||
|
|
||||||
onCameraZoomFactorChanged: {
|
|
||||||
thresIdx = Math.max(1, grid_thresholds.findIndex(v => v > cameraZoomFactor));
|
|
||||||
thresPerc = (grid_thresholds[thresIdx] - cameraZoomFactor) / (grid_thresholds[thresIdx] - grid_thresholds[thresIdx - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: sceneHelpers
|
|
||||||
|
|
||||||
HelperGrid {
|
|
||||||
id: helperGrid
|
|
||||||
lines: Math.pow(2, grid_thresholds.length - thresIdx - 1);
|
|
||||||
step: 100 * grid_thresholds[0] * Math.pow(2, thresIdx - 1);
|
|
||||||
subdivAlpha: thresPerc;
|
|
||||||
}
|
|
||||||
|
|
||||||
PointLight {
|
|
||||||
id: sceneLight
|
|
||||||
position: usePerspective ? scenePerspectiveCamera.position
|
|
||||||
: sceneOrthoCamera.position
|
|
||||||
quadraticFade: 0
|
|
||||||
linearFade: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial camera position and rotation should be such that they look at origin.
|
|
||||||
// Otherwise EditCameraController._lookAtPoint needs to be initialized to correct
|
|
||||||
// point.
|
|
||||||
PerspectiveCamera {
|
|
||||||
id: scenePerspectiveCamera
|
|
||||||
z: 600
|
|
||||||
y: 600
|
|
||||||
eulerRotation.x: -45
|
|
||||||
clipFar: 100000
|
|
||||||
clipNear: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
OrthographicCamera {
|
|
||||||
id: sceneOrthoCamera
|
|
||||||
z: 600
|
|
||||||
y: 600
|
|
||||||
eulerRotation.x: -45
|
|
||||||
clipFar: 100000
|
|
||||||
clipNear: -10000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,46 +0,0 @@
|
|||||||
// Copyright (C) 2019 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import SelectionBoxGeometry 1.0
|
|
||||||
|
|
||||||
Node {
|
|
||||||
id: selectionBox
|
|
||||||
|
|
||||||
property View3D view3D
|
|
||||||
property Node targetNode: null
|
|
||||||
property alias model: selectionBoxModel
|
|
||||||
property alias geometryName: selectionBoxGeometry.name
|
|
||||||
|
|
||||||
SelectionBoxGeometry {
|
|
||||||
id: selectionBoxGeometry
|
|
||||||
name: "Selection Box of 3D Edit View"
|
|
||||||
view3D: selectionBox.view3D
|
|
||||||
targetNode: selectionBox.targetNode
|
|
||||||
rootNode: selectionBox
|
|
||||||
}
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: selectionBoxModel
|
|
||||||
geometry: selectionBoxGeometry
|
|
||||||
|
|
||||||
scale: selectionBox.targetNode ? selectionBox.targetNode.scale : Qt.vector3d(1, 1, 1)
|
|
||||||
rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.quaternion(1, 0, 0, 0)
|
|
||||||
position: selectionBox.targetNode ? selectionBox.targetNode.position : Qt.vector3d(0, 0, 0)
|
|
||||||
pivot: selectionBox.targetNode ? selectionBox.targetNode.pivot : Qt.vector3d(0, 0, 0)
|
|
||||||
|
|
||||||
visible: selectionBox.targetNode && !selectionBoxGeometry.isEmpty
|
|
||||||
|
|
||||||
castsShadows: false
|
|
||||||
receivesShadows: false
|
|
||||||
|
|
||||||
materials: [
|
|
||||||
DefaultMaterial {
|
|
||||||
diffuseColor: "#fff600"
|
|
||||||
lighting: DefaultMaterial.NoLighting
|
|
||||||
cullMode: Material.NoCulling
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: handleRoot
|
|
||||||
|
|
||||||
property string currentLabel
|
|
||||||
property point currentMousePos
|
|
||||||
property string propName
|
|
||||||
property real propValue: 0
|
|
||||||
property real newValue: 0
|
|
||||||
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
|
||||||
length: 3
|
|
||||||
offset: -1.5
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: handle
|
|
||||||
source: "#Sphere"
|
|
||||||
materials: [ handleRoot.material ]
|
|
||||||
scale: Qt.vector3d(0.02, 0.02, 0.02)
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScaler
|
|
||||||
active: handleRoot.active
|
|
||||||
view3D: handleRoot.view3D
|
|
||||||
}
|
|
||||||
|
|
||||||
property real _startAngle
|
|
||||||
|
|
||||||
signal valueCommit()
|
|
||||||
signal valueChange()
|
|
||||||
|
|
||||||
function updateAngle(relativeDistance, screenPos)
|
|
||||||
{
|
|
||||||
handleRoot.newValue = Math.round(Math.min(180, Math.max(0, _startAngle + relativeDistance)));
|
|
||||||
var l = Qt.locale();
|
|
||||||
handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0);
|
|
||||||
handleRoot.currentMousePos = screenPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouseArea, screenPos)=> {
|
|
||||||
_startAngle = propValue;
|
|
||||||
updateAngle(0, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateAngle(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateAngle(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
import QtQuick 6.0
|
|
||||||
import QtQuick3D 6.0
|
|
||||||
|
|
||||||
DirectionalDraggable {
|
|
||||||
id: handleRoot
|
|
||||||
|
|
||||||
property string currentLabel
|
|
||||||
property point currentMousePos
|
|
||||||
property string propName
|
|
||||||
property real propValue: 0
|
|
||||||
property real newValue: 0
|
|
||||||
property real baseScale: 5
|
|
||||||
|
|
||||||
scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale))
|
|
||||||
length: 3
|
|
||||||
offset: -1.5
|
|
||||||
|
|
||||||
Model {
|
|
||||||
id: handle
|
|
||||||
readonly property bool _edit3dLocked: true // Make this non-pickable
|
|
||||||
source: "#Sphere"
|
|
||||||
materials: [ handleRoot.material ]
|
|
||||||
scale: Qt.vector3d(0.02, 0.02, 0.02)
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScaleHelper {
|
|
||||||
id: autoScaler
|
|
||||||
active: handleRoot.active
|
|
||||||
view3D: handleRoot.view3D
|
|
||||||
}
|
|
||||||
|
|
||||||
property real _startValue
|
|
||||||
property real _startScale
|
|
||||||
|
|
||||||
signal valueCommit()
|
|
||||||
signal valueChange()
|
|
||||||
|
|
||||||
function updateValue(relativeDistance, screenPos)
|
|
||||||
{
|
|
||||||
handleRoot.newValue = Math.round(Math.min(999999, Math.max(0, _startValue + (relativeDistance * _startScale))));
|
|
||||||
var l = Qt.locale();
|
|
||||||
handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0);
|
|
||||||
handleRoot.currentMousePos = screenPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: (mouseArea, screenPos)=> {
|
|
||||||
_startScale = autoScaler.relativeScale * baseScale;
|
|
||||||
_startValue = propValue;
|
|
||||||
updateValue(0, screenPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateValue(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> {
|
|
||||||
updateValue(relativeDistance, screenPos);
|
|
||||||
handleRoot.valueCommit();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -36,20 +36,15 @@ Node {
|
|||||||
|| spotLightHandle.dragging
|
|| spotLightHandle.dragging
|
||||||
|| spotLightInnerHandle.dragging
|
|| spotLightInnerHandle.dragging
|
||||||
|| spotLightFadeHandle.dragging
|
|| spotLightFadeHandle.dragging
|
||||||
|| areaHeightHandle.dragging
|
|
||||||
|| areaWidthHandle.dragging
|
|
||||||
|| pointLightFadeHandle.dragging
|
|| pointLightFadeHandle.dragging
|
||||||
property point currentMousePos
|
property point currentMousePos
|
||||||
property string currentLabel
|
property string currentLabel
|
||||||
property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2;
|
|
||||||
property real brightnessMultiplier: Math.pow(10, brightnessDecimals);
|
|
||||||
|
|
||||||
signal propertyValueCommit(string propName)
|
signal propertyValueCommit(string propName)
|
||||||
signal propertyValueChange(string propName)
|
signal propertyValueChange(string propName)
|
||||||
|
|
||||||
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
||||||
visible: lightGizmo.targetNode instanceof SpotLight
|
visible: lightGizmo.targetNode instanceof SpotLight
|
||||||
|| lightGizmo.targetNode instanceof AreaLight
|
|
||||||
|| lightGizmo.targetNode instanceof DirectionalLight
|
|| lightGizmo.targetNode instanceof DirectionalLight
|
||||||
|| lightGizmo.targetNode instanceof PointLight
|
|| lightGizmo.targetNode instanceof PointLight
|
||||||
|
|
||||||
@@ -213,65 +208,6 @@ Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node {
|
|
||||||
id: areaParts
|
|
||||||
visible: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
|
|
||||||
LightModel {
|
|
||||||
id: areaModel
|
|
||||||
geometryName: "Edit 3D AreaLight"
|
|
||||||
geometryType: LightGeometry.Area
|
|
||||||
material: lightMaterial
|
|
||||||
scale: areaParts.visible ? Qt.vector3d(lightGizmo.targetNode.width / 2,
|
|
||||||
lightGizmo.targetNode.height / 2, 1)
|
|
||||||
.times(lightGizmo.targetNode.scale)
|
|
||||||
: Qt.vector3d(1, 1, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
AreaLightHandle {
|
|
||||||
id: areaWidthHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(-areaModel.scale.x, 0, 0)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 90)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "width"
|
|
||||||
propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.width : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.width = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
|
||||||
}
|
|
||||||
|
|
||||||
AreaLightHandle {
|
|
||||||
id: areaHeightHandle
|
|
||||||
view3D: lightGizmo.view3D
|
|
||||||
color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color
|
|
||||||
position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(0, -areaModel.scale.y, 0)
|
|
||||||
: Qt.vector3d(0, 0, 0)
|
|
||||||
eulerRotation: Qt.vector3d(0, 0, 180)
|
|
||||||
targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null
|
|
||||||
active: lightGizmo.targetNode instanceof AreaLight
|
|
||||||
dragHelper: lightGizmo.dragHelper
|
|
||||||
propName: "height"
|
|
||||||
propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.height : 0
|
|
||||||
|
|
||||||
onNewValueChanged: targetNode.height = newValue
|
|
||||||
onCurrentMousePosChanged: {
|
|
||||||
lightGizmo.currentMousePos = currentMousePos;
|
|
||||||
lightGizmo.currentLabel = currentLabel;
|
|
||||||
}
|
|
||||||
onValueChange: lightGizmo.propertyValueChange(propName)
|
|
||||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LightModel {
|
LightModel {
|
||||||
id: directionalModel
|
id: directionalModel
|
||||||
@@ -291,19 +227,19 @@ Node {
|
|||||||
active: lightGizmo.visible
|
active: lightGizmo.visible
|
||||||
dragHelper: lightGizmo.dragHelper
|
dragHelper: lightGizmo.dragHelper
|
||||||
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
||||||
length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10
|
length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness * 10.0) + 3 : 10
|
||||||
|
|
||||||
property real _startBrightness
|
property real _startBrightness
|
||||||
|
|
||||||
function updateBrightness(relativeDistance, screenPos)
|
function updateBrightness(relativeDistance, screenPos)
|
||||||
{
|
{
|
||||||
var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0));
|
var currentValue = Math.max(0, (_startBrightness + relativeDistance / 10.0));
|
||||||
currentValue *= brightnessMultiplier;
|
currentValue *= 100;
|
||||||
currentValue = Math.round(currentValue);
|
currentValue = Math.round(currentValue);
|
||||||
currentValue /= brightnessMultiplier;
|
currentValue /= 100;
|
||||||
|
|
||||||
var l = Qt.locale();
|
var l = Qt.locale();
|
||||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals);
|
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', 2);
|
||||||
lightGizmo.currentMousePos = screenPos;
|
lightGizmo.currentMousePos = screenPos;
|
||||||
targetNode.brightness = currentValue;
|
targetNode.brightness = currentValue;
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,6 @@ IconGizmo {
|
|||||||
iconSource: targetNode
|
iconSource: targetNode
|
||||||
? targetNode instanceof DirectionalLight
|
? targetNode instanceof DirectionalLight
|
||||||
? "image://IconGizmoImageProvider/directional.png:" + overlayColor
|
? "image://IconGizmoImageProvider/directional.png:" + overlayColor
|
||||||
: targetNode instanceof AreaLight
|
|
||||||
? "image://IconGizmoImageProvider/area.png:" + overlayColor
|
|
||||||
: targetNode instanceof PointLight
|
: targetNode instanceof PointLight
|
||||||
? "image://IconGizmoImageProvider/point.png:" + overlayColor
|
? "image://IconGizmoImageProvider/point.png:" + overlayColor
|
||||||
: "image://IconGizmoImageProvider/spot.png:" + overlayColor
|
: "image://IconGizmoImageProvider/spot.png:" + overlayColor
|
||||||
|
@@ -120,16 +120,6 @@ void CameraGeometry::doUpdateGeometry()
|
|||||||
if (!QQuick3DObjectPrivate::get(m_camera)->spatialNode) {
|
if (!QQuick3DObjectPrivate::get(m_camera)->spatialNode) {
|
||||||
// Doing explicit viewport mapping forces cameraNode creation
|
// Doing explicit viewport mapping forces cameraNode creation
|
||||||
m_camera->mapToViewport({}, m_viewPortRect.width(), m_viewPortRect.height());
|
m_camera->mapToViewport({}, m_viewPortRect.width(), m_viewPortRect.height());
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!m_nodeCreationUpdateDone) {
|
|
||||||
// Post-node creation update is done only once to avoid infinite loop in case the node
|
|
||||||
// creation fails.
|
|
||||||
m_nodeCreationUpdateDone = true;
|
|
||||||
m_cameraUpdatePending = true;
|
|
||||||
update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryBase::doUpdateGeometry();
|
GeometryBase::doUpdateGeometry();
|
||||||
|
@@ -45,9 +45,6 @@ private:
|
|||||||
QQuick3DCamera *m_camera = nullptr;
|
QQuick3DCamera *m_camera = nullptr;
|
||||||
QRectF m_viewPortRect;
|
QRectF m_viewPortRect;
|
||||||
bool m_cameraUpdatePending = false;
|
bool m_cameraUpdatePending = false;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
bool m_nodeCreationUpdateDone = false;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,3 @@ SOURCES += $$PWD/generalhelper.cpp \
|
|||||||
$$PWD/selectionboxgeometry.cpp \
|
$$PWD/selectionboxgeometry.cpp \
|
||||||
$$PWD/linegeometry.cpp \
|
$$PWD/linegeometry.cpp \
|
||||||
$$PWD/icongizmoimageprovider.cpp
|
$$PWD/icongizmoimageprovider.cpp
|
||||||
|
|
||||||
versionAtLeast(QT_VERSION, 6.0.0) {
|
|
||||||
HEADERS += $$PWD/qt5compat/qquick3darealight_p.h
|
|
||||||
SOURCES += $$PWD/qt5compat/qquick3darealight.cpp
|
|
||||||
}
|
|
||||||
|
@@ -218,11 +218,7 @@ QVector4D GeneralHelper::focusNodesToCamera(QQuick3DCamera *camera, float defaul
|
|||||||
if (window) {
|
if (window) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
||||||
QSSGRef<QSSGRenderContextInterface> context;
|
QSSGRef<QSSGRenderContextInterface> context;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
|
||||||
#else
|
|
||||||
context = targetPriv->sceneManager->rci;
|
context = targetPriv->sceneManager->rci;
|
||||||
#endif
|
|
||||||
if (!context.isNull()) {
|
if (!context.isNull()) {
|
||||||
#else
|
#else
|
||||||
const auto &sm = targetPriv->sceneManager;
|
const auto &sm = targetPriv->sceneManager;
|
||||||
@@ -235,11 +231,7 @@ QVector4D GeneralHelper::focusNodesToCamera(QQuick3DCamera *camera, float defaul
|
|||||||
bounds = geometry->bounds();
|
bounds = geometry->bounds();
|
||||||
} else {
|
} else {
|
||||||
const auto &bufferManager(context->bufferManager());
|
const auto &bufferManager(context->bufferManager());
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
|
|
||||||
bounds = renderModel->getModelBounds(bufferManager);
|
|
||||||
#else
|
|
||||||
bounds = bufferManager->getModelBounds(renderModel);
|
bounds = bufferManager->getModelBounds(renderModel);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
center = renderModel->globalTransform.map(bounds.center());
|
center = renderModel->globalTransform.map(bounds.center());
|
||||||
@@ -430,7 +422,6 @@ QQuick3DPickResult GeneralHelper::pickViewAt(QQuick3DViewport *view, float posX,
|
|||||||
if (!view)
|
if (!view)
|
||||||
return QQuick3DPickResult();
|
return QQuick3DPickResult();
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
// Make sure global picking is on
|
// Make sure global picking is on
|
||||||
view->setGlobalPickingEnabled(true);
|
view->setGlobalPickingEnabled(true);
|
||||||
|
|
||||||
@@ -440,12 +431,6 @@ QQuick3DPickResult GeneralHelper::pickViewAt(QQuick3DViewport *view, float posX,
|
|||||||
if (isPickable(pickResult.objectHit()))
|
if (isPickable(pickResult.objectHit()))
|
||||||
return pickResult;
|
return pickResult;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
// With older Qt version we'll just pick the single object
|
|
||||||
auto pickResult = view->pick(posX, posY);
|
|
||||||
if (isPickable(pickResult.objectHit()))
|
|
||||||
return pickResult;
|
|
||||||
#endif
|
|
||||||
return QQuick3DPickResult();
|
return QQuick3DPickResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,13 +471,11 @@ bool GeneralHelper::isPickable(QQuick3DNode *node) const
|
|||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
|
||||||
// Instancing doesn't hide child nodes, so only check for instancing on the requested node
|
// Instancing doesn't hide child nodes, so only check for instancing on the requested node
|
||||||
if (auto model = qobject_cast<QQuick3DModel *>(node)) {
|
if (auto model = qobject_cast<QQuick3DModel *>(node)) {
|
||||||
if (model->instancing())
|
if (model->instancing())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QQuick3DNode *n = node;
|
QQuick3DNode *n = node;
|
||||||
while (n) {
|
while (n) {
|
||||||
@@ -607,16 +590,6 @@ QString GeneralHelper::rootSizeKey() const
|
|||||||
return _rootSizeKey;
|
return _rootSizeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
double GeneralHelper::brightnessScaler() const
|
|
||||||
{
|
|
||||||
// Light brightness was rescaled in Qt6 from 100 -> 1.
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
return 100.;
|
|
||||||
#else
|
|
||||||
return 1.;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralHelper::setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode,
|
void GeneralHelper::setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode,
|
||||||
const QVariantList &selectedList)
|
const QVariantList &selectedList)
|
||||||
{
|
{
|
||||||
@@ -1042,15 +1015,10 @@ bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVec
|
|||||||
auto renderNode = static_cast<QSSGRenderNode *>(nodePriv->spatialNode);
|
auto renderNode = static_cast<QSSGRenderNode *>(nodePriv->spatialNode);
|
||||||
|
|
||||||
if (renderNode) {
|
if (renderNode) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
|
||||||
if (renderNode->flags.testFlag(QSSGRenderNode::Flag::TransformDirty))
|
|
||||||
renderNode->calculateLocalTransform();
|
|
||||||
#else
|
|
||||||
if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) {
|
if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) {
|
||||||
renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix(
|
renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix(
|
||||||
node->position(), node->scale(), node->pivot(), node->rotation());
|
node->position(), node->scale(), node->pivot(), node->rotation());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
localTransform = renderNode->localTransform;
|
localTransform = renderNode->localTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,11 +1085,7 @@ bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVec
|
|||||||
if (window) {
|
if (window) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
||||||
QSSGRef<QSSGRenderContextInterface> context;
|
QSSGRef<QSSGRenderContextInterface> context;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
|
||||||
#else
|
|
||||||
context = QQuick3DObjectPrivate::get(node)->sceneManager->rci;
|
context = QQuick3DObjectPrivate::get(node)->sceneManager->rci;
|
||||||
#endif
|
|
||||||
if (!context.isNull()) {
|
if (!context.isNull()) {
|
||||||
#else
|
#else
|
||||||
const auto &sm = QQuick3DObjectPrivate::get(node)->sceneManager;
|
const auto &sm = QQuick3DObjectPrivate::get(node)->sceneManager;
|
||||||
@@ -1129,11 +1093,7 @@ bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVec
|
|||||||
if (context) {
|
if (context) {
|
||||||
#endif
|
#endif
|
||||||
const auto &bufferManager(context->bufferManager());
|
const auto &bufferManager(context->bufferManager());
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
|
|
||||||
QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager);
|
|
||||||
#else
|
|
||||||
QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel);
|
QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel);
|
||||||
#endif
|
|
||||||
QVector3D center = bounds.center();
|
QVector3D center = bounds.center();
|
||||||
QVector3D extents = bounds.extents();
|
QVector3D extents = bounds.extents();
|
||||||
QVector3D localMin = center - extents;
|
QVector3D localMin = center - extents;
|
||||||
|
@@ -82,8 +82,6 @@ public:
|
|||||||
QString lastSceneIdKey() const;
|
QString lastSceneIdKey() const;
|
||||||
QString rootSizeKey() const;
|
QString rootSizeKey() const;
|
||||||
|
|
||||||
Q_INVOKABLE double brightnessScaler() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode,
|
Q_INVOKABLE void setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode,
|
||||||
const QVariantList &selectedList);
|
const QVariantList &selectedList);
|
||||||
Q_INVOKABLE void resetMultiSelectionNode();
|
Q_INVOKABLE void resetMultiSelectionNode();
|
||||||
|
@@ -35,7 +35,6 @@ void GeometryBase::doUpdateGeometry()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QString GeometryBase::name() const
|
QString GeometryBase::name() const
|
||||||
{
|
{
|
||||||
return objectName();
|
return objectName();
|
||||||
@@ -46,7 +45,6 @@ void GeometryBase::setName(const QString &name)
|
|||||||
setObjectName(name);
|
setObjectName(name);
|
||||||
emit nameChanged();
|
emit nameChanged();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GeometryBase::updateGeometry()
|
void GeometryBase::updateGeometry()
|
||||||
{
|
{
|
||||||
|
@@ -16,7 +16,6 @@ class GeometryBase : public QQuick3DGeometry
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||||
// Name maps to object name.
|
// Name maps to object name.
|
||||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||||
@@ -25,7 +24,6 @@ public:
|
|||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GeometryBase();
|
GeometryBase();
|
||||||
|
@@ -892,10 +892,6 @@ bool MouseArea3D::eventFilter(QObject *, QEvent *event)
|
|||||||
// a problem
|
// a problem
|
||||||
onCircle = false;
|
onCircle = false;
|
||||||
if (m_pickNode) {
|
if (m_pickNode) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
QQuick3DPickResult pr = m_view3D->pick(float(mousePos.x()), float(mousePos.y()));
|
|
||||||
pickSuccess = pr.objectHit() == m_pickNode;
|
|
||||||
#else
|
|
||||||
// With the introduction of global picking API,
|
// With the introduction of global picking API,
|
||||||
// we need to pick all as various other geometries can often be the first
|
// we need to pick all as various other geometries can often be the first
|
||||||
// pick result, such as camera frustum or light geometry
|
// pick result, such as camera frustum or light geometry
|
||||||
@@ -907,7 +903,6 @@ bool MouseArea3D::eventFilter(QObject *, QEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
|
|
||||||
#include "qquick3darealight_p.h"
|
|
||||||
#include <QtQuick3D/private/qquick3dobject_p.h>
|
|
||||||
|
|
||||||
#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner::Internal {
|
|
||||||
|
|
||||||
float QQuick3DAreaLight::width() const
|
|
||||||
{
|
|
||||||
return m_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
float QQuick3DAreaLight::height() const
|
|
||||||
{
|
|
||||||
return m_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQuick3DAreaLight::setWidth(float width)
|
|
||||||
{
|
|
||||||
m_width = width;
|
|
||||||
emit widthChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQuick3DAreaLight::setHeight(float height)
|
|
||||||
{
|
|
||||||
m_height = height;
|
|
||||||
emit heightChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,43 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
|
|
||||||
// This is a dummy class for Qt 5 compatibility purposes only
|
|
||||||
|
|
||||||
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner::Internal {
|
|
||||||
|
|
||||||
class QQuick3DAreaLight : public QQuick3DAbstractLight
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged)
|
|
||||||
Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
~QQuick3DAreaLight() override {}
|
|
||||||
|
|
||||||
float width() const;
|
|
||||||
float height() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setWidth(float width);
|
|
||||||
void setHeight(float height);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void widthChanged();
|
|
||||||
void heightChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
float m_width = 100.0f;
|
|
||||||
float m_height = 100.0f;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight)
|
|
||||||
|
|
||||||
#endif
|
|
@@ -195,11 +195,7 @@ void SelectionBoxGeometry::doUpdateGeometry()
|
|||||||
m = targetRN->parent->globalTransform;
|
m = targetRN->parent->globalTransform;
|
||||||
}
|
}
|
||||||
rootRN->localTransform = m;
|
rootRN->localTransform = m;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
|
||||||
rootRN->markDirty(QSSGRenderNode::TransformDirtyFlag::TransformNotDirty);
|
|
||||||
#else
|
|
||||||
rootRN->markDirty(QSSGRenderNode::DirtyFlag::TransformDirty);
|
rootRN->markDirty(QSSGRenderNode::DirtyFlag::TransformDirty);
|
||||||
#endif
|
|
||||||
rootRN->calculateGlobalVariables();
|
rootRN->calculateGlobalVariables();
|
||||||
} else if (!m_spatialNodeUpdatePending) {
|
} else if (!m_spatialNodeUpdatePending) {
|
||||||
// Necessary spatial nodes do not yet exist. Defer selection box creation one frame.
|
// Necessary spatial nodes do not yet exist. Defer selection box creation one frame.
|
||||||
@@ -243,15 +239,10 @@ void SelectionBoxGeometry::getBounds(
|
|||||||
|
|
||||||
if (node != m_targetNode) {
|
if (node != m_targetNode) {
|
||||||
if (renderNode) {
|
if (renderNode) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
|
||||||
if (renderNode->flags.testFlag(QSSGRenderNode::Flag::TransformDirty))
|
|
||||||
renderNode->calculateLocalTransform();
|
|
||||||
#else
|
|
||||||
if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) {
|
if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) {
|
||||||
renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix(
|
renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix(
|
||||||
node->position(), node->scale(), node->pivot(), node->rotation());
|
node->position(), node->scale(), node->pivot(), node->rotation());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
localTransform = renderNode->localTransform;
|
localTransform = renderNode->localTransform;
|
||||||
}
|
}
|
||||||
trackNodeChanges(node);
|
trackNodeChanges(node);
|
||||||
@@ -314,11 +305,7 @@ void SelectionBoxGeometry::getBounds(
|
|||||||
if (window) {
|
if (window) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
||||||
QSSGRef<QSSGRenderContextInterface> context;
|
QSSGRef<QSSGRenderContextInterface> context;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
|
||||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
|
|
||||||
context = QQuick3DObjectPrivate::get(this)->sceneManager->rci;
|
context = QQuick3DObjectPrivate::get(this)->sceneManager->rci;
|
||||||
#endif
|
|
||||||
if (!context.isNull()) {
|
if (!context.isNull()) {
|
||||||
#else
|
#else
|
||||||
const auto &sm = QQuick3DObjectPrivate::get(this)->sceneManager;
|
const auto &sm = QQuick3DObjectPrivate::get(this)->sceneManager;
|
||||||
@@ -326,11 +313,7 @@ void SelectionBoxGeometry::getBounds(
|
|||||||
if (context) {
|
if (context) {
|
||||||
#endif
|
#endif
|
||||||
const auto &bufferManager(context->bufferManager());
|
const auto &bufferManager(context->bufferManager());
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
|
|
||||||
QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager);
|
|
||||||
#else
|
|
||||||
QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel);
|
QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel);
|
||||||
#endif
|
|
||||||
QVector3D center = bounds.center();
|
QVector3D center = bounds.center();
|
||||||
QVector3D extents = bounds.extents();
|
QVector3D extents = bounds.extents();
|
||||||
QVector3D localMin = center - extents;
|
QVector3D localMin = center - extents;
|
||||||
|
@@ -1,297 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "iconrenderer.h"
|
|
||||||
|
|
||||||
#include "../editor3d/selectionboxgeometry.h"
|
|
||||||
#include "../editor3d/generalhelper.h"
|
|
||||||
|
|
||||||
#include <private/qquickdesignersupport_p.h>
|
|
||||||
#include <QtQml/qqmlcomponent.h>
|
|
||||||
#include <QtQml/qqmlengine.h>
|
|
||||||
#include <QtQml/qqmlproperty.h>
|
|
||||||
#include <QtQml/qqmlcontext.h>
|
|
||||||
#include <QtQuick/qquickview.h>
|
|
||||||
#include <QtQuick/qquickitem.h>
|
|
||||||
#include <QtGui/qsurfaceformat.h>
|
|
||||||
#include <QtGui/qimage.h>
|
|
||||||
#include <QtGui/qguiapplication.h>
|
|
||||||
#include <QtCore/qtimer.h>
|
|
||||||
#include <QtCore/qfileinfo.h>
|
|
||||||
#include <QtCore/qdir.h>
|
|
||||||
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
#include <QtQuick3D/private/qquick3dnode_p.h>
|
|
||||||
#include <QtQuick3D/private/qquick3dviewport_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
#include <QtGui/private/qrhi_p.h>
|
|
||||||
#include <QtQuick/private/qquickrendercontrol_p.h>
|
|
||||||
#include <QtQuick/private/qquickrendertarget_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <private/qquickdesignersupportitems_p.h>
|
|
||||||
|
|
||||||
IconRenderer::IconRenderer(int size, const QString &filePath, const QString &source)
|
|
||||||
: QObject(nullptr)
|
|
||||||
, m_size(size)
|
|
||||||
, m_filePath(filePath)
|
|
||||||
, m_source(source)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IconRenderer::~IconRenderer() = default;
|
|
||||||
|
|
||||||
void IconRenderer::setupRender()
|
|
||||||
{
|
|
||||||
QQuickDesignerSupport::activateDesignerMode();
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
DesignerSupport::activateDesignerWindowManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QQmlEngine *engine = nullptr;
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
auto view = new QQuickView;
|
|
||||||
engine = view->engine();
|
|
||||||
m_window = view;
|
|
||||||
QSurfaceFormat surfaceFormat = view->requestedFormat();
|
|
||||||
surfaceFormat.setVersion(4, 1);
|
|
||||||
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
|
|
||||||
view->setFormat(surfaceFormat);
|
|
||||||
DesignerSupport::createOpenGLContext(view);
|
|
||||||
#else
|
|
||||||
engine = new QQmlEngine;
|
|
||||||
m_renderControl = new QQuickRenderControl;
|
|
||||||
m_window = new QQuickWindow(m_renderControl);
|
|
||||||
m_window->setDefaultAlphaBuffer(true);
|
|
||||||
m_window->setColor(Qt::transparent);
|
|
||||||
m_renderControl->initialize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QQmlComponent component(engine);
|
|
||||||
component.loadUrl(QUrl::fromLocalFile(m_source));
|
|
||||||
QObject *iconItem = component.create();
|
|
||||||
|
|
||||||
if (iconItem) {
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
if (auto scene = qobject_cast<QQuick3DNode *>(iconItem)) {
|
|
||||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
|
||||||
QQmlComponent component(engine);
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/qt5/IconRenderer3D.qml"));
|
|
||||||
m_containerItem = qobject_cast<QQuickItem *>(component.create());
|
|
||||||
DesignerSupport::setRootItem(view, m_containerItem);
|
|
||||||
#else
|
|
||||||
component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/qt6/IconRenderer3D.qml"));
|
|
||||||
m_containerItem = qobject_cast<QQuickItem *>(component.create());
|
|
||||||
m_window->contentItem()->setSize(m_containerItem->size());
|
|
||||||
m_window->setGeometry(0, 0, m_containerItem->width(), m_containerItem->height());
|
|
||||||
m_containerItem->setParentItem(m_window->contentItem());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
|
||||||
engine->rootContext()->setContextProperty("_generalHelper", helper);
|
|
||||||
|
|
||||||
m_contentItem = QQmlProperty::read(m_containerItem, "view3D").value<QQuickItem *>();
|
|
||||||
auto view3D = qobject_cast<QQuick3DViewport *>(m_contentItem);
|
|
||||||
view3D->setImportScene(scene);
|
|
||||||
m_is3D = true;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
if (auto scene = qobject_cast<QQuickItem *>(iconItem)) {
|
|
||||||
m_contentItem = scene;
|
|
||||||
m_containerItem = new QQuickItem();
|
|
||||||
m_containerItem->setSize(QSizeF(1024, 1024));
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
DesignerSupport::setRootItem(view, m_containerItem);
|
|
||||||
#else
|
|
||||||
m_window->contentItem()->setSize(m_containerItem->size());
|
|
||||||
m_window->setGeometry(0, 0, m_containerItem->width(), m_containerItem->height());
|
|
||||||
m_containerItem->setParentItem(m_window->contentItem());
|
|
||||||
#endif
|
|
||||||
m_contentItem->setParentItem(m_containerItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_containerItem && m_contentItem) {
|
|
||||||
resizeContent(m_size);
|
|
||||||
if (!initRhi())
|
|
||||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
|
||||||
QTimer::singleShot(0, this, &IconRenderer::startCreateIcon);
|
|
||||||
} else {
|
|
||||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconRenderer::startCreateIcon()
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
m_designerSupport->refFromEffectItem(m_containerItem, false);
|
|
||||||
#endif
|
|
||||||
QQuickDesignerSupportItems::disableNativeTextRendering(m_containerItem);
|
|
||||||
|
|
||||||
if (m_is3D)
|
|
||||||
QTimer::singleShot(0, this, &IconRenderer::focusCamera);
|
|
||||||
else
|
|
||||||
QTimer::singleShot(0, this, &IconRenderer::finishCreateIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconRenderer::focusCamera()
|
|
||||||
{
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
if (m_focusStep >= 10) {
|
|
||||||
QTimer::singleShot(0, this, &IconRenderer::finishCreateIcon);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
render({});
|
|
||||||
|
|
||||||
if (m_focusStep == 0) {
|
|
||||||
QMetaObject::invokeMethod(m_containerItem, "setSceneToBox");
|
|
||||||
} else if (m_focusStep > 1 && m_focusStep < 10) {
|
|
||||||
QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox");
|
|
||||||
}
|
|
||||||
++m_focusStep;
|
|
||||||
QTimer::singleShot(0, this, &IconRenderer::focusCamera);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconRenderer::finishCreateIcon()
|
|
||||||
{
|
|
||||||
QFileInfo fi(m_filePath);
|
|
||||||
|
|
||||||
// Render regular size image
|
|
||||||
render(fi.absoluteFilePath());
|
|
||||||
|
|
||||||
// Render @2x image
|
|
||||||
resizeContent(m_size * 2);
|
|
||||||
if (!initRhi())
|
|
||||||
QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit);
|
|
||||||
|
|
||||||
QString saveFile;
|
|
||||||
saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x";
|
|
||||||
if (!fi.suffix().isEmpty())
|
|
||||||
saveFile += '.' + fi.suffix();
|
|
||||||
|
|
||||||
fi.absoluteDir().mkpath(".");
|
|
||||||
|
|
||||||
render(saveFile);
|
|
||||||
|
|
||||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconRenderer::render(const QString &fileName)
|
|
||||||
{
|
|
||||||
std::function<void (QQuickItem *)> updateNodesRecursive;
|
|
||||||
updateNodesRecursive = [&updateNodesRecursive](QQuickItem *item) {
|
|
||||||
const auto childItems = item->childItems();
|
|
||||||
for (QQuickItem *childItem : childItems)
|
|
||||||
updateNodesRecursive(childItem);
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
DesignerSupport::updateDirtyNode(item);
|
|
||||||
#else
|
|
||||||
if (item->flags() & QQuickItem::ItemHasContents)
|
|
||||||
item->update();
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
updateNodesRecursive(m_containerItem);
|
|
||||||
|
|
||||||
QRect rect(QPoint(), m_contentItem->size().toSize());
|
|
||||||
QImage renderImage;
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
renderImage = m_designerSupport->renderImageForItem(m_containerItem, rect, rect.size());
|
|
||||||
#else
|
|
||||||
m_renderControl->polishItems();
|
|
||||||
m_renderControl->beginFrame();
|
|
||||||
m_renderControl->sync();
|
|
||||||
m_renderControl->render();
|
|
||||||
|
|
||||||
bool readCompleted = false;
|
|
||||||
QRhiReadbackResult readResult;
|
|
||||||
readResult.completed = [&] {
|
|
||||||
readCompleted = true;
|
|
||||||
QImage wrapperImage(reinterpret_cast<const uchar *>(readResult.data.constData()),
|
|
||||||
readResult.pixelSize.width(), readResult.pixelSize.height(),
|
|
||||||
QImage::Format_RGBA8888_Premultiplied);
|
|
||||||
if (m_rhi->isYUpInFramebuffer())
|
|
||||||
renderImage = wrapperImage.mirrored().copy(0, 0, rect.width(), rect.height());
|
|
||||||
else
|
|
||||||
renderImage = wrapperImage.copy(0, 0, rect.width(), rect.height());
|
|
||||||
};
|
|
||||||
QRhiResourceUpdateBatch *readbackBatch = m_rhi->nextResourceUpdateBatch();
|
|
||||||
readbackBatch->readBackTexture(m_texture, &readResult);
|
|
||||||
|
|
||||||
QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(m_renderControl);
|
|
||||||
rd->cb->resourceUpdate(readbackBatch);
|
|
||||||
|
|
||||||
m_renderControl->endFrame();
|
|
||||||
#endif
|
|
||||||
if (!fileName.isEmpty()) {
|
|
||||||
QFileInfo fi(fileName);
|
|
||||||
if (fi.suffix().isEmpty())
|
|
||||||
renderImage.save(fileName, "PNG");
|
|
||||||
else
|
|
||||||
renderImage.save(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconRenderer::resizeContent(int dimensions)
|
|
||||||
{
|
|
||||||
QSizeF size(dimensions, dimensions);
|
|
||||||
m_contentItem->setSize(size);
|
|
||||||
if (m_contentItem->width() > m_containerItem->width())
|
|
||||||
m_containerItem->setWidth(m_contentItem->width());
|
|
||||||
if (m_contentItem->height() > m_containerItem->height())
|
|
||||||
m_containerItem->setHeight(m_contentItem->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IconRenderer::initRhi()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!m_rhi) {
|
|
||||||
QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(m_renderControl);
|
|
||||||
m_rhi = rd->rhi;
|
|
||||||
if (!m_rhi) {
|
|
||||||
qWarning() << __FUNCTION__ << "Rhi is null";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't bother deleting old ones as iconrender is a single shot executable
|
|
||||||
m_texTarget = nullptr;
|
|
||||||
m_rpDesc = nullptr;
|
|
||||||
m_buffer = nullptr;
|
|
||||||
m_texture = nullptr;
|
|
||||||
|
|
||||||
const QSize size = m_containerItem->size().toSize();
|
|
||||||
m_texture = m_rhi->newTexture(QRhiTexture::RGBA8, size, 1,
|
|
||||||
QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource);
|
|
||||||
if (!m_texture->create()) {
|
|
||||||
qWarning() << __FUNCTION__ << "QRhiTexture creation failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_buffer = m_rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, size, 1);
|
|
||||||
if (!m_buffer->create()) {
|
|
||||||
qWarning() << __FUNCTION__ << "Depth/stencil buffer creation failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRhiTextureRenderTargetDescription rtDesc {QRhiColorAttachment(m_texture)};
|
|
||||||
rtDesc.setDepthStencilBuffer(m_buffer);
|
|
||||||
m_texTarget = m_rhi->newTextureRenderTarget(rtDesc);
|
|
||||||
m_rpDesc = m_texTarget->newCompatibleRenderPassDescriptor();
|
|
||||||
m_texTarget->setRenderPassDescriptor(m_rpDesc);
|
|
||||||
if (!m_texTarget->create()) {
|
|
||||||
qWarning() << __FUNCTION__ << "Texture render target creation failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// redirect Qt Quick rendering into our texture
|
|
||||||
m_window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(m_texTarget));
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QtCore/qstring.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QQuickWindow;
|
|
||||||
class QQuickItem;
|
|
||||||
class QQuickDesignerSupport;
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
class QQuickRenderControl;
|
|
||||||
class QRhi;
|
|
||||||
class QRhiTexture;
|
|
||||||
class QRhiRenderBuffer;
|
|
||||||
class QRhiTextureRenderTarget;
|
|
||||||
class QRhiRenderPassDescriptor;
|
|
||||||
#endif
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class IconRenderer : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit IconRenderer(int size, const QString &filePath, const QString &source);
|
|
||||||
~IconRenderer();
|
|
||||||
|
|
||||||
void setupRender();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void startCreateIcon();
|
|
||||||
void focusCamera();
|
|
||||||
void finishCreateIcon();
|
|
||||||
void render(const QString &fileName);
|
|
||||||
void resizeContent(int dimensions);
|
|
||||||
bool initRhi();
|
|
||||||
|
|
||||||
int m_size = 16;
|
|
||||||
QString m_filePath;
|
|
||||||
QString m_source;
|
|
||||||
QQuickWindow *m_window = nullptr;
|
|
||||||
QQuickItem *m_contentItem = nullptr;
|
|
||||||
QQuickItem *m_containerItem = nullptr;
|
|
||||||
std::unique_ptr<QQuickDesignerSupport> m_designerSupport;
|
|
||||||
bool m_is3D = false;
|
|
||||||
int m_focusStep = 0;
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QQuickRenderControl *m_renderControl = nullptr;
|
|
||||||
QRhi *m_rhi = nullptr;
|
|
||||||
QRhiTexture *m_texture = nullptr;
|
|
||||||
QRhiRenderBuffer *m_buffer = nullptr;
|
|
||||||
QRhiTextureRenderTarget *m_texTarget = nullptr;
|
|
||||||
QRhiRenderPassDescriptor *m_rpDesc = nullptr;
|
|
||||||
#endif
|
|
||||||
};
|
|
@@ -1,3 +0,0 @@
|
|||||||
HEADERS += $$PWD/iconrenderer.h
|
|
||||||
|
|
||||||
SOURCES += $$PWD/iconrenderer.cpp
|
|
@@ -32,11 +32,7 @@ void import3D([[maybe_unused]] const QString &sourceAsset,
|
|||||||
|
|
||||||
if (!optDoc.isNull() && optDoc.isObject()) {
|
if (!optDoc.isNull() && optDoc.isObject()) {
|
||||||
QJsonObject optObj = optDoc.object();
|
QJsonObject optObj = optDoc.object();
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
|
|
||||||
const auto &optionsMap = optObj;
|
const auto &optionsMap = optObj;
|
||||||
#else
|
|
||||||
const auto optionsMap = optObj.toVariantMap();
|
|
||||||
#endif // QT_VERSION >= 6.4.0
|
|
||||||
if (importer->importFile(sourceAsset, outDir, optionsMap, &errorStr)
|
if (importer->importFile(sourceAsset, outDir, optionsMap, &errorStr)
|
||||||
!= QSSGAssetImportManager::ImportState::Success) {
|
!= QSSGAssetImportManager::ImportState::Success) {
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,7 @@
|
|||||||
|
|
||||||
#include <qmlprivategate.h>
|
#include <qmlprivategate.h>
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
#include <private/qquickdesignersupportmetainfo_p.h>
|
#include <private/qquickdesignersupportmetainfo_p.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <createinstancescommand.h>
|
#include <createinstancescommand.h>
|
||||||
#include <changefileurlcommand.h>
|
#include <changefileurlcommand.h>
|
||||||
@@ -728,7 +726,6 @@ void NodeInstanceServer::setupMockupTypes(const QVector<MockupTypeContainer> &co
|
|||||||
{
|
{
|
||||||
for (const MockupTypeContainer &mockupType : container) {
|
for (const MockupTypeContainer &mockupType : container) {
|
||||||
if (!isTypeAvailable(mockupType, engine())) {
|
if (!isTypeAvailable(mockupType, engine())) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
|
|
||||||
if (mockupType.majorVersion() == -1 && mockupType.minorVersion() == -1) {
|
if (mockupType.majorVersion() == -1 && mockupType.minorVersion() == -1) {
|
||||||
QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(),
|
QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(),
|
||||||
1,
|
1,
|
||||||
@@ -740,13 +737,6 @@ void NodeInstanceServer::setupMockupTypes(const QVector<MockupTypeContainer> &co
|
|||||||
mockupType.minorVersion(),
|
mockupType.minorVersion(),
|
||||||
mockupType.typeName());
|
mockupType.typeName());
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
qmlRegisterType(QUrl("qrc:/qtquickplugin/mockfiles/GenericBackend.qml"),
|
|
||||||
mockupType.importUri().toUtf8(),
|
|
||||||
mockupType.majorVersion(),
|
|
||||||
mockupType.minorVersion(),
|
|
||||||
mockupType.typeName());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1412,10 +1402,8 @@ void NodeInstanceServer::loadDummyContextObjectFile(const QFileInfo &qmlFileInfo
|
|||||||
|
|
||||||
void NodeInstanceServer::setTranslationLanguage(const QString &language)
|
void NodeInstanceServer::setTranslationLanguage(const QString &language)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
|
||||||
// if there exists an /i18n directory it sets default translators
|
// if there exists an /i18n directory it sets default translators
|
||||||
engine()->setUiLanguage(language);
|
engine()->setUiLanguage(language);
|
||||||
#endif
|
|
||||||
static QPointer<MultiLanguage::Translator> multilanguageTranslator;
|
static QPointer<MultiLanguage::Translator> multilanguageTranslator;
|
||||||
if (!MultiLanguage::databaseFilePath().isEmpty()
|
if (!MultiLanguage::databaseFilePath().isEmpty()
|
||||||
&& QFileInfo::exists(QString::fromUtf8(MultiLanguage::databaseFilePath()))) {
|
&& QFileInfo::exists(QString::fromUtf8(MultiLanguage::databaseFilePath()))) {
|
||||||
|
@@ -40,11 +40,7 @@ namespace QtHelpers {
|
|||||||
template <class T>
|
template <class T>
|
||||||
QList<T>toList(const QSet<T> &set)
|
QList<T>toList(const QSet<T> &set)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
|
||||||
return set.toList();
|
|
||||||
#else
|
|
||||||
return QList<T>(set.begin(), set.end());
|
return QList<T>(set.begin(), set.end());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} // QtHelpers
|
} // QtHelpers
|
||||||
|
|
||||||
|
@@ -282,11 +282,7 @@ static void removeObjectFromList(const QQmlProperty &property,
|
|||||||
QObject *objectToBeRemoved,
|
QObject *objectToBeRemoved,
|
||||||
[[maybe_unused]] QQmlEngine *engine)
|
[[maybe_unused]] QQmlEngine *engine)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
|
||||||
QQmlListReference listReference(property.object(), property.name().toUtf8());
|
QQmlListReference listReference(property.object(), property.name().toUtf8());
|
||||||
#else
|
|
||||||
QQmlListReference listReference(property.object(), property.name().toUtf8(), engine);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!QmlPrivateGate::hasFullImplementedListInterface(listReference)) {
|
if (!QmlPrivateGate::hasFullImplementedListInterface(listReference)) {
|
||||||
qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
|
qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
|
||||||
|
@@ -34,14 +34,12 @@ QmlStateNodeInstance::Pointer
|
|||||||
|
|
||||||
void setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem)
|
void setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!parentItem)
|
if (!parentItem)
|
||||||
return;
|
return;
|
||||||
const QList<QQuickItem *> children = parentItem->childItems();
|
const QList<QQuickItem *> children = parentItem->childItems();
|
||||||
for (QQuickItem *childItem : children)
|
for (QQuickItem *childItem : children)
|
||||||
setAllNodesDirtyRecursive(childItem);
|
setAllNodesDirtyRecursive(childItem);
|
||||||
QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
|
QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlStateNodeInstance::activateState()
|
void QmlStateNodeInstance::activateState()
|
||||||
|
@@ -68,9 +68,7 @@
|
|||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
#include <QtQuick/private/qquickrendercontrol_p.h>
|
#include <QtQuick/private/qquickrendercontrol_p.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
#include <QtQuick3D/private/qquick3dnode_p.h>
|
#include <QtQuick3D/private/qquick3dnode_p.h>
|
||||||
@@ -81,10 +79,7 @@
|
|||||||
#include <QtQuick3D/private/qquick3drepeater_p.h>
|
#include <QtQuick3D/private/qquick3drepeater_p.h>
|
||||||
#include <QtQuick3D/private/qquick3dloader_p.h>
|
#include <QtQuick3D/private/qquick3dloader_p.h>
|
||||||
#include <QtQuick3D/private/qquick3dsceneenvironment_p.h>
|
#include <QtQuick3D/private/qquick3dsceneenvironment_p.h>
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if defined(QUICK3D_ASSET_UTILS_MODULE)
|
||||||
#include "../editor3d/qt5compat/qquick3darealight_p.h"
|
|
||||||
#endif
|
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
|
||||||
#include <private/qquick3druntimeloader_p.h>
|
#include <private/qquick3druntimeloader_p.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -172,16 +167,10 @@ static QList<PropertyName> toPropertyNameList(const QVariant &variantList)
|
|||||||
void Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url,
|
void Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url,
|
||||||
RenderViewData &viewData)
|
RenderViewData &viewData)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
viewData.window = new QQuickView(quickView()->engine(), quickView());
|
|
||||||
viewData.window->setFormat(quickView()->format());
|
|
||||||
QQuickDesignerSupport::createOpenGLContext(static_cast<QQuickView *>(viewData.window.data()));
|
|
||||||
#else
|
|
||||||
viewData.renderControl = new QQuickRenderControl;
|
viewData.renderControl = new QQuickRenderControl;
|
||||||
viewData.window = new QQuickWindow(viewData.renderControl);
|
viewData.window = new QQuickWindow(viewData.renderControl);
|
||||||
setPipelineCacheConfig(viewData.window);
|
setPipelineCacheConfig(viewData.window);
|
||||||
viewData.renderControl->initialize();
|
viewData.renderControl->initialize();
|
||||||
#endif
|
|
||||||
QQmlComponent component(engine());
|
QQmlComponent component(engine());
|
||||||
component.loadUrl(url);
|
component.loadUrl(url);
|
||||||
viewData.rootItem = qobject_cast<QQuickItem *>(component.create());
|
viewData.rootItem = qobject_cast<QQuickItem *>(component.create());
|
||||||
@@ -191,13 +180,9 @@ void Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QQuickDesignerSupport::setRootItem(static_cast<QQuickView *>(viewData.window.data()), viewData.rootItem);
|
|
||||||
#else
|
|
||||||
viewData.window->contentItem()->setSize(viewData.rootItem->size());
|
viewData.window->contentItem()->setSize(viewData.rootItem->size());
|
||||||
viewData.window->setGeometry(0, 0, viewData.rootItem->width(), viewData.rootItem->height());
|
viewData.window->setGeometry(0, 0, viewData.rootItem->width(), viewData.rootItem->height());
|
||||||
viewData.rootItem->setParentItem(viewData.window->contentItem());
|
viewData.rootItem->setParentItem(viewData.window->contentItem());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::updateLockedAndHiddenStates(const QSet<ServerNodeInstance> &instances)
|
void Qt5InformationNodeInstanceServer::updateLockedAndHiddenStates(const QSet<ServerNodeInstance> &instances)
|
||||||
@@ -237,16 +222,10 @@ void Qt5InformationNodeInstanceServer::handleInputEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QWheelEvent *we
|
QWheelEvent *we
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
|
||||||
= new QWheelEvent(command.pos(), command.pos(), {0, 0},
|
= new QWheelEvent(command.pos(), command.pos(), {0, 0},
|
||||||
{0, angleDelta + command.angleDelta()},
|
{0, angleDelta + command.angleDelta()},
|
||||||
command.buttons(), command.modifiers(), Qt::NoScrollPhase,
|
command.buttons(), command.modifiers(), Qt::NoScrollPhase,
|
||||||
false);
|
false);
|
||||||
#else
|
|
||||||
= new QWheelEvent(command.pos(), command.pos(), {0, 0}, {0, command.angleDelta()},
|
|
||||||
0, Qt::Horizontal, command.buttons(), command.modifiers(),
|
|
||||||
Qt::NoScrollPhase, Qt::MouseEventNotSynthesized);
|
|
||||||
#endif
|
|
||||||
angleDelta = 0;
|
angleDelta = 0;
|
||||||
QGuiApplication::sendEvent(m_editView3DData.window, we);
|
QGuiApplication::sendEvent(m_editView3DData.window, we);
|
||||||
} else if (command.type() == QEvent::KeyPress || command.type() == QEvent::KeyRelease) {
|
} else if (command.type() == QEvent::KeyPress || command.type() == QEvent::KeyRelease) {
|
||||||
@@ -289,17 +268,7 @@ void Qt5InformationNodeInstanceServer::resolveImportSupport()
|
|||||||
#ifdef IMPORT_QUICK3D_ASSETS
|
#ifdef IMPORT_QUICK3D_ASSETS
|
||||||
QSSGAssetImportManager importManager;
|
QSSGAssetImportManager importManager;
|
||||||
const QHash<QString, QStringList> supportedExtensions = importManager.getSupportedExtensions();
|
const QHash<QString, QStringList> supportedExtensions = importManager.getSupportedExtensions();
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
|
const QSSGAssetImportManager::PluginOptionMaps supportedOptions = importManager.getAllOptions();
|
||||||
#define AS_VARIANT_MAP(IT) IT.value().toVariantMap()
|
|
||||||
using PluginOptionMaps = QSSGAssetImportManager::PluginOptionMaps;
|
|
||||||
#else
|
|
||||||
#define AS_VARIANT_MAP(IT) IT.value()
|
|
||||||
using PluginOptionMaps = QHash<QString, QVariantMap>;
|
|
||||||
#endif // QT_VERSION >= 6.4.0
|
|
||||||
|
|
||||||
const PluginOptionMaps supportedOptions = importManager.getAllOptions();
|
|
||||||
|
|
||||||
QVariantMap supportMap;
|
|
||||||
|
|
||||||
QVariantMap extMap;
|
QVariantMap extMap;
|
||||||
auto itExt = supportedExtensions.constBegin();
|
auto itExt = supportedExtensions.constBegin();
|
||||||
@@ -311,10 +280,11 @@ void Qt5InformationNodeInstanceServer::resolveImportSupport()
|
|||||||
QVariantMap optMap;
|
QVariantMap optMap;
|
||||||
auto itOpt = supportedOptions.constBegin();
|
auto itOpt = supportedOptions.constBegin();
|
||||||
while (itOpt != supportedOptions.constEnd()) {
|
while (itOpt != supportedOptions.constEnd()) {
|
||||||
optMap.insert(itOpt.key(), AS_VARIANT_MAP(itOpt));
|
optMap.insert(itOpt.key(), itOpt.value().toVariantMap());
|
||||||
++itOpt;
|
++itOpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap supportMap;
|
||||||
supportMap.insert("options", optMap);
|
supportMap.insert("options", optMap);
|
||||||
supportMap.insert("extensions", extMap);
|
supportMap.insert("extensions", extMap);
|
||||||
nodeInstanceClient()->handlePuppetToCreatorCommand(
|
nodeInstanceClient()->handlePuppetToCreatorCommand(
|
||||||
@@ -368,7 +338,8 @@ void Qt5InformationNodeInstanceServer::updateRotationBlocks(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::updateSnapSettings(const QVector<PropertyValueContainer> &valueChanges)
|
void Qt5InformationNodeInstanceServer::updateSnapSettings(
|
||||||
|
[[maybe_unused]] const QVector<PropertyValueContainer> &valueChanges)
|
||||||
{
|
{
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||||
@@ -393,7 +364,8 @@ void Qt5InformationNodeInstanceServer::updateSnapSettings(const QVector<Property
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::updateColorSettings(const QVector<PropertyValueContainer> &valueChanges)
|
void Qt5InformationNodeInstanceServer::updateColorSettings(
|
||||||
|
[[maybe_unused]] const QVector<PropertyValueContainer> &valueChanges)
|
||||||
{
|
{
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
if (m_editView3DData.rootItem) {
|
if (m_editView3DData.rootItem) {
|
||||||
@@ -432,7 +404,7 @@ void Qt5InformationNodeInstanceServer::removeRotationBlocks(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::getNodeAtPos(const QPointF &pos)
|
void Qt5InformationNodeInstanceServer::getNodeAtPos([[maybe_unused]] const QPointF &pos)
|
||||||
{
|
{
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
// pick a Quick3DModel at view position
|
// pick a Quick3DModel at view position
|
||||||
@@ -481,8 +453,6 @@ void Qt5InformationNodeInstanceServer::getNodeAtPos(const QPointF &pos)
|
|||||||
data.append(pos3d);
|
data.append(pos3d);
|
||||||
nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::NodeAtPos,
|
nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::NodeAtPos,
|
||||||
QVariant::fromValue(data)});
|
QVariant::fromValue(data)});
|
||||||
#else
|
|
||||||
Q_UNUSED(pos)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,9 +468,6 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
|||||||
qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry");
|
qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry");
|
||||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
||||||
qmlRegisterType<QmlDesigner::Internal::LineGeometry>("LineGeometry", 1, 0, "LineGeometry");
|
qmlRegisterType<QmlDesigner::Internal::LineGeometry>("LineGeometry", 1, 0, "LineGeometry");
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
qmlRegisterType<QmlDesigner::Internal::QQuick3DAreaLight>("LightUtils", 1, 0, "AreaLight");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
||||||
QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
|
QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
|
||||||
@@ -511,11 +478,7 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
|||||||
m_3dHelper = helper;
|
m_3dHelper = helper;
|
||||||
Internal::MouseArea3D::setGeneralHelper(helper);
|
Internal::MouseArea3D::setGeneralHelper(helper);
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/EditView3D.qml"), m_editView3DData);
|
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/EditView3D.qml"), m_editView3DData);
|
||||||
#else
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/EditView3D.qml"), m_editView3DData);
|
|
||||||
#endif
|
|
||||||
if (m_editView3DData.rootItem)
|
if (m_editView3DData.rootItem)
|
||||||
helper->setParent(m_editView3DData.rootItem);
|
helper->setParent(m_editView3DData.rootItem);
|
||||||
#endif
|
#endif
|
||||||
@@ -527,9 +490,7 @@ void Qt5InformationNodeInstanceServer::resetParticleSystem()
|
|||||||
if (!m_targetParticleSystem)
|
if (!m_targetParticleSystem)
|
||||||
return;
|
return;
|
||||||
m_targetParticleSystem->reset();
|
m_targetParticleSystem->reset();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2)
|
|
||||||
m_targetParticleSystem->setEditorTime(0);
|
m_targetParticleSystem->setEditorTime(0);
|
||||||
#endif
|
|
||||||
if (m_particleAnimationDriver)
|
if (m_particleAnimationDriver)
|
||||||
m_particleAnimationDriver->reset();
|
m_particleAnimationDriver->reset();
|
||||||
}
|
}
|
||||||
@@ -555,13 +516,12 @@ void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DPart
|
|||||||
// Ensure clean slate for newly selected system
|
// Ensure clean slate for newly selected system
|
||||||
resetParticleSystem();
|
resetParticleSystem();
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2)
|
|
||||||
QObject::disconnect(m_particleAnimationConnection);
|
QObject::disconnect(m_particleAnimationConnection);
|
||||||
m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () {
|
m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () {
|
||||||
if (m_targetParticleSystem)
|
if (m_targetParticleSystem)
|
||||||
m_targetParticleSystem->setEditorTime(m_particleAnimationDriver->elapsed());
|
m_targetParticleSystem->setEditorTime(m_particleAnimationDriver->elapsed());
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
if (m_particleAnimationPlaying && m_targetParticleSystem->visible())
|
if (m_particleAnimationPlaying && m_targetParticleSystem->visible())
|
||||||
m_particleAnimationDriver->restart();
|
m_particleAnimationDriver->restart();
|
||||||
QObject::connect(m_targetParticleSystem, &QQuick3DNode::visibleChanged, [this] () {
|
QObject::connect(m_targetParticleSystem, &QQuick3DNode::visibleChanged, [this] () {
|
||||||
@@ -923,12 +883,6 @@ void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D([[maybe_unu
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QVariant activeSceneVar = objectToVariant(m_active3DScene);
|
QVariant activeSceneVar = objectToVariant(m_active3DScene);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
// Active scene change handling on qml side is async, so a deleted importScene would crash
|
|
||||||
// editView when it updates next. Disable/enable edit view update synchronously to avoid this.
|
|
||||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "enableEditViewUpdate",
|
|
||||||
Q_ARG(QVariant, activeSceneVar));
|
|
||||||
#endif
|
|
||||||
ServerNodeInstance sceneInstance = active3DSceneInstance();
|
ServerNodeInstance sceneInstance = active3DSceneInstance();
|
||||||
const QString sceneId = sceneInstance.id();
|
const QString sceneId = sceneInstance.id();
|
||||||
|
|
||||||
@@ -1069,22 +1023,15 @@ void Qt5InformationNodeInstanceServer::updateNodesRecursive(QQuickItem *item)
|
|||||||
for (QQuickItem *childItem : childItems)
|
for (QQuickItem *childItem : childItems)
|
||||||
updateNodesRecursive(childItem);
|
updateNodesRecursive(childItem);
|
||||||
|
|
||||||
if (Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) {
|
|
||||||
if (item->flags() & QQuickItem::ItemHasContents)
|
if (item->flags() & QQuickItem::ItemHasContents)
|
||||||
item->update();
|
item->update();
|
||||||
} else {
|
|
||||||
QQuickDesignerSupport::updateDirtyNode(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem)
|
QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem)
|
||||||
{
|
{
|
||||||
QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value<QQuickItem *>();
|
QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value<QQuickItem *>();
|
||||||
if (contentItem) {
|
if (contentItem)
|
||||||
if (!Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6())
|
|
||||||
designerSupport()->refFromEffectItem(contentItem, false);
|
|
||||||
QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem);
|
QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem);
|
||||||
}
|
|
||||||
return contentItem;
|
return contentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1106,22 +1053,6 @@ void Qt5InformationNodeInstanceServer::doRender3DEditView()
|
|||||||
|
|
||||||
updateNodesRecursive(m_editView3DData.contentItem);
|
updateNodesRecursive(m_editView3DData.contentItem);
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
|
||||||
renderImage = m_editView3DData.window->grabWindow();
|
|
||||||
} else {
|
|
||||||
// Fake render loop signaling to update things like QML items as 3D textures
|
|
||||||
m_editView3DData.window->beforeSynchronizing();
|
|
||||||
m_editView3DData.window->beforeRendering();
|
|
||||||
|
|
||||||
QSizeF size = qobject_cast<QQuickItem *>(m_editView3DData.contentItem)->size();
|
|
||||||
QRectF renderRect(QPointF(0., 0.), size);
|
|
||||||
renderImage = designerSupport()->renderImageForItem(m_editView3DData.contentItem,
|
|
||||||
renderRect, size.toSize());
|
|
||||||
|
|
||||||
m_editView3DData.window->afterRendering();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 1)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 1)
|
||||||
static bool justOnce = true;
|
static bool justOnce = true;
|
||||||
if (justOnce) {
|
if (justOnce) {
|
||||||
@@ -1130,7 +1061,6 @@ void Qt5InformationNodeInstanceServer::doRender3DEditView()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
renderImage = grabRenderControl(m_editView3DData);
|
renderImage = grabRenderControl(m_editView3DData);
|
||||||
#endif
|
|
||||||
|
|
||||||
// There's no instance related to image, so instance id is -1.
|
// There's no instance related to image, so instance id is -1.
|
||||||
// Key number is selected so that it is unlikely to conflict other ImageContainer use.
|
// Key number is selected so that it is unlikely to conflict other ImageContainer use.
|
||||||
@@ -1213,8 +1143,6 @@ void Qt5InformationNodeInstanceServer::renderModelNodeImageView()
|
|||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::doRenderModelNodeImageView()
|
void Qt5InformationNodeInstanceServer::doRenderModelNodeImageView()
|
||||||
{
|
{
|
||||||
// This crashes on Qt 6.0.x due to QtQuick3D issue, so the preview generation is disabled
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
|
||||||
if (!m_priorityView3DsToRender.isEmpty()) {
|
if (!m_priorityView3DsToRender.isEmpty()) {
|
||||||
// Postpone any preview renders until we have rendered the priority views to ensure
|
// Postpone any preview renders until we have rendered the priority views to ensure
|
||||||
// materials in material library are properly initialized
|
// materials in material library are properly initialized
|
||||||
@@ -1237,7 +1165,6 @@ void Qt5InformationNodeInstanceServer::doRenderModelNodeImageView()
|
|||||||
m_modelNodePreviewImageCommands.remove(cmd);
|
m_modelNodePreviewImageCommands.remove(cmd);
|
||||||
if (!m_modelNodePreviewImageCommands.isEmpty())
|
if (!m_modelNodePreviewImageCommands.isEmpty())
|
||||||
m_renderModelNodeImageViewTimer.start(17);
|
m_renderModelNodeImageViewTimer.start(17);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView(
|
void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView(
|
||||||
@@ -1273,18 +1200,15 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView(
|
|||||||
instanceObj = instance.internalObject();
|
instanceObj = instance.internalObject();
|
||||||
}
|
}
|
||||||
QSize renderSize = cmd.size();
|
QSize renderSize = cmd.size();
|
||||||
if (Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) {
|
|
||||||
// Requested size is already adjusted for target pixel ratio, so we have to adjust
|
// Requested size is already adjusted for target pixel ratio, so we have to adjust
|
||||||
// back if ratio is not default for our window.
|
// back if ratio is not default for our window.
|
||||||
double ratio = m_modelNode3DImageViewData.window->devicePixelRatio();
|
double ratio = m_modelNode3DImageViewData.window->devicePixelRatio();
|
||||||
renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio));
|
renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio));
|
||||||
renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio));
|
renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio));
|
||||||
}
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
m_modelNode3DImageViewData.bufferDirty = m_modelNode3DImageViewData.bufferDirty
|
m_modelNode3DImageViewData.bufferDirty = m_modelNode3DImageViewData.bufferDirty
|
||||||
|| m_modelNode3DImageViewData.rootItem->width() != renderSize.width()
|
|| m_modelNode3DImageViewData.rootItem->width() != renderSize.width()
|
||||||
|| m_modelNode3DImageViewData.rootItem->height() != renderSize.height();
|
|| m_modelNode3DImageViewData.rootItem->height() != renderSize.height();
|
||||||
#endif
|
|
||||||
|
|
||||||
m_modelNode3DImageViewData.window->resize(renderSize);
|
m_modelNode3DImageViewData.window->resize(renderSize);
|
||||||
m_modelNode3DImageViewData.rootItem->setSize(renderSize);
|
m_modelNode3DImageViewData.rootItem->setSize(renderSize);
|
||||||
@@ -1309,23 +1233,7 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView(
|
|||||||
, Qt::DirectConnection);
|
, Qt::DirectConnection);
|
||||||
|
|
||||||
updateNodesRecursive(m_modelNode3DImageViewData.contentItem);
|
updateNodesRecursive(m_modelNode3DImageViewData.contentItem);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
|
||||||
renderImage = m_modelNode3DImageViewData.window->grabWindow();
|
|
||||||
} else {
|
|
||||||
// Fake render loop signaling to update things like QML items as 3D textures
|
|
||||||
m_modelNode3DImageViewData.window->beforeSynchronizing();
|
|
||||||
m_modelNode3DImageViewData.window->beforeRendering();
|
|
||||||
|
|
||||||
QSizeF size = qobject_cast<QQuickItem *>(m_modelNode3DImageViewData.contentItem)->size();
|
|
||||||
QRectF renderRect(QPointF(0., 0.), size);
|
|
||||||
renderImage = designerSupport()->renderImageForItem(m_modelNode3DImageViewData.contentItem,
|
|
||||||
renderRect, size.toSize());
|
|
||||||
m_modelNode3DImageViewData.window->afterRendering();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
renderImage = grabRenderControl(m_modelNode3DImageViewData);
|
renderImage = grabRenderControl(m_modelNode3DImageViewData);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(m_modelNode3DImageViewData.rootItem, "destroyView");
|
QMetaObject::invokeMethod(m_modelNode3DImageViewData.rootItem, "destroyView");
|
||||||
@@ -1409,11 +1317,9 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView(const Reques
|
|||||||
renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize));
|
renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
m_modelNode2DImageViewData.bufferDirty = m_modelNode2DImageViewData.bufferDirty
|
m_modelNode2DImageViewData.bufferDirty = m_modelNode2DImageViewData.bufferDirty
|
||||||
|| m_modelNode2DImageViewData.rootItem->width() != renderSize.width()
|
|| m_modelNode2DImageViewData.rootItem->width() != renderSize.width()
|
||||||
|| m_modelNode2DImageViewData.rootItem->height() != renderSize.height();
|
|| m_modelNode2DImageViewData.rootItem->height() != renderSize.height();
|
||||||
#endif
|
|
||||||
|
|
||||||
m_modelNode2DImageViewData.window->resize(renderSize);
|
m_modelNode2DImageViewData.window->resize(renderSize);
|
||||||
m_modelNode2DImageViewData.rootItem->setSize(renderSize);
|
m_modelNode2DImageViewData.rootItem->setSize(renderSize);
|
||||||
@@ -1421,16 +1327,7 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView(const Reques
|
|||||||
|
|
||||||
updateNodesRecursive(m_modelNode2DImageViewData.contentItem);
|
updateNodesRecursive(m_modelNode2DImageViewData.contentItem);
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
|
||||||
renderImage = m_modelNode2DImageViewData.window->grabWindow();
|
|
||||||
} else {
|
|
||||||
renderImage = designerSupport()->renderImageForItem(m_modelNode2DImageViewData.contentItem,
|
|
||||||
renderRect, renderSize);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
renderImage = grabRenderControl(m_modelNode2DImageViewData);
|
renderImage = grabRenderControl(m_modelNode2DImageViewData);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!imageHasContent(renderImage))
|
if (!imageHasContent(renderImage))
|
||||||
renderImage = nonVisualComponentPreviewImage();
|
renderImage = nonVisualComponentPreviewImage();
|
||||||
@@ -1503,15 +1400,6 @@ Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
|
|||||||
|
|
||||||
if (m_editView3DData.rootItem)
|
if (m_editView3DData.rootItem)
|
||||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "aboutToShutDown", Qt::DirectConnection);
|
QMetaObject::invokeMethod(m_editView3DData.rootItem, "aboutToShutDown", Qt::DirectConnection);
|
||||||
|
|
||||||
if (!Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) {
|
|
||||||
if (m_editView3DData.contentItem)
|
|
||||||
designerSupport()->derefFromEffectItem(m_editView3DData.contentItem);
|
|
||||||
if (m_modelNode3DImageViewData.contentItem)
|
|
||||||
designerSupport()->derefFromEffectItem(m_modelNode3DImageViewData.contentItem);
|
|
||||||
if (m_modelNode2DImageViewData.contentItem)
|
|
||||||
designerSupport()->derefFromEffectItem(m_modelNode2DImageViewData.contentItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::sendTokenBack()
|
void Qt5InformationNodeInstanceServer::sendTokenBack()
|
||||||
@@ -1605,22 +1493,12 @@ void Qt5InformationNodeInstanceServer::initializeAuxiliaryViews()
|
|||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
if (ViewConfig::isQuick3DMode())
|
if (ViewConfig::isQuick3DMode())
|
||||||
createEditView3D();
|
createEditView3D();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode3DImageView.qml"),
|
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode3DImageView.qml"),
|
||||||
m_modelNode3DImageViewData);
|
m_modelNode3DImageViewData);
|
||||||
#else
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/ModelNode3DImageView.qml"),
|
|
||||||
m_modelNode3DImageViewData);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode2DImageView.qml"),
|
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode2DImageView.qml"),
|
||||||
m_modelNode2DImageViewData);
|
m_modelNode2DImageViewData);
|
||||||
#else
|
|
||||||
createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/ModelNode2DImageView.qml"),
|
|
||||||
m_modelNode2DImageViewData);
|
|
||||||
#endif
|
|
||||||
m_modelNode2DImageViewData.window->setDefaultAlphaBuffer(true);
|
m_modelNode2DImageViewData.window->setDefaultAlphaBuffer(true);
|
||||||
m_modelNode2DImageViewData.window->setColor(Qt::transparent);
|
m_modelNode2DImageViewData.window->setColor(Qt::transparent);
|
||||||
}
|
}
|
||||||
@@ -1639,24 +1517,6 @@ void Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout()
|
|||||||
void Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout()
|
void Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout()
|
||||||
{
|
{
|
||||||
for (auto obj : std::as_const(m_dynamicObjectConstructors)) {
|
for (auto obj : std::as_const(m_dynamicObjectConstructors)) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
#ifdef QUICK3D_MODULE
|
|
||||||
auto handleHiding = [this](QQuick3DNode *node) -> bool {
|
|
||||||
if (node && hasInstanceForObject(node)) {
|
|
||||||
ServerNodeInstance instance = instanceForObject(node);
|
|
||||||
handleInstanceHidden(instance, instance.internalInstance()->isHiddenInEditor(),
|
|
||||||
false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
auto nodeObj = qobject_cast<QQuick3DNode *>(obj);
|
|
||||||
if (!handleHiding(nodeObj)) {
|
|
||||||
if (auto pickTarget = obj->property("_pickTarget").value<QQuick3DNode *>())
|
|
||||||
handleHiding(pickTarget);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
auto handlePicking = [this](QObject *object) -> bool {
|
auto handlePicking = [this](QObject *object) -> bool {
|
||||||
if (object && hasInstanceForObject(object)) {
|
if (object && hasInstanceForObject(object)) {
|
||||||
ServerNodeInstance instance = instanceForObject(object);
|
ServerNodeInstance instance = instanceForObject(object);
|
||||||
@@ -1669,7 +1529,6 @@ void Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout()
|
|||||||
if (auto pickTarget = obj->property("_pickTarget").value<QObject *>())
|
if (auto pickTarget = obj->property("_pickTarget").value<QObject *>())
|
||||||
handlePicking(pickTarget);
|
handlePicking(pickTarget);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
m_dynamicObjectConstructors.clear();
|
m_dynamicObjectConstructors.clear();
|
||||||
}
|
}
|
||||||
@@ -2305,7 +2164,8 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
|
|||||||
render3DEditView(2);
|
render3DEditView(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(const PropertyValueContainer &container)
|
void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(
|
||||||
|
[[maybe_unused]] const PropertyValueContainer &container)
|
||||||
{
|
{
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||||
@@ -2339,8 +2199,6 @@ void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(const PropertyVa
|
|||||||
Q_ARG(QVariant, QVariant::fromValue(colors)));
|
Q_ARG(QVariant, QVariant::fromValue(colors)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
Q_UNUSED(container)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2729,65 +2587,12 @@ void Qt5InformationNodeInstanceServer::handleInstanceHidden(
|
|||||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||||
if (helper)
|
if (helper)
|
||||||
emit helper->hiddenStateChanged(node);
|
emit helper->hiddenStateChanged(node);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
if (auto model = qobject_cast<QQuick3DModel *>(node))
|
|
||||||
model->setPickable(!edit3dHidden); // allow 3D objects to receive mouse clicks
|
|
||||||
#endif
|
|
||||||
const auto childItems = node->childItems();
|
const auto childItems = node->childItems();
|
||||||
for (auto childItem : childItems) {
|
for (auto childItem : childItems) {
|
||||||
const ServerNodeInstance quick3dInstance = getQuick3DInstanceAndHidden(childItem);
|
const ServerNodeInstance quick3dInstance = getQuick3DInstanceAndHidden(childItem);
|
||||||
if (quick3dInstance.isValid()) {
|
if (quick3dInstance.isValid()) {
|
||||||
// Don't override explicit hide in children
|
// Don't override explicit hide in children
|
||||||
handleInstanceHidden(quick3dInstance, edit3dHidden || isInstanceHidden, false);
|
handleInstanceHidden(quick3dInstance, edit3dHidden || isInstanceHidden, false);
|
||||||
} else {
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
// Children of components do not have instances, but will still need to be pickable
|
|
||||||
std::function<void(QQuick3DNode *)> checkChildren;
|
|
||||||
checkChildren = [&](QQuick3DNode *checkNode) {
|
|
||||||
const auto childItems = checkNode->childItems();
|
|
||||||
for (auto child : childItems) {
|
|
||||||
if (auto childNode = qobject_cast<QQuick3DNode *>(child))
|
|
||||||
checkChildren(childNode);
|
|
||||||
}
|
|
||||||
if (auto checkModel = qobject_cast<QQuick3DModel *>(checkNode)) {
|
|
||||||
QVariant value;
|
|
||||||
if (!edit3dHidden)
|
|
||||||
value = QVariant::fromValue(node);
|
|
||||||
// Specify the actual pick target with dynamic property
|
|
||||||
checkModel->setProperty("_pickTarget", value);
|
|
||||||
checkModel->setPickable(!edit3dHidden);
|
|
||||||
} else {
|
|
||||||
auto checkRepeater = qobject_cast<QQuick3DRepeater *>(checkNode);
|
|
||||||
auto checkLoader = qobject_cast<QQuick3DLoader *>(checkNode);
|
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
|
||||||
auto checkRunLoader = qobject_cast<QQuick3DRuntimeLoader *>(checkNode);
|
|
||||||
if (checkRepeater || checkLoader || checkRunLoader) {
|
|
||||||
#else
|
|
||||||
if (checkRepeater || checkLoader) {
|
|
||||||
#endif
|
|
||||||
// Repeaters/loaders may not yet have created their children, so we set
|
|
||||||
// _pickTarget on them and connect the notifier.
|
|
||||||
if (checkNode->property("_pickTarget").isNull()) {
|
|
||||||
if (checkRepeater) {
|
|
||||||
QObject::connect(checkRepeater, &QQuick3DRepeater::objectAdded,
|
|
||||||
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
|
||||||
} else if (checkRunLoader) {
|
|
||||||
QObject::connect(checkRunLoader, &QQuick3DRuntimeLoader::statusChanged,
|
|
||||||
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
QObject::connect(checkLoader, &QQuick3DLoader::loaded,
|
|
||||||
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkNode->setProperty("_pickTarget", QVariant::fromValue(node));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (auto childNode = qobject_cast<QQuick3DNode *>(childItem))
|
|
||||||
checkChildren(childNode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2797,10 +2602,7 @@ void Qt5InformationNodeInstanceServer::handleInstanceHidden(
|
|||||||
void Qt5InformationNodeInstanceServer::handlePickTarget(
|
void Qt5InformationNodeInstanceServer::handlePickTarget(
|
||||||
[[maybe_unused]] const ServerNodeInstance &instance)
|
[[maybe_unused]] const ServerNodeInstance &instance)
|
||||||
{
|
{
|
||||||
#if defined(QUICK3D_MODULE) && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1))
|
#ifdef QUICK3D_MODULE
|
||||||
// Picking is dependent on hidden status prior to global picking support (<6.2.1), so it is
|
|
||||||
// handled in handleInstanceHidden() method in those builds
|
|
||||||
|
|
||||||
if (!ViewConfig::isQuick3DMode())
|
if (!ViewConfig::isQuick3DMode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2902,12 +2704,10 @@ void Qt5InformationNodeInstanceServer::update3DViewState(
|
|||||||
if (command.type() == Update3dViewStateCommand::SizeChange) {
|
if (command.type() == Update3dViewStateCommand::SizeChange) {
|
||||||
if (m_editView3DSetupDone) {
|
if (m_editView3DSetupDone) {
|
||||||
m_editView3DData.rootItem->setSize(command.size());
|
m_editView3DData.rootItem->setSize(command.size());
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
m_editView3DData.window->contentItem()->setSize(m_editView3DData.rootItem->size());
|
m_editView3DData.window->contentItem()->setSize(m_editView3DData.rootItem->size());
|
||||||
m_editView3DData.window->setGeometry(0, 0, m_editView3DData.rootItem->width(),
|
m_editView3DData.window->setGeometry(0, 0, m_editView3DData.rootItem->width(),
|
||||||
m_editView3DData.rootItem->height());
|
m_editView3DData.rootItem->height());
|
||||||
m_editView3DData.bufferDirty = true;
|
m_editView3DData.bufferDirty = true;
|
||||||
#endif
|
|
||||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||||
if (helper)
|
if (helper)
|
||||||
helper->storeToolState(helper->globalStateId(), helper->rootSizeKey(), QVariant(command.size()), 0);
|
helper->storeToolState(helper->globalStateId(), helper->rootSizeKey(), QVariant(command.size()), 0);
|
||||||
|
@@ -15,10 +15,6 @@
|
|||||||
#include "qt5testnodeinstanceserver.h"
|
#include "qt5testnodeinstanceserver.h"
|
||||||
#include "quickitemnodeinstance.h"
|
#include "quickitemnodeinstance.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
#include <private/qquickdesignersupport_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
@@ -44,10 +40,6 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
|
|||||||
|
|
||||||
if (unifiedRenderPath)
|
if (unifiedRenderPath)
|
||||||
Internal::QuickItemNodeInstance::enableUnifiedRenderPath(true);
|
Internal::QuickItemNodeInstance::enableUnifiedRenderPath(true);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
else
|
|
||||||
QQuickDesignerSupport::activateDesignerWindowManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (QCoreApplication::arguments().at(1) == QLatin1String("--readcapturedstream")) {
|
if (QCoreApplication::arguments().at(1) == QLatin1String("--readcapturedstream")) {
|
||||||
qputenv("DESIGNER_DONT_USE_SHARED_MEMORY", "1");
|
qputenv("DESIGNER_DONT_USE_SHARED_MEMORY", "1");
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
#include <QtGui/private/qrhi_p.h>
|
#include <QtGui/private/qrhi_p.h>
|
||||||
#include <QtQuick/private/qquickitem_p.h>
|
#include <QtQuick/private/qquickitem_p.h>
|
||||||
#include <QtQuick/private/qquickrendercontrol_p.h>
|
#include <QtQuick/private/qquickrendercontrol_p.h>
|
||||||
@@ -37,9 +36,6 @@
|
|||||||
#include <QtQuick/private/qsgcontext_p.h>
|
#include <QtQuick/private/qsgcontext_p.h>
|
||||||
#include <QtQuick/private/qsgrenderer_p.h>
|
#include <QtQuick/private/qsgrenderer_p.h>
|
||||||
#include <QtQuick/private/qsgrhilayer_p.h>
|
#include <QtQuick/private/qsgrhilayer_p.h>
|
||||||
#else
|
|
||||||
#include <QtQuick/private/qquickitem_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 1)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 1)
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -74,11 +70,7 @@ Qt5NodeInstanceServer::~Qt5NodeInstanceServer()
|
|||||||
|
|
||||||
QQuickView *Qt5NodeInstanceServer::quickView() const
|
QQuickView *Qt5NodeInstanceServer::quickView() const
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
return static_cast<QQuickView *>(m_viewData.window.data());
|
|
||||||
#else
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickWindow *Qt5NodeInstanceServer::quickWindow() const
|
QQuickWindow *Qt5NodeInstanceServer::quickWindow() const
|
||||||
@@ -90,25 +82,11 @@ void Qt5NodeInstanceServer::initializeView()
|
|||||||
{
|
{
|
||||||
Q_ASSERT(!quickWindow());
|
Q_ASSERT(!quickWindow());
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
auto view = new QQuickView;
|
|
||||||
m_viewData.window = view;
|
|
||||||
/* enables grab window without show */
|
|
||||||
QSurfaceFormat surfaceFormat = view->requestedFormat();
|
|
||||||
surfaceFormat.setVersion(4, 1);
|
|
||||||
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
|
|
||||||
QSurfaceFormat::setDefaultFormat(surfaceFormat);
|
|
||||||
view->setFormat(surfaceFormat);
|
|
||||||
|
|
||||||
QQuickDesignerSupport::createOpenGLContext(view);
|
|
||||||
m_qmlEngine = view->engine();
|
|
||||||
#else
|
|
||||||
m_viewData.renderControl = new QQuickRenderControl;
|
m_viewData.renderControl = new QQuickRenderControl;
|
||||||
m_viewData.window = new QQuickWindow(m_viewData.renderControl);
|
m_viewData.window = new QQuickWindow(m_viewData.renderControl);
|
||||||
setPipelineCacheConfig(m_viewData.window);
|
setPipelineCacheConfig(m_viewData.window);
|
||||||
m_viewData.renderControl->initialize();
|
m_viewData.renderControl->initialize();
|
||||||
m_qmlEngine = new QQmlEngine;
|
m_qmlEngine = new QQmlEngine;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (qEnvironmentVariableIsSet("QML_FILE_SELECTORS")) {
|
if (qEnvironmentVariableIsSet("QML_FILE_SELECTORS")) {
|
||||||
QQmlFileSelector *fileSelector = new QQmlFileSelector(engine(), engine());
|
QQmlFileSelector *fileSelector = new QQmlFileSelector(engine(), engine());
|
||||||
@@ -132,9 +110,6 @@ QQuickItem *Qt5NodeInstanceServer::rootItem() const
|
|||||||
void Qt5NodeInstanceServer::setRootItem(QQuickItem *item)
|
void Qt5NodeInstanceServer::setRootItem(QQuickItem *item)
|
||||||
{
|
{
|
||||||
m_viewData.rootItem = item;
|
m_viewData.rootItem = item;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QQuickDesignerSupport::setRootItem(quickView(), item);
|
|
||||||
#else
|
|
||||||
quickWindow()->setGeometry(0, 0, item->width(), item->height());
|
quickWindow()->setGeometry(0, 0, item->width(), item->height());
|
||||||
// Insert an extra item above the root to adjust root item position to 0,0 to make entire
|
// Insert an extra item above the root to adjust root item position to 0,0 to make entire
|
||||||
// item to be always rendered.
|
// item to be always rendered.
|
||||||
@@ -142,7 +117,6 @@ void Qt5NodeInstanceServer::setRootItem(QQuickItem *item)
|
|||||||
m_viewData.contentItem = new QQuickItem(quickWindow()->contentItem());
|
m_viewData.contentItem = new QQuickItem(quickWindow()->contentItem());
|
||||||
m_viewData.contentItem->setPosition(-item->position());
|
m_viewData.contentItem->setPosition(-item->position());
|
||||||
item->setParentItem(m_viewData.contentItem);
|
item->setParentItem(m_viewData.contentItem);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlEngine *Qt5NodeInstanceServer::engine() const
|
QQmlEngine *Qt5NodeInstanceServer::engine() const
|
||||||
@@ -152,11 +126,9 @@ QQmlEngine *Qt5NodeInstanceServer::engine() const
|
|||||||
|
|
||||||
void Qt5NodeInstanceServer::resizeCanvasToRootItem()
|
void Qt5NodeInstanceServer::resizeCanvasToRootItem()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
m_viewData.bufferDirty = true;
|
m_viewData.bufferDirty = true;
|
||||||
if (m_viewData.contentItem)
|
if (m_viewData.contentItem)
|
||||||
m_viewData.contentItem->setPosition(-m_viewData.rootItem->position());
|
m_viewData.contentItem->setPosition(-m_viewData.rootItem->position());
|
||||||
#endif
|
|
||||||
quickWindow()->resize(rootNodeInstance().boundingRect().size().toSize());
|
quickWindow()->resize(rootNodeInstance().boundingRect().size().toSize());
|
||||||
QQuickDesignerSupport::addDirty(rootNodeInstance().rootQuickItem(), QQuickDesignerSupport::Size);
|
QQuickDesignerSupport::addDirty(rootNodeInstance().rootQuickItem(), QQuickDesignerSupport::Size);
|
||||||
}
|
}
|
||||||
@@ -309,7 +281,6 @@ void Qt5NodeInstanceServer::handleRciSet()
|
|||||||
|
|
||||||
bool Qt5NodeInstanceServer::initRhi([[maybe_unused]] RenderViewData &viewData)
|
bool Qt5NodeInstanceServer::initRhi([[maybe_unused]] RenderViewData &viewData)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!viewData.renderControl) {
|
if (!viewData.renderControl) {
|
||||||
qWarning() << __FUNCTION__ << "Render control not created";
|
qWarning() << __FUNCTION__ << "Render control not created";
|
||||||
return false;
|
return false;
|
||||||
@@ -389,7 +360,7 @@ bool Qt5NodeInstanceServer::initRhi([[maybe_unused]] RenderViewData &viewData)
|
|||||||
viewData.window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(viewData.texTarget));
|
viewData.window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(viewData.texTarget));
|
||||||
|
|
||||||
viewData.bufferDirty = false;
|
viewData.bufferDirty = false;
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +369,6 @@ QImage Qt5NodeInstanceServer::grabRenderControl([[maybe_unused]] RenderViewData
|
|||||||
NANOTRACE_SCOPE("Update", "GrabRenderControl");
|
NANOTRACE_SCOPE("Update", "GrabRenderControl");
|
||||||
|
|
||||||
QImage renderImage;
|
QImage renderImage;
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (viewData.bufferDirty && !initRhi(viewData))
|
if (viewData.bufferDirty && !initRhi(viewData))
|
||||||
return renderImage;
|
return renderImage;
|
||||||
|
|
||||||
@@ -426,14 +396,13 @@ QImage Qt5NodeInstanceServer::grabRenderControl([[maybe_unused]] RenderViewData
|
|||||||
rd->cb->resourceUpdate(readbackBatch);
|
rd->cb->resourceUpdate(readbackBatch);
|
||||||
|
|
||||||
viewData.renderControl->endFrame();
|
viewData.renderControl->endFrame();
|
||||||
#endif
|
|
||||||
return renderImage;
|
return renderImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method simply renders the window without grabbing it
|
// This method simply renders the window without grabbing it
|
||||||
bool Qt5NodeInstanceServer::renderWindow()
|
bool Qt5NodeInstanceServer::renderWindow()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData)))
|
if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -443,8 +412,6 @@ bool Qt5NodeInstanceServer::renderWindow()
|
|||||||
m_viewData.renderControl->render();
|
m_viewData.renderControl->render();
|
||||||
m_viewData.renderControl->endFrame();
|
m_viewData.renderControl->endFrame();
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Qt5NodeInstanceServer::grabWindow()
|
QImage Qt5NodeInstanceServer::grabWindow()
|
||||||
@@ -471,7 +438,6 @@ QQuickItem *Qt5NodeInstanceServer::parentEffectItem(QQuickItem *item)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
static bool isEffectItem(QQuickItem *item, QQuickShaderEffectSource *sourceItem)
|
static bool isEffectItem(QQuickItem *item, QQuickShaderEffectSource *sourceItem)
|
||||||
{
|
{
|
||||||
QQuickItemPrivate *pItem = QQuickItemPrivate::get(sourceItem);
|
QQuickItemPrivate *pItem = QQuickItemPrivate::get(sourceItem);
|
||||||
@@ -492,12 +458,10 @@ static bool isLayerEnabled(QQuickItemPrivate *item)
|
|||||||
{
|
{
|
||||||
return item && item->layer() && item->layer()->enabled();
|
return item && item->layer() && item->layer()->enabled();
|
||||||
}
|
}
|
||||||
#endif // QT_VERSION check
|
|
||||||
|
|
||||||
QImage Qt5NodeInstanceServer::grabItem([[maybe_unused]] QQuickItem *item)
|
QImage Qt5NodeInstanceServer::grabItem([[maybe_unused]] QQuickItem *item)
|
||||||
{
|
{
|
||||||
QImage renderImage;
|
QImage renderImage;
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData)))
|
if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData)))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -623,7 +587,7 @@ QImage Qt5NodeInstanceServer::grabItem([[maybe_unused]] QQuickItem *item)
|
|||||||
|
|
||||||
if (!isLayerEnabled(pItem))
|
if (!isLayerEnabled(pItem))
|
||||||
pItem->derefFromEffectItem(false);
|
pItem->derefFromEffectItem(false);
|
||||||
#endif
|
|
||||||
return renderImage;
|
return renderImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,14 +12,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QQmlEngine;
|
class QQmlEngine;
|
||||||
class QQuickDesignerSupport;
|
class QQuickDesignerSupport;
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
class QQuickRenderControl;
|
class QQuickRenderControl;
|
||||||
class QRhi;
|
class QRhi;
|
||||||
class QRhiTexture;
|
class QRhiTexture;
|
||||||
class QRhiRenderBuffer;
|
class QRhiRenderBuffer;
|
||||||
class QRhiTextureRenderTarget;
|
class QRhiTextureRenderTarget;
|
||||||
class QRhiRenderPassDescriptor;
|
class QRhiRenderPassDescriptor;
|
||||||
#endif
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -66,7 +64,6 @@ protected:
|
|||||||
QPointer<QQuickWindow> window = nullptr;
|
QPointer<QQuickWindow> window = nullptr;
|
||||||
QQuickItem *rootItem = nullptr;
|
QQuickItem *rootItem = nullptr;
|
||||||
QQuickItem *contentItem = nullptr;
|
QQuickItem *contentItem = nullptr;
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
bool bufferDirty = true;
|
bool bufferDirty = true;
|
||||||
QQuickRenderControl *renderControl = nullptr;
|
QQuickRenderControl *renderControl = nullptr;
|
||||||
QRhi *rhi = nullptr;
|
QRhi *rhi = nullptr;
|
||||||
@@ -74,7 +71,6 @@ protected:
|
|||||||
QRhiRenderBuffer *buffer = nullptr;
|
QRhiRenderBuffer *buffer = nullptr;
|
||||||
QRhiTextureRenderTarget *texTarget = nullptr;
|
QRhiTextureRenderTarget *texTarget = nullptr;
|
||||||
QRhiRenderPassDescriptor *rpDesc = nullptr;
|
QRhiRenderPassDescriptor *rpDesc = nullptr;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool initRhi(RenderViewData &viewData);
|
virtual bool initRhi(RenderViewData &viewData);
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#include <private/qquick3dnode_p_p.h>
|
#include <private/qquick3dnode_p_p.h>
|
||||||
#include <private/qquick3drepeater_p.h>
|
#include <private/qquick3drepeater_p.h>
|
||||||
#include <private/qquick3dloader_p.h>
|
#include <private/qquick3dloader_p.h>
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
#if defined(QUICK3D_ASSET_UTILS_MODULE)
|
||||||
#include <private/qquick3druntimeloader_p.h>
|
#include <private/qquick3druntimeloader_p.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -42,7 +42,7 @@ void Quick3DNodeInstance::initialize(
|
|||||||
QObject *obj = object();
|
QObject *obj = object();
|
||||||
auto repObj = qobject_cast<QQuick3DRepeater *>(obj);
|
auto repObj = qobject_cast<QQuick3DRepeater *>(obj);
|
||||||
auto loadObj = qobject_cast<QQuick3DLoader *>(obj);
|
auto loadObj = qobject_cast<QQuick3DLoader *>(obj);
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
#if defined(QUICK3D_ASSET_UTILS_MODULE)
|
||||||
auto runLoadObj = qobject_cast<QQuick3DRuntimeLoader *>(obj);
|
auto runLoadObj = qobject_cast<QQuick3DRuntimeLoader *>(obj);
|
||||||
if (repObj || loadObj || runLoadObj) {
|
if (repObj || loadObj || runLoadObj) {
|
||||||
#else
|
#else
|
||||||
@@ -52,7 +52,7 @@ void Quick3DNodeInstance::initialize(
|
|||||||
if (repObj) {
|
if (repObj) {
|
||||||
QObject::connect(repObj, &QQuick3DRepeater::objectAdded,
|
QObject::connect(repObj, &QQuick3DRepeater::objectAdded,
|
||||||
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
||||||
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
|
#if defined(QUICK3D_ASSET_UTILS_MODULE)
|
||||||
} else if (runLoadObj) {
|
} else if (runLoadObj) {
|
||||||
QObject::connect(runLoadObj, &QQuick3DRuntimeLoader::statusChanged,
|
QObject::connect(runLoadObj, &QQuick3DRuntimeLoader::statusChanged,
|
||||||
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
|
||||||
|
@@ -31,7 +31,6 @@ void Quick3DRenderableNodeInstance::initialize(const ObjectNodeInstance::Pointer
|
|||||||
InstanceContainer::NodeFlags flags)
|
InstanceContainer::NodeFlags flags)
|
||||||
{
|
{
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
// In case this is the scene root, we need to create a dummy View3D for the scene
|
// In case this is the scene root, we need to create a dummy View3D for the scene
|
||||||
// in preview puppets
|
// in preview puppets
|
||||||
if (instanceId() == 0 && (!nodeInstanceServer()->isInformationServer())) {
|
if (instanceId() == 0 && (!nodeInstanceServer()->isInformationServer())) {
|
||||||
@@ -49,14 +48,12 @@ void Quick3DRenderableNodeInstance::initialize(const ObjectNodeInstance::Pointer
|
|||||||
|
|
||||||
nodeInstanceServer()->setRootItem(m_dummyRootView);
|
nodeInstanceServer()->setRootItem(m_dummyRootView);
|
||||||
}
|
}
|
||||||
#endif // QT_VERSION
|
|
||||||
#endif // QUICK3D_MODULE
|
#endif // QUICK3D_MODULE
|
||||||
ObjectNodeInstance::initialize(objectNodeInstance, flags);
|
ObjectNodeInstance::initialize(objectNodeInstance, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Quick3DRenderableNodeInstance::renderImage() const
|
QImage Quick3DRenderableNodeInstance::renderImage() const
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!isRootNodeInstance() || !m_dummyRootView)
|
if (!isRootNodeInstance() || !m_dummyRootView)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -83,14 +80,11 @@ QImage Quick3DRenderableNodeInstance::renderImage() const
|
|||||||
renderImage.setDevicePixelRatio(1);
|
renderImage.setDevicePixelRatio(1);
|
||||||
|
|
||||||
return renderImage;
|
return renderImage;
|
||||||
#endif
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Quick3DRenderableNodeInstance::renderPreviewImage(
|
QImage Quick3DRenderableNodeInstance::renderPreviewImage(
|
||||||
[[maybe_unused]] const QSize &previewImageSize) const
|
[[maybe_unused]] const QSize &previewImageSize) const
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (!isRootNodeInstance() || !m_dummyRootView)
|
if (!isRootNodeInstance() || !m_dummyRootView)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -118,7 +112,6 @@ QImage Quick3DRenderableNodeInstance::renderPreviewImage(
|
|||||||
return transparentImage;
|
return transparentImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,15 +44,6 @@ QuickItemNodeInstance::~QuickItemNodeInstance()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickItemNodeInstance::handleObjectDeletion(QObject *object)
|
|
||||||
{
|
|
||||||
auto item = qobject_cast<QQuickItem *>(object);
|
|
||||||
if (item && checkIfRefFromEffect(instanceId()))
|
|
||||||
designerSupport()->derefFromEffectItem(item);
|
|
||||||
|
|
||||||
ObjectNodeInstance::handleObjectDeletion(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isContentItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer)
|
static bool isContentItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -153,18 +144,6 @@ void QuickItemNodeInstance::enableUnifiedRenderPath(bool unifiedRenderPath)
|
|||||||
s_unifiedRenderPath = unifiedRenderPath;
|
s_unifiedRenderPath = unifiedRenderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickItemNodeInstance::checkIfRefFromEffect([[maybe_unused]] qint32 id)
|
|
||||||
{
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (s_unifiedRenderPath)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (s_createEffectItem || id == 0);
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance,
|
void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance,
|
||||||
InstanceContainer::NodeFlags flags)
|
InstanceContainer::NodeFlags flags)
|
||||||
{
|
{
|
||||||
@@ -174,12 +153,6 @@ void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &object
|
|||||||
else
|
else
|
||||||
quickItem()->setParentItem(nodeInstanceServer()->rootItem());
|
quickItem()->setParentItem(nodeInstanceServer()->rootItem());
|
||||||
|
|
||||||
if (quickItem()->window() && checkIfRefFromEffect(instanceId())) {
|
|
||||||
designerSupport()->refFromEffectItem(quickItem(),
|
|
||||||
!flags.testFlag(
|
|
||||||
InstanceContainer::ParentTakesOverRendering));
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectNodeInstance::initialize(objectNodeInstance, flags);
|
ObjectNodeInstance::initialize(objectNodeInstance, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,11 +229,6 @@ QStringList QuickItemNodeInstance::allStates() const
|
|||||||
|
|
||||||
void QuickItemNodeInstance::updateDirtyNode([[maybe_unused]] QQuickItem *item)
|
void QuickItemNodeInstance::updateDirtyNode([[maybe_unused]] QQuickItem *item)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (s_unifiedRenderPath)
|
|
||||||
return;
|
|
||||||
QQuickDesignerSupport::updateDirtyNode(item);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickItemNodeInstance::unifiedRenderPath()
|
bool QuickItemNodeInstance::unifiedRenderPath()
|
||||||
@@ -268,15 +236,6 @@ bool QuickItemNodeInstance::unifiedRenderPath()
|
|||||||
return s_unifiedRenderPath;
|
return s_unifiedRenderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickItemNodeInstance::unifiedRenderPathOrQt6()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return s_unifiedRenderPath;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickItemNodeInstance::setHiddenInEditor(bool hide)
|
void QuickItemNodeInstance::setHiddenInEditor(bool hide)
|
||||||
{
|
{
|
||||||
ObjectNodeInstance::setHiddenInEditor(hide);
|
ObjectNodeInstance::setHiddenInEditor(hide);
|
||||||
@@ -462,24 +421,6 @@ QImage QuickItemNodeInstance::renderImage() const
|
|||||||
QRectF renderBoundingRect = boundingRect();
|
QRectF renderBoundingRect = boundingRect();
|
||||||
QImage renderImage;
|
QImage renderImage;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QSize size = renderBoundingRect.size().toSize();
|
|
||||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
|
||||||
size *= devicePixelRatio;
|
|
||||||
|
|
||||||
if (s_unifiedRenderPath) {
|
|
||||||
renderImage = nodeInstanceServer()->quickWindow()->grabWindow();
|
|
||||||
} else {
|
|
||||||
// Fake render loop signaling to update things like QML items as 3D textures
|
|
||||||
nodeInstanceServer()->quickWindow()->beforeSynchronizing();
|
|
||||||
nodeInstanceServer()->quickWindow()->beforeRendering();
|
|
||||||
|
|
||||||
renderImage = designerSupport()->renderImageForItem(quickItem(), renderBoundingRect, size);
|
|
||||||
|
|
||||||
nodeInstanceServer()->quickWindow()->afterRendering();
|
|
||||||
}
|
|
||||||
renderImage.setDevicePixelRatio(devicePixelRatio);
|
|
||||||
#else
|
|
||||||
if (s_unifiedRenderPath) {
|
if (s_unifiedRenderPath) {
|
||||||
renderImage = nodeInstanceServer()->grabWindow();
|
renderImage = nodeInstanceServer()->grabWindow();
|
||||||
renderImage = renderImage.copy(renderBoundingRect.toRect());
|
renderImage = renderImage.copy(renderBoundingRect.toRect());
|
||||||
@@ -489,8 +430,6 @@ QImage QuickItemNodeInstance::renderImage() const
|
|||||||
renderImage = nodeInstanceServer()->grabItem(quickItem());
|
renderImage = nodeInstanceServer()->grabItem(quickItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return renderImage;
|
return renderImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,27 +442,9 @@ QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize)
|
|||||||
const QSize size = previewImageSize * devicePixelRatio;
|
const QSize size = previewImageSize * devicePixelRatio;
|
||||||
if (quickItem()->isVisible()) {
|
if (quickItem()->isVisible()) {
|
||||||
QImage image;
|
QImage image;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (s_unifiedRenderPath) {
|
|
||||||
image = nodeInstanceServer()->quickWindow()->grabWindow();
|
|
||||||
} else {
|
|
||||||
// Fake render loop signaling to update things like QML items as 3D textures
|
|
||||||
nodeInstanceServer()->quickWindow()->beforeSynchronizing();
|
|
||||||
nodeInstanceServer()->quickWindow()->beforeRendering();
|
|
||||||
|
|
||||||
image = designerSupport()->renderImageForItem(quickItem(),
|
|
||||||
previewItemBoundingRect,
|
|
||||||
size);
|
|
||||||
|
|
||||||
nodeInstanceServer()->quickWindow()->afterRendering();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
image = nodeInstanceServer()->grabWindow();
|
image = nodeInstanceServer()->grabWindow();
|
||||||
image = image.copy(previewItemBoundingRect.toRect());
|
image = image.copy(previewItemBoundingRect.toRect());
|
||||||
#endif
|
|
||||||
|
|
||||||
image = image.scaledToWidth(size.width());
|
image = image.scaledToWidth(size.width());
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
} else {
|
} else {
|
||||||
QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied);
|
QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied);
|
||||||
@@ -605,9 +526,6 @@ void QuickItemNodeInstance::updateDirtyNodesRecursive(QQuickItem *parentItem) co
|
|||||||
}
|
}
|
||||||
|
|
||||||
QmlPrivateGate::disableNativeTextRendering(parentItem);
|
QmlPrivateGate::disableNativeTextRendering(parentItem);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QQuickDesignerSupport::updateDirtyNode(parentItem);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickItemNodeInstance::updateAllDirtyNodesRecursive(QQuickItem *parentItem) const
|
void QuickItemNodeInstance::updateAllDirtyNodesRecursive(QQuickItem *parentItem) const
|
||||||
@@ -621,12 +539,10 @@ void QuickItemNodeInstance::updateAllDirtyNodesRecursive(QQuickItem *parentItem)
|
|||||||
|
|
||||||
void QuickItemNodeInstance::setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem) const
|
void QuickItemNodeInstance::setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem) const
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
const QList<QQuickItem *> children = parentItem->childItems();
|
const QList<QQuickItem *> children = parentItem->childItems();
|
||||||
for (QQuickItem *childItem : children)
|
for (QQuickItem *childItem : children)
|
||||||
setAllNodesDirtyRecursive(childItem);
|
setAllNodesDirtyRecursive(childItem);
|
||||||
QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
|
QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isRectangleSane(const QRectF &rect)
|
static inline bool isRectangleSane(const QRectF &rect)
|
||||||
@@ -636,9 +552,6 @@ static inline bool isRectangleSane(const QRectF &rect)
|
|||||||
|
|
||||||
static bool isEffectItem([[maybe_unused]] QQuickItem *item)
|
static bool isEffectItem([[maybe_unused]] QQuickItem *item)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
if (qobject_cast<QQuickShaderEffectSource *>(item))
|
if (qobject_cast<QQuickShaderEffectSource *>(item))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -658,7 +571,6 @@ static bool isEffectItem([[maybe_unused]] QQuickItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const
|
QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const
|
||||||
|
@@ -23,7 +23,6 @@ public:
|
|||||||
using WeakPointer = QWeakPointer<QuickItemNodeInstance>;
|
using WeakPointer = QWeakPointer<QuickItemNodeInstance>;
|
||||||
|
|
||||||
~QuickItemNodeInstance() override;
|
~QuickItemNodeInstance() override;
|
||||||
void handleObjectDeletion(QObject *object) override;
|
|
||||||
|
|
||||||
static Pointer create(QObject *objectToBeWrapped);
|
static Pointer create(QObject *objectToBeWrapped);
|
||||||
static void createEffectItem(bool createEffectItem);
|
static void createEffectItem(bool createEffectItem);
|
||||||
@@ -86,7 +85,6 @@ public:
|
|||||||
|
|
||||||
static void updateDirtyNode(QQuickItem *item);
|
static void updateDirtyNode(QQuickItem *item);
|
||||||
static bool unifiedRenderPath();
|
static bool unifiedRenderPath();
|
||||||
static bool unifiedRenderPathOrQt6();
|
|
||||||
|
|
||||||
void setHiddenInEditor(bool b) override;
|
void setHiddenInEditor(bool b) override;
|
||||||
|
|
||||||
@@ -111,7 +109,6 @@ protected:
|
|||||||
|
|
||||||
double x() const;
|
double x() const;
|
||||||
double y() const;
|
double y() const;
|
||||||
bool checkIfRefFromEffect(qint32 id);
|
|
||||||
void markRepeaterParentDirty() const;
|
void markRepeaterParentDirty() const;
|
||||||
|
|
||||||
private: //variables
|
private: //variables
|
||||||
|
@@ -309,12 +309,7 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
|
|||||||
|
|
||||||
instance.internalInstance()->initialize(instance.m_nodeInstance, instanceContainer.metaFlags());
|
instance.internalInstance()->initialize(instance.m_nodeInstance, instanceContainer.metaFlags());
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1)
|
|
||||||
// Handle hidden state to initialize pickable state
|
|
||||||
nodeInstanceServer->handleInstanceHidden(instance, false, false);
|
|
||||||
#else
|
|
||||||
nodeInstanceServer->handlePickTarget(instance);
|
nodeInstanceServer->handlePickTarget(instance);
|
||||||
#endif
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,8 @@ class QStyleOptionGraphicsItem;
|
|||||||
class QQmlContext;
|
class QQmlContext;
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class QGraphicsTransform;
|
class QGraphicsTransform;
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QQuickItemGrabResult;
|
class QQuickItemGrabResult;
|
||||||
#endif
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -46,11 +44,7 @@ namespace Internal {
|
|||||||
class ServerNodeInstance
|
class ServerNodeInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
using QHashValueType = size_t;
|
||||||
using QHashValueType = uint;
|
|
||||||
#else
|
|
||||||
using QHashValueType = size_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
friend class NodeInstanceServer;
|
friend class NodeInstanceServer;
|
||||||
friend class Qt4NodeInstanceServer;
|
friend class Qt4NodeInstanceServer;
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
#include <qml2puppet/iconrenderer/iconrenderer.h>
|
|
||||||
#include <qml2puppet/import3d/import3d.h>
|
#include <qml2puppet/import3d/import3d.h>
|
||||||
|
|
||||||
#include <qt5nodeinstanceclientproxy.h>
|
#include <qt5nodeinstanceclientproxy.h>
|
||||||
@@ -73,7 +72,6 @@ void QmlPuppet::populateParser()
|
|||||||
// we're not using the commandline parser but just populating the help text
|
// we're not using the commandline parser but just populating the help text
|
||||||
m_argParser.addOptions(
|
m_argParser.addOptions(
|
||||||
{{"readcapturedstream", "Read captured stream.", "inputStream, [outputStream]"},
|
{{"readcapturedstream", "Read captured stream.", "inputStream, [outputStream]"},
|
||||||
{"rendericon", "Renders icon.", "size, fileName, sourceQml"},
|
|
||||||
{"import3dAsset", "Import 3d asset.", "sourceAsset, outDir, importOptJson"}});
|
{"import3dAsset", "Import 3d asset.", "sourceAsset, outDir, importOptJson"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +97,6 @@ void QmlPuppet::initQmlRunner()
|
|||||||
{
|
{
|
||||||
if (m_coreApp->arguments().count() < 2
|
if (m_coreApp->arguments().count() < 2
|
||||||
|| (m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() < 3)
|
|| (m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() < 3)
|
||||||
|| (m_argParser.isSet("rendericon") && m_coreApp->arguments().count() < 5)
|
|
||||||
|| (m_argParser.isSet("import3dAsset") && m_coreApp->arguments().count() < 6)
|
|| (m_argParser.isSet("import3dAsset") && m_coreApp->arguments().count() < 6)
|
||||||
|| (!m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() < 4)) {
|
|| (!m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() < 4)) {
|
||||||
qDebug() << "Wrong argument count: " << m_coreApp->arguments().count();
|
qDebug() << "Wrong argument count: " << m_coreApp->arguments().count();
|
||||||
@@ -122,14 +119,7 @@ void QmlPuppet::initQmlRunner()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_argParser.isSet("rendericon")) {
|
if (m_argParser.isSet("import3dAsset")) {
|
||||||
int size = m_coreApp->arguments().at(2).toInt();
|
|
||||||
QString iconFileName = m_coreApp->arguments().at(3);
|
|
||||||
QString iconSource = m_coreApp->arguments().at(4);
|
|
||||||
|
|
||||||
m_iconRenderer.reset(new IconRenderer(size, iconFileName, iconSource));
|
|
||||||
m_iconRenderer->setupRender();
|
|
||||||
} else if (m_argParser.isSet("import3dAsset")) {
|
|
||||||
QString sourceAsset = m_coreApp->arguments().at(2);
|
QString sourceAsset = m_coreApp->arguments().at(2);
|
||||||
QString outDir = m_coreApp->arguments().at(3);
|
QString outDir = m_coreApp->arguments().at(3);
|
||||||
QString options = m_coreApp->arguments().at(4);
|
QString options = m_coreApp->arguments().at(4);
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../qmlbase.h"
|
#include "../qmlbase.h"
|
||||||
|
|
||||||
class IconRenderer;
|
|
||||||
class QmlPuppet : public QmlBase
|
class QmlPuppet : public QmlBase
|
||||||
{
|
{
|
||||||
using QmlBase::QmlBase;
|
using QmlBase::QmlBase;
|
||||||
@@ -15,7 +14,4 @@ private:
|
|||||||
void populateParser() override;
|
void populateParser() override;
|
||||||
int startTestMode() override;
|
int startTestMode() override;
|
||||||
void initQmlRunner() override;
|
void initQmlRunner() override;
|
||||||
|
|
||||||
private:
|
|
||||||
QSharedPointer<IconRenderer> m_iconRenderer;
|
|
||||||
};
|
};
|
||||||
|
@@ -41,10 +41,6 @@
|
|||||||
#include <private/qquick3drepeater_p.h>
|
#include <private/qquick3drepeater_p.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
#include <private/qqmlvaluetype_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -56,93 +52,9 @@ bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName)
|
|||||||
return QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName);
|
return QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
|
|
||||||
static void addToPropertyNameListIfNotBlackListed(
|
|
||||||
PropertyNameList *propertyNameList, const QQuickDesignerSupport::PropertyName &propertyName)
|
|
||||||
{
|
|
||||||
if (!QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName))
|
|
||||||
propertyNameList->append(propertyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyNameList allPropertyNamesInline(QObject *object,
|
|
||||||
const PropertyName &baseName = {},
|
|
||||||
QObjectList *inspectedObjects = nullptr,
|
|
||||||
int depth = 0)
|
|
||||||
{
|
|
||||||
QQuickDesignerSupport::PropertyNameList propertyNameList;
|
|
||||||
|
|
||||||
QObjectList localObjectList;
|
|
||||||
|
|
||||||
if (inspectedObjects == nullptr)
|
|
||||||
inspectedObjects = &localObjectList;
|
|
||||||
|
|
||||||
if (depth > 2)
|
|
||||||
return propertyNameList;
|
|
||||||
|
|
||||||
if (!inspectedObjects->contains(object))
|
|
||||||
inspectedObjects->append(object);
|
|
||||||
|
|
||||||
const QMetaObject *metaObject = object->metaObject();
|
|
||||||
|
|
||||||
QStringList deferredPropertyNames;
|
|
||||||
const int namesIndex = metaObject->indexOfClassInfo("DeferredPropertyNames");
|
|
||||||
if (namesIndex != -1) {
|
|
||||||
QMetaClassInfo classInfo = metaObject->classInfo(namesIndex);
|
|
||||||
deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < metaObject->propertyCount(); ++index) {
|
|
||||||
QMetaProperty metaProperty = metaObject->property(index);
|
|
||||||
QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name()));
|
|
||||||
if (declarativeProperty.isValid()
|
|
||||||
&& declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) {
|
|
||||||
if (declarativeProperty.name() != QLatin1String("parent")
|
|
||||||
&& !deferredPropertyNames.contains(declarativeProperty.name())) {
|
|
||||||
QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read());
|
|
||||||
if (childObject)
|
|
||||||
propertyNameList.append(
|
|
||||||
allPropertyNamesInline(childObject,
|
|
||||||
baseName
|
|
||||||
+ QQuickDesignerSupport::PropertyName(
|
|
||||||
metaProperty.name())
|
|
||||||
+ '.',
|
|
||||||
inspectedObjects,
|
|
||||||
depth + 1));
|
|
||||||
}
|
|
||||||
} else if (QQmlGadgetPtrWrapper *valueType = QQmlGadgetPtrWrapper::instance(
|
|
||||||
qmlEngine(object), metaProperty.typeId())) {
|
|
||||||
valueType->setValue(metaProperty.read(object));
|
|
||||||
propertyNameList.append(baseName
|
|
||||||
+ QQuickDesignerSupport::PropertyName(metaProperty.name()));
|
|
||||||
propertyNameList.append(
|
|
||||||
allPropertyNamesInline(valueType,
|
|
||||||
baseName
|
|
||||||
+ QQuickDesignerSupport::PropertyName(metaProperty.name())
|
|
||||||
+ '.',
|
|
||||||
inspectedObjects,
|
|
||||||
depth + 1));
|
|
||||||
} else {
|
|
||||||
addToPropertyNameListIfNotBlackListed(&propertyNameList,
|
|
||||||
baseName
|
|
||||||
+ QQuickDesignerSupport::PropertyName(
|
|
||||||
metaProperty.name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return propertyNameList;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PropertyNameList allPropertyNames(QObject *object)
|
PropertyNameList allPropertyNames(QObject *object)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
return QQuickDesignerSupportProperties::allPropertyNames(object);
|
return QQuickDesignerSupportProperties::allPropertyNames(object);
|
||||||
#elif QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
|
||||||
return allPropertyNamesInline(object);
|
|
||||||
#else
|
|
||||||
return QQuickDesignerSupportProperties::allPropertyNames(object);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyNameList propertyNameListForWritableProperties(QObject *object)
|
PropertyNameList propertyNameListForWritableProperties(QObject *object)
|
||||||
@@ -204,15 +116,10 @@ static bool isConnections(QObject *object)
|
|||||||
// This is used in share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
|
// This is used in share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
|
||||||
QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
|
QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
|
|
||||||
QTypeRevision revision = QTypeRevision::zero();
|
QTypeRevision revision = QTypeRevision::zero();
|
||||||
if (majorNumber > 0)
|
if (majorNumber > 0)
|
||||||
revision = QTypeRevision::fromVersion(majorNumber, minorNumber);
|
revision = QTypeRevision::fromVersion(majorNumber, minorNumber);
|
||||||
return QQuickDesignerSupportItems::createPrimitive(typeName, revision, context);
|
return QQuickDesignerSupportItems::createPrimitive(typeName, revision, context);
|
||||||
#else
|
|
||||||
return QQuickDesignerSupportItems::createPrimitive(typeName, majorNumber, minorNumber, context);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString qmlDesignerRCPath()
|
static QString qmlDesignerRCPath()
|
||||||
@@ -347,21 +254,13 @@ void emitComponentComplete(QObject *item)
|
|||||||
|
|
||||||
QQmlData *data = QQmlData::get(item);
|
QQmlData *data = QQmlData::get(item);
|
||||||
if (data && data->context) {
|
if (data && data->context) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
QQmlComponentAttached *componentAttached = data->context->componentAttached;
|
|
||||||
#else
|
|
||||||
QQmlComponentAttached *componentAttached = data->context->componentAttacheds();
|
QQmlComponentAttached *componentAttached = data->context->componentAttacheds();
|
||||||
#endif
|
|
||||||
while (componentAttached) {
|
while (componentAttached) {
|
||||||
if (componentAttached->parent())
|
if (componentAttached->parent()) {
|
||||||
if (componentAttached->parent() == item)
|
if (componentAttached->parent() == item)
|
||||||
emit componentAttached->completed();
|
emit componentAttached->completed();
|
||||||
|
}
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
componentAttached = componentAttached->next;
|
|
||||||
#else
|
|
||||||
componentAttached = componentAttached->next();
|
componentAttached = componentAttached->next();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,12 +451,8 @@ bool isSubclassOf(QObject *object, const QByteArray &superTypeName)
|
|||||||
|
|
||||||
void getPropertyCache(QObject *object, QQmlEngine *engine)
|
void getPropertyCache(QObject *object, QQmlEngine *engine)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
|
||||||
QQuickDesignerSupportProperties::getPropertyCache(object, engine);
|
|
||||||
#else
|
|
||||||
Q_UNUSED(engine);
|
Q_UNUSED(engine);
|
||||||
QQuickDesignerSupportProperties::getPropertyCache(object);
|
QQuickDesignerSupportProperties::getPropertyCache(object);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &))
|
void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &))
|
||||||
|
@@ -27,16 +27,9 @@ namespace QmlPrivateGate {
|
|||||||
class ComponentCompleteDisabler
|
class ComponentCompleteDisabler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
|
|
||||||
ComponentCompleteDisabler();
|
ComponentCompleteDisabler();
|
||||||
|
|
||||||
~ComponentCompleteDisabler();
|
~ComponentCompleteDisabler();
|
||||||
#else
|
|
||||||
ComponentCompleteDisabler()
|
|
||||||
{
|
|
||||||
//nothing not available yet
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name);
|
void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name);
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
<file>images/non-visual-component@2x.png</file>
|
<file>images/non-visual-component@2x.png</file>
|
||||||
<file>mockfiles/Window.qml</file>
|
<file>mockfiles/Window.qml</file>
|
||||||
<file>mockfiles/SwipeView.qml</file>
|
<file>mockfiles/SwipeView.qml</file>
|
||||||
<file>mockfiles/GenericBackend.qml</file>
|
|
||||||
<file>mockfiles/Dialog.qml</file>
|
<file>mockfiles/Dialog.qml</file>
|
||||||
<file>mockfiles/ToolBarButton.qml</file>
|
<file>mockfiles/ToolBarButton.qml</file>
|
||||||
<file>mockfiles/ToggleButton.qml</file>
|
<file>mockfiles/ToggleButton.qml</file>
|
||||||
|
Reference in New Issue
Block a user