Commit 8de26ab4 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel

Update constraint creator widget

parent 6bec8aef
......@@ -52,13 +52,7 @@ namespace hpp {
void ManipulationConstraintWidget::confirmNumerical()
{
HppManipulationWidgetsPlugin* plugin = dynamic_cast<HppManipulationWidgetsPlugin*>(plugin_);
QStringList l;
for (int i = 0; i < ui->nameList->count(); i++) {
QListWidgetItem* item = ui->nameList->item(i);
l << item->text();
}
ManipulationNCPicker* ncp = new ManipulationNCPicker(l, plugin);
ManipulationNCPicker* ncp = new ManipulationNCPicker(plugin);
ncp->show();
}
......
......@@ -9,10 +9,9 @@
namespace hpp {
namespace gui {
ManipulationNCPicker::ManipulationNCPicker(QStringList const& names,
HppManipulationWidgetsPlugin* plugin,
ManipulationNCPicker::ManipulationNCPicker(HppManipulationWidgetsPlugin* plugin,
QWidget* parent)
: NumericalConstraintPicker(names, plugin, parent)
: NumericalConstraintPicker(plugin, parent)
{
listComp_ = new QListWidget(this);
hpp::GraphComp_var graphComp;
......@@ -47,27 +46,27 @@ namespace hpp {
void ManipulationNCPicker::onConfirmClicked()
{
QList<QListWidgetItem*> selectedConst = ui->constraintList->selectedItems();
QList<QListWidgetItem*> lj = ui->lockedJointList->selectedItems();
QList<QListWidgetItem*> nc = ui->numericalList->selectedItems();
hpp::Names_t_var constraints = new hpp::Names_t;
hpp::Names_t_var locked = new hpp::Names_t;
hpp::Names_t_var dofs = new hpp::Names_t;
QList<QListWidgetItem*> selectedComp = listComp_->selectedItems();
HppManipulationWidgetsPlugin* plugin = dynamic_cast<HppManipulationWidgetsPlugin*>(plugin_);
constraints->length(selectedConst.count());
locked->length(selectedConst.count());
int iC = -1;
int iL = -1;
foreach (QListWidgetItem* item, selectedConst) {
if (!item->text().startsWith("lock_")) {
constraints[++iC] = item->text().toStdString().c_str();
}
else {
locked[++iL] = item->text().toStdString().c_str();
}
constraints->length(nc.count());
locked->length(lj.count());
int i = 0;
foreach (QListWidgetItem* item, lj) {
locked[i] = item->text().toStdString().c_str();
++i;
}
locked->length(iL + 1);
constraints->length(iC + 1);
i = 0;
foreach (QListWidgetItem* item, nc) {
constraints[i] = item->text().toStdString().c_str();
++i;
}
foreach (QListWidgetItem* item, selectedComp) {
if (constraints->length())
plugin->manipClient()->graph()->setNumericalConstraints(components_[item->text().toStdString()].id,
......
......@@ -21,7 +21,7 @@ namespace hpp {
virtual void onConfirmClicked();
public:
ManipulationNCPicker(QStringList const& names, HppManipulationWidgetsPlugin* plugin,
ManipulationNCPicker(HppManipulationWidgetsPlugin* plugin,
QWidget* parent = 0);
virtual ~ManipulationNCPicker();
......
......@@ -77,12 +77,7 @@ namespace hpp {
void ConstraintWidget::confirmNumerical()
{
QStringList l;
for (int i = 0; i < ui->nameList->count(); i++) {
QListWidgetItem* item = ui->nameList->item(i);
l << item->text();
}
NumericalConstraintPicker* ncp = new NumericalConstraintPicker(l, plugin_);
NumericalConstraintPicker* ncp = new NumericalConstraintPicker(plugin_);
ncp->show();
}
......
......@@ -13,17 +13,25 @@
namespace hpp {
namespace gui {
NumericalConstraintPicker::NumericalConstraintPicker(QStringList const& names,
HppWidgetsPlugin* plugin,
NumericalConstraintPicker::NumericalConstraintPicker(HppWidgetsPlugin* plugin,
QWidget *parent) :
QWidget(parent),
ui(new Ui::NumericalConstraintPicker)
{
ui->setupUi(this);
ui->constraintList->setSelectionMode(QAbstractItemView::ExtendedSelection);
foreach (QString name, names) {
ui->constraintList->addItem(name);
hpp::Names_t_var names = plugin->client()->problem()->getAvailable("lockedjoint");
ui->lockedJointList->setSelectionMode(QAbstractItemView::ExtendedSelection);
for (unsigned i = 0; i < names->length(); ++i) {
ui->lockedJointList->addItem(QString(names[i]));
}
names = plugin->client()->problem()->getAvailable("numericalconstraint");
ui->numericalList->setSelectionMode(QAbstractItemView::ExtendedSelection);
for (unsigned i = 0; i < names->length(); ++i) {
ui->numericalList->addItem(QString(names[i]));
}
connect(ui->cancelButton, SIGNAL(clicked()), SLOT(onCancelClicked()));
connect(ui->confirmButton, SIGNAL(clicked()), SLOT(onConfirmClicked()));
plugin_ = plugin;
......@@ -48,20 +56,31 @@ namespace hpp {
void NumericalConstraintPicker::onConfirmClicked()
{
QList<QListWidgetItem *> list = ui->constraintList->selectedItems();
QList<QListWidgetItem *> lj = ui->lockedJointList->selectedItems();
QList<QListWidgetItem *> nc = ui->numericalList->selectedItems();
hpp::Names_t_var names = new hpp::Names_t;
hpp::intSeq_var priorities = new hpp::intSeq;
names->length(list.count());
priorities->length(list.count());
names->length(nc.count());
priorities->length(nc.count());
int i = 0;
foreach(QListWidgetItem* item, list) {
foreach(QListWidgetItem* item, nc) {
names[i] = gepetto::gui::Traits<QString>::to_corba(item->text());
priorities[i] = 0;
i++;
}
plugin_->client()->problem()->setNumericalConstraints(gepetto::gui::Traits<QString>::to_corba(ui->numericalName->text()),
plugin_->client()->problem()->setNumericalConstraints(gepetto::gui::Traits<QString>::to_corba(ui->constraintName->text()),
names.in(), priorities.in());
names->length(lj.count());
i = 0;
foreach(QListWidgetItem* item, lj) {
names[i] = gepetto::gui::Traits<QString>::to_corba(item->text());
i++;
}
plugin_->client()->problem()->setLockedJointConstraints(gepetto::gui::Traits<QString>::to_corba(ui->constraintName->text()),
names.in());
onCancelClicked();
}
}
......
......@@ -32,7 +32,7 @@ namespace hpp {
void closeEvent(QCloseEvent* event);
public:
explicit NumericalConstraintPicker(QStringList const& names, HppWidgetsPlugin* plugin,
explicit NumericalConstraintPicker(HppWidgetsPlugin* plugin,
QWidget *parent = 0);
virtual ~NumericalConstraintPicker();
......
......@@ -17,26 +17,40 @@
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="constraintLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="numericalName"/>
<widget class="QLineEdit" name="constraintName">
<property name="text">
<string>constraint</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="lockedJointLabel">
<property name="text">
<string>Select the locked joint constraints:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="lockedJointList"/>
</item>
<item>
<widget class="QLabel" name="numericalLabel">
<property name="text">
<string>Select the constraint you want to add</string>
<string>Select the numerical constraints:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="constraintList"/>
<widget class="QListWidget" name="numericalList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment