Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/3dview/viewer3d.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
53 | auto format = QSurfaceFormat(); | 53 | auto format = QSurfaceFormat(); | ||
54 | format.setVersion(3, 1); | 54 | format.setVersion(3, 1); | ||
55 | format.setProfile(QSurfaceFormat::CoreProfile); | 55 | format.setProfile(QSurfaceFormat::CoreProfile); | ||
56 | _view->setFormat(format); | 56 | _view->setFormat(format); | ||
57 | 57 | | |||
58 | _view->rootContext()->setContextProperty("viewer3d", this); | 58 | _view->rootContext()->setContextProperty("viewer3d", this); | ||
59 | _view->setResizeMode(QQuickView::SizeRootObjectToView); | 59 | _view->setResizeMode(QQuickView::SizeRootObjectToView); | ||
60 | _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); | 60 | _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); | ||
61 | QHBoxLayout *mainLayout = new QHBoxLayout; | 61 | auto mainLayout = new QHBoxLayout; | ||
62 | mainLayout->addWidget(QWidget::createWindowContainer(_view)); | 62 | mainLayout->addWidget(QWidget::createWindowContainer(_view)); | ||
63 | QObject *item = _view->rootObject(); | 63 | QObject *item = _view->rootObject(); | ||
64 | //Connect the drop pass from the QML part. | 64 | //Connect the drop pass from the QML part. | ||
65 | connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); | 65 | connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); | ||
66 | this->setLayout(mainLayout); | 66 | this->setLayout(mainLayout); | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | Viewer3D::~Viewer3D() | | |||
70 | { | | |||
71 | } | | |||
72 | | ||||
73 | void Viewer3D::dropCatch(const QVariant &var) | 69 | void Viewer3D::dropCatch(const QVariant &var) | ||
74 | { | 70 | { | ||
75 | emit droppedUrls(var.value<QList<QUrl> >()); | 71 | emit droppedUrls(var.value<QList<QUrl> >()); | ||
76 | } | 72 | } | ||
77 | 73 | | |||
78 | void Viewer3D::drawModel(QString file) | 74 | void Viewer3D::drawModel(const QString &file) | ||
79 | { | 75 | { | ||
80 | QObject *object = _view->rootObject(); | 76 | QObject *object = _view->rootObject(); | ||
81 | QObject *fileName = object->findChild<QObject *>(QStringLiteral("fileName")); | 77 | auto fileName = object->findChild<QObject *>(QStringLiteral("fileName")); | ||
82 | fileName->setProperty("text", QVariant(file)); | 78 | fileName->setProperty("text", QVariant(file)); | ||
83 | } | 79 | } | ||
84 | 80 | | |||
85 | void Viewer3D::setBedSize(const QSize &newBedSize) | 81 | void Viewer3D::setBedSize(const QSize &newBedSize) | ||
86 | { | 82 | { | ||
87 | if (newBedSize != _bedSize) { | 83 | if (newBedSize != _bedSize) { | ||
88 | _bedSize = newBedSize; | 84 | _bedSize = newBedSize; | ||
89 | emit bedSizeChanged(_bedSize); | 85 | emit bedSizeChanged(_bedSize); | ||
90 | } | 86 | } | ||
91 | } | 87 | } | ||
92 | 88 | | |||
93 | QSize Viewer3D::bedSize() | 89 | QSize Viewer3D::bedSize() | ||
94 | { | 90 | { | ||
95 | return _bedSize; | 91 | return _bedSize; | ||
96 | } | 92 | } |