Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) CNRS |
3 |
|
|
// Authors: Heidy Dallard |
4 |
|
|
// |
5 |
|
|
|
6 |
|
|
#include "listjointconstraint.hh" |
7 |
|
|
|
8 |
|
|
#include <QLabel> |
9 |
|
|
#include <QListWidget> |
10 |
|
|
#include <QVBoxLayout> |
11 |
|
|
#include <QWidget> |
12 |
|
|
|
13 |
|
|
namespace hpp { |
14 |
|
|
namespace gui { |
15 |
|
✗ |
ListJointConstraint::ListJointConstraint(HppWidgetsPlugin* plugin) { |
16 |
|
✗ |
plugin_ = plugin; |
17 |
|
✗ |
widget_ = new QWidget; |
18 |
|
✗ |
QVBoxLayout* layout = new QVBoxLayout(widget_); |
19 |
|
✗ |
jointList_ = new QListWidget(widget_); |
20 |
|
|
|
21 |
|
✗ |
layout->addWidget(jointList_); |
22 |
|
✗ |
jointList_->setSelectionMode(QAbstractItemView::ExtendedSelection); |
23 |
|
|
} |
24 |
|
|
|
25 |
|
✗ |
ListJointConstraint::~ListJointConstraint() { delete widget_; } |
26 |
|
|
|
27 |
|
✗ |
QWidget* ListJointConstraint::getWidget() const { return widget_; } |
28 |
|
|
|
29 |
|
✗ |
void ListJointConstraint::reload() { |
30 |
|
✗ |
hpp::Names_t_var joints = plugin_->client()->robot()->getAllJointNames(); |
31 |
|
|
|
32 |
|
✗ |
jointList_->clear(); |
33 |
|
✗ |
for (unsigned i = 0; i < joints->length(); i++) { |
34 |
|
✗ |
jointList_->addItem(joints[i].in()); |
35 |
|
|
} |
36 |
|
|
} |
37 |
|
|
|
38 |
|
✗ |
LockedJointConstraint::LockedJointConstraint(HppWidgetsPlugin* plugin) |
39 |
|
✗ |
: ListJointConstraint(plugin) { |
40 |
|
✗ |
widget_->layout()->addWidget(new QLabel( |
41 |
|
✗ |
"The joints will be locked in their current position.", widget_)); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
✗ |
LockedJointConstraint::~LockedJointConstraint() {} |
45 |
|
|
|
46 |
|
✗ |
QString LockedJointConstraint::getName() const { return "Lock joints"; } |
47 |
|
|
|
48 |
|
✗ |
void LockedJointConstraint::operator()(QString const&) { |
49 |
|
✗ |
QList<QListWidgetItem*> selected = jointList_->selectedItems(); |
50 |
|
✗ |
foreach (QListWidgetItem* item, selected) { |
51 |
|
✗ |
std::string jointName = item->text().toStdString(); |
52 |
|
✗ |
std::string lockName = "lock_" + jointName; |
53 |
|
|
hpp::floatSeq_var config = |
54 |
|
✗ |
plugin_->client()->robot()->getJointConfig(jointName.c_str()); |
55 |
|
✗ |
plugin_->client()->problem()->createLockedJoint( |
56 |
|
|
lockName.c_str(), jointName.c_str(), config.in()); |
57 |
|
✗ |
emit constraintCreated(lockName.c_str()); |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
} // namespace gui |
61 |
|
|
} // namespace hpp |
62 |
|
|
|