session: plots carry row and width; files without row load one cell per row
This commit is contained in:
1 parent
ae1d262be4
commit
62ceb69278
5 files changed
+203
-6
No files matched your search
+14
-1
@@ -611,6 +611,15 @@ bool load_layout(const std::string& path, LayoutState& out) {
|
||||
st.rows.back().signals = names;
|
||||
} else if (key == "weight") {
|
||||
st.rows.back().weight = std::strtod(value.c_str(), nullptr);
|
||||
} else if (key == "row") {
|
||||
try {
|
||||
const int r = std::stoi(value);
|
||||
if (r >= 0) st.rows.back().row = r;
|
||||
} catch (...) {
|
||||
}
|
||||
} else if (key == "width") {
|
||||
const double w = std::strtod(value.c_str(), nullptr);
|
||||
if (w > 0.0) st.rows.back().width = w;
|
||||
}
|
||||
} else if (section == Section::Math && !st.math.empty()) {
|
||||
MathChannel& m = st.math.back();
|
||||
@@ -784,7 +793,11 @@ bool save_layout(const std::string& path, const LayoutState& state) {
|
||||
o << "relative_time = " << (state.relative_time ? "true" : "false") << "\n";
|
||||
if (state.capture_packets > 0) o << "capture_packets = " << state.capture_packets << "\n";
|
||||
for (const auto& row : state.rows) {
|
||||
o << "\n[[plot]]\nweight = " << row.weight << "\nsignals = [";
|
||||
o << "\n[[plot]]\n";
|
||||
// A row of -1 is a state built without the split (nothing in the app does that now); leaving the
|
||||
// key out keeps it readable as the one-cell-per-row file it is.
|
||||
if (row.row >= 0) o << "row = " << row.row << "\nwidth = " << row.width << "\n";
|
||||
o << "weight = " << row.weight << "\nsignals = [";
|
||||
for (std::size_t i = 0; i < row.signals.size(); ++i) {
|
||||
if (i != 0) o << ", ";
|
||||
o << toml_escape(row.signals[i]);
|
||||
|
||||
Reference in new issue
Block a user