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();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ public:
|
||||
void assignQGLView(QGLView * v);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Mesh * createMesh();
|
||||
void showEditors();
|
||||
|
||||
Ui::PrimitiveEditor *ui;
|
||||
@@ -40,6 +39,8 @@ protected:
|
||||
QList<QWidget *> all_editors;
|
||||
|
||||
private slots:
|
||||
void selectionChanged();
|
||||
void replaceMesh();
|
||||
void on_buttonAdd_clicked();
|
||||
void on_comboPrimitives_currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
@@ -439,5 +439,185 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>spinWidth</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>331</x>
|
||||
<y>51</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>368</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinLength</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>330</x>
|
||||
<y>84</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>369</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinHeight</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>366</x>
|
||||
<y>114</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinRadius</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>332</x>
|
||||
<y>144</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
<y>145</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinRadius2</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>186</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>371</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinAngle</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>335</x>
|
||||
<y>210</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>372</x>
|
||||
<y>213</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinSegments</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>329</x>
|
||||
<y>246</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
<y>247</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinSegments2</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>336</x>
|
||||
<y>284</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>372</x>
|
||||
<y>279</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>flipNormals</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>70</x>
|
||||
<y>344</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
<y>341</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>comboPrimitives</sender>
|
||||
<signal>currentIndexChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>348</x>
|
||||
<y>9</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>367</x>
|
||||
<y>9</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonReplace</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>340</x>
|
||||
<y>529</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>367</x>
|
||||
<y>524</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>replaceMesh()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user