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

Method rebindClipboardCurveKeys

pj_plotting/widget/src/PlotWidget.cpp:1128–1162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128void PlotWidget::rebindClipboardCurveKeys(QDomElement& plot_element) const {
1129 if (catalog_ == nullptr) {
1130 return;
1131 }
1132 const auto resolve = [this](const QString& topic, const QString& field) -> QString {
1133 if (topic.isEmpty() || field.isEmpty()) {
1134 return {};
1135 }
1136 for (const CurveDescriptor& descriptor : catalog_->curves()) {
1137 if (descriptor.topic_name == topic && descriptor.field_path == field) {
1138 return descriptor.name;
1139 }
1140 }
1141 return {};
1142 };
1143
1144 for (QDomElement curve = plot_element.firstChildElement(QStringLiteral("curve")); !curve.isNull();
1145 curve = curve.nextSiblingElement(QStringLiteral("curve"))) {
1146 if (curve.hasAttribute(QStringLiteral("x_topic"))) {
1147 const QString x_key =
1148 resolve(curve.attribute(QStringLiteral("x_topic")), curve.attribute(QStringLiteral("x_field")));
1149 const QString y_key =
1150 resolve(curve.attribute(QStringLiteral("y_topic")), curve.attribute(QStringLiteral("y_field")));
1151 if (!x_key.isEmpty() && !y_key.isEmpty()) {
1152 curve.setAttribute(QStringLiteral("curve_x"), x_key);
1153 curve.setAttribute(QStringLiteral("curve_y"), y_key);
1154 }
1155 continue;
1156 }
1157 const QString key = resolve(curve.attribute(QStringLiteral("topic")), curve.attribute(QStringLiteral("field")));
1158 if (!key.isEmpty()) {
1159 curve.setAttribute(QStringLiteral("name"), key);
1160 }
1161 }
1162}
1163
1164void PlotWidget::canvasContextMenuTriggered(const QPoint& pos) {
1165 if (!context_menu_enabled_) {

Callers

nothing calls this directly

Calls 4

curvesMethod · 0.80
isEmptyMethod · 0.45
isNullMethod · 0.45
setAttributeMethod · 0.45

Tested by

no test coverage detected