9#include <OpenSim/Common/Component.h>
10#include <OpenSim/Common/Property.h>
24 public OpenSim::Component,
28 OpenSim_DECLARE_LIST_PROPERTY(scaling_parameter_overrides,
ScalingParameterOverride,
"A sequence of `ScalingParameterOverride`s that should be used in place of the default values used by the `ScalingStep`s.");
32 constructProperties();
33 finalizeFromProperties();
34 finalizeConnections(*
this);
39 Component{source.string(), false}
41 constructProperties();
42 updateFromXMLDocument();
43 finalizeFromProperties();
44 finalizeConnections(*
this);
49 if (getNumImmediateSubcomponents() == 0) {
52 const auto lst = getComponentList<ScalingStep>();
53 return lst.begin() != lst.end();
58 if (getNumImmediateSubcomponents() == 0) {
61 const auto lst = getComponentList<ScalingStep>();
62 return std::distance(lst.begin(), lst.end());
67 return getComponentList<ScalingStep>();
72 addComponent(step.release());
74 finalizeConnections(*
this);
75 finalizeFromProperties();
80 if (not step.hasOwner()) {
83 if (&step.getOwner() !=
this) {
87 removeComponent(&step);
89 finalizeConnections(*
this);
90 finalizeFromProperties();
117 if (getNumImmediateSubcomponents() == 0) {
127 auto msg = std::format(
"{}: declares a scaling parameter ({}) that has the same name as another scaling parameter, but they differ: the engine cannot figure out how to rectify this difference. The parameter should have a different name, or a disambiguating prefix added to it",
128 step.getAbsolutePathString(),
131 throw std::runtime_error{std::move(msg)};
139 for (
int i = 0; i < overrides.size(); ++i) {
150 mutateScalingParammeterOverridesWithNewOverride(scalingParamName, newValue);
151 finalizeFromProperties();
155 void saveTo(
const std::filesystem::path& p)
const
161 void constructProperties()
163 constructProperty_scaling_parameter_overrides();
166 void mutateScalingParammeterOverridesWithNewOverride(
const std::string& scalingParamName,
ScalingParameterValue newValue)
170 for (
int i = 0; i < overrides.size(); ++i) {
171 const ScalingParameterOverride& o = overrides.getValue(i);
172 if (o.get_parameter_name() == scalingParamName) {
173 updProperty_scaling_parameter_overrides().updValue(i).set_parameter_value(newValue);
179 int idx = updProperty_scaling_parameter_overrides().appendValue(ScalingParameterOverride{scalingParamName, newValue});
180 updProperty_scaling_parameter_overrides().updValue(idx).set_parameter_name(scalingParamName);
181 updProperty_scaling_parameter_overrides().updValue(idx).set_parameter_value(newValue);
196 throw std::runtime_error{
"component updating not implemented for this IComponentAccessor" };
Definition open_sim_helpers.h:55
Definition model_warper_v3_document.h:25
bool removeScalingStep(ScalingStep &step)
Definition model_warper_v3_document.h:78
const OpenSim::Component & implGetComponent() const final
Definition model_warper_v3_document.h:184
bool hasScalingSteps() const
Definition model_warper_v3_document.h:47
ModelWarperV3Document(const std::filesystem::path &source)
Constructs a ModelWarperV3Document by loading its contents from source.
Definition model_warper_v3_document.h:38
void addScalingStep(std::unique_ptr< ScalingStep > step)
Definition model_warper_v3_document.h:70
size_t getNumScalingParameters() const
Definition model_warper_v3_document.h:109
auto iterateScalingSteps() const
Definition model_warper_v3_document.h:65
size_t getNumScalingSteps() const
Definition model_warper_v3_document.h:56
bool implCanUpdComponent() const final
Definition model_warper_v3_document.h:189
ModelWarperV3Document()
Definition model_warper_v3_document.h:30
bool hasScalingParameters() const
Definition model_warper_v3_document.h:94
ScalingParameters getEffectiveScalingParameters() const
Definition model_warper_v3_document.h:114
bool setScalingParameterOverride(const std::string &scalingParamName, ScalingParameterValue newValue)
Definition model_warper_v3_document.h:148
void saveTo(const std::filesystem::path &p) const
Definition model_warper_v3_document.h:155
OpenSim::Component & implUpdComponent() final
Definition model_warper_v3_document.h:194
Definition scaling_parameter_declaration.h:16
const ScalingParameterValue & default_value() const
Definition scaling_parameter_declaration.h:24
const std::string & name() const
Definition scaling_parameter_declaration.h:23
Definition scaling_parameter_override.h:14
Definition scaling_parameters.h:14
auto insert_or_assign(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:35
auto try_emplace(const std::string &name, const ScalingParameterValue &value)
Definition scaling_parameters.h:30
size_t size() const
Definition scaling_parameters.h:26
Definition scaling_step.h:25
Definition versioned_component_accessor.h:8
Definition component_registry.h:14
double ScalingParameterValue
Definition scaling_parameter_value.h:9