MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / setValues

Method setValues

pj_plotting/widget/src/ParameterForm.cpp:196–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196void ParameterForm::setValues(const nlohmann::json& values) {
197 silent_ = true;
198 for (Row& r : rows_) {
199 if (!values.contains(r.spec.name)) {
200 continue;
201 }
202 const nlohmann::json& v = values.at(r.spec.name);
203 switch (r.spec.type) {
204 case ParamType::kInteger:
205 if (v.is_number()) {
206 qobject_cast<QSpinBox*>(r.editor)->setValue(v.get<int>());
207 }
208 break;
209 case ParamType::kNumber:
210 if (v.is_number()) {
211 qobject_cast<QLineEdit*>(r.editor)->setText(QString::number(v.get<double>(), 'g', 17));
212 }
213 break;
214 case ParamType::kBoolean:
215 if (v.is_boolean()) {
216 qobject_cast<ToggleSwitch*>(r.editor)->setChecked(v.get<bool>(), false);
217 }
218 break;
219 case ParamType::kEnum: {
220 auto* cb = qobject_cast<ComboBox*>(r.editor);
221 for (std::size_t i = 0; i < r.spec.values.size(); ++i) {
222 if (r.spec.values[i].value == v) {
223 cb->setCurrentIndex(static_cast<int>(i));
224 break;
225 }
226 }
227 break;
228 }
229 case ParamType::kString:
230 if (v.is_string()) {
231 qobject_cast<QLineEdit*>(r.editor)->setText(QString::fromStdString(v.get<std::string>()));
232 }
233 break;
234 case ParamType::kText:
235 if (v.is_string()) {
236 qobject_cast<QPlainTextEdit*>(r.editor)->setPlainText(QString::fromStdString(v.get<std::string>()));
237 }
238 break;
239 }
240 }
241 silent_ = false;
242 updateConditionalVisibility();
243}
244
245void ParameterForm::updateConditionalVisibility() {
246 const nlohmann::json current = values();

Callers 2

setWidgetsFromParamsMethod · 0.45
TESTFunction · 0.45

Calls 7

atMethod · 0.80
setPlainTextMethod · 0.80
containsMethod · 0.45
setValueMethod · 0.45
setTextMethod · 0.45
setCheckedMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.36