diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl index 78bd3636d2e..ed6ba6c2411 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl @@ -131,6 +131,11 @@ template void FixedProjectiveConstraint::checkIndices() { // Check value of given indices + if (!this->mstate.get()) + { + msg_warning() << "Missing mstate, cannot check indices .!"; + return; + } Index maxIndex=this->mstate->getSize(); const SetIndexArray & indices = d_indices.getValue(); diff --git a/Sofa/GUI/Qt/src/sofa/gui/qt/DataWidget.cpp b/Sofa/GUI/Qt/src/sofa/gui/qt/DataWidget.cpp index c51dbb3040f..8b66300d7ee 100644 --- a/Sofa/GUI/Qt/src/sofa/gui/qt/DataWidget.cpp +++ b/Sofa/GUI/Qt/src/sofa/gui/qt/DataWidget.cpp @@ -52,6 +52,8 @@ DataWidget::DataWidget(QWidget* parent,const char* name, MyData* d) , m_toFill(false) { this->setObjectName(name); + + } DataWidget::~DataWidget() @@ -211,23 +213,26 @@ QDisplayDataInfoWidget::QDisplayDataInfoWidget(QWidget* parent, const std::strin if (!ownerClass.empty()) helper_button->setToolTip( ("Data from "+ownerClass).c_str()); } + + linkpath_edit = new QLineEdit(this); + linkpath_edit->setContentsMargins(2, 0, 0, 0); + linkpath_edit->setReadOnly(!modifiable); + layout->addWidget(linkpath_edit); + if(modifyObjectFlags.PROPERTY_WIDGET_FLAG) + connect(linkpath_edit, &QLineEdit::textChanged, [=](){ WidgetDirty(); }); + else + connect(linkpath_edit, &QLineEdit::editingFinished, this, &QDisplayDataInfoWidget::linkEdited); + if(data->getParent()) { const std::string linkvalue = data->getParent()->getLinkPath(); - linkpath_edit = new QLineEdit(this); - linkpath_edit->setContentsMargins(2, 0, 0, 0); linkpath_edit->setText(QString(linkvalue.c_str())); - linkpath_edit->setReadOnly(!modifiable); - layout->addWidget(linkpath_edit); linkpath_edit->setVisible(!linkvalue.empty()); - if(modifyObjectFlags.PROPERTY_WIDGET_FLAG) - connect(linkpath_edit, &QLineEdit::textChanged, [=](){ WidgetDirty(); }); - else - connect(linkpath_edit, &QLineEdit::editingFinished, this, &QDisplayDataInfoWidget::linkEdited); } else { - linkpath_edit=nullptr; + linkpath_edit->setText(""); + linkpath_edit->setVisible(false); } } diff --git a/Sofa/GUI/Qt/src/sofa/gui/qt/SofaSceneGraphWidget.h b/Sofa/GUI/Qt/src/sofa/gui/qt/SofaSceneGraphWidget.h index 9eda652c557..74aa191fe8b 100644 --- a/Sofa/GUI/Qt/src/sofa/gui/qt/SofaSceneGraphWidget.h +++ b/Sofa/GUI/Qt/src/sofa/gui/qt/SofaSceneGraphWidget.h @@ -81,7 +81,10 @@ class SOFA_GUI_QT_API SofaSceneGraphWidget : public QTreeWidget { Q_OBJECT public: - SofaSceneGraphWidget(QWidget* parent) : QTreeWidget(parent){} + SofaSceneGraphWidget(QWidget* parent) : QTreeWidget(parent) + { + m_isLocked = false; + } ~SofaSceneGraphWidget(){} void lock(); diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/AspectPool.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/AspectPool.cpp index a973c544b7b..ad313e4e4da 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/AspectPool.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/AspectPool.cpp @@ -24,8 +24,13 @@ #include #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { /** @@ -220,8 +225,8 @@ bool AspectBuffer::pop(AspectRef& id) return true; } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.cpp index df738d145a1..6c9983e165f 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.cpp @@ -637,17 +637,32 @@ void Base::writeDatas (std::ostream& out, const std::string& separator) for(VecData::const_iterator iData = m_vecData.begin(); iData != m_vecData.end(); ++iData) { const BaseData* field = *iData; - if (!field->getLinkPath().empty() ) + + if (field->getParent()) { - out << separator << field->getName() << "=\""<< xmlencode(field->getLinkPath()) << "\" "; +// out << separator << field->getName() << "=\"" << xmlencode(field->getLinkPath()) << "\" "; + std::string linkPath = field->getParent()->getLinkPath(); + if(!linkPath.empty()) + out << separator << field->getName() << "=\"" << xmlencode(linkPath) << "\" "; } else { - if(field->isPersistent() && field->isSet()) + std::string val = field->getValueString(); + std::string fieldname = field->getName(); + bool isFullTrim = false; + bool isset = field->isSet(); + if(isset && fieldname != "parents") { - std::string val = field->getValueString(); - if (!val.empty()) - out << separator << field->getName() << "=\""<< xmlencode(val) << "\" "; + std::string checkSpace = field->getValueString(); + checkSpace.erase(remove_if(checkSpace.begin(), checkSpace.end(), isspace), checkSpace.end()); + if(checkSpace.empty()) + { + isFullTrim = true; + } + if (!val.empty() && !isFullTrim) + { + out << separator << fieldname << "=\""<< xmlencode(val) << "\" "; + } } } } @@ -657,8 +672,10 @@ void Base::writeDatas (std::ostream& out, const std::string& separator) if(link->storePath()) { std::string val = link->getValueString(); - if (!val.empty()) + if (!val.empty() && link->getName() != "parents") + { out << separator << link->getName() << "=\""<< xmlencode(val) << "\" "; + } } } } diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.cpp index e05f2d9b5c4..aa4b374e0b3 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.cpp @@ -21,8 +21,13 @@ ******************************************************************************/ #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { BaseClass* DeprecatedBaseClass::GetSingleton() @@ -49,9 +54,9 @@ DeprecatedBaseClass::DeprecatedBaseClass() } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp index 3d16511118f..0a4f2890807 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp @@ -137,8 +137,20 @@ bool BaseData::setParent(BaseData* parent, const std::string& path) std::string BaseData::getLinkPath() const { - if(m_owner) - return "@"+m_owner->getPathName()+"."+getName(); +// std::string ownerPathName = m_owner->getPathName(); +// bool isStrFine = false; +// for(unsigned int i=0 ; i < ownerPathName.length() ; i++) +// { +// if(ownerPathName[i] != '/') +// { +// isStrFine = true; +// } +// } + if(m_owner /*&& ownerPathName != "/"*/) + { + std::string linkPathStr = "@"+m_owner->getPathName()+"."+getName(); + return linkPathStr; + } return ""; } @@ -158,9 +170,9 @@ void BaseData::doDelInput(DDGNode* n) void BaseData::update() { cleanDirty(); - for (DDGNode* input : inputs) + for(DDGLinkIterator it=inputs.begin(); it!=inputs.end(); ++it) { - input->updateIfDirty(); + (*it)->updateIfDirty(); } /// Check if there is a parent (so a predecessor in the DDG), if so @@ -168,6 +180,10 @@ void BaseData::update() const auto parent = parentData.resolvePathAndGetTarget(); if (parent) { +#ifdef SOFA_DDG_TRACE + if (m_owner) + dmsg_warning(m_owner) << "Data " << m_name << ": update from parent " << parentBaseData->m_name; +#endif updateValueFromLink(parent); // If the value is dirty clean it if(this->isDirty()) diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h index aaef1b3abe3..d784e3c7b96 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h @@ -272,7 +272,7 @@ class SOFA_CORE_API BaseData : public DDGNode /// True if this %Data is set, i.e. its value is different from the default value bool m_isSet; /// Flags indicating the purpose and behaviour of this %Data - DataFlags m_dataFlags; + DataFlags m_dataFlags = FLAG_PERSISTENT; /// Return the Base component owning this %Data Base* m_owner {nullptr}; /// Data name within the Base component diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.cpp index 91d4001ec10..70068215d21 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.cpp @@ -26,8 +26,13 @@ #include #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { BaseNode::BaseNode() @@ -94,6 +99,15 @@ std::string BaseNode::internalGetPathName() const { // no smarter choice without breaking the "Node" heritage str = parents[0]->internalGetPathName(); str += '/'; +// bool strIsFine = false; +// for(unsigned int i=0 ; i < str.length() ; i++) +// { +// if(str[i] != '/') +// { +// strIsFine = true; +// } +// } +// if(strIsFine) str += getName(); } return str; @@ -116,8 +130,8 @@ std::string BaseNode::getRootPath() const { return str; } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp index c0d94dff970..c0b62abab22 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp @@ -29,7 +29,13 @@ #include -namespace sofa::core::objectmodel +namespace sofa +{ + +namespace core +{ + +namespace objectmodel { BaseObject::BaseObject() @@ -363,13 +369,22 @@ std::string BaseObject::getPathName() const { } } +// bool strIsFine = false; +// for(unsigned int i=0 ; i < result.length() ; i++) +// { +// if(result[i] != '/') +// { +// strIsFine = true; +// } +// } +// if(strIsFine) result += getName(); return result; } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h index 95d2b11babd..192283812ad 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h @@ -211,14 +211,14 @@ class SOFA_CORE_API BaseObject : public virtual Base public: - /// the component can insert itself directly in the right sequence in the Node - /// so the Node does not have to test its type against all known types - /// \returns true if the component was inserted + /// the component can insert itseft direclty in the right sequence in the Node + /// so the Node does not have to test its type against every known types. + /// \returns true iff the component was inserted virtual bool insertInNode( BaseNode* /*node*/ ) { return false; } - /// the component can remove itself directly in the right sequence in the Node - /// so the Node does not have to test its type against all known types - /// \returns true if the component was removed + /// the component can remove itseft direclty in the right sequence in the Node + /// so the Node does not have to test its type against every known types. + /// \returns true iff the component was removed virtual bool removeInNode( BaseNode* /*node*/ ) { return false; } }; diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/ClassInfo.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/ClassInfo.cpp index d234fbdda42..1c7459b6bb4 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/ClassInfo.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/ClassInfo.cpp @@ -21,8 +21,13 @@ ******************************************************************************/ #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { std::map ClassInfo::classes; @@ -38,9 +43,9 @@ ClassInfo::~ClassInfo() } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/ComponentState.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/ComponentState.cpp index 6b96a6765a2..6a0277b9b21 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/ComponentState.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/ComponentState.cpp @@ -24,8 +24,11 @@ #include #include - -namespace sofa::core::objectmodel +namespace sofa +{ +namespace core +{ +namespace objectmodel { @@ -60,5 +63,8 @@ std::istream& operator>>(std::istream& i, ComponentState& s) return i; } -} +} /// namespace objectmodel +} /// namespace core +} /// namespace sofa + diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/ConfigurationSetting.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/ConfigurationSetting.cpp index 7080c02c1fc..f39f2bdabfe 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/ConfigurationSetting.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/ConfigurationSetting.cpp @@ -23,8 +23,13 @@ #include #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { ConfigurationSetting::ConfigurationSetting() @@ -41,8 +46,6 @@ ConfigurationSetting::~ConfigurationSetting() void ConfigurationSetting::init() { - Inherit1::init(); - //Set all the Data in read only mode: for (VecData::const_iterator it = m_vecData.begin(); it!=m_vecData.end(); ++it) { @@ -67,8 +70,8 @@ bool ConfigurationSetting::removeInNode( objectmodel::BaseNode* node ) } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/Data.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/Data.cpp index cde0424eefa..32de378a748 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/Data.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/Data.cpp @@ -23,8 +23,13 @@ #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { /// Specialization for reading strings @@ -59,6 +64,10 @@ template class SOFA_CORE_API Data< sofa::type::vector >; template class SOFA_CORE_API Data< bool >; template class SOFA_CORE_API Data< sofa::type::vector >; -} +} // objectmodel + +} // core + +} // sofa diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/DeprecatedData.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/DeprecatedData.cpp index 5b1f42517be..139b7a14508 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/DeprecatedData.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/DeprecatedData.cpp @@ -19,6 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ +#pragma once + #include #include #include diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/DetachNodeEvent.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/DetachNodeEvent.cpp index a69cdb05310..4cdfe3f9aae 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/DetachNodeEvent.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/DetachNodeEvent.cpp @@ -21,8 +21,13 @@ ******************************************************************************/ #include +namespace sofa +{ + +namespace core +{ -namespace sofa::core::objectmodel +namespace objectmodel { SOFA_EVENT_CPP( DetachNodeEvent ) @@ -55,8 +60,8 @@ bool DetachNodeEvent::contains(BaseObject* o) const return contains(o->getContext()->toBaseNode()); } -} // namespace sofa::core::objectmodel - - +} // namespace objectmodel +} // namespace core +} // namespace sofa diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.cpp index f3c4f3d34ec..ccf220b1857 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.cpp @@ -833,6 +833,8 @@ void Node::setDefaultVisualContextValue() */ } + + void Node::initialize() { initialized = true; // flag telling is the node is initialized @@ -1001,11 +1003,13 @@ void Node::printComponents() msg_info() << sstream.str(); } -Node::SPtr Node::create( const std::string& name ) +Node::SPtr Node::create(core::objectmodel::BaseObjectDescription *arg) { if (Simulation* simulation = getSimulation()) { - return simulation->createNewNode(name); + Node::SPtr obj = simulation->createNewNode(arg->getName()); + obj->parse(arg); + return obj; } return nullptr; } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.h index 271c83e4892..5f1ad9ac083 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/Node.h @@ -515,8 +515,7 @@ class SOFA_SIMULATION_CORE_API Node : public sofa::core::objectmodel::BaseNode, template static Node::SPtr create(RealObject*, sofa::core::objectmodel::BaseObjectDescription* arg); - SOFA_ATTRIBUTE_DISABLED_NODECREATENODE() - static Node::SPtr create( const std::string& name ); + static Node::SPtr create(sofa::core::objectmodel::BaseObjectDescription* arg); /// return the smallest common parent between this and node2 (returns nullptr if separated sub-graphes) virtual Node* findCommonParent( simulation::Node* node2 ) = 0; diff --git a/applications/projects/CMakeLists.txt b/applications/projects/CMakeLists.txt index 0c85f91879a..1a858184d25 100644 --- a/applications/projects/CMakeLists.txt +++ b/applications/projects/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.22) sofa_add_subdirectory(application SceneChecking SceneChecking ON) -sofa_add_subdirectory(application Modeler Modeler OFF) +sofa_add_subdirectory(application Modeler Modeler ON) sofa_add_subdirectory(application getDeprecatedComponents getDeprecatedComponents OFF) diff --git a/applications/projects/Modeler/CMakeLists.txt b/applications/projects/Modeler/CMakeLists.txt index 2e1570f39e3..026972a526f 100644 --- a/applications/projects/Modeler/CMakeLists.txt +++ b/applications/projects/Modeler/CMakeLists.txt @@ -1,4 +1,4 @@ -message(DEPRECATION "Modeler project is deprecated") +#message(DEPRECATION "Modeler project is deprecated") add_subdirectory("lib") add_subdirectory("exec") diff --git a/applications/projects/Modeler/Modeler.ispc b/applications/projects/Modeler/Modeler.ispc new file mode 100644 index 00000000000..79da865c78a Binary files /dev/null and b/applications/projects/Modeler/Modeler.ispc differ diff --git a/applications/projects/Modeler/exec/CMakeLists.txt b/applications/projects/Modeler/exec/CMakeLists.txt index d302149da79..9740ef4a56e 100644 --- a/applications/projects/Modeler/exec/CMakeLists.txt +++ b/applications/projects/Modeler/exec/CMakeLists.txt @@ -1,22 +1,108 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.12) project(Modeler) +################################### +# Generate plugin_list.conf.default +include(cmake/GeneratePluginConfig.cmake) +if(MSVC) + # plugins are located in bin/ + set(_pluginLocation "bin") +else() + # plugins are located in lib/ + set(_pluginLocation "lib") +endif() +set(_configPluginFileName plugin_list.conf) +set(_defaultConfigPluginFileName "${_configPluginFileName}.default") +set(_defaultConfigPluginFilePath "${CMAKE_BINARY_DIR}/${_pluginLocation}/${_defaultConfigPluginFileName}") +sofa_generate_plugin_config(${_defaultConfigPluginFilePath}) +message("Write Plugin list at ${_defaultConfigPluginFilePath}") +configure_file(${_defaultConfigPluginFilePath} ${PROJECT_BINARY_DIR}/${_defaultConfigPluginFileName} COPYONLY) +install(FILES "${_defaultConfigPluginFilePath}" DESTINATION ${_pluginLocation}/ COMPONENT applications) + +################################### +set(QT_TARGETS "") + +sofa_find_package(Sofa.Component.Playback QUIET) +sofa_find_package(Sofa.Simulation.Graph REQUIRED) +sofa_find_package(Sofa.GUI.Common REQUIRED) +sofa_find_package(Sofa.GUI.Batch REQUIRED) +sofa_find_package(SceneChecking REQUIRED) +sofa_find_package(SofaComponentAll REQUIRED) + +find_package(Qt5 COMPONENTS Core QUIET) +if (NOT Qt5Core_FOUND) + if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") + find_package(Qt6 COMPONENTS Core CoreTools QUIET) + endif() +endif() + +if (Qt5Core_FOUND) + message("${PROJECT_NAME}: will use Qt5") + sofa_find_package(Qt5 COMPONENTS Core Gui OpenGL REQUIRED) + set(QT_TARGETS ${QT_TARGETS} Qt5::Core Qt5::Gui Qt5::OpenGL) +elseif (Qt6Core_FOUND) + message("${PROJECT_NAME}: will use Qt6 (beta)") + sofa_find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets REQUIRED) + set(QT_TARGETS ${QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets ) +else() + message(SEND_ERROR "${PROJECT_NAME}: Could not find either Qt5 or Qt6.") +endif() +set(SOURCE_FILES + Main.cpp + ) + +set(RESOURCE_FILES + resources/docs/runsofa.html + ${PROJECT_BINARY_DIR}/${_defaultConfigPluginFileName} + ) if(APPLE) - set(RC_FILES "../Modeler.icns") + #set(RC_FILES "../${CMAKE_CURRENT_SOURCE_DIR}/Modeler.ispc") + #set_source_files_properties(${RC_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") else() - set(RC_FILES "sofa.rc") + set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/sofa.rc") endif() -sofa_find_package(Qt5 COMPONENTS Core REQUIRED) -sofa_find_package(SofaComponentAll REQUIRED) +if(APPLE AND SOFA_BUILD_APP_BUNDLE) + add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${RC_FILES} ${RESOURCE_FILES} ${HEADER_FILES} ${SOURCE_FILES}) + set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Modeler.plist") +else() + add_executable(${PROJECT_NAME} ${RESOURCE_FILES} ${HEADER_FILES} ${SOURCE_FILES}) +endif() + +target_compile_definitions(${PROJECT_NAME} PUBLIC "CONFIG_PLUGIN_FILENAME=${_configPluginFileName}") +target_compile_definitions(${PROJECT_NAME} PUBLIC "DEFAULT_CONFIG_PLUGIN_FILENAME=${_defaultConfigPluginFileName}") -if(Qt5Core_FOUND) - message("Modeler executable: Using Qt5") - qt5_add_resources(RESOURCE_FILES "${CMAKE_SOURCE_DIR}/share/textures/modeler/icons.qrc") +target_link_libraries(${PROJECT_NAME} Sofa.Simulation.Graph) +target_link_libraries(${PROJECT_NAME} Sofa.GUI.Common) +target_link_libraries(${PROJECT_NAME} Sofa.GUI.Batch) +target_link_libraries(${PROJECT_NAME} SceneChecking) +target_link_libraries(${PROJECT_NAME} SofaComponentAll) +target_link_libraries(${PROJECT_NAME} SofaModeler) +target_link_libraries(${PROJECT_NAME} ${QT_TARGETS}) + +if(Sofa.Component.Playback_FOUND) + target_link_libraries(${PROJECT_NAME} Sofa.Component.Playback) +else() + message(WARNING "Modeler: Sofa.Component.Playback not found, disabling validation feature.") endif() -add_executable(${PROJECT_NAME} Main.cpp ${RC_FILES} ${RESOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} SofaModeler SofaComponentAll SofaSimulationGraph) +#if(SOFA_BUILD_TESTS) +# add_subdirectory(runSofa_test) +#endif() + +# Create build and install versions of .ini file for resources finding +set(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/etc/${PROJECT_NAME}.ini.in" "${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.ini") +set(RESOURCES_DIR "../share/sofa/gui/runSofa") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/etc/${PROJECT_NAME}.ini.in" "${CMAKE_BINARY_DIR}/etc/installed${PROJECT_NAME}.ini") +install(FILES "${CMAKE_BINARY_DIR}/etc/installed${PROJECT_NAME}.ini" DESTINATION etc RENAME ${PROJECT_NAME}.ini COMPONENT applications) + +install(DIRECTORY "resources/" DESTINATION "share/sofa/gui/runSofa" COMPONENT resources) -sofa_install_targets(SofaModeler Modeler "Modeler") +sofa_add_targets_to_package( + PACKAGE_NAME Sofa.GUI + TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES + INCLUDE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + INCLUDE_INSTALL_DIR "Sofa.GUI/Modeler" + ) diff --git a/applications/projects/Modeler/exec/Main.cpp b/applications/projects/Modeler/exec/Main.cpp index f55716f2c7b..91811cc1f51 100644 --- a/applications/projects/Modeler/exec/Main.cpp +++ b/applications/projects/Modeler/exec/Main.cpp @@ -25,8 +25,11 @@ #include #include #include +#include +#include +#include -#include +#include #include @@ -36,9 +39,30 @@ #include #include - +#include +#include +#include +#include +#include +#include + +using sofa::gui::common::BaseGUI; +using sofa::helper::logging::MainPerComponentLoggingMessageHandler; +using sofa::helper::logging::ConsoleMessageHandler; +using sofa::helper::logging::MessageDispatcher; +using sofa::gui::common::GuiDataRepository; using sofa::helper::system::FileSystem; using sofa::helper::Utils; +using sofa::gui::common::GUIManager; +using sofa::core::ExecParams ; +using sofa::simulation::graph::DAGSimulation; +using sofa::helper::system::SetDirectory; +using sofa::core::objectmodel::BaseNode ; +using sofa::helper::system::DataRepository; +using sofa::helper::system::PluginRepository; +using sofa::helper::system::PluginManager; +using namespace std; + // --------------------------------------------------------------------- // --- @@ -46,19 +70,84 @@ using sofa::helper::Utils; int main(int argc, char** argv) { - sofa::component::initSofaComponentAll(); - // TODO: create additionnal handlers depending on command-line parameters + // Add resources dir to GuiDataRepository + const std::string runSofaIniFilePath = Utils::getSofaPathTo("/etc/runSofa.ini"); + std::map iniFileValues = Utils::readBasicIniFile(runSofaIniFilePath); + if (iniFileValues.find("RESOURCES_DIR") != iniFileValues.end()) + { + std::string dir = iniFileValues["RESOURCES_DIR"]; + dir = SetDirectory::GetRelativeFromProcess(dir.c_str()); + if(FileSystem::isDirectory(dir)) + { + sofa::gui::common::GuiDataRepository.addFirstPath(dir); + } + } + +#if defined(SOFA_HAVE_DAG) + string simulationType = "dag"; +#else + string simulationType = "tree"; +#endif + + vector plugins; + vector files; + + string gui_help = "choose the UI ("; + gui_help += GUIManager::ListSupportedGUI('|'); + gui_help += ")"; + + sofa::simulation::common::init(); + sofa::simulation::graph::init(); + + MessageDispatcher::clearHandlers() ; + MessageDispatcher::addHandler( new ConsoleMessageHandler() ) ; + MessageDispatcher::addHandler(&MainPerComponentLoggingMessageHandler::getInstance()) ; +#ifdef TRACY_ENABLE + MessageDispatcher::addHandler(&sofa::helper::logging::MainTracyMessageHandler::getInstance()); +#endif + + // Output FileRepositories + msg_info("Modeler") << "PluginRepository paths = " << PluginRepository.getPathsJoined(); + msg_info("Modeler") << "DataRepository paths = " << DataRepository.getPathsJoined(); + msg_info("Modeler") << "GuiDataRepository paths = " << GuiDataRepository.getPathsJoined(); + + // Initialise paths + BaseGUI::setConfigDirectoryPath(Utils::getSofaPathPrefix() + "/config", true); + BaseGUI::setScreenshotDirectoryPath(Utils::getSofaPathPrefix() + "/screenshots", true); + + // Add Batch GUI (runSofa without any GUIs wont be useful) + sofa::gui::batch::init(); + + for (unsigned int i=0; isetMainWidget(sofaModeler); sofaModeler->show(); std::string binaryName=argv[0]; @@ -79,5 +168,6 @@ int main(int argc, char** argv) if (argc <= 1 ) sofaModeler->newTab(); int appReturnCode = application->exec(); + delete application; return appReturnCode; } diff --git a/applications/projects/Modeler/exec/Modeler.icns b/applications/projects/Modeler/exec/Modeler.icns new file mode 100644 index 00000000000..79da865c78a Binary files /dev/null and b/applications/projects/Modeler/exec/Modeler.icns differ diff --git a/applications/projects/Modeler/exec/Modeler.ispc b/applications/projects/Modeler/exec/Modeler.ispc new file mode 100644 index 00000000000..79da865c78a Binary files /dev/null and b/applications/projects/Modeler/exec/Modeler.ispc differ diff --git a/applications/projects/Modeler/exec/Modeler.plist b/applications/projects/Modeler/exec/Modeler.plist new file mode 100644 index 00000000000..c59e246bd0c --- /dev/null +++ b/applications/projects/Modeler/exec/Modeler.plist @@ -0,0 +1,32 @@ + + + + + CFBundlePackageType + APPL + CFBundleDevelopmentRegion + en_US + CFBundleExecutable + bin/runSofa + CFBundleGetInfoString + Created by the SOFA Team + CFBundleIconFile + runSofa.icns + CFBundleIdentifier + org.sofa-framework.runsofa + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + runSOFA + CFBundleDisplayName + SOFA Framework - Real-time multi-physics simulation + CFBundleVersion + @Sofa_VERSION@ + CFBundleShortVersionString + v@Sofa_VERSION@ + NSHumanReadableCopyright + LGPL + GPL + CSResourcesFileMapped + + + diff --git a/applications/projects/Modeler/exec/cmake/GeneratePluginConfig.cmake b/applications/projects/Modeler/exec/cmake/GeneratePluginConfig.cmake new file mode 100644 index 00000000000..4c81141a32d --- /dev/null +++ b/applications/projects/Modeler/exec/cmake/GeneratePluginConfig.cmake @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.22) + +include_guard(GLOBAL) + +macro(sofa_generate_plugin_config config_filename) + # Generate default list of plugins (according to the options) + get_property(_allTargets GLOBAL PROPERTY __GlobalTargetList__) + get_property(_allTargetNames GLOBAL PROPERTY __GlobalTargetNameList__) + + list(LENGTH _allTargets nbTargets) + + # do the generation only if there is any plugin + if (NOT ${nbTargets} EQUAL 0) + math(EXPR len "${nbTargets} - 1") + + set(_modulePrefix "MODULE") + set(_pluginPrefix "PLUGIN") + foreach(counter RANGE ${len}) + list(GET _allTargets ${counter} _target) + list(GET _allTargetNames ${counter} _targetName) + + string(SUBSTRING "${_targetName}" 0 6 _testPlugin) + if(${_testPlugin} MATCHES "${_modulePrefix}.*" OR ${_testPlugin} MATCHES "${_pluginPrefix}.*") + if(${${_targetName}}) + get_target_property(_version ${_target} VERSION ) + if(${_version} MATCHES ".*NOTFOUND") + set(_version "NO_VERSION") + endif() + + set(_target_filename ${_target}) + get_target_property(target_output_name ${_target} OUTPUT_NAME) + if(target_output_name) + set(_target_filename ${target_output_name}) + endif() + + string(CONCAT _pluginConfig "${_pluginConfig}\n${_target_filename} ${_version}") + endif() + endif() + endforeach() + FILE(WRITE ${config_filename} ${_pluginConfig}) + + endif() + +endmacro() diff --git a/applications/projects/Modeler/exec/etc/Modeler.ini.in b/applications/projects/Modeler/exec/etc/Modeler.ini.in new file mode 100644 index 00000000000..1a9c6a74899 --- /dev/null +++ b/applications/projects/Modeler/exec/etc/Modeler.ini.in @@ -0,0 +1 @@ +RESOURCES_DIR=@RESOURCES_DIR@ diff --git a/applications/projects/Modeler/exec/resources/docs/runsofa.html b/applications/projects/Modeler/exec/resources/docs/runsofa.html new file mode 100644 index 00000000000..c6c274b2494 --- /dev/null +++ b/applications/projects/Modeler/exec/resources/docs/runsofa.html @@ -0,0 +1,16 @@ + + + + +runSofa 1.0. +
+Welcome in runSofa, a simple way to execute and debug Sofa scene. This tool is part of the Sofa framework +for simulation. + +You can try the following examples: +
    + Caduceus +
+ + + diff --git a/applications/projects/Modeler/lib/CMakeLists.txt b/applications/projects/Modeler/lib/CMakeLists.txt index fa26182ad40..642174019ec 100644 --- a/applications/projects/Modeler/lib/CMakeLists.txt +++ b/applications/projects/Modeler/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.12) project(SofaModeler VERSION 0.1) find_package(TinyXML2 REQUIRED) diff --git a/applications/projects/Modeler/lib/GraphHistoryManager.cpp b/applications/projects/Modeler/lib/GraphHistoryManager.cpp index 3530069c1e8..6bd76418fd5 100644 --- a/applications/projects/Modeler/lib/GraphHistoryManager.cpp +++ b/applications/projects/Modeler/lib/GraphHistoryManager.cpp @@ -248,7 +248,7 @@ void GraphHistoryManager::clearHistory() else if (historyOperation[i].ID == Operation::DELETE_Node) { Node *n=down_cast(historyOperation[i].sofaComponent->toBaseNode()); - simulation::getSimulation()->unload(n); + sofa::simulation::node::unload(n); historyOperation[i].sofaComponent.reset(); } } @@ -267,7 +267,7 @@ void GraphHistoryManager::clearHistoryUndo() else if (historyUndoOperation[i].ID == Operation::DELETE_Node) { Node *n=down_cast(historyUndoOperation[i].sofaComponent->toBaseNode()); - simulation::getSimulation()->unload(n); + sofa::simulation::node::unload(n); historyUndoOperation[i].sofaComponent.reset(); } } diff --git a/applications/projects/Modeler/lib/GraphModeler.cpp b/applications/projects/Modeler/lib/GraphModeler.cpp index 6566804c01c..3b20969af1a 100644 --- a/applications/projects/Modeler/lib/GraphModeler.cpp +++ b/applications/projects/Modeler/lib/GraphModeler.cpp @@ -33,10 +33,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -69,6 +69,7 @@ GraphModeler::GraphModeler(QWidget* parent, const char* name, Qt::WindowFlags f) setWindowFlags(f); graphListener = new GraphListenerQListView(this); + graphListener->widget->unLock(); //addColumn("Graph"); header()->hide(); setSortingEnabled(false); @@ -97,7 +98,7 @@ GraphModeler::GraphModeler(QWidget* parent, const char* name, Qt::WindowFlags f) GraphModeler::~GraphModeler() { delete historyManager; - simulation::getSimulation()->unload(getRoot()); + simulation::node::unload(getRoot()); //delete getRoot(); graphRoot.reset(); delete graphListener; @@ -126,7 +127,10 @@ Node::SPtr GraphModeler::addNode(Node::SPtr parent, Node::SPtr child, bool saveH { std::ostringstream oss; oss << Node::shortName(child.get()) << numNode++; - child = Node::create(oss.str() ); + sofa::core::objectmodel::BaseObjectDescription arg; + arg.setName(oss.str()); + child = Node::create(&arg); +// child = Node::create(oss.str() ); if (!parent) child->setName("Root"); } @@ -134,6 +138,7 @@ Node::SPtr GraphModeler::addNode(Node::SPtr parent, Node::SPtr child, bool saveH if (parent != nullptr) { parent->addChild(child); + graphListener->onBeginAddChild(parent.get(),child.get()); if (saveHistory) { @@ -146,7 +151,8 @@ Node::SPtr GraphModeler::addNode(Node::SPtr parent, Node::SPtr child, bool saveH { graphListener->onBeginAddChild(nullptr, child.get()); //Set up the root - this->topLevelItem(0)->setExpanded(true); + if(this->topLevelItem(0) != nullptr) + this->topLevelItem(0)->setExpanded(true); if (saveHistory) historyManager->graphClean(); graphRoot = child; @@ -283,15 +289,15 @@ void GraphModeler::dropEvent(QDropEvent* event) if (text == QString("ComponentCreation")) { BaseObject::SPtr newComponent = addComponent(getNode(event->pos()), lastSelectedComponent.second, lastSelectedComponent.first ); + graphListener->onBeginAddObject(getNode(event->pos()),newComponent.get()); if (newComponent) { -// QTreeWidgetItem *after = graphListener->items[newComponent.get()]; - -// std::ostringstream oss; -// oss << newComponent->getClassName() << " " << newComponent->getName(); -// after->setText(0, QString(oss.str().c_str())); -// QTreeWidgetItem *item = itemAt(event->pos()); -// if (getObject(item)) initItem(after, item); + QTreeWidgetItem *after = graphListener->items[newComponent.get()]; + std::ostringstream oss; + oss << newComponent->getClassName() << " " << newComponent->getName(); + after->setText(0, QString(oss.str().c_str())); + QTreeWidgetItem *item = itemAt(event->pos()); + if (getObject(item)) initItem(after, item); } } else @@ -299,7 +305,6 @@ void GraphModeler::dropEvent(QDropEvent* event) if (text == QString("Node")) { Node* node=getNode(event->pos()); - if (node) { Node::SPtr newNode=addNode(node); @@ -307,7 +312,8 @@ void GraphModeler::dropEvent(QDropEvent* event) { QTreeWidgetItem *after = graphListener->items[newNode.get()]; QTreeWidgetItem *item = itemAt(event->pos()); - if (getObject(item)) initItem(after,item); + if (getObject(item)) + initItem(after,item); } } } @@ -315,6 +321,8 @@ void GraphModeler::dropEvent(QDropEvent* event) } + + Base* GraphModeler::getComponent(QTreeWidgetItem *item) const { if (!item) return nullptr; @@ -332,7 +340,8 @@ Base* GraphModeler::getComponent(QTreeWidgetItem *item) const BaseObject *GraphModeler::getObject(QTreeWidgetItem *item) const { Base* component=getComponent(item); - return dynamic_cast(component); + BaseObject* ComponentBaseObject = component->toBaseObject(); + return ComponentBaseObject; } @@ -678,7 +687,10 @@ void GraphModeler::linkComponent() Node::SPtr GraphModeler::buildNodeFromBaseElement(Node::SPtr node,xml::BaseElement *elem, bool saveHistory) { const bool displayWarning=true; - Node::SPtr newNode = Node::create(""); + sofa::core::objectmodel::BaseObjectDescription arg; + arg.setName(""); + Node::SPtr newNode = Node::create(&arg); +// Node::SPtr newNode = Node::create(""); //Configure the new Node configureElement(newNode.get(), elem); @@ -913,7 +925,7 @@ bool GraphModeler::getSaveFilename(std::string &filename) void GraphModeler::save(const std::string &filename) { Node *node = getNode(this->topLevelItem(0)); - simulation::getSimulation()->exportXML(node, filename.c_str()); + simulation::node::exportInXML(node, filename.c_str()); emit graphClean(); } @@ -968,6 +980,7 @@ void GraphModeler::deleteComponent(QTreeWidgetItem* item, bool saveHistory) } getNode(item)->removeObject(getObject(item)); + graphListener->onBeginRemoveObject(parent,object); } else { @@ -985,7 +998,10 @@ void GraphModeler::deleteComponent(QTreeWidgetItem* item, bool saveHistory) if (!parent) graphListener->onBeginRemoveChild(parent, node); else + { parent->removeChild(dynamic_cast(node)); + graphListener->onBeginRemoveChild(nullptr,node); + } if (!parent && this->children().size() == 0) addNode(nullptr); } diff --git a/applications/projects/Modeler/lib/GraphModeler.h b/applications/projects/Modeler/lib/GraphModeler.h index 4ef7d664b00..276d6a11304 100644 --- a/applications/projects/Modeler/lib/GraphModeler.h +++ b/applications/projects/Modeler/lib/GraphModeler.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -48,6 +48,8 @@ #include + + namespace sofa { @@ -72,7 +74,7 @@ class GraphModeler : public SofaSceneGraphWidget friend class LinkComponent; Q_OBJECT public: - GraphModeler( QWidget* parent=0, const char* name=0, Qt::WindowFlags f = 0 ); + GraphModeler( QWidget* parent=0, const char* name=0, Qt::WindowFlags f = Qt::WindowFlags() ); ~GraphModeler() override; /// Set the Sofa Resources: intern library to get the creators of the elements @@ -178,6 +180,8 @@ class GraphModeler : public SofaSceneGraphWidget /// Used to know what component is about to be created by a drag&drop void setLastSelectedComponent( const std::string& templateName, ClassEntry::SPtr entry) {lastSelectedComponent = std::make_pair(templateName, entry);} + GraphListenerQListView *getGraphListener(){return graphListener;} + signals: void fileOpen(const QString&); diff --git a/applications/projects/Modeler/lib/SofaModeler.cpp b/applications/projects/Modeler/lib/SofaModeler.cpp index 429c0ff48ce..c5d37faefe2 100644 --- a/applications/projects/Modeler/lib/SofaModeler.cpp +++ b/applications/projects/Modeler/lib/SofaModeler.cpp @@ -28,7 +28,8 @@ #include #include -#include +//#include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include using namespace sofa::core; @@ -71,23 +73,25 @@ using sofa::helper::Utils; void SofaModeler::createActions() { - newTabAction = new QAction(QIcon(":/image0.png"), "New &Tab", this); + QString pathIcon=(sofa::helper::system::DataRepository.getFirstPath() + std::string( "/textures/modeler" )).c_str(); + + newTabAction = new QAction(QIcon(pathIcon+"/image0.png"), "New &Tab", this); newTabAction->setShortcut(QString("Ctrl+T")); connect(newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - closeTabAction = new QAction(QIcon(":/imageClose.png"), "&Close Tab", this); + closeTabAction = new QAction(QIcon(pathIcon+"/imageClose.png"), "&Close Tab", this); closeTabAction->setShortcut(QString("Ctrl+W")); connect(closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - clearTabAction = new QAction(QIcon(":/image0.png"), "Clear", this); + clearTabAction = new QAction(QIcon(pathIcon+"/image0.png"), "Clear", this); clearTabAction->setShortcut(QString("Ctrl+N")); connect(clearTabAction, SIGNAL(triggered()), this, SLOT(clearTab())); - openAction = new QAction(QIcon(":/image1.png"), "&Open...", this); + openAction = new QAction(QIcon(pathIcon+"/image1.png"), "&Open...", this); openAction->setShortcut(QString("Ctrl+O")); connect(openAction, SIGNAL(triggered()), this, SLOT(fileOpen())); - saveAction = new QAction(QIcon(":/image3.png"), "&Save", this); + saveAction = new QAction(QIcon(pathIcon+"/image3.png"), "&Save", this); saveAction->setShortcut(QString("Ctrl+S")); connect(saveAction, SIGNAL(triggered()), this, SLOT(fileSave())); @@ -100,25 +104,25 @@ void SofaModeler::createActions() exitAction = new QAction("E&xit", this); connect(exitAction, SIGNAL(triggered()), this, SLOT(exit())); - undoAction = new QAction(QIcon(":/image5.png"), "&Undo", this); + undoAction = new QAction(QIcon(pathIcon+"/image5.png"), "&Undo", this); undoAction->setEnabled(false); undoAction->setShortcut(QString("Ctrl+Z")); connect(undoAction, SIGNAL(triggered()), this, SLOT(undo())); - redoAction = new QAction(QIcon(":/image6.png"), "&Redo", this); + redoAction = new QAction(QIcon(pathIcon+"/image6.png"), "&Redo", this); redoAction->setEnabled(false); redoAction->setShortcut(QString("Ctrl+Y")); connect(redoAction, SIGNAL(triggered()), this, SLOT(redo())); - cutAction = new QAction(QIcon(":/image7.png"), "&Cut", this); + cutAction = new QAction(QIcon(pathIcon+"/image7.png"), "&Cut", this); cutAction->setShortcut(QString("Ctrl+X")); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); - copyAction = new QAction(QIcon(":/image8.png"), "C&opy", this); + copyAction = new QAction(QIcon(pathIcon+"/image8.png"), "C&opy", this); copyAction->setShortcut(QString("Ctrl+C")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); - pasteAction = new QAction(QIcon(":/image9.png"), "&Paste", this); + pasteAction = new QAction(QIcon(pathIcon+"/image9.png"), "&Paste", this); pasteAction->setEnabled(false); pasteAction->setShortcut(QString("Ctrl+V")); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); @@ -126,11 +130,11 @@ void SofaModeler::createActions() openPluginManagerAction = new QAction("Plugin Manager", this); connect(openPluginManagerAction, SIGNAL(triggered()), this, SLOT(showPluginManager())); - runInSofaAction = new QAction(QIcon(":/image2.png"), "&Run in SOFA", this); + runInSofaAction = new QAction(QIcon(pathIcon+"/image2.png"), "&Run in SOFA", this); runInSofaAction->setShortcut(QString("Ctrl+R")); connect(runInSofaAction, SIGNAL(triggered()), this, SLOT(runInSofa())); - openTutorialsAction = new QAction(QIcon(":/image11.png"), "Launch the &Tutorials" ,this); + openTutorialsAction = new QAction(QIcon(pathIcon+"/image11.png"), "Launch the &Tutorials" ,this); connect(openTutorialsAction, SIGNAL(triggered()), this, SLOT(openTutorial())); exportSofaClassesAction = new QAction("Export Sofa Classes", this); @@ -572,7 +576,8 @@ void SofaModeler::createTab() graph = modelerGraph; graph->setAcceptDrops(true); - currentTabLayout->addWidget(graph,0,0); + graph->getGraphListener()->widget->unLock(); + currentTabLayout->addWidget(graph); graph->setSofaLibrary(library); graph->setPropertyWidget(propertyWidget); @@ -613,7 +618,7 @@ bool SofaModeler::closeTab(QWidget *curTab, bool forceClose) else if (response == QMessageBox::Ok) { if (mod->getFilename().empty()) fileSaveAs(); - else simulation::getSimulation()->exportXML(mod->getRoot(), mod->getFilename().c_str()); + else simulation::node::exportInXML(mod->getRoot(), mod->getFilename().c_str()); } } //If the scene has been launch in Sofa @@ -625,7 +630,7 @@ bool SofaModeler::closeTab(QWidget *curTab, bool forceClose) range=mapSofa.equal_range(curTab); for (multimapIterator it=range.first; it!=range.second; ++it) { - removeTemporaryFiles(it->second->objectName().toStdString()); +// removeTemporaryFiles(it->second->objectName().toStdString()); it->second->kill(); } mapSofa.erase(range.first, range.second); @@ -679,10 +684,10 @@ void SofaModeler::fileOpen(std::string filename) { filename = sofa::helper::system::DataRepository.getFile ( filename ); openPath = sofa::helper::system::SetDirectory::GetParentDir(filename.c_str()); - Node::SPtr root = NULL; - root = down_cast( sofa::simulation::getSimulation()->load(filename.c_str()).get() ); + Node::SPtr root = sofa::simulation::node::load(filename.c_str()).get(); if (root) { +// sofa::simulation::node::initRoot(root.get()); createTab(); fileNew(root.get()); sceneTab->setCurrentIndex(sceneTab->count()-1); @@ -826,7 +831,7 @@ void SofaModeler::exportSofaClasses() } } - getSimulation()->exportXML(root.get(), filename.toStdString().c_str()); + sofa::simulation::node::exportInXML(root.get(), filename.toStdString().c_str()); std::cout << "Sofa classes have been XML exported in: " << filename.toStdString() << std::endl << std::endl; } @@ -951,7 +956,7 @@ void SofaModeler::componentDraggedReception( std::string description, std::strin mimedata->setText("ComponentCreation"); dragging->setMimeData(mimedata); dragging->exec(Qt::CopyAction | Qt::MoveAction); - //dragging->dragCopy(); +// dragging->dragCopy(); } void SofaModeler::changeComponent(const std::string &description) @@ -966,7 +971,6 @@ void SofaModeler::newGNode() QMimeData* mimedata = new QMimeData(); mimedata->setText("Node"); dragging->setMimeData(mimedata); - //dragging->dragCopy(); dragging->exec(Qt::CopyAction | Qt::MoveAction); } @@ -1087,14 +1091,12 @@ void SofaModeler::runInSofa( const std::string &sceneFilename, Node* root) // Init the scene sofa::gui::common::GUIManager::Init("Modeler"); - //Saving the scene in a temporary file ==> doesn't modify the current Node of the simulation std::string path; if (sceneFilename.empty()) path=presetPath; else path = sofa::helper::system::SetDirectory::GetParentDir(sceneFilename.c_str())+std::string("/"); - std::string filename=path + std::string("temp") + (++count) + std::string(".scn"); - simulation::getSimulation()->exportXML(root,filename.c_str()); + std::string filename=sceneFilename; //Make a copy of the .view if it exists for the current viewer const std::string &extension=sofa::helper::system::SetDirectory::GetExtension(sceneFilename.c_str()); @@ -1134,7 +1136,6 @@ void SofaModeler::runInSofa( const std::string &sceneFilename, Node* root) viewerExtension = ".view"; } - // msg_error("SofaModeler") << "viewFile = " << viewFile ; if ( sofa::helper::system::DataRepository.findFile ( viewFile ) ) { std::ifstream originalViewFile(viewFile.c_str()); @@ -1167,7 +1168,7 @@ void SofaModeler::runInSofa( const std::string &sceneFilename, Node* root) #endif } - argv << QString(filename.c_str()); + messageLaunch = QString("Use command: ") + QString(sofaBinary.c_str()) @@ -1195,22 +1196,20 @@ void SofaModeler::runInSofa( const std::string &sceneFilename, Node* root) for( it = pluginMap.begin(); it != pluginMap.end(); ++it ) { argv << "-l" << QString((it->first).c_str()) << " "; - messageLaunch += QString("-l ") + QString((it->first).c_str()); + messageLaunch += QString(" -l ") + QString((it->first).c_str()); } + argv << QString::fromStdString(filename); - argv << "-t"; - + messageLaunch += (" "+QString(filename.c_str())); QProcess *p = new QProcess(this); - p->setWorkingDirectory(QString(binPath.c_str()) ); p->setObjectName(QString(filename.c_str()) ); connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(sofaExited(int, QProcess::ExitStatus))); - QDir dir(QString(sofa::helper::system::SetDirectory::GetParentDir(sceneFilename.c_str()).c_str())); connect(p, SIGNAL( readyReadStandardOutput () ), this , SLOT ( redirectStdout() ) ); connect(p, SIGNAL( readyReadStandardError () ), this , SLOT ( redirectStderr() ) ); @@ -1257,7 +1256,7 @@ void SofaModeler::sofaExited(int exitCode, QProcess::ExitStatus existStatus) programName = p->objectName().toStdString(); - removeTemporaryFiles(programName); +// removeTemporaryFiles(programName); if (existStatus == QProcess::NormalExit ) { p->closeWriteChannel(); diff --git a/applications/projects/Modeler/lib/SofaTutorialManager.cpp b/applications/projects/Modeler/lib/SofaTutorialManager.cpp index 090455931e0..030cc2196e7 100644 --- a/applications/projects/Modeler/lib/SofaTutorialManager.cpp +++ b/applications/projects/Modeler/lib/SofaTutorialManager.cpp @@ -26,8 +26,7 @@ #include #include -#include - +#include #include #include #include diff --git a/applications/projects/Modeler/lib/TutorialSelector.h b/applications/projects/Modeler/lib/TutorialSelector.h index bb41e8e7c03..0d73ade8935 100644 --- a/applications/projects/Modeler/lib/TutorialSelector.h +++ b/applications/projects/Modeler/lib/TutorialSelector.h @@ -25,13 +25,14 @@ #include #include #include +#include #include #include // Forward declarations -class tinyxml2::XMLNode; -class tinyxml2::XMLElement; +//class tinyxml2::XMLNode; +//class tinyxml2::XMLElement; #include