From ef35c4f7ea436c47e1ad7eaf4c06114e18c8a1ef Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Mon, 18 Dec 2023 11:41:40 +0100 Subject: [PATCH] [SofaSimpleGUI] Fix calls to deprecated functions --- applications/plugins/SofaSimpleGUI/SofaGL.cpp | 10 +++- .../plugins/SofaSimpleGUI/SofaScene.cpp | 47 +++++++++---------- .../plugins/SofaSimpleGUI/SofaScene.h | 5 +- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/applications/plugins/SofaSimpleGUI/SofaGL.cpp b/applications/plugins/SofaSimpleGUI/SofaGL.cpp index 57af6801880..24903830b67 100644 --- a/applications/plugins/SofaSimpleGUI/SofaGL.cpp +++ b/applications/plugins/SofaSimpleGUI/SofaGL.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include using sofa::simulation::mechanicalvisitor::MechanicalPickParticlesVisitor; @@ -276,8 +277,13 @@ void SofaGL::getSceneBBox( float* xmin, float* ymin, float* zmin, float* xmax, f { SReal xm, xM, ym, yM, zm, zM; _sofaScene->getBoundingBox(&xm,&xM,&ym,&yM,&zm,&zM); - // cerr << "SofaGL::getSceneBBox, xm=" << xm <<", xM=" << xM << endl; - *xmin=xm, *xmax=xM, *ymin=ym, *ymax=yM, *zmin=zm, *zmax=zM; + + *xmin = helper::narrow_cast(xm); + *xmax = helper::narrow_cast(xM); + *ymin = helper::narrow_cast(ym); + *ymax = helper::narrow_cast(yM); + *zmin = helper::narrow_cast(zm); + *zmax = helper::narrow_cast(zM); } diff --git a/applications/plugins/SofaSimpleGUI/SofaScene.cpp b/applications/plugins/SofaSimpleGUI/SofaScene.cpp index 70c7184782d..8cbf2a7abdc 100644 --- a/applications/plugins/SofaSimpleGUI/SofaScene.cpp +++ b/applications/plugins/SofaSimpleGUI/SofaScene.cpp @@ -17,8 +17,8 @@ using std::endl; typedef sofa::simulation::graph::DAGSimulation SofaSimulation; -namespace sofa { -namespace simplegui { +namespace sofa::simplegui +{ typedef sofa::type::Vec3 Vec3; @@ -27,29 +27,29 @@ typedef sofa::component::statecontainer::MechanicalObject< defaulttype::Vec3Type SofaScene::SofaScene() { - _groot = _iroot = NULL; + _groot = _iroot = nullptr; std::shared_ptr classVisualModel;// = NULL; sofa::core::ObjectFactory::AddAlias("VisualModel", "OglModel", true, &classVisualModel); - sofaSimulation = sofa::simulation::getSimulation(); // creates one if it is not already created sofa::component::init(); } void SofaScene::step( SReal dt) { - sofaSimulation->animate(_groot.get(),dt); + sofa::simulation::node::animate(_groot.get(),dt); } void SofaScene::printGraph() { - sofaSimulation->print(_groot.get()); + sofa::simulation::node::print(_groot.get()); } -void SofaScene::loadPlugins( std::vector plugins ) +void SofaScene::loadPlugins( const std::vector& plugins ) { - for (unsigned int i=0; iunload (_groot); - _groot = sofaSimulation->load( fileName.c_str() ).get(); + if(_groot) sofa::simulation::node::unload (_groot); + _groot = sofa::simulation::node::load( fileName.c_str() ).get(); if(!_groot) { cerr << "loading failed" << endl; @@ -72,7 +72,7 @@ void SofaScene::open(const std::string& fileName ) // _currentFileName = fileName; - sofaSimulation->init(_groot.get()); + sofa::simulation::node::init(_groot.get()); printGraph(); SReal xm,xM,ym,yM,zm,zM; @@ -83,16 +83,16 @@ void SofaScene::open(const std::string& fileName ) void SofaScene::setScene(simulation::Node *node ) { - if(_groot) sofaSimulation->unload (_groot); - _groot = sofaSimulation->createNewGraph("root").get(); + if(_groot) sofa::simulation::node::unload (_groot); + _groot = sofa::simulation::getSimulation()->createNewGraph("root").get(); _groot->addChild(node); _iroot = _groot->createChild("iroot").get(); - sofaSimulation->init(_groot.get()); + sofa::simulation::node::init(_groot.get()); } void SofaScene::reset() { - sofaSimulation->reset(_groot.get()); + sofa::simulation::node::reset(_groot.get()); } //void SofaScene::open(const char *filename) @@ -110,7 +110,7 @@ void SofaScene::reset() // _currentFileName = filename; -// sofaSimulation->::init(_groot); +// sofa::simulation::node::::init(_groot); //// cout<<"SofaScene::init, scene loaded" << endl; //// printGraph(); //} @@ -118,7 +118,7 @@ void SofaScene::reset() void SofaScene::getBoundingBox( SReal* xmin, SReal* xmax, SReal* ymin, SReal* ymax, SReal* zmin, SReal* zmax ) { SReal pmin[3], pmax[3]; - sofaSimulation->computeBBox( _groot.get(), pmin, pmax ); + sofa::simulation::node::computeBBox( _groot.get(), pmin, pmax ); *xmin = pmin[0]; *xmax = pmax[0]; *ymin = pmin[1]; *ymax = pmax[1]; *zmin = pmin[2]; *zmax = pmax[2]; @@ -133,12 +133,12 @@ void SofaScene::insertInteractor( Interactor * interactor ) simulation::Node* SofaScene::groot() { return _groot.get(); } void SofaScene::initVisual(){ - sofaSimulation->initTextures(_groot.get()); + sofa::simulation::node::initTextures(_groot.get()); } void SofaScene::updateVisual() { - sofaSimulation->updateVisual(_groot.get()); // needed to update normals and VBOs ! (i think it should be better if updateVisual() was called from draw(), why it is not already the case ?) + sofa::simulation::node::updateVisual(_groot.get()); // needed to update normals and VBOs ! (i think it should be better if updateVisual() was called from draw(), why it is not already the case ?) } //void SofaScene::draw( sofa::core::visual::VisualParams* v) @@ -147,9 +147,8 @@ void SofaScene::updateVisual() // { // // } -// sofaSimulation->draw(_vparams, groot() ); +// sofa::simulation::node::draw(_vparams, groot() ); //} -}// newgui -}// sofa +} diff --git a/applications/plugins/SofaSimpleGUI/SofaScene.h b/applications/plugins/SofaSimpleGUI/SofaScene.h index 0d10d28a339..11565dbbb5e 100644 --- a/applications/plugins/SofaSimpleGUI/SofaScene.h +++ b/applications/plugins/SofaSimpleGUI/SofaScene.h @@ -44,9 +44,9 @@ class SOFA_SOFASIMPLEGUI_API SofaScene /** * @brief load the given plugin - * @param pluginName name of the plugin + * @param plugins names of the plugins */ - void loadPlugins( std::vector pluginName ); + void loadPlugins( const std::vector& plugins ); /** * @brief Load a scene file. The previous scene graph, if any, is deleted. * @param fileName Scene file to load @@ -110,7 +110,6 @@ class SOFA_SOFASIMPLEGUI_API SofaScene protected: simulation::Node::SPtr _groot; ///< root of the scene simulation::Node* _iroot; ///< root of the interactors, child of _groot - simulation::Simulation* sofaSimulation; };