| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) CNRS |
| 3 |
|
|
// Authors: Heidy Dallard |
| 4 |
|
|
// |
| 5 |
|
|
|
| 6 |
|
|
#include "hppwidgetsplugin/numericalconstraintpicker.hh" |
| 7 |
|
|
|
| 8 |
|
|
#include <QHBoxLayout> |
| 9 |
|
|
#include <iostream> |
| 10 |
|
|
|
| 11 |
|
|
#include "hppwidgetsplugin/hppwidgetsplugin.hh" |
| 12 |
|
|
#include "hppwidgetsplugin/ui_numericalconstraintpicker.h" |
| 13 |
|
|
|
| 14 |
|
|
namespace hpp { |
| 15 |
|
|
namespace gui { |
| 16 |
|
✗ |
NumericalConstraintPicker::NumericalConstraintPicker(HppWidgetsPlugin* plugin, |
| 17 |
|
✗ |
QWidget* parent) |
| 18 |
|
✗ |
: QWidget(parent), ui(new Ui::NumericalConstraintPicker) { |
| 19 |
|
✗ |
ui->setupUi(this); |
| 20 |
|
|
|
| 21 |
|
|
hpp::Names_t_var names = |
| 22 |
|
✗ |
plugin->client()->problem()->getAvailable("numericalconstraint"); |
| 23 |
|
✗ |
ui->numericalList->setSelectionMode(QAbstractItemView::ExtendedSelection); |
| 24 |
|
✗ |
for (unsigned i = 0; i < names->length(); ++i) { |
| 25 |
|
✗ |
ui->numericalList->addItem(QString(names[i])); |
| 26 |
|
|
} |
| 27 |
|
|
|
| 28 |
|
✗ |
connect(ui->cancelButton, SIGNAL(clicked()), SLOT(onCancelClicked())); |
| 29 |
|
✗ |
connect(ui->confirmButton, SIGNAL(clicked()), SLOT(onConfirmClicked())); |
| 30 |
|
✗ |
plugin_ = plugin; |
| 31 |
|
|
} |
| 32 |
|
|
|
| 33 |
|
✗ |
NumericalConstraintPicker::~NumericalConstraintPicker() { delete ui; } |
| 34 |
|
|
|
| 35 |
|
✗ |
void NumericalConstraintPicker::closeEvent(QCloseEvent* event) { |
| 36 |
|
✗ |
deleteLater(); |
| 37 |
|
✗ |
event->accept(); |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
✗ |
void NumericalConstraintPicker::onCancelClicked() { |
| 41 |
|
✗ |
deleteLater(); |
| 42 |
|
✗ |
close(); |
| 43 |
|
|
} |
| 44 |
|
|
|
| 45 |
|
✗ |
void NumericalConstraintPicker::onConfirmClicked() { |
| 46 |
|
✗ |
QList<QListWidgetItem*> lj = ui->lockedJointList->selectedItems(); |
| 47 |
|
✗ |
QList<QListWidgetItem*> nc = ui->numericalList->selectedItems(); |
| 48 |
|
|
|
| 49 |
|
✗ |
hpp::Names_t_var names = new hpp::Names_t; |
| 50 |
|
✗ |
hpp::intSeq_var priorities = new hpp::intSeq; |
| 51 |
|
|
|
| 52 |
|
✗ |
names->length(nc.count()); |
| 53 |
|
✗ |
priorities->length(nc.count()); |
| 54 |
|
✗ |
int i = 0; |
| 55 |
|
✗ |
foreach (QListWidgetItem* item, nc) { |
| 56 |
|
✗ |
names[i] = to_corba(item->text()); |
| 57 |
|
✗ |
priorities[i] = 0; |
| 58 |
|
✗ |
i++; |
| 59 |
|
|
} |
| 60 |
|
✗ |
plugin_->client()->problem()->addNumericalConstraints( |
| 61 |
|
✗ |
to_corba(ui->constraintName->text()), names.in(), priorities.in()); |
| 62 |
|
|
|
| 63 |
|
✗ |
names->length(lj.count()); |
| 64 |
|
✗ |
i = 0; |
| 65 |
|
✗ |
foreach (QListWidgetItem* item, lj) { |
| 66 |
|
✗ |
names[i] = to_corba(item->text()); |
| 67 |
|
✗ |
i++; |
| 68 |
|
|
} |
| 69 |
|
✗ |
plugin_->client()->problem()->addLockedJointConstraints( |
| 70 |
|
✗ |
to_corba(ui->constraintName->text()), names.in()); |
| 71 |
|
✗ |
onCancelClicked(); |
| 72 |
|
|
} |
| 73 |
|
|
} // namespace gui |
| 74 |
|
|
} // namespace hpp |
| 75 |
|
|
|