Commit 48202836 authored by Joseph Mirabel's avatar Joseph Mirabel

Merge remote-tracking branch 'redmine/devel' into devel

Conflicts:
	plugins/hppwidgetsplugin/listjointconstraint.cc
parents 75b600e1 1f011f74
......@@ -31,7 +31,6 @@ SET(BUILD_HPP_WIDGETS_PLUGIN ${HPP_CORBASERVER_FOUND}
SET(BUILD_HPP_MANIPULATION_WIDGETS_PLUGIN ${HPP_MANIPULATION_CORBA_FOUND}
CACHE BOOL "Build hppmanipulationwidgetsplugin")
#ADD_SUBDIRECTORY(plugintest)
IF (HPP_CORBASERVER_FOUND)
IF (REMOTEIMU_FOUND AND BUILD_REMOTEIMU_PLUGIN)
ADD_SUBDIRECTORY(remoteimuplugin)
......
......@@ -33,7 +33,6 @@ GEPETTO_GUI_PLUGIN(hppmanipulationwidgetsplugin
linkwidget.hh
manipulationconstraintwidget.hh
manipulationncpicker.hh
manipulationlockedjoint.hh
HEADERS_NO_MOC
roadmap.hh
......@@ -47,7 +46,6 @@ GEPETTO_GUI_PLUGIN(hppmanipulationwidgetsplugin
linkwidget.cc
manipulationconstraintwidget.cc
manipulationncpicker.cc
manipulationlockedjoint.cc
LINK_DEPENDENCIES
hppwidgetsplugin
......
......@@ -21,7 +21,7 @@
#include "hppmanipulationwidgetsplugin/linkwidget.hh"
#include "hppmanipulationwidgetsplugin/manipulationconstraintwidget.hh"
#include "hppwidgetsplugin/twojointsconstraint.hh"
#include "hppmanipulationwidgetsplugin/manipulationlockedjoint.hh"
#include "hppwidgetsplugin/listjointconstraint.hh"
using CORBA::ULong;
......@@ -125,8 +125,9 @@ namespace hpp {
{
HppWidgetsPlugin::openConnection();
hpp_ = new HppManipClient (0,0);
QByteArray iiop = getHppIIOPurl ().toLatin1();
hpp_->connect (iiop.constData ());
QByteArray iiop = getHppIIOPurl ().toLatin1();
QByteArray context = getHppContext ().toLatin1();
hpp_->connect (iiop.constData (), context.constData ());
}
void HppManipulationWidgetsPlugin::closeConnection()
......@@ -522,7 +523,7 @@ namespace hpp {
constraintWidget_->addConstraint(new PositionConstraint(this));
constraintWidget_->addConstraint(new OrientationConstraint(this));
constraintWidget_->addConstraint(new TransformConstraint(this));
constraintWidget_->addConstraint(new ManipulationLockedJoint(this));
constraintWidget_->addConstraint(new LockedJointConstraint(this));
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
......
......@@ -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();
}
......
//
// Copyright (c) CNRS
// Authors: Joseph Mirabel and Heidy Dallard
//
#include "hppmanipulationwidgetsplugin.hh"
#include "manipulationlockedjoint.hh"
#include <QListWidgetItem>
namespace hpp {
namespace gui {
ManipulationLockedJoint::ManipulationLockedJoint(HppManipulationWidgetsPlugin* plugin)
: ListJointConstraint(plugin)
{
}
ManipulationLockedJoint::~ManipulationLockedJoint()
{
}
QString ManipulationLockedJoint::getName() const
{
return "Locked Joint";
}
void ManipulationLockedJoint::operator ()(QString const& /*name*/) {
QList<QListWidgetItem*> selected = jointList_->selectedItems();
HppManipulationWidgetsPlugin* plugin = dynamic_cast<HppManipulationWidgetsPlugin*>(plugin_);
foreach (QListWidgetItem *item, selected) {
std::string jointName = item->text().toStdString().c_str();
hpp::floatSeq_var config = plugin->client()->robot()->getJointConfig(jointName.c_str());
plugin->client()->problem()->createLockedJoint(std::string("lock_" + jointName).c_str(),
jointName.c_str(),
config.in());
emit constraintCreated(std::string("lock_" + jointName).c_str());
}
}
}
}
//
// Copyright (c) CNRS
// Authors: Joseph Mirabel and Heidy Dallard
//
#ifndef HPP_GUI_MANIPULATIONLOCKEDJOINT_HH
#define HPP_GUI_MANIPULATIONLOCKEDJOINT_HH
#include "hppwidgetsplugin/listjointconstraint.hh"
namespace hpp {
namespace gui {
class HppManipulationWidgetsPlugin;
class ManipulationLockedJoint : public ListJointConstraint
{
Q_OBJECT
public:
ManipulationLockedJoint(HppManipulationWidgetsPlugin* plugin);
virtual ~ManipulationLockedJoint();
virtual QString getName() const;
virtual void operator()(QString const& name);
};
}
}
#endif // HPP_GUI_MANIPULATIONLOCKEDJOINT_HH
......@@ -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();
}
......
......@@ -150,6 +150,7 @@ namespace hpp {
main->registerSlot("lengthBetweenRefresh", pathPlayer_);
main->registerSlot("getCurrentPath", pathPlayer_);
main->registerSlot("getHppIIOPurl", this);
main->registerSlot("getHppContext", this);
main->registerSlot("getSelectedJoint", jointTreeWidget_);
main->registerSignal(SIGNAL(appliedConfigAtParam(int,double)), pathPlayer_);
......@@ -226,12 +227,20 @@ namespace hpp {
return gepetto::gui::omniOrb::IIOPurl (host, port);
}
QString HppWidgetsPlugin::getHppContext () const
{
QString context = gepetto::gui::MainWindow::instance ()->settings_->getSetting
("hpp/context", QString ()).toString ();
return context;
}
void HppWidgetsPlugin::openConnection ()
{
closeConnection ();
hpp_ = new hpp::corbaServer::Client (0,0);
QByteArray iiop = getHppIIOPurl ().toLatin1();
hpp_->connect (iiop.constData ());
QByteArray iiop = getHppIIOPurl ().toLatin1();
QByteArray context = getHppContext ().toLatin1();
hpp_->connect (iiop.constData (), context.constData ());
}
void HppWidgetsPlugin::closeConnection ()
......
......@@ -123,6 +123,8 @@ signals:
QString getHppIIOPurl () const;
QString getHppContext () const;
public:
/// Get the corbaserver client.
HppClient* client () const;
......
......@@ -11,6 +11,7 @@
#include "hppwidgetsplugin/ui_jointtreewidget.h"
#include <gepetto/gui/mainwindow.hh>
#include <gepetto/gui/bodytreewidget.hh>
#include <gepetto/gui/windows-manager.hh>
#include <gepetto/gui/action-search-bar.hh>
#if GEPETTO_GUI_HAS_PYTHONQT
......@@ -49,6 +50,8 @@ namespace hpp {
SLOT (customContextMenu(QPoint)));
connect(ui_->jointTree, SIGNAL (expanded(QModelIndex)),
SLOT (resize(QModelIndex)));
connect(ui_->jointTree->selectionModel(), SIGNAL (currentChanged(QModelIndex, QModelIndex)),
SLOT (currentJointChanged(QModelIndex,QModelIndex)));
}
JointTreeWidget::~JointTreeWidget()
......@@ -257,5 +260,26 @@ namespace hpp {
Q_UNUSED (index);
ui_->jointTree->resizeColumnToContents(0);
}
void JointTreeWidget::currentJointChanged(const QModelIndex& current, const QModelIndex& previous)
{
Q_UNUSED (previous);
if (current.isValid())
{
JointTreeItem* item = dynamic_cast <JointTreeItem*>
(model_->itemFromIndex(current));
if (item == NULL) return;
HppWidgetsPlugin::JointMap::const_iterator itj = plugin_->jointMap().find(item->name());
if (itj == plugin_->jointMap().constEnd()) return;
const HppWidgetsPlugin::JointElement& je = itj.value();
MainWindow* main = MainWindow::instance();
for (std::size_t i = 0; i < je.bodyNames.size(); ++i)
{
main->bodyTree()->selectBodyByName (je.bodyNames[i]);
}
}
}
} // namespace gui
} // namespace hpp
......@@ -65,6 +65,10 @@ signals:
private slots:
void resize (const QModelIndex index);
/// Connected to signal "currentChanged" of the selection model of the
/// joint tree view.
void currentJointChanged (const QModelIndex& current, const QModelIndex& previous);
private:
void initSearchActions();
......
......@@ -61,25 +61,15 @@ namespace hpp {
void LockedJointConstraint::operator ()(QString const&)
{
QList<QListWidgetItem *> selected = jointList_->selectedItems();
std::size_t len (0);
std::vector <std::string> lockedJointName;
foreach(QListWidgetItem* item, selected) {
std::string jointName = item->text().toStdString();
lockedJointName.push_back (std::string ("locked_") + jointName);
hpp::floatSeq_var config =
plugin_->client ()->robot ()->getJointConfig (jointName.c_str ());
plugin_->client()->problem()->createLockedJoint
(lockedJointName.back ().c_str (), jointName.c_str (), config.in());
++len;
std::string jointName = item->text().toStdString();
std::string lockName = "lock_" + jointName;
hpp::floatSeq_var config = plugin_->client()->robot()->getJointConfig(jointName.c_str());
plugin_->client()->problem()->createLockedJoint(lockName.c_str(),
jointName.c_str(),
config.in());
emit constraintCreated(lockName.c_str());
}
char** nameList = hpp::Names_t::allocbuf((CORBA::ULong) len);
Names_t names ((CORBA::ULong) len, (CORBA::ULong) len, nameList);
for (std::size_t i=0; i < len; ++i) {
nameList[i] = const_cast <char*> (lockedJointName [i].c_str ());
}
plugin_->client()->problem()->setLockedJointConstraints
("config-projector", names);
delete nameList;
}
}
}
......@@ -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()->addNumericalConstraints(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()->addLockedJointConstraints(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">
......
#
# Copyright (c) 2015 CNRS
# Authors: Joseph Mirabel
#
#
# This file is part of hpp-gui
# hpp-gui is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-gui is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-gui If not, see
# <http://www.gnu.org/licenses/>.
SET(PLUGIN_NAME plugintest)
SET(${PLUGIN_NAME}_HEADERS_NO_MOC
../../include/hpp/gui/plugin-interface.hh
)
SET(${PLUGIN_NAME}_HEADERS
test.hh
)
SET(${PLUGIN_NAME}_FORMS
)
SET(${PLUGIN_NAME}_RESOURCES
)
QT4_WRAP_CPP(${PLUGIN_NAME}_HEADERS_MOC ${${PLUGIN_NAME}_HEADERS} OPTIONS -I${GEPETTO_VIEWER_CORBA_INCLUDEDIR})
QT4_WRAP_UI(${PLUGIN_NAME}_FORMS_HEADERS ${${PLUGIN_NAME}_FORMS})
QT4_ADD_RESOURCES(${PLUGIN_NAME}_RESOURCES_RCC ${${PLUGIN_NAME}_RESOURCES})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)
SET (${PLUGIN_NAME}_SOURCES
test.cc
)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${${PLUGIN_NAME}_SOURCES}
${${PLUGIN_NAME}_HEADERS_NO_MOC}
${${PLUGIN_NAME}_HEADERS_MOC}
${${PLUGIN_NAME}_FORMS_HEADERS}
${${PLUGIN_NAME}_RESOURCES_RCC}
)
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES})
# Uncomment to install
#INSTALL(TARGETS ${PLUGIN_NAME} DESTINATION lib)
//
// Copyright (c) CNRS
// Authors: Joseph Mirabel
//
#include <test.hh>
#include <QtPlugin>
namespace hpp {
namespace gui {
void TestPlugin::init() {
qDebug() << "test";
std::cout << "test" << std::endl;
}
Q_EXPORT_PLUGIN2 (testplugin, TestPlugin)
} // namespace gui
} // namespace hpp
//
// Copyright (c) CNRS
// Author: Joseph Mirabel
//
#include <QObject>
#include <QWidget>
#include <iostream>
#include <gepetto/gui/plugin-interface.hh>
namespace hpp {
namespace gui {
class TestPlugin : public QObject, public PluginInterface {
Q_OBJECT
Q_INTERFACES (PluginInterface)
public:
void init();
};
} // namespace gui
} // namespace hpp
......@@ -4,7 +4,6 @@
#
from PythonQt import QtGui, Qt
from hpp.corbaserver import Client
import sys
sys.argv = ["none"]
......
......@@ -21,8 +21,10 @@ def fromHPP(t):
class _Clients(object):
def __init__(self, mainWindow):
self.hppPlugin = mainWindow.getFromSlot("getHppIIOPurl")
self.basic = BasicClient(url= str(self.hppPlugin.getHppIIOPurl()))
self.manipulation = ManipClient(url= str(self.hppPlugin.getHppIIOPurl()))
self.basic = BasicClient(url= str(self.hppPlugin.getHppIIOPurl()),
postContextId= str(self.hppPlugin.getHppContext()))
self.manipulation = ManipClient(url= str(self.hppPlugin.getHppIIOPurl()),)
postContextId= str(self.hppPlugin.getHppContext()))
self.viewer = ViewerClient()
class _GraspMode(QWidget):
......
......@@ -4,7 +4,6 @@
#
from PythonQt import QtGui, Qt, QtCore
from hpp.corbaserver import Client
from hpp import Transform
from numpy import array
......
......@@ -180,7 +180,8 @@ class Plugin(QtGui.QDockWidget):
self.tabWidget.addTab (CollisionPairs(self), "Collision pairs")
def resetConnection(self):
self.client = Client(url= str(self.hppPlugin.getHppIIOPurl()))
self.client = Client(url= str(self.hppPlugin.getHppIIOPurl()),
postContextId= str(self.hppPlugin.getHppContext()))
self.resetRobot();
self.gui = GuiClient()
......
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