From eff39cbc5a726aea37112237257fc722abf0359f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Tue, 10 Dec 2019 17:29:12 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@669 a8b55f48-bf90-11e4-a774-851b48703e85 --- qglengine/widgets/primitiveeditor.cpp | 72 ++++++---- qglengine/widgets/primitiveeditor.h | 5 +- qglengine/widgets/primitiveeditor.ui | 182 +++++++++++++++++++++++++- 3 files changed, 232 insertions(+), 27 deletions(-) diff --git a/qglengine/widgets/primitiveeditor.cpp b/qglengine/widgets/primitiveeditor.cpp index 4b97f22..5b0c3f2 100644 --- a/qglengine/widgets/primitiveeditor.cpp +++ b/qglengine/widgets/primitiveeditor.cpp @@ -57,23 +57,12 @@ PrimitiveEditor::~PrimitiveEditor() { void PrimitiveEditor::assignQGLView(QGLView * v) { view = v; -// connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); -// connect(view, SIGNAL(objectsPositionChanged()), this, SLOT(selectionChanged())); -// connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(selectionChanged())); -// selectionChanged(); + connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); + selectionChanged(); } -void PrimitiveEditor::showEditors() { - foreach (QWidget * w, all_editors) w->hide(); - PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex(); - QList wds = editors[pt]; - foreach (QWidget * w, wds) w->show(); -} - - -void PrimitiveEditor::on_buttonAdd_clicked() { - if (!view) return; +Mesh * PrimitiveEditor::createMesh() { Mesh * m = 0; PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex(); switch (pt) { @@ -119,20 +108,55 @@ void PrimitiveEditor::on_buttonAdd_clicked() { ui->spinRadius2->value(), ui->spinAngle->value()); break; + default: return 0; } - if (m) { - if (ui->flipNormals->isChecked()) m->flipNormals(); - ObjectBase * o = new ObjectBase(m); - o->setColor(ui->colorButton->color()); - o->setName(ui->comboPrimitives->currentText()); - view->scene()->addObject(o); - view->scene()->selectObject(o); - delete m; - } + if (ui->flipNormals->isChecked()) + m->flipNormals(); + return m; +} + + +void PrimitiveEditor::showEditors() { + foreach (QWidget * w, all_editors) w->hide(); + PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex(); + QList wds = editors[pt]; + foreach (QWidget * w, wds) w->show(); +} + + +void PrimitiveEditor::selectionChanged() { + ObjectBase * so = view->selectedObject(); + bool has_1 = so; + ui->buttonReplace->setEnabled(has_1); +} + + +void PrimitiveEditor::replaceMesh() { + if (!view) return; + if (!ui->buttonReplace->isEnabled() || !ui->buttonReplace->isChecked()) return; + ObjectBase * so = view->selectedObject(); + if (!so) return; + Mesh * m = createMesh(); + if (!m) return; + so->setMesh(m); + delete m; + +} + + +void PrimitiveEditor::on_buttonAdd_clicked() { + if (!view) return; + Mesh * m = createMesh(); + if (!m) return; + ObjectBase * o = new ObjectBase(m); + o->setColor(ui->colorButton->color()); + o->setName(ui->comboPrimitives->currentText()); + view->scene()->addObject(o); + view->scene()->selectObject(o); + delete m; } void PrimitiveEditor::on_comboPrimitives_currentIndexChanged(int index) { showEditors(); } - diff --git a/qglengine/widgets/primitiveeditor.h b/qglengine/widgets/primitiveeditor.h index 0d18570..ef34b7c 100644 --- a/qglengine/widgets/primitiveeditor.h +++ b/qglengine/widgets/primitiveeditor.h @@ -30,8 +30,7 @@ public: void assignQGLView(QGLView * v); protected: - - + Mesh * createMesh(); void showEditors(); Ui::PrimitiveEditor *ui; @@ -40,6 +39,8 @@ protected: QList all_editors; private slots: + void selectionChanged(); + void replaceMesh(); void on_buttonAdd_clicked(); void on_comboPrimitives_currentIndexChanged(int index); }; diff --git a/qglengine/widgets/primitiveeditor.ui b/qglengine/widgets/primitiveeditor.ui index eff9f93..5501ffa 100644 --- a/qglengine/widgets/primitiveeditor.ui +++ b/qglengine/widgets/primitiveeditor.ui @@ -439,5 +439,185 @@ - + + + spinWidth + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 331 + 51 + + + 368 + 45 + + + + + spinLength + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 330 + 84 + + + 369 + 82 + + + + + spinHeight + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 334 + 116 + + + 366 + 114 + + + + + spinRadius + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 332 + 144 + + + 370 + 145 + + + + + spinRadius2 + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 334 + 186 + + + 371 + 181 + + + + + spinAngle + valueChanged(double) + PrimitiveEditor + replaceMesh() + + + 335 + 210 + + + 372 + 213 + + + + + spinSegments + valueChanged(int) + PrimitiveEditor + replaceMesh() + + + 329 + 246 + + + 370 + 247 + + + + + spinSegments2 + valueChanged(int) + PrimitiveEditor + replaceMesh() + + + 336 + 284 + + + 372 + 279 + + + + + flipNormals + toggled(bool) + PrimitiveEditor + replaceMesh() + + + 70 + 344 + + + 370 + 341 + + + + + comboPrimitives + currentIndexChanged(int) + PrimitiveEditor + replaceMesh() + + + 348 + 9 + + + 367 + 9 + + + + + buttonReplace + clicked() + PrimitiveEditor + replaceMesh() + + + 340 + 529 + + + 367 + 524 + + + + + + replaceMesh() +