diff --git a/CHANGELOG.md b/CHANGELOG.md index 87c240e3b808c..dd45b9fc920c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ * Added voxel grid map: [#1076](https://github.com/dartsim/dart/pull/1076), [#1083](https://github.com/dartsim/dart/pull/1083) * Added heightmap support: [#1069](https://github.com/dartsim/dart/pull/1069) +* GUI + + * Reorganized OpenGL and GLUT files: [#1088](https://github.com/dartsim/dart/pull/1088) + ### [DART 6.5.0 (2018-05-12)](https://github.com/dartsim/dart/milestone/41?closed=1) * Common diff --git a/dart/collision/Option.hpp b/dart/collision/Option.hpp index dcfda7ce57157..375ba8c83778c 100644 --- a/dart/collision/Option.hpp +++ b/dart/collision/Option.hpp @@ -33,8 +33,8 @@ #ifndef DART_COLLISION_OPTION_HPP_ #define DART_COLLISION_OPTION_HPP_ -#warning "This header has been deprecated in DART 6.1. "\ - "Please include CollisionOption.hpp intead." +#pragma message("This header has been deprecated in DART 6.1. "\ + "Please include CollisionOption.hpp intead.") #include "dart/collision/CollisionOption.hpp" diff --git a/dart/collision/Result.hpp b/dart/collision/Result.hpp index 8c7324d753bc0..989081c54e514 100644 --- a/dart/collision/Result.hpp +++ b/dart/collision/Result.hpp @@ -33,8 +33,8 @@ #ifndef DART_COLLISION_RESULT_HPP_ #define DART_COLLISION_RESULT_HPP_ -#warning "This header has been deprecated in DART 6.1. "\ - "Please include CollisionResult.hpp intead." +#pragma message("This header has been deprecated in DART 6.1. "\ + "Please include CollisionResult.hpp intead.") #include "dart/collision/CollisionResult.hpp" diff --git a/dart/dynamics/MultiSphereShape.hpp b/dart/dynamics/MultiSphereShape.hpp index cad555e5b28d4..e474767d97113 100644 --- a/dart/dynamics/MultiSphereShape.hpp +++ b/dart/dynamics/MultiSphereShape.hpp @@ -33,8 +33,8 @@ #ifndef DART_DYNAMICS_MULTISPHERESHAPE_HPP_ #define DART_DYNAMICS_MULTISPHERESHAPE_HPP_ -#warning "This header has been deprecated in DART 6.2. "\ - "Please include MultiSphereConvexHullShape.hpp intead." +#pragma message("This header has been deprecated in DART 6.2. "\ + "Please include MultiSphereConvexHullShape.hpp intead.") #include "dart/dynamics/MultiSphereConvexHullShape.hpp" diff --git a/dart/gui/CMakeLists.txt b/dart/gui/CMakeLists.txt index 795de42bf41ad..8988c85aa226a 100644 --- a/dart/gui/CMakeLists.txt +++ b/dart/gui/CMakeLists.txt @@ -21,15 +21,31 @@ else() endif() # Search all header and source files -file(GLOB hdrs "*.hpp") -file(GLOB srcs "*.cpp") +file(GLOB hdrs "*.hpp" "*.h" "detail/*.hpp") +file(GLOB srcs "*.cpp" "*.c" "detail/*.cpp") + +function(dart_add_gui_headers) + dart_property_add(DART_GUI_HEADERS ${ARGN}) +endfunction() + +function(dart_add_gui_sources) + dart_property_add(DART_GUI_SOURCES ${ARGN}) +endfunction() + +# Add required subdirectory +add_subdirectory(glut) + +get_property(dart_gui_headers GLOBAL PROPERTY DART_GUI_HEADERS) +get_property(dart_gui_sources GLOBAL PROPERTY DART_GUI_SOURCES) # Set local target name set(target_name ${PROJECT_NAME}-gui) set(component_name gui) # Add target -dart_add_library(${target_name} ${hdrs} ${srcs}) +dart_add_library(${target_name} + ${hdrs} ${srcs} ${dart_gui_headers} ${dart_gui_sources} +) target_include_directories( ${target_name} SYSTEM PUBLIC @@ -62,6 +78,25 @@ add_subdirectory(osg) # Generate header for this namespace dart_get_filename_components(header_names "gui headers" ${hdrs}) + +# Remove deprecated files from the list +list(REMOVE_ITEM header_names + "GLFuncs.hpp" + "GlutWindow.hpp" + "GraphWindow.hpp" + "LoadGlut.hpp" + "MotionBlurSimWindow.hpp" + "SimWindow.hpp" + "SoftSimWindow.hpp" + "Win2D.hpp" + "Win3D.hpp" +) + +set( + header_names + ${header_names} + glut/glut.hpp +) dart_generate_include_header_list( gui_headers "dart/gui/" diff --git a/dart/gui/GLFuncs.cpp b/dart/gui/GLFuncs.cpp index 5b1183e32b1d3..bce15c9c581d1 100644 --- a/dart/gui/GLFuncs.cpp +++ b/dart/gui/GLFuncs.cpp @@ -38,40 +38,18 @@ #include +#include "dart/common/Console.hpp" #include "dart/math/Constants.hpp" #include "dart/gui/LoadOpengl.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/GLUTFuncs.hpp" +// TODO(JS): remove once glut become an optional dependency namespace dart { namespace gui { - void drawStringOnScreen(float _x, float _y, const std::string& _s, - bool _bigFont) { - // draws text on the screen - GLint oldMode; - glGetIntegerv(GL_MATRIX_MODE, &oldMode); - glMatrixMode(GL_PROJECTION); - - glPushMatrix(); - glLoadIdentity(); - gluOrtho2D(0.0, 1.0, 0.0, 1.0); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glRasterPos2f(_x, _y); - unsigned int length = _s.length(); - for (unsigned int c = 0; c < length; c++) { - if (_bigFont) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, _s.at(c) ); - else - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, _s.at(c) ); - } - glPopMatrix(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(oldMode); +void drawStringOnScreen(float x, float y, const std::string& s, bool bigFont) +{ + glut::drawStringOnScreen(x, y, s, bigFont); } // draw a 3D arrow starting from pt along dir, the arrowhead is on the other end diff --git a/dart/gui/GLFuncs.hpp b/dart/gui/GLFuncs.hpp index d213a5a474e47..2e6df3c662918 100644 --- a/dart/gui/GLFuncs.hpp +++ b/dart/gui/GLFuncs.hpp @@ -34,15 +34,18 @@ #define DART_GUI_GLFUNCS_HPP_ #include - #include +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -/// \brief - void drawStringOnScreen(float _x, float _y, const std::string& _s, - bool _bigFont = true); +/// \deprecated Deprecated in 6.6. Please use +/// dart::gui::glut::drawStringOnScreen() instead in +/// dart/gui/glut/GLUTFuncs.hpp file. +DART_DEPRECATED(6.6) +void drawStringOnScreen(float _x, float _y, const std::string& _s, + bool _bigFont = true); /// \brief void drawArrow3D(const Eigen::Vector3d& _pt, const Eigen::Vector3d& _dir, diff --git a/dart/gui/GlutWindow.hpp b/dart/gui/GlutWindow.hpp index d1b7abeeccdb9..2717cd62bc545 100644 --- a/dart/gui/GlutWindow.hpp +++ b/dart/gui/GlutWindow.hpp @@ -33,67 +33,18 @@ #ifndef DART_GUI_GLUTWINDOW_HPP_ #define DART_GUI_GLUTWINDOW_HPP_ -#include +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/Window.hpp instead.") -#include "dart/gui/LoadOpengl.hpp" -#include "dart/gui/RenderInterface.hpp" +#include "dart/gui/glut/Window.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -/// \brief -class GlutWindow { -public: - GlutWindow(); - virtual ~GlutWindow(); +using GlutWindow DART_DEPRECATED(6.6) = ::dart::gui::glut::Window; - /// \warning This function should be called once. - virtual void initWindow(int _w, int _h, const char* _name); - - // callback functions - static void reshape(int _w, int _h); - static void keyEvent(unsigned char _key, int _x, int _y); - static void specKeyEvent(int _key, int _x, int _y); - static void mouseClick(int _button, int _state, int _x, int _y); - static void mouseDrag(int _x, int _y); - static void mouseMove(int _x, int _y); - static void refresh(); - static void refreshTimer(int _val); - static void runTimer(int _val); - - static GlutWindow* current(); - static std::vector mWindows; - static std::vector mWinIDs; - -protected: - // callback implementation - virtual void resize(int _w, int _h) = 0; - virtual void render() = 0; - virtual void keyboard(unsigned char _key, int _x, int _y); - virtual void specKey(int _key, int _x, int _y); - virtual void click(int _button, int _state, int _x, int _y); - virtual void drag(int _x, int _y); - virtual void move(int _x, int _y); - virtual void displayTimer(int _val); - virtual void simTimer(int _val); - - virtual bool screenshot(); - - int mWinWidth; - int mWinHeight; - int mMouseX; - int mMouseY; - double mDisplayTimeout; - bool mMouseDown; - bool mMouseDrag; - bool mCapture; - double mBackground[4]; - gui::RenderInterface* mRI; - std::vector mScreenshotTemp; - std::vector mScreenshotTemp2; -}; - -} // namespace gui -} // namespace dart +} // namespace gui +} // namespace dart #endif // DART_GUI_GLUTWINDOW_HPP_ diff --git a/dart/gui/GraphWindow.hpp b/dart/gui/GraphWindow.hpp index e71382ba9380a..624220f392d8f 100644 --- a/dart/gui/GraphWindow.hpp +++ b/dart/gui/GraphWindow.hpp @@ -39,35 +39,16 @@ #ifndef DART_GUI_GRAPHWINDOW_HPP_ #define DART_GUI_GRAPHWINDOW_HPP_ -#include +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/GraphWindow.hpp instead.") -#include - -#include "dart/gui/Win2D.hpp" +#include "dart/gui/glut/GraphWindow.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -/// \brief -class GraphWindow : public Win2D { -public: - /// \brief - GraphWindow(); - - /// \brief - virtual ~GraphWindow(); - - /// \brief - void draw() override; - - /// \brief - void keyboard(unsigned char _key, int _x, int _y) override; - - void setData(Eigen::VectorXd _data); - -protected: - Eigen::VectorXd mData; -}; +using GraphWindow DART_DEPRECATED(6.6) = ::dart::gui::glut::GraphWindow; } // namespace gui } // namespace dart diff --git a/dart/gui/LoadGlut.hpp b/dart/gui/LoadGlut.hpp index 18cf436eddf81..c5baa79309211 100644 --- a/dart/gui/LoadGlut.hpp +++ b/dart/gui/LoadGlut.hpp @@ -33,15 +33,9 @@ #ifndef DART_GUI_LOADGLUT_HPP_ #define DART_GUI_LOADGLUT_HPP_ -#if defined(_WIN32) - #include // To disable glut::exit() function - #include -#elif defined(__linux__) - #include -#elif defined(__APPLE__) - #include -#else - #error "Load OpenGL Error: What's your operating system?" -#endif +#pragma message("This file is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/LoadGlut.hpp instead.") + +#include "dart/gui/glut/LoadGlut.hpp" #endif // DART_GUI_LOADGLUT_HPP_ diff --git a/dart/gui/MotionBlurSimWindow.hpp b/dart/gui/MotionBlurSimWindow.hpp index 0950fb2688059..ca53ebbc801b2 100644 --- a/dart/gui/MotionBlurSimWindow.hpp +++ b/dart/gui/MotionBlurSimWindow.hpp @@ -9,49 +9,19 @@ #ifndef DART_GUI_MOTIONBLURSIMWINDOW_HPP_ #define DART_GUI_MOTIONBLURSIMWINDOW_HPP_ -#include -#include +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/MotionBlurSimWindow.hpp instead.") -#include "dart/gui/SimWindow.hpp" +#include "dart/gui/glut/MotionBlurSimWindow.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -class MotionBlurSimWindow : public SimWindow -{ -public: +using MotionBlurSimWindow DART_DEPRECATED(6.6) = + ::dart::gui::glut::MotionBlurSimWindow; - /// \brief - MotionBlurSimWindow(); - - /// \brief - virtual ~MotionBlurSimWindow(); - - // Set the Quality of Motion Blur - // Default is 5 (record position of every frame) - // int from 0 (No motion blur) - 5 (Highest) - // The function takes value smaller than 0 as 0, larger than 5 as 5 - void setMotionBlurQuality(int _val); - - // Override the render function in dart/gui/Win3D.hpp - // To draw the motion image - // Render function is called once per GUI display time - // but in MotionBlurSimWindow, draw function will run in motion blur frequency - void render() override; - - // Override the display timer, - // Move the part of "step" in world function to the render function - void displayTimer(int _val) override; - -protected: - // Determines the frequency of the motion blur - // Default is 1, which means motion blur effect has the highest quality - // When set to m, motion blur record data every m frames - int mMotionBlurFrequency; - -}; // End of Class Definition - -} // namespace gui -} // namespace dart +} // namespace gui +} // namespace dart #endif // DART_GUI_MOTIONBLURSIMWINDOW_HPP_ diff --git a/dart/gui/SimWindow.hpp b/dart/gui/SimWindow.hpp index 2948aa3e6daf0..1915008c8fa2e 100644 --- a/dart/gui/SimWindow.hpp +++ b/dart/gui/SimWindow.hpp @@ -39,120 +39,16 @@ #ifndef DART_GUI_SIMWINDOW_HPP_ #define DART_GUI_SIMWINDOW_HPP_ -#include - -#include +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/SimWindow.hpp instead.") +#include "dart/gui/glut/SimWindow.hpp" #include "dart/common/Deprecated.hpp" -#include "dart/gui/Win3D.hpp" -#include "dart/simulation/World.hpp" namespace dart { namespace gui { -class GraphWindow; - -/// \brief -class SimWindow : public Win3D { -public: - /// \brief - SimWindow(); - - /// \brief - virtual ~SimWindow(); - - /// \brief - virtual void timeStepping(); - - virtual void drawWorld() const; - - virtual void drawSkeletons() const; - - DART_DEPRECATED(6.0) - virtual void drawSkels(); - - DART_DEPRECATED(6.0) - virtual void drawEntities(); - - /// \brief - void displayTimer(int _val) override; - - /// \brief - void draw() override; - - /// \brief - void keyboard(unsigned char _key, int _x, int _y) override; - - /// \brief - void setWorld(dart::simulation::WorldPtr _world); - - /// \brief Save world in 'tempWorld.txt' - void saveWorld(); - - /// \brief Plot _data in a 2D window - void plot(Eigen::VectorXd& _data); -// bool isSimulating() const { return mSimulating; } - -// void setSimulatingFlag(int _flag) { mSimulating = _flag; } - -protected: - - virtual void drawSkeleton( - const dynamics::Skeleton* skeleton, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true) const; - - virtual void drawEntity( - const dynamics::Entity* entity, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true) const; - - virtual void drawBodyNode( - const dynamics::BodyNode* bodyNode, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true, - bool recursive = false) const; - - virtual void drawShapeFrame( - const dynamics::ShapeFrame* shapeFrame, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true) const; - - virtual void drawShape( - const dynamics::Shape* shape, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5)) const; - - virtual void drawPointMasses( - const std::vector pointMasses, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true) const; - - virtual void drawMarker( - const dynamics::Marker* marker, - const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), - bool useDefaultColor = true) const; - - /// \brief - simulation::WorldPtr mWorld; - - /// \brief - int mPlayFrame; - - /// \brief - bool mPlay; - - /// \brief - bool mSimulating; - - /// If true, render point masses of soft bodies - bool mShowPointMasses; - - /// If true, render markers - bool mShowMarkers; - - /// \brief Array of graph windows - std::vector mGraphWindows; -}; +using SimWindow DART_DEPRECATED(6.6) = ::dart::gui::glut::SimWindow; } // namespace gui } // namespace dart diff --git a/dart/gui/SoftSimWindow.hpp b/dart/gui/SoftSimWindow.hpp index 0fde069c84968..c1588361b7cfd 100644 --- a/dart/gui/SoftSimWindow.hpp +++ b/dart/gui/SoftSimWindow.hpp @@ -39,31 +39,16 @@ #ifndef DART_GUI_SOFTSIMWINDOW_HPP_ #define DART_GUI_SOFTSIMWINDOW_HPP_ -#include "dart/gui/SimWindow.hpp" +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/SoftSimWindow.hpp instead.") + +#include "dart/gui/glut/SoftSimWindow.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -/// \brief -class SoftSimWindow : public SimWindow -{ -public: - /// \brief - SoftSimWindow(); - - /// \brief - virtual ~SoftSimWindow(); - - /// \brief - void keyboard(unsigned char key, int x, int y) override; - -protected: - /// \brief - bool mShowPointMasses; - - /// \brief - bool mShowMeshs; -}; +using SoftSimWindow DART_DEPRECATED(6.6) = ::dart::gui::glut::SoftSimWindow; } // namespace gui } // namespace dart diff --git a/dart/gui/Win2D.hpp b/dart/gui/Win2D.hpp index c985c09320fee..9fa6f78cc687d 100644 --- a/dart/gui/Win2D.hpp +++ b/dart/gui/Win2D.hpp @@ -33,48 +33,16 @@ #ifndef DART_GUI_WIN2D_HPP_ #define DART_GUI_WIN2D_HPP_ -#include "dart/gui/GlutWindow.hpp" +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/Win2D.hpp instead.") + +#include "dart/gui/glut/Win2D.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -/// \brief -class Win2D : public GlutWindow { -public: - /// \brief - Win2D(); - - /// \brief - void resize(int _w, int _h) override; - - /// \brief - void render() override; - - /// \brief - void keyboard(unsigned char _key, int _x, int _y) override; - - /// \brief - void click(int _button, int _state, int _x, int _y) override; - - /// \brief - void drag(int _x, int _y) override; - - /// \brief - virtual void initGL(); - - /// \brief - virtual void draw() = 0; - -protected: - /// \brief - bool mTranslate; - - /// \brief - double mTransX; - - /// \brief - double mTransY; -}; +using Win2D DART_DEPRECATED(6.6) = ::dart::gui::glut::Win2D; } // namespace gui } // namespace dart diff --git a/dart/gui/Win3D.hpp b/dart/gui/Win3D.hpp index 8407f889c7ba9..49eaa093af915 100644 --- a/dart/gui/Win3D.hpp +++ b/dart/gui/Win3D.hpp @@ -33,43 +33,16 @@ #ifndef DART_GUI_WIN3D_HPP_ #define DART_GUI_WIN3D_HPP_ -#include +#pragma message("This header is deprecated as of DART 6.6. "\ + "Please use dart/gui/glut/Win3D.hpp instead.") -#include "dart/gui/GlutWindow.hpp" -#include "dart/gui/Trackball.hpp" +#include "dart/gui/glut/Win3D.hpp" +#include "dart/common/Deprecated.hpp" namespace dart { namespace gui { -class Win3D : public GlutWindow { -public: - Win3D(); - - void initWindow(int _w, int _h, const char* _name) override; - void resize(int _w, int _h) override; - void render() override; - - void keyboard(unsigned char _key, int _x, int _y) override; - void click(int _button, int _state, int _x, int _y) override; - void drag(int _x, int _y) override; - - virtual void initGL(); - virtual void initLights(); - - virtual void draw()=0; - -protected: - Trackball mTrackBall; - Eigen::Vector3d mTrans; - Eigen::Vector3d mEye; - Eigen::Vector3d mUp; - float mZoom; - float mPersp; - - bool mRotate; - bool mTranslate; - bool mZooming; -}; +using Win3D DART_DEPRECATED(6.6) = ::dart::gui::glut::Win3D; } // namespace gui } // namespace dart diff --git a/dart/gui/glut/CMakeLists.txt b/dart/gui/glut/CMakeLists.txt new file mode 100644 index 0000000000000..9ddaccad48d3d --- /dev/null +++ b/dart/gui/glut/CMakeLists.txt @@ -0,0 +1,25 @@ +# Search all header and source files +file(GLOB hdrs "*.hpp") +file(GLOB srcs "*.cpp") +dart_add_gui_headers(${hdrs} ${detail_hdrs}) +dart_add_gui_sources(${srcs} ${detail_srcs}) + +# Generate header for this namespace +dart_get_filename_components(header_names "gui_glut_headers headers" ${hdrs}) +dart_generate_include_header_list( + gui_glut_headers + "dart/gui/glut/" + "gui_glut_headers headers" + ${header_names} +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/glut.hpp.in + ${CMAKE_CURRENT_BINARY_DIR}/glut.hpp +) + +# Install +install( + FILES ${hdrs} ${CMAKE_CURRENT_BINARY_DIR}/glut.hpp + DESTINATION include/dart/gui/glut + COMPONENT headers +) diff --git a/dart/gui/glut/GLUTFuncs.cpp b/dart/gui/glut/GLUTFuncs.cpp new file mode 100644 index 0000000000000..a694cc6d6385a --- /dev/null +++ b/dart/gui/glut/GLUTFuncs.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "dart/gui/glut/GLUTFuncs.hpp" + +#include +#include +#include + +#include + +#include "dart/gui/LoadOpengl.hpp" +#include "dart/gui/glut/LoadGlut.hpp" + +namespace dart { +namespace gui { +namespace glut { + +void drawStringOnScreen(float x, float y, const std::string& s, bool bigFont) +{ + // draws text on the screen + GLint oldMode; + glGetIntegerv(GL_MATRIX_MODE, &oldMode); + glMatrixMode(GL_PROJECTION); + + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D(0.0, 1.0, 0.0, 1.0); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glRasterPos2f(x, y); + unsigned int length = s.length(); + for (unsigned int c = 0; c < length; c++) + { + if (bigFont) + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, s.at(c) ); + else + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, s.at(c) ); + } + glPopMatrix(); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(oldMode); +} + +} // namespace glut +} // namespace gui +} // namespace dart diff --git a/dart/gui/glut/GLUTFuncs.hpp b/dart/gui/glut/GLUTFuncs.hpp new file mode 100644 index 0000000000000..605ad78fc21f1 --- /dev/null +++ b/dart/gui/glut/GLUTFuncs.hpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_GLFUNCS_HPP_ +#define DART_GUI_GLUT_GLFUNCS_HPP_ + +#include + +namespace dart { +namespace gui { +namespace glut { + +void drawStringOnScreen( + float x, float y, const std::string& s, bool bigFont = true); + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_GLFUNCS_HPP_ diff --git a/dart/gui/GlutWindow.cpp b/dart/gui/glut/GlutWindow.cpp similarity index 81% rename from dart/gui/GlutWindow.cpp rename to dart/gui/glut/GlutWindow.cpp index bdeaf8e7b582a..83a3275be3d02 100644 --- a/dart/gui/GlutWindow.cpp +++ b/dart/gui/glut/GlutWindow.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/GlutWindow.hpp" +#include "dart/gui/glut/Window.hpp" #include "dart/external/lodepng/lodepng.h" @@ -48,17 +48,18 @@ #include #include "dart/common/Console.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/LoadGlut.hpp" #include "dart/gui/GLFuncs.hpp" #include "dart/gui/OpenGLRenderInterface.hpp" namespace dart { namespace gui { +namespace glut { -std::vector GlutWindow::mWindows; -std::vector GlutWindow::mWinIDs; +std::vector Window::mWindows; +std::vector Window::mWinIDs; -GlutWindow::GlutWindow() { +Window::Window() { mWinWidth = 0; mWinHeight = 0; mMouseX = 0; @@ -74,11 +75,11 @@ GlutWindow::GlutWindow() { mRI = nullptr; } -GlutWindow::~GlutWindow() { +Window::~Window() { delete mRI; } -void GlutWindow::initWindow(int _w, int _h, const char* _name) { +void Window::initWindow(int _w, int _h, const char* _name) { mWindows.push_back(this); mWinWidth = _w; @@ -113,53 +114,53 @@ void GlutWindow::initWindow(int _w, int _h, const char* _name) { // Note: We book the timer id 0 for the main rendering purpose. } -void GlutWindow::reshape(int _w, int _h) { +void Window::reshape(int _w, int _h) { current()->mScreenshotTemp = std::vector(_w*_h*4); current()->mScreenshotTemp2 = std::vector(_w*_h*4); current()->resize(_w, _h); } -void GlutWindow::keyEvent(unsigned char _key, int _x, int _y) { +void Window::keyEvent(unsigned char _key, int _x, int _y) { current()->keyboard(_key, _x, _y); } -void GlutWindow::specKeyEvent(int _key, int _x, int _y) { +void Window::specKeyEvent(int _key, int _x, int _y) { current()->specKey(_key, _x, _y); } -void GlutWindow::mouseClick(int _button, int _state, int _x, int _y) { +void Window::mouseClick(int _button, int _state, int _x, int _y) { current()->click(_button, _state, _x, _y); } -void GlutWindow::mouseDrag(int _x, int _y) { +void Window::mouseDrag(int _x, int _y) { current()->drag(_x, _y); } -void GlutWindow::mouseMove(int _x, int _y) { +void Window::mouseMove(int _x, int _y) { current()->move(_x, _y); } -void GlutWindow::refresh() { +void Window::refresh() { current()->render(); } -void GlutWindow::refreshTimer(int _val) { +void Window::refreshTimer(int _val) { current()->displayTimer(_val); } -void GlutWindow::displayTimer(int _val) { +void Window::displayTimer(int _val) { glutPostRedisplay(); glutTimerFunc(mDisplayTimeout, refreshTimer, _val); } -void GlutWindow::simTimer(int /*_val*/) { +void Window::simTimer(int /*_val*/) { } -void GlutWindow::runTimer(int _val) { +void Window::runTimer(int _val) { current()->simTimer(_val); } -bool GlutWindow::screenshot() { +bool Window::screenshot() { static int count = 0; const char directory[8] = "frames"; const char fileBase[8] = "Capture"; @@ -181,7 +182,7 @@ bool GlutWindow::screenshot() { if (!S_ISDIR(buff.st_mode)) { - dtwarn << "[GlutWindow::screenshot] 'frames' is not a directory, " + dtwarn << "[Window::screenshot] 'frames' is not a directory, " << "cannot write a screenshot\n"; return false; } @@ -218,7 +219,7 @@ bool GlutWindow::screenshot() { } } -inline GlutWindow* GlutWindow::current() { +inline Window* Window::current() { int id = glutGetWindow(); for (unsigned int i = 0; i < mWinIDs.size(); i++) { if (mWinIDs.at(i) == id) { @@ -229,21 +230,22 @@ inline GlutWindow* GlutWindow::current() { exit(0); } -void GlutWindow::keyboard(unsigned char /*_key*/, int /*_x*/, int /*_y*/) { +void Window::keyboard(unsigned char /*_key*/, int /*_x*/, int /*_y*/) { // TODO(JS): Is 2d point information necessary for keyboard event? } -void GlutWindow::specKey(int /*_key*/, int /*_x*/, int /*_y*/) { +void Window::specKey(int /*_key*/, int /*_x*/, int /*_y*/) { } -void GlutWindow::click(int /*_button*/, int /*_state*/, int /*_x*/, int /*_y*/) { +void Window::click(int /*_button*/, int /*_state*/, int /*_x*/, int /*_y*/) { } -void GlutWindow::drag(int /*_x*/, int /*_y*/) { +void Window::drag(int /*_x*/, int /*_y*/) { } -void GlutWindow::move(int /*_x*/, int /*_y*/) { +void Window::move(int /*_x*/, int /*_y*/) { } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/GraphWindow.cpp b/dart/gui/glut/GraphWindow.cpp similarity index 93% rename from dart/gui/GraphWindow.cpp rename to dart/gui/glut/GraphWindow.cpp index 5c201f7704070..7b17172c9cde6 100644 --- a/dart/gui/GraphWindow.cpp +++ b/dart/gui/glut/GraphWindow.cpp @@ -36,17 +36,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/GraphWindow.hpp" +#include "dart/gui/glut/GraphWindow.hpp" #include #include #include -#include "dart/gui/GLFuncs.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/GLUTFuncs.hpp" +#include "dart/gui/glut/LoadGlut.hpp" namespace dart { namespace gui { +namespace glut { GraphWindow::GraphWindow() : Win2D() { @@ -94,7 +95,7 @@ void GraphWindow::draw() { #endif std::string frame(buff); glColor3f(0.0, 0.0, 0.0); - gui::drawStringOnScreen(xPos, 0.01f, frame, false); + drawStringOnScreen(xPos, 0.01f, frame, false); xPos += 0.2; } @@ -109,7 +110,7 @@ void GraphWindow::draw() { #endif std::string frame(buff); glColor3f(0.0, 0.0, 0.0); - gui::drawStringOnScreen(0.01f, yPos, frame, false); + drawStringOnScreen(0.01f, yPos, frame, false); yPos += 0.2; } } @@ -126,5 +127,6 @@ void GraphWindow::setData(Eigen::VectorXd _data) { mData = _data; } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/glut/GraphWindow.hpp b/dart/gui/glut/GraphWindow.hpp new file mode 100644 index 0000000000000..1fe561994a1ad --- /dev/null +++ b/dart/gui/glut/GraphWindow.hpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_GRAPHWINDOW_HPP_ +#define DART_GUI_GLUT_GRAPHWINDOW_HPP_ + +#include + +#include + +#include "dart/gui/glut/Win2D.hpp" + +namespace dart { +namespace gui { +namespace glut { + +/// \brief +class GraphWindow : public Win2D { +public: + /// \brief + GraphWindow(); + + /// \brief + virtual ~GraphWindow(); + + /// \brief + void draw() override; + + /// \brief + void keyboard(unsigned char _key, int _x, int _y) override; + + void setData(Eigen::VectorXd _data); + +protected: + Eigen::VectorXd mData; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_GRAPHWINDOW_HPP_ diff --git a/dart/gui/glut/LoadGlut.hpp b/dart/gui/glut/LoadGlut.hpp new file mode 100644 index 0000000000000..2ea3c0d7419c9 --- /dev/null +++ b/dart/gui/glut/LoadGlut.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_LOADGLUT_HPP_ +#define DART_GUI_GLUT_LOADGLUT_HPP_ + +#if defined(_WIN32) + #include // To disable glut::exit() function + #include +#elif defined(__linux__) + #include +#elif defined(__APPLE__) + #include +#else + #error "Load OpenGL Error: What's your operating system?" +#endif + +#endif // DART_GUI_GLUT_LOADGLUT_HPP_ diff --git a/dart/gui/MotionBlurSimWindow.cpp b/dart/gui/glut/MotionBlurSimWindow.cpp similarity index 94% rename from dart/gui/MotionBlurSimWindow.cpp rename to dart/gui/glut/MotionBlurSimWindow.cpp index 6bad000c29f62..719dc8466d972 100644 --- a/dart/gui/MotionBlurSimWindow.cpp +++ b/dart/gui/glut/MotionBlurSimWindow.cpp @@ -9,29 +9,33 @@ ///////////////////////////////////////////////////////////////////////// // OpenGL Motion blur require the Accumulate function of OpenGL // To intergrate this class into the engine -// Change line 86 of dart/gui/GlutWindows.cpp +// Change line 86 of dart/gui/glut/Window.cpp // From glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE); // to glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE | GLUT_ACCUM); ///////////////////////////////////////////////////////////////////////// -#include "dart/gui/MotionBlurSimWindow.hpp" +#include "dart/gui/glut/MotionBlurSimWindow.hpp" #include "dart/constraint/ConstraintSolver.hpp" #include "dart/gui/GLFuncs.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/LoadGlut.hpp" namespace dart { namespace gui { +namespace glut { +//============================================================================== MotionBlurSimWindow::MotionBlurSimWindow() : SimWindow() { mMotionBlurFrequency = 1; } +//============================================================================== MotionBlurSimWindow::~MotionBlurSimWindow() { + // Do nothing } //============================================================================== @@ -218,8 +222,7 @@ void MotionBlurSimWindow::displayTimer(int _val) glutPostRedisplay(); glutTimerFunc(mDisplayTimeout, refreshTimer, _val); } - +} // namespace glut } // namespace gui } // namespace dart - diff --git a/dart/gui/glut/MotionBlurSimWindow.hpp b/dart/gui/glut/MotionBlurSimWindow.hpp new file mode 100644 index 0000000000000..448ee40f5b28d --- /dev/null +++ b/dart/gui/glut/MotionBlurSimWindow.hpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// +// MotionBlurSimWindow.hpp +// dart +// +// Created by Dong Xu on 1/22/17. +// +// + +#ifndef DART_GUI_GLUT_MOTIONBLURSIMWINDOW_HPP_ +#define DART_GUI_GLUT_MOTIONBLURSIMWINDOW_HPP_ + +#include +#include + +#include "dart/gui/glut/SimWindow.hpp" + +namespace dart { +namespace gui { +namespace glut { + +class MotionBlurSimWindow : public glut::SimWindow +{ +public: + /// \brief + MotionBlurSimWindow(); + + /// \brief + virtual ~MotionBlurSimWindow(); + + // Set the Quality of Motion Blur + // Default is 5 (record position of every frame) + // int from 0 (No motion blur) - 5 (Highest) + // The function takes value smaller than 0 as 0, larger than 5 as 5 + void setMotionBlurQuality(int _val); + + // Override the render function in dart/gui/Win3D.hpp + // To draw the motion image + // Render function is called once per GUI display time + // but in MotionBlurSimWindow, draw function will run in motion blur frequency + void render() override; + + // Override the display timer, + // Move the part of "step" in world function to the render function + void displayTimer(int _val) override; + +protected: + // Determines the frequency of the motion blur + // Default is 1, which means motion blur effect has the highest quality + // When set to m, motion blur record data every m frames + int mMotionBlurFrequency; + +}; // End of Class Definition + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_MOTIONBLURSIMWINDOW_HPP_ diff --git a/dart/gui/SimWindow.cpp b/dart/gui/glut/SimWindow.cpp similarity index 98% rename from dart/gui/SimWindow.cpp rename to dart/gui/glut/SimWindow.cpp index dec29f8592060..922f50993e362 100644 --- a/dart/gui/SimWindow.cpp +++ b/dart/gui/glut/SimWindow.cpp @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/SimWindow.hpp" +#include "dart/gui/glut/SimWindow.hpp" #include #include @@ -59,13 +59,14 @@ #include "dart/dynamics/Marker.hpp" #include "dart/constraint/ConstraintSolver.hpp" #include "dart/collision/CollisionDetector.hpp" -#include "dart/gui/LoadGlut.hpp" -#include "dart/gui/GLFuncs.hpp" -#include "dart/gui/GraphWindow.hpp" +#include "dart/gui/glut/GLUTFuncs.hpp" +#include "dart/gui/glut/GraphWindow.hpp" +#include "dart/gui/glut/LoadGlut.hpp" #include "dart/utils/FileInfoWorld.hpp" namespace dart { namespace gui { +namespace glut { SimWindow::SimWindow() : Win3D() { @@ -207,7 +208,7 @@ void SimWindow::draw() { #endif std::string frame(buff); glColor3f(0.0, 0.0, 0.0); - gui::drawStringOnScreen(0.02f, 0.02f, frame); + gui::glut::drawStringOnScreen(0.02f, 0.02f, frame); glEnable(GL_LIGHTING); } @@ -551,5 +552,6 @@ void SimWindow::drawMarker(const dynamics::Marker* marker, mRI->popName(); } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/glut/SimWindow.hpp b/dart/gui/glut/SimWindow.hpp new file mode 100644 index 0000000000000..3ec0438218e9a --- /dev/null +++ b/dart/gui/glut/SimWindow.hpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_SIMWINDOW_HPP_ +#define DART_GUI_GLUT_SIMWINDOW_HPP_ + +#include + +#include + +#include "dart/common/Deprecated.hpp" +#include "dart/gui/glut/Win3D.hpp" +#include "dart/simulation/World.hpp" + +namespace dart { +namespace gui { +namespace glut { + +class GraphWindow; + +/// \brief +class SimWindow : public Win3D { +public: + /// \brief + SimWindow(); + + /// \brief + virtual ~SimWindow(); + + /// \brief + virtual void timeStepping(); + + virtual void drawWorld() const; + + virtual void drawSkeletons() const; + + DART_DEPRECATED(6.0) + virtual void drawSkels(); + + DART_DEPRECATED(6.0) + virtual void drawEntities(); + + /// \brief + void displayTimer(int _val) override; + + /// \brief + void draw() override; + + /// \brief + void keyboard(unsigned char _key, int _x, int _y) override; + + /// \brief + void setWorld(dart::simulation::WorldPtr _world); + + /// \brief Save world in 'tempWorld.txt' + void saveWorld(); + + /// \brief Plot _data in a 2D window + void plot(Eigen::VectorXd& _data); +// bool isSimulating() const { return mSimulating; } + +// void setSimulatingFlag(int _flag) { mSimulating = _flag; } + +protected: + + virtual void drawSkeleton( + const dynamics::Skeleton* skeleton, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true) const; + + virtual void drawEntity( + const dynamics::Entity* entity, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true) const; + + virtual void drawBodyNode( + const dynamics::BodyNode* bodyNode, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true, + bool recursive = false) const; + + virtual void drawShapeFrame( + const dynamics::ShapeFrame* shapeFrame, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true) const; + + virtual void drawShape( + const dynamics::Shape* shape, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5)) const; + + virtual void drawPointMasses( + const std::vector pointMasses, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true) const; + + virtual void drawMarker( + const dynamics::Marker* marker, + const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5), + bool useDefaultColor = true) const; + + /// \brief + simulation::WorldPtr mWorld; + + /// \brief + int mPlayFrame; + + /// \brief + bool mPlay; + + /// \brief + bool mSimulating; + + /// If true, render point masses of soft bodies + bool mShowPointMasses; + + /// If true, render markers + bool mShowMarkers; + + /// \brief Array of graph windows + std::vector mGraphWindows; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_SIMWINDOW_HPP_ diff --git a/dart/gui/SoftSimWindow.cpp b/dart/gui/glut/SoftSimWindow.cpp similarity index 96% rename from dart/gui/SoftSimWindow.cpp rename to dart/gui/glut/SoftSimWindow.cpp index 3433ac8779adb..55b2df26762ee 100644 --- a/dart/gui/SoftSimWindow.cpp +++ b/dart/gui/glut/SoftSimWindow.cpp @@ -36,12 +36,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/SoftSimWindow.hpp" +#include "dart/gui/glut/SoftSimWindow.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/LoadGlut.hpp" namespace dart { namespace gui { +namespace glut { SoftSimWindow::SoftSimWindow() : SimWindow(), @@ -101,5 +102,6 @@ void SoftSimWindow::keyboard(unsigned char key, int x, int y) glutPostRedisplay(); } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/glut/SoftSimWindow.hpp b/dart/gui/glut/SoftSimWindow.hpp new file mode 100644 index 0000000000000..e8af653816287 --- /dev/null +++ b/dart/gui/glut/SoftSimWindow.hpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_SOFTSIMWINDOW_HPP_ +#define DART_GUI_GLUT_SOFTSIMWINDOW_HPP_ + +#include "dart/gui/glut/SimWindow.hpp" + +namespace dart { +namespace gui { +namespace glut { + +/// \brief +class SoftSimWindow : public SimWindow +{ +public: + /// \brief + SoftSimWindow(); + + /// \brief + virtual ~SoftSimWindow(); + + /// \brief + void keyboard(unsigned char key, int x, int y) override; + +protected: + /// \brief + bool mShowPointMasses; + + /// \brief + bool mShowMeshs; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_SOFTSIMWINDOW_HPP_ diff --git a/dart/gui/Win2D.cpp b/dart/gui/glut/Win2D.cpp similarity index 96% rename from dart/gui/Win2D.cpp rename to dart/gui/glut/Win2D.cpp index 999f05a6f7795..315edf8cafb3f 100644 --- a/dart/gui/Win2D.cpp +++ b/dart/gui/glut/Win2D.cpp @@ -30,16 +30,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/Win2D.hpp" +#include "dart/gui/glut/Win2D.hpp" #include -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/LoadGlut.hpp" namespace dart { namespace gui { +namespace glut { -Win2D::Win2D() : GlutWindow() { +Win2D::Win2D() : glut::Window() { mTransX = 0; mTransY = 0; mTranslate = false; @@ -154,5 +155,6 @@ void Win2D::initGL() { glEnable(GL_LINE_SMOOTH); } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/glut/Win2D.hpp b/dart/gui/glut/Win2D.hpp new file mode 100644 index 0000000000000..649641be976fb --- /dev/null +++ b/dart/gui/glut/Win2D.hpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_WIN2D_HPP_ +#define DART_GUI_GLUT_WIN2D_HPP_ + +#include "dart/gui/glut/Window.hpp" + +namespace dart { +namespace gui { +namespace glut { + +/// \brief +class Win2D : public glut::Window { +public: + /// \brief + Win2D(); + + /// \brief + void resize(int _w, int _h) override; + + /// \brief + void render() override; + + /// \brief + void keyboard(unsigned char _key, int _x, int _y) override; + + /// \brief + void click(int _button, int _state, int _x, int _y) override; + + /// \brief + void drag(int _x, int _y) override; + + /// \brief + virtual void initGL(); + + /// \brief + virtual void draw() = 0; + +protected: + /// \brief + bool mTranslate; + + /// \brief + double mTransX; + + /// \brief + double mTransY; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_WIN2D_HPP_ diff --git a/dart/gui/Win3D.cpp b/dart/gui/glut/Win3D.cpp similarity index 88% rename from dart/gui/Win3D.cpp rename to dart/gui/glut/Win3D.cpp index 1ad6de1714e7c..87e7dc6a5b432 100644 --- a/dart/gui/Win3D.cpp +++ b/dart/gui/glut/Win3D.cpp @@ -30,18 +30,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "dart/gui/Win3D.hpp" +#include "dart/gui/glut/Win3D.hpp" #include #include "dart/math/Constants.hpp" -#include "dart/gui/LoadGlut.hpp" +#include "dart/gui/glut/LoadGlut.hpp" namespace dart { namespace gui { +namespace glut { +//============================================================================== Win3D::Win3D() - : GlutWindow(), + : Window(), mTrans(0.0, 0.0, 0.0), mEye(0.0, 0.0, 1.0), mUp(0.0, 1.0, 0.0), @@ -49,17 +51,23 @@ Win3D::Win3D() mPersp(45.0), mRotate(false), mTranslate(false), - mZooming(false) { + mZooming(false) +{ + // Do nothing } -void Win3D::initWindow(int _w, int _h, const char* _name) { - GlutWindow::initWindow(_w, _h, _name); +//============================================================================== +void Win3D::initWindow(int _w, int _h, const char* _name) +{ + Window::initWindow(_w, _h, _name); int smaller = _w < _h ? _w : _h; mTrackBall.setTrackball(Eigen::Vector2d(_w*0.5, _h*0.5), smaller/2.5); } -void Win3D::resize(int _w, int _h) { +//============================================================================== +void Win3D::resize(int _w, int _h) +{ mWinWidth = _w; mWinHeight = _h; @@ -79,7 +87,9 @@ void Win3D::resize(int _w, int _h) { glutPostRedisplay(); } -void Win3D::keyboard(unsigned char _key, int /*_x*/, int /*_y*/) { +//============================================================================== +void Win3D::keyboard(unsigned char _key, int /*_x*/, int /*_y*/) +{ switch (_key) { case ',': // slow down mDisplayTimeout +=2; @@ -109,7 +119,9 @@ void Win3D::keyboard(unsigned char _key, int /*_x*/, int /*_y*/) { // printf("ascii key: %lu\n", key); } -void Win3D::click(int _button, int _state, int _x, int _y) { +//============================================================================== +void Win3D::click(int _button, int _state, int _x, int _y) +{ mMouseDown = !mMouseDown; int mask = glutGetModifiers(); if (mMouseDown) { @@ -141,7 +153,9 @@ void Win3D::click(int _button, int _state, int _x, int _y) { glutPostRedisplay(); } -void Win3D::drag(int _x, int _y) { +//============================================================================== +void Win3D::drag(int _x, int _y) +{ double deltaX = _x - mMouseX; double deltaY = _y - mMouseY; @@ -162,7 +176,9 @@ void Win3D::drag(int _x, int _y) { glutPostRedisplay(); } -void Win3D::render() { +//============================================================================== +void Win3D::render() +{ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(mPersp, @@ -220,7 +236,9 @@ void Win3D::render() { screenshot(); } -void Win3D::initGL() { +//============================================================================== +void Win3D::initGL() +{ glClearColor(mBackground[0], mBackground[1], mBackground[2], mBackground[3]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_BLEND); @@ -230,7 +248,9 @@ void Win3D::initGL() { glPolygonMode(GL_FRONT, GL_FILL); } -void Win3D::initLights() { +//============================================================================== +void Win3D::initLights() +{ static float ambient[] = {0.2, 0.2, 0.2, 1.0}; static float diffuse[] = {0.6, 0.6, 0.6, 1.0}; static float front_mat_shininess[] = {60.0}; @@ -308,5 +328,6 @@ void accPerspective(GLdouble fovy, GLdouble aspect, pixdx, pixdy, eyedx, eyedy, focus); } +} // namespace glut } // namespace gui } // namespace dart diff --git a/dart/gui/glut/Win3D.hpp b/dart/gui/glut/Win3D.hpp new file mode 100644 index 0000000000000..50bc638f25a65 --- /dev/null +++ b/dart/gui/glut/Win3D.hpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_WIN3D_HPP_ +#define DART_GUI_GLUT_WIN3D_HPP_ + +#include + +#include "dart/gui/Trackball.hpp" +#include "dart/gui/glut/Window.hpp" + +namespace dart { +namespace gui { +namespace glut { + +class Win3D : public glut::Window { +public: + Win3D(); + + void initWindow(int _w, int _h, const char* _name) override; + void resize(int _w, int _h) override; + void render() override; + + void keyboard(unsigned char _key, int _x, int _y) override; + void click(int _button, int _state, int _x, int _y) override; + void drag(int _x, int _y) override; + + virtual void initGL(); + virtual void initLights(); + + virtual void draw()=0; + +protected: + Trackball mTrackBall; + Eigen::Vector3d mTrans; + Eigen::Vector3d mEye; + Eigen::Vector3d mUp; + float mZoom; + float mPersp; + + bool mRotate; + bool mTranslate; + bool mZooming; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_WIN3D_HPP_ diff --git a/dart/gui/glut/Window.hpp b/dart/gui/glut/Window.hpp new file mode 100644 index 0000000000000..549f40a08c339 --- /dev/null +++ b/dart/gui/glut/Window.hpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011-2018, The DART development contributors + * All rights reserved. + * + * The list of contributors can be found at: + * https://github.com/dartsim/dart/blob/master/LICENSE + * + * This file is provided under the following "BSD-style" License: + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DART_GUI_GLUT_WINDOW_HPP_ +#define DART_GUI_GLUT_WINDOW_HPP_ + +#include + +#include "dart/gui/LoadOpengl.hpp" +#include "dart/gui/RenderInterface.hpp" + +namespace dart { +namespace gui { +namespace glut { + +/// \brief +class Window { +public: + Window(); + virtual ~Window(); + + /// \warning This function should be called once. + virtual void initWindow(int _w, int _h, const char* _name); + + // callback functions + static void reshape(int _w, int _h); + static void keyEvent(unsigned char _key, int _x, int _y); + static void specKeyEvent(int _key, int _x, int _y); + static void mouseClick(int _button, int _state, int _x, int _y); + static void mouseDrag(int _x, int _y); + static void mouseMove(int _x, int _y); + static void refresh(); + static void refreshTimer(int _val); + static void runTimer(int _val); + + static Window* current(); + static std::vector mWindows; + static std::vector mWinIDs; + +protected: + // callback implementation + virtual void resize(int _w, int _h) = 0; + virtual void render() = 0; + virtual void keyboard(unsigned char _key, int _x, int _y); + virtual void specKey(int _key, int _x, int _y); + virtual void click(int _button, int _state, int _x, int _y); + virtual void drag(int _x, int _y); + virtual void move(int _x, int _y); + virtual void displayTimer(int _val); + virtual void simTimer(int _val); + + virtual bool screenshot(); + + int mWinWidth; + int mWinHeight; + int mMouseX; + int mMouseY; + double mDisplayTimeout; + bool mMouseDown; + bool mMouseDrag; + bool mCapture; + double mBackground[4]; + gui::RenderInterface* mRI; + std::vector mScreenshotTemp; + std::vector mScreenshotTemp2; +}; + +} // namespace glut +} // namespace gui +} // namespace dart + +#endif // DART_GUI_GLUT_WINDOW_HPP_ diff --git a/dart/gui/glut/glut.hpp.in b/dart/gui/glut/glut.hpp.in new file mode 100644 index 0000000000000..22537f837dbb5 --- /dev/null +++ b/dart/gui/glut/glut.hpp.in @@ -0,0 +1,3 @@ +// Automatically generated file by cmake + +${gui_glut_headers} diff --git a/dart/simulation/World.hpp b/dart/simulation/World.hpp index 865f34524fd78..c3e65384da294 100644 --- a/dart/simulation/World.hpp +++ b/dart/simulation/World.hpp @@ -47,6 +47,7 @@ #include "dart/common/Timer.hpp" #include "dart/common/NameManager.hpp" +#include "dart/common/SmartPointer.hpp" #include "dart/common/Subject.hpp" #include "dart/dynamics/SimpleFrame.hpp" #include "dart/dynamics/Skeleton.hpp" @@ -73,6 +74,8 @@ class CollisionResult; namespace simulation { +DART_COMMON_DECLARE_SHARED_WEAK(World) + /// class World class World : public virtual common::Subject { @@ -310,8 +313,6 @@ class World : public virtual common::Subject }; -typedef std::shared_ptr WorldPtr; - } // namespace simulation } // namespace dart diff --git a/dart/utils/urdf/URDFTypes.hpp b/dart/utils/urdf/URDFTypes.hpp index 117e33c558cec..1a5864323d03f 100644 --- a/dart/utils/urdf/URDFTypes.hpp +++ b/dart/utils/urdf/URDFTypes.hpp @@ -33,8 +33,8 @@ #ifndef DART_UTILS_URDF_URDFTYPES_HPP_ #define DART_UTILS_URDF_URDFTYPES_HPP_ -#warning "This header has been deprecated in DART 6.2. "\ - "Please include dart/utils/urdf/BackwardCompatibility.hpp intead." +#pragma message("This header has been deprecated in DART 6.2. "\ + "Please include dart/utils/urdf/BackwardCompatibility.hpp intead.") #include "dart/utils/urdf/BackwardCompatibility.hpp" diff --git a/examples/addDeleteSkels/MyWindow.hpp b/examples/addDeleteSkels/MyWindow.hpp index b3f471bb3eea4..442a455a87874 100644 --- a/examples/addDeleteSkels/MyWindow.hpp +++ b/examples/addDeleteSkels/MyWindow.hpp @@ -37,7 +37,7 @@ #include /// \brief -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief MyWindow(); diff --git a/examples/atlasSimbicon/MyWindow.cpp b/examples/atlasSimbicon/MyWindow.cpp index 645be908f8566..ad6398852b28f 100644 --- a/examples/atlasSimbicon/MyWindow.cpp +++ b/examples/atlasSimbicon/MyWindow.cpp @@ -32,6 +32,8 @@ #include "MyWindow.hpp" +#include + //============================================================================== MyWindow::MyWindow(Controller* _controller) : SimWindow(), diff --git a/examples/atlasSimbicon/MyWindow.hpp b/examples/atlasSimbicon/MyWindow.hpp index a8fbb53a10ec9..1ce14ce639774 100644 --- a/examples/atlasSimbicon/MyWindow.hpp +++ b/examples/atlasSimbicon/MyWindow.hpp @@ -39,7 +39,7 @@ #include "Controller.hpp" /// \brief class MyWindow -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief Constructor diff --git a/examples/bipedStand/MyWindow.cpp b/examples/bipedStand/MyWindow.cpp index 0df0cc3f61447..3b9b461020ee6 100644 --- a/examples/bipedStand/MyWindow.cpp +++ b/examples/bipedStand/MyWindow.cpp @@ -32,6 +32,8 @@ #include "MyWindow.hpp" +#include + MyWindow::MyWindow(): SimWindow() { mForce = Eigen::Vector3d::Zero(); mController = nullptr; diff --git a/examples/bipedStand/MyWindow.hpp b/examples/bipedStand/MyWindow.hpp index e29a98ce314e8..058102ff724b4 100644 --- a/examples/bipedStand/MyWindow.hpp +++ b/examples/bipedStand/MyWindow.hpp @@ -42,7 +42,7 @@ #include "Controller.hpp" -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow { public: MyWindow(); virtual ~MyWindow(); diff --git a/examples/hardcodedDesign/MyWindow.hpp b/examples/hardcodedDesign/MyWindow.hpp index eeb7eb07c00b5..9077dc2d4475c 100644 --- a/examples/hardcodedDesign/MyWindow.hpp +++ b/examples/hardcodedDesign/MyWindow.hpp @@ -46,7 +46,7 @@ #include #include -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief The constructor - set the position of the skeleton explicit MyWindow(dart::dynamics::SkeletonPtr _skel): SimWindow(), skel(_skel) { diff --git a/examples/hybridDynamics/MyWindow.hpp b/examples/hybridDynamics/MyWindow.hpp index e2c125bd0074c..a13936a5bde78 100644 --- a/examples/hybridDynamics/MyWindow.hpp +++ b/examples/hybridDynamics/MyWindow.hpp @@ -37,7 +37,7 @@ #include /// \brief -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief diff --git a/examples/jointConstraints/MyWindow.cpp b/examples/jointConstraints/MyWindow.cpp index a42c35dcf475b..d534c3338e390 100644 --- a/examples/jointConstraints/MyWindow.cpp +++ b/examples/jointConstraints/MyWindow.cpp @@ -32,6 +32,8 @@ #include "MyWindow.hpp" +#include + using namespace dart; using namespace math; using namespace dynamics; diff --git a/examples/jointConstraints/MyWindow.hpp b/examples/jointConstraints/MyWindow.hpp index 4017dd0145bc0..d5301537c785b 100644 --- a/examples/jointConstraints/MyWindow.hpp +++ b/examples/jointConstraints/MyWindow.hpp @@ -41,7 +41,7 @@ #include #include -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: MyWindow(): SimWindow() diff --git a/examples/mixedChain/MyWindow.cpp b/examples/mixedChain/MyWindow.cpp index 450fa29e01a29..8dff888230ae8 100644 --- a/examples/mixedChain/MyWindow.cpp +++ b/examples/mixedChain/MyWindow.cpp @@ -38,6 +38,8 @@ #include "MyWindow.hpp" +#include + #define FORCE_ON_RIGIDBODY 500.0; #define FORCE_ON_VERTEX 1.00; diff --git a/examples/mixedChain/MyWindow.hpp b/examples/mixedChain/MyWindow.hpp index 54b3930316007..509e49199c1dc 100644 --- a/examples/mixedChain/MyWindow.hpp +++ b/examples/mixedChain/MyWindow.hpp @@ -43,7 +43,7 @@ #include /// \brief -class MyWindow : public dart::gui::SoftSimWindow +class MyWindow : public dart::gui::glut::SoftSimWindow { public: /// \brief diff --git a/examples/operationalSpaceControl/MyWindow.hpp b/examples/operationalSpaceControl/MyWindow.hpp index af139b078a5de..b271f886043ca 100644 --- a/examples/operationalSpaceControl/MyWindow.hpp +++ b/examples/operationalSpaceControl/MyWindow.hpp @@ -39,7 +39,7 @@ #include "Controller.hpp" /// \brief class MyWindow -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief Default constructor diff --git a/examples/rigidChain/MyWindow.hpp b/examples/rigidChain/MyWindow.hpp index 3dc51c3f3c98c..5044867be5d76 100644 --- a/examples/rigidChain/MyWindow.hpp +++ b/examples/rigidChain/MyWindow.hpp @@ -36,7 +36,7 @@ #include #include -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow { public: MyWindow(); diff --git a/examples/rigidCubes/MyWindow.hpp b/examples/rigidCubes/MyWindow.hpp index c2192f2675084..c1d82a621672a 100644 --- a/examples/rigidCubes/MyWindow.hpp +++ b/examples/rigidCubes/MyWindow.hpp @@ -34,24 +34,19 @@ #define EXAMPLES_CUBES_MYWINDOW_HPP_ #include -#include +#include -/// \brief -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow +{ public: - /// \brief MyWindow(); - /// \brief virtual ~MyWindow(); - /// \brief void timeStepping() override; - /// \brief void drawWorld() const override; - /// \brief void keyboard(unsigned char _key, int _x, int _y) override; private: diff --git a/examples/rigidCubes/Main.cpp b/examples/rigidCubes/main.cpp similarity index 86% rename from examples/rigidCubes/Main.cpp rename to examples/rigidCubes/main.cpp index aba51e820b90a..11e558f7c49b1 100644 --- a/examples/rigidCubes/Main.cpp +++ b/examples/rigidCubes/main.cpp @@ -39,16 +39,18 @@ int main(int argc, char* argv[]) { - // create and initialize the world - dart::simulation::WorldPtr myWorld - = dart::utils::SkelParser::readWorld("dart://sample/skel/cubes.skel"); - assert(myWorld != nullptr); - Eigen::Vector3d gravity(0.0, -9.81, 0.0); - myWorld->setGravity(gravity); + // Create and initialize the world + auto world = dart::utils::SkelParser::readWorld("dart://sample/skel/cubes.skel"); + if (!world) + { + dterr << "Failed to load world.\n"; + exit(EXIT_FAILURE); + } + world->setGravity(Eigen::Vector3d(0.0, -9.81, 0.0)); - // create a window and link it to the world + // Create a window and link it to the world MyWindow window; - window.setWorld(myWorld); + window.setWorld(world); std::cout << "space bar: simulation on/off" << std::endl; std::cout << "'p': playback/stop" << std::endl; diff --git a/examples/rigidLoop/MyWindow.hpp b/examples/rigidLoop/MyWindow.hpp index 229f9b2ac602b..d175e972f8227 100644 --- a/examples/rigidLoop/MyWindow.hpp +++ b/examples/rigidLoop/MyWindow.hpp @@ -36,7 +36,7 @@ #include #include -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: MyWindow() : SimWindow() {} diff --git a/examples/rigidShapes/MyWindow.hpp b/examples/rigidShapes/MyWindow.hpp index 1f362361e15f7..a676c34437cf2 100644 --- a/examples/rigidShapes/MyWindow.hpp +++ b/examples/rigidShapes/MyWindow.hpp @@ -43,7 +43,7 @@ #include /// MyWindow -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: /// Constructor diff --git a/examples/simpleFrames/Main.cpp b/examples/simpleFrames/Main.cpp index 2f54d06eaca60..1370f5ffd3189 100644 --- a/examples/simpleFrames/Main.cpp +++ b/examples/simpleFrames/Main.cpp @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) // rendered correctly, it must be a child of the World Frame // TODO(MXG): Fix this issue ^ - dart::gui::SimWindow window; + dart::gui::glut::SimWindow window; window.setWorld(myWorld); glutInit(&argc, argv); diff --git a/examples/softBodies/MyWindow.cpp b/examples/softBodies/MyWindow.cpp index c6059dd5334c4..f1b6507a069bc 100644 --- a/examples/softBodies/MyWindow.cpp +++ b/examples/softBodies/MyWindow.cpp @@ -38,6 +38,8 @@ #include "MyWindow.hpp" +#include + #define FORCE_ON_RIGIDBODY 25.0; #define FORCE_ON_VERTEX 1.00; diff --git a/examples/softBodies/MyWindow.hpp b/examples/softBodies/MyWindow.hpp index 390a140298139..2943e21b52f9a 100644 --- a/examples/softBodies/MyWindow.hpp +++ b/examples/softBodies/MyWindow.hpp @@ -43,7 +43,7 @@ #include /// \brief -class MyWindow : public dart::gui::SoftSimWindow +class MyWindow : public dart::gui::glut::SoftSimWindow { public: /// \brief diff --git a/examples/vehicle/MyWindow.hpp b/examples/vehicle/MyWindow.hpp index 5a427dcf6ba63..8d603dfad60ac 100644 --- a/examples/vehicle/MyWindow.hpp +++ b/examples/vehicle/MyWindow.hpp @@ -38,7 +38,7 @@ #include /// \brief -class MyWindow : public dart::gui::SimWindow { +class MyWindow : public dart::gui::glut::SimWindow { public: /// \brief MyWindow(); diff --git a/tutorials/tutorialBiped-Finished/tutorialBiped-Finished.cpp b/tutorials/tutorialBiped-Finished/tutorialBiped-Finished.cpp index 9035f837f5b3f..9b9fc53f6eff7 100644 --- a/tutorials/tutorialBiped-Finished/tutorialBiped-Finished.cpp +++ b/tutorials/tutorialBiped-Finished/tutorialBiped-Finished.cpp @@ -45,6 +45,7 @@ using namespace dart::common; using namespace dart::dynamics; using namespace dart::simulation; using namespace dart::gui; +using namespace dart::gui::glut; using namespace dart::utils; using namespace dart::math; diff --git a/tutorials/tutorialBiped/tutorialBiped.cpp b/tutorials/tutorialBiped/tutorialBiped.cpp index 0a8347312e87b..09f7373f27309 100644 --- a/tutorials/tutorialBiped/tutorialBiped.cpp +++ b/tutorials/tutorialBiped/tutorialBiped.cpp @@ -45,6 +45,7 @@ using namespace dart::common; using namespace dart::dynamics; using namespace dart::simulation; using namespace dart::gui; +using namespace dart::gui::glut; using namespace dart::utils; using namespace dart::math; diff --git a/tutorials/tutorialCollisions-Finished/tutorialCollisions-Finished.cpp b/tutorials/tutorialCollisions-Finished/tutorialCollisions-Finished.cpp index 14b66b5f35e4e..07ec2a2df325b 100644 --- a/tutorials/tutorialCollisions-Finished/tutorialCollisions-Finished.cpp +++ b/tutorials/tutorialCollisions-Finished/tutorialCollisions-Finished.cpp @@ -105,7 +105,7 @@ void setupRing(const SkeletonPtr& ring) } } -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: diff --git a/tutorials/tutorialCollisions/tutorialCollisions.cpp b/tutorials/tutorialCollisions/tutorialCollisions.cpp index c1b1c465aa60e..8a7082d7b6eca 100644 --- a/tutorials/tutorialCollisions/tutorialCollisions.cpp +++ b/tutorials/tutorialCollisions/tutorialCollisions.cpp @@ -71,6 +71,7 @@ const double default_soft_damping = 5.0; using namespace dart::dynamics; using namespace dart::simulation; using namespace dart::gui; +using namespace dart::gui::glut; void setupRing(const SkeletonPtr& /*ring*/) { diff --git a/tutorials/tutorialDominoes-Finished/tutorialDominoes-Finished.cpp b/tutorials/tutorialDominoes-Finished/tutorialDominoes-Finished.cpp index 8cc6a618beae1..8b19842268671 100644 --- a/tutorials/tutorialDominoes-Finished/tutorialDominoes-Finished.cpp +++ b/tutorials/tutorialDominoes-Finished/tutorialDominoes-Finished.cpp @@ -219,7 +219,7 @@ class Controller Eigen::VectorXd mForces; }; -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: diff --git a/tutorials/tutorialDominoes/tutorialDominoes.cpp b/tutorials/tutorialDominoes/tutorialDominoes.cpp index 189ae5a0b811f..322f760e7de44 100644 --- a/tutorials/tutorialDominoes/tutorialDominoes.cpp +++ b/tutorials/tutorialDominoes/tutorialDominoes.cpp @@ -132,7 +132,7 @@ class Controller Eigen::VectorXd mForces; }; -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: diff --git a/tutorials/tutorialMultiPendulum-Finished/tutorialMultiPendulum-Finished.cpp b/tutorials/tutorialMultiPendulum-Finished/tutorialMultiPendulum-Finished.cpp index fc395703dbaea..0d2a7c5144cb4 100644 --- a/tutorials/tutorialMultiPendulum-Finished/tutorialMultiPendulum-Finished.cpp +++ b/tutorials/tutorialMultiPendulum-Finished/tutorialMultiPendulum-Finished.cpp @@ -53,7 +53,7 @@ const double delta_damping = 1.0; using namespace dart::dynamics; using namespace dart::simulation; -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: diff --git a/tutorials/tutorialMultiPendulum/tutorialMultiPendulum.cpp b/tutorials/tutorialMultiPendulum/tutorialMultiPendulum.cpp index f1a9a9364f6fe..c99dc70655a2a 100644 --- a/tutorials/tutorialMultiPendulum/tutorialMultiPendulum.cpp +++ b/tutorials/tutorialMultiPendulum/tutorialMultiPendulum.cpp @@ -53,7 +53,7 @@ const double delta_damping = 1.0; using namespace dart::dynamics; using namespace dart::simulation; -class MyWindow : public dart::gui::SimWindow +class MyWindow : public dart::gui::glut::SimWindow { public: