diff --git a/include/gepetto/gui/meta.hh b/include/gepetto/gui/meta.hh deleted file mode 100644 index b014a41e286106673451de6bc905084d1ef415e9..0000000000000000000000000000000000000000 --- a/include/gepetto/gui/meta.hh +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2015-2018, LAAS-CNRS -// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) -// -// This file is part of gepetto-viewer-corba. -// gepetto-viewer-corba 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. -// -// gepetto-viewer-corba 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 -// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>. - -#ifndef GEPETTO_GUI_META_HH -#define GEPETTO_GUI_META_HH - -#include <QString> - -namespace gepetto { - namespace gui { - template <typename T> struct convertTo { - static inline T& from ( T& t) { return t; } - static inline const T& from (const T& t) { return t; } - }; - template <> struct convertTo<std::string> { - static inline std::string from (const QString& in) { return in.toStdString(); }; - }; - - template <typename T> struct Traits; - - template <> struct Traits <CORBA::String_var> { - typedef CORBA::String_var type; - static inline type from (const QString& s) { return (const char*)s.toLocal8Bit().data(); } - static inline type from (const std::string& s) { return s.c_str(); } - }; - - template <> struct Traits <QString> { - typedef CORBA::String_var CORBA_t; - static inline CORBA_t to_corba (const QString& s) { return (const char*)s.toLocal8Bit().data(); } - }; - - - template <typename In, typename Out, std::size_t Size> - inline void convertSequence (const In* in, Out (&out)[Size]) { - for (size_t i = 0; i < Size; ++i) out[i] = (Out)in[i]; - } - template <typename In, typename Out> - inline void convertSequence (const In* in, Out* out, const std::size_t& s) { - for (size_t i = 0; i < s; ++i) out[i] = (Out)in[i]; - } - } -} - -#endif // GEPETTO_GUI_META_HH diff --git a/include/gepetto/gui/windows-manager.hh b/include/gepetto/gui/windows-manager.hh index 0870fb5f3417c915a9235a4e9a64340f7cfd0e25..c55fa66dc1c8aa1456abcdb47112cca6a83f08d8 100644 --- a/include/gepetto/gui/windows-manager.hh +++ b/include/gepetto/gui/windows-manager.hh @@ -20,23 +20,12 @@ #include <gepetto/gui/fwd.hh> #include <gepetto/viewer/corba/windows-manager.hh> -#include <gepetto/gui/meta.hh> #include <QColor> #include <QObject> #include <QVector3D> namespace gepetto { namespace gui { - template <> struct convertTo<graphics::WindowsManager::Color_t> { - typedef graphics::WindowsManager::Color_t T; - typedef typename T::value_type v_t; - static inline T from (const QColor& in) { - T v((v_t)in.redF(), (v_t)in.greenF(), (v_t)in.blueF(), (v_t)in.alphaF()); - // in.getRgbF(&v[0],&v[1],&v[2],&v[3]); - return v; - } - }; - class WindowsManager : public QObject, public graphics::WindowsManager { Q_OBJECT diff --git a/include/gepetto/viewer/corba/se3.hh b/include/gepetto/viewer/corba/se3.hh deleted file mode 100644 index 41019809e748e3c3c01d8ac12f52a62330d6432f..0000000000000000000000000000000000000000 --- a/include/gepetto/viewer/corba/se3.hh +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2015-2018, LAAS-CNRS -// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) -// -// This file is part of gepetto-viewer-corba. -// gepetto-viewer-corba 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. -// -// gepetto-viewer-corba 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 -// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>. - -#ifndef __se3_se3_hpp__ -#define __se3_se3_hpp__ -#include <Eigen/Geometry> - -namespace se3 -{ -/* Type returned by the "se3Action" and "se3ActionInverse" functions. */ -namespace internal -{ -template<typename D> -struct ActionReturn { typedef D Type; }; -} -/** The rigid transform aMb can be seen in two ways: -* -* - given a point p expressed in frame B by its coordinate vector Bp, aMb -* computes its coordinates in frame A by Ap = aMb Bp. -* - aMb displaces a solid S centered at frame A into the solid centered in -* B. In particular, the origin of A is displaced at the origin of B: $^aM_b -* ^aA = ^aB$. -* The rigid displacement is stored as a rotation matrix and translation vector by: -* aMb (x) = aRb*x + aAB -* where aAB is the vector from origin A to origin B expressed in coordinates A. -*/ -template<typename _Scalar, int _Options> -class SE3Tpl -{ -public: -typedef _Scalar Scalar; -enum { Options = _Options }; -typedef Eigen::Matrix<Scalar,3,1,Options> Vector3; -typedef Eigen::Matrix<Scalar,4,1,Options> Vector4; -typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3; -typedef Eigen::Matrix<Scalar,6,1,Options> Vector6; -typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4; -typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6; -typedef Eigen::Quaternion<Scalar,Options> Quaternion; -//typedef MotionTpl<Scalar,Options> Motion; -//typedef ForceTpl<Scalar,Options> Force; -//typedef ActionTpl<Scalar,Options> Action; -enum { LINEAR = 0, ANGULAR = 3 }; -public: -// Constructors -SE3Tpl() : rot(), trans() {} -template<typename M3,typename v3> -SE3Tpl(const Eigen::MatrixBase<M3> & R, const Eigen::MatrixBase<v3> & p) -: rot(R), trans(p) {} -SE3Tpl(int) : rot(Matrix3::Identity()), trans(Vector3::Zero()) {} -template<typename S2, int O2> -SE3Tpl( const SE3Tpl<S2,O2> clone ) -: rot(clone.rotation()),trans(clone.translation()) {} -template<typename S2, int O2> -SE3Tpl & operator= (const SE3Tpl<S2,O2> & other) -{ -rot = other.rotation (); -trans = other.translation (); -return *this; -} -const Matrix3 & rotation() const { return rot; } -const Vector3 & translation() const { return trans; } -Matrix3 & rotation() { return rot; } -Vector3 & translation() { return trans; } -void rotation(const Matrix3 & R) { rot=R; } -void translation(const Vector3 & p) { trans=p; } -static SE3Tpl Identity() -{ -return SE3Tpl(1); -} -static SE3Tpl Random() -{ -Eigen::Quaternion<Scalar,Options> q(Vector4::Random()); -q.normalize(); -return SE3Tpl(q.matrix(),Vector3::Random()); -} -Eigen::Matrix<Scalar,4,4,Options> toHomogeneousMatrix() const -{ -Eigen::Matrix<Scalar,4,4,Options> M; -M.template block<3,3>(0,0) = rot; -M.template block<3,1>(0,3) = trans; -M.template block<1,3>(3,0).setZero(); -M(3,3) = 1; -return M; -} -/// Vb.toVector() = bXa.toMatrix() * Va.toVector() -Matrix6 toActionMatrix() const -{ -Matrix6 M; -M.template block<3,3>(ANGULAR,ANGULAR) -= M.template block<3,3>(LINEAR,LINEAR) = rot; -M.template block<3,3>(ANGULAR,LINEAR).setZero(); -M.template block<3,3>(LINEAR,ANGULAR) -= skew(trans) * M.template block<3,3>(ANGULAR,ANGULAR); -return M; -} -/// aXb = bXa.inverse() -SE3Tpl inverse() const -{ -return SE3Tpl(rot.transpose(), -rot.transpose()*trans); -} -void disp(std::ostream & os) const -{ -os << " R =\n" << rot << std::endl -<< " p =\n" << trans.transpose() << std::endl; -} -/* --- GROUP ACTIONS ON M6, F6 and I6 --- */ -/// ay = aXb.act(by) -template<typename D> typename internal::ActionReturn<D>::Type act (const D & d) const -{ return d.se3Action(*this); } -/// by = aXb.actInv(ay) -template<typename D> typename internal::ActionReturn<D>::Type actInv(const D & d) const -{ return d.se3ActionInverse(*this); } -Vector3 act (const Vector3& p) const { return (rot*p+trans).eval(); } -Vector3 actInv(const Vector3& p) const { return (rot.transpose()*(p-trans)).eval(); } -SE3Tpl act (const SE3Tpl& m2) const { return SE3Tpl( rot*m2.rot,trans+rot*m2.trans);} -SE3Tpl actInv (const SE3Tpl& m2) const { return SE3Tpl( rot.transpose()*m2.rot, -rot.transpose()*(m2.trans-trans));} -/* --- OPERATORS -------------------------------------------------------- */ -operator Matrix4() const { return toHomogeneousMatrix(); } -operator Matrix6() const { return toActionMatrix(); } -SE3Tpl operator*(const SE3Tpl & m2) const { return this->act(m2); } -friend std::ostream & operator << (std::ostream & os,const SE3Tpl & X) -{ X.disp(os); return os; } -public: -private: -Matrix3 rot; -Vector3 trans; -}; -typedef SE3Tpl<float,0> SE3; -} // namespace se3 -#endif // ifndef __se3_se3_hpp__ - diff --git a/src/client-cpp.cc b/src/client-cpp.cc deleted file mode 100644 index 721c8232ab32c7872c82681d9f734790a16692a6..0000000000000000000000000000000000000000 --- a/src/client-cpp.cc +++ /dev/null @@ -1,230 +0,0 @@ -// -// client-cpp.cc -// C++ CORBA client interface for SceneViewer. -// -// Created by Mathieu Geisert in December 2014. -// Copyright (c) 2014 LAAS-CNRS. All rights reserved. -// - -#include <gepetto/viewer/corba/client.hh> - -namespace graphics { -namespace corbaServer { - -void ClientCpp::se3ToCorba(CORBA::Float* corbaPosition, const se3::SE3& se3position) -{ - Eigen::Quaternion<value_type> q(se3position.rotation()); - corbaPosition[0] = se3position.translation()(0); - corbaPosition[1] = se3position.translation()(1); - corbaPosition[2] = se3position.translation()(2); - corbaPosition[3] = q.w(); - corbaPosition[4] = q.x(); - corbaPosition[5] = q.y(); - corbaPosition[6] = q.z(); -} - -ClientCpp::ClientCpp() -{ - int argc=0; // Dummy variables to support following call. - char** argv=0; - orb_ = CORBA::ORB_init(argc, argv); - - // Get a reference to the Naming Service - CORBA::Object_var rootContextObj = - orb_->resolve_initial_references("NameService"); - CosNaming::NamingContext_var nc = - CosNaming::NamingContext::_narrow(rootContextObj.in()); - - CosNaming::Name name; - name.length(2); - name[0].id = (const char *) "gepetto"; - name[0].kind = (const char *) "viewer"; - name[1].id = (const char *) "corbaserver"; - name[1].kind = (const char *) "gui"; - // Invoke the root context to retrieve the object reference - CORBA::Object_var managerObj = nc->resolve(name); - // Narrow the previous object to obtain the correct type - manager_ = - gepetto::corbaserver::GraphicalInterface::_narrow(managerObj.in()); -} - -ClientCpp::~ClientCpp() -{ - //manager_->shutdown(); - if (!CORBA::is_nil(orb_)) { - try { - orb_->destroy(); - std::cout << "Ending CORBA..." << std::endl; - } catch(const CORBA::Exception& e) { - std::cout << "orb->destroy failed" << std::endl; - } - } -} - -void ClientCpp::getNodeList() -{ - manager_->getNodeList(); -} - - -void ClientCpp::getWindowList() -{ - manager_->getWindowList(); -} - -bool ClientCpp::setRate(int rate) -{ - return manager_->setRate(rate); -} - -void ClientCpp::refresh() -{ - manager_->refresh(); -} - -ClientCpp::WindowID ClientCpp::createWindow(const char* windowName) -{ - return manager_->createWindow(windowName); -} - - - //void ClientCpp::createWindow(const char* name, CORBA::ULong x, CORBA::ULong y, CORBA::ULong width, CORBA::ULong height) ; - -void ClientCpp::createScene(const char* sceneName) -{ - manager_->createScene(sceneName); -} - -void ClientCpp::createSceneWithFloor(const char* sceneName) -{ - manager_->createSceneWithFloor(sceneName); -} - -bool ClientCpp::addSceneToWindow(const char* sceneName, const ClientCpp::WindowID windowId) -{ - return manager_->addSceneToWindow(sceneName, windowId); -} - -/*bool ClientCpp::addBox(const char* boxName, float boxSize1, float boxSize2, float boxSize3) -{ - return manager_->addBox(boxName, boxSize1, boxSize2, boxSize3); -}*/ - -bool ClientCpp::addBox(const char* boxName, const float boxSize1, const float boxSize2, const float boxSize3, const value_type* color) -{ - return manager_->addBox(boxName, boxSize1, boxSize2, boxSize3, color); -} - -/*bool ClientCpp::addCapsule(const char* capsuleName, float radius, float height) -{ - return manager_->addCapsule(capsuleName, radius, height); -}*/ - -bool ClientCpp::addCapsule(const char* capsuleName, const float radius, const float height, const value_type* color) -{ - return manager_->addCapsule(capsuleName, radius, height, color); -} - -bool ClientCpp::addMesh(const char* meshName, const char* meshPath) -{ - return manager_->addMesh(meshName, meshPath); -} - -/*bool ClientCpp::addCone(const char* coneName, float radius, float height) -{ - return manager_->addCone(coneName, radius, height); -}*/ - -bool ClientCpp::addCone(const char* coneName, const float radius, const float height, const value_type* color) -{ - return manager_->addCone(coneName, radius, height, color); -} - -/*bool ClientCpp::addCylinder(const char* cylinderName, float radius, float height) -{ - return manager_->addCylinder(cylinderName, radius, height); -}*/ - -bool ClientCpp::addCylinder(const char* cylinderName, const float radius, const float height, const value_type* color) -{ - return manager_->addCylinder(cylinderName, radius, height, color); -} - -/*bool ClientCpp::addSphere(const char* sphereName, float radius) -{ - return manager_->addSphere(sphereName, radius); -}*/ - -bool ClientCpp::addSphere(const char* sphereName, const float radius, const value_type* color) -{ - return manager_->addSphere(sphereName, radius, color); -} - -bool ClientCpp::addLine(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* color) -{ - return manager_->addLine(lineName, pos1, pos2, color); -} - -bool ClientCpp::addTriangleFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color) -{ - return manager_->addTriangleFace(faceName, pos1, pos2, pos3, color); -} - -bool ClientCpp::addSquareFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color) -{ - return manager_->addSquareFace(faceName, pos1, pos2, pos3, pos4, color); -} - -bool ClientCpp::addURDF(const char* urdfName, const char* urdfPath, const char* urdfPackagePath) -{ - return manager_->addURDF(urdfName, urdfPath, urdfPackagePath); -} - -bool ClientCpp::createGroup(const char* groupName) -{ - return manager_->createGroup(groupName); -} - -bool ClientCpp::addToGroup(const char* nodeName, const char* groupName) -{ - return manager_->addToGroup(nodeName, groupName); -} - -bool ClientCpp::applyConfiguration(const char* nodeName, const se3::SE3& se3position) -{ - CORBA::Float corbaPosition[7]; - ClientCpp::se3ToCorba(corbaPosition, se3position); - return manager_->applyConfiguration(nodeName, corbaPosition); -} - -bool ClientCpp::setVisibility(const char* nodeName, const char* visibilityMode) -{ - return manager_->setVisibility(nodeName, visibilityMode); -} - -bool ClientCpp::setWireFrameMode(const char* nodeName, const char* wireFrameMode) -{ - return manager_->setWireFrameMode(nodeName, wireFrameMode); -} -bool ClientCpp::setLightingMode(const char* nodeName, const char* lightingMode) -{ - return manager_->setLightingMode(nodeName, lightingMode); -} - -bool ClientCpp::startCapture (const WindowID windowId, const char* filename, const char* extension) -{ - return manager_->startCapture (windowId, filename, extension); -} - -bool ClientCpp::stopCapture (const WindowID windowId) -{ - return manager_->stopCapture (windowId); -} - -bool ClientCpp::writeNodeFile (const WindowID windowId, const char* filename) -{ - return manager_->writeWindowFile (windowId, filename); -} - -} // end of namespace corbaserver -} // end of namespace graphics diff --git a/src/gui/bodytreewidget.cc b/src/gui/bodytreewidget.cc index 785f4f18d27093fd677684ebb1d5e3ac968a9cc8..f68913c0644d65a2ef4dcbd5a19f7f7624a671b5 100644 --- a/src/gui/bodytreewidget.cc +++ b/src/gui/bodytreewidget.cc @@ -20,7 +20,6 @@ #include <gepetto/gui/mainwindow.hh> #include <gepetto/gui/windows-manager.hh> #include <gepetto/gui/osgwidget.hh> -#include <gepetto/gui/meta.hh> #include <gepetto/gui/selection-event.hh> #include <gepetto/gui/node-action.hh> diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 145248f9d5ff8941d8f5801ad9be6f5b0e05bf82..19fdd855de3b1e123d01e74e5e0676812729488f 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -34,7 +34,6 @@ #include "gepetto/gui/action-search-bar.hh" #include "gepetto/gui/node-action.hh" -#include <gepetto/gui/meta.hh> #include <gepetto/gui/config-dep.hh> #if GEPETTO_GUI_HAS_PYTHONQT diff --git a/src/test-client-cpp.cc b/src/test-client-cpp.cc deleted file mode 100644 index 78ec8bf299e1cd8620d81a7628e9a4c04ab6bea2..0000000000000000000000000000000000000000 --- a/src/test-client-cpp.cc +++ /dev/null @@ -1,71 +0,0 @@ -// -// test-client-cpp.cc -// Test SceneViewer with C++ CORBA client interface. -// -// Created by Mathieu Geisert in December 2014. -// Copyright (c) 2014 LAAS-CNRS. All rights reserved. -// - -#include <gepetto/viewer/corba/client.hh> - -void se3ToCorba(CORBA::Float* corbaPosition, const se3::SE3& se3position) -{ - Eigen::Quaternion<float> q(se3position.rotation()); - corbaPosition[0] = se3position.translation()(0); - corbaPosition[1] = se3position.translation()(1); - corbaPosition[2] = se3position.translation()(2); - corbaPosition[3] = q.w(); - corbaPosition[4] = q.x(); - corbaPosition[5] = q.y(); - corbaPosition[6] = q.z(); -} - -int main(int, const char **) -{ - using namespace graphics; - using namespace corbaServer; - using namespace std; - - Client client (0, NULL); - client.connect (); - - se3::SE3 position1 = se3::SE3::Random(); - se3::SE3 position2 = se3::SE3::Random(); - se3::SE3 position3 = se3::SE3::Random(); - se3::SE3 position4 = se3::SE3::Random(); - se3::SE3 position5 = se3::SE3::Random(); - CORBA::Float pos[7]; - - Client::WindowID windowId = client.gui()->createWindow("window1"); - client.gui()->createScene("scene1"); - client.gui()->addSceneToWindow("scene1",windowId); - client.gui()->addURDF("scene1/hrp2", "/local/mgeisert/devel/src/hrp2/hrp2_14_description/urdf/hrp2_14_capsule.urdf", "/local/mgeisert/devel/src/hrp2/"); - - sleep(5); - - //vector<float> tri01 (3); - - float pos1[3]= {1.,0.,0.}; - float pos2[3] = {0.,1.,0.}; - float pos3[3]= {0.,1.,1.}; - float color[4] = {1.,1.,1.,1.}; - client.gui()->addTriangleFace("scene1/triangle", pos1, pos2, pos3, color); - - sleep(15); - - - se3ToCorba (pos, position1); - client.gui()->applyConfiguration("scene1/hrp2/RLEG_LINK0", pos); - se3ToCorba (pos, position2); - client.gui()->applyConfiguration("scene1/hrp2/RLEG_LINK1", pos); - se3ToCorba (pos, position3); - client.gui()->applyConfiguration("scene1/hrp2/LLEG_LINK1", pos); - se3ToCorba (pos, position4); - client.gui()->applyConfiguration("scene1/hrp2/LLEG_LINK2", pos); - se3ToCorba (pos, position5); - client.gui()->applyConfiguration("scene1/hrp2/BODY", pos); - - client.gui()->refresh(); - - return 0; -}