1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include <qwidget.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qcolor.h>
#include <qfont.h>
#include <qnamespace.h>
// language file
//#include "language.h"
// end language include(s)
#include "render2d.h"
#include "fixeddialog.h"
FixedDialog::FixedDialog(QWidget *parent, QString name) :
QDialog(parent, name, TRUE)
{
QPushButton *ok, *cancel, *def1;
QLabel *t1, *t2, *t3, *t4;
setBackgroundColor(lightGray);
setCaption( tr("Set fixed angle and length") );
t1 = new QLabel( tr("Bond fixed length:"), this);
t1->setGeometry(10,10,130,30);
t1->setBackgroundColor(lightGray);
t2 = new QLabel( tr("Bond fixed angle:"), this);
t2->setGeometry(10,50,130,30);
t2->setBackgroundColor(lightGray);
bond_length = new QLineEdit(this);
bond_length->setGeometry(150,10,170,30);
bond_angle = new QLineEdit(this);
bond_angle->setGeometry(150,50,170,30);
t3 = new QLabel( tr("Arrow fixed length:"), this);
t3->setGeometry(10,90,130,30);
t3->setBackgroundColor(lightGray);
t4 = new QLabel( tr("Arrow fixed angle:"), this);
t4->setGeometry(10,130,130,30);
t4->setBackgroundColor(lightGray);
arrow_length = new QLineEdit(this);
arrow_length->setGeometry(150,90,170,30);
arrow_angle = new QLineEdit(this);
arrow_angle->setGeometry(150,130,170,30);
ok = new QPushButton( tr("OK"), this);
ok->setGeometry(10,170,100,30);
ok->setPalette(QPalette(lightGray));
connect(ok, SIGNAL(clicked()), SLOT(accept()) );
cancel = new QPushButton( tr("Cancel"), this);
cancel->setGeometry(230,170,100,30);
cancel->setPalette(QPalette(lightGray));
connect(cancel, SIGNAL(clicked()), SLOT(reject()) );
def1 = new QPushButton( tr("Default"), this);
def1->setGeometry(120,170,100,30);
def1->setPalette(QPalette(lightGray));
connect(def1, SIGNAL(clicked()), SLOT(setDefaults()) );
}
void FixedDialog::setDefaults() {
QString n;
n.setNum(25);
bond_length->setText(n);
n.setNum(15);
bond_angle->setText(n);
n.setNum(50);
arrow_length->setText(n);
n.setNum(15);
arrow_angle->setText(n);
}
void FixedDialog::setLength_bond(double t)
{
QString n;
n.setNum(t);
bond_length->setText(n);
}
void FixedDialog::setAngle_bond(double t)
{
QString n;
n.setNum(t);
bond_angle->setText(n);
}
double FixedDialog::getLength_bond(void)
{
double t;
bool b;
t = bond_length->text().toDouble(&b);
if (b == true)
return t;
return -1.0;
}
double FixedDialog::getAngle_bond(void)
{
double t;
bool b;
t = bond_angle->text().toDouble(&b);
if (b == true)
return t;
return -1.0;
}
void FixedDialog::setLength_arrow(double t)
{
QString n;
n.setNum(t);
arrow_length->setText(n);
}
void FixedDialog::setAngle_arrow(double t)
{
QString n;
n.setNum(t);
arrow_angle->setText(n);
}
double FixedDialog::getLength_arrow(void)
{
double t;
bool b;
t = arrow_length->text().toDouble(&b);
if (b == true)
return t;
return -1.0;
}
double FixedDialog::getAngle_arrow(void)
{
double t;
bool b;
t = arrow_angle->text().toDouble(&b);
if (b == true)
return t;
return -1.0;
}
|