Index: src/widgets/3dview/gridmesh.h =================================================================== --- src/widgets/3dview/gridmesh.h +++ src/widgets/3dview/gridmesh.h @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing - Copyright (C) <2017> + 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 @@ -18,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #pragma once #include Index: src/widgets/3dview/gridmesh.cpp =================================================================== --- src/widgets/3dview/gridmesh.cpp +++ src/widgets/3dview/gridmesh.cpp @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing - Copyright (C) <2017> + 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 @@ -18,8 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include -#include #include #include #include "gridmesh.h" @@ -33,13 +34,13 @@ setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines); QVector2D s(20, 20); - QList vertices; + QList vertices; for (uint i = 0; i <= s.x(); i++) { for (uint j = 0; j <= s.y(); j++) { - vertices.append(QVector4D(i, 0, 0, 0)); - vertices.append(QVector4D(i, j, 0, 0)); - vertices.append(QVector4D(0, j, 0, 0)); - vertices.append(QVector4D(i, j, 0, 0)); + vertices.append(QVector3D(i, 0, 0)); + vertices.append(QVector3D(i, j, 0)); + vertices.append(QVector3D(0, j, 0)); + vertices.append(QVector3D(i, j, 0)); } } Index: src/widgets/3dview/linemesh.h =================================================================== --- src/widgets/3dview/linemesh.h +++ src/widgets/3dview/linemesh.h @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #pragma once #include @@ -28,7 +29,6 @@ class LineMeshGeometry; class QString; -class QVector4D; class LineMesh : public Qt3DRender::QGeometryRenderer { @@ -48,5 +48,4 @@ private: GcodeTo4D _gcode; LineMeshGeometry *_lineMeshGeo; - QList _vertices; }; Index: src/widgets/3dview/linemesh.cpp =================================================================== --- src/widgets/3dview/linemesh.cpp +++ src/widgets/3dview/linemesh.cpp @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing - Copyright (C) <2017> + 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 @@ -18,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include #include @@ -54,8 +56,15 @@ void LineMesh::posUpdate(const QList &pos) { - _vertices = pos; - _lineMeshGeo = new LineMeshGeometry(_vertices, this); + QList vertices; + vertices.reserve(pos.size()); + std::transform(pos.cbegin(), pos.cend(), + std::back_inserter(vertices), + [](const QVector4D & x) { + return x.toVector3D(); + }); + + _lineMeshGeo = new LineMeshGeometry(vertices, this); setVertexCount(_lineMeshGeo->vertexCount()); setGeometry(_lineMeshGeo); emit finished(); Index: src/widgets/3dview/linemeshgeometry.h =================================================================== --- src/widgets/3dview/linemeshgeometry.h +++ src/widgets/3dview/linemeshgeometry.h @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing - Copyright (C) <2017> + 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 @@ -18,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #pragma once #include @@ -29,7 +31,7 @@ Q_OBJECT public: - LineMeshGeometry(const QList &vertices, Qt3DCore::QNode *parent = Q_NULLPTR); + LineMeshGeometry(const QList &vertices, Qt3DCore::QNode *parent = Q_NULLPTR); ~LineMeshGeometry(); int vertexCount(); Index: src/widgets/3dview/linemeshgeometry.cpp =================================================================== --- src/widgets/3dview/linemeshgeometry.cpp +++ src/widgets/3dview/linemeshgeometry.cpp @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing - Copyright (C) <2017> + 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 @@ -18,12 +19,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include -#include #include "linemeshgeometry.h" -LineMeshGeometry::LineMeshGeometry(const QList &vertices, Qt3DCore::QNode *parent) : +LineMeshGeometry::LineMeshGeometry(const QList &vertices, Qt3DCore::QNode *parent) : Qt3DRender::QGeometry(parent) , _positionAttribute(new Qt3DRender::QAttribute(this)) , _vertexBuffer(new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, this)) @@ -36,7 +37,7 @@ rawVertexArray[idx++] = v.x(); rawVertexArray[idx++] = v.y(); rawVertexArray[idx++] = v.z(); - _vertices.append(v.toVector3D()); + _vertices.append(v); } _vertexBuffer->setData(vertexBufferData);