Skip to content

Commit 474e925

Browse files
oscplot: fix math feature
ensures that channels whose names end _i and _q are properly read and added when creating math channels Signed-off-by: Cristina Suteu <[email protected]>
1 parent 4441374 commit 474e925

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

Diff for: oscplot.c

+23-6
Original file line numberDiff line numberDiff line change
@@ -5361,7 +5361,7 @@ int osc_plot_ini_read_handler (OscPlot *plot, int line, const char *section,
53615361
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(priv->builder, "labelYMax")));
53625362
gtk_widget_hide(priv->y_axis_min);
53635363
gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(priv->builder, "labelYMin")));
5364-
}
5364+
}
53655365
} else if (MATCH_NAME("user_y_axis_max"))
53665366
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->y_axis_max), atof(value));
53675367
else if (MATCH_NAME("user_y_axis_min"))
@@ -6109,18 +6109,31 @@ static gint channel_compare(gconstpointer a, gconstpointer b)
61096109
static GSList * math_expression_get_iio_channel_list(const char *expression, struct iio_context *ctx, const char *device, bool *has_invalid_ch)
61106110
{
61116111
GSList *chn_list = NULL;
6112-
GRegex *regex;
6113-
GMatchInfo *info;
6112+
GRegex *regex, *regex_i, *regex_q;
6113+
GMatchInfo *info, *info_i, *info_q;
61146114
gchar *chn_name;
61156115
struct iio_device *iio_dev;
61166116
struct iio_channel *iio_chn;
6117-
gboolean invalid_list = false, is_match;
6117+
gboolean invalid_list = false, is_match = false, match_q, match_i, match;
61186118

61196119
if (!device || !(iio_dev = iio_context_find_device(ctx, device)))
61206120
return NULL;
61216121

61226122
regex = g_regex_new("voltage[0-9]+", 0, 0, NULL);
6123-
is_match = g_regex_match(regex, expression, 0, &info);
6123+
regex_i = g_regex_new("voltage[0-9]+_i", 0, 0 , NULL);
6124+
regex_q = g_regex_new("voltage[0-9]+_q", 0, 0 , NULL);
6125+
match = g_regex_match(regex, expression, 0, &info);
6126+
match_i = g_regex_match(regex_i, expression, 0, &info_i);
6127+
match_q = g_regex_match(regex_q, expression, 0, &info_q);
6128+
6129+
6130+
if (match_i || match_q || match)
6131+
is_match = true;
6132+
if (match_i)
6133+
info = info_i;
6134+
if (match_q)
6135+
info = info_q;
6136+
61246137
if (!is_match) {
61256138
invalid_list = true;
61266139
} else {
@@ -6137,7 +6150,11 @@ static GSList * math_expression_get_iio_channel_list(const char *expression, str
61376150
} while (g_match_info_next(info, NULL) && !invalid_list);
61386151
}
61396152
g_match_info_free(info);
6153+
g_match_info_free(info_q);
6154+
g_match_info_free(info_i);
61406155
g_regex_unref(regex);
6156+
g_regex_unref(regex_i);
6157+
g_regex_unref(regex_q);
61416158

61426159
if (invalid_list) {
61436160
if (chn_list)
@@ -7039,7 +7056,7 @@ static void create_plot(OscPlot *plot)
70397056
g_error_free(err);
70407057
gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(plot->priv->provider),OSC_STYLE_FILE_PATH"styles.css",NULL);
70417058
}
7042-
7059+
70437060
//gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(plot->priv->provider),"styles.css",NULL);
70447061
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(plot->priv->provider), GTK_STYLE_PROVIDER_PRIORITY_USER);
70457062
style_context = gtk_widget_get_style_context(GTK_WIDGET(priv->databox));

0 commit comments

Comments
 (0)