diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index e5b100b708bbf6c728ae0e0b59861cef6812d10b..910119925ab23d30f3280432a4a91fd08362f166 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -341,6 +341,8 @@ typedef sequence<Position> PositionSeq; /// \param input state : 0 for off, 1 or 2 for other things. boolean setHighlight (in string nodeName, in long state) raises (Error); + void captureFrame (in WindowID wid, in string imageFilename) raises (Error); + /// Start capturing a window into image files. /// \param windowId the ID of the window /// \param filename, extension image files will be diff --git a/include/gepetto/viewer/corba/windows-manager.hh b/include/gepetto/viewer/corba/windows-manager.hh index 38ff265ef9eab5edc382bab1c98c7b7bf0f049f6..50abd5cb2827bba1320c9e5a8fc808dd6c4b68e9 100644 --- a/include/gepetto/viewer/corba/windows-manager.hh +++ b/include/gepetto/viewer/corba/windows-manager.hh @@ -249,6 +249,7 @@ namespace graphics { virtual bool setAlpha(const std::string& nodeName, const float& alpha); virtual bool setAlpha(const std::string& nodeName, const int& alphaPercentage); + virtual void captureFrame (const WindowID windowId, const std::string& filename); virtual bool startCapture (const WindowID windowId, const std::string& filename, const std::string& extension); virtual bool stopCapture (const WindowID windowId); diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index 8a8aaea832c6f80d6e81e92ad79e860c94c15ef1..a2d6d2b286baa7f5a641a27bc55beb02e9d515e8 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -367,6 +367,8 @@ namespace graphics { BIND_TO_WINDOWS_MANAGER_2(BOOL, setHighlight, STRING, LONG) + BIND_TO_WINDOWS_MANAGER_2(VOID, captureFrame, WINDOW_ID, STRING) + BIND_TO_WINDOWS_MANAGER_3(BOOL, startCapture, WINDOW_ID, STRING, STRING) BIND_TO_WINDOWS_MANAGER_1(BOOL, stopCapture, WINDOW_ID) diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 4b1a7427a90150b372edc197a69657e092b5107e..f73f8da7754698fa0c82f2ef47ec5103dfa71360 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -142,6 +142,7 @@ public: virtual bool setLightingMode(const char* nodeNameCorba, const char* lightingModeCorba) throw (Error); virtual bool setHighlight(const char* nodeNameCorba, ::CORBA::Long state) throw (Error); + virtual void captureFrame (const WindowID windowId, const char* filename) throw (Error); virtual bool startCapture (const WindowID windowId, const char* filename, const char* extension) throw (Error); virtual bool stopCapture (const WindowID windowId) throw (Error); diff --git a/src/windows-manager.cpp b/src/windows-manager.cpp index fe676f469aee03655720496f9a5639490c910dac..917c556a3acfd70faa0ac25299aab8ca202e6b20 100644 --- a/src/windows-manager.cpp +++ b/src/windows-manager.cpp @@ -1172,6 +1172,19 @@ namespace graphics { return true; } + void WindowsManager::captureFrame (const WindowID wid, const std::string& filename) + { + WindowManagerPtr_t wm = getWindowManager(wid, true); + mtx_.lock(); + try { + wm->captureFrame (filename); + } catch (const std::exception& exc) { + mtx_.unlock(); + throw; + } + mtx_.unlock(); + } + bool WindowsManager::startCapture (const WindowID windowId, const std::string& filename, const std::string& extension) {