Skip to content

Commit 6a88dba

Browse files
committed
Merge branch 'master' of github.com:sofa-framework/PluginExample into 25_05_add_notify_dash
2 parents 1699a29 + cb6acf8 commit 6a88dba

17 files changed

Lines changed: 132 additions & 88 deletions

.github/workflows/ci.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-22.04, macos-13, windows-2022]
15+
os: [ubuntu-22.04, macos-14, windows-2022]
1616
sofa_branch: [master]
1717

1818
steps:
@@ -69,18 +69,31 @@ jobs:
6969
echo ${CCACHE_BASEDIR}
7070
ccache -s
7171
fi
72+
73+
- name: Sanitize artifact name
74+
id: sanitize
75+
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
76+
# Characters removed: " : < > | * ? \r \n \ /
77+
# Spaces are replaced with underscores
78+
# This sanitization prevents errors in artifact creation and retrieval
79+
shell: pwsh
80+
run: |
81+
$originalName = "PluginExample_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
82+
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
83+
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
84+
7285
- name: Create artifact
7386
id: create-artifact
74-
uses: actions/upload-artifact@v2
87+
uses: actions/upload-artifact@v4.4.0
7588
with:
76-
name: PluginExample_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
89+
name: ${{ steps.sanitize.outputs.artifact_name }}
7790
path: ${{ env.WORKSPACE_INSTALL_PATH }}
7891

7992
- name: Install artifact
8093
id: install-artifact
81-
uses: actions/download-artifact@v2
94+
uses: actions/download-artifact@v4.1.7
8295
with:
83-
name: PluginExample_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
96+
name: ${{ steps.sanitize.outputs.artifact_name }}
8497
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}
8598

8699
- name: Set env vars for tests
@@ -131,6 +144,7 @@ jobs:
131144
132145
binary_status=$([ '${{ steps.create-artifact.outcome }}' == 'success' ] && \
133146
[ '${{ steps.install-artifact.outcome }}' == 'success' ] && \
147+
[ '${{ steps.sanitize.outcome }}' == 'success' ] && \
134148
echo 'true' || echo 'false')
135149
136150
@@ -151,7 +165,7 @@ jobs:
151165
continue-on-error: true
152166
steps:
153167
- name: Get artifacts
154-
uses: actions/download-artifact@v2
168+
uses: actions/download-artifact@v4.1.7
155169
with:
156170
path: artifacts
157171

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ project(PluginExample VERSION 1.0 LANGUAGES CXX)
66
find_package(Sofa.Component.Visual REQUIRED) # Needed for VisualModelImpl
77

88
## Optional dependencies
9-
sofa_find_package(Sofa.GUI.Qt)
10-
sofa_find_package(Qt5 COMPONENTS Core) # Dependency to Qt5Core (needed for qt5_wrap_cpp)
9+
sofa_find_package(Sofa.GUI.Qt QUIET)
10+
sofa_find_package(Qt5 COMPONENTS Core QUIET) # Dependency to Qt5Core (needed for qt5_wrap_cpp)
1111

1212
# List all files
1313
set(PLUGINEXAMPLE_SRC_DIR src/PluginExample)

PluginExample_test/MyBehaviorModel_test.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@ using std::vector;
2626

2727
#include <sofa/testing/BaseTest.h>
2828
using sofa::testing::BaseTest;
29-
3029
using ::testing::Types;
3130

31+
using namespace pluginexample;
32+
3233
namespace {
3334

3435
class MyBehaviorModel_test : public BaseTest,
3536
public ::testing::WithParamInterface<unsigned>
3637
{
3738
public:
38-
using MyBehaviorModel = sofa::component::behaviormodel::MyBehaviorModel;
39+
using MyBehaviorModel = pluginexample::MyBehaviorModel;
3940

40-
void TearDown()
41+
void doTearDown() override
4142
{
4243

4344
}
4445

45-
void SetUp()
46+
void doSetUp() override
4647
{
4748
m_behaviorModel = sofa::core::objectmodel::New< MyBehaviorModel >();
4849
}

src/PluginExample/MyBehaviorModel.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <sofa/core/ObjectFactory.h>
2525

2626

27-
namespace sofa::component::behaviormodel
27+
namespace pluginexample
2828
{
2929

3030
MyBehaviorModel::MyBehaviorModel()
@@ -52,8 +52,11 @@ void MyBehaviorModel::updatePosition(double dt)
5252
SOFA_UNUSED(dt);
5353
}
5454

55-
int MyBehaviorModelClass = core::RegisterObject("Dummy component with a custom widget.").add< MyBehaviorModel >();
56-
55+
void registerMyBehaviorModel(sofa::core::ObjectFactory* factory)
56+
{
57+
factory->registerObjects(core::ObjectRegistrationData("Dummy component with a custom widget.")
58+
.add< MyBehaviorModel >());
59+
}
5760

58-
} // namespace sofa::component::behaviormodel
61+
} // namespace pluginexample
5962

src/PluginExample/MyBehaviorModel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <sofa/core/BehaviorModel.h>
2727

2828

29-
namespace sofa::component::behaviormodel
29+
namespace pluginexample
3030
{
3131

3232
/**
@@ -52,5 +52,5 @@ class SOFA_PLUGINEXAMPLE_API MyBehaviorModel : public sofa::core::BehaviorModel
5252
};
5353

5454

55-
} // sofa::component::behaviormodel
55+
} // namespace pluginexample
5656

src/PluginExample/MyDataWidgetUnsigned.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <sofa/helper/Factory.h>
2525

2626

27-
namespace sofa::gui::qt
27+
namespace pluginexample
2828
{
2929

3030
/*
@@ -112,4 +112,4 @@ void MyDataWidgetUnsigned::change()
112112
}
113113

114114

115-
} // namespace sofa::gui::qt
115+
} // namespace pluginexample

src/PluginExample/MyDataWidgetUnsigned.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <QString>
3232

3333

34-
namespace sofa::gui::qt
34+
namespace pluginexample
3535
{
3636

3737
/**
@@ -65,4 +65,4 @@ protected slots:
6565
};
6666

6767

68-
} // namespace sofa::gui::qt
68+
} // namespace pluginexample

src/PluginExample/MyMappingPendulumInPlane.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@
2727
#include <sofa/defaulttype/VecTypes.h>
2828

2929

30-
namespace sofa::component::mapping
30+
namespace pluginexample
3131
{
3232

3333
using namespace sofa::defaulttype;
3434

35-
36-
int MyMappingPendulumInPlaneClass = core::RegisterObject("Mapping from an angle to a point in 2D")
35+
void registerMyMappingPendulumInPlane(sofa::core::ObjectFactory* factory)
36+
{
37+
factory->registerObjects(core::ObjectRegistrationData("Mapping from an angle to a point in 2D.")
3738
.add< MyMappingPendulumInPlane<Vec1Types, Vec3Types> >()
38-
.add< MyMappingPendulumInPlane<Vec1Types, Vec2Types> >()
39-
;
39+
.add< MyMappingPendulumInPlane<Vec1Types, Vec2Types> >());
40+
}
4041

4142
template class SOFA_PLUGINEXAMPLE_API MyMappingPendulumInPlane<Vec1Types, Vec3Types>;
4243
template class SOFA_PLUGINEXAMPLE_API MyMappingPendulumInPlane<Vec1Types, Vec2Types>;
4344

4445

4546

46-
} // namespace sofa::component::mapping
47-
47+
} // namespace pluginexample

src/PluginExample/MyMappingPendulumInPlane.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <sofa/helper/OptionsGroup.h>
2929

3030

31-
namespace sofa::component::mapping
31+
namespace pluginexample
3232
{
3333

3434
using type::vector;
@@ -84,5 +84,5 @@ class MyMappingPendulumInPlane: public core::Mapping<TIn, TOut>
8484
vector<Vec2> gap;
8585
};
8686

87-
} // namespace sofa::component::mapping
87+
} // namespace pluginexample
8888

src/PluginExample/MyMappingPendulumInPlane.inl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using std::cerr;
3232
using std::endl;
3333

3434

35-
namespace sofa::component::mapping
35+
namespace pluginexample
3636
{
3737

3838
using helper::ReadAccessor;
@@ -57,8 +57,8 @@ MyMappingPendulumInPlane<In, Out>::~MyMappingPendulumInPlane()
5757
template <class In, class Out>
5858
void MyMappingPendulumInPlane<In, Out>::init()
5959
{
60-
ReadAccessor<Data<VecOutCoord> > out (*this->toModel->read(core::ConstVecCoordId::position()));
61-
WriteAccessor<Data<VecInCoord> > in (*this->fromModel->write(core::VecCoordId::position()));
60+
ReadAccessor<Data<VecOutCoord> > out (*this->toModel->read(core::vec_id::read_access::position));
61+
WriteAccessor<Data<VecInCoord> > in (*this->fromModel->write(core::vec_id::write_access::position));
6262
WriteAccessor<Data<vector<OutReal> > > distances (d_length);
6363
if (distances.size() != out.size()) // values not read from file
6464
{
@@ -80,7 +80,7 @@ void MyMappingPendulumInPlane<In, Out>::draw(const core::visual::VisualParams* v
8080
{
8181
if (!vparams->displayFlags().getShowMappings()) return;
8282

83-
ReadAccessor<Data<VecOutCoord> > out (*this->toModel->read(core::ConstVecCoordId::position()));
83+
ReadAccessor<Data<VecOutCoord> > out (*this->toModel->read(core::vec_id::read_access::position));
8484
std::vector< Vec3 > points(out.size());
8585

8686
for (unsigned int i=0; i<out.size(); i++)
@@ -206,4 +206,4 @@ void MyMappingPendulumInPlane<In, Out>::applyDJT(const core::MechanicalParams* m
206206
}
207207

208208

209-
} // namespace sofa::component::mapping
209+
} // namespace pluginexample

0 commit comments

Comments
 (0)