diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 27a44a97145f043086badaf7e9a3ec98876d0810..e7aa5c3ae6a50cc2931562d1ca1baa4abc2a3881 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,12 +17,13 @@ SET(LIBRARY_NAME ${PROJECT_NAME}) -ADD_EXECUTABLE (basic-scene basic-scene.cc) -TARGET_LINK_LIBRARIES(basic-scene ${LIBRARY_NAME}) -PKG_CONFIG_USE_DEPENDENCY(basic-scene gepetto-viewer) -PKG_CONFIG_USE_DEPENDENCY(basic-scene omniORB4) +MACRO(ADD_EXAMPLE NAME SOURCE) + ADD_EXECUTABLE (${NAME} ${SOURCE}) + TARGET_LINK_LIBRARIES(${NAME} ${LIBRARY_NAME}) + PKG_CONFIG_USE_DEPENDENCY(${NAME} gepetto-viewer) + PKG_CONFIG_USE_DEPENDENCY(${NAME} omniORB4) +ENDMACRO() -ADD_EXECUTABLE (display-urdf display-urdf.cc) -TARGET_LINK_LIBRARIES(display-urdf ${LIBRARY_NAME}) -PKG_CONFIG_USE_DEPENDENCY(display-urdf gepetto-viewer) -PKG_CONFIG_USE_DEPENDENCY(display-urdf omniORB4) +ADD_EXAMPLE (basic-scene basic-scene.cc) +ADD_EXAMPLE (display-urdf display-urdf.cc) +ADD_EXAMPLE (free-functions free-functions.cc) diff --git a/examples/free-functions.cc b/examples/free-functions.cc new file mode 100644 index 0000000000000000000000000000000000000000..531151e426055759e39528c467e6520b85edb165 --- /dev/null +++ b/examples/free-functions.cc @@ -0,0 +1,30 @@ +// +// free-functions.cc +// Example usage of gepetto-viewer C++ CORBA client interface. +// +// Created by Joseph Mirabel in 2020. +// Copyright (c) 2020 LAAS-CNRS. All rights reserved. +// + +#include <gepetto/viewer/corba/client.hh> +#include <gepetto/viewer/corba/conversions.hh> + +namespace gui = gepetto::viewer::corba; + +int main(int, const char **) +{ + gui::connect ("windowName", true); + + if (gui::connected()) gui::gui()->createWindow("window1"); + if (gui::connected()) gui::gui()->addSphere ("window1/sphere", 0.5f, gui::white); + +#if __cplusplus >= 201103L + if (gui::connected()) gui::gui()->addCurve("window1/points", + gepetto::viewer::corba::positionSeq ({ {0., 1., 0.}, {0., 1., 2.}, }), + gui::green); +#endif + + if (gui::connected()) gui::gui()->refresh(); + + return 0; +} diff --git a/include/gepetto/viewer/corba/client.hh b/include/gepetto/viewer/corba/client.hh index 53b933a1db8c9437d303624cfd60bb822afc6a78..7caf2c310aa67f1ea0019bda7004ba5f753a1253 100644 --- a/include/gepetto/viewer/corba/client.hh +++ b/include/gepetto/viewer/corba/client.hh @@ -71,6 +71,27 @@ namespace corba { connect (windowName, dontRaise, url, host, port); return gui(); } + +#if __cplusplus >= 201103L + constexpr corbaserver::Color + white { 1.0f, 1.0f, 1.0f, 1.0f }, + lightWhite { 0.9f, 0.9f, 0.9f, 1.0f }, + green { 0.0f, 1.0f, 0.0f, 1.0f }, + lightGreen { 0.0f, 0.9f, 0.0f, 1.0f }, + yellow { 1.0f, 1.0f, 0.0f, 1.0f }, + lightYellow { 0.9f, 0.9f, 0.0f, 1.0f }, + blue { 0.0f, 0.0f, 1.0f, 1.0f }, + lightBlue { 0.0f, 0.0f, 0.9f, 1.0f }, + grey { 0.7f, 0.7f, 0.7f, 1.0f }, + lightGrey { 0.7f, 0.7f, 0.7f, 0.7f }, + red { 1.0f, 0.0f, 0.0f, 1.0f }, + lightRed { 0.9f, 0.0f, 0.0f, 1.0f }, + black { 0.0f, 0.0f, 0.0f, 1.0f }, + lightBlack { 0.1f, 0.1f, 0.1f, 1.0f }, + brown {0.85f, 0.75f, 0.15f, 1.0f }, + lightBrown {0.75f, 0.65f, 0.10f, 1.0f }; +#endif + } //end of namespace corba } //end of namespace viewer } //end of namespace gepetto