// // File: viewpointdialog.cc // // (C) 2000-2006 Helmut Cantzler // // Licensed under the terms of the Lesser General Public License. // #include #include #include #include #include #include #include #include "viewpointdialog.h" DoubleItem::DoubleItem(QTable *t, float l, float h, const float &f) : QTableItem(t, QTableItem::WhenCurrent, QString::number(f)) { low=l; high=h; } QWidget* DoubleItem::createEditor() const { QLineEdit *e = new QLineEdit(table()); e->setValidator( new QDoubleValidator(low, high, 10, e) ); e->setText(text()); return e; } ViewpointDialog::ViewpointDialog(QWidget *parent, GLMesh_Settings *s, const char *name) : QDialog(parent, name, TRUE) { QString string; settings=s; QVBoxLayout *box = new QVBoxLayout(this); box->setMargin(5); box->setSpacing(5); QHBoxLayout *row1 = new QHBoxLayout(box); row1->setMargin(5); row1->setSpacing(5); row1->addWidget( new QLabel("XShift:", this) ); xshift = new QLineEdit(this); xshift->setValidator( new QDoubleValidator(-99.0, 99.0, 10, xshift) ); string.setNum(settings->xShift); xshift->setText(string); xshift->setMaximumWidth(80); row1->addWidget( xshift ); row1->addWidget( new QLabel("YShift:", this) ); yshift = new QLineEdit(this); yshift->setValidator( new QDoubleValidator(-99.0, 99.0, 10, yshift) ); string.setNum(settings->yShift); yshift->setText(string); yshift->setMaximumWidth(80); row1->addWidget(yshift); row1->addWidget( new QLabel("ZShift:", this) ); zshift = new QLineEdit(this); zshift->setValidator( new QDoubleValidator(-99.0, 99.0, 10, zshift) ); string.setNum(settings->zShift); zshift->setText(string); zshift->setMaximumWidth(80); row1->addWidget(zshift); row1->addStretch(0); QHBoxLayout *row2 = new QHBoxLayout(box); row2->setMargin(5); row2->setSpacing(5); row2->addWidget( new QLabel("Clipping:", this) ); clipping = new QLineEdit(this); clipping->setValidator( new QDoubleValidator(-99.0, 99.0, 10, clipping) ); string.setNum(settings->clipping); clipping->setText(string); clipping->setMaximumWidth(80); row2->addWidget( clipping ); row2->addStretch(0); DoubleItem *item; table = new QTable(3, 3, this); for (int i=0; i < 3; i++) for (int j=0; j < 3; j++) { item = new DoubleItem(table, -1.0, 1.0, settings->tb_transform[i][j]); table->setItem(i, j, item); } box->addWidget(table); QWidget *buttons = new QWidget(this); QHBoxLayout *buttons_layout = new QHBoxLayout(buttons); buttons_layout->setMargin(5); buttons_layout->setSpacing(5); QPushButton* cancel = new QPushButton("Cancel", buttons); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); QPushButton* ok = new QPushButton("OK", buttons); connect(ok, SIGNAL(clicked()), this, SLOT(accept())); buttons_layout->addStretch( 10 ); buttons_layout->addWidget( ok ); buttons_layout->addWidget( cancel ); box->addWidget(buttons); setCaption("Set Viewpoint"); } void ViewpointDialog::accept() { settings->xShift=xshift->text().toFloat(); settings->yShift=yshift->text().toFloat(); settings->zShift=zshift->text().toFloat(); settings->clipping=clipping->text().toFloat(); for (int i=0; i < 3; i++) for (int j=0; j < 3; j++) settings->tb_transform[i][j]=table->text(i,j).toFloat(); QDialog::accept(); }