Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/3dview/linemesh.cpp
Show All 15 Lines | 1 | /* Atelier KDE Printer Host for 3D Printing | |||
---|---|---|---|---|---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | 17 | GNU General Public License for more details. | ||
18 | 18 | | |||
19 | You should have received a copy of the GNU General Public License | 19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include <QGeometryRenderer> | 23 | #include <QGeometryRenderer> | ||
24 | #include <QVector3D> | | |||
25 | #include <QVector4D> | 24 | #include <QVector4D> | ||
26 | #include "gcodeto4d.h" | 25 | #include "gcodeto4d.h" | ||
27 | #include "linemesh.h" | 26 | #include "linemesh.h" | ||
28 | #include "linemeshgeometry.h" | 27 | #include "linemeshgeometry.h" | ||
29 | 28 | | |||
30 | LineMesh::LineMesh(Qt3DCore::QNode *parent) : | 29 | LineMesh::LineMesh(Qt3DCore::QNode *parent) : | ||
31 | Qt3DRender::QGeometryRenderer(parent) | 30 | Qt3DRender::QGeometryRenderer(parent) | ||
32 | , _lineMeshGeo(nullptr) | 31 | , _lineMeshGeo(nullptr) | ||
Show All 28 Lines | 57 | { | |||
61 | std::transform(pos.cbegin(), pos.cend(), | 60 | std::transform(pos.cbegin(), pos.cend(), | ||
62 | std::back_inserter(vertices), | 61 | std::back_inserter(vertices), | ||
63 | [] (const QVector4D &x) { return x.toVector3D(); }); | 62 | [] (const QVector4D &x) { return x.toVector3D(); }); | ||
64 | 63 | | |||
65 | _lineMeshGeo = new LineMeshGeometry(vertices, this); | 64 | _lineMeshGeo = new LineMeshGeometry(vertices, this); | ||
66 | setVertexCount(_lineMeshGeo->vertexCount()); | 65 | setVertexCount(_lineMeshGeo->vertexCount()); | ||
67 | setGeometry(_lineMeshGeo); | 66 | setGeometry(_lineMeshGeo); | ||
68 | emit finished(); | 67 | emit finished(); | ||
68 | emit centerChanged(center()); | ||||
69 | } | ||||
70 | | ||||
71 | QVector3D LineMesh::center() | ||||
72 | { | ||||
73 | return _lineMeshGeo ? _lineMeshGeo->center() : QVector3D(); | ||||
69 | } | 74 | } |