From c5bbf5ef8fb64bed47a0827047b85ca731f63918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Fri, 6 Dec 2019 13:38:17 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@658 a8b55f48-bf90-11e4-a774-851b48703e85 --- qglengine/core/glprimitives.cpp | 13 +- qglengine/qglview.cpp | 2 +- qglengine/qglview_test/qglview_window.cpp | 3 +- qglengine/qglview_test/qglview_window.ui | 33 +- qglengine/widgets/primitiveeditor.cpp | 30 ++ qglengine/widgets/primitiveeditor.h | 40 +++ qglengine/widgets/primitiveeditor.ui | 372 ++++++++++++++++++++++ 7 files changed, 471 insertions(+), 22 deletions(-) create mode 100644 qglengine/widgets/primitiveeditor.cpp create mode 100644 qglengine/widgets/primitiveeditor.h create mode 100644 qglengine/widgets/primitiveeditor.ui diff --git a/qglengine/core/glprimitives.cpp b/qglengine/core/glprimitives.cpp index 106c02f..d0652cd 100644 --- a/qglengine/core/glprimitives.cpp +++ b/qglengine/core/glprimitives.cpp @@ -303,7 +303,18 @@ Mesh * Primitive::torus(int segments_main, int segments_second, float radius_mai } pcnt = v.size(); } - + if (end_angle < 360.) { + Mesh * cap = Primitive::disc(segments_second-1, radius_second * 2, radius_second * 2, true); + cap->rotatePoints(90, 1, 0, 0); + cap->translatePoints(radius_main, 0, 0); + ret->append(cap); + delete cap; + cap = Primitive::disc(segments_second-1, radius_second * 2, radius_second * 2, false); + cap->rotatePoints(90, 1, 0, 0); + cap->translatePoints(radius_main, 0, 0); + cap->rotatePoints(end_angle, 0, 0, 1); + ret->append(cap); + } return ret; } diff --git a/qglengine/qglview.cpp b/qglengine/qglview.cpp index a171e3d..37af806 100644 --- a/qglengine/qglview.cpp +++ b/qglengine/qglview.cpp @@ -89,7 +89,7 @@ QGLView::QGLView(): OpenGLWindow(), renderer_(this), mouse(this) { //camera().aim_ = camera().pos_; ktm_.restart(); - Mesh * m = Primitive::torus(30, 12, 1., 0.1, 90); + Mesh * m = Primitive::torus(100, 40, 1., 0.4, 360); //Mesh * m = Primitive::coneFrame(10, 1, 1., 2.); //QMatrix4x4 mat; //mat.rotate(90, 0,1,0); diff --git a/qglengine/qglview_test/qglview_window.cpp b/qglengine/qglview_test/qglview_window.cpp index fec35e1..e72c9a8 100644 --- a/qglengine/qglview_test/qglview_window.cpp +++ b/qglengine/qglview_test/qglview_window.cpp @@ -23,6 +23,7 @@ #include #include #include +#include "qad_types.h" QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLViewWindow() { @@ -91,7 +92,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView session.load(); - loadFile("axis.DAE.qgl"); + //loadFile("axis.DAE.qgl"); //matEditor->setMaterial(const_cast(view->view()->scene()->rootObject()->child(0))->material()); /*Scene * sc = loadScene("truck.obj"); //view->view()->scene()->addScene(sc); diff --git a/qglengine/qglview_test/qglview_window.ui b/qglengine/qglview_test/qglview_window.ui index a0d11c9..0c6b934 100644 --- a/qglengine/qglview_test/qglview_window.ui +++ b/qglengine/qglview_test/qglview_window.ui @@ -57,7 +57,7 @@ - 1 + 3 @@ -440,8 +440,8 @@ 0 0 - 960 - 737 + 968 + 636 @@ -1079,8 +1079,8 @@ 0 0 - 999 - 853 + 1009 + 877 @@ -1107,17 +1107,11 @@ - Страница + Primitives - - - - 1 - - - + @@ -1169,7 +1163,7 @@ 0 0 1125 - 24 + 21 @@ -1391,11 +1385,6 @@
widgets/object_editor.h
1 - - PropertyEditor - QTreeWidget -
widgets/propertyeditor.h
-
SceneTree QWidget @@ -1408,6 +1397,12 @@
widgets/materials_editor.h
1
+ + PrimitiveEditor + QWidget +
primitiveeditor.h
+ 1 +
diff --git a/qglengine/widgets/primitiveeditor.cpp b/qglengine/widgets/primitiveeditor.cpp new file mode 100644 index 0000000..84b815a --- /dev/null +++ b/qglengine/widgets/primitiveeditor.cpp @@ -0,0 +1,30 @@ +#include "primitiveeditor.h" +#include "ui_primitiveeditor.h" +#include + + +PrimitiveEditor::PrimitiveEditor(QWidget *parent) : QWidget(parent), ui(new Ui::PrimitiveEditor) { + ui->setupUi(this); + QMetaEnum me = metaObject()->enumerator(0); + for (int i=0; icomboPrimitives->addItem(me.key(i)); + +} + + +PrimitiveEditor::~PrimitiveEditor() { + delete ui; +} + + +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(); +} + + +void PrimitiveEditor::showEditors() { +} diff --git a/qglengine/widgets/primitiveeditor.h b/qglengine/widgets/primitiveeditor.h new file mode 100644 index 0000000..437cf0d --- /dev/null +++ b/qglengine/widgets/primitiveeditor.h @@ -0,0 +1,40 @@ +#ifndef PRIMITIVEEDITOR_H +#define PRIMITIVEEDITOR_H + +#include +#include "qglview.h" + + +namespace Ui { +class PrimitiveEditor; +} + + +class PrimitiveEditor : public QWidget { + Q_OBJECT +public: + enum PrimitiveType { + Plane, + Cube, + Ellipsoid, + }; + Q_ENUMS(PrimitiveType) + + explicit PrimitiveEditor(QWidget *parent = nullptr); + ~PrimitiveEditor(); + + void assignQGLView(QGLView * v); + +protected: + + + void showEditors(); + + Ui::PrimitiveEditor *ui; + QGLView * view; + QMap > editors; + +}; + + +#endif // PRIMITIVEEDITOR_H diff --git a/qglengine/widgets/primitiveeditor.ui b/qglengine/widgets/primitiveeditor.ui new file mode 100644 index 0000000..994f6b3 --- /dev/null +++ b/qglengine/widgets/primitiveeditor.ui @@ -0,0 +1,372 @@ + + + PrimitiveEditor + + + + 0 + 0 + 575 + 608 + + + + Form + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Width: + + + + + + + 1.000000000000000 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Length: + + + + + + + 1.000000000000000 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Height + + + + + + + 1.000000000000000 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Radius 1: + + + + + + + 1.000000000000000 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Radius 2: + + + + + + + 1.000000000000000 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Angle: + + + + + + + 360.000000000000000 + + + 360.000000000000000 + + + 4.500000000000000 + + + 90.000000000000000 + + + ° + + + QSlider::TicksAbove + + + 90 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Segments: + + + + + + + 2 + + + 1000 + + + 1 + + + QAbstractSpinBox::AdaptiveDecimalStepType + + + 16 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Segments 2: + + + + + + + 2 + + + 1000 + + + 1 + + + QAbstractSpinBox::AdaptiveDecimalStepType + + + 16 + + + + + + + + + + Flip normals + + + + + + + Qt::Vertical + + + + 20 + 220 + + + + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Replace + + + true + + + + + + + + + + SpinSlider + QWidget +
spinslider.h
+
+ + EComboBox + QComboBox +
ecombobox.h
+
+ + ScrollSpinBox + QWidget +
scroll_spin_box.h
+
+
+ + +