Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) CNRS |
3 |
|
|
// Authors: Joseph Mirabel |
4 |
|
|
// |
5 |
|
|
|
6 |
|
|
#include "hppwidgetsplugin/jointbounddialog.hh" |
7 |
|
|
|
8 |
|
|
#include <omniORB4/CORBA.h> |
9 |
|
|
|
10 |
|
|
#include <QDebug> |
11 |
|
|
#include <QDialogButtonBox> |
12 |
|
|
#include <QHBoxLayout> |
13 |
|
|
#include <QVBoxLayout> |
14 |
|
|
|
15 |
|
|
using CORBA::ULong; |
16 |
|
|
|
17 |
|
|
namespace hpp { |
18 |
|
|
namespace gui { |
19 |
|
✗ |
JointBoundDialog::JointBoundDialog(QString name, std::size_t nbDof, |
20 |
|
✗ |
QWidget* parent) |
21 |
|
✗ |
: QDialog(parent, Qt::Dialog) { |
22 |
|
✗ |
QVBoxLayout* vl = new QVBoxLayout(this); |
23 |
|
✗ |
for (std::size_t i = 0; i < nbDof; ++i) { |
24 |
|
✗ |
QWidget* w = new QWidget(this); |
25 |
|
✗ |
QHBoxLayout* hl = new QHBoxLayout(w); |
26 |
|
✗ |
Line l(name + " " + QString::number(i), w); |
27 |
|
✗ |
l.addToLayout(hl); |
28 |
|
✗ |
lines_.append(l); |
29 |
|
✗ |
vl->addWidget(w); |
30 |
|
|
} |
31 |
|
✗ |
QDialogButtonBox* buttonBox = new QDialogButtonBox(); |
32 |
|
|
// buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
33 |
|
|
// buttonBox->setGeometry(QRect(30, 240, 341, 32)); |
34 |
|
✗ |
buttonBox->setOrientation(Qt::Horizontal); |
35 |
|
✗ |
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | |
36 |
|
|
QDialogButtonBox::Ok); |
37 |
|
✗ |
vl->addWidget(buttonBox); |
38 |
|
|
|
39 |
|
✗ |
QObject::connect(buttonBox, SIGNAL(accepted()), SLOT(accept())); |
40 |
|
✗ |
QObject::connect(buttonBox, SIGNAL(rejected()), SLOT(reject())); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
✗ |
void JointBoundDialog::setBounds(const hpp::floatSeq& bounds) { |
44 |
|
✗ |
if (bounds.length() != (ULong)lines_.length() * 2) { |
45 |
|
✗ |
qDebug() << "Wrong bounds dimensions"; |
46 |
|
✗ |
return; |
47 |
|
|
} |
48 |
|
✗ |
std::size_t i = 0; |
49 |
|
✗ |
foreach (const Line& l, lines_) { |
50 |
|
✗ |
l.min->setValue(bounds[(ULong)i]); |
51 |
|
✗ |
i++; |
52 |
|
✗ |
l.max->setValue(bounds[(ULong)i]); |
53 |
|
✗ |
i++; |
54 |
|
|
} |
55 |
|
|
} |
56 |
|
|
|
57 |
|
✗ |
void JointBoundDialog::getBounds(hpp::floatSeq& bounds) const { |
58 |
|
✗ |
bounds.length(lines_.length() * 2); |
59 |
|
✗ |
std::size_t i = 0; |
60 |
|
✗ |
foreach (const Line& l, lines_) { |
61 |
|
✗ |
bounds[(ULong)i] = l.min->value(); |
62 |
|
✗ |
i++; |
63 |
|
✗ |
bounds[(ULong)i] = l.max->value(); |
64 |
|
✗ |
i++; |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|
68 |
|
✗ |
JointBoundDialog::~JointBoundDialog() {} |
69 |
|
|
|
70 |
|
✗ |
JointBoundDialog::Line::Line(const QString& name, QWidget* parent) |
71 |
|
✗ |
: label(new QLabel(name, parent)), |
72 |
|
✗ |
min(new QDoubleSpinBox(parent)), |
73 |
|
✗ |
max(new QDoubleSpinBox(parent)) { |
74 |
|
✗ |
min->setRange(-100, 100); |
75 |
|
✗ |
max->setRange(-100, 100); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
✗ |
void JointBoundDialog::Line::addToLayout(QLayout* l) { |
79 |
|
✗ |
l->addWidget(label); |
80 |
|
✗ |
l->addWidget(min); |
81 |
|
✗ |
l->addWidget(max); |
82 |
|
|
} |
83 |
|
|
} // namespace gui |
84 |
|
|
} // namespace hpp |
85 |
|
|
|