git-svn-id: svn://db.shs.com.ru/libs@660 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -88,6 +88,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
|
|||||||
sceneTree->assignQGLView(view->view());
|
sceneTree->assignQGLView(view->view());
|
||||||
matEditor->assignQGLView(view->view());
|
matEditor->assignQGLView(view->view());
|
||||||
objectEditor->assignQGLView(view->view());
|
objectEditor->assignQGLView(view->view());
|
||||||
|
primitiveEditor->assignQGLView(view->view());
|
||||||
|
|
||||||
session.load();
|
session.load();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,52 @@
|
|||||||
#include "primitiveeditor.h"
|
#include "primitiveeditor.h"
|
||||||
#include "ui_primitiveeditor.h"
|
#include "ui_primitiveeditor.h"
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include "glprimitives.h"
|
||||||
|
#include "glmesh.h"
|
||||||
|
|
||||||
|
|
||||||
PrimitiveEditor::PrimitiveEditor(QWidget *parent) : QWidget(parent), ui(new Ui::PrimitiveEditor) {
|
PrimitiveEditor::PrimitiveEditor(QWidget *parent) : QWidget(parent), ui(new Ui::PrimitiveEditor) {
|
||||||
|
view = 0;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
editors[Plane] << ui->widgetWidth;
|
||||||
|
editors[Plane] << ui->widgetLength;
|
||||||
|
editors[Cube] << ui->widgetWidth;
|
||||||
|
editors[Cube] << ui->widgetLength;
|
||||||
|
editors[Cube] << ui->widgetHeight;
|
||||||
|
editors[Ellipsoid] << ui->widgetWidth;
|
||||||
|
editors[Ellipsoid] << ui->widgetLength;
|
||||||
|
editors[Ellipsoid] << ui->widgetHeight;
|
||||||
|
editors[Ellipsoid] << ui->widgetSegments;
|
||||||
|
editors[Ellipsoid] << ui->widgetSegments2;
|
||||||
|
editors[Disc] << ui->widgetWidth;
|
||||||
|
editors[Disc] << ui->widgetLength;
|
||||||
|
editors[Disc] << ui->widgetSegments;
|
||||||
|
editors[Disc] << ui->widgetAngle;
|
||||||
|
editors[Cone] << ui->widgetWidth;
|
||||||
|
editors[Cone] << ui->widgetLength;
|
||||||
|
editors[Cone] << ui->widgetHeight;
|
||||||
|
editors[Cone] << ui->widgetSegments;
|
||||||
|
editors[Cylinder] << ui->widgetWidth;
|
||||||
|
editors[Cylinder] << ui->widgetLength;
|
||||||
|
editors[Cylinder] << ui->widgetHeight;
|
||||||
|
editors[Cylinder] << ui->widgetSegments;
|
||||||
|
editors[Torus] << ui->widgetRadius1;
|
||||||
|
editors[Torus] << ui->widgetRadius2;
|
||||||
|
editors[Torus] << ui->widgetSegments;
|
||||||
|
editors[Torus] << ui->widgetSegments2;
|
||||||
|
editors[Torus] << ui->widgetAngle;
|
||||||
|
QSet<QWidget *> all;
|
||||||
QMetaEnum me = metaObject()->enumerator(0);
|
QMetaEnum me = metaObject()->enumerator(0);
|
||||||
for (int i=0; i<me.keyCount(); ++i)
|
for (int i=0; i<me.keyCount(); ++i) {
|
||||||
ui->comboPrimitives->addItem(me.key(i));
|
ui->comboPrimitives->addItem(me.key(i));
|
||||||
|
all.unite(editors[(PrimitiveType)me.value(i)].toSet());
|
||||||
|
}
|
||||||
|
all_editors = all.toList();
|
||||||
|
foreach (QWidget * w, all_editors) {
|
||||||
|
if (w->layout()) w->layout()->setContentsMargins(0, layout()->spacing(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->comboPrimitives->setCurrentIndex(Plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -22,9 +60,78 @@ void PrimitiveEditor::assignQGLView(QGLView * v) {
|
|||||||
// connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
// connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||||
// connect(view, SIGNAL(objectsPositionChanged()), this, SLOT(selectionChanged()));
|
// connect(view, SIGNAL(objectsPositionChanged()), this, SLOT(selectionChanged()));
|
||||||
// connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(selectionChanged()));
|
// connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(selectionChanged()));
|
||||||
// selectionChanged();
|
// selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrimitiveEditor::showEditors() {
|
void PrimitiveEditor::showEditors() {
|
||||||
|
foreach (QWidget * w, all_editors) w->hide();
|
||||||
|
PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex();
|
||||||
|
QList<QWidget *> wds = editors[pt];
|
||||||
|
foreach (QWidget * w, wds) w->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrimitiveEditor::on_buttonAdd_clicked() {
|
||||||
|
if (!view) return;
|
||||||
|
Mesh * m = 0;
|
||||||
|
PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex();
|
||||||
|
switch (pt) {
|
||||||
|
case Plane:
|
||||||
|
m = Primitive::plane(ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value());
|
||||||
|
break;
|
||||||
|
case Cube:
|
||||||
|
m = Primitive::cube(ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value(),
|
||||||
|
ui->spinHeight->value());
|
||||||
|
break;
|
||||||
|
case Ellipsoid:
|
||||||
|
m = Primitive::ellipsoid(ui->spinSegments->value(),
|
||||||
|
ui->spinSegments2->value(),
|
||||||
|
ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value(),
|
||||||
|
ui->spinHeight->value());
|
||||||
|
break;
|
||||||
|
case Disc:
|
||||||
|
m = Primitive::disc(ui->spinSegments->value(),
|
||||||
|
ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value(),
|
||||||
|
true,
|
||||||
|
ui->spinAngle->value());
|
||||||
|
break;
|
||||||
|
case Cone:
|
||||||
|
m = Primitive::cone(ui->spinSegments->value(),
|
||||||
|
ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value(),
|
||||||
|
ui->spinHeight->value());
|
||||||
|
break;
|
||||||
|
case Cylinder:
|
||||||
|
m = Primitive::cylinder(ui->spinSegments->value(),
|
||||||
|
ui->spinWidth->value(),
|
||||||
|
ui->spinLength->value(),
|
||||||
|
ui->spinHeight->value());
|
||||||
|
break;
|
||||||
|
case Torus:
|
||||||
|
m = Primitive::torus(ui->spinSegments->value(),
|
||||||
|
ui->spinSegments2->value(),
|
||||||
|
ui->spinRadius->value(),
|
||||||
|
ui->spinRadius2->value(),
|
||||||
|
ui->spinAngle->value());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrimitiveEditor::on_comboPrimitives_currentIndexChanged(int index) {
|
||||||
|
showEditors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public:
|
|||||||
Plane,
|
Plane,
|
||||||
Cube,
|
Cube,
|
||||||
Ellipsoid,
|
Ellipsoid,
|
||||||
|
Disc,
|
||||||
|
Cone,
|
||||||
|
Cylinder,
|
||||||
|
Torus
|
||||||
};
|
};
|
||||||
Q_ENUMS(PrimitiveType)
|
Q_ENUMS(PrimitiveType)
|
||||||
|
|
||||||
@@ -33,7 +37,11 @@ protected:
|
|||||||
Ui::PrimitiveEditor *ui;
|
Ui::PrimitiveEditor *ui;
|
||||||
QGLView * view;
|
QGLView * view;
|
||||||
QMap<PrimitiveType, QList<QWidget *> > editors;
|
QMap<PrimitiveType, QList<QWidget *> > editors;
|
||||||
|
QList<QWidget *> all_editors;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonAdd_clicked();
|
||||||
|
void on_comboPrimitives_currentIndexChanged(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,47 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>575</width>
|
<width>360</width>
|
||||||
<height>608</height>
|
<height>536</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="EComboBox" name="comboPrimitives"/>
|
<widget class="EComboBox" name="comboPrimitives"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widgetRows" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widgetWidth" native="true">
|
<widget class="QWidget" name="widgetWidth" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
@@ -231,7 +261,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinSegments">
|
<widget class="QSpinBox" name="spinSegments">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>2</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>1000</number>
|
<number>1000</number>
|
||||||
@@ -272,7 +302,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinSegments2">
|
<widget class="QSpinBox" name="spinSegments2">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>2</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>1000</number>
|
<number>1000</number>
|
||||||
@@ -291,6 +321,42 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widgetColor" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="ColorButton" name="colorButton">
|
||||||
|
<property name="color">
|
||||||
|
<color>
|
||||||
|
<red>255</red>
|
||||||
|
<green>255</green>
|
||||||
|
<blue>255</blue>
|
||||||
|
</color>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="flipNormals">
|
<widget class="QCheckBox" name="flipNormals">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -306,7 +372,7 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>220</height>
|
<height>176</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
@@ -356,6 +422,11 @@
|
|||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>spinslider.h</header>
|
<header>spinslider.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ColorButton</class>
|
||||||
|
<extends>QPushButton</extends>
|
||||||
|
<header>colorbutton.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>EComboBox</class>
|
<class>EComboBox</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
|
|||||||
Reference in New Issue
Block a user