14 #include <QGridLayout> 16 #include <QDoubleValidator> 17 #include <QPushButton> 28 : QDialog(parent), layout(this), text( tr(msg) ),
29 buttons_layout(this), index(1) {
31 setWindowTitle( tr(title) );
34 const int nb_btn = 2, dft_btn = 1;
35 QDialogButtonBox::StandardButton std_btn[nb_btn]
36 = {QDialogButtonBox::Cancel, QDialogButtonBox::Ok};
38 const char* btn_slots[nb_btn]
39 = {SLOT( reject() ), SLOT( accept() )};
40 for(
int btn_idx = 0; btn_idx < nb_btn; btn_idx++) {
44 btn->setDefault(btn_idx == dft_btn);
46 connect(btn, SIGNAL( clicked() ),
this, btn_slots[btn_idx]);
66 (QWidget* parent,
const char* title,
const char* msg,
67 const int nb_lines,
const int nb_col,
const char* nameVal[],
68 const bool isGreek[],
double val[]) {
69 const int nbVal = nb_lines * nb_col;
71 QWidget values_wdgt(&dialog);
72 QGridLayout values_layout(&values_wdgt);
73 QLineEdit valBox[nbVal];
74 QDoubleValidator doubleValid(&values_wdgt);
76 for(idx = 0; idx < nbVal; idx++) {
77 const int lg = idx / nb_col, col = 2 * (idx % nb_col);
79 sprintf(name,
"%s%s%s", isGreek[idx] ?
"<span>" :
"<em>",
80 nameVal[idx], isGreek[idx] ?
"</span>:" :
"</em>:");
81 values_layout.addWidget(
new QLabel( tr(name) ), lg, col);
82 valBox[idx].setText( QString(
"%L1").arg(val[idx]) );
83 valBox[idx].setValidator(&doubleValid);
84 values_layout.addWidget(&valBox[idx], lg, col + 1);
89 const bool res = (dialog.exec() == QDialog::Accepted);
90 for(idx = 0; res && (idx < nbVal); idx++)
91 val[idx] = valBox[idx].
text().toDouble();
104 const char* title,
const char* msg,
105 iSeeML::rob::OrPtConfig &q) {
106 static const int nb_val = 3;
107 static const char* name_val[nb_val]
108 = {
"x",
"y",
"θ"};
109 static const bool val_Greek[nb_val]
110 = {
false,
false,
true};
111 std::string ext_msg(msg);
112 ext_msg +=
" (angle is in degres):";
113 double val[nb_val] = {0, 0, 0};
114 const bool res =
getDoubleArray(parent, title, ext_msg.c_str(), 1,
115 nb_val, name_val, val_Greek, val);
117 val[2] = iSeeML::Object::deg2rad(val[2]);
118 q = iSeeML::rob::OrPtConfig(iSeeML::geom::Point(val[0], val[1]),
133 const char* msg,
State &state) {
134 static const int nb_val = 6;
135 static const char* name_val[nb_val]
136 = {
"t",
"x",
"y",
"θ",
"v",
"ω"};
137 static const bool val_Greek[nb_val]
138 = {
false,
false,
false,
true,
false,
true};
139 std::string ext_msg(msg);
140 ext_msg +=
" (angle are in degres):";
141 double val[nb_val] = {0, 0, 0, 0, 0, 0};
142 const bool res =
getDoubleArray(parent, title, ext_msg.c_str(), 2,
143 nb_val / 2, name_val, val_Greek, val);
145 val[3] = iSeeML::Object::deg2rad(val[3]);
146 val[5] = iSeeML::Object::deg2rad(val[5]);
147 state =
State( val[0], iSeeML::rob::OrPtConfig
148 (iSeeML::geom::Point(val[1], val[2]), val[3]),
This class defines a sub-class of dialog windows which lower part is a horizontal button panel with o...
QLabel text
The upper label.
OkCancelDialog(QWidget *parent, const char *title, const char *msg)
The dialog is build with a given parent and title.
static bool getDoubleArray(QWidget *parent, const char *title, const char *msg, const int nb_lines, const int nb_col, const char *nameVal[], const bool isGreek[], double val[])
Asks in a dialog for a set of doubles, and returns it.
void insertWidget(QWidget &widget)
Inserts the given widget (containing the inputs) in the dialog, between message and buttons...
This class defines a state, i.e. a configuration and its (translation and rotation) velocities...
QDialogButtonBox buttons_layout
The button layout.
static bool getOrPtConfig(QWidget *parent, const char *title, const char *msg, iSeeML::rob::OrPtConfig &q)
Asks in a dialog for an oriented point.
QVBoxLayout layout
The main layout (vertic.)
static bool getState(QWidget *parent, const char *title, const char *msg, State &state)
Asks in a dialog for a state.