Skip to content

Commit

Permalink
[Setting] Rename Data (sofa-framework#4682)
Browse files Browse the repository at this point in the history
* [Setting] Rename Data

* Update Sofa/framework/Simulation/Core/src/sofa/simulation/Simulation.cpp

Co-authored-by: Alex Bilger <[email protected]>

* Update Sofa/framework/Simulation/Core/src/sofa/simulation/config.h.in

Co-authored-by: Alex Bilger <[email protected]>

* Update Sofa/Component/Setting/src/sofa/component/setting/StatsSetting.cpp

Co-authored-by: Alex Bilger <[email protected]>

* Update Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp

Co-authored-by: Alex Bilger <[email protected]>

* Update Sofa/Component/Setting/src/sofa/component/setting/StatsSetting.cpp

Co-authored-by: Alex Bilger <[email protected]>

* Fix typo

* Update Sofa/Component/Setting/src/sofa/component/setting/SofaDefaultPathSetting.cpp

Co-authored-by: Paul Baksic <[email protected]>

---------

Co-authored-by: Alex Bilger <[email protected]>
Co-authored-by: Paul Baksic <[email protected]>
  • Loading branch information
3 people authored May 13, 2024
1 parent 4d425cd commit 2124785
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ int BackgroundSettingClass = core::RegisterObject("Background setting")
;

BackgroundSetting::BackgroundSetting():
color(initData(&color, "color", "Color of the background"))
, image(initData(&image, "image", "Image to be used as background"))
d_color(initData(&d_color, "color", "Color of the background")),
d_image(initData(&d_image, "image", "Image to be used as background"))
{
color.setParent(&d_color);
image.setParent(&d_image);
}

} // namespace sofa::component::setting
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ class SOFA_COMPONENT_SETTING_API BackgroundSetting: public core::objectmodel::Co
BackgroundSetting(); ///< Default constructor

public:
Data<sofa::type::RGBAColor> color; ///< Color of the Background of the Viewer.
SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<sofa::type::RGBAColor> color;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
sofa::core::objectmodel::DataFileName image; ///< Image to be used as background of the viewer.


Data<sofa::type::RGBAColor> d_color; ///< Color of the Background of the Viewer.
sofa::core::objectmodel::DataFileName d_image; ///< Image to be used as background of the viewer.

};

} // namespace sofa::component::setting
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ namespace sofa::component::setting
{

MouseButtonSetting::MouseButtonSetting():
button(initData(&button, "button", "Mouse button used"))
d_button(initData(&d_button, "button", "Mouse button used"))
{
const sofa::helper::OptionsGroup buttonGroup{"Left","Middle","Right"};
button.setValue(buttonGroup);
d_button.setValue(buttonGroup);
button.setParent(&d_button);

}

} // namespace sofa::component::setting
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class SOFA_COMPONENT_SETTING_API MouseButtonSetting: public core::objectmodel::C
public:
virtual std::string getOperationType()=0;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
core::objectmodel::Data<sofa::helper::OptionsGroup> button;

core::objectmodel::Data<sofa::helper::OptionsGroup> button; ///< Mouse button used
core::objectmodel::Data<sofa::helper::OptionsGroup> d_button; ///< Mouse button used

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int SofaDefaultPathSettingClass = core::RegisterObject("Default Paths for Sofa A
;

SofaDefaultPathSetting::SofaDefaultPathSetting():
gnuplotPath(initData(&gnuplotPath, "gnuplotPath", "Path where will be saved the gnuplot files"))
d_gnuplotPath(initData(&d_gnuplotPath, "gnuplotPath", "Path where will be saved the gnuplot files"))
{

gnuplotPath.setParent(&d_gnuplotPath);
}
} // namespace sofa::component::setting
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class SOFA_COMPONENT_SETTING_API SofaDefaultPathSetting: public core::objectmode
protected:
SofaDefaultPathSetting(); ///<Default constructor.
public:
sofa::core::objectmodel::Data<std::string> gnuplotPath; ///<Path where will be saved the gnuplot files.
SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
sofa::core::objectmodel::Data<std::string> gnuplotPath;

sofa::core::objectmodel::Data<std::string> d_gnuplotPath; ///<Path where will be saved the gnuplot files.
};

} // namespace sofa::component::setting
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ int StatsSettingClass = core::RegisterObject("Stats settings")
;

StatsSetting::StatsSetting():
dumpState(initData(&dumpState,false,"dumpState", "Dump state vectors at each time step of the simulation"))
, logTime(initData(&logTime, false, "logTime", "Output in the console an average of the time spent during different stages of the simulation"))
, exportState(initData(&exportState, false, "exportState", "Create GNUPLOT files with the positions, velocities and forces of all the simulated objects of the scene"))
d_dumpState(initData(&d_dumpState, false, "dumpState", "Dump state vectors at each time step of the simulation"))
, d_logTime(initData(&d_logTime, false, "logTime", "Output in the console an average of the time spent during different stages of the simulation"))
, d_exportState(initData(&d_exportState, false, "exportState", "Create GNUPLOT files with the positions, velocities and forces of all the simulated objects of the scene"))
#ifdef SOFA_DUMP_VISITOR_INFO
, traceVisitors(initData(&traceVisitors, "traceVisitors", "Trace the time spent by each visitor, and allows to profile precisely one step of a simulation"))
#endif
{
dumpState.setParent(&d_dumpState);
logTime.setParent(&d_logTime);
exportState.setParent(&d_exportState);

}

} // namespace sofa::component::setting
21 changes: 16 additions & 5 deletions Sofa/Component/Setting/src/sofa/component/setting/StatsSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,26 @@ class SOFA_COMPONENT_SETTING_API StatsSetting: public core::objectmodel::Configu
* @brief Default constructor.
*
* By default :
* - @ref dumpState is set to false.
* - @ref d_dumpState is set to false.
* - @ref logTime is set to false.
* - @ref exportState is set to false.
* - @ref d_exportState is set to false.
*/
StatsSetting();
public:
Data<bool> dumpState; ///< If true, dump state vectors at each time step of the simulation.
Data<bool> logTime; ///< If true, output in the console an average of the time spent during different stages of the simulation.
Data<bool> exportState; ///< If true, create GNUPLOT files with the positions, velocities and forces of all the simulated objects of the scene.

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<bool> dumpState;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<bool> logTime;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<bool> exportState;


Data<bool> d_dumpState; ///< If true, dump state vectors at each time step of the simulation.
Data<bool> d_logTime; ///< If true, output in the console an average of the time spent during different stages of the simulation.
Data<bool> d_exportState; ///< If true, create GNUPLOT files with the positions, velocities and forces of all the simulated objects of the scene.
#ifdef SOFA_DUMP_VISITOR_INFO
Data<bool> traceVisitors; ///< If true, trace the time spent by each visitor, and allows to profile precisely one step of a simulation.
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ int ViewerSettingClass = core::RegisterObject("Configuration for the Viewer of y
;

ViewerSetting::ViewerSetting()
: resolution(initData(&resolution, Vec<2,int>(800,600), "resolution", "resolution of the Viewer"))
, fullscreen(initData(&fullscreen, false, "fullscreen", "Fullscreen mode"))
, cameraMode(initData(&cameraMode, {"Perspective","Orthographic"}, "cameraMode", "Camera mode"))
, objectPickingMethod(initData(&objectPickingMethod, {"Ray casting","Selection buffer"}, "objectPickingMethod","The method used to pick objects"))
{}
: d_resolution(initData(&d_resolution, Vec<2,int>(800, 600), "resolution", "resolution of the Viewer"))
, d_fullscreen(initData(&d_fullscreen, false, "fullscreen", "Fullscreen mode"))
, d_cameraMode(initData(&d_cameraMode, {"Perspective", "Orthographic"}, "cameraMode", "Camera mode"))
, d_objectPickingMethod(initData(&d_objectPickingMethod, {"Ray casting", "Selection buffer"}, "objectPickingMethod", "The method used to pick objects"))
{
resolution.setParent(&d_resolution);
fullscreen.setParent (&d_fullscreen);
cameraMode.setParent(&d_cameraMode);
objectPickingMethod.setParent(&d_objectPickingMethod);
}

} // namespace sofa::component::setting
20 changes: 16 additions & 4 deletions Sofa/Component/Setting/src/sofa/component/setting/ViewerSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@ class SOFA_COMPONENT_SETTING_API ViewerSetting: public sofa::core::objectmodel::
ViewerSetting();
public:

Data<sofa::type::Vec<2,int> > resolution; ///< Screen resolution (width, height).
Data<bool> fullscreen; ///< True if viewer should be fullscreen.
Data<sofa::helper::OptionsGroup> cameraMode; ///< Camera mode.
SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<sofa::type::Vec<2,int> > resolution;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<bool> fullscreen;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<sofa::helper::OptionsGroup> cameraMode;

SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
Data<sofa::helper::OptionsGroup> objectPickingMethod;

Data<sofa::type::Vec<2,int> > d_resolution; ///< Screen resolution (width, height).
Data<bool> d_fullscreen; ///< True if viewer should be fullscreen.
Data<sofa::helper::OptionsGroup> d_cameraMode; ///< Camera mode.
/**< \arg Perspective.
* \arg Orthographic.
*/
Data<sofa::helper::OptionsGroup> objectPickingMethod; ///< Picking Method.
Data<sofa::helper::OptionsGroup> d_objectPickingMethod; ///< Picking Method.
/**< \arg Ray casting.
* \arg Selection Buffer.
*/
Expand Down
9 changes: 9 additions & 0 deletions Sofa/Component/Setting/src/sofa/component/setting/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ namespace sofa::component::setting
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
} // namespace sofa::component::setting

#ifdef SOFA_BUILD_SOFA_COMPONENT_SETTING
#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA()
#else
#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() \
SOFA_ATTRIBUTE_DEPRECATED( \
"v24.06", "v24.12", \
"Data renamed according to the guidelines")
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void OglLabel::reinit()
if (backgroundSetting)
{
//in contrast mode, the text color is selected between black or white depending on the background color
const RGBAColor& backgroundColor = backgroundSetting->color.getValue();
const RGBAColor& backgroundColor = backgroundSetting->d_color.getValue();
float yiq = (float)(backgroundColor[0]*255*299 + backgroundColor[1]*255*587 + backgroundColor[2]*255*114);
yiq /= 1000;
if (yiq >= 128)
Expand Down
16 changes: 8 additions & 8 deletions Sofa/GUI/Common/src/sofa/gui/common/BaseGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void BaseGUI::configureGUI(sofa::simulation::Node::SPtr groot)
groot->get(defaultPath, sofa::core::objectmodel::BaseContext::SearchRoot);
if (defaultPath)
{
if (!defaultPath->gnuplotPath.getValue().empty())
setGnuplotPath(defaultPath->gnuplotPath.getValue());
if (!defaultPath->d_gnuplotPath.getValue().empty())
setGnuplotPath(defaultPath->d_gnuplotPath.getValue());
}


Expand All @@ -80,20 +80,20 @@ void BaseGUI::configureGUI(sofa::simulation::Node::SPtr groot)
groot->get(background, sofa::core::objectmodel::BaseContext::SearchRoot);
if (background)
{
if (background->image.getValue().empty())
setBackgroundColor(background->color.getValue());
if (background->d_image.getValue().empty())
setBackgroundColor(background->d_color.getValue());
else
setBackgroundImage(background->image.getFullPath());
setBackgroundImage(background->d_image.getFullPath());
}

//Stats
sofa::component::setting::StatsSetting *stats;
groot->get(stats, sofa::core::objectmodel::BaseContext::SearchRoot);
if (stats)
{
setDumpState(stats->dumpState.getValue());
setLogTime(stats->logTime.getValue());
setExportState(stats->exportState.getValue());
setDumpState(stats->d_dumpState.getValue());
setLogTime(stats->d_logTime.getValue());
setExportState(stats->d_exportState.getValue());
#ifdef SOFA_DUMP_VISITOR_INFO
setTraceVisitors(stats->traceVisitors.getValue());
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sofa/GUI/Common/src/sofa/gui/common/BaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void BaseViewer::wait()
void BaseViewer::configure(sofa::component::setting::ViewerSetting* viewerConf)
{
using namespace core::visual;
if (viewerConf->cameraMode.getValue().getSelectedId() == VisualParams::ORTHOGRAPHIC_TYPE)
if (viewerConf->d_cameraMode.getValue().getSelectedId() == VisualParams::ORTHOGRAPHIC_TYPE)
setCameraMode(VisualParams::ORTHOGRAPHIC_TYPE);
else
setCameraMode(VisualParams::PERSPECTIVE_TYPE);
Expand Down
2 changes: 1 addition & 1 deletion Sofa/GUI/Common/src/sofa/gui/common/MouseOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SOFA_GUI_COMMON_API Operation
virtual ~Operation() {}
virtual void configure(PickHandler*picker, MOUSE_BUTTON b) { pickHandle=picker; button=b; }
virtual void configure(PickHandler* picker, sofa::component::setting::MouseButtonSetting* s)
{ setSetting(s); configure(picker,GetMouseId(s->button.getValue().getSelectedId())); }
{ setSetting(s); configure(picker,GetMouseId(s->d_button.getValue().getSelectedId())); }
virtual void start(); /// This function is called each time the mouse is clicked.
virtual void execution() {}
virtual void end(); /// This function is called after each mouse click.
Expand Down
8 changes: 4 additions & 4 deletions Sofa/GUI/Common/src/sofa/gui/common/PickHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ void PickHandler::unload()

Operation *PickHandler::changeOperation(sofa::component::setting::MouseButtonSetting* setting)
{
if (operations[setting->button.getValue().getSelectedId()])
if (operations[setting->d_button.getValue().getSelectedId()])
{
delete operations[setting->button.getValue().getSelectedId()];
operations[setting->button.getValue().getSelectedId()] = nullptr;
delete operations[setting->d_button.getValue().getSelectedId()];
operations[setting->d_button.getValue().getSelectedId()] = nullptr;
}
Operation *mouseOp=OperationFactory::Instanciate(setting->getOperationType());
if (mouseOp)
{
mouseOp->configure(this,setting);
operations[setting->button.getValue().getSelectedId()]=mouseOp;
operations[setting->d_button.getValue().getSelectedId()]=mouseOp;
}

return mouseOp;
Expand Down
16 changes: 8 additions & 8 deletions Sofa/GUI/Qt/src/sofa/gui/qt/QMouseOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ void QAttachOperation::configure(PickHandler *picker, sofa::component::setting::
{
if (const sofa::gui::component::AttachBodyButtonSetting* attachSetting=dynamic_cast<sofa::gui::component::AttachBodyButtonSetting*>(button))
{
AttachOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
AttachOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
setting->d_stiffness.copyValueFrom(&(attachSetting->d_stiffness));
setting->d_arrowSize.copyValueFrom(&(attachSetting->d_arrowSize) );
setting->d_showFactorSize.copyValueFrom(&( attachSetting->d_showFactorSize) ) ;

stiffnessWidget->updateWidgetValue();
arrowSizeWidget->updateWidgetValue();
}
else AttachOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
else AttachOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}
//*******************************************************************************************

Expand All @@ -111,9 +111,9 @@ void QAddRecordedCameraOperation::configure(PickHandler *picker, sofa::component
{
if (dynamic_cast<sofa::gui::component::AddRecordedCameraButtonSetting*>(button))
{
AddRecordedCameraOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
AddRecordedCameraOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}
else AddRecordedCameraOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
else AddRecordedCameraOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}

//*******************************************************************************************
Expand All @@ -127,9 +127,9 @@ void QStartNavigationOperation::configure(PickHandler *picker, sofa::component::
{
if (dynamic_cast<sofa::gui::component::StartNavigationButtonSetting*>(button))
{
StartNavigationOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
StartNavigationOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}
else StartNavigationOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
else StartNavigationOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}

//*******************************************************************************************
Expand All @@ -151,12 +151,12 @@ void QFixOperation::configure(PickHandler *picker, sofa::component::setting::Mou
{
if (const auto* fixSetting=dynamic_cast<sofa::gui::component::FixPickedParticleButtonSetting*>(button))
{
FixOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId() )) ;
FixOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId() )) ;
setting->stiffness.setValue(fixSetting->stiffness.getValue());

stiffnessWidget->updateWidgetValue();
}
else FixOperation::configure(picker,GetMouseId(button->button.getValue().getSelectedId()));
else FixOperation::configure(picker,GetMouseId(button->d_button.getValue().getSelectedId()));
}

//*******************************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ void RealGUI::setBackgroundImage(const std::string& c)

void RealGUI::setViewerConfiguration(sofa::component::setting::ViewerSetting* viewerConf)
{
const type::Vec<2,int> &res=viewerConf->resolution.getValue();
const type::Vec<2,int> &res=viewerConf->d_resolution.getValue();

if (viewerConf->fullscreen.getValue())
if (viewerConf->d_fullscreen.getValue())
setFullScreen();
else
setViewerResolution(res[0], res[1]);
Expand Down
2 changes: 1 addition & 1 deletion Sofa/GUI/Qt/src/sofa/gui/qt/viewer/GLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GLBackend::~GLBackend()

void GLBackend::setPickingMethod(sofa::gui::common::PickHandler* pick, sofa::component::setting::ViewerSetting* viewerConf)
{
if ( viewerConf->objectPickingMethod.getValue().getSelectedId() == gui::common::PickHandler::RAY_CASTING)
if (viewerConf->d_objectPickingMethod.getValue().getSelectedId() == gui::common::PickHandler::RAY_CASTING)
pick->setPickingMethod( gui::common::PickHandler::RAY_CASTING );
else
pick->setPickingMethod( gui::common::PickHandler::SELECTION_BUFFER);
Expand Down

0 comments on commit 2124785

Please sign in to comment.