git-svn-id: svn://db.shs.com.ru/libs@669 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -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<QWidget *> 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<QWidget *> 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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user