diff --git a/src/widgets/3dview/SceneEntity.qml b/src/widgets/3dview/SceneEntity.qml index 676cd86..bfe27fa 100644 --- a/src/widgets/3dview/SceneEntity.qml +++ b/src/widgets/3dview/SceneEntity.qml @@ -1,76 +1,75 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017-2018> Author: Patrick José Pereira - patrickjp@kde.org Kevin Ottens - ervin@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.7 import Qt3D.Core 2.0 import Qt3D.Render 2.0 import Qt3D.Input 2.0 import Qt3D.Extras 2.0 -import GridMesh 1.0 -import LineMesh 1.0 +import Atelier 1.0 Entity { id: sceneRoot property string currentFile Camera { id: camera projectionType: CameraLens.PerspectiveProjection fieldOfView: 45 aspectRatio: 16/9 nearPlane : 0.01 farPlane : 1000.0 position: Qt.vector3d( 10.0, -10.0, 35.0 ) upVector: Qt.vector3d( 0.0, 0.85, 0.75 ) viewCenter: Qt.vector3d( 10.0, 10.0, 0.0 ) } FirstPersonCameraController { camera: camera } components: [ RenderSettings { activeFrameGraph: ForwardRenderer { camera: camera } }, InputSettings { } ] Entity { id: gridEntity components: [ PhongMaterial { ambient: "darkBlue" }, GridMesh {} ] } Entity { id: lineEntity components: [ PhongMaterial { ambient: "darkGreen" }, LineMesh { readonly property string currentFile: sceneRoot.currentFile onCurrentFileChanged: readAndRun(currentFile) } ] } } diff --git a/src/widgets/3dview/viewer3d.cpp b/src/widgets/3dview/viewer3d.cpp index 39d49dc..3627391 100644 --- a/src/widgets/3dview/viewer3d.cpp +++ b/src/widgets/3dview/viewer3d.cpp @@ -1,69 +1,69 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Patrick José Pereira - patrickjp@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "gridmesh.h" #include "viewer3d.h" #include "linemesh.h" Viewer3D::Viewer3D(QWidget *parent) : QWidget(parent) , _lineMesh(new LineMesh) { Q_INIT_RESOURCE(viewer3d); - qmlRegisterType("GridMesh", 1, 0, "GridMesh"); - qmlRegisterType("LineMesh", 1, 0, "LineMesh"); + qmlRegisterType("Atelier", 1, 0, "GridMesh"); + qmlRegisterType("Atelier", 1, 0, "LineMesh"); _view = new QQuickView(&_engine, nullptr); _view->setResizeMode(QQuickView::SizeRootObjectToView); _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(QWidget::createWindowContainer(_view)); QObject *item = _view->rootObject(); //Connect the drop pass from the QML part. connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); this->setLayout(mainLayout); } Viewer3D::~Viewer3D() { } void Viewer3D::dropCatch(const QVariant &var) { emit droppedUrls(var.value >()); } void Viewer3D::drawModel(QString file) { QObject *object = _view->rootObject(); QObject *fileName = object->findChild(QStringLiteral("fileName")); fileName->setProperty("text", QVariant(file)); } diff --git a/src/widgets/3dview/viewer3d.qml b/src/widgets/3dview/viewer3d.qml index 58b022d..8decbbc 100644 --- a/src/widgets/3dview/viewer3d.qml +++ b/src/widgets/3dview/viewer3d.qml @@ -1,65 +1,64 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017-2018> Author: Patrick José Pereira - patrickjp@kde.org Kevin Ottens - ervin@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Scene3D 2.0 -import LineMesh 1.0 Item { id: item width: 1000 height: 1000 signal droppedUrls (var urls) DropArea { id: dropArea anchors.fill: parent onDropped: if(drop.hasUrls) { droppedUrls(drop.urls) } } Rectangle { id: scene anchors.fill: parent Scene3D { id: scene3d anchors.fill: parent focus: true aspects: ["input", "logic"] cameraAspectRatioMode: Scene3D.AutomaticAspectRatio SceneEntity { id: entity } } } Text { objectName: "fileName" id: fileName text: "" onTextChanged: { entity.currentFile = text } } }