diff --git a/trunk2/core/CMakeLists.txt b/trunk2/core/CMakeLists.txt index 5f8a5a38e835d5b180755b844a43b63659c466dd..95054303d970844638654c3ae55fc716a4d9bcca 100644 --- a/trunk2/core/CMakeLists.txt +++ b/trunk2/core/CMakeLists.txt @@ -51,7 +51,8 @@ SET(OV_TRUNK "trunc") # Branch name __SKIPME signifies that this component should not be compiled or installed. # SET(OV_BRANCH_PLUGINS_PYTHON "__SKIPME") # skips python module SET(OV_BRANCH_DOCUMENTATION "__SKIPME") # skips documentation module - +SET(SKIP_PLUGINS_PYTHON "yes") + # Some recognized branch variables #SET(OV_BRANCH_OPENVIBE "branches/mybranch") #SET(OV_BRANCH_KERNEL "branches/mybranch") @@ -135,7 +136,7 @@ ADD_SUBDIRECTORY("modules/") ADD_SUBDIRECTORY("toolkit/") ADD_SUBDIRECTORY("plugins/") #ADD_SUBDIRECTORY("openvibe-scenarios/") -#ADD_SUBDIRECTORY("openvibe-applications/") +ADD_SUBDIRECTORY("applications/") #ADD_SUBDIRECTORY("openvibe-externals/") #ADD_SUBDIRECTORY("openvibe-documentation/") # needs to be the last since it uses the list of collected projects diff --git a/trunk2/core/applications/CMakeLists.txt b/trunk2/core/applications/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9bae9bdadead8071dcf6cbb0a0023aa84a6e895f --- /dev/null +++ b/trunk2/core/applications/CMakeLists.txt @@ -0,0 +1,3 @@ + +# Add all the subdirs as projects of the named branch +OV_ADD_PROJECTS("APPLICATIONS") diff --git a/trunk2/core/applications/demos/CMakeLists.txt b/trunk2/core/applications/demos/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..74f4e1d73bbf93a7606f6cf8dcb0004c05e0d45a --- /dev/null +++ b/trunk2/core/applications/demos/CMakeLists.txt @@ -0,0 +1,4 @@ + +# Add all the subdirs as projects of the named branch +OV_ADD_PROJECTS("APPLICATIONS_DEMOS") + diff --git a/trunk2/core/applications/demos/ssvep-demo/CMakeLists.txt b/trunk2/core/applications/demos/ssvep-demo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/trunk2/core/applications/demos/ssvep-demo/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/trunk2/core/applications/demos/vr-demo/CMakeLists.txt b/trunk2/core/applications/demos/vr-demo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/trunk2/core/applications/demos/vr-demo/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/trunk2/core/applications/developer-tools/CMakeLists.txt b/trunk2/core/applications/developer-tools/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0d6c6eea6f16aca6614ee26befe9aa9d8847602e --- /dev/null +++ b/trunk2/core/applications/developer-tools/CMakeLists.txt @@ -0,0 +1,4 @@ + +# Add all the subdirs as projects of the named branch +OV_ADD_PROJECTS("APPLICATIONS_DEVELOPER-TOOLS") + diff --git a/trunk2/core/applications/developer-tools/id-generator/CMakeLists.txt b/trunk2/core/applications/developer-tools/id-generator/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a353dc1bce26594e6db227b2377089fd22946df0 --- /dev/null +++ b/trunk2/core/applications/developer-tools/id-generator/CMakeLists.txt @@ -0,0 +1,45 @@ +PROJECT(openvibe-id-generator) + +SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR}) +SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR}) +SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH}) +SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl) +ADD_EXECUTABLE(${PROJECT_NAME} ${source_files}) + +# --------------------------------- +# Target macros +# Defines target operating system +# Defines target architecture +# Defines target compiler +# --------------------------------- +IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-DTARGET_OS_Windows) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio) +ENDIF(WIN32) +IF(UNIX) + # ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc + ADD_DEFINITIONS(-g) + ADD_DEFINITIONS(-fnon-call-exceptions) + ADD_DEFINITIONS(-DTARGET_OS_Linux) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_GCC) +ENDIF(UNIX) + +# ---------------------- +# Generate launch script +# ---------------------- +OV_INSTALL_LAUNCH_SCRIPT("openvibe-id-generator") + +# ----------------------------- +# Install files +# ----------------------------- +INSTALL(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) + +#INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "doc" EXCLUDE) diff --git a/trunk2/core/applications/developer-tools/id-generator/src/ovig_main.cpp b/trunk2/core/applications/developer-tools/id-generator/src/ovig_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2fd14ab872875478de2c6b6fede615f2b0b0effe --- /dev/null +++ b/trunk2/core/applications/developer-tools/id-generator/src/ovig_main.cpp @@ -0,0 +1,19 @@ +#include <cstdio> +#include <cstdlib> +#include <ctime> +#include <cmath> + +int main(int argc, char** argv) +{ + srand((unsigned int)time(NULL)); + for(int i=0; i<16; i++) + { + unsigned short int l_ui16Value1=(rand()&0xffff); + unsigned short int l_ui16Value2=(rand()&0xffff); + unsigned short int l_ui16Value3=(rand()&0xffff); + unsigned short int l_ui16Value4=(rand()&0xffff); + printf("#define OV_ClassId_ OpenViBE::CIdentifier(0x%04X%04X, 0x%04X%04X)\n", (int)l_ui16Value1, (int)l_ui16Value2, (int)l_ui16Value3, (int)l_ui16Value4); + } + + return 0; +} diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/CMakeLists.txt b/trunk2/core/applications/developer-tools/plugin-inspector/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b3ec32bb54eafd9fd874fb59ee26170fd24234dd --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/CMakeLists.txt @@ -0,0 +1,53 @@ +PROJECT(openvibe-plugin-inspector) + +SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR}) +SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR}) +SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH}) +SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl) +ADD_EXECUTABLE(${PROJECT_NAME} ${source_files}) + +INCLUDE("FindOpenViBE") +INCLUDE("FindOpenViBECommon") +INCLUDE("FindOpenViBEToolkit") +INCLUDE("FindOpenViBEModuleEBML") +INCLUDE("FindOpenViBEModuleSystem") +INCLUDE("FindThirdPartyGTK") + +# --------------------------------- +# Target macros +# Defines target operating system +# Defines target architecture +# Defines target compiler +# --------------------------------- +IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-DTARGET_OS_Windows) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio) +ENDIF(WIN32) +IF(UNIX) + # ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc + ADD_DEFINITIONS(-g) + ADD_DEFINITIONS(-fnon-call-exceptions) + ADD_DEFINITIONS(-DTARGET_OS_Linux) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_GCC) +ENDIF(UNIX) + +# ---------------------- +# Generate launch script +# ---------------------- +OV_INSTALL_LAUNCH_SCRIPT("openvibe-plugin-inspector") + + +# ----------------------------- +# Install files +# ----------------------------- +INSTALL(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) + +#INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "doc" EXCLUDE) diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.cpp b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c9a90dce52505356bda51c8eb4c6c5b645d9ed3 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.cpp @@ -0,0 +1,83 @@ +#include "ovpiCPluginObjectDescEnum.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +CPluginObjectDescEnum::CPluginObjectDescEnum(const IKernelContext& rKernelContext) + :m_rKernelContext(rKernelContext) +{ +} + +CPluginObjectDescEnum::~CPluginObjectDescEnum(void) +{ +} + +boolean CPluginObjectDescEnum::enumeratePluginObjectDesc(void) +{ + CIdentifier l_oIdentifier; + while((l_oIdentifier=m_rKernelContext.getPluginManager().getNextPluginObjectDescIdentifier(l_oIdentifier))!=OV_UndefinedIdentifier) + { + this->callback(*m_rKernelContext.getPluginManager().getPluginObjectDesc(l_oIdentifier)); + } + return true; +} + +boolean CPluginObjectDescEnum::enumeratePluginObjectDesc( + const CIdentifier& rParentClassIdentifier) +{ + CIdentifier l_oIdentifier; + while((l_oIdentifier=m_rKernelContext.getPluginManager().getNextPluginObjectDescIdentifier(l_oIdentifier, rParentClassIdentifier))!=OV_UndefinedIdentifier) + { + this->callback(*m_rKernelContext.getPluginManager().getPluginObjectDesc(l_oIdentifier)); + } + return true; +} + +std::string CPluginObjectDescEnum::transform(const std::string& sInput, const boolean bRemoveSlash) +{ + std::string l_sInput(sInput); + std::string l_sOutput; + bool l_bLastWasSeparator=true; + + for(std::string::size_type i=0; i<l_sInput.length(); i++) + { + if((l_sInput[i]>='a' && l_sInput[i]<='z') || (l_sInput[i]>='A' && l_sInput[i]<='Z') || (l_sInput[i]>='0' && l_sInput[i]<='9') || (!bRemoveSlash && l_sInput[i]=='/')) + { + if(l_sInput[i]=='/') + { + l_sOutput+="_"; + } + else + { + if(l_bLastWasSeparator) + { + if('a' <= l_sInput[i] && l_sInput[i] <= 'z') + { + l_sOutput+=l_sInput[i]+'A'-'a'; + } + else + { + l_sOutput+=l_sInput[i]; + } + } + else + { + l_sOutput+=l_sInput[i]; + } + } + l_bLastWasSeparator=false; + } + else + { +/* + if(!l_bLastWasSeparator) + { + l_sOutput+="_"; + } +*/ + l_bLastWasSeparator=true; + } + } + return l_sOutput; +} diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.h new file mode 100644 index 0000000000000000000000000000000000000000..b38167cabe4e8dfb6c39a2f264f80ba836350914 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnum.h @@ -0,0 +1,29 @@ +#ifndef __OpenViBEPluginInspector_CPluginObjectDescEnum_H__ +#define __OpenViBEPluginInspector_CPluginObjectDescEnum_H__ + +#include "ovpi_base.h" + +#include <string> + +class CPluginObjectDescEnum +{ +public: + + CPluginObjectDescEnum(const OpenViBE::Kernel::IKernelContext& rKernelContext); + virtual ~CPluginObjectDescEnum(void); + + virtual OpenViBE::boolean enumeratePluginObjectDesc(void); + virtual OpenViBE::boolean enumeratePluginObjectDesc( + const OpenViBE::CIdentifier& rParentClassIdentifier); + + virtual OpenViBE::boolean callback( + const OpenViBE::Plugins::IPluginObjectDesc& rPluginObjectDesc)=0; + + static std::string transform(const std::string& sInput, const OpenViBE::boolean bRemoveSlash=false); + +protected: + + const OpenViBE::Kernel::IKernelContext& m_rKernelContext; +}; + +#endif // __OpenViBEPluginInspector_CPluginObjectDescEnum_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.cpp b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..39c60ac3561f82b073fab4d8fc010ac7c2257dc9 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.cpp @@ -0,0 +1,165 @@ +#include "ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +#include <iostream> + +CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator::CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator(const IKernelContext& rKernelContext, const CString& sFilename) + :CPluginObjectDescEnum(rKernelContext) +{ + m_oUsedIdentifiers.clear(); + + OpenViBE::CString l_sFullFilename = sFilename + CString("/ovp_global_defines.h"); + + m_rKernelContext.getLogManager() << LogLevel_Info << "Writing global defines to '" << l_sFullFilename << "\n"; + + m_oFile.open(l_sFullFilename.toASCIIString()); + + if(!m_oFile.good()) { + m_rKernelContext.getLogManager() << LogLevel_Error << "Error opening '" << l_sFullFilename << "for writing\n"; + return; + } + + m_oFile << "#ifndef __OpenViBEPlugins_Global_Defines_H__\n"; + m_oFile << "#define __OpenViBEPlugins_Global_Defines_H__\n"; + m_oFile << "\n"; + m_oFile << "// This file was automatically generated by Plugin Inspector\n"; + m_oFile << "\n"; +} + +CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator::~CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator(void) +{ + if(!m_oFile.good()) return; + + m_oFile << "#endif // __OpenViBEPlugins_Global_Defines_H__\n"; + m_oFile.close(); +} + +void CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator::addIdentifier(const OpenViBE::CString &objectName, const OpenViBE::CIdentifier candidate, const OpenViBE::CString &sSpaces) +{ + if(m_oUsedIdentifiers.find(candidate) == m_oUsedIdentifiers.end() ) { + m_oUsedIdentifiers[candidate]=objectName; + m_oFile << "#define " << objectName << sSpaces << "OpenViBE::CIdentifier" << candidate.toString().toASCIIString() << "\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Warning << " Object '" << objectName << "' has duplicate id " << candidate.toString().toASCIIString() << " with " << m_oUsedIdentifiers[candidate] << "\n"; + m_oFile << "#define " << objectName << sSpaces << "OpenViBE::CIdentifier" << candidate.toString().toASCIIString() << " // Duplicate of " << m_oUsedIdentifiers[candidate] << "\n"; + } +} + +boolean CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator::callback(const IPluginObjectDesc& rPluginObjectDesc) +{ + if(!m_oFile.good()) return false; + + int l_iWidth=120; + + m_rKernelContext.getLogManager() << LogLevel_Info << " Dumping [" << rPluginObjectDesc.getName() << "]\n"; + + IAlgorithmManager& l_rAlgorithmManager=m_rKernelContext.getAlgorithmManager(); + IAlgorithmProxy& l_rAlgorithmProxy=l_rAlgorithmManager.getAlgorithm(l_rAlgorithmManager.createAlgorithm(rPluginObjectDesc.getCreatedClass())); + CIdentifier l_oIdentifier; + + m_oFile << "// -----------------------------------------------------\n"; + m_oFile << "// " << rPluginObjectDesc.getName().toASCIIString() << "\n"; + m_oFile << "// -----------------------------------------------------\n"; + m_oFile << "\n"; + + l_rAlgorithmProxy.initialize(); + + { + std::string l_sDefName; + l_sDefName+="OVP_GD_ClassId_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+=""; + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + l_oIdentifier = rPluginObjectDesc.getCreatedClassIdentifier(); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + { + std::string l_sDefName; + l_sDefName+="OVP_GD_ClassId_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+="Desc"; + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + l_oIdentifier = rPluginObjectDesc.getClassIdentifier(); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + l_oIdentifier = OV_UndefinedIdentifier; + while((l_oIdentifier=l_rAlgorithmProxy.getNextInputParameterIdentifier(l_oIdentifier))!=OV_UndefinedIdentifier) + { + std::string l_sDefName; + l_sDefName+="OVP_GD_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+="_InputParameterId_"; + l_sDefName+=transform(l_rAlgorithmProxy.getInputParameterName(l_oIdentifier).toASCIIString(), true); + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + l_oIdentifier = OV_UndefinedIdentifier; + while((l_oIdentifier=l_rAlgorithmProxy.getNextOutputParameterIdentifier(l_oIdentifier))!=OV_UndefinedIdentifier) + { + std::string l_sDefName; + l_sDefName+="OVP_GD_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+="_OutputParameterId_"; + l_sDefName+=transform(l_rAlgorithmProxy.getOutputParameterName(l_oIdentifier).toASCIIString(), true); + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + l_oIdentifier = OV_UndefinedIdentifier; + while((l_oIdentifier=l_rAlgorithmProxy.getNextInputTriggerIdentifier(l_oIdentifier))!=OV_UndefinedIdentifier) + { + std::string l_sDefName; + l_sDefName+="OVP_GD_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+="_InputTriggerId_"; + l_sDefName+=transform(l_rAlgorithmProxy.getInputTriggerName(l_oIdentifier).toASCIIString(), true); + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + l_oIdentifier = OV_UndefinedIdentifier; + while((l_oIdentifier=l_rAlgorithmProxy.getNextOutputTriggerIdentifier(l_oIdentifier))!=OV_UndefinedIdentifier) + { + std::string l_sDefName; + l_sDefName+="OVP_GD_Algorithm_"; + l_sDefName+=transform(rPluginObjectDesc.getName().toASCIIString(), true); + l_sDefName+="_OutputTriggerId_"; + l_sDefName+=transform(l_rAlgorithmProxy.getOutputTriggerName(l_oIdentifier).toASCIIString(), true); + + std::string l_sSpaces; + l_sSpaces.resize(l_iWidth-l_sDefName.length(), ' '); + + addIdentifier(l_sDefName.c_str(), l_oIdentifier, l_sSpaces.c_str()); + } + + l_rAlgorithmProxy.uninitialize(); + + m_oFile << "\n"; + + l_rAlgorithmManager.releaseAlgorithm(l_rAlgorithmProxy); + + return true; +} diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..5a773c5156091e8f39204854fa322d9ca263aee5 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.h @@ -0,0 +1,27 @@ +#ifndef __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator_H__ +#define __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator_H__ + +#include "ovpiCPluginObjectDescEnum.h" + +#include <fstream> +#include <map> + +class CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator : public CPluginObjectDescEnum +{ +public: + + CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator(const OpenViBE::Kernel::IKernelContext& rKernelContext, const OpenViBE::CString& sFilename); + virtual ~CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator(void); + virtual OpenViBE::boolean callback(const OpenViBE::Plugins::IPluginObjectDesc& rPluginObjectDesc); + +protected: + + std::ofstream m_oFile; + + std::map<OpenViBE::CIdentifier, OpenViBE::CString> m_oUsedIdentifiers; + // Adds the define to m_usedIdentifiers and m_oFile + void addIdentifier(const OpenViBE::CString &objectName, const OpenViBE::CIdentifier candidate, const OpenViBE::CString &sSpaces); + +}; + +#endif // __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.cpp b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..298d54b3652e123535ef81eeadb54a5bfce92053 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.cpp @@ -0,0 +1,481 @@ +#include "ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h" + +#include <system/include/Time.h> + +#include <iostream> +#include <fstream> +#include <map> +#include <vector> +#include <algorithm> + +#include <gtk/gtk.h> +#include <gdk/gdk.h> +#include <pango/pango.h> + +using namespace std; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +namespace +{ + enum + { + Color_BackgroundPlayerStarted, + Color_BoxBackground, + Color_BoxBackgroundSelected, + Color_BoxBackgroundMissing, + Color_BoxBackgroundObsolete, + Color_BoxBorder, + Color_BoxBorderSelected, + Color_BoxInputBackground, + Color_BoxInputBorder, + Color_BoxOutputBackground, + Color_BoxOutputBorder, + Color_BoxSettingBackground, + Color_BoxSettingBorder, + Color_Link, + Color_LinkSelected, + Color_SelectionArea, + Color_SelectionAreaBorder, + }; +/* + static ::GdkColor colorFromIdentifier(const CIdentifier& rIdentifier) + { + ::GdkColor l_oGdkColor; + unsigned int l_ui32Value1=0; + unsigned int l_ui32Value2=0; + uint64 l_ui64Result=0; + + sscanf(rIdentifier.toString(), "(0x%08X, 0x%08X)", &l_ui32Value1, &l_ui32Value2); + l_ui64Result+=l_ui32Value1; + l_ui64Result<<=32; + l_ui64Result+=l_ui32Value2; + + l_oGdkColor.pixel=(guint16)0; + l_oGdkColor.red =(guint16)(((l_ui64Result )&0xffff)|0x8000); + l_oGdkColor.green=(guint16)(((l_ui64Result>>16)&0xffff)|0x8000); + l_oGdkColor.blue =(guint16)(((l_ui64Result>>32)&0xffff)|0x8000); + + return l_oGdkColor; + } + + static void gdk_draw_rounded_rectangle(::GdkDrawable* pDrawable, ::GdkGC* pDrawGC, ::gboolean bFill, gint x, gint y, gint width, gint height, gint radius=8) + { + if(bFill) + { + gdk_draw_rectangle( + pDrawable, + pDrawGC, + TRUE, + x+radius, y, width-2*radius, height); + gdk_draw_rectangle( + pDrawable, + pDrawGC, + TRUE, + x, y+radius, width, height-2*radius); + } + else + { + gdk_draw_line( + pDrawable, + pDrawGC, + x+radius, y, x+width-radius, y); + gdk_draw_line( + pDrawable, + pDrawGC, + x+radius, y+height, x+width-radius, y+height); + gdk_draw_line( + pDrawable, + pDrawGC, + x, y+radius, x, y+height-radius); + gdk_draw_line( + pDrawable, + pDrawGC, + x+width, y+radius, x+width, y+height-radius); + } + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x+width-radius*2, y, radius*2, radius*2, 0*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x, y, radius*2, radius*2, 90*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x, y+height-radius*2, radius*2, radius*2, 180*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x+width-radius*2, y+height-radius*2, radius*2, radius*2, 270*64, 90*64); + } +*/ +}; + +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ + +CPluginObjectDescEnumAlgorithmSnapshotGenerator::CPluginObjectDescEnumAlgorithmSnapshotGenerator(const IKernelContext& rKernelContext, const CString& sSnapshotDirectory, const CString& sDocTemplateDirectory) + :CPluginObjectDescEnum(rKernelContext) + ,m_sSnapshotDirectory(sSnapshotDirectory) + ,m_sDocTemplateDirectory(sDocTemplateDirectory) +{ + #define gdk_color_set(c, r, g, b) { c.pixel=0; c.red=r; c.green=g; c.blue=b; } + gdk_color_set(m_vColors[Color_BackgroundPlayerStarted], 32767, 32767, 32767); + gdk_color_set(m_vColors[Color_BoxBackgroundSelected], 65535, 65535, 49151); + gdk_color_set(m_vColors[Color_BoxBackgroundMissing], 49151, 32767, 32767); + gdk_color_set(m_vColors[Color_BoxBackgroundObsolete], 32767, 49151, 49151); + gdk_color_set(m_vColors[Color_BoxBackground], 65535, 65535, 65535); + gdk_color_set(m_vColors[Color_BoxBorderSelected], 0, 0, 0); + gdk_color_set(m_vColors[Color_BoxBorder], 0, 0, 0); + gdk_color_set(m_vColors[Color_BoxInputBackground], 65535, 49151, 32767); + gdk_color_set(m_vColors[Color_BoxInputBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_BoxOutputBackground], 32767, 65535, 49151); + gdk_color_set(m_vColors[Color_BoxOutputBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_BoxSettingBackground], 49151, 32767, 65535); + gdk_color_set(m_vColors[Color_BoxSettingBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_Link], 0, 0, 0); + gdk_color_set(m_vColors[Color_LinkSelected], 49151, 16383, 16383); + gdk_color_set(m_vColors[Color_SelectionArea], 0x3f00,0x3f00,0x3f00); + gdk_color_set(m_vColors[Color_SelectionAreaBorder], 0, 0, 0); + #undef gdk_color_set + + m_pWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL); + m_pWidget=gtk_drawing_area_new(); + gtk_container_add(GTK_CONTAINER(m_pWindow), m_pWidget); + gtk_widget_set_size_request(m_pWidget, 512, 128); + gtk_widget_show_all(m_pWindow); + gdk_flush(); + System::Time::sleep(1000); +} + +CPluginObjectDescEnumAlgorithmSnapshotGenerator::~CPluginObjectDescEnumAlgorithmSnapshotGenerator(void) +{ + std::ofstream l_oAlgorithmsFile; + l_oAlgorithmsFile.open((m_sDocTemplateDirectory+"/Doc_Algorithms.dox").c_str()); + l_oAlgorithmsFile + << "/**\n" + << " * \\page Doc_Algorithms Algorithms list\n" + << " *\n" + << " * Available algorithms :\n"; + + uint32 l_ui32Level=0; + string l_sLastCategory; + vector < string > l_vLastSplittedCategory; + vector < pair < string, string > >::iterator itCategories; + std::sort(m_vCategories.begin(), m_vCategories.end()); + for(itCategories=m_vCategories.begin(); itCategories!=m_vCategories.end(); itCategories++) + { + string l_sCategory=itCategories->first; + string l_sName=itCategories->second; + + if(l_sLastCategory!=l_sCategory) + { + vector < string >::iterator itLastSplittedCategory; + vector < string >::iterator itSplittedCategory1; + vector < string >::iterator itSplittedCategory2; + vector < string > l_vSplittedCategory; + size_t i=(size_t)-1; + size_t j; + bool l_bFinished=false; + while(!l_bFinished) + { + j=l_sCategory.find('/', i+1); + if(j==string::npos) + { + j=l_sCategory.length(); + l_bFinished=true; + } + if(j!=i+1) + { + l_vSplittedCategory.push_back(l_sCategory.substr(i+1, j-i-1)); + i=j; + } + } + l_ui32Level=l_vSplittedCategory.size(); + + for(itLastSplittedCategory =l_vLastSplittedCategory.begin(), itSplittedCategory1 =l_vSplittedCategory.begin(); + itLastSplittedCategory!=l_vLastSplittedCategory.end() && itSplittedCategory1!=l_vSplittedCategory.end() && *itLastSplittedCategory==*itSplittedCategory1; + itLastSplittedCategory++, itSplittedCategory1++); + + for(; itSplittedCategory1!=l_vSplittedCategory.end(); itSplittedCategory1++) + { + l_oAlgorithmsFile << " * "; + for(itSplittedCategory2=l_vSplittedCategory.begin(); itSplittedCategory2!=itSplittedCategory1; itSplittedCategory2++) + { + l_oAlgorithmsFile << " "; + } + l_oAlgorithmsFile << " - " << *itSplittedCategory1 << " : \n"; + } + + l_sLastCategory=l_sCategory; + l_vLastSplittedCategory=l_vSplittedCategory; + } + + l_oAlgorithmsFile << " * "; + for(uint32 k=0; k<l_ui32Level+1; k++) + l_oAlgorithmsFile << " "; + l_oAlgorithmsFile << " - \\subpage Doc_algorithm_" << transform(l_sCategory+"/"+l_sName).c_str() << " \"" << l_sName << "\"\n"; + } + + l_oAlgorithmsFile << " */\n"; + l_oAlgorithmsFile.close(); +} + +boolean CPluginObjectDescEnumAlgorithmSnapshotGenerator::callback(const IPluginObjectDesc& rPluginObjectDesc) +{ + string l_sFullName=string(rPluginObjectDesc.getCategory().toASCIIString()) + "/" + string(rPluginObjectDesc.getName().toASCIIString()); + string l_sFilename=m_sSnapshotDirectory+"/Algorithm_"+transform(l_sFullName); + CIdentifier l_oIdentifier; + if((l_oIdentifier=m_rKernelContext.getAlgorithmManager().createAlgorithm(rPluginObjectDesc.getCreatedClassIdentifier()))==OV_UndefinedIdentifier) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Skipped [" << CString(l_sFilename.c_str()) << "] (could not create corresponding algorithm)\n"; + return true; + } + IAlgorithmProxy& l_rAlgorithm=m_rKernelContext.getAlgorithmManager().getAlgorithm(l_oIdentifier); + + m_rKernelContext.getLogManager() << LogLevel_Trace << "Working on [" << CString(l_sFilename.c_str()) << "]\n"; + + ::PangoContext* l_pPangoContext=gtk_widget_get_pango_context(m_pWidget); + ::PangoLayout* l_pPangoLayout=pango_layout_new(l_pPangoContext); + ::PangoRectangle l_oPangoRectangle; + + pango_layout_set_alignment(l_pPangoLayout, PANGO_ALIGN_CENTER); + pango_layout_set_text(l_pPangoLayout, rPluginObjectDesc.getName(), -1); + pango_layout_get_pixel_extents(l_pPangoLayout, NULL, &l_oPangoRectangle); + + uint32 i; + const int xMargin=5; + const int yMargin=5; + const int iCircleMargin=5; + const int iCircleSize=11; + const int iCircleSpace=4; + + int xSize=l_oPangoRectangle.width+xMargin*2; + int ySize=l_oPangoRectangle.height+yMargin*2; + int xStart=16; + int yStart=16; + + gdk_window_invalidate_rect( + m_pWidget->window, + NULL, + true); + + while(gtk_events_pending()) + { + gtk_main_iteration(); + } + + ::GdkGC* l_pDrawGC=gdk_gc_new(m_pWidget->window); + + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxBackground]); + gdk_draw_rectangle( + m_pWidget->window, + l_pDrawGC, + TRUE, + xStart, yStart, xSize, ySize); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxBorder]); + gdk_draw_rectangle( + m_pWidget->window, + l_pDrawGC, + FALSE, + xStart, yStart, xSize, ySize); + + i=0; + CIdentifier l_oInputIdentifier; + while((l_oInputIdentifier=l_rAlgorithm.getNextInputParameterIdentifier(l_oInputIdentifier))!=OV_UndefinedIdentifier) + { + ::GdkColor l_oInputColor=m_vColors[l_rAlgorithm.getInputParameter(l_oInputIdentifier)->getType()]; + + ::GdkPoint l_vPoint[4]; + l_vPoint[0].x=iCircleSize>>1; + l_vPoint[0].y=iCircleSize; + l_vPoint[1].x=0; + l_vPoint[1].y=0; + l_vPoint[2].x=iCircleSize-1; + l_vPoint[2].y=0; + for(int j=0; j<3; j++) + { + l_vPoint[j].x+=xStart+iCircleMargin+i*(iCircleSpace+iCircleSize); + l_vPoint[j].y+=yStart-(iCircleSize>>1); + } + + gdk_gc_set_rgb_fg_color(l_pDrawGC, &l_oInputColor); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + TRUE, + l_vPoint, + 3); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxInputBorder]); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + FALSE, + l_vPoint, + 3); + + i++; + } + + i=0; + CIdentifier l_oOutputIdentifier; + while((l_oOutputIdentifier=l_rAlgorithm.getNextOutputParameterIdentifier(l_oOutputIdentifier))!=OV_UndefinedIdentifier) + { + ::GdkColor l_oOutputColor=m_vColors[l_rAlgorithm.getOutputParameter(l_oOutputIdentifier)->getType()]; + + ::GdkPoint l_vPoint[4]; + l_vPoint[0].x=iCircleSize>>1; + l_vPoint[0].y=iCircleSize; + l_vPoint[1].x=0; + l_vPoint[1].y=0; + l_vPoint[2].x=iCircleSize-1; + l_vPoint[2].y=0; + for(int j=0; j<3; j++) + { + l_vPoint[j].x+=xStart+iCircleMargin+i*(iCircleSpace+iCircleSize); + l_vPoint[j].y+=yStart-(iCircleSize>>1)+ySize; + } + + gdk_gc_set_rgb_fg_color(l_pDrawGC, &l_oOutputColor); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + TRUE, + l_vPoint, + 3); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxOutputBorder]); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + FALSE, + l_vPoint, + 3); + + i++; + } + + gdk_draw_layout( + m_pWidget->window, + m_pWidget->style->text_gc[GTK_WIDGET_STATE(m_pWidget)], + xStart+xMargin, yStart+yMargin, l_pPangoLayout); + g_object_unref(l_pPangoLayout); + g_object_unref(l_pDrawGC); + + ::GdkPixbuf* l_pPixBuf=gdk_pixbuf_get_from_drawable( + NULL, + m_pWidget->window, + NULL, + 0, 0, + 0, 0, + xSize+32, ySize+32); + gdk_pixbuf_save(l_pPixBuf, (l_sFilename+".png").c_str(), "png", NULL, NULL); + + g_object_unref(l_pPixBuf); + + // -------------------------------------------------------------------------------------------------------------------- + +#if 0 + + m_vCategories.push_back(pair < string, string >(rPluginObjectDesc.getCategory().toASCIIString(), rPluginObjectDesc.getName().toASCIIString())); + + std::ofstream l_oFile; + l_oFile.open((l_sFilename+".dox").toASCIIString()); + + l_oFile + << "/**\n" + << " * \\page Doc_" << l_sFilename.c_str() << " " << l_sFullName.toASCIIString() << "\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_summary Summary\n" + << " * \\image html " << l_sFilename.c_str() << ".png\n" + << " *\n" + << " * - Plugin name : " << rPluginObjectDesc.getName() << "\n" + << " * - Version : " << rPluginObjectDesc.getVersion() << "\n" + << " * - Author : " << rPluginObjectDesc.getAuthorName() << "\n" + << " * - Company : " << rPluginObjectDesc.getAuthorCompanyName() << "\n" + << " * - Short description : " << rPluginObjectDesc.getShortDescription() << "\n" + << " * - Documentation template generation date : " << __DATE__ << "\n" + << " *\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_description Description\n" + << " * " << rPluginObjectDesc.getDetailedDescription() << " TODO\n" + << " *\n"; + + l_oFile + << " * \\section Doc_" << l_sFilename.c_str() << "_inputs Inputs\n" + << " * Number of inputs : " << l_rBox.getInputCount() << "\n" + << " *\n"; + for(i=0; i<l_rBox.getInputCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + l_rBox.getInputName(i, l_sName); + l_rBox.getInputType(i, l_oTypeIdentifier); + l_oFile + << " * - Input " << i+1 << "\n" + << " * - Name : " << l_sName.toASCIIString() << "\n" + << " * - Type identifier : " << m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier).toASCIIString() << " " << l_oTypeIdentifier.toString().toASCIIString() << "\n" + << " * - Description : TODO\n" + << " *\n"; + } + + l_oFile + << " * \\section Doc_" << l_sFilename.c_str() << "_outputs Outputs\n" + << " * Number of outputs : " << l_rBox.getOutputCount() << "\n" + << " *\n"; + for(i=0; i<l_rBox.getOutputCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + l_rBox.getOutputName(i, l_sName); + l_rBox.getOutputType(i, l_oTypeIdentifier); + l_oFile + << " * - Output " << i+1 << "\n" + << " * - Name : " << l_sName.toASCIIString() << "\n" + << " * - Type identifier : " << m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier).toASCIIString() << " " << l_oTypeIdentifier.toString().toASCIIString() << "\n" + << " * - Description : TODO\n" + << " *\n"; + } + + l_oFile + << " * \\section Doc_" << l_sFilename.c_str() << "_settings Settings\n" + << " * Number of settings : " << l_rBox.getSettingCount() << "\n" + << " *\n"; + for(i=0; i<l_rBox.getSettingCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + CString l_sDefaultValue; + l_rBox.getSettingName(i, l_sName); + l_rBox.getSettingType(i, l_oTypeIdentifier); + l_rBox.getSettingDefaultValue(i, l_sDefaultValue); + l_oFile + << " * - Setting " << i+1 << "\n" + << " * - Name : " << l_sName.toASCIIString() << "\n" + << " * - Type identifier : " << m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier).toASCIIString() << " " << l_oTypeIdentifier.toString().toASCIIString() << "\n" + << " * - Default value : " << l_sDefaultValue.toASCIIString() << "\n" + << " * - Description : TODO\n" + << " *\n"; + } + + l_oFile + << " * \\section Doc_" << l_sFilename.c_str() << "_examples Examples\n" + << " * TODO\n" + << " *\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_misc Miscellaneous\n" + << " * TODO\n" + << " */"; + + l_oFile.close(); + +#endif + + m_rKernelContext.getAlgorithmManager().releaseAlgorithm(l_rAlgorithm); + + return true; +} diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..ffe04b03d85e3f11a06375e3a75cf5540aa90aed --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h @@ -0,0 +1,34 @@ +#ifndef __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmSnapshotGenerator_H__ +#define __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmSnapshotGenerator_H__ + +#include "ovpiCPluginObjectDescEnum.h" + +#include <map> +#include <vector> +#include <string> + +#include <gtk/gtk.h> + +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ + +class CPluginObjectDescEnumAlgorithmSnapshotGenerator : public CPluginObjectDescEnum +{ +public: + + CPluginObjectDescEnumAlgorithmSnapshotGenerator(const OpenViBE::Kernel::IKernelContext& rKernelContext, const OpenViBE::CString& sSnapshotDirectory, const OpenViBE::CString& sDocTemplateDirectory); + virtual ~CPluginObjectDescEnumAlgorithmSnapshotGenerator(void); + virtual OpenViBE::boolean callback(const OpenViBE::Plugins::IPluginObjectDesc& rPluginObjectDesc); + +protected: + + std::string m_sSnapshotDirectory; + std::string m_sDocTemplateDirectory; + std::vector < std::pair < std::string, std::string > > m_vCategories; + std::map<OpenViBE::uint32, ::GdkColor> m_vColors; + ::GtkWidget* m_pWindow; + ::GtkWidget* m_pWidget; +}; + +#endif // __OpenViBEPluginInspector_CPluginObjectDescEnumAlgorithmSnapshotGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.cpp b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b019e10a216c1858170ecc5129b2da1bf3c3138d --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.cpp @@ -0,0 +1,626 @@ +#include "ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.h" + +#include <system/include/Time.h> + +#include <iostream> +#include <fstream> +#include <map> +#include <vector> +#include <algorithm> + +#include <gtk/gtk.h> +#include <gdk/gdk.h> +#include <pango/pango.h> + +using namespace std; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +namespace +{ + enum + { + Color_BackgroundPlayerStarted, + Color_BoxBackground, + Color_BoxBackgroundSelected, + Color_BoxBackgroundMissing, + Color_BoxBackgroundDeprecated, + Color_BoxBorder, + Color_BoxBorderSelected, + Color_BoxInputBackground, + Color_BoxInputBorder, + Color_BoxOutputBackground, + Color_BoxOutputBorder, + Color_BoxSettingBackground, + Color_BoxSettingBorder, + Color_Link, + Color_LinkSelected, + Color_SelectionArea, + Color_SelectionAreaBorder, + }; + + static ::GdkColor colorFromIdentifier(const CIdentifier& rIdentifier) + { + ::GdkColor l_oGdkColor; + unsigned int l_ui32Value1=0; + unsigned int l_ui32Value2=0; + uint64 l_ui64Result=0; + + sscanf(rIdentifier.toString(), "(0x%08X, 0x%08X)", &l_ui32Value1, &l_ui32Value2); + l_ui64Result+=l_ui32Value1; + l_ui64Result<<=32; + l_ui64Result+=l_ui32Value2; + + l_oGdkColor.pixel=(guint16)0; + l_oGdkColor.red =(guint16)(((l_ui64Result )&0xffff)|0x8000); + l_oGdkColor.green=(guint16)(((l_ui64Result>>16)&0xffff)|0x8000); + l_oGdkColor.blue =(guint16)(((l_ui64Result>>32)&0xffff)|0x8000); + + return l_oGdkColor; + } + + static void gdk_draw_rounded_rectangle(::GdkDrawable* pDrawable, ::GdkGC* pDrawGC, ::gboolean bFill, gint x, gint y, gint width, gint height, gint radius=8) + { + if(bFill) + { + gdk_draw_rectangle( + pDrawable, + pDrawGC, + TRUE, + x+radius, y, width-2*radius, height); + gdk_draw_rectangle( + pDrawable, + pDrawGC, + TRUE, + x, y+radius, width, height-2*radius); + } + else + { + gdk_draw_line( + pDrawable, + pDrawGC, + x+radius, y, x+width-radius, y); + gdk_draw_line( + pDrawable, + pDrawGC, + x+radius, y+height, x+width-radius, y+height); + gdk_draw_line( + pDrawable, + pDrawGC, + x, y+radius, x, y+height-radius); + gdk_draw_line( + pDrawable, + pDrawGC, + x+width, y+radius, x+width, y+height-radius); + } + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x+width-radius*2, y, radius*2, radius*2, 0*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x, y, radius*2, radius*2, 90*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x, y+height-radius*2, radius*2, radius*2, 180*64, 90*64); + gdk_draw_arc( + pDrawable, + pDrawGC, + bFill, + x+width-radius*2, y+height-radius*2, radius*2, radius*2, 270*64, 90*64); + } +}; + +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ + +CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator::CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator(const IKernelContext& rKernelContext, const CString& sSnapshotDirectory, const CString& sDocTemplateDirectory) + :CPluginObjectDescEnum(rKernelContext) + ,m_sSnapshotDirectory(sSnapshotDirectory) + ,m_sDocTemplateDirectory(sDocTemplateDirectory) +{ + m_rKernelContext.getScenarioManager().createScenario(m_oScenarioIdentifier); + m_pScenario=&m_rKernelContext.getScenarioManager().getScenario(m_oScenarioIdentifier); + + #define gdk_color_set(c, r, g, b) { c.pixel=0; c.red=r; c.green=g; c.blue=b; } + gdk_color_set(m_vColors[Color_BackgroundPlayerStarted], 32767, 32767, 32767); + gdk_color_set(m_vColors[Color_BoxBackgroundSelected], 65535, 65535, 49151); + gdk_color_set(m_vColors[Color_BoxBackgroundMissing], 49151, 32767, 32767); + gdk_color_set(m_vColors[Color_BoxBackgroundDeprecated], 16383, 24575, 24575); + gdk_color_set(m_vColors[Color_BoxBackground], 65535, 65535, 65535); + gdk_color_set(m_vColors[Color_BoxBorderSelected], 0, 0, 0); + gdk_color_set(m_vColors[Color_BoxBorder], 0, 0, 0); + gdk_color_set(m_vColors[Color_BoxInputBackground], 65535, 49151, 32767); + gdk_color_set(m_vColors[Color_BoxInputBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_BoxOutputBackground], 32767, 65535, 49151); + gdk_color_set(m_vColors[Color_BoxOutputBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_BoxSettingBackground], 49151, 32767, 65535); + gdk_color_set(m_vColors[Color_BoxSettingBorder], 16383, 16383, 16383); + gdk_color_set(m_vColors[Color_Link], 0, 0, 0); + gdk_color_set(m_vColors[Color_LinkSelected], 49151, 16383, 16383); + gdk_color_set(m_vColors[Color_SelectionArea], 0x3f00,0x3f00,0x3f00); + gdk_color_set(m_vColors[Color_SelectionAreaBorder], 0, 0, 0); + #undef gdk_color_set + + m_pWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL); + m_pWidget=gtk_drawing_area_new(); + gtk_container_add(GTK_CONTAINER(m_pWindow), m_pWidget); + gtk_widget_set_size_request(m_pWidget, 512, 128); + gtk_widget_show_all(m_pWindow); + gdk_flush(); + System::Time::sleep(1000); +} + +CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator::~CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator(void) +{ + m_rKernelContext.getScenarioManager().releaseScenario(m_oScenarioIdentifier); + + std::ofstream l_oBoxAlgorithmsFile; + l_oBoxAlgorithmsFile.open((m_sDocTemplateDirectory+"/Doc_BoxAlgorithms.dox").c_str()); + l_oBoxAlgorithmsFile + << "/**\n" + << " * \\page Doc_BoxAlgorithms Box algorithms list\n" + << " *\n" + << " * Available box algorithms :\n"; + + uint32 l_ui32Level=0; + string l_sLastCategory; + vector < string > l_vLastSplittedCategory; + vector < pair < string, string > >::iterator itCategories; + std::sort(m_vCategories.begin(), m_vCategories.end()); + for(itCategories=m_vCategories.begin(); itCategories!=m_vCategories.end(); itCategories++) + { + string l_sCategory=itCategories->first; + string l_sName=itCategories->second; + + if(l_sLastCategory!=l_sCategory) + { + vector < string >::iterator itLastSplittedCategory; + vector < string >::iterator itSplittedCategory1; + vector < string >::iterator itSplittedCategory2; + vector < string > l_vSplittedCategory; + size_t i=(size_t)-1; + size_t j; + bool l_bFinished=false; + while(!l_bFinished) + { + j=l_sCategory.find('/', i+1); + if(j==string::npos) + { + j=l_sCategory.length(); + l_bFinished=true; + } + if(j!=i+1) + { + l_vSplittedCategory.push_back(l_sCategory.substr(i+1, j-i-1)); + i=j; + } + } + l_ui32Level=l_vSplittedCategory.size(); + + for(itLastSplittedCategory =l_vLastSplittedCategory.begin(), itSplittedCategory1 =l_vSplittedCategory.begin(); + itLastSplittedCategory!=l_vLastSplittedCategory.end() && itSplittedCategory1!=l_vSplittedCategory.end() && *itLastSplittedCategory==*itSplittedCategory1; + itLastSplittedCategory++, itSplittedCategory1++); + + for(; itSplittedCategory1!=l_vSplittedCategory.end(); itSplittedCategory1++) + { + l_oBoxAlgorithmsFile << " * "; + for(itSplittedCategory2=l_vSplittedCategory.begin(); itSplittedCategory2!=itSplittedCategory1; itSplittedCategory2++) + { + l_oBoxAlgorithmsFile << " "; + } + l_oBoxAlgorithmsFile << " - " << *itSplittedCategory1 << " : \n"; + } + + l_sLastCategory=l_sCategory; + l_vLastSplittedCategory=l_vSplittedCategory; + } + + l_oBoxAlgorithmsFile << " * "; + for(uint32 k=0; k<l_ui32Level; k++) + l_oBoxAlgorithmsFile << " "; + l_oBoxAlgorithmsFile << " - \\subpage Doc_BoxAlgorithm_" << transform(l_sName).c_str() << " \"" << l_sName << "\"\n"; + } + + l_oBoxAlgorithmsFile << " */\n"; + l_oBoxAlgorithmsFile.close(); +} + +boolean CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator::callback(const IPluginObjectDesc& rPluginObjectDesc) +{ + string l_sFullName=string(rPluginObjectDesc.getCategory().toASCIIString()) + "/" + string(rPluginObjectDesc.getName().toASCIIString()); + string l_sFilename="BoxAlgorithm_"+transform(rPluginObjectDesc.getName().toASCIIString()); + CIdentifier l_oBoxIdentifier; + if(!m_pScenario->addBox(rPluginObjectDesc.getCreatedClassIdentifier(), l_oBoxIdentifier)) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Skipped [" << CString(l_sFilename.c_str()) << "] (could not create corresponding box)\n"; + return true; + } + IBox& l_rBox=*m_pScenario->getBoxDetails(l_oBoxIdentifier); + IBox& rBox=*m_pScenario->getBoxDetails(l_oBoxIdentifier); + + m_rKernelContext.getLogManager() << LogLevel_Trace << "Working on [" << CString(l_sFilename.c_str()) << "]\n"; + + ::PangoContext* l_pPangoContext=gtk_widget_get_pango_context(m_pWidget); + ::PangoLayout* l_pPangoLayout=pango_layout_new(l_pPangoContext); + ::PangoRectangle l_oPangoRectangle; + + pango_layout_set_alignment(l_pPangoLayout, PANGO_ALIGN_CENTER); + pango_layout_set_text(l_pPangoLayout, rPluginObjectDesc.getName(), -1); + pango_layout_get_pixel_extents(l_pPangoLayout, NULL, &l_oPangoRectangle); + + uint32 i; + const int xMargin=5; + const int yMargin=5; + const int iCircleSize=11; + const int iCircleSpace=4; + + int xSize=l_oPangoRectangle.width+xMargin*2; + int ySize=l_oPangoRectangle.height+yMargin*2; + int xStart=16; + int yStart=16; + + gdk_window_invalidate_rect( + m_pWidget->window, + NULL, + true); + + while(gtk_events_pending()) + { + gtk_main_iteration(); + } + + ::GdkGC* l_pDrawGC=gdk_gc_new(m_pWidget->window); + + boolean l_bDeprecated=m_rKernelContext.getPluginManager().isPluginObjectFlaggedAsDeprecated(rBox.getAlgorithmClassIdentifier()); + if(l_bDeprecated) + { + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxBackgroundDeprecated]); + } + else + { + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxBackground]); + } + + gdk_draw_rounded_rectangle( + m_pWidget->window, + l_pDrawGC, + TRUE, + xStart, yStart, xSize, ySize); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxBorder]); + gdk_draw_rounded_rectangle( + m_pWidget->window, + l_pDrawGC, + FALSE, + xStart, yStart, xSize, ySize); + + int l_iInputOffset=(xSize-l_rBox.getInputCount()*(iCircleSpace+iCircleSize)+iCircleSize/2)/2; + for(i=0; i<l_rBox.getInputCount(); i++) + { + CIdentifier l_oInputIdentifier; + l_rBox.getInputType(i, l_oInputIdentifier); + ::GdkColor l_oInputColor=colorFromIdentifier(l_oInputIdentifier); + + ::GdkPoint l_vPoint[4]; + l_vPoint[0].x=iCircleSize>>1; + l_vPoint[0].y=iCircleSize; + l_vPoint[1].x=0; + l_vPoint[1].y=0; + l_vPoint[2].x=iCircleSize-1; + l_vPoint[2].y=0; + for(int j=0; j<3; j++) + { + l_vPoint[j].x+=xStart+i*(iCircleSpace+iCircleSize)+l_iInputOffset; + l_vPoint[j].y+=yStart-(iCircleSize>>1); + } + + gdk_gc_set_rgb_fg_color(l_pDrawGC, &l_oInputColor); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + TRUE, + l_vPoint, + 3); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxInputBorder]); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + FALSE, + l_vPoint, + 3); + } + + int l_iOutputOffset=(xSize-l_rBox.getOutputCount()*(iCircleSpace+iCircleSize)+iCircleSize/2)/2; + for(i=0; i<l_rBox.getOutputCount(); i++) + { + CIdentifier l_oOutputIdentifier; + l_rBox.getOutputType(i, l_oOutputIdentifier); + ::GdkColor l_oOutputColor=colorFromIdentifier(l_oOutputIdentifier); + + ::GdkPoint l_vPoint[4]; + l_vPoint[0].x=iCircleSize>>1; + l_vPoint[0].y=iCircleSize; + l_vPoint[1].x=0; + l_vPoint[1].y=0; + l_vPoint[2].x=iCircleSize-1; + l_vPoint[2].y=0; + for(int j=0; j<3; j++) + { + l_vPoint[j].x+=xStart+i*(iCircleSpace+iCircleSize)+l_iOutputOffset; + l_vPoint[j].y+=yStart-(iCircleSize>>1)+ySize; + } + + gdk_gc_set_rgb_fg_color(l_pDrawGC, &l_oOutputColor); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + TRUE, + l_vPoint, + 3); + gdk_gc_set_rgb_fg_color(l_pDrawGC, &m_vColors[Color_BoxOutputBorder]); + gdk_draw_polygon( + m_pWidget->window, + l_pDrawGC, + FALSE, + l_vPoint, + 3); + } + + gdk_draw_layout( + m_pWidget->window, + m_pWidget->style->text_gc[GTK_WIDGET_STATE(m_pWidget)], + xStart+xMargin, yStart+yMargin, l_pPangoLayout); + g_object_unref(l_pPangoLayout); + g_object_unref(l_pDrawGC); + + ::GdkPixbuf* l_pPixBuf=gdk_pixbuf_get_from_drawable( + NULL, + m_pWidget->window, + NULL, + 0, 0, + 0, 0, + xSize+32, ySize+32); + gdk_pixbuf_save(l_pPixBuf, (m_sSnapshotDirectory+"/Doc_"+l_sFilename+".png").c_str(), "png", NULL, NULL); + + g_object_unref(l_pPixBuf); + + // -------------------------------------------------------------------------------------------------------------------- + + m_vCategories.push_back(pair < string, string >(rPluginObjectDesc.getCategory().toASCIIString(), rPluginObjectDesc.getName().toASCIIString())); + + std::ofstream l_oFileSkeleton; + std::ofstream l_oFilePart; + l_oFileSkeleton.open((m_sDocTemplateDirectory+"/Doc_"+l_sFilename+".dox-skeleton").c_str()); + l_oFilePart.open((m_sDocTemplateDirectory+"/Doc_"+l_sFilename+".dox-part-skeleton").c_str()); + + l_oFileSkeleton + << "/**\n" + << " * \\page Doc_" << l_sFilename.c_str() << " " << rPluginObjectDesc.getName().toASCIIString() << "\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_Summary Summary\n" + << " * \\image html Doc_" << l_sFilename.c_str() << ".png\n" + << " *\n" + << " * - Plugin name : " << rPluginObjectDesc.getName() << "\n" + << " * - Version : " << rPluginObjectDesc.getVersion() << "\n" + << " * - Author : " << rPluginObjectDesc.getAuthorName() << "\n" + << " * - Company : " << rPluginObjectDesc.getAuthorCompanyName() << "\n" + << " * - Short description : " << rPluginObjectDesc.getShortDescription() << "\n" + << " * - Documentation template generation date : " << __DATE__ << "\n"; + + boolean l_bDeprectated=m_rKernelContext.getPluginManager().isPluginObjectFlaggedAsDeprecated(rPluginObjectDesc.getCreatedClassIdentifier()); + if(l_bDeprectated) + { + l_oFileSkeleton + << " * - <b>WARNING : this box has been marked as DEPRECATED by the developer.</b>\n" + << " * It will be removed soon or later, so you should consider not using this\n" + << " * box and turn to another \"equivalent\" one.\n"; + } + + boolean l_bUnstable=m_rKernelContext.getPluginManager().isPluginObjectFlaggedAsUnstable(rPluginObjectDesc.getCreatedClassIdentifier()); + if(l_bUnstable) + { + l_oFileSkeleton + << " * - <b>WARNING : this box has been marked as UNSTABLE by the developer.\n" + << " * It means that its implementation may be incomplete or that the box can only work\n" + << " * under well known conditions. It may possibly crash or cause data loss.\n" + << " * Use this box at your own risk, you've been warned.</b>\n"; + } + + l_oFileSkeleton + << " *\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_Description Description\n" + << " * " << rPluginObjectDesc.getDetailedDescription() << "\n" + << " *\n" + << " * @Doc_" << l_sFilename.c_str() << "_Description_Content@\n" + << " *\n"; + + l_oFilePart + << "/**\n" + << " * \\page " << l_sFilename.c_str() << " " << rPluginObjectDesc.getName().toASCIIString() << "\n" + << "__________________________________________________________________\n" + << "\n" + << "Detailed description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Description|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Description|\n"; + + if(l_rBox.getInputCount()) + { + l_oFileSkeleton + << " * \\section Doc_" << l_sFilename.c_str() << "_Inputs Inputs\n" + // << " * Number of inputs : " << l_rBox.getInputCount() << "\n" + << " *\n" + << " * @Doc_" << l_sFilename.c_str() << "_Inputs_Content@\n"; + + l_oFilePart + << "__________________________________________________________________\n" + << "\n" + << "Inputs description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Inputs|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Inputs|\n"; + + for(i=0; i<l_rBox.getInputCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + CString l_sTypeName; + l_rBox.getInputName(i, l_sName); + l_rBox.getInputType(i, l_oTypeIdentifier); + l_sTypeName=m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier); + + l_oFileSkeleton + << " * \\subsection Doc_" << l_sFilename.c_str() << "_Input_" << i+1 << " " << i+1 << ". " << l_sName.toASCIIString() << "\n" + << " * @Doc_" << l_sFilename.c_str() << "_Input" << i+1 << "_Content@\n" + << " *\n" + << " * - Type identifier : \\ref Doc_Streams_" << transform(l_sTypeName.toASCIIString()).c_str() << " \"" << l_sTypeName.toASCIIString() << "\" <em>" << l_oTypeIdentifier.toString().toASCIIString() << "</em>\n" + << " *\n"; + + l_oFilePart + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Input" << i+1 << "|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Input" << i+1 << "|\n"; + } + } + + if(l_rBox.getOutputCount()) + { + l_oFileSkeleton + << " * \\section Doc_" << l_sFilename.c_str() << "_Outputs Outputs\n" + // << " * Number of outputs : " << l_rBox.getOutputCount() << "\n" + << " *\n" + << " * @Doc_" << l_sFilename.c_str() << "_Outputs_Content@\n"; + + l_oFilePart + << "__________________________________________________________________\n" + << "\n" + << "Outputs description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Outputs|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Outputs|\n"; + + for(i=0; i<l_rBox.getOutputCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + CString l_sTypeName; + l_rBox.getOutputName(i, l_sName); + l_rBox.getOutputType(i, l_oTypeIdentifier); + l_sTypeName=m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier); + + l_oFileSkeleton + << " * \\subsection Doc_" << l_sFilename.c_str() << "_Output_" << i+1 << " " << i+1 << ". " << l_sName.toASCIIString() << "\n" + << " * @Doc_" << l_sFilename.c_str() << "_Output" << i+1 << "_Content@\n" + << " *\n" + << " * - Type identifier : \\ref Doc_Streams_" << transform(l_sTypeName.toASCIIString()).c_str() << " \"" << l_sTypeName.toASCIIString() << "\" <em>" << l_oTypeIdentifier.toString().toASCIIString() << "</em>\n" + << " *\n"; + + l_oFilePart + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Output" << i+1 << "|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Output" << i+1 << "|\n"; + } + } + + if(l_rBox.getSettingCount()) + { + l_oFileSkeleton + << " * \\section Doc_" << l_sFilename.c_str() << "_Settings Settings\n" + // << " * Number of settings : " << l_rBox.getSettingCount() << "\n" + << " *\n" + << " * @Doc_" << l_sFilename.c_str() << "_Settings_Content@\n"; + + l_oFilePart + << "__________________________________________________________________\n" + << "\n" + << "Settings description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Settings|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Settings|\n"; + + for(i=0; i<l_rBox.getSettingCount(); i++) + { + CString l_sName; + CIdentifier l_oTypeIdentifier; + CString l_sDefaultValue; + CString l_sTypeName; + l_rBox.getSettingName(i, l_sName); + l_rBox.getSettingType(i, l_oTypeIdentifier); + l_rBox.getSettingDefaultValue(i, l_sDefaultValue); + l_sTypeName=m_rKernelContext.getTypeManager().getTypeName(l_oTypeIdentifier); + + l_oFileSkeleton + << " * \\subsection Doc_" << l_sFilename.c_str() << "_Setting_" << i+1 << " " << i+1 << ". " << l_sName.toASCIIString() << "\n" + << " * @Doc_" << l_sFilename.c_str() << "_Setting" << i+1 << "_Content@\n" + << " *\n" +// "\\ref Doc_Types_" << transform(l_sTypeName.toASCIIString()).c_str() + << " * - Type identifier : <em> " << l_sTypeName.toASCIIString() << " " << l_oTypeIdentifier.toString().toASCIIString() << "</em>\n" + << " *\n" + << " * - Default value : [ <em>" << l_sDefaultValue.toASCIIString() << "</em> ]\n" + << " *\n"; + + l_oFilePart + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Setting" << i+1 << "|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Setting" << i+1 << "|\n"; + } + } + + if(rPluginObjectDesc.hasFunctionality(PluginFunctionality_Visualization)) + { + l_oFileSkeleton + << " * \\section Doc_" << l_sFilename.c_str() << "_OnlineVisualizationSettings Online visualisation settings\n" + << " *\n" + << " * @Doc_" << l_sFilename.c_str() << "_OnlineVisualizationSettings_Content@\n"; + + l_oFilePart + << "__________________________________________________________________\n" + << "\n" + << "Online visualisation settings\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_OnlineVisualizationSettings|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_OnlineVisualizationSettings|\n"; + } + + l_oFileSkeleton + << " *\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_Examples Examples\n" + << " * @Doc_" << l_sFilename.c_str() << "_Examples_Content@\n" + << " *\n" + << " * \\section Doc_" << l_sFilename.c_str() << "_Miscellaneous Miscellaneous\n" + << " * @Doc_" << l_sFilename.c_str() << "_Miscellaneous_Content@\n" + << " */\n"; + + l_oFilePart + << "__________________________________________________________________\n" + << "\n" + << "Examples description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Examples|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Examples|\n" + << "__________________________________________________________________\n" + << "\n" + << "Miscellaneous description\n" + << "__________________________________________________________________\n" + << "\n" + << " * |OVP_DocBegin_" << l_sFilename.c_str() << "_Miscellaneous|\n" + << " * |OVP_DocEnd_" << l_sFilename.c_str() << "_Miscellaneous|\n" + << " */\n"; + + l_oFileSkeleton.close(); + l_oFilePart.close(); + + return true; +} diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..880ae4c4272de96a88638081ba70c457773eb678 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.h @@ -0,0 +1,36 @@ +#ifndef __OpenViBEPluginInspector_CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator_H__ +#define __OpenViBEPluginInspector_CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator_H__ + +#include "ovpiCPluginObjectDescEnum.h" + +#include <map> +#include <vector> +#include <string> + +#include <gtk/gtk.h> + +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------------------------ + +class CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator : public CPluginObjectDescEnum +{ +public: + + CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator(const OpenViBE::Kernel::IKernelContext& rKernelContext, const OpenViBE::CString& sSnapshotDirectory, const OpenViBE::CString& sDocTemplateDirectory); + virtual ~CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator(void); + virtual OpenViBE::boolean callback(const OpenViBE::Plugins::IPluginObjectDesc& rPluginObjectDesc); + +protected: + + std::string m_sSnapshotDirectory; + std::string m_sDocTemplateDirectory; + std::vector < std::pair < std::string, std::string > > m_vCategories; + std::map<OpenViBE::uint32, ::GdkColor> m_vColors; + ::GtkWidget* m_pWindow; + ::GtkWidget* m_pWidget; + OpenViBE::CIdentifier m_oScenarioIdentifier; + OpenViBE::Kernel::IScenario* m_pScenario; +}; + +#endif // __OpenViBEPluginInspector_CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_base.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_base.h new file mode 100644 index 0000000000000000000000000000000000000000..93bf1fb06125d3f133a09cae022b6bbe7bdbc887 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_base.h @@ -0,0 +1,12 @@ +#ifndef __OpenViBEPluginInspector_base_H__ +#define __OpenViBEPluginInspector_base_H__ + +#include <ov_all.h> +#include <ovtk_all.h> + +#include <gtk/gtk.h> +#include <gdk/gdk.h> + +#include "ovpi_defines.h" + +#endif // __OpenViBEPluginInspector_base_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_defines.h b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..c80e4ee7d4da0247f112c2f662d2346e53c36836 --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_defines.h @@ -0,0 +1,5 @@ +#ifndef __OpenViBEPluginInspector_defines_H__ +#define __OpenViBEPluginInspector_defines_H__ + + +#endif // __OpenViBEPluginInspector_defines_H__ diff --git a/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_main.cpp b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ad6e4f3159aa4756c2c8fcf8440068361487025e --- /dev/null +++ b/trunk2/core/applications/developer-tools/plugin-inspector/src/ovpi_main.cpp @@ -0,0 +1,291 @@ +#include "ovpiCPluginObjectDescEnumAlgorithmGlobalDefinesGenerator.h" +#include "ovpiCPluginObjectDescEnumBoxAlgorithmSnapshotGenerator.h" +#include "ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h" + +#include <iostream> +#include <sstream> +#include <string> + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; +using namespace std; + +typedef struct _SConfiguration +{ + _SConfiguration(void) : + m_bKernelPathOverload(false), + m_bLoadPluginsFromPaths(false), + m_bDumpPathOverload(false), + m_bConfigPathOverload(false) + {} + + bool m_bKernelPathOverload; + bool m_bLoadPluginsFromPaths; + bool m_bDumpPathOverload; + bool m_bConfigPathOverload; + std::string m_sKernelPath; + std::string m_sDumpPath; + std::string m_sConfigPath; + std::vector<std::string> m_vPluginPaths; +} SConfiguration; + + + +boolean parse_arguments(int argc, char** argv, SConfiguration& rConfiguration) +{ + int i; + std::vector < std::string > l_vArgValue; + std::vector < std::string >::const_iterator it; + + for(i=1; i<argc; i++) + { + l_vArgValue.push_back(argv[i]); + } + + for(it=l_vArgValue.begin(); it!=l_vArgValue.end(); it++) + { + if (*it=="-h" || *it=="--help") + { + std::cout << "Usage: " << argv[0] << " [-p <dir1:dir2...>] [-d <dump_path>]" << std::endl; + return true; + } + // get a list of folders to load plugins from + else if (*it=="-p") + { + if (it + 1 != l_vArgValue.end()) + { + std::string l_sPluginDirectories = *++it; + + // split the argument to separate paths, the delimiter is ":" + std::stringstream ss(l_sPluginDirectories); + std::string item; + while(std::getline(ss, item, ';')) + { + rConfiguration.m_vPluginPaths.push_back(item); + } + rConfiguration.m_bLoadPluginsFromPaths = true; + } + else + { + return false; + } + } + // Configuration path + else if (*it=="-c") + { + if (it + 1 != l_vArgValue.end()) + { + rConfiguration.m_bConfigPathOverload = true; + rConfiguration.m_sConfigPath = *++it; + } + else + { + return false; + } + } + // Kernel path + else if (*it=="-k") + { + if (it + 1 != l_vArgValue.end()) + { + rConfiguration.m_bKernelPathOverload = true; + rConfiguration.m_sKernelPath = *++it; + } + else + { + return false; + } + } + // Dump path + else if (*it=="-d") + { + if (it + 1 != l_vArgValue.end()) + { + rConfiguration.m_bDumpPathOverload = true; + rConfiguration.m_sDumpPath = *++it; + } + else + { + return false; + } + } + } + + return true; +} + + + +int main(int argc, char ** argv) +{ +//___________________________________________________________________// +// // + SConfiguration l_oConfiguration; + + if (!parse_arguments(argc, argv, l_oConfiguration)) + { + std::cout << "Error parsing arguments" << std::endl; + } + + CKernelLoader l_oKernelLoader; + + cout<<"[ INF ] Created kernel loader, trying to load kernel module"<<endl; + CString l_sError; +#if defined TARGET_OS_Windows + CString l_sKernelFile = "/openvibe-kernel.dll"; +#else + CString l_sKernelFile = "/libopenvibe-kernel.so"; +#endif + + if (l_oConfiguration.m_bKernelPathOverload) + { + l_sKernelFile = CString(l_oConfiguration.m_sKernelPath.c_str()) + l_sKernelFile; + } + else + { + l_sKernelFile = OpenViBE::Directories::getLibDir() + l_sKernelFile; + } + + if(!l_oKernelLoader.load(l_sKernelFile, &l_sError)) + { + cout<<"[ FAILED ] Error loading kernel ("<<l_sError<<")" << " from [" << l_sKernelFile << "]\n"; + } + else + { + cout<<"[ INF ] Kernel module loaded, trying to get kernel descriptor"<<endl; + IKernelDesc* l_pKernelDesc=NULL; + IKernelContext* l_pKernelContext=NULL; + l_oKernelLoader.initialize(); + l_oKernelLoader.getKernelDesc(l_pKernelDesc); + if(!l_pKernelDesc) + { + cout<<"[ FAILED ] No kernel descriptor"<<endl; + } + else + { + cout<<"[ INF ] Got kernel descriptor, trying to create kernel"<<endl; + CString l_sConfigPath = OpenViBE::Directories::getDataDir() + "/openvibe.conf"; + if (l_oConfiguration.m_bConfigPathOverload) + { + l_sConfigPath = CString(l_oConfiguration.m_sConfigPath.c_str()); + } + + l_pKernelContext=l_pKernelDesc->createKernel("plugin-inspector", l_sConfigPath ); + if(!l_pKernelContext) + { + cout<<"[ FAILED ] No kernel created by kernel descriptor"<<endl; + } + else + { + OpenViBEToolkit::initialize(*l_pKernelContext); + + IConfigurationManager& l_rConfigurationManager=l_pKernelContext->getConfigurationManager(); + + if (l_oConfiguration.m_bLoadPluginsFromPaths) + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Loading plugins from specified folders\n"; + + std::string l_sPluginPattern; + // Choose the right pattern for libraries to load depending on the OS + #if defined TARGET_OS_Windows + l_sPluginPattern = "openvibe-plugins-*.dll"; + #elif defined TARGET_OS_Linux + l_sPluginPattern = "libopenvibe-plugins-*.so"; + #endif + + typedef std::vector<std::string>::iterator stringVectorIt; + for (stringVectorIt it = l_oConfiguration.m_vPluginPaths.begin(); it != l_oConfiguration.m_vPluginPaths.end(); ++it) + { + std::string l_sPluginPath = *it + "/" + l_sPluginPattern; + std::cout << l_sPluginPath << std::endl; + l_pKernelContext->getPluginManager().addPluginsFromFiles(CString(l_sPluginPath.c_str())); + } + } + else + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Loading plugins as specified by kernel\n"; + l_pKernelContext->getPluginManager().addPluginsFromFiles(l_rConfigurationManager.expand("${Kernel_Plugins}")); + } + + //initialise Gtk before 3D context + gtk_init(&argc, &argv); + // gtk_rc_parse(OpenViBE::Directories::getDataDir() + "/openvibe-applications/designer/interface.gtkrc"); + + if(l_rConfigurationManager.expandAsBoolean("${Kernel_3DVisualisationEnabled}")) + { + // l_pKernelContext->getVisualisationManager().initialize3DContext(); + } + + CString l_sGlobalDefinesDirectory = ""; + + CString l_sAlgorithmSnapshotDirectory = ""; + CString l_sAlgorithmDocTemplateDirectory = ""; + CString l_sBoxAlgorithmSnapshotDirectory = ""; + CString l_sBoxAlgorithmDocTemplateDirectory = ""; + + if (l_oConfiguration.m_bDumpPathOverload) + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping stuff to [" << l_oConfiguration.m_sDumpPath.c_str() << "]\n"; + l_sAlgorithmSnapshotDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/algorithm-snapshots"; + l_sAlgorithmDocTemplateDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/algorithm-doc"; + l_sBoxAlgorithmSnapshotDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/box-algorithm-snapshots"; + l_sBoxAlgorithmDocTemplateDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/box-algorithm-doc"; + l_sGlobalDefinesDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()); + } + else + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Loading paths from Kernel configuration\n"; + l_sAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmSnapshotDirectory}"); + l_sAlgorithmDocTemplateDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmDocTemplateDirectory}"); + l_sBoxAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmSnapshotDirectory}"); + l_sBoxAlgorithmDocTemplateDirectory=l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmDocTemplateDirectory}"); + l_sGlobalDefinesDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpGlobalDefinesDirectory}"); + } + + l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping global defines...\n"; + if(l_sGlobalDefinesDirectory!=CString("")) + { + CPluginObjectDescEnumAlgorithmGlobalDefinesGenerator l_oGlobalDefinesGenerator(*l_pKernelContext, l_sGlobalDefinesDirectory); + l_oGlobalDefinesGenerator.enumeratePluginObjectDesc(OV_ClassId_Plugins_AlgorithmDesc); + } + else + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Skipped, related PluginInspector tokens are empty in openvibe.conf\n"; + } + + l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping algorithm snapshots... to [" << l_sAlgorithmSnapshotDirectory << "]\n"; + if(l_sAlgorithmSnapshotDirectory!=CString("") && l_sAlgorithmDocTemplateDirectory!=CString("")) + { + CPluginObjectDescEnumAlgorithmSnapshotGenerator l_oAlgorithmSnapshotGenerator(*l_pKernelContext, l_sAlgorithmSnapshotDirectory, l_sAlgorithmDocTemplateDirectory); + l_oAlgorithmSnapshotGenerator.enumeratePluginObjectDesc(OV_ClassId_Plugins_AlgorithmDesc); + } + else + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Skipped, related PluginInspector tokens are empty in openvibe.conf\n"; + } + + l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping box algorithm snapshots...\n"; + if(l_sBoxAlgorithmSnapshotDirectory!=CString("") && l_sBoxAlgorithmDocTemplateDirectory!=CString("")) + { + CPluginObjectDescEnumBoxAlgorithmSnapshotGenerator l_oBoxAlgorithmSnapshotGenerator(*l_pKernelContext, l_sBoxAlgorithmSnapshotDirectory, l_sBoxAlgorithmDocTemplateDirectory); + l_oBoxAlgorithmSnapshotGenerator.enumeratePluginObjectDesc(OV_ClassId_Plugins_BoxAlgorithmDesc); + } + else + { + l_pKernelContext->getLogManager() << LogLevel_Info << "Skipped, related PluginInspector tokens are empty in openvibe.conf\n"; + } + + l_pKernelContext->getLogManager() << LogLevel_Info << "Application terminated, releasing allocated objects \n"; + + OpenViBEToolkit::uninitialize(*l_pKernelContext); + + l_pKernelDesc->releaseKernel(l_pKernelContext); + } + } + l_oKernelLoader.uninitialize(); + l_oKernelLoader.unload(); + } + + return 0; +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/CMakeLists.txt b/trunk2/core/applications/developer-tools/skeleton-generator/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..63950a3cf89e741838a51410674f7b07bf7d93f3 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/CMakeLists.txt @@ -0,0 +1,58 @@ +PROJECT(openvibe-skeleton-generator) + +SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR}) +SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR}) +SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH}) +SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl) +ADD_EXECUTABLE(${PROJECT_NAME} ${source_files}) + +INCLUDE("FindOpenViBE") +INCLUDE("FindOpenViBECommon") +INCLUDE("FindOpenViBEToolkit") +INCLUDE("FindOpenViBEModuleSystem") +INCLUDE("FindOpenViBEModuleEBML") +INCLUDE("FindOpenViBEModuleFS") +INCLUDE("FindThirdPartyGTK") +INCLUDE("FindThirdPartyBoost") +INCLUDE("FindThirdPartyBoost_Thread") +INCLUDE("FindThirdPartyBoost_Regex") + +# --------------------------------- +# Target macros +# Defines target operating system +# Defines target architecture +# Defines target compiler +# --------------------------------- +IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-DTARGET_OS_Windows) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio) +ENDIF(WIN32) +IF(UNIX) + # ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc + ADD_DEFINITIONS(-g) + ADD_DEFINITIONS(-fnon-call-exceptions) + ADD_DEFINITIONS(-DTARGET_OS_Linux) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_GCC) +ENDIF(UNIX) + +# ---------------------- +# Generate launch script +# ---------------------- +OV_INSTALL_LAUNCH_SCRIPT("openvibe-skeleton-generator") + +# ----------------------------- +# Install files +# ----------------------------- +INSTALL(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) + +INSTALL(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications/skeleton-generator PATTERN ".svn" EXCLUDE) + +#INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "doc" EXCLUDE) diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-codec-toolkit-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-codec-toolkit-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..02a85c6c82eae05fb74c4a11eb10338ac10a72e5 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-codec-toolkit-skeleton @@ -0,0 +1,146 @@ +#include "ovpCBoxAlgorithm@@ClassName@@.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +using namespace OpenViBEPlugins; +using namespace OpenViBEPlugins::@@Namespace@@; + +boolean CBoxAlgorithm@@ClassName@@::initialize(void) +{ +@@AlgorithmInitialisation@@ +@@AlgorithmInitialisationReferenceTargets@@ + // If you need to retrieve setting values, use the FSettingValueAutoCast function. + // For example : + // - CString setting at index 0 in the setting list : + // CString l_sSettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0); + // - unsigned int64 setting at index 1 in the setting list : + // uint64 l_ui64SettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1); + // - float64 setting at index 2 in the setting list : + // float64 l_f64SettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2); + // ... + + return true; +} +/*******************************************************************************/ + +boolean CBoxAlgorithm@@ClassName@@::uninitialize(void) +{ +@@AlgorithmUninitialisation@@ + return true; +} +/*******************************************************************************/ + +@@ProcessClockCommentIn@@ +boolean CBoxAlgorithm@@ClassName@@::processClock(IMessageClock& rMessageClock) +{ + // some pre-processing code if needed... + + // ready to process ! + getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess(); + + return true; +} +/*******************************************************************************/ + +@@ProcessClockCommentIn@@ +uint64 CBoxAlgorithm@@ClassName@@::getClockFrequency(void) +{ + // Note that the time is coded on a 64 bits unsigned integer, fixed decimal point (32:32) + return @@ClockFrequency@@; // the box clock frequency +} +/*******************************************************************************/ + +@@ProcessInputCommentIn@@ +boolean CBoxAlgorithm@@ClassName@@::processInput(uint32 ui32InputIndex) +{ + // some pre-processing code if needed... + + // ready to process ! + getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess(); + + return true; +} +/*******************************************************************************/ + +boolean CBoxAlgorithm@@ClassName@@::process(void) +{ + + // the static box context describes the box inputs, outputs, settings structures + IBox& l_rStaticBoxContext=this->getStaticBoxContext(); + // the dynamic box context describes the current state of the box inputs and outputs (i.e. the chunks) + IBoxIO& l_rDynamicBoxContext=this->getDynamicBoxContext(); + + // here is some useful functions: + // - To get input/output/setting count: + // l_rStaticBoxContext.getInputCount(); + // l_rStaticBoxContext.getOutputCount(); + + // - To get the number of chunks currently available on a particular input : + // l_rDynamicBoxContext.getInputChunkCount(input_index) + + // - To send an output chunk : + // l_rDynamicBoxContext.markOutputAsReadyToSend(output_index, chunk_start_time, chunk_end_time); + + + // A typical process iteration may look like this. + // This example only iterate over the first input of type Signal, and output a modified Signal. + // thus, the box uses 1 decoder (m_oSignalDecoder) and 1 encoder (m_oSignalEncoder) + /* + IBoxIO& l_rDynamicBoxContext=this->getDynamicBoxContext(); + + //iterate over all chunk on input 0 + for(uint32 i=0; i<l_rDynamicBoxContext.getInputChunkCount(0); i++) + { + // decode the chunk i on input 0 + m_oSignalDecoder.decode(0,i); + // the decoder may have decoded 3 different parts : the header, a buffer or the end of stream. + if(m_oSignalDecoder.isHeaderReceived()) + { + // Header received. This happens only once when pressing "play". For example with a StreamedMatrix input, you now know the dimension count, sizes, and labels of the matrix + // ... maybe do some process ... + + // Pass the header to the next boxes, by encoding a header on the output 0: + m_oSignalEncoder.encodeHeader(0); + // send the output chunk containing the header. The dates are the same as the input chunk: + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + } + if(m_oSignalDecoder.isBufferReceived()) + { + // Buffer received. For example the signal values + // Access to the buffer can be done thanks to : + IMatrix* l_pMatrix = m_oSignalDecoder.getOutputMatrix(); // the StreamedMatrix of samples. + uint64 l_uiSamplingFrequency = m_oSignalDecoder.getOutputSamplingRate(); // the sampling rate of the signal + + // ... do some process on the matrix ... + + // Encode the output buffer : + m_oSignalEncoder.encodeBuffer(0); + // and send it to the next boxes : + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + + } + if(m_oSignalDecoder.isEndReceived()) + { + // End of stream received. This happens only once when pressing "stop". Just pass it to the next boxes so they receive the message : + m_oSignalEncoder.encodeEnd(0); + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + } + + // The current input chunk has been processed, and automaticcaly discarded. + // you don't need to call "l_rDynamicBoxContext.markInputAsDeprecated(0, i);" + } + */ + + // check the official developer documentation webpage for more example and information : + + // Tutorials: + // http://openvibe.inria.fr/documentation/#Developer+Documentation + // Codec Toolkit page : + // http://openvibe.inria.fr/codec-toolkit-references/ + + // Feel free to ask experienced developers on the forum (http://openvibe.inria.fr/forum) and IRC (#openvibe on irc.freenode.net). + + return true; +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..bb842dd7df79d9b08035b8c29c8c895c84b26ac7 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.cpp-skeleton @@ -0,0 +1,151 @@ +#include "ovpCBoxAlgorithm@@ClassName@@.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; + +using namespace OpenViBEPlugins; +using namespace OpenViBEPlugins::@@Namespace@@; + +boolean CBoxAlgorithm@@ClassName@@::initialize(void) +{ +@@AlgorithmInitialisation@@ +@@AlgorithmInitialisationReferenceTargets@@ + // If you need to retrieve setting values, use the FSettingValueAutoCast function. + // For example : + // - CString setting at index 0 in the setting list : + // CString l_sSettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0); + // - unsigned int64 setting at index 1 in the setting list : + // uint64 l_ui64SettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1); + // - float64 setting at index 2 in the setting list : + // float64 l_f64SettingValue = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2); + // ... + + return true; +} +/*******************************************************************************/ + +boolean CBoxAlgorithm@@ClassName@@::uninitialize(void) +{ +@@AlgorithmUninitialisation@@ + return true; +} +/*******************************************************************************/ + +@@ProcessClockCommentIn@@ +boolean CBoxAlgorithm@@ClassName@@::processClock(IMessageClock& rMessageClock) +{ + // some pre-processing code if needed... + + // ready to process ! + getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess(); + + return true; +} +/*******************************************************************************/ + +@@ProcessClockCommentIn@@ +uint64 CBoxAlgorithm@@ClassName@@::getClockFrequency(void) +{ + // Note that the time is coded on a 64 bits unsigned integer, fixed decimal point (32:32) + return @@ClockFrequency@@; // the box clock frequency +} +/*******************************************************************************/ + +@@ProcessInputCommentIn@@ +boolean CBoxAlgorithm@@ClassName@@::processInput(uint32 ui32InputIndex) +{ + // some pre-processing code if needed... + + // ready to process ! + getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess(); + + return true; +} +/*******************************************************************************/ + +boolean CBoxAlgorithm@@ClassName@@::process(void) +{ + + // the static box context describes the box inputs, outputs, settings structures + IBox& l_rStaticBoxContext=this->getStaticBoxContext(); + // the dynamic box context describes the current state of the box inputs and outputs (i.e. the chunks) + IBoxIO& l_rDynamicBoxContext=this->getDynamicBoxContext(); + + // here is some useful functions: + // - To get input/output/setting count: + // l_rStaticBoxContext.getInputCount(); + // l_rStaticBoxContext.getOutputCount(); + // l_rStaticBoxContext.getSettingCount(); + + // - To get the chunks currently available on a particular input : + // l_rDynamicBoxContext.getInputChunkCount(input_index) + // l_rDynamicBoxContext.getInputChunk(input_index, chunk_index) + + // - To get the chunk available on a particular output : + // l_rDynamicBoxContext.getOutputChunk(output_index) + // - To send an output chunk : + // l_rDynamicBoxContext.markOutputAsReadyToSend(output_index, chunk_start_time, chunk_end_time); + + + // A typical process iteration may look like this. + // This example only iterate over the first input. + /* + IBoxIO& l_rDynamicBoxContext=this->getDynamicBoxContext(); + + //iterate over all chunk on input 0 + for(uint32 i=0; i<l_rDynamicBoxContext.getInputChunkCount(0); i++) + { + // fill the decoder input with input chunk + ip_pMemoryBufferToDecode=l_rDynamicBoxContext.getInputChunk(0, i); + // link the encoder output to box output chunk + op_pEncodedMemoryBuffer=l_rDynamicBoxContext.getOutputChunk(0); + + // decode the input chunk + m_pSignalDecoder->process(); + // the decoder may have decoded 3 different parts : the header, a buffer or the end of stream. + // 3 corresponding output triggers may rise. + // the decoded block is now in the decoded output (let's say op_pDecodedMatrix) + + if(m_pSignalDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedHeader)) + { + // Header received. This happens only once when pressing "play". For example with a StreamedMatrix input, you now know the dimension count size, and label of the matrix + // ... do some process ... + + // Pass the header to the next boxes, by encoding it : + m_pSignalEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeHeader); + // send the output chunk containing the header : + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + } + if(m_pSignalDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedBuffer)) + { + // Buffer received. For example the matrix values + // Access to the matrix buffer can be done thanks to : + // op_pDecodedMatrix->getBuffer(), which is a one-dimension vector of value. + + // ... do some process ... + + // Encode the output buffer : + m_pSignalEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeBuffer); + // and send it to the next boxes : + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + + } + if(m_pSignalDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedEnd)) + { + // End of stream received. This happens only once when pressing "stop". Just pass it to the next boxes so they receive the message : + m_pSignalEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeEnd); + l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i)); + } + + // The current input chunk has been processed, let's discard it : + l_rDynamicBoxContext.markInputAsDeprecated(0, i); + } + */ + + // check the official developer documentation webpage for more example and information : + // http://openvibe.inria.fr/documentation/#Developer+Documentation + // Feel free to ask experienced developers on the forum (http://openvibe.inria.fr/forum) and IRC (#openvibe on irc.freenode.net). + + return true; +} \ No newline at end of file diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/box.h-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.h-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..c38308821df5d6f45c703a48954677d5e7d2da89 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/box.h-skeleton @@ -0,0 +1,152 @@ +#ifndef __OpenViBEPlugins_BoxAlgorithm_@@ClassName@@_H__ +#define __OpenViBEPlugins_BoxAlgorithm_@@ClassName@@_H__ + +//You may have to change this path to match your folder organisation +#include "ovp_defines.h" + +#include <openvibe/ov_all.h> +#include <openvibe-toolkit/ovtk_all.h> + +// The unique identifiers for the box and its descriptor. +// Identifier are randomly chosen by the skeleton-generator. +#define OVP_ClassId_BoxAlgorithm_@@ClassName@@ @@RandomIdentifierClass@@ +#define OVP_ClassId_BoxAlgorithm_@@ClassName@@Desc @@RandomIdentifierDescriptor@@ + +namespace OpenViBEPlugins +{ + namespace @@Namespace@@ + { + /** + * \class CBoxAlgorithm@@ClassName@@ + * \author @@Author@@ (@@Company@@) + * \date @@Date@@ + * \brief The class CBoxAlgorithm@@ClassName@@ describes the box @@BoxName@@. + * + */ + class CBoxAlgorithm@@ClassName@@ : virtual public OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm > + { + public: + virtual void release(void) { delete this; } + + virtual OpenViBE::boolean initialize(void); + virtual OpenViBE::boolean uninitialize(void); + + //Here is the different process callbacks possible + // - On clock ticks : + @@ProcessClockComment@@virtual OpenViBE::boolean processClock(OpenViBE::CMessageClock& rMessageClock); + // - On new input received (the most common behaviour for signal processing) : + @@ProcessInputComment@@virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex); + + // If you want to use processClock, you must provide the clock frequency. + @@ProcessClockComment@@virtual OpenViBE::uint64 getClockFrequency(void); + + virtual OpenViBE::boolean process(void); + + // As we do with any class in openvibe, we use the macro below + // to associate this box to an unique identifier. + // The inheritance information is also made available, + // as we provide the superclass OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm > + _IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm >, OVP_ClassId_BoxAlgorithm_@@ClassName@@); + + protected: + @@Algorithms@@ + }; + + + // If you need to implement a box Listener, here is a sekeleton for you. + // Use only the callbacks you need. + // For example, if your box has a variable number of input, but all of them must be stimulation inputs. + // The following listener callback will ensure that any newly added input is stimulations : + /* + virtual OpenViBE::boolean onInputAdded(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) + { + rBox.setInputType(ui32Index, OV_TypeId_Stimulations); + }; + */ + + @@BoxListenerCommentIn@@ + // The box listener can be used to call specific callbacks whenever the box structure changes : input added, name changed, etc. + // Please uncomment below the callbacks you want to use. + class CBoxAlgorithm@@ClassName@@Listener : public OpenViBEToolkit::TBoxListener < OpenViBE::Plugins::IBoxListener > + { + public: + + //virtual OpenViBE::boolean onInitialized(OpenViBE::Kernel::IBox& rBox) { return true; }; + //virtual OpenViBE::boolean onNameChanged(OpenViBE::Kernel::IBox& rBox) { return true; }; + @@BoxListenerOnInputConnectedComment@@virtual OpenViBE::boolean onInputConnected(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnInputDisconnectedComment@@virtual OpenViBE::boolean onInputDisconnected(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnInputAddedComment@@virtual OpenViBE::boolean onInputAdded(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnInputRemovedComment@@virtual OpenViBE::boolean onInputRemoved(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnInputTypeChangedComment@@virtual OpenViBE::boolean onInputTypeChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnInputNameChangedComment@@virtual OpenViBE::boolean onInputNameChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputConnectedComment@@virtual OpenViBE::boolean onOutputConnected(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputDisconnectedComment@@virtual OpenViBE::boolean onOutputDisconnected(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputAddedComment@@virtual OpenViBE::boolean onOutputAdded(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputRemovedComment@@virtual OpenViBE::boolean onOutputRemoved(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputTypeChangedComment@@virtual OpenViBE::boolean onOutputTypeChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnOutputNameChangedComment@@virtual OpenViBE::boolean onOutputNameChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingAddedComment@@virtual OpenViBE::boolean onSettingAdded(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingRemovedComment@@virtual OpenViBE::boolean onSettingRemoved(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingTypeChangedComment@@virtual OpenViBE::boolean onSettingTypeChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingNameChangedComment@@virtual OpenViBE::boolean onSettingNameChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingDefaultValueChangedComment@@virtual OpenViBE::boolean onSettingDefaultValueChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + @@BoxListenerOnSettingValueChangedComment@@virtual OpenViBE::boolean onSettingValueChanged(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index) { return true; }; + + _IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxListener < OpenViBE::Plugins::IBoxListener >, OV_UndefinedIdentifier); + }; + @@BoxListenerCommentOut@@ + + /** + * \class CBoxAlgorithm@@ClassName@@Desc + * \author @@Author@@ (@@Company@@) + * \date @@Date@@ + * \brief Descriptor of the box @@BoxName@@. + * + */ + class CBoxAlgorithm@@ClassName@@Desc : virtual public OpenViBE::Plugins::IBoxAlgorithmDesc + { + public: + + virtual void release(void) { } + + virtual OpenViBE::CString getName(void) const { return OpenViBE::CString("@@BoxName@@"); } + virtual OpenViBE::CString getAuthorName(void) const { return OpenViBE::CString("@@Author@@"); } + virtual OpenViBE::CString getAuthorCompanyName(void) const { return OpenViBE::CString("@@Company@@"); } + virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString("@@ShortDescription@@"); } + virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString("@@DetailedDescription@@"); } + virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("@@Category@@"); } + virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("@@Version@@"); } + virtual OpenViBE::CString getStockItemName(void) const { return OpenViBE::CString("@@StockItemName@@"); } + + virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_BoxAlgorithm_@@ClassName@@; } + virtual OpenViBE::Plugins::IPluginObject* create(void) { return new OpenViBEPlugins::@@Namespace@@::CBoxAlgorithm@@ClassName@@; } + + @@BoxListenerCommentIn@@ + virtual OpenViBE::Plugins::IBoxListener* createBoxListener(void) const { return new CBoxAlgorithm@@ClassName@@Listener; } + virtual void releaseBoxListener(OpenViBE::Plugins::IBoxListener* pBoxListener) const { delete pBoxListener; } + @@BoxListenerCommentOut@@ + virtual OpenViBE::boolean getBoxPrototype( + OpenViBE::Kernel::IBoxProto& rBoxAlgorithmPrototype) const + { + @@Inputs@@ + @@InputFlagCanModify@@ + @@InputFlagCanAdd@@ + + @@Outputs@@ + @@OutputFlagCanModify@@ + @@OutputFlagCanAdd@@ + + @@Settings@@ + @@SettingFlagCanModify@@ + @@SettingFlagCanAdd@@ + + rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_IsUnstable); + + return true; + } + _IsDerivedFromClass_Final_(OpenViBE::Plugins::IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithm_@@ClassName@@Desc); + }; + }; +}; + +#endif // __OpenViBEPlugins_BoxAlgorithm_@@ClassName@@_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.cpp-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.cpp-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..dd8ad3fd5a5b6c255cd340da58ee755de3cb1dca --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.cpp-skeleton @@ -0,0 +1,68 @@ +#include "ovasCConfiguration@@ClassName@@.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBEAcquisitionServer; +using namespace std; + +/*_________________________________________________ + +Insert callback to specific widget here +Example with a button that launch a calibration of the device: + +//Callback connected to a dedicated gtk button: +static void button_calibrate_pressed_cb(::GtkButton* pButton, void* pUserData) +{ + CConfiguration@@ClassName@@* l_pConfig=static_cast<CConfiguration@@ClassName@@*>(pUserData); + l_pConfig->buttonCalibratePressedCB(); +} + +//Callback actually called: +void CConfigurationGTecGUSBamp::buttonCalibratePressedCB(void) +{ + // Connect to the hardware, ask for calibration, verify the return code, etc. +} +_________________________________________________*/ + +// If you added more reference attribute, initialize them here +CConfiguration@@ClassName@@::CConfiguration@@ClassName@@(IDriverContext& rDriverContext, const char* sGtkBuilderFileName) + :CConfigurationBuilder(sGtkBuilderFileName) + ,m_rDriverContext(rDriverContext) +{ +} + +boolean CConfiguration@@ClassName@@::preConfigure(void) +{ + if(! CConfigurationBuilder::preConfigure()) + { + return false; + } + + // Connect here all callbacks + // Example: + // g_signal_connect(gtk_builder_get_object(m_pBuilderConfigureInterface, "button_calibrate"), "pressed", G_CALLBACK(button_calibrate_pressed_cb), this); + + // Insert here the pre-configure code. + // For example, you may want to check if a device is currently connected + // and if more than one are connected. Then you can list in a dedicated combo-box + // the device currently connected so the user can choose which one he wants to acquire from. + + return true; +} + +boolean CConfiguration@@ClassName@@::postConfigure(void) +{ + if(m_bApplyConfiguration) + { + // If the user pressed the "apply" button, you need to save the changes made in the configuration. + // For example, you can save the connection ID of the selected device: + // m_ui32ConnectionID = <value-from-gtk-widget> + } + + if(! CConfigurationBuilder::postConfigure()) // normal header is filled (Subject ID, Age, Gender, channels, sampling frequency), ressources are realesed + { + return false; + } + + return true; +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.h-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.h-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..796b035f547c4dce09e06266ecefffc55f9c536a --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/configuration.h-skeleton @@ -0,0 +1,48 @@ +#ifndef __OpenViBE_AcquisitionServer_CConfiguration@@ClassName@@_H__ +#define __OpenViBE_AcquisitionServer_CConfiguration@@ClassName@@_H__ + +#include "../ovasCConfigurationBuilder.h" +#include "../ovasIDriver.h" + +#include <gtk/gtk.h> + +namespace OpenViBEAcquisitionServer +{ + /** + * \class CConfiguration@@ClassName@@ + * \author @@AuthorName@@ (@@CompanyName@@) + * \date @@Date@@ + * \erief The CConfiguration@@ClassName@@ handles the configuration dialog specific to the @@DriverName@@ device. + * + * TODO: details + * + * \sa CDriver@@ClassName@@ + */ + class CConfiguration@@ClassName@@ : public OpenViBEAcquisitionServer::CConfigurationBuilder + { + public: + + // you may have to add to your constructor some reference parameters + // for example, a connection ID: + //CConfiguration@@ClassName@@(OpenViBEAcquisitionServer::IDriverContext& rDriverContext, const char* sGtkBuilderFileName, OpenViBE::uint32& rConnectionId); + CConfiguration@@ClassName@@(OpenViBEAcquisitionServer::IDriverContext& rDriverContext, const char* sGtkBuilderFileName); + + virtual OpenViBE::boolean preConfigure(void); + virtual OpenViBE::boolean postConfigure(void); + + protected: + + OpenViBEAcquisitionServer::IDriverContext& m_rDriverContext; + + private: + + /* + * Insert here all specific attributes, such as a connection ID. + * use references to directly modify the corresponding attribute of the driver + * Example: + */ + // OpenViBE::uint32& m_ui32ConnectionID; + }; +}; + +#endif // __OpenViBE_AcquisitionServer_CConfiguration@@ClassName@@_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.cpp-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.cpp-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..be6bbb0d74f4ed503cb6803a028fbe023fc6cdb8 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.cpp-skeleton @@ -0,0 +1,154 @@ +#include "ovasCDriver@@ClassName@@.h" +#include "ovasCConfiguration@@ClassName@@.h" + +#include <openvibe-toolkit/ovtk_all.h> + +using namespace OpenViBEAcquisitionServer; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace std; + +//___________________________________________________________________// +// // + +CDriver@@ClassName@@::CDriver@@ClassName@@(IDriverContext& rDriverContext) + :IDriver(rDriverContext) + ,m_pCallback(NULL) + ,m_ui32SampleCountPerSentBlock(0) + ,m_pSample(NULL) +{ + m_oHeader.setSamplingFrequency(@@SamplingFrequency@@); + m_oHeader.setChannelCount(@@MaxChannel@@); +} + +CDriver@@ClassName@@::~CDriver@@ClassName@@(void) +{ +} + +const char* CDriver@@ClassName@@::getName(void) +{ + return "@@DriverName@@"; +} + +//___________________________________________________________________// +// // + +boolean CDriver@@ClassName@@::initialize( + const uint32 ui32SampleCountPerSentBlock, + IDriverCallback& rCallback) +{ + if(m_rDriverContext.isConnected()) return false; + if(!m_oHeader.isChannelCountSet()||!m_oHeader.isSamplingFrequencySet()) return false; + + // Builds up a buffer to store + // acquired samples. This buffer + // will be sent to the acquisition + // server later... + m_pSample=new float32[m_oHeader.getChannelCount()*ui32SampleCountPerSentBlock]; + if(!m_pSample) + { + delete [] m_pSample; + m_pSample=NULL; + return false; + } + + // ... + // initialize hardware and get + // available header information + // from it + // Using for example the connection ID provided by the configuration (m_ui32ConnectionID) + // ... + + // Saves parameters + m_pCallback=&rCallback; + m_ui32SampleCountPerSentBlock=ui32SampleCountPerSentBlock; + return true; +} + +boolean CDriver@@ClassName@@::start(void) +{ + if(!m_rDriverContext.isConnected()) return false; + if(m_rDriverContext.isStarted()) return false; + + // ... + // request hardware to start + // sending data + // ... + + return true; +} + +boolean CDriver@@ClassName@@::loop(void) +{ + if(!m_rDriverContext.isConnected()) return false; + if(!m_rDriverContext.isStarted()) return true; + + OpenViBE::CStimulationSet l_oStimulationSet; + + // ... + // receive samples from hardware + // put them the correct way in the sample array + // whether the buffer is full, send it to the acquisition server + //... + m_pCallback->setSamples(m_pSample); + + // When your sample buffer is fully loaded, + // it is advised to ask the acquisition server + // to correct any drift in the acquisition automatically. + m_rDriverContext.correctDriftSampleCount(m_rDriverContext.getSuggestedDriftCorrectionSampleCount()); + + // ... + // receive events from hardware + // and put them the correct way in a CStimulationSet object + //... + m_pCallback->setStimulationSet(l_oStimulationSet); + + return true; +} + +boolean CDriver@@ClassName@@::stop(void) +{ + if(!m_rDriverContext.isConnected()) return false; + if(!m_rDriverContext.isStarted()) return false; + + // ... + // request the hardware to stop + // sending data + // ... + + return true; +} + +boolean CDriver@@ClassName@@::uninitialize(void) +{ + if(!m_rDriverContext.isConnected()) return false; + if(m_rDriverContext.isStarted()) return false; + + // ... + // uninitialize hardware here + // ... + + delete [] m_pSample; + m_pSample=NULL; + m_pCallback=NULL; + + return true; +} + +//___________________________________________________________________// +// // +boolean CDriver@@ClassName@@::isConfigurable(void) +{ + return true; // change to false if your device is not configurable +} + +boolean CDriver@@ClassName@@::configure(void) +{ + // Change this line if you need to specify some references to your driver attribute that need configuration, e.g. the connection ID. + CConfiguration@@ClassName@@ m_oConfiguration(m_rDriverContext, OpenViBE::Directories::getDataDir() + "/openvibe-applications/acquisition-server/interface-@@ClassName@@.ui"); + if(!m_oConfiguration.configure(m_oHeader)) + { + return false; + } + return true; +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.h-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.h-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..29bbd6034d019307acb248080f7ed423bbd928c4 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/driver.h-skeleton @@ -0,0 +1,67 @@ +#ifndef __OpenViBE_AcquisitionServer_CDriver@@ClassName@@_H__ +#define __OpenViBE_AcquisitionServer_CDriver@@ClassName@@_H__ + +#include "../ovasIDriver.h" +#include "../ovasCHeader.h" +#include <openvibe/ov_all.h> + +namespace OpenViBEAcquisitionServer +{ + /** + * \class CDriver@@ClassName@@ + * \author @@AuthorName@@ (@@CompanyName@@) + * \date @@Date@@ + * \erief The CDriver@@ClassName@@ allows the acquisition server to acquire data from a @@DriverName@@ device. + * + * TODO: details + * + * \sa CConfiguration@@ClassName@@ + */ + class CDriver@@ClassName@@ : public OpenViBEAcquisitionServer::IDriver + { + public: + + CDriver@@ClassName@@(OpenViBEAcquisitionServer::IDriverContext& rDriverContext); + virtual ~CDriver@@ClassName@@(void); + virtual const char* getName(void); + + virtual OpenViBE::boolean initialize( + const OpenViBE::uint32 ui32SampleCountPerSentBlock, + OpenViBEAcquisitionServer::IDriverCallback& rCallback); + virtual OpenViBE::boolean uninitialize(void); + + virtual OpenViBE::boolean start(void); + virtual OpenViBE::boolean stop(void); + virtual OpenViBE::boolean loop(void); + + virtual OpenViBE::boolean isConfigurable(void); + virtual OpenViBE::boolean configure(void); + virtual const OpenViBEAcquisitionServer::IHeader* getHeader(void) { return &m_oHeader; } + + virtual OpenViBE::boolean isFlagSet( + const OpenViBEAcquisitionServer::EDriverFlag eFlag) const + { + return eFlag==DriverFlag_IsUnstable; + } + + protected: + + OpenViBEAcquisitionServer::IDriverCallback* m_pCallback; + + // Replace this generic Header with any specific header you might have written + OpenViBEAcquisitionServer::CHeader m_oHeader; + + OpenViBE::uint32 m_ui32SampleCountPerSentBlock; + OpenViBE::float32* m_pSample; + + private: + + /* + * Insert here all specific attributes, such as USB port number or device ID. + * Example : + */ + // OpenViBE::uint32 m_ui32ConnectionID; + }; +}; + +#endif // __OpenViBE_AcquisitionServer_CDriver@@ClassName@@_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/generator-interface.ui b/trunk2/core/applications/developer-tools/skeleton-generator/share/generator-interface.ui new file mode 100644 index 0000000000000000000000000000000000000000..6242bfbfd1252c29511344ddf2e88576988a08ac --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/generator-interface.ui @@ -0,0 +1,2945 @@ +<?xml version="1.0"?> +<interface> + <requires lib="gtk+" version="2.16"/> + <!-- interface-naming-policy project-wide --> + <object class="GtkAdjustment" id="adjustment1"> + <property name="value">1</property> + <property name="lower">1</property> + <property name="upper">1024</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="value">1</property> + <property name="lower">1</property> + <property name="upper">1024</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkTextBuffer" id="sg-box-tooltips-textbuffer"> + <property name="text">Press any "Help" button for more detail about a field. + + + + + + +</property> + </object> + <object class="GtkDialog" id="sg-selection-dialog"> + <property name="width_request">800</property> + <property name="height_request">300</property> + <property name="border_width">10</property> + <property name="title" translatable="yes">OpenViBE Skeleton-Generator</property> + <property name="resizable">False</property> + <property name="window_position">center</property> + <property name="type_hint">normal</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="spacing">2</property> + <child> + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">3</property> + <property name="column_spacing">10</property> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="larger" foreground="#602020"> OpenViBE Skeleton-Generator</span> + +Please select the skeleton you want to generate : +</property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">3</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="sg-driver-selection-radio-button"> + <property name="label" translatable="yes">Driver skeleton</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="sg-algo-selection-radio-button"> + <property name="label" translatable="yes">Algorithm skeleton</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <property name="group">sg-driver-selection-radio-button</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="sg-box-selection-radio-button"> + <property name="label" translatable="yes">Box skeleton</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <property name="group">sg-driver-selection-radio-button</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Author:</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Company:</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_author_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_company_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkWindow" id="sg-driver-window"> + <property name="width_request">800</property> + <property name="height_request">500</property> + <property name="resizable">False</property> + <property name="window_position">center</property> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="border_width">10</property> + <property name="orientation">vertical</property> + <property name="spacing">10</property> + <child> + <object class="GtkTable" id="table5"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">4</property> + <property name="column_spacing">10</property> + <property name="row_spacing">10</property> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="label" translatable="yes">Driver name:</property> + <property name="justify">right</property> + </object> + </child> + <child> + <object class="GtkEntry" id="entry_sampling_frequencies"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_driver_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_min_channel"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="adjustment">adjustment1</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_max_channel"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="adjustment">adjustment2</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="label" translatable="yes">Class name:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_class_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_length">20</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label11"> + <property name="visible">True</property> + <property name="label" translatable="yes">Target directory:</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-driver-name-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-class-name-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-channel-count-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-sampling-frequencies-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-target-directory-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkFileChooserButton" id="filechooserbutton_target_directory"> + <property name="visible">True</property> + <property name="action">select-folder</property> + <property name="title" translatable="yes">Select a folder</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Sampling frequencies</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Min & Max channel count:</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow7"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="sg-driver-tooltips-textview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="pixels_above_lines">2</property> + <property name="pixels_below_lines">2</property> + <property name="editable">False</property> + <property name="left_margin">5</property> + <property name="right_margin">5</property> + <property name="cursor_visible">False</property> + <property name="buffer">sg-driver-tooltips-textbuffer</property> + </object> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="border_width">10</property> + <property name="spacing">10</property> + <child> + <object class="GtkButton" id="sg-driver-check-button"> + <property name="label" translatable="yes">Check...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-ok-button"> + <property name="label" translatable="yes">Generate !</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-driver-cancel-button"> + <property name="label" translatable="yes">Save & Exit</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkListStore" id="sg-box-icons-liststore"> + <columns> + <!-- column-name icon --> + <column type="gchararray"/> + <!-- column-name name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-add-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + <!-- column-name Identifier --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-add-outputs-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-add-input-triggers-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-add-inputs-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-add-output-triggers-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-settings-liststore"> + <columns> + <!-- column-name name --> + <column type="gchararray"/> + <!-- column-name type --> + <column type="gchararray"/> + <!-- column-name default --> + <column type="gchararray"/> + <!-- column-name type-ov --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-setting-add-type-liststore"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + <!-- column-name type-ov --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-IO-add-type-liststore"> + <columns> + <!-- column-name type --> + <column type="gchararray"/> + <!-- column-name type-ov --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-inputs-liststore"> + <columns> + <!-- column-name name --> + <column type="gchararray"/> + <!-- column-name type --> + <column type="gchararray"/> + <!-- column-name type-ov --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-outputs-liststore"> + <columns> + <!-- column-name name --> + <column type="gchararray"/> + <!-- column-name type --> + <column type="gchararray"/> + <!-- column-name type-ov --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkListStore" id="sg-box-algorithms-liststore"> + <columns> + <!-- column-name Name --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkWindow" id="sg-box-window"> + <property name="window_position">center</property> + <child> + <object class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="border_width">10</property> + <property name="orientation">vertical</property> + <property name="spacing">10</property> + <child> + <object class="GtkLabel" id="label35"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big><b><span fgcolor='#006400'>Welcome to the OpenViBE Skeleton-Generator !</span></b> +Fill the tabs below with what you need, +then run the checking routine and generate the files.</big> + +<i>Press any 'help' button to have more detail about a field in the Console below.</i></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkNotebook" id="sg-box-notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkTable" id="table3"> + <property name="visible">True</property> + <property name="n_rows">11</property> + <property name="n_columns">5</property> + <property name="column_spacing">5</property> + <property name="row_spacing">5</property> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Box name:</property> + <property name="justify">right</property> + </object> + </child> + <child> + <object class="GtkEntry" id="sg-box-box-name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label14"> + <property name="visible">True</property> + <property name="label" translatable="yes">Version:</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-version-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-name-version-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator2"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">5</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">Short description:</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-short-description-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="label" translatable="yes">Detailed description:</property> + </object> + <packing> + <property name="top_attach">5</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-description-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">4</property> + <property name="bottom_attach">7</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label13"> + <property name="visible">True</property> + <property name="label" translatable="yes">Box icon:</property> + </object> + <packing> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sg-box-icon-combobox"> + <property name="visible">True</property> + <property name="model">sg-box-icons-liststore</property> + <signal name="changed" handler="entry_modified_cb"/> + <child> + <object class="GtkCellRendererPixbuf" id="sg-box-icon-cellrenderer"/> + <attributes> + <attribute name="icon-name">1</attribute> + <attribute name="stock-id">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> + <property name="x_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator4"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">5</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-icon-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator5"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">5</property> + <property name="top_attach">9</property> + <property name="bottom_attach">10</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label19"> + <property name="visible">True</property> + <property name="label" translatable="yes"><i>Your box will be automatically flagged as <span fgcolor='red'>UNSTABLE</span> +Don't forget to set the configuration variable <b>Designer_ShowUnstable</b> to TRUE +in your configuration file in order to see it in the Designer.</i></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">5</property> + <property name="top_attach">10</property> + <property name="bottom_attach">11</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="sg-box-detailed-description-textview"> + <property name="height_request">50</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="wrap_mode">word</property> + <property name="left_margin">1</property> + <property name="right_margin">1</property> + <property name="buffer">sg-box-detailed-description-textbuffer</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">5</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label27"> + <property name="visible">True</property> + <property name="label" translatable="yes">Class name:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-class-name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-class-name-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label28"> + <property name="visible">True</property> + <property name="label" translatable="yes">Category:</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-category-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-category-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="label15"> + <property name="visible">True</property> + <property name="label" translatable="yes">General</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table6"> + <property name="visible">True</property> + <property name="border_width">3</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="column_spacing">5</property> + <property name="row_spacing">5</property> + <child> + <object class="GtkLabel" id="label20"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big>Please describe the box input(s), by providing +a name and a type for each input</big></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">3</property> + <child> + <object class="GtkButton" id="sg-box-inputs-add-button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-inputs-remove-button"> + <property name="label">gtk-remove</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator6"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-inputs-list-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-inputs-modify-checkbutton"> + <property name="label" translatable="yes">The input(s) can be modified by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-inputs-add-checkbutton"> + <property name="label" translatable="yes">Inputs can be added and removed by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-inputs-modify-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-inputs-add-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="sg-box-inputs-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-inputs-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="sizing">autosize</property> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="title">Type</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext3"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label16"> + <property name="visible">True</property> + <property name="label" translatable="yes">Inputs</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table7"> + <property name="visible">True</property> + <property name="border_width">3</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="column_spacing">5</property> + <property name="row_spacing">5</property> + <child> + <object class="GtkLabel" id="label21"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big>Please describe the box output(s), by providing +a name and a type for each output</big></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">3</property> + <child> + <object class="GtkButton" id="sg-box-outputs-add-button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-outputs-remove-button"> + <property name="label">gtk-remove</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator7"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-outputs-list-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-outputs-modify-checkbutton"> + <property name="label" translatable="yes">The output(s) can be modified by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-outputs-add-checkbutton"> + <property name="label" translatable="yes">Outputs can be added and removed by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-outputs-modify-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-outputs-add-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="sg-box-outputs-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-outputs-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext6"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <property name="title">Type</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext7"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label17"> + <property name="visible">True</property> + <property name="label" translatable="yes">Outputs</property> + </object> + <packing> + <property name="position">2</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table8"> + <property name="visible">True</property> + <property name="border_width">3</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="column_spacing">5</property> + <property name="row_spacing">5</property> + <child> + <object class="GtkLabel" id="label22"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big>Please describe the box setting(s), by providing +a name, a type and a default value for each setting</big></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox5"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">3</property> + <child> + <object class="GtkButton" id="sg-box-settings-add-button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-settings-remove-button"> + <property name="label">gtk-remove</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator8"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-settings-list-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-settings-modify-checkbutton"> + <property name="label" translatable="yes">The setting(s) can be modified by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-settings-add-checkbutton"> + <property name="label" translatable="yes">Settings can be added and removed by the box user</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-settings-modify-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-settings-add-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow5"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="sg-box-settings-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-settings-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn5"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext8"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn6"> + <property name="title">Type</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext9"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn7"> + <property name="title">Default Value</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext10"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label18"> + <property name="visible">True</property> + <property name="label" translatable="yes">Settings</property> + </object> + <packing> + <property name="position">3</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table11"> + <property name="visible">True</property> + <property name="border_width">3</property> + <property name="n_rows">3</property> + <property name="n_columns">3</property> + <property name="column_spacing">5</property> + <property name="row_spacing">5</property> + <child> + <object class="GtkLabel" id="label30"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big>Select the stream decoder(s) and encoder(s) you want to use in the box. +The skeleton generator will handle the initialisation and +destruction of these algorithms. +<span fgcolor='#BB0000'>The connection between algorithms (reference targets) +has to be done manually.</span> +</big></property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="right_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox6"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">3</property> + <child> + <object class="GtkButton" id="sg-box-algorithms-add-button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-algorithms-remove-button"> + <property name="label">gtk-remove</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator11"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-algorithms-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow6"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="sg-box-algorithms-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-algorithms-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn8"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext11"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-algorithms-toolkit-checkbutton"> + <property name="label" translatable="yes">Use the Codec Toolkit in the implementation (recommended)</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-algorithms-toolkit-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label29"> + <property name="visible">True</property> + <property name="label" translatable="yes">Codec Algorithms</property> + </object> + <packing> + <property name="position">4</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox8"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="label46"> + <property name="visible">True</property> + <property name="label" translatable="yes"><big><b>Processing Methods</b></big> +Depending on your needs, OpenViBE can call the box 'process' method in 2 different ways : +whenever a new input chunk is received on any input, <u>and/or</u> on every tick of a defined clock. +In your box implementation, you choose to activate or not these 2 behaviours +by overwritting 2 callbacks: <b>'processInput'</b> and <b>'processClock'</b>. +</property> + <property name="use_markup">True</property> + <property name="justify">center</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-process-input-checkbutton"> + <property name="label" translatable="yes">Call the 'process' callback whenever a new input chunk is available</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-process-clock-checkbutton"> + <property name="label" translatable="yes">Call the 'process' callback at a specific frequency</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="processing_method_clock_toggled"/> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + <child> + <object class="GtkLabel" id="label47"> + <property name="visible">True</property> + <property name="label" translatable="yes">Clock Frequency (in Hertz):</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="sg-box-process-frequency-spinbutton"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="adjustment">adjustment1</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label48"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label49"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label50"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label51"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">6</property> + </packing> + </child> + </object> + <packing> + <property name="fill">False</property> + <property name="padding">5</property> + <property name="position">4</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">5</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label45"> + <property name="visible">True</property> + <property name="label" translatable="yes">Processing Method</property> + </object> + <packing> + <property name="position">6</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox7"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">5</property> + <child> + <object class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <child> + <object class="GtkCheckButton" id="sg-box-listener-checkbutton"> + <property name="label" translatable="yes">Implement a Box Listener</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="listener_checkbutton_toggled_cb"/> + </object> + <packing> + <property name="padding">10</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-listener-tooltip-button"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">10</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">10</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator16"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table13"> + <property name="visible">True</property> + <property name="n_rows">7</property> + <property name="n_columns">3</property> + <child> + <object class="GtkLabel" id="label42"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Input Callbacks</b></property> + <property name="use_markup">True</property> + </object> + </child> + <child> + <object class="GtkLabel" id="label43"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Output Callbacks</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label44"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Settings Callbacks</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-added-checkbutton"> + <property name="label" translatable="yes">On input added</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-removed-checkbutton"> + <property name="label" translatable="yes">On input removed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-type-checkbutton"> + <property name="label" translatable="yes">On input type changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-name-checkbutton"> + <property name="label" translatable="yes">On input name changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-connected-checkbutton"> + <property name="label" translatable="yes">On input connected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-input-disconnected-checkbutton"> + <property name="label" translatable="yes">On input disconnected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-added-checkbutton"> + <property name="label" translatable="yes">On output added</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-removed-checkbutton"> + <property name="label" translatable="yes">On output removed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-type-checkbutton"> + <property name="label" translatable="yes">On output type changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-name-checkbutton"> + <property name="label" translatable="yes">On output name changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-connected-checkbutton"> + <property name="label" translatable="yes">On output connected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-added-checkbutton"> + <property name="label" translatable="yes">On setting added</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-removed-checkbutton"> + <property name="label" translatable="yes">On setting removed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-type-checkbutton"> + <property name="label" translatable="yes">On setting type changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-name-checkbutton"> + <property name="label" translatable="yes">On setting name changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-default-checkbutton"> + <property name="label" translatable="yes">On setting default value changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-setting-value-checkbutton"> + <property name="label" translatable="yes">On setting value changed</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sg-box-listener-output-disconnected-checkbutton"> + <property name="label" translatable="yes">On output disconnected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">6</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label41"> + <property name="visible">True</property> + <property name="label" translatable="yes">Box Listener</property> + </object> + <packing> + <property name="position">6</property> + <property name="tab_fill">False</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator3"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">16</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label40"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b><span color="#006400"><big> | Help and Status Console | </big></span></b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="height_request">175</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hadjustment">adjustment3</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">out</property> + <child> + <object class="GtkTextView" id="sg-box-tooltips-textview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="pixels_above_lines">2</property> + <property name="pixels_below_lines">2</property> + <property name="editable">False</property> + <property name="left_margin">5</property> + <property name="right_margin">5</property> + <property name="cursor_visible">False</property> + <property name="buffer">sg-box-tooltips-textbuffer</property> + </object> + </child> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="border_width">10</property> + <property name="spacing">10</property> + <child> + <object class="GtkButton" id="sg-box-check-button"> + <property name="label" translatable="yes">Check...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-ok-button"> + <property name="label" translatable="yes">Generate !</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sg-box-exit-button"> + <property name="label" translatable="yes">Save & Exit</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">5</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkTextBuffer" id="sg-driver-tooltips-textbuffer"> + <property name="text" translatable="yes">Press any "Help !" button for more detail about a field. + + + + + + +</property> + </object> + <object class="GtkTextBuffer" id="sg-box-detailed-description-textbuffer"> + <signal name="changed" handler="entry_modified_cb"/> + </object> + <object class="GtkDialog" id="sg-box-IO-add-dialog"> + <property name="border_width">5</property> + <property name="window_position">center</property> + <property name="type_hint">normal</property> + <property name="deletable">False</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox2"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkTable" id="table4"> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">2</property> + <property name="column_spacing">3</property> + <property name="row_spacing">3</property> + <child> + <object class="GtkLabel" id="label23"> + <property name="visible">True</property> + <property name="label" translatable="yes">Name:</property> + </object> + <packing> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label24"> + <property name="visible">True</property> + <property name="label" translatable="yes">Type:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-IO-add-name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sg-box-IO-add-type-combobox"> + <property name="visible">True</property> + <property name="model">sg-box-IO-add-type-liststore</property> + <property name="active">0</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext4"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator9"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area2"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkDialog" id="sg-box-settings-add-dialog"> + <property name="border_width">5</property> + <property name="window_position">center</property> + <property name="type_hint">normal</property> + <property name="deletable">False</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox4"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkTable" id="table9"> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="column_spacing">3</property> + <property name="row_spacing">3</property> + <child> + <object class="GtkLabel" id="label25"> + <property name="visible">True</property> + <property name="label" translatable="yes">Name:</property> + </object> + <packing> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label26"> + <property name="visible">True</property> + <property name="label" translatable="yes">Type:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_EXPAND</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-settings-add-name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sg-box-settings-add-type-combobox"> + <property name="visible">True</property> + <property name="model">sg-box-setting-add-type-liststore</property> + <property name="active">0</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext5"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator10"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="sg-box-settings-add-default-value-label"> + <property name="visible">True</property> + <property name="label" translatable="yes">Default value:</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-settings-add-default-value-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area4"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkDialog" id="sg-box-algorithms-add-dialog"> + <property name="border_width">5</property> + <property name="window_position">center</property> + <property name="type_hint">normal</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox5"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkTable" id="table10"> + <property name="visible">True</property> + <property name="n_rows">9</property> + <property name="n_columns">4</property> + <child> + <object class="GtkLabel" id="label31"> + <property name="visible">True</property> + <property name="label" translatable="yes">Name:</property> + </object> + </child> + <child> + <object class="GtkHSeparator" id="hseparator12"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">4</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label32"> + <property name="visible">True</property> + <property name="label" translatable="yes">Input(s):</property> + </object> + <packing> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label33"> + <property name="visible">True</property> + <property name="label" translatable="yes">Output(s):</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label34"> + <property name="label" translatable="yes">Input Trigger(s):</property> + </object> + <packing> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sg-box-algorithms-add-combobox"> + <property name="visible">True</property> + <property name="model">sg-box-algorithms-add-liststore</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext18"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="sg-box-algorithms-add-inputs-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-algorithms-add-inputs-liststore</property> + <property name="headers_clickable">False</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn9"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext12"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="sg-box-algorithms-add-outputs-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">sg-box-algorithms-add-outputs-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn11"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext14"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="sg-box-algorithms-add-input-triggers-treeview"> + <property name="can_focus">True</property> + <property name="model">sg-box-algorithms-add-input-triggers-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn13"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext16"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator13"/> + <packing> + <property name="right_attach">4</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label36"> + <property name="label" translatable="yes">Short description:</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-algorithms-add-short-description-entry"> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label37"> + <property name="label" translatable="yes">Detailed description:</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkTextView" id="sg-box-algorithms-add-detailed-description-textview"> + <property name="can_focus">True</property> + <property name="editable">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label38"> + <property name="label" translatable="yes">Category:</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="sg-box-algorithms-add-category-entry"> + <property name="editable">False</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator14"> + <property name="visible">True</property> + </object> + <packing> + <property name="right_attach">4</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label39"> + <property name="label" translatable="yes">Output Trigger(s):</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="sg-box-algorithms-add-output-triggers-treeview"> + <property name="can_focus">True</property> + <property name="model">sg-box-algorithms-add-output-triggers-liststore</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn10"> + <property name="title">Name</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext13"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area5"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="lower">10</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + <property name="page_size">100</property> + </object> +</interface> diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/interface.ui-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/interface.ui-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..2e37bcc6c33d10a2e8c4d579d5327ca3b860df1c --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/interface.ui-skeleton @@ -0,0 +1,323 @@ +<?xml version="1.0"?> +<interface> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">100</property> + <property name="lower">0</property> + <property name="page_increment">10</property> + <property name="step_increment">1</property> + <property name="page_size">0</property> + <property name="value">18</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="upper">100</property> + <property name="lower">0</property> + <property name="page_increment">10</property> + <property name="step_increment">1</property> + <property name="page_size">0</property> + <property name="value">0</property> + </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="upper">@@MaxChannel@@</property> + <property name="lower">@@MinChannel@@</property> + <property name="page_increment">10</property> + <property name="step_increment">1</property> + <property name="page_size">0</property> + <property name="value">@@MaxChannel@@</property> + </object> + <object class="GtkListStore" id="model1"> + <columns> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">unspecified</col> + </row> + <row> + <col id="0" translatable="yes">female</col> + </row> + <row> + <col id="0" translatable="yes">male</col> + </row> + <row> + <col id="0" translatable="yes">unknown</col> + </row> + </data> + </object> + <object class="GtkListStore" id="model2"> + <columns> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">@@SamplingFrequencyList@@</col> + </row> + </data> + </object> + <!-- interface-requires gtk+ 2.6 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkDialog" id="openvibe-acquisition-server-settings"> + <property name="border_width">5</property> + <property name="title" translatable="yes">Device configuration</property> + <property name="window_position">center</property> + <property name="type_hint">dialog</property> + <property name="gravity">center</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="spacing">8</property> + <child> + <object class="GtkLabel" id="label_title"> + <property name="visible">True</property> + <property name="label" translatable="yes">@@DriverName@@</property> + <property name="justify">center</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox"> + <property name="visible">True</property> + <property name="border_width">8</property> + <property name="spacing">8</property> + <child> + <object class="GtkHBox" id="hbox"> + <property name="visible">True</property> + <property name="spacing">8</property> + <child> + <object class="GtkTable" id="table2"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkComboBox" id="combobox_gender"> + <property name="visible">True</property> + <property name="model">model1</property> + <child> + <object class="GtkCellRendererText" id="renderer1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_age"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment1</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_identifier"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment2</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_sampling_frequency"> + <property name="visible">True</property> + <property name="label" translatable="yes">Sampling frequency :</property> + <property name="justify">right</property> + <property name="single_line_mode">True</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_number_of_channels"> + <property name="visible">True</property> + <property name="label" translatable="yes">Number of channels :</property> + <property name="justify">right</property> + <property name="single_line_mode">True</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_gender"> + <property name="visible">True</property> + <property name="label" translatable="yes">Gender :</property> + <property name="justify">right</property> + <property name="single_line_mode">True</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_age"> + <property name="visible">True</property> + <property name="label" translatable="yes">Age :</property> + <property name="justify">right</property> + <property name="single_line_mode">True</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_identifier"> + <property name="visible">True</property> + <property name="label" translatable="yes">Identifier :</property> + <property name="justify">right</property> + <property name="single_line_mode">True</property> + </object> + </child> + <child> + <object class="GtkComboBox" id="combobox_sampling_frequency"> + <property name="visible">True</property> + <property name="active">0</property> + <property name="model">model2</property> + <child> + <object class="GtkCellRendererText" id="renderer2"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_number_of_channels"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment3</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button_change_channel_names"> + <property name="label" translatable="yes">Change channel names</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">4</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button_apply"> + <property name="label">gtk-apply</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button_cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-10">button_apply</action-widget> + <action-widget response="-6">button_cancel</action-widget> + </action-widgets> + </object> +</interface> diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/libiconv2.dll b/trunk2/core/applications/developer-tools/skeleton-generator/share/libiconv2.dll new file mode 100644 index 0000000000000000000000000000000000000000..544dd92f56d05f4caf06bfac3194431ddd1bc97f Binary files /dev/null and b/trunk2/core/applications/developer-tools/skeleton-generator/share/libiconv2.dll differ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/libintl3.dll b/trunk2/core/applications/developer-tools/skeleton-generator/share/libintl3.dll new file mode 100644 index 0000000000000000000000000000000000000000..ec11e6b19911c2714181f57f8c2f05bee40958b0 Binary files /dev/null and b/trunk2/core/applications/developer-tools/skeleton-generator/share/libintl3.dll differ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-box.txt-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-box.txt-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..8db70288d039a5a92490d977443e3df94cb5a744 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-box.txt-skeleton @@ -0,0 +1,51 @@ +****************************************************** +* Thanks for using the OpenViBE Skeleton Generator ! * +****************************************************** + +File generation completed +[@@Date@@] +------------------------- + +The generator produced the following files: + +The Box class: +- ovpCBoxAlgorithm@@ClassName@@.h +- ovpCBoxAlgorithm@@ClassName@@.cpp +Please put these files in your local repository, in the project of your choice (e.g. Signal Processing or Classification) + [openvibe-repository]/trunk/openvibe-plugins/[plugin-project]/trunc/src/[my-box-folder] + +You may have to change the file ovpCBoxAlgorithm@@ClassName@@.h to make it find the included file ovp_defines.h, whose path is related to the project used. + +Don't forget to declare your box in ovp_main.cpp, in order to make it available in the Designer. +Look in one of the ovp_main.cpp file, you will find examples of such declarations (#include the header, then OVP_Declare_New macro). +This look something like this: + +#include "[my-box-folder]/ovpCBoxAlgorithm@@ClassName@@.h" + +... + +OVP_Declare_Begin(); + +... + +OVP_Declare_New(OpenViBEPlugins::@@Namespace@@::CBoxAlgorithm@@ClassName@@Desc); +... + +OVP_Declare_End(); + + +If your box doesn't appear in the designer, maybe it's because you cannot see Unstable Boxes. +Try to set your configuration file (openvibe.conf on windows / .openviberc on Linux) with the following token : +>>>>> +Designer_ShowUnstable = true +>>>>> + +For more information about implementing algorithms and boxes to fill your skeleton, please read the official tutorial: +http://openvibe.inria.fr/tutorial-1-implementing-a-signal-processing-box/ + +Feel free to propose your contribution on the forum ! +http://openvibe.inria.fr/forum/ + +Enjoy OpenViBE ! + +- The development team - diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-driver.txt-skeleton b/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-driver.txt-skeleton new file mode 100644 index 0000000000000000000000000000000000000000..3468b40cf6ce134400a8ee3d4eead34509c65ca4 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/share/readme-driver.txt-skeleton @@ -0,0 +1,44 @@ +****************************************************** +* Thanks for using the OpenViBE Skeleton Generator ! * +****************************************************** + +File generation completed +[@@Date@@] +------------------------- + +WARNING: +Writing a new driver for an EEG device is hardly dependent on hardware specifications, such as OS compatibility +or communication protocol. The generator gives you only the basic skeletons for easy integration with OpenViBE, +please refer to your device specifications (API, protocol description, etc.) for the next steps... + +The generator produced the following files: + +The Driver class: +- ovasCDriver@@ClassName@@.h +- ovasCDriver@@ClassName@@.cpp +You can put the driver files in the trunk directory in your local repository: + [openvibe-repository]/trunk/openvibe-applications/acquisition-server/trunk/src/[my-device]/ + +The configuration class: +- ovasCConfiguration@@ClassName@@.h +- ovasCConfiguration@@ClassName@@.cpp +You can put these files in the trunk directory in your local repository: + [openvibe-repository]/trunk/openvibe-applications/acquisition-server/trunk/src/[my-device]/ + +The glade interface: +- interface-@@ClassName@@.glade +You can put this file in the trunk directory in your local repository: + [openvibe-repository]/trunk/openvibe-applications/acquisition-server/trunk/share/openvibe-applications/acquisition-server/ + +Don't forget to declare your driver in the Acquisition Server application. +Look in ovasCAquisitionServerGUI.cpp, you will find examples of such declarations. + +For more information about building a new driver and filling your skeleton, please read the official tutorial: +http://openvibe.inria.fr/tutorial-creating-a-new-driver-for-the-acquisition-server/ + +Feel free to propose your contribution on the forum ! +http://openvibe.inria.fr/forum/ + +Enjoy OpenViBE ! + +- The development team - diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/regex2.dll b/trunk2/core/applications/developer-tools/skeleton-generator/share/regex2.dll new file mode 100644 index 0000000000000000000000000000000000000000..f84a847a0de92fc59fa2ff8494ff700e62b87326 Binary files /dev/null and b/trunk2/core/applications/developer-tools/skeleton-generator/share/regex2.dll differ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/share/sed.exe b/trunk2/core/applications/developer-tools/skeleton-generator/share/sed.exe new file mode 100644 index 0000000000000000000000000000000000000000..42c26778d0f8d8772d09f2030392f139566858d3 Binary files /dev/null and b/trunk2/core/applications/developer-tools/skeleton-generator/share/sed.exe differ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.cpp b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..311851e40dc45c0b02c1b3db92c092ef696ea80e --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.cpp @@ -0,0 +1,2089 @@ +#include "ovsgCBoxAlgorithmSkeletonGenerator.h" + + +#include <iostream> +#include <sstream> + +#include <glib/gstdio.h> +#include <cstdio> + +#include <boost/regex.hpp> + +#include <ctime> +#include <cmath> + +#include <list> + +using namespace std; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBE::Plugins; +using namespace OpenViBESkeletonGenerator; + +boolean CDummyAlgoProto::addInputParameter(const CIdentifier& rInputParameterIdentifier,const CString& sInputName,const EParameterType eParameterType,const CIdentifier& rSubTypeIdentifier) +{ + m_vInputs[sInputName] = eParameterType; + return true; +} +boolean CDummyAlgoProto::addOutputParameter(const CIdentifier& rOutputParameterIdentifier,const CString& sOutputName,const EParameterType eParameterType,const CIdentifier& rSubTypeIdentifier) +{ + m_vOutputs[sOutputName] = eParameterType; + return true; +} + +boolean CDummyAlgoProto::addInputTrigger(const CIdentifier& rInputTriggerIdentifier,const CString& rInputTriggerName) +{ + m_vInputTriggers.push_back(rInputTriggerName); + return true; +} + +boolean CDummyAlgoProto::addOutputTrigger(const CIdentifier& rOutputTriggerIdentifier,const CString& rOutputTriggerName) +{ + m_vOutputTriggers.push_back(rOutputTriggerName); + return true; +} + +//----------------------------------------------------------------------- +static void button_check_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonCheckCB(); +} +static void button_tooltip_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonTooltipCB(pButton); +} +static void button_ok_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonOkCB(); +} + +static void button_add_input_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonAddInputCB(); +} +static void button_remove_input_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonRemoveInputCB(); +} + +static void button_add_output_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonAddOutputCB(); +} +static void button_remove_output_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonRemoveOutputCB(); +} + +static void button_add_setting_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonAddSettingCB(); +} +static void button_remove_setting_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonRemoveSettingCB(); +} + +static void button_add_algorithm_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonAddAlgorithmCB(); +} +static void button_remove_algorithm_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonRemoveAlgorithmCB(); +} +static void algorithm_selected_cb(::GtkComboBox* pCombobox, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->algorithmSelectedCB(gtk_combo_box_get_active(pCombobox)); +} + +static void button_exit_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->buttonExitCB(); + ::gtk_exit(0); +} + +extern "C" G_MODULE_EXPORT void entry_modified_cb(::GtkWidget * pObject, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->forceRecheckCB(); +} +extern "C" G_MODULE_EXPORT void listener_checkbutton_toggled_cb(::GtkWidget * pObject, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->toggleListenerCheckbuttonsStateCB((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pObject))>0)); +} +extern "C" G_MODULE_EXPORT void processing_method_clock_toggled(::GtkWidget * pObject, void* pUserData) +{ + static_cast<CBoxAlgorithmSkeletonGenerator*>(pUserData)->toggleClockFrequencyStateCB((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pObject))>0)); +} +//----------------------------------------------------------------------- +void CBoxAlgorithmSkeletonGenerator::buttonExitCB(void) +{ + getCommonParameters(); + getCurrentParameters(); + cleanConfigurationFile(m_sConfigurationFile); + saveCommonParameters(m_sConfigurationFile); + save(m_sConfigurationFile); + + m_rKernelContext.getLogManager() << LogLevel_Info << "All entries saved in ["<< m_sConfigurationFile<<"]. Exiting.\n"; +} + +void CBoxAlgorithmSkeletonGenerator::forceRecheckCB(void) +{ + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + if(l_pButtonOk != NULL) gtk_widget_set_sensitive(l_pButtonOk,false); +} + +void CBoxAlgorithmSkeletonGenerator::toggleListenerCheckbuttonsStateCB(boolean bNewState) +{ + ::GtkWidget * l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-added-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-removed-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-type-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-name-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-connected-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-disconnected-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-added-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-removed-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-type-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-name-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-connected-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-disconnected-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-added-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-removed-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-type-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-name-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-default-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-value-checkbutton")); + gtk_widget_set_sensitive(l_pListenerWidget,bNewState); + +} + +void CBoxAlgorithmSkeletonGenerator::toggleClockFrequencyStateCB(boolean bNewState) +{ + ::GtkWidget * l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-frequency-spinbutton")); + gtk_widget_set_sensitive(l_pWidget,bNewState); +} +void CBoxAlgorithmSkeletonGenerator::buttonCheckCB(void) +{ + m_rKernelContext.getLogManager() << LogLevel_Info << "Extracting values... \n"; + //Author and Company + getCommonParameters(); + //Box generator entries + getCurrentParameters(); + + m_rKernelContext.getLogManager() << LogLevel_Info << "Checking values... \n"; + + boolean l_bSuccess = true; + + stringstream l_ssTextBuffer; + l_ssTextBuffer << "----- STATUS -----\n"; + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // Box Description + //-------------------------------------------------------------------------------------------------------------------------------------------// + if(string((const char *)m_sName) == "") + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- box name: INVALID (" << (const char *)m_sName << ")\n"; + l_ssTextBuffer << "[FAILED] No name found. Please provide a name for the box (all characters allowed).\n"; + } + else + { + //m_sName = ensureSedCompliancy(m_sName); + m_rKernelContext.getLogManager() << LogLevel_Info << "-- box name: VALID (" << (const char *)m_sName << ")\n"; + l_ssTextBuffer << "[ OK ] Valid box name.\n"; + } + + const boost::regex l_RegExpClassName("([a-z]|[A-Z])+([a-z]|[A-Z]|[0-9]|[_])*",boost::regex::perl); + if(boost::regex_match(string(m_sClassName),l_RegExpClassName) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- class name: INVALID (" << (const char *)m_sClassName << ")\n"; + l_ssTextBuffer << "[FAILED] Class name invalid. Please provide a class name using lower/upper case letters, numbers or underscores.\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- class name: VALID (" << (const char *)m_sClassName << ")\n"; + l_ssTextBuffer << "[ OK ] Valid class name.\n"; + } + + const boost::regex l_RegExpCategory("([a-z]|[A-Z])+([a-z]|[A-Z]|[ ]|[/])*",boost::regex::perl); + if(boost::regex_match(string(m_sCategory),l_RegExpCategory) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- category: INVALID (" << (const char *)m_sCategory << ")\n"; + l_ssTextBuffer << "[FAILED] Category invalid. Please provide a category using only letters and spaces (for sub-category, use '/' separator).\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- category: VALID (" << (const char *)m_sCategory << ")\n"; + l_ssTextBuffer << "[ OK ] Valid category.\n"; + } + + const boost::regex l_RegExpboxVersion("([0-9])+([a-z]|[A-Z]|[0-9]|[\\.])*",boost::regex::perl); + if(boost::regex_match(string(m_sVersion),l_RegExpboxVersion) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- box version: INVALID (" << (const char *)m_sVersion << ")\n"; + l_bSuccess = false; + l_ssTextBuffer << "[FAILED] Invalid box version (" << (const char *)m_sVersion << "). Please use a number followed by either numbers, letters or '.'\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- box version: VALID (" << (const char *)m_sVersion << ")\n"; + l_ssTextBuffer << "[ OK ] Valid box version.\n"; + } + + { + //m_sShortDescription = ensureSedCompliancy(m_sShortDescription); + m_rKernelContext.getLogManager() << LogLevel_Info << "-- short description: VALID (" << (const char *)m_sShortDescription << ")\n"; + l_ssTextBuffer << "[ OK ] Valid short description.\n"; + } + + if(((string)m_sDetailedDescription).length()<500) + { + //m_sDetailedDescription = ensureSedCompliancy(m_sDetailedDescription); + m_rKernelContext.getLogManager() << LogLevel_Info << "-- detailed description: VALID (" << (const char *)m_sDetailedDescription << ")\n"; + l_ssTextBuffer << "[ OK ] Valid detailed description.\n"; + } + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // Box INPUTS OUTPUTS and SETTINGS + //-------------------------------------------------------------------------------------------------------------------------------------------// + + //checking the inputs... + if(m_vInputs.size() != 0) + { + l_ssTextBuffer << "Checking inputs... \n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "-- checking inputs...\n"; + } + else + { + l_ssTextBuffer << "[----//----] No input specified.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "No input specified.\n"; + } + for(uint32 i = 0; i < m_vInputs.size(); i++) + { + if(string((const char *)(m_vInputs[i]._name)) == "" || string((const char *)(m_vInputs[i]._type)) == "") + { + m_rKernelContext.getLogManager() << LogLevel_Warning << " -- Input "<<i<<": [" << (const char *)m_vInputs[i]._name<<"],["<< (const char *)m_vInputs[i]._type << "] INVALID.\n"; + l_ssTextBuffer << ">>[FAILED] Invalid input "<<i<<". Please provide a name and a type for each input.\n"; + l_bSuccess = false; + } + else + { + m_vInputs[i]._name = ensureSedCompliancy(m_vInputs[i]._name); + m_rKernelContext.getLogManager() << LogLevel_Info << " -- Input "<<i<<": [" << (const char *)m_vInputs[i]._name<<"],["<< (const char *)m_vInputs[i]._type << "] VALID.\n"; + l_ssTextBuffer << ">>[ OK ] Valid input "<<i<<" [" << (const char *)m_vInputs[i]._name<<"]\n"; + } + } + + //checking the outputs... + if(m_vOutputs.size() != 0) + { + l_ssTextBuffer << "Checking outputs... \n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "-- checking outputs...\n"; + } + else + { + l_ssTextBuffer << "[----//----] No output specified.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "No output specified.\n"; + } + for(uint32 i = 0; i < m_vOutputs.size(); i++) + { + if(string((const char *)(m_vOutputs[i]._name)) == "" || string((const char *)(m_vOutputs[i]._type)) == "") + { + m_rKernelContext.getLogManager() << LogLevel_Warning << " -- Output "<<i<<": [" << (const char *)m_vOutputs[i]._name<<"],["<< (const char *)m_vOutputs[i]._type << "] INVALID.\n"; + l_ssTextBuffer << ">>[FAILED] Invalid output "<<i<<". Please provide a name and a type for each output.\n"; + l_bSuccess = false; + } + else + { + m_vOutputs[i]._name = ensureSedCompliancy(m_vOutputs[i]._name); + m_rKernelContext.getLogManager() << LogLevel_Info << " -- Output "<<i<<": [" << (const char *)m_vOutputs[i]._name<<"],["<< (const char *)m_vOutputs[i]._type << "] VALID.\n"; + l_ssTextBuffer << ">>[ OK ] Valid output "<<i<<" [" << (const char *)m_vOutputs[i]._name<<"]\n"; + } + } + + //checking the settings... + if(m_vSettings.size() != 0) + { + l_ssTextBuffer << "Checking settings... \n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "-- checking settings...\n"; + } + else + { + l_ssTextBuffer << "[----//----] No setting specified.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "No setting specified.\n"; + } + for(uint32 i = 0; i < m_vSettings.size(); i++) + { + if(string((const char *)(m_vSettings[i]._name)) == "" || string((const char *)(m_vSettings[i]._type)) == "") + { + m_rKernelContext.getLogManager() << LogLevel_Warning << " -- Setting "<<i<<": [" << (const char *)m_vSettings[i]._name<<"],["<< (const char *)m_vSettings[i]._type << "] INVALID.\n"; + l_ssTextBuffer << ">>[FAILED] Invalid setting "<<i<<". Please provide a name, a type and a default value for each setting.\n"; + l_bSuccess = false; + } + else + { + m_vSettings[i]._name = ensureSedCompliancy(m_vSettings[i]._name); + m_rKernelContext.getLogManager() << LogLevel_Info << " -- Setting "<<i<<": [" << (const char *)m_vSettings[i]._name<<"],["<< (const char *)m_vSettings[i]._type <<"],["<< (const char *)m_vSettings[i]._defaultValue << "] VALID.\n"; + l_ssTextBuffer << ">>[ OK ] Valid setting "<<i<<" [" << (const char *)m_vSettings[i]._name<<"]\n"; + } + } + + //checking the algorithms... + if(m_vAlgorithms.size() != 0) + { + l_ssTextBuffer << "Checking algorithm... \n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "-- checking algorithm...\n"; + } + else + { + l_ssTextBuffer << "[----//----] No algorithm specified.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "No algorithm specified.\n"; + } + for(uint32 i = 0; i < m_vAlgorithms.size(); i++) + { + m_rKernelContext.getLogManager() << LogLevel_Info << " -- Algorithm "<<i<<": [" << (const char *)m_vAlgorithms[i]<<"] VALID.\n"; + l_ssTextBuffer << ">>[ OK ] Valid algorithm "<<i<<" [" << (const char *)m_vAlgorithms[i]<<"]\n"; + } + + //-------------------------------------------------------------------------------------------------------------------------------------------// + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + if(l_bSuccess) + { + l_ssTextBuffer << "----- SUCCESS -----\nPress 'Generate!' to generate the files. If you want to modify your choice(s), please press the \"Check\" button again."; + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,true); + + } + else + { + l_ssTextBuffer << "----- PROCESS FAILED -----\nModify your choices and press the \"Check\" button again."; + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + + gtk_text_buffer_set_text (l_pTextBuffer,l_ssTextBuffer.str().c_str(), -1); + +} + +void CBoxAlgorithmSkeletonGenerator::buttonOkCB(void) +{ + m_rKernelContext.getLogManager() << LogLevel_Info << "Generating files... \n"; + CString l_sLogMessages = "Generating files...\n"; + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + + boolean l_bSuccess = true; + + // we ask for a target directory + ::GtkWidget* l_pWidgetDialogOpen=gtk_file_chooser_dialog_new( + "Select the destination folder", + NULL, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + + CString l_sTargetDirectory; + // if the user specified a target directory, it has full priority + l_sTargetDirectory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_TargetDirectory}"); + boolean l_bNeedFilePrefix = false; + if((string)l_sTargetDirectory != string("")) + { + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target dir user [" << l_sTargetDirectory << "]\n"; + l_bNeedFilePrefix = true; + } + else + { + //previous entry + l_sTargetDirectory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_TargetDirectory}"); + if((string)l_sTargetDirectory != string("")) + { + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target previous [" << l_sTargetDirectory << "]\n"; + l_bNeedFilePrefix = true; + } + else + { + //default path = dist + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target default [dist]\n"; +#ifdef TARGET_OS_Linux + l_sTargetDirectory = CString(gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(l_pWidgetDialogOpen))); + l_sTargetDirectory = l_sTargetDirectory + "/.."; +#elif defined TARGET_OS_Windows + l_sTargetDirectory = ".."; +#endif + } + } +#ifdef TARGET_OS_Linux + if(l_bNeedFilePrefix) l_sTargetDirectory = "file://"+l_sTargetDirectory; + gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(l_pWidgetDialogOpen),(const char *)l_sTargetDirectory); +#elif defined TARGET_OS_Windows + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen),(const char *)l_sTargetDirectory); +#endif + + + if(gtk_dialog_run(GTK_DIALOG(l_pWidgetDialogOpen))==GTK_RESPONSE_ACCEPT) + { + //char* l_sFileName=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen)); + char * l_pTargetDirectory = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen)); + m_sTargetDirectory = CString(l_pTargetDirectory); + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "User cancel. Aborting generation.\n"; + l_sLogMessages = l_sLogMessages + "User cancel. Aborting generation.\n"; + gtk_text_buffer_set_text(l_pTextBuffer,l_sLogMessages,-1); + gtk_widget_destroy(l_pWidgetDialogOpen); + return; + } + gtk_widget_destroy(l_pWidgetDialogOpen); + + CString l_sDate = getDate(); + + // construction of the namespace name from category + string l_sNamespace(m_sCategory); + for(uint32 s=0; s<l_sNamespace.length(); s++) + { + if(s == 0 && l_sNamespace[s] >= 'a' && l_sNamespace[s]<= 'z') + { + l_sNamespace.replace(s,1,1,(char)(l_sNamespace[s]+'A'-'a')); + } + boolean l_bErase = false; + while(s<l_sNamespace.length() && (l_sNamespace[s]==' ' || l_sNamespace[s]=='/')) + { + l_sNamespace.erase(s,1); + l_bErase = true; + } + if(l_bErase && s<l_sNamespace.length() && l_sNamespace[s] >= 'a' && l_sNamespace[s]<= 'z') + { + l_sNamespace.replace(s,1,1,(char)(l_sNamespace[s]+'A'-'a')); + } + } + + // generating some random identifiers + CString l_sClassIdentifier = getRandomIdentifierString(); + CString l_sDescriptorIdentifier = getRandomIdentifierString(); + + // replace tags in the allgorithm description + if(m_bUseCodecToolkit) + { + for(uint32 i = 0; i < m_vAlgorithms.size(); i++) + { + + string l_sAlgo = string((const char *)m_mAlgorithmHeaderDeclaration[m_vAlgorithms[i]]); + size_t it = l_sAlgo.find("@@ClassName@@"); + if(it != string::npos) + { + string l_sClass(m_sClassName); + l_sClass = "CBoxAlgorithm" + l_sClass; + l_sAlgo.replace(it,13, l_sClass); + m_mAlgorithmHeaderDeclaration[m_vAlgorithms[i]] = CString(l_sAlgo.c_str()); + } + } + } + + // we construct the map of substitutions + map<CString,CString> l_mSubstitutions; + l_mSubstitutions[CString("@@Author@@")] = m_sAuthor; + l_mSubstitutions[CString("@@Date@@")] = l_sDate; + l_mSubstitutions[CString("@@Company@@")] = m_sCompany; + l_mSubstitutions[CString("@@Date@@")] = l_sDate; + l_mSubstitutions[CString("@@BoxName@@")] = m_sName; + l_mSubstitutions[CString("@@ClassName@@")] = m_sClassName; + l_mSubstitutions[CString("@@RandomIdentifierClass@@")] = l_sClassIdentifier; + l_mSubstitutions[CString("@@RandomIdentifierDescriptor@@")] = l_sDescriptorIdentifier; + l_mSubstitutions[CString("@@ShortDescription@@")] = m_sShortDescription; + l_mSubstitutions[CString("@@DetailedDescription@@")] = m_sDetailedDescription; + l_mSubstitutions[CString("@@Category@@")] = m_sCategory; + l_mSubstitutions[CString("@@Namespace@@")] = CString(l_sNamespace.c_str()); + l_mSubstitutions[CString("@@Version@@")] = m_sVersion; + l_mSubstitutions[CString("@@StockItemName@@")] = m_sGtkStockItemName; + l_mSubstitutions[CString("@@InputFlagCanAdd@@")] = (m_bCanAddInputs ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddInput);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddInput);"); + l_mSubstitutions[CString("@@InputFlagCanModify@@")] = (m_bCanModifyInputs ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifyInput);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifyInput);"); + l_mSubstitutions[CString("@@OutputFlagCanAdd@@")] = (m_bCanAddOutputs ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddOutput);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddOutput);"); + l_mSubstitutions[CString("@@OutputFlagCanModify@@")] = (m_bCanModifyOutputs ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifyOutput);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifyOutput);"); + l_mSubstitutions[CString("@@SettingFlagCanAdd@@")] = (m_bCanAddSettings ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddSetting);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanAddSetting);"); + l_mSubstitutions[CString("@@SettingFlagCanModify@@")] = (m_bCanModifySettings ? "rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifySetting);" : "//rBoxAlgorithmPrototype.addFlag(OpenViBE::Kernel::BoxFlag_CanModifySetting);"); + l_mSubstitutions[CString("@@BoxListenerCommentIn@@")] = (m_bUseBoxListener ? "" : "/*"); + l_mSubstitutions[CString("@@BoxListenerCommentOut@@")] = (m_bUseBoxListener ? "" : "*/"); + l_mSubstitutions[CString("@@BoxListenerOnInputConnectedComment@@")] = (m_bBoxListenerOnInputConnected ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnInputDisconnectedComment@@")] = (m_bBoxListenerOnInputDisconnected ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnInputAddedComment@@")] = (m_bBoxListenerOnInputAdded ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnInputRemovedComment@@")] = (m_bBoxListenerOnInputRemoved ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnInputTypeChangedComment@@")] = (m_bBoxListenerOnInputTypeChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnInputNameChangedComment@@")] = (m_bBoxListenerOnInputNameChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputConnectedComment@@")] = (m_bBoxListenerOnOutputConnected ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputDisconnectedComment@@")] = (m_bBoxListenerOnOutputDisconnected ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputAddedComment@@")] = (m_bBoxListenerOnOutputAdded ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputRemovedComment@@")] = (m_bBoxListenerOnOutputRemoved ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputTypeChangedComment@@")] = (m_bBoxListenerOnOutputTypeChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnOutputNameChangedComment@@")] = (m_bBoxListenerOnOutputNameChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingAddedComment@@")] = (m_bBoxListenerOnSettingAdded ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingRemovedComment@@")] = (m_bBoxListenerOnSettingRemoved ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingTypeChangedComment@@")] = (m_bBoxListenerOnSettingTypeChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingNameChangedComment@@")] = (m_bBoxListenerOnSettingNameChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingDefaultValueChangedComment@@")] = (m_bBoxListenerOnSettingDefaultValueChanged ? "" : "//"); + l_mSubstitutions[CString("@@BoxListenerOnSettingValueChangedComment@@")] = (m_bBoxListenerOnSettingValueChanged ? "" : "//"); + l_mSubstitutions[CString("@@ProcessClockComment@@")] = (m_bProcessClock ? "" : "//"); + l_mSubstitutions[CString("@@ProcessInputComment@@")] = (m_bProcessInput ? "" : "//"); + l_mSubstitutions[CString("@@ProcessClockCommentIn@@")] = (m_bProcessClock ? "" : "/*"); + l_mSubstitutions[CString("@@ProcessInputCommentIn@@")] = (m_bProcessInput ? "" : "/*"); + stringstream ss; ss << m_ui32ClockFrequency << "LL<<32"; + l_mSubstitutions[CString("@@ClockFrequency@@")] = ss.str().c_str(); + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // box.h + CString l_sDest = m_sTargetDirectory + "/ovpCBoxAlgorithm" + m_sClassName + ".h"; + CString l_sTemplate(OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/box.h-skeleton"); + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + //-------------------------------------------------------------------------------------- + //Inputs + //-------------------------------------------------------------------------------------- + CString l_sCommandSed = "s/@@Inputs@@/"; + if(m_vInputs.empty()) l_sCommandSed = l_sCommandSed + "\\/\\/No input specified.To add inputs use :\\n\\/\\/rBoxAlgorithmPrototype.addInput(\\\"Input Name\\\",OV_TypeId_XXXX);\\n"; + for(vector<IOSStruct>::iterator it = m_vInputs.begin(); it != m_vInputs.end(); it++) + { + if(it != m_vInputs.begin()) + l_sCommandSed = l_sCommandSed + "\\t\\t\\t\\t"; + //add the CIdentifier corresponding to type + //l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addInput(\\\""+(*it)._name+"\\\", OpenViBE::Cidentifier"+(*it)._typeId+");\\n"; + //reconstruct the type_id + string l_sTypeName((const char *)(*it)._type); + for(uint32 s=0; s<l_sTypeName.length(); s++) + { + if(l_sTypeName[s]==' ') + { + l_sTypeName.erase(s,1); + if(l_sTypeName[s] >= 'a' && l_sTypeName[s]<= 'z') l_sTypeName.replace(s,1,1,(char)(l_sTypeName[s]+'A'-'a')); + } + } + l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addInput(\\\""+(*it)._name+"\\\",OV_TypeId_"+CString(l_sTypeName.c_str())+");\\n"; + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------- + //Outputs + //-------------------------------------------------------------------------------------- + l_sCommandSed = " s/@@Outputs@@/"; + if(m_vOutputs.empty()) l_sCommandSed = l_sCommandSed + "\\/\\/No output specified.To add outputs use :\\n\\/\\/rBoxAlgorithmPrototype.addOutput(\\\"Output Name\\\",OV_TypeId_XXXX);\\n"; + for(vector<IOSStruct>::iterator it = m_vOutputs.begin(); it != m_vOutputs.end(); it++) + { + if(it != m_vOutputs.begin()) + l_sCommandSed = l_sCommandSed + "\\t\\t\\t\\t"; + //add the CIdentifier corresponding to type + //l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addOutput(\\\""+(*it)._name+"\\\", OpenViBE::Cidentifier"+(*it)._typeId+");\\n"; + //reconstruct the type_id + string l_sTypeName((const char *)(*it)._type); + for(uint32 s=0; s<l_sTypeName.length(); s++) + { + if(l_sTypeName[s]==' ') + { + l_sTypeName.erase(s,1); + if(l_sTypeName[s] >= 'a' && l_sTypeName[s]<= 'z') l_sTypeName.replace(s,1,1,(char)(l_sTypeName[s]+'A'-'a')); + } + } + l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addOutput(\\\""+(*it)._name+"\\\",OV_TypeId_"+CString(l_sTypeName.c_str())+");\\n"; + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------- + //Settings + //-------------------------------------------------------------------------------------- + l_sCommandSed = "s/@@Settings@@/"; + if(m_vSettings.empty()) l_sCommandSed = l_sCommandSed + "\\/\\/No setting specified.To add settings use :\\n\\/\\/rBoxAlgorithmPrototype.addSetting(\\\"Setting Name\\\",OV_TypeId_XXXX,\\\"default value\\\");\\n"; + for(vector<IOSStruct>::iterator it = m_vSettings.begin(); it != m_vSettings.end(); it++) + { + if(it != m_vSettings.begin()) + l_sCommandSed = l_sCommandSed + "\\t\\t\\t\\t"; + //add the CIdentifier corresponding to type + //l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addSetting(\\\""+(*it)._name+"\\\", OpenViBE::Cidentifier"+(*it)._typeId+",\\\""+(*it)._defaultValue+"\\\");\\n"; + //reconstruct the type_id by erasing the spaces and upcasing the following letter + string l_sTypeName((const char *)(*it)._type); + for(uint32 s=0; s<l_sTypeName.length(); s++) + { + if(l_sTypeName[s]==' ') + { + l_sTypeName.erase(s,1); + if(l_sTypeName[s] >= 'a' && l_sTypeName[s]<= 'z') l_sTypeName.replace(s,1,1,(char)(l_sTypeName[s]+'A'-'a')); + } + } + l_sCommandSed = l_sCommandSed + "rBoxAlgorithmPrototype.addSetting(\\\""+(*it)._name+"\\\",OV_TypeId_"+CString(l_sTypeName.c_str())+",\\\""+(*it)._defaultValue+"\\\");\\n"; + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------- + //Codecs algorithms + //-------------------------------------------------------------------------------------- + l_sCommandSed = "s/@@Algorithms@@/"; + if(m_vAlgorithms.size() == 0) + { + l_sCommandSed = l_sCommandSed + "\\/\\/ No codec algorithms were specified in the skeleton-generator.\\n"; + } + else + { + l_sCommandSed = l_sCommandSed + "\\/\\/ Codec algorithms specified in the skeleton-generator:\\n"; + } + for(uint32 a=0; a<m_vAlgorithms.size(); a++) + { + /*if(a != 0) + l_sCommandSed = l_sCommandSed + "\\t\\t\\t"; +*/ + string l_sBlock = string((const char *)m_mAlgorithmHeaderDeclaration[m_vAlgorithms[a]]); + stringstream ss; ss << "Algo" << a << "_"; + string l_sUniqueMarker = ss.str(); + for(uint32 s=0; s<l_sBlock.length(); s++) + { + if(l_sBlock[s]=='@') + { + l_sBlock.erase(s,1); + l_sBlock.insert(s,l_sUniqueMarker); + } + } + l_sCommandSed = l_sCommandSed + CString(l_sBlock.c_str()); + } + + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // box.cpp + l_sDest = m_sTargetDirectory + "/ovpCBoxAlgorithm" + m_sClassName + ".cpp"; + if(m_bUseCodecToolkit) + { + l_sTemplate= OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/box.cpp-codec-toolkit-skeleton"; + } + else + { + l_sTemplate= OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/box.cpp-skeleton"; + } + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + + // Codec Algorithm stuff. too complicated for the simple SED primitives. + l_sCommandSed = "s/@@AlgorithmInitialisation@@/"; + for(uint32 a=0; a<m_vAlgorithms.size(); a++) + { + string l_sBlock = string((const char *)m_mAlgorithmInitialisation[m_vAlgorithms[a]]); + stringstream ss; ss << "Algo" << a << "_"; + string l_sUniqueMarker = ss.str(); + for(uint32 s=0; s<l_sBlock.length(); s++) + { + if(l_sBlock[s]=='@') + { + l_sBlock.erase(s,1); + l_sBlock.insert(s,l_sUniqueMarker); + } + } + l_sCommandSed = l_sCommandSed + CString(l_sBlock.c_str()); + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + l_sCommandSed = "s/@@AlgorithmInitialisationReferenceTargets@@/"; + if(m_bUseCodecToolkit) + { + l_sCommandSed = l_sCommandSed + "\\t\\/\\/ If you need to, you can manually set the reference targets to link the codecs input and output. To do so, you can use :\\n"; + l_sCommandSed = l_sCommandSed + "\\t\\/\\/m_oEncoder.getInputX().setReferenceTarget(m_oDecoder.getOutputX())\\n"; + l_sCommandSed = l_sCommandSed + "\\t\\/\\/ Where 'X' depends on the codec type. Please refer to the Codec Toolkit Reference Page\\n"; + l_sCommandSed = l_sCommandSed + "\\t\\/\\/ (http:\\/\\/openvibe.inria.fr\\/documentation\\/unstable\\/Doc_Tutorial_Developer_SignalProcessing_CodecToolkit_Ref.html) for a complete list.\\n"; + } + else + { + for(uint32 a=0; a<m_vAlgorithms.size(); a++) + { + string l_sBlock = string((const char *)m_mAlgorithmInitialisation_ReferenceTargets[m_vAlgorithms[a]]); + stringstream ss; ss << "Algo" << a << "_"; + string l_sUniqueMarker = ss.str(); + for(uint32 s=0; s<l_sBlock.length(); s++) + { + if(l_sBlock[s]=='@') + { + l_sBlock.erase(s,1); + l_sBlock.insert(s,l_sUniqueMarker); + } + } + l_sCommandSed = l_sCommandSed + CString(l_sBlock.c_str()); + } + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + + l_sCommandSed = "s/@@AlgorithmUninitialisation@@/"; + for(uint32 a=0; a<m_vAlgorithms.size(); a++) + { + string l_sBlock = string((const char *)m_mAlgorithmUninitialisation[m_vAlgorithms[a]]); + stringstream ss; ss << "Algo" << a << "_"; + string l_sUniqueMarker = ss.str(); + for(uint32 s=0; s<l_sBlock.length(); s++) + { + if(l_sBlock[s]=='@') + { + l_sBlock.erase(s,1); + l_sBlock.insert(s,l_sUniqueMarker); + } + } + l_sCommandSed = l_sCommandSed + CString(l_sBlock.c_str()); + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // readme-box.cpp + l_sDest = m_sTargetDirectory + "/README.txt"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/readme-box.txt-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + + //-------------------------------------------------------------------------------------------------------------------------------------------// + + if(l_bSuccess) + { + l_bSuccess&=cleanConfigurationFile(m_sConfigurationFile); + //re-load all entries, the internal variables may have been modified to be sed compliant. + getCommonParameters(); + getCurrentParameters(); + //save the entries as the user typed them + l_bSuccess&=saveCommonParameters(m_sConfigurationFile); + l_bSuccess&=save(m_sConfigurationFile); + } + + if(!l_bSuccess) + { + l_sLogMessages = l_sLogMessages + "Generation process did not completly succeed. Some files may have not been produced.\n"; + m_rKernelContext.getLogManager() << LogLevel_Warning << "Generation process did not completly succeed. Some files may have not been produced.\n"; + } + else + { + l_sLogMessages = l_sLogMessages + "Generation process successful. All entries saved in [" + m_sConfigurationFile + "]\n"; + l_sLogMessages = l_sLogMessages + "Please read file [README.txt] !\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "Generation process successful. All entries saved in [" << m_sConfigurationFile << "]\n"; + + // opening browser to see the produced files + CString l_sBrowser = m_rKernelContext.getConfigurationManager().expand("${Designer_WebBrowserCommand_${OperatingSystem}}"); + CString l_sBrowserCmd = l_sBrowser + " \"" + m_sTargetDirectory+"\""; + +#ifdef TARGET_OS_Windows + l_sBrowserCmd = l_sBrowser + " file:///"+ m_sTargetDirectory; //otherwise the browser does not find the directory (problem with / and \ char) +#endif + if(system((const char *)l_sBrowserCmd)) + { + } + } + + gtk_text_buffer_set_text(l_pTextBuffer,l_sLogMessages,-1); +} + +void CBoxAlgorithmSkeletonGenerator::buttonTooltipCB(::GtkButton* pButton) +{ + CString l_sTooltip = m_vTooltips[pButton]; + + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + gtk_text_buffer_set_text (l_pTextBuffer, (const char *) l_sTooltip, -1); +} + +void CBoxAlgorithmSkeletonGenerator::buttonAddInputCB(void) +{ + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-dialog")); + ::GtkWidget * l_pNameEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-name-entry")); + ::GtkWidget * l_pTypeCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-type-combobox")); + + gtk_entry_set_text(GTK_ENTRY(l_pNameEntry),""); + + gint resp = gtk_dialog_run(GTK_DIALOG(l_pDialog)); + + if(resp== GTK_RESPONSE_APPLY) + { + const gchar * l_sName = gtk_entry_get_text(GTK_ENTRY(l_pNameEntry)); + //we get the two types (user/ov) + GtkTreeIter l_iterType; + GtkTreeModel * l_treeModelType = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pTypeCombobox)); + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(l_pTypeCombobox),&l_iterType); + gchar* l_dataTypeUser; + gchar* l_dataTypeOv; + gtk_tree_model_get(l_treeModelType,&l_iterType,0,&l_dataTypeUser,1,&l_dataTypeOv,-1); + //const gchar * l_sType = gtk_combo_box_get_active_text(GTK_COMBO_BOX(l_pTypeCombobox)); + + ::GtkWidget * l_pInputTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-treeview")); + ::GtkTreeModel * l_pInputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pInputTreeView)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pInputListStore),&l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pInputListStore), &l_iter, 0, l_sName,1,l_dataTypeUser,2,l_dataTypeOv,-1); + gtk_widget_hide(l_pDialog); + + g_free(l_dataTypeUser);g_free(l_dataTypeOv); + + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + else + { + gtk_widget_hide(l_pDialog); + } + +} +void CBoxAlgorithmSkeletonGenerator::buttonRemoveInputCB(void) +{ + ::GtkWidget * l_pInputTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-treeview")); + ::GtkTreeModel * l_pInputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pInputTreeView)); + GtkTreeIter l_iter; + GtkTreeSelection *l_select; + l_select = gtk_tree_view_get_selection(GTK_TREE_VIEW(l_pInputTreeView)); + if(gtk_tree_selection_get_selected (l_select, &l_pInputListStore, &l_iter)) + { + gtk_list_store_remove(GTK_LIST_STORE(l_pInputListStore),&l_iter); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + +} + +void CBoxAlgorithmSkeletonGenerator::buttonAddOutputCB(void) +{ + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-dialog")); + ::GtkWidget * l_pNameEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-name-entry")); + ::GtkWidget * l_pTypeCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-type-combobox")); + + gtk_entry_set_text(GTK_ENTRY(l_pNameEntry),""); + + gint resp = gtk_dialog_run(GTK_DIALOG(l_pDialog)); + + if(resp== GTK_RESPONSE_APPLY) + { + const gchar * l_sName = gtk_entry_get_text(GTK_ENTRY(l_pNameEntry)); + //we get the two types (user/ov) + GtkTreeIter l_iterType; + GtkTreeModel * l_treeModelType = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pTypeCombobox)); + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(l_pTypeCombobox),&l_iterType); + gchar* l_dataTypeUser; + gchar* l_dataTypeOv; + gtk_tree_model_get(l_treeModelType,&l_iterType,0,&l_dataTypeUser,1,&l_dataTypeOv,-1); + //const gchar * l_sType = gtk_combo_box_get_active_text(GTK_COMBO_BOX(l_pTypeCombobox)); + + ::GtkWidget * l_pOutputTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-treeview")); + ::GtkTreeModel * l_pOutputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pOutputTreeView)); + GtkTreeIter l_iter; + + gtk_list_store_append(GTK_LIST_STORE(l_pOutputListStore),&l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pOutputListStore), &l_iter, 0, l_sName,1,l_dataTypeUser,2,l_dataTypeOv,-1); + gtk_widget_hide(l_pDialog); + + g_free(l_dataTypeUser);g_free(l_dataTypeOv); + + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + else + { + gtk_widget_hide(l_pDialog); + } +} +void CBoxAlgorithmSkeletonGenerator::buttonRemoveOutputCB(void) +{ + ::GtkWidget * l_pOutputTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-treeview")); + ::GtkTreeModel * l_pOutputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pOutputTreeView)); + GtkTreeIter l_iter; + GtkTreeSelection *l_select; + l_select = gtk_tree_view_get_selection(GTK_TREE_VIEW(l_pOutputTreeView)); + if(gtk_tree_selection_get_selected (l_select, &l_pOutputListStore, &l_iter)) + { + gtk_list_store_remove(GTK_LIST_STORE(l_pOutputListStore),&l_iter); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } +} + +void CBoxAlgorithmSkeletonGenerator::buttonAddSettingCB(void) +{ + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-dialog")); + ::GtkWidget * l_pNameEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-name-entry")); + ::GtkWidget * l_pTypeCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-type-combobox")); + ::GtkWidget * l_pValueEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-default-value-entry")); + + gtk_entry_set_text(GTK_ENTRY(l_pNameEntry),""); + gtk_entry_set_text(GTK_ENTRY(l_pValueEntry),""); + + gint resp = gtk_dialog_run(GTK_DIALOG(l_pDialog)); + + if(resp== GTK_RESPONSE_APPLY) + { + const gchar * l_sName = gtk_entry_get_text(GTK_ENTRY(l_pNameEntry)); + const gchar * l_sValue = gtk_entry_get_text(GTK_ENTRY(l_pValueEntry)); + //we get the two types (user/ov) + GtkTreeIter l_iterType; + GtkTreeModel * l_treeModelType = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pTypeCombobox)); + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(l_pTypeCombobox),&l_iterType); + gchar* l_dataTypeUser; + gchar* l_dataTypeOv; + gtk_tree_model_get(l_treeModelType,&l_iterType,0,&l_dataTypeUser,1,&l_dataTypeOv,-1); + //const gchar * l_sType = gtk_combo_box_get_active_text(GTK_COMBO_BOX(l_pTypeCombobox)); + + ::GtkWidget * l_pOutputTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-treeview")); + ::GtkTreeModel * l_pOutputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pOutputTreeView)); + GtkTreeIter l_iter; + + gtk_list_store_append(GTK_LIST_STORE(l_pOutputListStore),&l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pOutputListStore), &l_iter, 0, l_sName,1,l_dataTypeUser,2,l_sValue,3,l_dataTypeOv,-1); + gtk_widget_hide(l_pDialog); + + g_free(l_dataTypeUser);g_free(l_dataTypeOv); + + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + else + { + gtk_widget_hide(l_pDialog); + } +} +void CBoxAlgorithmSkeletonGenerator::buttonRemoveSettingCB(void) +{ + ::GtkWidget * l_pSettingTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-treeview")); + ::GtkTreeModel * l_pSettingListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pSettingTreeView)); + GtkTreeIter l_iter; + GtkTreeSelection *l_select; + l_select = gtk_tree_view_get_selection(GTK_TREE_VIEW(l_pSettingTreeView)); + if(gtk_tree_selection_get_selected (l_select, &l_pSettingListStore, &l_iter)) + { + gtk_list_store_remove(GTK_LIST_STORE(l_pSettingListStore),&l_iter); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } +} + +void CBoxAlgorithmSkeletonGenerator::buttonAddAlgorithmCB(void) +{ + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-dialog")); + ::GtkWidget * l_pAlgoCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-combobox")); + + ::GtkWidget * l_pAlgoInputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-inputs-treeview")); + ::GtkTreeModel * l_pAlgoInputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputsTreeView)); + ::GtkWidget * l_pAlgoOutputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-outputs-treeview")); + ::GtkTreeModel * l_pAlgoOutputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputsTreeView)); + ::GtkWidget * l_pAlgoInputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-input-triggers-treeview")); + ::GtkTreeModel * l_pAlgoInputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputTriggersTreeView)); + ::GtkWidget * l_pAlgoOutputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-output-triggers-treeview")); + ::GtkTreeModel * l_pAlgoOutputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputTriggersTreeView)); + + ::GtkWidget * l_pAlgoCategoryEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-category-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoCategoryEntry),""); + ::GtkWidget * l_pAlgoShortEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-short-description-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoShortEntry),""); + ::GtkWidget * l_pAlgoDetailedTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-detailed-description-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pAlgoDetailedTextview)); + gtk_text_buffer_set_text(l_pTextBuffer,"",-1); + + + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoInputsListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoOutputsListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoInputTriggersListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoOutputTriggersListStore)); + gtk_combo_box_set_active(GTK_COMBO_BOX(l_pAlgoCombobox),-1); + + gint resp = gtk_dialog_run(GTK_DIALOG(l_pDialog)); + + if(resp== GTK_RESPONSE_APPLY) + { + const gchar * l_sAlgo = gtk_combo_box_get_active_text(GTK_COMBO_BOX(l_pAlgoCombobox)); + + ::GtkWidget * l_pAlgoTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-treeview")); + ::GtkTreeModel * l_pAlgoListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoTreeView)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoListStore),&l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pAlgoListStore), &l_iter, 0, l_sAlgo,-1); + gtk_widget_hide(l_pDialog); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + else + { + gtk_widget_hide(l_pDialog); + } + +} +void CBoxAlgorithmSkeletonGenerator::buttonRemoveAlgorithmCB(void) +{ + ::GtkWidget * l_pAlgoTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-treeview")); + ::GtkTreeModel * l_pAlgoListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoTreeView)); + GtkTreeIter l_iter; + GtkTreeSelection *l_select; + l_select = gtk_tree_view_get_selection(GTK_TREE_VIEW(l_pAlgoTreeView)); + if(gtk_tree_selection_get_selected (l_select, &l_pAlgoListStore, &l_iter)) + { + gtk_list_store_remove(GTK_LIST_STORE(l_pAlgoListStore),&l_iter); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } +} +void CBoxAlgorithmSkeletonGenerator::algorithmSelectedCB(int32 i32IndexSelected) +{ + ::GtkWidget * l_pAlgoInputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-inputs-treeview")); + ::GtkTreeModel * l_pAlgoInputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputsTreeView)); + ::GtkWidget * l_pAlgoOutputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-outputs-treeview")); + ::GtkTreeModel * l_pAlgoOutputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputsTreeView)); + ::GtkWidget * l_pAlgoInputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-input-triggers-treeview")); + ::GtkTreeModel * l_pAlgoInputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputTriggersTreeView)); + ::GtkWidget * l_pAlgoOutputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-output-triggers-treeview")); + ::GtkTreeModel * l_pAlgoOutputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputTriggersTreeView)); + + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoInputsListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoOutputsListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoInputTriggersListStore)); + gtk_list_store_clear(GTK_LIST_STORE(l_pAlgoOutputTriggersListStore)); + + ::GtkWidget * l_pAlgoCategoryEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-category-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoCategoryEntry),""); + ::GtkWidget * l_pAlgoShortEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-short-description-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoShortEntry),""); + ::GtkWidget * l_pAlgoDetailedTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-detailed-description-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pAlgoDetailedTextview)); + gtk_text_buffer_set_text(l_pTextBuffer,"",-1); + + if(i32IndexSelected != -1) + { + ::GtkWidget * l_pAlgoCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-combobox")); + ::GtkTreeModel * l_pAlgoListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pAlgoCombobox)); + ::GtkTreeIter l_iter; + gchar *l_sIdentifier; + gtk_tree_model_iter_nth_child(l_pAlgoListStore,&l_iter,NULL,i32IndexSelected); + gtk_tree_model_get(l_pAlgoListStore,&l_iter,1,&l_sIdentifier,-1); + CIdentifier l_identifier; + l_identifier.fromString(CString(l_sIdentifier)); + + //we need to create a dummy instance of the algorithm proto to know its input/output/triggers + const IPluginObjectDesc * l_pDesc = m_rKernelContext.getPluginManager().getPluginObjectDesc(l_identifier); + CDummyAlgoProto l_oDummyProto; + ((IAlgorithmDesc *)l_pDesc)->getAlgorithmPrototype(l_oDummyProto); + + //inputs of the algorithm + ::GtkWidget * l_pAlgoInputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-inputs-treeview")); + ::GtkTreeModel * l_pAlgoInputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputsTreeView)); + for(map<CString,EParameterType>::iterator i = l_oDummyProto.m_vInputs.begin(); i!=l_oDummyProto.m_vInputs.end(); i++) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoInputsListStore),&l_iter); + gtk_list_store_set(GTK_LIST_STORE(l_pAlgoInputsListStore), &l_iter, 0, (const char *)(*i).first,-1); + } + + //outputs of the algorithm + ::GtkWidget * l_pAlgoOutputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-outputs-treeview")); + ::GtkTreeModel * l_pAlgoOutputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputsTreeView)); + for(map<CString,EParameterType>::iterator i = l_oDummyProto.m_vOutputs.begin(); i!=l_oDummyProto.m_vOutputs.end(); i++) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoOutputsListStore),&l_iter); + gtk_list_store_set(GTK_LIST_STORE(l_pAlgoOutputsListStore), &l_iter, 0, (const char *)(*i).first,-1); + } + + //Input triggers of the algorithm + ::GtkWidget * l_pAlgoInputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-input-triggers-treeview")); + ::GtkTreeModel * l_pAlgoInputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoInputTriggersTreeView)); + for(uint32 i = 0; i<l_oDummyProto.m_vInputTriggers.size(); i++) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoInputTriggersListStore),&l_iter); + gtk_list_store_set(GTK_LIST_STORE(l_pAlgoInputTriggersListStore), &l_iter, 0, (const char *)l_oDummyProto.m_vInputTriggers[i],-1); + } + //Output triggers of the algorithm + ::GtkWidget * l_pAlgoOutputTriggersTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-output-triggers-treeview")); + ::GtkTreeModel * l_pAlgoOutputTriggersListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoOutputTriggersTreeView)); + for(uint32 i = 0; i<l_oDummyProto.m_vOutputTriggers.size(); i++) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoOutputTriggersListStore),&l_iter); + gtk_list_store_set(GTK_LIST_STORE(l_pAlgoOutputTriggersListStore), &l_iter, 0, (const char *)l_oDummyProto.m_vOutputTriggers[i],-1); + } + + ::GtkWidget * l_pAlgoCategoryEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-category-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoCategoryEntry),(const char*)l_pDesc->getCategory()); + ::GtkWidget * l_pAlgoShortEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-short-description-entry")); + gtk_entry_set_text(GTK_ENTRY(l_pAlgoShortEntry),(const char*)l_pDesc->getShortDescription()); + ::GtkWidget * l_pAlgoDetailedTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-detailed-description-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pAlgoDetailedTextview)); + gtk_text_buffer_set_text(l_pTextBuffer,(const char*)l_pDesc->getDetailedDescription(),-1); + + } +} +//-------------------------------------------------------------------------- +CBoxAlgorithmSkeletonGenerator::CBoxAlgorithmSkeletonGenerator(IKernelContext & rKernelContext, ::GtkBuilder * pBuilderInterface) + :CSkeletonGenerator(rKernelContext, pBuilderInterface) +{ +} +CBoxAlgorithmSkeletonGenerator::~CBoxAlgorithmSkeletonGenerator(void) +{ +} + +OpenViBE::boolean CBoxAlgorithmSkeletonGenerator::initialize( void ) +{ + //random seed + srand((unsigned int)time(NULL)); + + ::GtkWidget * l_pBox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-window")); + + // Main Buttons and signals + ::GtkWidget * l_pButtonCheck = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-check-button")); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + + g_signal_connect(l_pButtonCheck, "pressed",G_CALLBACK(button_check_cb), this); + g_signal_connect(l_pButtonOk, "pressed",G_CALLBACK(button_ok_cb), this); + + //connect all the signals in the .ui file (entry_modified_cb) + gtk_builder_connect_signals(m_pBuilderInterface, this); + + // Tooltips buttons and signal + ::GtkButton * l_pTooltipButton_nameVersion = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-name-version-tooltip-button")); + ::GtkButton * l_pTooltipButton_category = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-category-tooltip-button")); + ::GtkButton * l_pTooltipButton_description = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-description-tooltip-button")); + ::GtkButton * l_pTooltipButton_icon = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-icon-tooltip-button")); + ::GtkButton * l_pTooltipButton_inputs = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-list-tooltip-button")); + ::GtkButton * l_pTooltipButton_inputs_modify = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-modify-tooltip-button")); + ::GtkButton * l_pTooltipButton_inputs_addRemove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-add-tooltip-button")); + ::GtkButton * l_pTooltipButton_outputs = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-list-tooltip-button")); + ::GtkButton * l_pTooltipButton_outputs_modify = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-modify-tooltip-button")); + ::GtkButton * l_pTooltipButton_outputs_addRemove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-add-tooltip-button")); + ::GtkButton * l_pTooltipButton_settings = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-list-tooltip-button")); + ::GtkButton * l_pTooltipButton_settings_modify = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-modify-tooltip-button")); + ::GtkButton * l_pTooltipButton_settings_addRemove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-tooltip-button")); + ::GtkButton * l_pTooltipButton_algorithms = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-tooltip-button")); + ::GtkButton * l_pTooltipButton_className = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-class-name-tooltip-button")); + ::GtkButton * l_pTooltipButton_UseCodecToolkit = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-toolkit-tooltip-button")); + ::GtkButton * l_pTooltipButton_BoxListener = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-tooltip-button")); + + m_vTooltips[l_pTooltipButton_nameVersion] = CString("Box Name: \nThis name will be the one displayed in the Designer.\nUsually, the box name reflects its main purpose.\nIf your box relies on GPL licensed libraries such as IT++, please precise it in the name.\nPlease also enter a version number for your box.\nAuthorized characters: letters (lower and upper case), numbers, special characters '()[]._-'\n------\nExample: Clock Stimulator (tic tac), version 1.2"); + m_vTooltips[l_pTooltipButton_category] = CString("Category: \nThe category decides where the box will be strored in designer's box panel.\nYou can refer to an existing category, already used in the designer, or choose a new one.\nIf you need to specifiy a subcategory, use the character '/'.\nAuthorized characters: letters (lower and upper case) and spaces.\n------\nExample: Samples/Seleton Generator\n"); + m_vTooltips[l_pTooltipButton_description] = CString("Description: \nThe short description will be displayed next to the box in the designer box panel.\nThe detailed description is showed on the 'About Box...' panel.\nAll characters are authorized.\n------\nExample:\nShort Description : Periodic stimulation generator\nDetailed description : This box triggers stimulation at fixed frequency."); + m_vTooltips[l_pTooltipButton_icon] = CString("Box Icon: \nThe icon used in the designer box panel for this box.\nThis is an optionnal field.\n------\nExample: 'gtk-help' will be the corresponding gtk stock item (depending on the gtk theme used)\n\n\n"); + m_vTooltips[l_pTooltipButton_inputs] = CString("Inputs: \nUse the 'Add' and 'Remove' buttons to set all the inputs your box will have.\nWhen pressing 'Add' a dialog window will appear to know the name and type of the new input.\n------\nExample:\n'Incoming Signal' of type 'Signal'\n\n"); + m_vTooltips[l_pTooltipButton_inputs_modify] = CString("Modify: \nCheck this option if the input(s) of your box can be modified (type and name) in the Designer by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanModifyInput'.\n\n\n\n\n"); + m_vTooltips[l_pTooltipButton_inputs_addRemove] = CString("Add/Remove: \nCheck this option if the user must be able to add (or remove) inputs, by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanAddInput'.\n\n\n\n"); + m_vTooltips[l_pTooltipButton_outputs] = CString("Outputs: \nUse the 'Add' and 'Remove' buttons to set all the outputs your box will have.\nWhen pressing 'Add' a dialog window will appear to know the name and type of the new output.\n------\nExample:\n'Filtered Signal' of type 'Signal'\n\n"); + m_vTooltips[l_pTooltipButton_outputs_modify] = CString("Modify: \nCheck this option if the output(s) of your box can be modified (type and name) in the Designer by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanModifyOutput'.\n\n\n\n\n"); + m_vTooltips[l_pTooltipButton_outputs_addRemove] = CString("Add/Remove: \nCheck this option if the user must be able to add (or remove) outputs, by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanAddOutput'.\n\n\n\n"); + m_vTooltips[l_pTooltipButton_settings] = CString("Settings: \nUse the 'Add' and 'Remove' buttons to set all the settings your box will have.\nWhen pressing 'Add' a dialog window will appear to know the name,type and default value of the new output.\n------\nExample:\n'Filter order' of type 'int' with default value '4'\n\n"); + m_vTooltips[l_pTooltipButton_settings_modify] = CString("Modify: \nCheck this option if the setting(s) of your box can be modified (type and name) in the Designer by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanModifySetting'.\n\n\n\n\n"); + m_vTooltips[l_pTooltipButton_settings_addRemove] = CString("Add/Remove: \nCheck this option if the user must be able to add (or remove) settings, by right-clicking the box.\nIn the implementation, this option decides whether or not the box will have the flag 'BoxFlag_CanAddSetting'.\n\n\n\n"); + m_vTooltips[l_pTooltipButton_algorithms] = CString("Codec Algorithms: \nChoose the decoder(s) and encoder(s) used by the box. \nYou can choose between all the different stream codecs currently in OpenViBE.\nWhen choosing a codec, the dialog window will display the algorithm inputs and outputs that can be retrieve through getter methods. \n------\nExample: Signal Decoder, that outputs a Streamed Matrix and a Sampling Frequency value from a Memory Buffer.\n\n"); + m_vTooltips[l_pTooltipButton_className] = CString("Class Name: \nThis name will be used in the code to build the class name.\nUsually, the class name is close to the box name, just without any blank.\nIf your box relies on GPL licensed libraries such as IT++, please precise it in the class name with the postfix 'GPL'.\nAuthorized characters: letters (lower and upper case), numbers, NO special characters, NO blank.\n------\nExample: ClockStimulator\n"); + m_vTooltips[l_pTooltipButton_UseCodecToolkit] = CString("Codec Toolkit: \nTells the generator to use or not the Codec Toolkit in the box implementation. \nThe Codec Toolkit makes the decoding and encoding process much more simpler, and is highly advised.\n\n\n\n\n"); + m_vTooltips[l_pTooltipButton_BoxListener] = CString("Box Listener: \nImplement or not a box listener class in the header.\nA box listener has various callbacks that you can overwrite, related to any modification of the box structure.\n------\nExample:\nThe Identity box uses a box listener with 2 callbacks: 'onInputAdded' and 'onOutputAdded'.\nWhenever an input (output) is added, the listener automatically add an output (input) of the same type.\n"); + + g_signal_connect(l_pTooltipButton_nameVersion, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_category, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_description, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_icon, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_inputs, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_inputs_modify, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_inputs_addRemove, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_outputs, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_outputs_modify, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_outputs_addRemove, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_settings, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_settings_modify, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_settings_addRemove, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_algorithms, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_className, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_UseCodecToolkit, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_BoxListener, "pressed",G_CALLBACK(button_tooltip_cb), this); + + //'Inputs' buttons + ::GtkButton * l_pInputsButton_add = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-add-button")); + ::GtkButton * l_pInputsButton_remove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-remove-button")); + + g_signal_connect(l_pInputsButton_add, "pressed",G_CALLBACK(button_add_input_cb), this); + g_signal_connect(l_pInputsButton_remove, "pressed",G_CALLBACK(button_remove_input_cb), this); + + //'outputs' buttons + ::GtkButton * l_pOutputsButton_add = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-add-button")); + ::GtkButton * l_pOutputsButton_remove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-remove-button")); + + g_signal_connect(l_pOutputsButton_add, "pressed",G_CALLBACK(button_add_output_cb), this); + g_signal_connect(l_pOutputsButton_remove, "pressed",G_CALLBACK(button_remove_output_cb), this); + + //'settings' buttons + ::GtkButton * l_pSettingsButton_add = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-button")); + ::GtkButton * l_pSettingsButton_remove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-remove-button")); + + g_signal_connect(l_pSettingsButton_add, "pressed",G_CALLBACK(button_add_setting_cb), this); + g_signal_connect(l_pSettingsButton_remove, "pressed",G_CALLBACK(button_remove_setting_cb), this); + + //'algos' buttons + ::GtkButton * l_pAlgorithmsButton_add = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-button")); + ::GtkButton * l_pAlgorithmsButton_remove = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-remove-button")); + + g_signal_connect(l_pAlgorithmsButton_add, "pressed",G_CALLBACK(button_add_algorithm_cb), this); + g_signal_connect(l_pAlgorithmsButton_remove, "pressed",G_CALLBACK(button_remove_algorithm_cb), this); + + //Add IO dialog buttons + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-dialog")); + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY); + + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + + //Add Setting dialog buttons + l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-dialog")); + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY); + + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + + //Add Algo dialog buttons + l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-dialog")); + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY); + + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + + //initialize the icon combo box with gtk stock items + ::GtkWidget * l_pIconCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-icon-combobox")); + ::GtkTreeModel * l_pIconListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pIconCombobox)); + ::GSList * l_StockIdList = gtk_stock_list_ids(); + while(l_StockIdList->next!=NULL) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pIconListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pIconListStore), &l_iter, 0, (char *)l_StockIdList->data,1,(char *)l_StockIdList->data,-1); + l_StockIdList = g_slist_next(l_StockIdList); + } + g_slist_free(l_StockIdList); + + //types when adding IOS + ::GtkWidget * l_pTypeCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-IO-add-type-combobox")); + ::GtkTreeModel * l_pTypeListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pTypeCombobox)); + ::GtkWidget * l_pSettingTypeCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-type-combobox")); + ::GtkTreeModel * l_pSettingTypeListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pSettingTypeCombobox)); + //we iterate over all identifiers + CIdentifier l_Identifier = m_rKernelContext.getTypeManager().getNextTypeIdentifier(OV_UndefinedIdentifier); + while(l_Identifier != OV_UndefinedIdentifier) + { + CString l_sType = m_rKernelContext.getTypeManager().getTypeName(l_Identifier); + CString l_sTypeId = l_Identifier.toString(); + //Streams are possible inputs and outputs + if(m_rKernelContext.getTypeManager().isStream(l_Identifier)) + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pTypeListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pTypeListStore), &l_iter, 0, (const char *)l_sType,1,(const char *)l_sTypeId,-1); + } + else // other types are possible settings + { + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pSettingTypeListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pSettingTypeListStore), &l_iter, 0, (const char *)l_sType,1,(const char *)l_sTypeId,-1); + } + l_Identifier = m_rKernelContext.getTypeManager().getNextTypeIdentifier(l_Identifier); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(l_pTypeCombobox),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(l_pSettingTypeCombobox),0); + //types when adding Algorithms + m_vParameterType_EnumTypeCorrespondance.resize(ParameterType_Pointer+1); + m_vParameterType_EnumTypeCorrespondance[ParameterType_None] = "TYPE-NOT-AVAILABLE"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Integer] = "OpenViBE::int64"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_UInteger] = "OpenViBE::uint64"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Enumeration] = "ENUMERATION-NOT-AVAILABLE"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Boolean] = "OpenViBE::boolean"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Float] = "OpenViBE::float64"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_String] = "OpenViBE::CString"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Identifier] = "OpenViBE::CIdentifier"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Matrix] = "OpenViBE::IMatrix *"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_StimulationSet] = "OpenViBE::IStimulationSet *"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_MemoryBuffer] = "OpenViBE::IMemoryBuffer *"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Object] = "OpenViBE::IObject *"; + m_vParameterType_EnumTypeCorrespondance[ParameterType_Pointer] = "OpenViBE::uint8*"; + + + // CODECS INITIALISATION: + ::GtkWidget * l_pCodecCheckbutton = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-toolkit-checkbutton")); + m_bUseCodecToolkit = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCodecCheckbutton))>0); + + ::GtkWidget * l_pAlgoCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-add-combobox")); + ::GtkTreeModel * l_pAlgoListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pAlgoCombobox)); + //we iterate over all plugin descriptor identifiers + l_Identifier = m_rKernelContext.getPluginManager().getNextPluginObjectDescIdentifier(OV_UndefinedIdentifier); + while(l_Identifier != OV_UndefinedIdentifier) + { + const IPluginObjectDesc * l_pDesc = m_rKernelContext.getPluginManager().getPluginObjectDesc(l_Identifier); + if(l_pDesc != NULL && l_pDesc->isDerivedFromClass(OV_ClassId_Plugins_AlgorithmDesc)) // we select only algorithm descriptors + { + CString l_sAlgo = l_pDesc->getName(); + string l_sTest((const char *) l_sAlgo); + + // we only keep decoders and encoders + // and reject the master acquisition stream + if((l_sTest.find("encoder")!=string::npos || l_sTest.find("decoder")!=string::npos) && l_sTest.find("Master")==string::npos) + { + CString l_sAlgoID = l_Identifier.toString(); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pAlgoListStore), &l_iter, 0, (const char *)l_sAlgo,1,(const char *)l_sAlgoID,-1); + + // now we map every decoder/encoder to its string description that will be added in the skeleton (algorithmProxy + parameter handlers for I/O) + CString l_sHeaderDeclaration ="\\t\\t\\t\\/\\/ "+ l_sAlgo +"\\n"; + CString l_sInitialisation ="\\t\\/\\/ "+ l_sAlgo +"\\n"; + CString l_sInitialisation_ReferenceTargets; + CString l_sUninitialisation; + + + //we need to create a dummy instance of the algorithm proto to know its input/output/triggers + const IPluginObjectDesc * l_pDesc = m_rKernelContext.getPluginManager().getPluginObjectDesc(l_Identifier); + CDummyAlgoProto l_oDummyProto; + ((IAlgorithmDesc *)l_pDesc)->getAlgorithmPrototype(l_oDummyProto); + //algorithm proxy + string l_sAlgoNameStdSTr((const char *)l_sAlgo); + for(uint32 s=0; s<l_sAlgoNameStdSTr.length(); s++) + { + if(l_sAlgoNameStdSTr[s]==' ') + { + l_sAlgoNameStdSTr.erase(s,1); + if(l_sAlgoNameStdSTr[s] >= 'a' && l_sAlgoNameStdSTr[s]<= 'z') l_sAlgoNameStdSTr.replace(s,1,1,(char)(l_sAlgoNameStdSTr[s]+'A'-'a')); + } + } + string l_sCodecTypeStdStr = l_sAlgoNameStdSTr; + string l_sStream("Stream"); + l_sCodecTypeStdStr.erase(l_sCodecTypeStdStr.rfind(l_sStream),6); + + CString l_sAlgorithmProxy = "m_p@" + CString(l_sAlgoNameStdSTr.c_str()); + CString l_sCodec = "m_o@" + CString(l_sCodecTypeStdStr.c_str()); + CString l_sCodecType = CString(l_sCodecTypeStdStr.c_str()); + + if(! m_bUseCodecToolkit) + { + l_sInitialisation_ReferenceTargets = "\\t\\/\\/"+ l_sAlgo +" Reference Targets :\\n"; + l_sHeaderDeclaration = l_sHeaderDeclaration + "\\t\\t\\tOpenViBE::Kernel::IAlgorithmProxy* "+ l_sAlgorithmProxy +";\\n"; + l_sInitialisation = l_sInitialisation + "\\t" + + l_sAlgorithmProxy +" = \\&this->getAlgorithmManager().getAlgorithm(this->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_"+CString(l_sAlgoNameStdSTr.c_str())+"));\\n" + + "\\t"+ l_sAlgorithmProxy +"->initialize();\\n"; + l_sUninitialisation = "\\tthis->getAlgorithmManager().releaseAlgorithm(*"+l_sAlgorithmProxy+");\\n" + l_sUninitialisation; + //inputs of the algorithm + for(map<CString,EParameterType>::iterator it = l_oDummyProto.m_vInputs.begin(); it!=l_oDummyProto.m_vInputs.end(); it++) + { + string l_sInputNameStdSTr((const char *)(*it).first); + for(uint32 s=0; s<l_sInputNameStdSTr.length(); s++) + { + if(l_sInputNameStdSTr[s]==' ') + { + l_sInputNameStdSTr.erase(s,1); + if(l_sInputNameStdSTr[s] >= 'a' && l_sInputNameStdSTr[s]<= 'z') l_sInputNameStdSTr.replace(s,1,1,(char)(l_sInputNameStdSTr[s]+'A'-'a')); + } + } + CString l_sInputHandler ="ip_p@"+ CString(l_sInputNameStdSTr.c_str()); + // input handlers for pointer must be "const" + CString l_sConst = ""; + if(l_oDummyProto.m_vInputs[(*it).first] >= ParameterType_Matrix) + { + l_sConst = "const "; + } + l_sHeaderDeclaration = l_sHeaderDeclaration + "\\t\\t\\tOpenViBE::Kernel::TParameterHandler < " + l_sConst + (const char *)m_vParameterType_EnumTypeCorrespondance[l_oDummyProto.m_vInputs[(*it).first]] + "> "+ l_sInputHandler +";\\n"; + l_sInitialisation = l_sInitialisation + "\\t" + + l_sInputHandler + ".initialize("+ l_sAlgorithmProxy +"->getInputParameter(OVP_GD_Algorithm_"+CString(l_sAlgoNameStdSTr.c_str())+"_InputParameterId_"+CString(l_sInputNameStdSTr.c_str())+"));\\n"; + l_sInitialisation_ReferenceTargets = l_sInitialisation_ReferenceTargets + "\\t\\/\\/"+l_sInputHandler +".setReferenceTarget( ... )\\n"; + l_sUninitialisation = "\\t"+l_sInputHandler+ ".uninitialize();\\n" + l_sUninitialisation; + } + //outputs of the algorithm + for(map<CString,EParameterType>::iterator it = l_oDummyProto.m_vOutputs.begin(); it!=l_oDummyProto.m_vOutputs.end(); it++) + { + string l_sOutputNameStdSTr((const char *)(*it).first); + for(uint32 s=0; s<l_sOutputNameStdSTr.length(); s++) + { + if(l_sOutputNameStdSTr[s]==' ') + { + l_sOutputNameStdSTr.erase(s,1); + if(l_sOutputNameStdSTr[s] >= 'a' && l_sOutputNameStdSTr[s]<= 'z') l_sOutputNameStdSTr.replace(s,1,1,(char)(l_sOutputNameStdSTr[s]+'A'-'a')); + } + } + CString l_sOutputHandler ="op_p@"+ CString(l_sOutputNameStdSTr.c_str()); + l_sHeaderDeclaration = l_sHeaderDeclaration + "\\t\\t\\tOpenViBE::Kernel::TParameterHandler < " + (const char *)m_vParameterType_EnumTypeCorrespondance[l_oDummyProto.m_vOutputs[(*it).first]] + "> "+ l_sOutputHandler +";\\n"; + l_sInitialisation = l_sInitialisation + "\\t" + + l_sOutputHandler+ ".initialize("+ l_sAlgorithmProxy +"->getOutputParameter(OVP_GD_Algorithm_"+CString(l_sAlgoNameStdSTr.c_str())+"_OutputParameterId_"+CString(l_sOutputNameStdSTr.c_str())+"));\\n"; + l_sUninitialisation = "\\t"+ l_sOutputHandler+ ".uninitialize();\\n" + l_sUninitialisation; + } + l_sHeaderDeclaration = l_sHeaderDeclaration + "\\n"; + l_sInitialisation = l_sInitialisation + "\\n"; + l_sInitialisation_ReferenceTargets = l_sInitialisation_ReferenceTargets + "\\n"; + l_sUninitialisation ="\\t\\/\\/ "+ l_sAlgo +"\\n" + l_sUninitialisation + "\\t"+l_sAlgorithmProxy+" = NULL;\\n\\n"; + } + else // use the Codec Toolkit + { + l_sHeaderDeclaration = l_sHeaderDeclaration + "\\t\\t\\tOpenViBEToolkit::T"+ l_sCodecType + " < @@ClassName@@ > " + l_sCodec +";\\n"; + l_sInitialisation = l_sInitialisation + "\\t" + l_sCodec + ".initialize(*this);\\n"; + l_sUninitialisation = "\\t" + l_sCodec + ".uninitialize();\\n" + l_sUninitialisation; + l_sInitialisation_ReferenceTargets = ""; + //l_sInitialisation_ReferenceTargets = l_sInitialisation_ReferenceTargets + "\\t\\/\\/ If you need to, you can manually set the reference targets to link the codecs input and output. To do so, you can use :\n"; + //l_sInitialisation_ReferenceTargets = l_sInitialisation_ReferenceTargets + "\\t\\/\\/"+l_sCodec + ".getInputX().setReferenceTarget( ... )\\n"; + } + m_mAlgorithmHeaderDeclaration[l_sAlgo] = l_sHeaderDeclaration; + m_mAlgorithmInitialisation[l_sAlgo] = l_sInitialisation; + m_mAlgorithmUninitialisation[l_sAlgo] = l_sUninitialisation; + m_mAlgorithmInitialisation_ReferenceTargets[l_sAlgo] = l_sInitialisation_ReferenceTargets; + m_rKernelContext.getLogManager() << LogLevel_Debug << "The algorithm [" << l_sAlgo << "] has description [" << l_sHeaderDeclaration << "\n"; + } + } + l_Identifier =m_rKernelContext.getPluginManager().getNextPluginObjectDescIdentifier(l_Identifier); + } + + + + gtk_combo_box_set_active(GTK_COMBO_BOX(l_pAlgoCombobox),-1); + //callback to update algo description + g_signal_connect(G_OBJECT(l_pAlgoCombobox),"changed", G_CALLBACK(algorithm_selected_cb),this); + + //Close with X and "cancel" button + g_signal_connect (G_OBJECT(l_pBox),"delete_event",G_CALLBACK(::gtk_exit),0); + ::GtkWidget * l_pButtonCancel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-exit-button")); + g_signal_connect(l_pButtonCancel,"pressed", G_CALLBACK(button_exit_cb), this); + + //load everything from config file + load(m_sConfigurationFile); + ::GtkWidget * l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-checkbutton")); + toggleListenerCheckbuttonsStateCB((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget))>0)); + + gtk_widget_show_all(l_pBox); + + return true; +} + +boolean CBoxAlgorithmSkeletonGenerator::save(CString sFileName) +{ + FILE* l_pFile=::fopen(sFileName.toASCIIString(), "ab"); + if(!l_pFile) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Saving the box entries in [" << sFileName << "] failed !\n"; + return false; + } + ::fprintf(l_pFile, "# ----------------------BOX GENERATOR-------------------------\n"); + // we need to replace the \ by / in the path for cross compatibility + string::iterator it_directory; + string l_sTempTargetDirectory(m_sTargetDirectory.toASCIIString()); + for(it_directory=l_sTempTargetDirectory.begin(); it_directory<l_sTempTargetDirectory.end(); it_directory++) + { + if((*it_directory)=='\\') + { + l_sTempTargetDirectory.replace(it_directory, it_directory+1, 1, '/'); + } + } + ::fprintf(l_pFile, "SkeletonGenerator_Box_TargetDirectory = %s\n", l_sTempTargetDirectory.c_str()); + + ::fprintf(l_pFile, "SkeletonGenerator_Box_Name = %s\n",(const char *)m_sName); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Version = %s\n",(const char *) m_sVersion); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Category = %s\n",(const char *)m_sCategory); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ClassName = %s\n",(const char *)m_sClassName); + + //we need to escape with '\' the special characters of the configuration manager files + string l_sTempShortDescr((const char *)m_sShortDescription); + l_sTempShortDescr.reserve(1000); // if we need to insert characters + string::iterator it_sdescr=l_sTempShortDescr.begin(); + while(it_sdescr<l_sTempShortDescr.end()) + { + //characters to escape + if((*it_sdescr)=='\\' || (*it_sdescr)=='=' || (*it_sdescr)=='$' || (*it_sdescr)=='\t') + { + l_sTempShortDescr.insert(it_sdescr, '\\'); + it_sdescr++; + } + it_sdescr++; + } + ::fprintf(l_pFile, "SkeletonGenerator_Box_ShortDescription = %s\n", l_sTempShortDescr.c_str()); + + //we need to escape with '\' the special characters of the configuration manager files + string l_sTempDetailedDescr((const char *)m_sDetailedDescription); + m_rKernelContext.getLogManager() << LogLevel_Debug << "SAVE > DESCRIPTION FROM WIDGET: "<<l_sTempDetailedDescr.c_str()<<"\n"; + l_sTempDetailedDescr.reserve(1000); // if we need to insert characters + string::iterator it_descr=l_sTempDetailedDescr.begin(); + while(it_descr<l_sTempDetailedDescr.end()) + { + //characters to escape + if((*it_descr)=='\\' || (*it_descr)=='=' || (*it_descr)=='$' || (*it_descr)=='\t') + { + l_sTempDetailedDescr.insert(it_descr, '\\'); + it_descr++; + } + //the special character we use for \n must also be escaped when used in the text + else if((*it_descr)=='@') + { + l_sTempDetailedDescr.insert(it_descr, '\\'); + l_sTempDetailedDescr.insert(it_descr, '\\'); + it_descr+=2; + } + //we add a special character @ representing a \n for further loading. the \ ensure that the config manager will read the token past the \n + else if((*it_descr)=='\n') + { + l_sTempDetailedDescr.insert(it_descr, '\\'); + l_sTempDetailedDescr.insert(it_descr, '@'); + it_descr+=2; + } + it_descr++; + } + m_rKernelContext.getLogManager() << LogLevel_Debug << "SAVE > DESCR MODIFIED: "<<l_sTempDetailedDescr.c_str()<<"\n"; + + ::fprintf(l_pFile, "SkeletonGenerator_Box_DetailedDescription = %s\n", (const char *) l_sTempDetailedDescr.c_str()); + + ::fprintf(l_pFile, "SkeletonGenerator_Box_IconIndex = %i\n",m_i32GtkStockItemIndex); + ::fprintf(l_pFile, "SkeletonGenerator_Box_IconName = %s\n",(const char *)m_sGtkStockItemName); + + // ADD/MODIFY FLAGS + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanModifyInputs = %s\n",(m_bCanModifyInputs?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanAddInputs = %s\n",(m_bCanAddInputs?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanModifyOutputs = %s\n",(m_bCanModifyOutputs?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanAddOutputs = %s\n",(m_bCanModifyOutputs?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanModifySettings = %s\n",(m_bCanModifySettings?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_CanAddSettings = %s\n",(m_bCanAddSettings?"TRUE":"FALSE")); + + // Inputs + ::fprintf(l_pFile, "SkeletonGenerator_Box_InputCount = %lu\n",(unsigned long int)m_vInputs.size()); + for(uint32 i = 0; i < m_vInputs.size(); i++) + { + ::fprintf(l_pFile, "SkeletonGenerator_Box_Input%i_Name = %s\n",i,(const char *)m_vInputs[i]._name); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Input%i_Type = %s\n",i,(const char *)m_vInputs[i]._type); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Input%i_TypeId = %s\n",i,(const char *)m_vInputs[i]._typeId); + } + // Outputs + ::fprintf(l_pFile, "SkeletonGenerator_Box_OutputCount = %lu\n",(unsigned long int)m_vOutputs.size()); + for(uint32 i = 0; i < m_vOutputs.size(); i++) + { + ::fprintf(l_pFile, "SkeletonGenerator_Box_Output%i_Name = %s\n",i,(const char *)m_vOutputs[i]._name); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Output%i_Type = %s\n",i,(const char *)m_vOutputs[i]._type); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Output%i_TypeId = %s\n",i,(const char *)m_vOutputs[i]._typeId); + } + // Inputs + ::fprintf(l_pFile, "SkeletonGenerator_Box_SettingCount = %lu\n",(unsigned long int)m_vSettings.size()); + for(uint32 i = 0; i < m_vSettings.size(); i++) + { + ::fprintf(l_pFile, "SkeletonGenerator_Box_Setting%i_Name = %s\n",i,(const char *)m_vSettings[i]._name); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Setting%i_Type = %s\n",i,(const char *)m_vSettings[i]._type); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Setting%i_TypeId = %s\n",i,(const char *)m_vSettings[i]._typeId); + ::fprintf(l_pFile, "SkeletonGenerator_Box_Setting%i_DefaultValue = %s\n",i,(const char *)m_vSettings[i]._defaultValue); + } + // Algorithms + ::fprintf(l_pFile, "SkeletonGenerator_Box_AlgorithmCount = %lu\n",(unsigned long int)m_vAlgorithms.size()); + for(uint32 i = 0; i < m_vAlgorithms.size(); i++) + { + ::fprintf(l_pFile, "SkeletonGenerator_Box_Algorithm%i_Name = %s\n",i,(const char *)m_vAlgorithms[i]); + } + + // Listener + ::fprintf(l_pFile, "SkeletonGenerator_Box_UseListener = %s\n",(m_bUseBoxListener?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputAdded = %s\n",(m_bBoxListenerOnInputAdded?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputRemoved = %s\n",(m_bBoxListenerOnInputRemoved?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputTypeChanged = %s\n",(m_bBoxListenerOnInputTypeChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputNameChanged = %s\n",(m_bBoxListenerOnInputNameChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputConnected = %s\n",(m_bBoxListenerOnInputConnected?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnInputDisconnected = %s\n",(m_bBoxListenerOnInputDisconnected?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputAdded = %s\n",(m_bBoxListenerOnOutputAdded?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputRemoved = %s\n",(m_bBoxListenerOnOutputRemoved?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputTypeChanged = %s\n",(m_bBoxListenerOnOutputTypeChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputNameChanged = %s\n",(m_bBoxListenerOnOutputNameChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputConnected = %s\n",(m_bBoxListenerOnOutputConnected?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnOutputDisconnected = %s\n",(m_bBoxListenerOnOutputDisconnected?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingAdded = %s\n",(m_bBoxListenerOnSettingAdded?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingRemoved = %s\n",(m_bBoxListenerOnSettingRemoved?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingTypeChanged = %s\n",(m_bBoxListenerOnSettingTypeChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingNameChanged = %s\n",(m_bBoxListenerOnSettingNameChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingDefaultValueChanged = %s\n",(m_bBoxListenerOnSettingDefaultValueChanged?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ListenerOnSettingValueChanged = %s\n",(m_bBoxListenerOnSettingValueChanged?"TRUE":"FALSE")); + + ::fprintf(l_pFile, "SkeletonGenerator_Box_ProcessInput = %s\n",(m_bProcessInput?"TRUE":"FALSE")); + ::fprintf(l_pFile, "SkeletonGenerator_Box_ProcessClock = %s\n",(m_bProcessClock?"TRUE":"FALSE")); + stringstream ssListener; ssListener << m_ui32ClockFrequency; + ::fprintf(l_pFile, "SkeletonGenerator_Box_ClockFrequency = %s\n",ssListener.str().c_str()); + + + + + ::fprintf(l_pFile, "# --------------------------------------------------\n"); + ::fclose(l_pFile); + m_rKernelContext.getLogManager() << LogLevel_Info << "box entries saved in [" << sFileName << "]\n"; + + m_bConfigurationFileLoaded = false; + + return true; +} + +boolean CBoxAlgorithmSkeletonGenerator::load(CString sFileName) +{ + if(!m_bConfigurationFileLoaded && !m_rKernelContext.getConfigurationManager().addConfigurationFromFile(sFileName)) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "box: Configuration file [" << sFileName << "] could not be loaded.\n"; + return false; + } + + ::GtkWidget * l_pClassNameEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-class-name-entry")); + CString l_sClassName = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_ClassName}"); + gtk_entry_set_text(GTK_ENTRY(l_pClassNameEntry),(const char *) l_sClassName); + ::GtkWidget * l_pCategoryEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-category-entry")); + CString l_sCategory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_Category}"); + gtk_entry_set_text(GTK_ENTRY(l_pCategoryEntry),(const char *) l_sCategory); + ::GtkWidget * l_pNameEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-box-name-entry")); + CString l_sName = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_Name}"); + gtk_entry_set_text(GTK_ENTRY(l_pNameEntry),(const char *) l_sName); + ::GtkWidget * l_pVersionEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-version-entry")); + CString l_sVersion = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_Version}"); + gtk_entry_set_text(GTK_ENTRY(l_pVersionEntry),(const char *) l_sVersion); + ::GtkWidget * l_pSDEntry = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-short-description-entry")); + + CString l_sShortDescr = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_ShortDescription}"); + //we need to UNescape the special characters of the configuration manager files + string::iterator it_sdescr; + string l_sTempShortDescr(l_sShortDescr.toASCIIString()); + for(it_sdescr=l_sTempShortDescr.begin(); it_sdescr<l_sTempShortDescr.end(); it_sdescr++) + { + // juste erase the escape character + if((*it_sdescr)=='\\' && (it_sdescr+1) != l_sTempShortDescr.end()) + { + if((*(it_sdescr+1))=='\\' || (*(it_sdescr+1))=='=' || (*(it_sdescr+1))=='$' || (*(it_sdescr+1))=='\t' || (*(it_sdescr+1))=='@') + { + l_sTempShortDescr.erase(it_sdescr); + } + } + // replace the special character @ by \n in the textview + else if((*it_sdescr)=='@') + { + l_sTempShortDescr.erase(it_sdescr); + l_sTempShortDescr.insert(it_sdescr,'\n'); + } + } + gtk_entry_set_text(GTK_ENTRY(l_pSDEntry),l_sTempShortDescr.c_str()); + + ::GtkWidget * l_pDetailedDescrTextView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-detailed-description-textview")); + ::GtkTextBuffer * l_pDetailedDescrTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pDetailedDescrTextView)); + CString l_sDetailedDescr = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Box_DetailedDescription}"); + + //we need to UNescape the special characters of the configuration manager files + string::iterator it_descr; + string l_sTempDetailedDescr(l_sDetailedDescr.toASCIIString()); + m_rKernelContext.getLogManager() << LogLevel_Debug << "LOAD > DESCR LOADED: "<<l_sTempDetailedDescr.c_str()<<"\n"; + for(it_descr=l_sTempDetailedDescr.begin(); it_descr<l_sTempDetailedDescr.end(); it_descr++) + { + // juste erase the escape character + if((*it_descr)=='\\' && (it_descr+1) != l_sTempDetailedDescr.end()) + { + if((*(it_sdescr+1))=='\\' || (*(it_sdescr+1))=='=' || (*(it_sdescr+1))=='$' || (*(it_sdescr+1))=='\t' || (*(it_sdescr+1))=='@') + { + l_sTempDetailedDescr.erase(it_descr); + } + } + // replace the special character @ by \n in the textview + else if((*it_descr)=='@') + { + l_sTempDetailedDescr.erase(it_descr); + l_sTempDetailedDescr.insert(it_descr,'\n'); + } + } + m_rKernelContext.getLogManager() << LogLevel_Debug << "LOAD > DESCR MODIFIED: "<<l_sTempDetailedDescr.c_str()<<"\n"; + gtk_text_buffer_set_text(l_pDetailedDescrTextBuffer,l_sTempDetailedDescr.c_str(),((string)l_sTempDetailedDescr).length()); + + GtkWidget * l_pIconCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-icon-combobox")); + int64 l_iIconSelected = m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Box_IconIndex}"); + gtk_combo_box_set_active(GTK_COMBO_BOX(l_pIconCombobox),(gint)l_iIconSelected); + + GtkWidget * l_pCanModifyInputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-modify-checkbutton")); + boolean l_pCanModifyInputs = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanModifyInputs}"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanModifyInputsCheckbox),l_pCanModifyInputs); + + GtkWidget * l_pCanAddInputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-add-checkbutton")); + boolean l_pCanAddInputs = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanAddInputs}",false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanAddInputsCheckbox),l_pCanAddInputs); + + GtkWidget * l_pCanModifyOutputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-modify-checkbutton")); + boolean l_pCanModifyOutputs = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanModifyOutputs}",false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanModifyOutputsCheckbox),l_pCanModifyOutputs); + + GtkWidget * l_pCanAddOutputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-add-checkbutton")); + boolean l_pCanAddOutputs = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanAddOutputs}",false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanAddOutputsCheckbox),l_pCanAddOutputs); + + GtkWidget * l_pCanModifySettingsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-modify-checkbutton")); + boolean l_pCanModifySettings = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanModifySettings}",false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanModifySettingsCheckbox),l_pCanModifySettings); + + GtkWidget * l_pCanAddSettingsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-checkbutton")); + boolean l_pCanAddSettings = m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_CanAddSettings}",false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCanAddSettingsCheckbox),l_pCanAddSettings); + + ::GtkWidget * l_pInputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-treeview")); + ::GtkTreeModel * l_pInputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pInputsTreeView)); + int64 l_i32InputCount = m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Box_InputCount}",0); + for(int32 i = 0; i < l_i32InputCount; i++) + { + char l_sTokenName [128]; + sprintf(l_sTokenName,"${SkeletonGenerator_Box_Input%i_Name}",i); + CString l_sName = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenName)); + char l_sTokenType [128]; + sprintf(l_sTokenType,"${SkeletonGenerator_Box_Input%i_Type}",i); + CString l_sType = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenType)); + char l_sTokenTypeId [128]; + sprintf(l_sTokenTypeId,"${SkeletonGenerator_Box_Input%i_TypeId}",i); + CString l_sTypeId = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenTypeId)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pInputsListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pInputsListStore), &l_iter, 0, (const char *)l_sName,1,(const char *)l_sType,2,(const char *)l_sTypeId,-1); + } + + ::GtkWidget * l_pOutputsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-treeview")); + ::GtkTreeModel * l_pOutputsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pOutputsTreeView)); + int64 l_i32OutputCount = m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Box_OutputCount}",0); + for(int32 i = 0; i < l_i32OutputCount; i++) + { + char l_sTokenName [128]; + sprintf(l_sTokenName,"${SkeletonGenerator_Box_Output%i_Name}",i); + CString l_sName = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenName)); + char l_sTokenType [128]; + sprintf(l_sTokenType,"${SkeletonGenerator_Box_Output%i_Type}",i); + CString l_sType = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenType)); + char l_sTokenTypeId [128]; + sprintf(l_sTokenTypeId,"${SkeletonGenerator_Box_Output%i_TypeId}",i); + CString l_sTypeId = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenTypeId)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pOutputsListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pOutputsListStore), &l_iter, 0, (const char *)l_sName,1,(const char *)l_sType,2,(const char *)l_sTypeId,-1); + } + + ::GtkWidget * l_pSettingsTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-treeview")); + ::GtkTreeModel * l_pSettingsListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pSettingsTreeView)); + int64 l_i32SettingCount = m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Box_SettingCount}",0); + for(int32 i = 0; i < l_i32SettingCount; i++) + { + char l_sTokenName [128]; + sprintf(l_sTokenName,"${SkeletonGenerator_Box_Setting%i_Name}",i); + CString l_sName = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenName)); + char l_sTokenType [128]; + sprintf(l_sTokenType,"${SkeletonGenerator_Box_Setting%i_Type}",i); + CString l_sType = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenType)); + char l_sTokenTypeId [128]; + sprintf(l_sTokenTypeId,"${SkeletonGenerator_Box_Setting%i_TypeId}",i); + CString l_sTypeId = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenTypeId)); + char l_sTokenDefaultValue [128]; + sprintf(l_sTokenDefaultValue,"${SkeletonGenerator_Box_Setting%i_DefaultValue}",i); + CString l_sDefaultValue = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenDefaultValue)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pSettingsListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pSettingsListStore), &l_iter, 0, (const char *)l_sName,1,(const char *)l_sType,2,(const char *)l_sDefaultValue,3,(const char *)l_sTypeId,-1); + } + + ::GtkWidget * l_pAlgoTreeView = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-treeview")); + ::GtkTreeModel * l_pAlgoListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgoTreeView)); + int64 l_i32AlgoCount = m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Box_AlgorithmCount}",0); + for(int32 i = 0; i < l_i32AlgoCount; i++) + { + char l_sTokenName [128]; + sprintf(l_sTokenName,"${SkeletonGenerator_Box_Algorithm%i_Name}",i); + CString l_sName = m_rKernelContext.getConfigurationManager().expand(CString(l_sTokenName)); + GtkTreeIter l_iter; + gtk_list_store_append(GTK_LIST_STORE(l_pAlgoListStore), &l_iter); + gtk_list_store_set (GTK_LIST_STORE(l_pAlgoListStore), &l_iter, 0, (const char *)l_sName,-1); + } + + ::GtkWidget * l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_UseListener}",false)); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-added-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputAdded}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-removed-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputRemoved}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-type-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputTypeChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-name-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputNameChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-connected-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputConnected}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-disconnected-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnInputDisconnected}",false)); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-added-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputAdded}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-removed-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputRemoved}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-type-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputTypeChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-name-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputNameChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-connected-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputConnected}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-disconnected-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnOutputDisconnected}",false)); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-added-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingAdded}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-removed-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingRemoved}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-type-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingTypeChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-name-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingNameChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-default-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingDefaultValueChanged}",false)); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-value-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pListenerWidget),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ListenerOnSettingValueChanged}",false)); + + ::GtkWidget * l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-input-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pProcessingMethod),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ProcessInput}",false)); + l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-clock-checkbutton")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pProcessingMethod),m_rKernelContext.getConfigurationManager().expandAsBoolean("${SkeletonGenerator_Box_ProcessClock}",false)); + l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-frequency-spinbutton")); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(l_pProcessingMethod), (gdouble) m_rKernelContext.getConfigurationManager().expandAsUInteger("${SkeletonGenerator_Box_ProcessClock}",1)); + + m_rKernelContext.getLogManager() << LogLevel_Info << "box entries from [" << m_sConfigurationFile << "] loaded.\n"; + + return true; +} + +void CBoxAlgorithmSkeletonGenerator::getCurrentParameters(void){ + ::GtkWidget * l_pEntryBoxName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-box-name-entry")); + m_sName = gtk_entry_get_text(GTK_ENTRY(l_pEntryBoxName)); + + ::GtkWidget * l_pEntryClassName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-class-name-entry")); + m_sClassName = gtk_entry_get_text(GTK_ENTRY(l_pEntryClassName)); + + ::GtkWidget * l_pEntryCategory = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-category-entry")); + m_sCategory = gtk_entry_get_text(GTK_ENTRY(l_pEntryCategory)); + + ::GtkWidget * l_pEntryVersion = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-version-entry")); + m_sVersion = gtk_entry_get_text(GTK_ENTRY(l_pEntryVersion)); + + ::GtkWidget * l_pEntryShortDescr = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-short-description-entry")); + m_sShortDescription = gtk_entry_get_text(GTK_ENTRY(l_pEntryShortDescr)); + + ::GtkWidget * l_pEntryDetailedDescr = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-detailed-description-textview")); + ::GtkTextBuffer * l_pTextBufferDetailedDescr = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pEntryDetailedDescr)); + ::GtkTextIter l_TextIterStart,l_TextIterEnd; + gtk_text_buffer_get_start_iter(l_pTextBufferDetailedDescr,&l_TextIterStart); + gtk_text_buffer_get_end_iter(l_pTextBufferDetailedDescr,&l_TextIterEnd); + m_sDetailedDescription = gtk_text_buffer_get_text(l_pTextBufferDetailedDescr,&l_TextIterStart,&l_TextIterEnd, false); + + ::GtkWidget * l_pIconCombobox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-icon-combobox")); + ::GtkTreeModel * l_pIconListStore = gtk_combo_box_get_model(GTK_COMBO_BOX(l_pIconCombobox)); + ::GtkTreeIter l_iterIcon; + m_i32GtkStockItemIndex = gtk_combo_box_get_active(GTK_COMBO_BOX(l_pIconCombobox)); // can be -1 if nothing selected + if(m_i32GtkStockItemIndex != -1) + { + gtk_tree_model_iter_nth_child(l_pIconListStore,&l_iterIcon,NULL,m_i32GtkStockItemIndex); + gchar * l_sData; + gtk_tree_model_get(l_pIconListStore, &l_iterIcon,0, &l_sData,-1); + m_sGtkStockItemName = CString((const char *)l_sData); + } + else + { + m_sGtkStockItemName = ""; + } + ::GtkWidget * l_pCanModifyInputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-modify-checkbutton")); + m_bCanModifyInputs = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanModifyInputsCheckbox)) ? true : false); + ::GtkWidget * l_pCanAddInputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-add-checkbutton")); + m_bCanAddInputs = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanAddInputsCheckbox)) ? true : false); + ::GtkWidget * l_pCanModifyOutputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-modify-checkbutton")); + m_bCanModifyOutputs = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanModifyOutputsCheckbox)) ? true : false); + ::GtkWidget * l_pCanAddOutputsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-add-checkbutton")); + m_bCanAddOutputs = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanAddOutputsCheckbox)) ? true : false); + ::GtkWidget * l_pCanModifySettingsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-modify-checkbutton")); + m_bCanModifySettings = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanModifySettingsCheckbox)) ? true : false); + ::GtkWidget * l_pCanAddSettingsCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-add-checkbutton")); + m_bCanAddSettings = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCanAddSettingsCheckbox)) ? true : false); + + ::GtkWidget * l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-checkbutton")); + m_bUseBoxListener = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-added-checkbutton")); + m_bBoxListenerOnInputAdded = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-removed-checkbutton")); + m_bBoxListenerOnInputRemoved = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-type-checkbutton")); + m_bBoxListenerOnInputTypeChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-name-checkbutton")); + m_bBoxListenerOnInputNameChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-connected-checkbutton")); + m_bBoxListenerOnInputConnected = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-input-disconnected-checkbutton")); + m_bBoxListenerOnInputDisconnected = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-added-checkbutton")); + m_bBoxListenerOnOutputAdded = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-removed-checkbutton")); + m_bBoxListenerOnOutputRemoved = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-type-checkbutton")); + m_bBoxListenerOnOutputTypeChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-name-checkbutton")); + m_bBoxListenerOnOutputNameChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-connected-checkbutton")); + m_bBoxListenerOnOutputConnected = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-output-disconnected-checkbutton")); + m_bBoxListenerOnOutputDisconnected = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-added-checkbutton")); + m_bBoxListenerOnSettingAdded = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-removed-checkbutton")); + m_bBoxListenerOnSettingRemoved = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-type-checkbutton")); + m_bBoxListenerOnSettingTypeChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-name-checkbutton")); + m_bBoxListenerOnSettingNameChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-default-checkbutton")); + m_bBoxListenerOnSettingDefaultValueChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + l_pListenerWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-listener-setting-value-checkbutton")); + m_bBoxListenerOnSettingValueChanged = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pListenerWidget)) ? true : false); + + ::GtkWidget * l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-input-checkbutton")); + m_bProcessInput = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pProcessingMethod)) ? true : false); + l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-clock-checkbutton")); + m_bProcessClock = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pProcessingMethod)) ? true : false); + l_pProcessingMethod = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-process-frequency-spinbutton")); + m_ui32ClockFrequency = (uint32) gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pProcessingMethod)); + + ::GtkWidget * l_pUseCodecToolkitCheckbox = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-toolkit-checkbutton")); + m_bUseCodecToolkit = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pUseCodecToolkitCheckbox)) ? true : false); + + ::GtkWidget * l_pInputsTreeview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-inputs-treeview")); + ::GtkTreeModel * l_pInputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pInputsTreeview)); + GtkTreeIter l_iter; + boolean l_bValid = (gtk_tree_model_get_iter_first(l_pInputListStore,&l_iter) ? true : false); + gint l_iRowCount = 0; + m_vInputs.clear(); + while(l_bValid) + { + /* Walk through the list, reading each row */ + gchar * l_sName; + gchar * l_sType; + gchar * l_sTypeOv; + gtk_tree_model_get(l_pInputListStore, &l_iter,0, &l_sName,1, &l_sType,2,&l_sTypeOv,-1); + + IOSStruct l_struct; + l_struct._name=l_sName; + l_struct._type=l_sType; + l_struct._typeId=l_sTypeOv; + m_vInputs.push_back(l_struct); + + g_free(l_sName);g_free (l_sType);g_free(l_sTypeOv); + l_iRowCount++; + l_bValid = (gtk_tree_model_iter_next (l_pInputListStore, &l_iter) ? true : false); + } + + ::GtkWidget * l_pOutputsTreeview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-outputs-treeview")); + ::GtkTreeModel * l_pOutputListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pOutputsTreeview)); + GtkTreeIter l_iterOutput; + l_bValid = (gtk_tree_model_get_iter_first(l_pOutputListStore,&l_iterOutput) ? true : false); + l_iRowCount = 0; + m_vOutputs.clear(); + while(l_bValid) + { + /* Walk through the list, reading each row */ + gchar * l_sName; + gchar * l_sType; + gchar * l_sTypeOv; + gtk_tree_model_get(l_pOutputListStore, &l_iterOutput,0, &l_sName,1, &l_sType,2,&l_sTypeOv,-1); + + IOSStruct l_struct; + l_struct._name=l_sName; + l_struct._type=l_sType; + l_struct._typeId=l_sTypeOv; + m_vOutputs.push_back(l_struct); + + g_free(l_sName);g_free(l_sType);g_free(l_sTypeOv); + l_iRowCount++; + l_bValid = (gtk_tree_model_iter_next (l_pOutputListStore, &l_iterOutput) ? true : false); + } + + ::GtkWidget * l_pSettingsTreeview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-settings-treeview")); + ::GtkTreeModel * l_pSettingListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pSettingsTreeview)); + GtkTreeIter l_iterSetting; + l_bValid = (gtk_tree_model_get_iter_first(l_pSettingListStore,&l_iterSetting) ? true : false); + l_iRowCount = 0; + m_vSettings.clear(); + while(l_bValid) + { + /* Walk through the list, reading each row */ + gchar * l_sName; + gchar * l_sType;gchar * l_sTypeOv; + gchar * l_sDefaultValue; + gtk_tree_model_get(l_pSettingListStore, &l_iterSetting,0, &l_sName,1, &l_sType, 2, &l_sDefaultValue,3,&l_sTypeOv,-1); + + IOSStruct l_struct; + l_struct._name = l_sName; + l_struct._type = l_sType; + l_struct._typeId=l_sTypeOv; + l_struct._defaultValue = l_sDefaultValue; + m_vSettings.push_back(l_struct); + + g_free(l_sName);g_free(l_sType);g_free(l_sDefaultValue);g_free(l_sTypeOv); + l_iRowCount++; + l_bValid = (gtk_tree_model_iter_next (l_pSettingListStore, &l_iterSetting) ? true : false); + } + + ::GtkWidget * l_pAlgosTreeview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-algorithms-treeview")); + ::GtkTreeModel * l_pAlgosListStore = gtk_tree_view_get_model(GTK_TREE_VIEW(l_pAlgosTreeview)); + GtkTreeIter l_iterAlgo; + l_bValid = (gtk_tree_model_get_iter_first(l_pAlgosListStore,&l_iterAlgo) ? true : false); + l_iRowCount = 0; + m_vAlgorithms.clear(); + while(l_bValid) + { + /* Walk through the list, reading each row */ + gchar * l_sName; + gtk_tree_model_get(l_pAlgosListStore, &l_iterAlgo,0, &l_sName,-1); + + m_vAlgorithms.push_back(l_sName); + + g_free(l_sName); + l_iRowCount++; + l_bValid = (gtk_tree_model_iter_next (l_pAlgosListStore, &l_iterAlgo) ? true : false); + } +} + +CString CBoxAlgorithmSkeletonGenerator::getRandomIdentifierString(void) +{ + + unsigned short int l_ui16Value1=(rand()&0xffff); + unsigned short int l_ui16Value2=(rand()&0xffff); + unsigned short int l_ui16Value3=(rand()&0xffff); + unsigned short int l_ui16Value4=(rand()&0xffff); + + char buffer[50]; + sprintf(buffer,"OpenViBE::CIdentifier(0x%04X%04X, 0x%04X%04X)",(int)l_ui16Value1, (int)l_ui16Value2, (int)l_ui16Value3, (int)l_ui16Value4); + return CString(buffer); +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.h b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..c76edf38b14af0af3c1ffc97180a0e21aa5d2706 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCBoxAlgorithmSkeletonGenerator.h @@ -0,0 +1,148 @@ +#ifndef __OpenViBESkeletonGenerator_CBoxAlgorithmSkeletonGenerator_H__ +#define __OpenViBESkeletonGenerator_CBoxAlgorithmSkeletonGenerator_H__ + +#include "ovsgCSkeletonGenerator.h" +#include <map> +#include <vector> + +namespace OpenViBESkeletonGenerator +{ + class CBoxAlgorithmSkeletonGenerator : public CSkeletonGenerator + { + public: + + CBoxAlgorithmSkeletonGenerator(OpenViBE::Kernel::IKernelContext & rKernelContext,::GtkBuilder * pBuilderInterface); + virtual ~CBoxAlgorithmSkeletonGenerator(void); + + OpenViBE::boolean initialize(void); + OpenViBE::boolean save(OpenViBE::CString sFileName); + OpenViBE::boolean load(OpenViBE::CString sFileName); + void getCurrentParameters(void); + + // Box Description + OpenViBE::CString m_sName; + OpenViBE::CString m_sVersion; + OpenViBE::CString m_sClassName; + OpenViBE::CString m_sCategory; + OpenViBE::CString m_sShortDescription; + OpenViBE::CString m_sDetailedDescription; + OpenViBE::int32 m_i32GtkStockItemIndex; + OpenViBE::CString m_sGtkStockItemName; + + struct IOSStruct{ + OpenViBE::CString _name; + OpenViBE::CString _type; + OpenViBE::CString _typeId; + OpenViBE::CString _defaultValue; + }; + + // Inputs + OpenViBE::boolean m_bCanModifyInputs; + OpenViBE::boolean m_bCanAddInputs; + std::vector<IOSStruct> m_vInputs; + // Outputs + OpenViBE::boolean m_bCanModifyOutputs; + OpenViBE::boolean m_bCanAddOutputs; + std::vector<IOSStruct> m_vOutputs; + // Settings + OpenViBE::boolean m_bCanModifySettings; + OpenViBE::boolean m_bCanAddSettings; + std::vector<IOSStruct> m_vSettings; + + //Algorithms + std::vector<OpenViBE::CString> m_vAlgorithms; // the algorithm selected by user + OpenViBE::boolean m_bUseCodecToolkit; // use or not the codec toolkit for encoder and decoder algorithms + std::map <OpenViBE::CString, OpenViBE::CString> m_mAlgorithmHeaderDeclaration; //the map between algorithm and corresponding header declaration (all variables algo/input/output). + std::map <OpenViBE::CString, OpenViBE::CString> m_mAlgorithmInitialisation;//the map between algorithm and corresponding initialisation + std::map <OpenViBE::CString, OpenViBE::CString> m_mAlgorithmInitialisation_ReferenceTargets;//the map between algorithm and corresponding initialisation of ref targets + std::map <OpenViBE::CString, OpenViBE::CString> m_mAlgorithmUninitialisation;//the map between algorithm and corresponding uninitialisation + + // Box Listener + OpenViBE::boolean m_bUseBoxListener; + // input + OpenViBE::boolean m_bBoxListenerOnInputAdded; + OpenViBE::boolean m_bBoxListenerOnInputRemoved; + OpenViBE::boolean m_bBoxListenerOnInputTypeChanged; + OpenViBE::boolean m_bBoxListenerOnInputNameChanged; + OpenViBE::boolean m_bBoxListenerOnInputConnected; + OpenViBE::boolean m_bBoxListenerOnInputDisconnected; + // output + OpenViBE::boolean m_bBoxListenerOnOutputAdded; + OpenViBE::boolean m_bBoxListenerOnOutputRemoved; + OpenViBE::boolean m_bBoxListenerOnOutputTypeChanged; + OpenViBE::boolean m_bBoxListenerOnOutputNameChanged; + OpenViBE::boolean m_bBoxListenerOnOutputConnected; + OpenViBE::boolean m_bBoxListenerOnOutputDisconnected; + // setting + OpenViBE::boolean m_bBoxListenerOnSettingAdded; + OpenViBE::boolean m_bBoxListenerOnSettingRemoved; + OpenViBE::boolean m_bBoxListenerOnSettingTypeChanged; + OpenViBE::boolean m_bBoxListenerOnSettingNameChanged; + OpenViBE::boolean m_bBoxListenerOnSettingDefaultValueChanged; + OpenViBE::boolean m_bBoxListenerOnSettingValueChanged; + + OpenViBE::boolean m_bProcessInput; + OpenViBE::boolean m_bProcessClock; + OpenViBE::uint32 m_ui32ClockFrequency; + + void buttonCheckCB(void); + void buttonOkCB(void); + void forceRecheckCB(void); + void toggleListenerCheckbuttonsStateCB(OpenViBE::boolean bNewState); + void toggleClockFrequencyStateCB(OpenViBE::boolean bNewState); + void buttonTooltipCB(::GtkButton* pButton); + void buttonExitCB(void); + + void buttonAddInputCB(void); + void buttonRemoveInputCB(void); + void buttonAddOutputCB(void); + void buttonRemoveOutputCB(void); + void buttonAddSettingCB(void); + void buttonRemoveSettingCB(void); + void buttonAddAlgorithmCB(void); + void buttonRemoveAlgorithmCB(void); + void algorithmSelectedCB(OpenViBE::int32 i32IndexSelected); + + private: + + std::map < ::GtkButton*, OpenViBE::CString > m_vTooltips; + + OpenViBE::CString getRandomIdentifierString(void); + + std::vector<OpenViBE::CString> m_vParameterType_EnumTypeCorrespondance; + + }; + + class CDummyAlgoProto : public OpenViBE::Kernel::IAlgorithmProto + { + public: + std::map<OpenViBE::CString, OpenViBE::Kernel::EParameterType> m_vInputs; + std::map<OpenViBE::CString, OpenViBE::Kernel::EParameterType> m_vOutputs; + std::vector<OpenViBE::CString> m_vInputTriggers; + std::vector<OpenViBE::CString> m_vOutputTriggers; + public: + OpenViBE::boolean addInputParameter( + const OpenViBE::CIdentifier& rInputParameterIdentifier, + const OpenViBE::CString& sInputName, + const OpenViBE::Kernel::EParameterType eParameterType, + const OpenViBE::CIdentifier& rSubTypeIdentifier=OV_UndefinedIdentifier); + + OpenViBE::boolean addOutputParameter( + const OpenViBE::CIdentifier& rOutputParameterIdentifier, + const OpenViBE::CString& sOutputName, + const OpenViBE::Kernel::EParameterType eParameterType, + const OpenViBE::CIdentifier& rSubTypeIdentifier=OV_UndefinedIdentifier); + + OpenViBE::boolean addInputTrigger( + const OpenViBE::CIdentifier& rInputTriggerIdentifier, + const OpenViBE::CString& rInputTriggerName); + + OpenViBE::boolean addOutputTrigger( + const OpenViBE::CIdentifier& rOutputTriggerIdentifier, + const OpenViBE::CString& rOutputTriggerName); + + OpenViBE::CIdentifier getClassIdentifier(void) const {return OV_UndefinedIdentifier;} + }; +} + +#endif //__OpenViBESkeletonGenerator_CBoxAlgorithmSkeletonGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.cpp b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..66f40341aaf71e79931161de1ed55a65fdd0f26e --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.cpp @@ -0,0 +1,551 @@ +#include "ovsgCDriverSkeletonGenerator.h" + +#include <iostream> +#include <sstream> + +#include <glib/gstdio.h> +#include <cstdio> + +#include <boost/regex.hpp> + +using namespace std; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBESkeletonGenerator; + +//----------------------------------------------------------------------- +static void button_check_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CDriverSkeletonGenerator*>(pUserData)->buttonCheckCB(); +} +static void button_tooltip_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CDriverSkeletonGenerator*>(pUserData)->buttonTooltipCB(pButton); +} +static void button_ok_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CDriverSkeletonGenerator*>(pUserData)->buttonOkCB(); +} +static void button_exit_cb(::GtkButton* pButton, void* pUserData) +{ + static_cast<CDriverSkeletonGenerator*>(pUserData)->buttonExitCB(); + ::gtk_exit(0); +} + +//----------------------------------------------------------------------- +void CDriverSkeletonGenerator::buttonExitCB() +{ + getCommonParameters(); + getCurrentParameters(); + cleanConfigurationFile(m_sConfigurationFile); + saveCommonParameters(m_sConfigurationFile); + save(m_sConfigurationFile); + + m_rKernelContext.getLogManager() << LogLevel_Info << "All entries saved in ["<< m_sConfigurationFile<<"]. Exiting.\n"; +} + +void CDriverSkeletonGenerator::buttonCheckCB() +{ + //Author and Company + getCommonParameters(); + getCurrentParameters(); + + m_rKernelContext.getLogManager() << LogLevel_Info << "Checking values... \n"; + + boolean l_bSuccess = true; + + stringstream l_ssTextBuffer; + l_ssTextBuffer << "----- STATUS -----\n"; + + //-------------------------------------------------------------------------------------------------------------------------------------------// + //::GtkWidget * l_pEntryDriverName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_driver_name")); + //m_sDriverName = gtk_entry_get_text(GTK_ENTRY(l_pEntryDriverName)); + const boost::regex l_RegExpDriverName("([a-z]|[A-Z]|[0-9])+([a-z]|[A-Z]|[0-9]|[ \t\r\n]|[\\.-_\\(\\)])*",boost::regex::perl); + if(boost::regex_match(string(m_sDriverName),l_RegExpDriverName) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- Driver Name: INVALID\n"; + l_bSuccess = false; + l_ssTextBuffer << "[FAILED] Invalid driver name. Please use only characters (lower or uppercase) and numbers (blanck allowed).\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- Driver Name: VALID (" << (const char *)m_sDriverName << ")\n"; + l_ssTextBuffer << "[ OK ] Valid driver name.\n"; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + //::GtkWidget * l_pEntryClassName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_class_name")); + //m_sClassName = gtk_entry_get_text(GTK_ENTRY(l_pEntryClassName)); + const boost::regex l_RegExpClassName("([a-z]|[A-Z]|[0-9])+",boost::regex::perl); + if(boost::regex_match(string(m_sClassName),l_RegExpClassName) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- Class Name: INVALID\n"; + l_bSuccess = false; + l_ssTextBuffer << "[FAILED] Invalid class name. Please use only characters (lower or uppercase) and numbers (no blanck allowed).\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- Class Name: VALID (" << (const char *)m_sClassName << ")\n"; + l_ssTextBuffer << "[ OK ] Valid class name.\n"; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + ::GtkWidget * l_pSpinbuttonMinChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_min_channel")); + //stringstream ss1,ss2; + //ss1 << (uint32) gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMinChannel)); + //m_sMinChannel = CString(ss1.str().c_str()); + ::GtkWidget * l_pSpinbuttonMaxChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_max_channel")); + //ss2 << (uint32) gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMaxChannel)); + //m_sMaxChannel = CString(ss2.str().c_str()); + if(gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMinChannel)) > gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMaxChannel))) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- Channels: INVALID\n"; + l_bSuccess = false; + l_ssTextBuffer << "[FAILED] Invalid channel count. Be sure that Min <= Max.\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- Channels: VALID (" << (const char *)m_sMinChannel << "/" << (const char *)m_sMaxChannel << ")\n"; + l_ssTextBuffer << "[ OK ] Valid channel count.\n"; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + /*::GtkWidget * l_pEntrySF = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_sampling_frequencies")); + CString l_sSamplingFrequencies = gtk_entry_get_text(GTK_ENTRY(l_pEntrySF)); + */const boost::regex l_RegExpSamplingFrequencies("(([1-9][0-9]*);)*([1-9][0-9]*)",boost::regex::perl); + if(boost::regex_match(string(m_sSamplingFrequencies),l_RegExpSamplingFrequencies) == false) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "-- Sampling frequencies: INVALID\n"; + l_bSuccess = false; + l_ssTextBuffer << "[FAILED] Invalid sampling frequencies. Please use only whole numbers separated with ';' (no blanck allowed).\n"; + } + else + { + // Maximum 16 frequencies + int l_pSF[16]; + uint32 l_ui32SamplingFrequencyCount = sscanf((const char *)m_sSamplingFrequencies, + "%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d", + &l_pSF[0],&l_pSF[1],&l_pSF[2],&l_pSF[3],&l_pSF[4],&l_pSF[5],&l_pSF[6],&l_pSF[7], + &l_pSF[8],&l_pSF[9],&l_pSF[10],&l_pSF[11],&l_pSF[12],&l_pSF[13],&l_pSF[14],&l_pSF[15]); + + m_rKernelContext.getLogManager() << LogLevel_Info << "-- Sampling frequencies: VALID\n"; + m_vSamplingFrequencies.clear(); + for(unsigned int i = 0;i<l_ui32SamplingFrequencyCount;i++) + { + stringstream ss; + ss << l_pSF[i]; + m_vSamplingFrequencies.push_back( CString(ss.str().c_str()) ); + printf("- %s Hz\n", ss.str().c_str()); + } + + l_ssTextBuffer << "[ OK ] " << l_ui32SamplingFrequencyCount << " valid sampling frequencie(s).\n"; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + /*::GtkWidget * l_pFileChooser = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "filechooserbutton_target_directory")); + char * l_pTargetDirectory = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(l_pFileChooser)); + m_sTargetDirectory = CString(l_pTargetDirectory); + g_free(l_pTargetDirectory);*/ + +#ifdef TARGET_OS_Windows + string space("%20"); + if(((string)m_sTargetDirectory).rfind(space) != string::npos) + { + l_ssTextBuffer << "[FAILED] Invalid destination folder :" << (const char *)m_sTargetDirectory << ".\n"; + m_rKernelContext.getLogManager() << LogLevel_Error << "Invalid destination folder :" << (const char *)m_sTargetDirectory << ".\n"; + l_bSuccess = false; + } + else +#endif + { + m_rKernelContext.getLogManager() << LogLevel_Info << "-- Target directory: " << (const char *)m_sTargetDirectory << "\n"; + l_ssTextBuffer << "[ OK ] Valid target directory: " << (const char *)m_sTargetDirectory << "\n"; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + if(l_bSuccess) + { + l_ssTextBuffer << "----- SUCCESS -----\nPress OK to generate the files. If you want to modify your choice(s), please press the \"Check\" button again."; + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,true); + } + else + { + l_ssTextBuffer << "----- PROCESS FAILED -----\nModify your choices and press the \"Check\" button again."; + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-ok-button")); + gtk_widget_set_sensitive(l_pButtonOk,false); + } + + gtk_text_buffer_set_text (l_pTextBuffer, + l_ssTextBuffer.str().c_str() + , -1); +} + +void CDriverSkeletonGenerator::buttonOkCB() +{ + + m_rKernelContext.getLogManager() << LogLevel_Info << "Generating files... \n"; + CString l_sLogMessages = "Generating files...\n"; + + boolean l_bSuccess = true; + + CString l_sDate = getDate(); + + // we construct the map of substitutions + map<CString,CString> l_mSubstitutions; + l_mSubstitutions[CString("@@AuthorName@@")] = m_sAuthor; + l_mSubstitutions[CString("@@CompanyName@@")] = m_sCompany; + l_mSubstitutions[CString("@@Date@@")] = l_sDate; + l_mSubstitutions[CString("@@ClassName@@")] = m_sClassName; + l_mSubstitutions[CString("@@DriverName@@")] = m_sDriverName; + l_mSubstitutions[CString("@@MinChannel@@")] = m_sMinChannel; + l_mSubstitutions[CString("@@MaxChannel@@")] = m_sMaxChannel; + l_mSubstitutions[CString("@@SamplingFrequency@@")] = m_vSamplingFrequencies[0]; + + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // driver.h + CString l_sDest = m_sTargetDirectory + "/ovasCDriver" + m_sClassName + ".h"; + CString l_sTemplate(OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/driver.h-skeleton"); + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // driver.cpp + l_sDest = m_sTargetDirectory + "/ovasCDriver" + m_sClassName + ".cpp"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/driver.cpp-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + // config.h + l_sDest = m_sTargetDirectory + "/ovasCConfiguration" + m_sClassName + ".h"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/configuration.h-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + // config.cpp + l_sDest = m_sTargetDirectory + "/ovasCConfiguration" + m_sClassName + ".cpp"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/configuration.cpp-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + // interface.ui + l_sDest = m_sTargetDirectory + "/interface-" + m_sClassName + ".ui"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/interface.ui-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + // the following substitution is done in a .ui file, and not in a cpp file. + // The SED primitive immplemented do not cover that case, and some typo problem happen with the character " + CString l_sCommandSed = "s/@@SamplingFrequencyList@@/"; + for(vector<CString>::iterator it = m_vSamplingFrequencies.begin(); it != m_vSamplingFrequencies.end(); ) + { + l_sCommandSed = l_sCommandSed + (*it++); + if(it!=m_vSamplingFrequencies.end()) l_sCommandSed = l_sCommandSed + "<\\/col><\\/row><row><col id=\\\"0\\\" translatable=\\\"yes\\\">"; + } + l_sCommandSed = l_sCommandSed + "/g"; + l_bSuccess &= executeSedCommand(l_sDest, l_sCommandSed); + + //-------------------------------------------------------------------------------------------------------------------------------------------// + // readme-driver.txt + l_sDest = m_sTargetDirectory + "/README.txt"; + l_sTemplate = OpenViBE::Directories::getDataDir() + "/openvibe-applications/skeleton-generator/readme-driver.txt-skeleton"; + + if(!this->generate(l_sTemplate,l_sDest,l_mSubstitutions,l_sLogMessages)) + { + gtk_text_buffer_set_text (l_pTextBuffer, + l_sLogMessages, + -1); + l_bSuccess = false; + } + //-------------------------------------------------------------------------------------------------------------------------------------------// + + if(l_bSuccess) + { + l_bSuccess&=cleanConfigurationFile(m_sConfigurationFile); + l_bSuccess&=saveCommonParameters(m_sConfigurationFile); + l_bSuccess&=save(m_sConfigurationFile); + } + + if(!l_bSuccess) + { + l_sLogMessages = l_sLogMessages + "Generation process did not completly succeed. Some files may have not been produced.\n"; + m_rKernelContext.getLogManager() << LogLevel_Warning << "Generation process did not completly succeed. Some files may have not been produced.\n"; + } + else + { + l_sLogMessages = l_sLogMessages + "Generation process successful. All information saved in [" + m_sConfigurationFile + "]\n"; + l_sLogMessages = l_sLogMessages + "Please read the file [README.txt] !\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << "Generation process successful. All information saved in [" << m_sConfigurationFile << "]\n"; + } + + // Launch the browser to display the produced files + CString l_sBrowser = m_rKernelContext.getConfigurationManager().expand("${Designer_WebBrowserCommand_${OperatingSystem}}"); + CString l_sBrowserCmd = l_sBrowser + " \"" + m_sTargetDirectory+"\""; + +#ifdef TARGET_OS_Windows + l_sBrowserCmd = l_sBrowser + " file:///"+ m_sTargetDirectory; //otherwise the browser does not find the directory (problem with / and \ char) +#endif + + if(system((const char *)l_sBrowserCmd)) + { + } + + gtk_text_buffer_set_text( + l_pTextBuffer, + l_sLogMessages, + -1); +} + +void CDriverSkeletonGenerator::buttonTooltipCB(::GtkButton* pButton) +{ + EWidgetName l_eWidgetName=m_vWidgetName[pButton]; + + ::GtkWidget * l_pTooltipTextview = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-tooltips-textview")); + ::GtkTextBuffer * l_pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(l_pTooltipTextview)); + + if(l_eWidgetName == WidgetName_DriverName) + { + gtk_text_buffer_set_text (l_pTextBuffer, + "Driver Name: \nThis name will be the one displayed in the Acquisition Server selection combobox.\nUsually, the driver is named according to the EEG device (with precisions such as a version number).\n------\nExample: OpenEEG Modular EEG (P2)\n\n\n" + , -1); + } + else if(l_eWidgetName == WidgetName_ClassName) + { + gtk_text_buffer_set_text (l_pTextBuffer, + "Class Name: \nThis name will be used to generate all source and GUI files.\nYou should choose a class name close to the device name (no blank allowed !).\n------\nExample: OpenEEGModularEEG will generate\n - ovasCDriverOpenEEGModularEEG.h/.cpp, the driver skeleton \n - ovasCConfigurationOpenEEGModularEEG.h/.cpp, the configuration class skeleton\n - interface-OpenEEG-ModularEEG.ui, the GUI description file" + , -1); + } + else if(l_eWidgetName == WidgetName_ChannelCount) + { + gtk_text_buffer_set_text (l_pTextBuffer, + "Channel count: \nEnter in the two fields the minimum and maximum number of channels the device is capable of.\nOf course you can still change it later in the source code.\n------\nExample: Min(1) Max(16)\n\n\n" + , -1); + } + else if(l_eWidgetName == WidgetName_SamplingFrequencies) + { + gtk_text_buffer_set_text (l_pTextBuffer, + "Sampling frequencies: \nEnter in the text field the sampling frequencies your device is capable of.\nYou can specify a list of defined frequencies (value separator ';').\n------\nExample:\n\"128;256;512\" for three defined frequencies.\n\n" + , -1); + } + else if(l_eWidgetName == WidgetName_TargetDirectory) + { + gtk_text_buffer_set_text (l_pTextBuffer, + "Target directory: \nEnter the destination directory in which all files will be generated. \nAny existing files will be overwritten.\n------\nExample: ~/skeleton-generator/foobar-driver/\n\n\n" + , -1); + } + else + { + } +} + +CDriverSkeletonGenerator::CDriverSkeletonGenerator(IKernelContext & rKernelContext, ::GtkBuilder * pBuilderInterface) + :CSkeletonGenerator(rKernelContext, pBuilderInterface) +{ +} +CDriverSkeletonGenerator::~CDriverSkeletonGenerator(void) +{ +} + +OpenViBE::boolean CDriverSkeletonGenerator::initialize( void ) +{ + ::GtkWidget * l_pWindowDriver = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-window")); + + // Buttons and signals + ::GtkWidget * l_pButtonCheck = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-check-button")); + ::GtkWidget * l_pButtonOk = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-ok-button")); + + g_signal_connect(l_pButtonCheck,"pressed",G_CALLBACK(button_check_cb), this); + g_signal_connect(l_pButtonOk,"pressed",G_CALLBACK(button_ok_cb), this); + + ////target directory + //::GtkWidget * l_pFileChooser = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "filechooserbutton_target_directory")); + //CString l_sTargetDirectory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_TargetDirectory}"); + //if(!gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pFileChooser),(const char *)l_sTargetDirectory)) + //{ + // gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pFileChooser),".."); + //} + + + // Tooltips buttons and signal + ::GtkButton * l_pTooltipButton_driverName = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-driver-name-tooltip-button")); + ::GtkButton * l_pTooltipButton_className = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-class-name-tooltip-button")); + ::GtkButton * l_pTooltipButton_channelCount = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-channel-count-tooltip-button")); + ::GtkButton * l_pTooltipButton_samplingFrequencies = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-sampling-frequencies-tooltip-button")); + ::GtkButton * l_pTooltipButton_targetDirectory = GTK_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-target-directory-tooltip-button")); + + m_vWidgetName[l_pTooltipButton_driverName]=WidgetName_DriverName; + m_vWidgetName[l_pTooltipButton_className]=WidgetName_ClassName; + m_vWidgetName[l_pTooltipButton_channelCount]=WidgetName_ChannelCount; + m_vWidgetName[l_pTooltipButton_samplingFrequencies]=WidgetName_SamplingFrequencies; + m_vWidgetName[l_pTooltipButton_targetDirectory]=WidgetName_TargetDirectory; + + g_signal_connect(l_pTooltipButton_driverName, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_className, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_channelCount, "pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_samplingFrequencies,"pressed",G_CALLBACK(button_tooltip_cb), this); + g_signal_connect(l_pTooltipButton_targetDirectory, "pressed",G_CALLBACK(button_tooltip_cb), this); + + //Close with X and "cancel" button + g_signal_connect (G_OBJECT(l_pWindowDriver),"delete_event",G_CALLBACK(::gtk_exit),0); + ::GtkWidget * l_pButtonCancel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-cancel-button")); + g_signal_connect(l_pButtonCancel,"pressed", G_CALLBACK(button_exit_cb), this); + + //load everything from file + load(m_sConfigurationFile); + + gtk_widget_show_all(l_pWindowDriver); + + return true; +} + +boolean CDriverSkeletonGenerator::save(OpenViBE::CString sFileName) +{ + FILE* l_pFile=::fopen(sFileName.toASCIIString(), "ab"); + if(!l_pFile) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Saving the driver entries in [" << m_sConfigurationFile << "] failed !\n"; + return false; + } + ::fprintf(l_pFile, "# ----------------------DRIVER-------------------------\n"); + string::iterator it; + string l_sTempTargetDirectory(m_sTargetDirectory.toASCIIString()); + for(it=l_sTempTargetDirectory.begin(); it<l_sTempTargetDirectory.end(); it++) + { + if((*it)=='\\') + { + l_sTempTargetDirectory.replace(it, it+1, 1, '/'); + } + } + + ::fprintf(l_pFile, "SkeletonGenerator_Driver_DriverName = %s\n", m_sDriverName.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Driver_ClassName = %s\n", m_sClassName.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Driver_MinChannel = %s\n", m_sMinChannel.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Driver_MaxChannel = %s\n", m_sMaxChannel.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Driver_SamplingFrequencies = %s\n", m_sSamplingFrequencies.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Driver_TargetDirectory = %s\n", l_sTempTargetDirectory.c_str()); + ::fprintf(l_pFile, "# -----------------------------------------------------\n"); + ::fclose(l_pFile); + m_rKernelContext.getLogManager() << LogLevel_Info << "Driver entries saved in [" << m_sConfigurationFile << "]\n"; + + m_bConfigurationFileLoaded = false; + + return true; +} + +boolean CDriverSkeletonGenerator::load(OpenViBE::CString sFileName) +{ + if(!m_bConfigurationFileLoaded && !m_rKernelContext.getConfigurationManager().addConfigurationFromFile(sFileName)) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Driver: Configuration file [" << sFileName << "] could not be loaded. It will be automatically generated after first use.\n"; + return false; + } + + ::GtkWidget * l_pEntryDriverName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_driver_name")); + gtk_entry_set_text(GTK_ENTRY(l_pEntryDriverName),m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Driver_DriverName}")); + + ::GtkWidget * l_pEntryClassName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_class_name")); + gtk_entry_set_text(GTK_ENTRY(l_pEntryClassName),m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Driver_ClassName}")); + + ::GtkWidget * l_pSpinbuttonMinChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_min_channel")); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(l_pSpinbuttonMinChannel),(gdouble)m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Driver_MinChannel}")); + + ::GtkWidget * l_pSpinbuttonMaxChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_max_channel")); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(l_pSpinbuttonMaxChannel),(gdouble)m_rKernelContext.getConfigurationManager().expandAsInteger("${SkeletonGenerator_Driver_MaxChannel}")); + + ::GtkWidget * l_pEntrySF = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_sampling_frequencies")); + gtk_entry_set_text(GTK_ENTRY(l_pEntrySF),m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Driver_SamplingFrequencies}")); + + ::GtkWidget * l_pFileChooser = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "filechooserbutton_target_directory")); + CString l_sTargetDirectory; + + // if the user specified a target directory, it has full priority + l_sTargetDirectory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_TargetDirectory}"); + boolean l_bNeedFilePrefix = false; + if((string)l_sTargetDirectory != string("")) + { + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target dir user [" << l_sTargetDirectory << "]\n"; + l_bNeedFilePrefix = true; + } + else + { + //previous entry + l_sTargetDirectory = m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Driver_TargetDirectory}"); + if((string)l_sTargetDirectory != string("")) + { + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target previous [" << l_sTargetDirectory << "]\n"; + l_bNeedFilePrefix = true; + } + else + { + //default path = dist + m_rKernelContext.getLogManager() << LogLevel_Debug << "Target default [dist]\n"; +#ifdef TARGET_OS_Linux + l_sTargetDirectory = CString(gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(l_pFileChooser))); + l_sTargetDirectory = l_sTargetDirectory + "/.."; +#elif defined TARGET_OS_Windows + l_sTargetDirectory = ".."; +#endif + } + } +#ifdef TARGET_OS_Linux + if(l_bNeedFilePrefix) l_sTargetDirectory = "file://"+l_sTargetDirectory; + gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(l_pFileChooser),(const char *)l_sTargetDirectory); +#elif defined TARGET_OS_Windows + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pFileChooser),(const char *)l_sTargetDirectory); +#endif + + m_rKernelContext.getLogManager() << LogLevel_Info << "Driver entries from [" << sFileName << "] loaded.\n"; + return true; +} + +void CDriverSkeletonGenerator::getCurrentParameters(void) +{ + ::GtkWidget * l_pEntryDriverName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_driver_name")); + m_sDriverName = gtk_entry_get_text(GTK_ENTRY(l_pEntryDriverName)); + ::GtkWidget * l_pEntryClassName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_class_name")); + m_sClassName = gtk_entry_get_text(GTK_ENTRY(l_pEntryClassName)); + ::GtkWidget * l_pSpinbuttonMinChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_min_channel")); + stringstream ss1,ss2; + ss1 << (uint32) gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMinChannel)); + m_sMinChannel = CString(ss1.str().c_str()); + ::GtkWidget * l_pSpinbuttonMaxChannel = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "spinbutton_max_channel")); + ss2 << (uint32) gtk_spin_button_get_value(GTK_SPIN_BUTTON(l_pSpinbuttonMaxChannel)); + m_sMaxChannel = CString(ss2.str().c_str()); + ::GtkWidget * l_pEntrySF = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_sampling_frequencies")); + m_sSamplingFrequencies = gtk_entry_get_text(GTK_ENTRY(l_pEntrySF)); + ::GtkWidget * l_pFileChooser = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "filechooserbutton_target_directory")); + char * l_pTargetDirectory = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(l_pFileChooser)); + m_sTargetDirectory = CString(l_pTargetDirectory); + g_free(l_pTargetDirectory); +} + diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.h b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..92f79c583d358da32548bf0eb76ce8920f48dd27 --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCDriverSkeletonGenerator.h @@ -0,0 +1,50 @@ +#ifndef __OpenViBESkeletonGenerator_CDriverSkeletonGenerator_H__ +#define __OpenViBESkeletonGenerator_CDriverSkeletonGenerator_H__ + +#include "ovsgCSkeletonGenerator.h" + +#include <vector> +#include <map> + +namespace OpenViBESkeletonGenerator +{ + class CDriverSkeletonGenerator : public CSkeletonGenerator + { + public: + + CDriverSkeletonGenerator(OpenViBE::Kernel::IKernelContext & rKernelContext, ::GtkBuilder * pBuilderInterface); + virtual ~CDriverSkeletonGenerator(void); + + OpenViBE::boolean initialize(void); + OpenViBE::boolean save(OpenViBE::CString sFileName); + OpenViBE::boolean load(OpenViBE::CString sFileName); + void getCurrentParameters(void); + + OpenViBE::CString m_sDriverName; + OpenViBE::CString m_sClassName; + OpenViBE::CString m_sSamplingFrequencies; + std::vector<OpenViBE::CString> m_vSamplingFrequencies; + OpenViBE::CString m_sMinChannel; + OpenViBE::CString m_sMaxChannel; + + void buttonCheckCB(void); + void buttonOkCB(void); + void buttonTooltipCB(::GtkButton* pButton); + void buttonExitCB(void); + + private: + + typedef enum + { + WidgetName_DriverName, + WidgetName_ClassName, + WidgetName_ChannelCount, + WidgetName_SamplingFrequencies, + WidgetName_TargetDirectory, + } EWidgetName; + + std::map < ::GtkButton*, EWidgetName > m_vWidgetName; + }; +} + +#endif //__OpenViBESkeletonGenerator_CDriverSkeletonGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.cpp b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d40155d773162d67ce6191cf9e4c3cc2b92ac6e --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.cpp @@ -0,0 +1,344 @@ +#include "ovsgCSkeletonGenerator.h" + +#include <string> +#include <cstdlib> +#include <ctime> +#include <sstream> + +using namespace std; +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBESkeletonGenerator; + +CSkeletonGenerator::CSkeletonGenerator(IKernelContext & rKernelContext, ::GtkBuilder * pBuilderInterface) + :m_rKernelContext(rKernelContext) + ,m_pBuilderInterface(pBuilderInterface) + ,m_bConfigurationFileLoaded(false) +{ + m_sConfigurationFile = m_rKernelContext.getConfigurationManager().expand("${CustomConfigurationApplication}"); + m_rKernelContext.getLogManager() << LogLevel_Trace << "Configuration file [" << m_sConfigurationFile << "]\n"; + loadCommonParameters(m_sConfigurationFile); +} + +CSkeletonGenerator::~CSkeletonGenerator(void) +{ +} + +void CSkeletonGenerator::getCommonParameters() +{ + //Author and Company + ::GtkWidget* l_pEntryCompany = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_company_name")); + m_sCompany = gtk_entry_get_text(GTK_ENTRY(l_pEntryCompany)); + + ::GtkWidget* l_pEntryAuthor = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_author_name")); + m_sAuthor=gtk_entry_get_text(GTK_ENTRY(l_pEntryAuthor)); + +} + +boolean CSkeletonGenerator::saveCommonParameters(CString sFileName) +{ + // we get the latest values + getCommonParameters(); + + FILE* l_pFile=::fopen(sFileName.toASCIIString(), "ab"); + if(!l_pFile) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Saving the common entries in [" << sFileName << "] failed !\n"; + return false; + } + + // generator selected + CString l_sActive; + ::GtkWidget* l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-selection-radio-button")); + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pWidget))) + { + l_sActive = "0"; + } + l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-algo-selection-radio-button")); + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pWidget))) + { + l_sActive = "1"; + } + l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-selection-radio-button")); + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pWidget))) + { + l_sActive = "2"; + } + + ::fprintf(l_pFile, "SkeletonGenerator_GeneratorSelected = %s\n", l_sActive.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Common_Author = %s\n", m_sAuthor.toASCIIString()); + ::fprintf(l_pFile, "SkeletonGenerator_Common_Company = %s\n", m_sCompany.toASCIIString()); + ::fclose(l_pFile); + m_rKernelContext.getLogManager() << LogLevel_Info << "Common entries saved in [" << sFileName << "]\n"; + + //we can reload the file, it may have changed + m_bConfigurationFileLoaded = false; + + return true; +} + +boolean CSkeletonGenerator::cleanConfigurationFile(CString sFileName) +{ + FILE* l_pFile=::fopen(sFileName.toASCIIString(), "wb"); + if(!l_pFile) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Failed to clean [" << sFileName << "]\n"; + return false; + } + + m_rKernelContext.getLogManager() << LogLevel_Info << "Configuration file [" << sFileName << "] cleaned.\n"; + ::fclose(l_pFile); + return true; +} + +boolean CSkeletonGenerator::loadCommonParameters(CString sFileName) +{ + if(!m_bConfigurationFileLoaded && !m_rKernelContext.getConfigurationManager().addConfigurationFromFile(sFileName)) + { + m_rKernelContext.getLogManager() << LogLevel_Warning << "Common: Configuration file [" << sFileName << "] could not be loaded. \n"; + return false; + } + + ::GtkWidget* l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-driver-selection-radio-button")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pWidget), (m_rKernelContext.getConfigurationManager().expandAsUInteger("${SkeletonGenerator_GeneratorSelected}") == 0)); + l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-algo-selection-radio-button")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pWidget), (m_rKernelContext.getConfigurationManager().expandAsUInteger("${SkeletonGenerator_GeneratorSelected}") == 1)); + l_pWidget = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "sg-box-selection-radio-button")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pWidget), (m_rKernelContext.getConfigurationManager().expandAsUInteger("${SkeletonGenerator_GeneratorSelected}") == 2)); + + ::GtkWidget* l_pEntryCompany = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_company_name")); + gtk_entry_set_text(GTK_ENTRY(l_pEntryCompany),m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Common_Company}")); + + ::GtkWidget * l_pEntryAuthorName = GTK_WIDGET(gtk_builder_get_object(m_pBuilderInterface, "entry_author_name")); + gtk_entry_set_text(GTK_ENTRY(l_pEntryAuthorName),m_rKernelContext.getConfigurationManager().expand("${SkeletonGenerator_Common_Author}")); + + m_rKernelContext.getLogManager() << LogLevel_Info << "Common entries from [" << sFileName << "] loaded.\n"; + + m_bConfigurationFileLoaded = true; + + return true; +} + +CString CSkeletonGenerator::ensureSedCompliancy(CString sExpression) +{ + string l_sExpression((const char*)sExpression); + string::iterator it=l_sExpression.begin(); + while(it<l_sExpression.end()) + { + if((*it)=='\\') + { + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; +#ifdef TARGET_OS_Linux + it = l_sExpression.insert(it,'\\'); + it = l_sExpression.insert(it,'\\'); + it+=2; + it = l_sExpression.insert(it,'\\'); + it = l_sExpression.insert(it,'\\'); + it+=2; +#endif + } + else if((*it)=='/') + { + it = l_sExpression.insert(it,'\\'); + it++; + } + else if((*it)=='"') + { + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; + it = l_sExpression.insert(it,'\\'); + it++; + } + else if((*it)=='\n') + { + it = l_sExpression.erase(it); +#ifdef TARGET_OS_Linux + it = l_sExpression.insert(it,'\\'); + it = l_sExpression.insert(it,'\\'); + it+=2; +#endif + it = l_sExpression.insert(it,'\\'); + it = l_sExpression.insert(it,'\\'); + it+=2; + it = l_sExpression.insert(it,'n'); + //it++; + } + it++; + } + + return CString(l_sExpression.c_str()); +} + +boolean CSkeletonGenerator::executeSedCommand(CString sTemplateFile, CString sCommand, CString sDestinationFile) +{ + CString l_sSed; + CString l_sMove; + CString l_sNull; +#ifdef TARGET_OS_Windows + l_sSed = "..\\share\\openvibe-applications\\skeleton-generator\\sed"; + l_sMove = "move"; + l_sNull = "NULL"; +#else +#ifdef TARGET_OS_Linux + l_sSed = "sed"; + l_sMove = "mv"; + l_sNull = "/dev/null"; +#endif +#endif + + boolean l_bSuccess = false; + + CString l_sCommandSed = l_sSed + " \"" + sCommand+"\" \"" + sTemplateFile + "\""; + if(string(sDestinationFile) != string("")) + { + l_sCommandSed = l_sCommandSed + " > \"" + sDestinationFile + "\""; + l_bSuccess = (system(((string)l_sCommandSed).c_str()) == 0); + } + else + { + l_sCommandSed = l_sCommandSed + " > tmp-sed"; + l_bSuccess = (system(l_sCommandSed) == 0); + CString l_sMoveCommand = l_sMove + " tmp-sed \"" + sTemplateFile + "\" >> "+l_sNull; + l_bSuccess &= (system(l_sMoveCommand) == 0); + m_rKernelContext.getLogManager() << LogLevel_Trace << " -- Move command : [" << l_sMoveCommand << "]\n"; + } + + l_bSuccess = (system(((string)l_sCommandSed).c_str()) == 0); + + if(l_bSuccess) + { + m_rKernelContext.getLogManager() << LogLevel_Trace << " -- Sed command successfully called : [" << l_sCommandSed << "]\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Error << " -- Faulty substitution command : [" << l_sCommandSed <<"]\n"; + } + + return l_bSuccess; + +} + +boolean CSkeletonGenerator::executeSedSubstitution(CString sTemplateFile, CString sTag, CString sSubstitute, CString sDestinationFile) +{ + CString l_sSed; + CString l_sMove; + CString l_sNull; +#ifdef TARGET_OS_Windows + l_sSed = "..\\share\\openvibe-applications\\skeleton-generator\\sed"; + l_sMove = "move"; + l_sNull = "NULL"; +#else +#ifdef TARGET_OS_Linux + l_sSed = "sed"; + l_sMove = "mv"; + l_sNull = "/dev/null"; +#endif +#endif + + boolean l_bSuccess = false; + + CString l_sSubstitute = ensureSedCompliancy(sSubstitute); + + CString l_sCommandSed = l_sSed + " \"s/" + sTag + "/" + l_sSubstitute+ "/g\" \"" + sTemplateFile + "\""; + if(string(sDestinationFile) != string("")) + { + l_sCommandSed = l_sCommandSed + " > \"" + sDestinationFile + "\""; + l_bSuccess = (system(((string)l_sCommandSed).c_str()) == 0); + } + else + { + l_sCommandSed = l_sCommandSed + " > tmp-sed"; + l_bSuccess = (system(l_sCommandSed) == 0); + CString l_sMoveCommand = l_sMove + " tmp-sed \"" + sTemplateFile + "\" >> "+l_sNull; + l_bSuccess &= (system(l_sMoveCommand) == 0); + m_rKernelContext.getLogManager() << LogLevel_Trace << " -- Move command : [" << l_sMoveCommand << "]\n"; +#ifdef TARGET_OS_Windows + l_bSuccess &= (system("del NULL") == 0); +#endif + } + + if(l_bSuccess) + { + m_rKernelContext.getLogManager() << LogLevel_Trace << " -- Sed command successfully called : [" << l_sCommandSed << "]\n"; + } + else + { + m_rKernelContext.getLogManager() << LogLevel_Error << " -- Faulty substitution command : [" << l_sCommandSed <<"]\n"; + } + + return l_bSuccess; +} + +CString CSkeletonGenerator::getDate() +{ + time_t rawtime; + struct tm * timeinfo; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + stringstream ssTime; + string string_time(asctime (timeinfo)); + string_time = string_time.substr(0,string_time.size()-1); // the ascitime ends with a "\n" + CString l_sDate(string_time.c_str()); + + return l_sDate; +} + +boolean CSkeletonGenerator::generate(CString sTemplateFile, CString sDestinationFile, map<CString,CString> mSubstitutions, CString& rLog) +{ + // we check if the template file is in place. + if(! g_file_test(sTemplateFile, G_FILE_TEST_EXISTS)) + { + rLog = rLog + "[FAILED] the template file '"+sTemplateFile+"' is missing.\n"; + m_rKernelContext.getLogManager() << LogLevel_Error << "The template file '"<<sTemplateFile<<"' is missing.\n"; + return false; + } + + // we check the map + if(mSubstitutions.size() == 0) + { + rLog = rLog + "[WARNING] No substitution provided.\n"; + m_rKernelContext.getLogManager() << LogLevel_Warning << "No substitution provided.\n"; + return false; + } + + boolean l_bSuccess = true; + + rLog = rLog + "[ OK ] -- template file '"+sTemplateFile+"' found.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << " -- template file '" << sTemplateFile << "' found.\n"; + + //we need to create the destination file by copying the template file, then do the first substitution + map<CString,CString>::const_iterator it = mSubstitutions.begin(); + l_bSuccess &= executeSedSubstitution(sTemplateFile, it->first, it->second, sDestinationFile); + it++; + + //next substitutions are done on the - incomplete - destination file itself + while(it != mSubstitutions.end() && l_bSuccess) + { + m_rKernelContext.getLogManager() << LogLevel_Trace << "Executing substitution ["<<it->first<<"] ->["<<it->second<<"]\n"; + l_bSuccess &= executeSedSubstitution(sDestinationFile, it->first, it->second); + it++; + } + + if(! l_bSuccess) + { + rLog = rLog + "[FAILED] -- " + sDestinationFile + " cannot be written.\n"; + m_rKernelContext.getLogManager() << LogLevel_Error << " -- " << sDestinationFile << " cannot be written.\n"; + return false; + + } + + rLog = rLog + "[ OK ] -- " + sDestinationFile + " written.\n"; + m_rKernelContext.getLogManager() << LogLevel_Info << " -- " << sDestinationFile << " written.\n"; + return true; +} diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.h b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.h new file mode 100644 index 0000000000000000000000000000000000000000..1b1b23e19cfae49d6e56b5fc47d9a4c13395a5dd --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsgCSkeletonGenerator.h @@ -0,0 +1,64 @@ +#ifndef __OpenViBESkeletonGenerator_CSkeletonGenerator_H__ +#define __OpenViBESkeletonGenerator_CSkeletonGenerator_H__ + +#include <ov_all.h> +#include <ovtk_all.h> +//#include <configuration/ovkCConfigurationManager.h> + +#include <gtk/gtk.h> +#include <gdk/gdk.h> + +#include <map> + +namespace OpenViBESkeletonGenerator +{ + class CSkeletonGenerator + { + public: + + CSkeletonGenerator(OpenViBE::Kernel::IKernelContext & rKernelContext, ::GtkBuilder * pBuilderInterface); + virtual ~CSkeletonGenerator(void); + + protected: + OpenViBE::Kernel::IKernelContext &m_rKernelContext; + + ::GtkBuilder * m_pBuilderInterface; + + OpenViBE::CString m_sAuthor; + OpenViBE::CString m_sCompany; + OpenViBE::CString m_sTargetDirectory; + + virtual OpenViBE::boolean initialize(void)=0; + + OpenViBE::CString m_sConfigurationFile; // basic application config file + OpenViBE::boolean m_bConfigurationFileLoaded; + + void getCommonParameters(void); + OpenViBE::boolean saveCommonParameters(OpenViBE::CString sFileName); + OpenViBE::boolean loadCommonParameters(OpenViBE::CString sFileName); + + OpenViBE::boolean cleanConfigurationFile(OpenViBE::CString sFileName); + + // returns a sed-compliant expression to be parsed in a substitution command + OpenViBE::CString ensureSedCompliancy(OpenViBE::CString sExpression); + // executes a sed command and build a new file, no verification is made. If no destination file is provided, the template file is modified. + OpenViBE::boolean executeSedCommand(OpenViBE::CString sTemplateFile, OpenViBE::CString sCommand, OpenViBE::CString sDestinationFile = OpenViBE::CString("")); + // executes a sed substitution and build a new file, by replacing the tag by the substitute. Sed-compliancy is verified. If no destination file is provided, the template file is modified. + OpenViBE::boolean executeSedSubstitution(OpenViBE::CString sTemplateFile, OpenViBE::CString sTag, OpenViBE::CString sSubstitute, OpenViBE::CString sDestinationFile = OpenViBE::CString("")); + // get the formated string date + OpenViBE::CString getDate(); + + // generate a new file, giving a template file, a destination file, and a map ofsubstitutions (Tag,Substitute) + // return false if an error occured. + OpenViBE::boolean generate(OpenViBE::CString sTemplateFile, OpenViBE::CString sDestinationFile, std::map<OpenViBE::CString,OpenViBE::CString> mSubstitutions, OpenViBE::CString& rLog); + + virtual void getCurrentParameters(void) = 0; + virtual OpenViBE::boolean save(OpenViBE::CString sFileName) = 0; + virtual OpenViBE::boolean load(OpenViBE::CString sFileName) = 0; + + + }; + +} + +#endif //__OpenViBESkeletonGenerator_CSkeletonGenerator_H__ diff --git a/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsg_main.cpp b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsg_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43fa9e299668196ce652afe2bdcdb0199009a3eb --- /dev/null +++ b/trunk2/core/applications/developer-tools/skeleton-generator/src/ovsg_main.cpp @@ -0,0 +1,119 @@ +#include <gtk/gtk.h> +#include <gdk/gdk.h> + +#include <iostream> + +#include "ovsgCDriverSkeletonGenerator.h" +#include "ovsgCBoxAlgorithmSkeletonGenerator.h" + +using namespace OpenViBE; +using namespace OpenViBE::Kernel; +using namespace OpenViBESkeletonGenerator; + +using namespace std; + +int main(int argc, char** argv) +{ + + CKernelLoader l_oKernelLoader; + + cout<<"[ INF ] Created kernel loader, trying to load kernel module"<<endl; + CString l_sError; +#if defined TARGET_OS_Windows + CString l_sKernelFile = OpenViBE::Directories::getLibDir() + "/openvibe-kernel.dll"; +#else + CString l_sKernelFile = OpenViBE::Directories::getLibDir() + "/libopenvibe-kernel.so"; +#endif + if(!l_oKernelLoader.load(l_sKernelFile, &l_sError)) + { + cout<<"[ FAILED ] Error loading kernel ("<<l_sError<<")" << " from [" << l_sKernelFile << "]\n"; + } + else + { + cout<<"[ INF ] Kernel module loaded, trying to get kernel descriptor"<<endl; + IKernelDesc* l_pKernelDesc=NULL; + IKernelContext* l_pKernelContext=NULL; + l_oKernelLoader.initialize(); + l_oKernelLoader.getKernelDesc(l_pKernelDesc); + if(!l_pKernelDesc) + { + cout<<"[ FAILED ] No kernel descriptor"<<endl; + } + else + { + cout<<"[ INF ] Got kernel descriptor, trying to create kernel"<<endl; + l_pKernelContext=l_pKernelDesc->createKernel("skeleton-generator", OpenViBE::Directories::getDataDir() + "/openvibe.conf"); + if(!l_pKernelContext) + { + cout<<"[ FAILED ] No kernel created by kernel descriptor"<<endl; + } + else + { + OpenViBEToolkit::initialize(*l_pKernelContext); + IConfigurationManager& l_rConfigurationManager=l_pKernelContext->getConfigurationManager(); + l_pKernelContext->getPluginManager().addPluginsFromFiles(l_rConfigurationManager.expand("${Kernel_Plugins}")); + + gtk_init(&argc, &argv); + + ::GtkBuilder * l_pBuilderInterface = gtk_builder_new(); + const OpenViBE::CString l_sFilename = OpenViBE::Directories::getDataDir() + "/applications/skeleton-generator/generator-interface.ui"; + if(!gtk_builder_add_from_file(l_pBuilderInterface, l_sFilename, NULL)) + { + std::cout << "Problem loading [" << l_sFilename << "]\n"; + return -1; + } + + //gtk_builder_connect_signals(l_pBuilderInterface, NULL); + + ::GtkWidget * l_pDialog = GTK_WIDGET(gtk_builder_get_object(l_pBuilderInterface, "sg-selection-dialog")); + + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_OK, + GTK_RESPONSE_OK); + + gtk_dialog_add_button (GTK_DIALOG (l_pDialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + + ::GtkWidget * l_pRadioDriver = GTK_WIDGET(gtk_builder_get_object(l_pBuilderInterface, "sg-driver-selection-radio-button")); + ::GtkWidget * l_pRadioAlgo = GTK_WIDGET(gtk_builder_get_object(l_pBuilderInterface, "sg-algo-selection-radio-button")); + ::GtkWidget * l_pRadioBox = GTK_WIDGET(gtk_builder_get_object(l_pBuilderInterface, "sg-box-selection-radio-button")); + + + CBoxAlgorithmSkeletonGenerator l_BoxGenerator(*l_pKernelContext,l_pBuilderInterface); + CDriverSkeletonGenerator l_DriverGenerator(*l_pKernelContext,l_pBuilderInterface); + + gint resp = gtk_dialog_run(GTK_DIALOG(l_pDialog)); + + if(resp== GTK_RESPONSE_OK) + { + gtk_widget_hide(GTK_WIDGET(l_pDialog)); + + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pRadioDriver))) + { + l_DriverGenerator.initialize(); + } + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pRadioAlgo))) + { + std::cout<< "NOT YET AVAILABLE." <<std::endl; + return 0; + } + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pRadioBox))) + { + l_BoxGenerator.initialize(); + } + gtk_main(); + } + else + { + std::cout<< "User cancelled. Exit." <<std::endl; + return 0 ; + } + } + } + } + + l_oKernelLoader.uninitialize(); + l_oKernelLoader.unload(); + return 0; +} diff --git a/trunk2/core/applications/developer-tools/vrpn-simulator/CMakeLists.txt b/trunk2/core/applications/developer-tools/vrpn-simulator/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0c385a704b76cb822ec9c3bc0f2473286fff09eb --- /dev/null +++ b/trunk2/core/applications/developer-tools/vrpn-simulator/CMakeLists.txt @@ -0,0 +1,73 @@ +PROJECT(openvibe-vrpn-simulator) + +SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR}) +SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR}) +SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH}) +SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +INCLUDE("FindThirdPartyVRPN_Check") +IF(NOT PATH_VRPN) + MESSAGE(STATUS " --> Not building ${PROJECT_NAME}") + RETURN() +ENDIF(NOT PATH_VRPN) + +FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl) +ADD_EXECUTABLE(${PROJECT_NAME} ${source_files}) + +INCLUDE("FindOpenViBE") +INCLUDE("FindOpenViBECommon") +INCLUDE("FindThirdPartyGTK") +INCLUDE("FindThirdPartyVRPN") + +# --------------------------------- +# Finds standard library pthread +# Adds library to target +# Adds include path +# --------------------------------- +IF(UNIX) + FIND_LIBRARY(LIB_STANDARD_MODULE_PTHREAD pthread) + IF(LIB_STANDARD_MODULE_PTHREAD) + MESSAGE(STATUS " Found pthread...") + TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_PTHREAD}) + ELSE(LIB_STANDARD_MODULE_PTHREAD) + MESSAGE(STATUS " FAILED to find pthread...") + ENDIF(LIB_STANDARD_MODULE_PTHREAD) +ENDIF(UNIX) + +# --------------------------------- +# Target macros +# Defines target operating system +# Defines target architecture +# Defines target compiler +# --------------------------------- +IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-DTARGET_OS_Windows) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio) +ENDIF(WIN32) +IF(UNIX) + # ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc + ADD_DEFINITIONS(-g) + ADD_DEFINITIONS(-fnon-call-exceptions) + ADD_DEFINITIONS(-DTARGET_OS_Linux) + ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386) + ADD_DEFINITIONS(-DTARGET_COMPILER_GCC) +ENDIF(UNIX) + +# ---------------------- +# Generate launch script +# ---------------------- +OV_INSTALL_LAUNCH_SCRIPT("openvibe-vrpn-simulator") + +# ----------------------------- +# Install files +# ----------------------------- +INSTALL(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) + +INSTALL(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications/vrpn-simulator PATTERN ".svn" EXCLUDE) + +#INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "doc" EXCLUDE) diff --git a/trunk2/core/applications/developer-tools/vrpn-simulator/share/interface.ui b/trunk2/core/applications/developer-tools/vrpn-simulator/share/interface.ui new file mode 100644 index 0000000000000000000000000000000000000000..ca17683c92eb4ffccc720293693b00a64c211f6c --- /dev/null +++ b/trunk2/core/applications/developer-tools/vrpn-simulator/share/interface.ui @@ -0,0 +1,293 @@ +<?xml version="1.0"?> +<interface> + <!-- interface-requires gtk+ 2.12 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment5"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment6"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment7"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment8"> + <property name="lower">-100</property> + <property name="upper">100</property> + <property name="step_increment">0.01</property> + <property name="page_increment">1</property> + </object> + <object class="GtkWindow" id="window"> + <child> + <object class="GtkVBox" id="vbox"> + <property name="visible">True</property> + <child> + <object class="GtkHBox" id="hbox_analog"> + <property name="visible">True</property> + <child> + <object class="GtkVScale" id="vscale_0"> + <property name="height_request">256</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment1</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment2</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment3</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment4</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment5</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_5"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment6</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_6"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment7</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="vscale_7"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment8</property> + <property name="inverted">True</property> + </object> + <packing> + <property name="position">7</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox_button"> + <property name="visible">True</property> + <child> + <object class="GtkToggleButton" id="togglebutton_0"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image4"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_5"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image5"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_6"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image6"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="togglebutton_7"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="image7"> + <property name="visible">True</property> + <property name="stock">gtk-about</property> + </object> + </child> + </object> + <packing> + <property name="position">7</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/trunk2/core/applications/developer-tools/vrpn-simulator/src/ova_main.cpp b/trunk2/core/applications/developer-tools/vrpn-simulator/src/ova_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..39b3e1707abe54f586fe268e74d111371f891f50 --- /dev/null +++ b/trunk2/core/applications/developer-tools/vrpn-simulator/src/ova_main.cpp @@ -0,0 +1,127 @@ +#if defined TARGET_HAS_ThirdPartyVRPN + +#include <gtk/gtk.h> + +#include <gdk/gdk.h> + +#include <ov_directories.h> +#include <ovCString.h> + +#include <vrpn_Button.h> +#include <vrpn_Analog.h> +#include <vrpn_Connection.h> + +#include <iostream> + +#define _vrpn_peripheral_name_ "openvibe-vrpn@localhost" + +// #define _DEBUG + +::vrpn_Connection* g_pConnection=NULL; +::vrpn_Button_Server* g_pButtonServer=NULL; +::vrpn_Analog_Server* g_pAnalogServer=NULL; +long g_iAnalogCount=0; +long g_iButtonCount=0; + +typedef union +{ + gpointer pUserData; + int iData; +} TUserData; + +void fScrollCB(::GtkRange* pRange, gpointer pUserData) +{ + TUserData l_oUserData; + l_oUserData.pUserData=pUserData; + gdouble l_oNewValue = gtk_range_get_value(pRange); + g_pAnalogServer->channels()[l_oUserData.iData]=l_oNewValue; + +#if defined _DEBUG + std::cout << "Channel " << (int)(pUserData) << " value changed to " << l_oNewValue << "\n"; +#endif +} + +void fSwitchCB(::GtkToggleButton* pTogglebutton, gpointer pUserData) +{ + TUserData l_oUserData; + l_oUserData.pUserData=pUserData; + gboolean l_bToggleValue = gtk_toggle_button_get_active(pTogglebutton); + g_pButtonServer->set_button(l_oUserData.iData, l_bToggleValue); + +#if defined _DEBUG + std::cout << "Channel " << (int)(l_oUserData.iData) << " toggled to " << l_bToggleValue << "\n"; +#endif +} + +void fConnectCB(::GtkWidget* pWidget, gpointer data) +{ + if(GTK_IS_RANGE(pWidget)) + { + g_signal_connect(G_OBJECT(pWidget), "value-changed", G_CALLBACK(fScrollCB), (gpointer) g_iAnalogCount); + g_iAnalogCount++; + } + + if(GTK_IS_TOGGLE_BUTTON(pWidget)) + { + g_signal_connect(G_OBJECT(pWidget), "toggled", G_CALLBACK(fSwitchCB), (void*)g_iButtonCount); + g_iButtonCount++; + } +} + +gboolean fIdleApplicationLoop(gpointer pUserData) +{ + g_pButtonServer->mainloop(); + g_pAnalogServer->report_changes(); + g_pAnalogServer->mainloop(); + g_pConnection->mainloop(); + return TRUE; +} + +#endif // TARGET_HAS_ThirdPartyVRPN + +int main(int argc, char ** argv) +{ +#if defined TARGET_HAS_ThirdPartyVRPN + const int l_nChannels = 8; + + gtk_init(&argc, &argv); + // g_pConnection=new ::vrpn_Connection; + g_pConnection=vrpn_create_server_connection(); + g_pButtonServer=new ::vrpn_Button_Server(_vrpn_peripheral_name_, g_pConnection, l_nChannels); + g_pAnalogServer=new ::vrpn_Analog_Server(_vrpn_peripheral_name_, g_pConnection, l_nChannels); + + ::GtkBuilder* l_pInterface=gtk_builder_new(); // glade_xml_new(OpenViBE::Directories::getDataDir() + "/openvibe-applications/vrpn-simulator/interface.ui", "window", NULL); + const OpenViBE::CString l_sFilename = OpenViBE::Directories::getDataDir() + "/applications/vrpn-simulator/interface.ui"; + if(!gtk_builder_add_from_file(l_pInterface, l_sFilename, NULL)) { + std::cout << "Problem loading [" << l_sFilename << "]\n"; + return -1; + } + + ::GtkWidget* l_pMainWindow=GTK_WIDGET(gtk_builder_get_object(l_pInterface, "window")); + ::GtkWidget* l_pHBoxButton=GTK_WIDGET(gtk_builder_get_object(l_pInterface, "hbox_button")); + ::GtkWidget* l_pHBoxAnalog=GTK_WIDGET(gtk_builder_get_object(l_pInterface, "hbox_analog")); + + g_signal_connect(G_OBJECT(l_pMainWindow), "destroy", gtk_main_quit, NULL); + gtk_container_foreach(GTK_CONTAINER(l_pHBoxButton), fConnectCB, NULL); + gtk_container_foreach(GTK_CONTAINER(l_pHBoxAnalog), fConnectCB, NULL); + gtk_builder_connect_signals(l_pInterface, NULL); + + std::cout << "VRPN Stimulator\n"; + std::cout << "Got " << g_iAnalogCount << " analogs...\n"; + std::cout << "Got " << g_iButtonCount << " buttons...\n"; + std::cout << "Using " << l_nChannels << " VRPN channels...\n"; + std::cout << "Signals will be sent to peripheral [" << _vrpn_peripheral_name_ << "]\n"; + + g_idle_add(fIdleApplicationLoop, NULL); + + gtk_widget_show(l_pMainWindow); + gtk_main(); + + delete g_pAnalogServer; + delete g_pButtonServer; + delete g_pConnection; + +#endif // TARGET_HAS_ThirdPartyVRPN + return 0; +} + diff --git a/trunk2/core/applications/platform/acquisition-server/CMakeLists.txt b/trunk2/core/applications/platform/acquisition-server/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/trunk2/core/applications/platform/acquisition-server/CMakeLists.txt @@ -0,0 +1 @@ +