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

Method buildSceneControls

pj_app/src/ui/Scene3DConfigPanel.cpp:255–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255void Scene3DConfigPanel::buildSceneControls(QVBoxLayout* root) {
256 QSettings settings;
257 settings.beginGroup(QString::fromLatin1(kScene3dSceneControlsGroup));
258 // Each control: init from QSettings (defaults = the User's look-dev pick),
259 // persist + re-apply to the bound dock on every change.
260 const auto wire = [this, &settings](auto* widget, const char* key, auto read, auto signal) {
261 widget->setProperty("settings_key", QString::fromLatin1(key));
262 if (const QVariant saved = settings.value(QString::fromLatin1(key)); saved.isValid()) {
263 read(saved);
264 }
265 // Apply live every tick so the view tracks the scrubber.
266 connect(widget, signal, this, [this]() { applySceneControls(); });
267 // Persist only when the scrub/edit settles — one INI rewrite per drag.
268 connect(widget, &ScrubberBase::editingFinished, this, [this, widget]() {
269 const QString settings_key = widget->property("settings_key").toString();
270 if (auto* dscrub = qobject_cast<DoubleScrubber*>(widget)) {
271 persistControl(settings_key, dscrub->value());
272 } else if (auto* iscrub = qobject_cast<IntScrubber*>(widget)) {
273 persistControl(settings_key, iscrub->value());
274 }
275 });
276 };
277
278 // Eye toggles: checked = visible. Persisted like the other controls; the
279 // icon mirrors the checked state (visibility / visibility_off). The shared
280 // curveVisibilityToggle objectName picks up the QSS rule that keeps these
281 // flat in every state — no checked/hover wash, the glyph is the indicator.
282 const auto make_eye = [this, &settings](const char* key, const QString& tip) {
283 auto* eye = new QToolButton(this);
284 eye->setObjectName(QStringLiteral("curveVisibilityToggle"));
285 eye->setCheckable(true);
286 eye->setAutoRaise(true);
287 eye->setFocusPolicy(Qt::NoFocus);
288 eye->setToolTip(tip);
289 sizeTrailingButton(eye);
290 eye->setProperty("settings_key", QString::fromLatin1(key));
291 eye->setChecked(settings.value(QString::fromLatin1(key), true).toBool());
292 connect(eye, &QToolButton::toggled, this, [this, eye](bool checked) {
293 persistControl(eye->property("settings_key").toString(), checked);
294 setEyeIcon(eye, checked);
295 applySceneControls();
296 });
297 return eye;
298 };
299 const auto add_band = [this, root](const QString& text) { root->addWidget(new SectionHeaderBand(text, this)); };
300
301 // Each band's controls live in a 3-column grid: label | field | trailing
302 // button. Column 1 stretches; column 2 is pinned to the trailing-button width
303 // so plain rows line up with rows that carry an eye/add button — and the Grid
304 // and Transforms sections align with each other. (A QFormLayout can't share a
305 // trailing column across its rows, which is what caused the right-edge drift.)
306 // The label column (0) is pinned to a shared width after both grids are built
307 // (shareLabelColumn below) so the two sections' labels — and therefore fields —
308 // line up vertically even though they are separate layouts.
309 const auto add_grid = [this, root]() {
310 auto* host = new QWidget(this);
311 auto* grid = new QGridLayout(host);
312 grid->setContentsMargins(8, 4, 8, 4);

Callers

nothing calls this directly

Calls 15

sizeTrailingButtonFunction · 0.85
trFunction · 0.85
addGridRowFunction · 0.85
makeScrubberFunction · 0.85
toStringMethod · 0.80
setIconSizeMethod · 0.80
addButtonMethod · 0.80
toIntMethod · 0.80
setDecimalsMethod · 0.80
toDoubleMethod · 0.80
QStringClass · 0.50
QSizeClass · 0.50

Tested by

no test coverage detected