28 GtkWidget *
title = gtk_label_new(
"");
29 gtk_label_set_markup(GTK_LABEL(title),
"<big>Features</big>");
31 TabAdd(gtk_hseparator_new());
35 this->continue_plotting =
false;
40 GtkWidget *hbox_features = gtk_hbox_new(
false, 0);
42 this->updating_view =
false;
43 this->num_features = 0;
44 this->selected_feature =
"";
45 combo_features = gtk_combo_box_new_text();
49 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_features),0);
50 g_signal_connect(G_OBJECT(combo_features),
52 G_CALLBACK(CB_changeFeature),
55 gtk_box_pack_start(GTK_BOX(hbox_features), combo_features,
false,
false, 0);
58 check_feature_trained = gtk_check_button_new_with_label(
"Feature Trained");
59 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_feature_trained),
false);
60 gtk_widget_set_sensitive(check_feature_trained,
false);
62 gtk_box_pack_end(GTK_BOX(hbox_features),check_feature_trained,
false,
false, 0);
64 gtk_widget_show_all(hbox_features);
70 GtkWidget * btn_box1 = gtk_hbutton_box_new();
71 gtk_button_box_set_layout(GTK_BUTTON_BOX(btn_box1),GTK_BUTTONBOX_START);
73 btn_start = gtk_button_new_with_label(
"Start Monitoring");
75 g_signal_connect(G_OBJECT(btn_start),
77 G_CALLBACK(CB_startPlot),
80 btn_stop = gtk_button_new_with_label(
"Stop");
81 gtk_widget_set_sensitive(btn_stop,
false);
83 g_signal_connect(G_OBJECT(btn_stop),
85 G_CALLBACK(CB_stopPlot),
88 gtk_box_pack_start(GTK_BOX(btn_box1),btn_start,
false,
false,2);
89 gtk_box_pack_start(GTK_BOX(btn_box1),btn_stop,
false,
false,2);
90 gtk_box_pack_start(GTK_BOX(btn_box1),gtk_label_new(
"Data Source: "),
false,
false, 2);
91 gtk_box_pack_start(GTK_BOX(btn_box1),
getView()->getDataSource()->getCombo(),
false,
false,2);
95 panel_box = gtk_vbox_new(
false, 0);
98 GtkWidget *features_box = gtk_vbox_new(
false,0);
99 gtk_box_pack_start(GTK_BOX(features_box),panel_box,
false,
false,2);
100 gtk_box_pack_start(GTK_BOX(features_box),btn_box1,
false,
false,2);
111 if(gtk_combo_box_get_active(GTK_COMBO_BOX(combo_features))==-1)
112 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_features),0);
124 this->updating_view =
true;
133 this->selected_feature = model_selected_feature;
134 this->feature_names = names;
135 for(
int i = this->num_features-1; i >= 0; i--)
137 gtk_combo_box_remove_text(GTK_COMBO_BOX(combo_features),i);
139 this->num_features = names.size();
142 for(
unsigned int i=0;i<names.size();i++)
144 gtk_combo_box_append_text(GTK_COMBO_BOX(combo_features),names[i].c_str());
145 if(names[i]==model_selected_feature)
147 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_features),i);
150 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_feature_trained),
153 if (this->panel != NULL)
155 gtk_container_remove(GTK_CONTAINER(this->panel_box),this->panel->
getContainer());
161 if(model_selected_feature !=
"")
165 std::map<std::string, CEBL::Param> params = model->
featureGetParams(model_selected_feature);
171 cerr <<
"ERROR: exception occured when trying to get parameters for feature.\n";
174 if (this->panel != NULL)
176 gtk_container_add(GTK_CONTAINER(this->panel_box),this->panel->
getContainer());
177 gtk_widget_show_all(this->panel_box);
184 if(
getView()->getModel()->dataIsStarted())
186 gtk_widget_set_sensitive(combo_features,
false);
187 gtk_widget_set_sensitive(btn_start,
false);
188 gtk_widget_set_sensitive(panel_box,
false);
189 gtk_widget_set_sensitive(btn_stop,
true);
193 gtk_widget_set_sensitive(combo_features,
true);
194 gtk_widget_set_sensitive(panel_box,
true);
195 gtk_widget_set_sensitive(btn_start,
true);
196 gtk_widget_set_sensitive(btn_stop,
false);
198 this->updating_view =
false;
205 if(this->panel != NULL){
215 this->stopPlotting();
234 void TabFeatures::createPlot()
241 TabAdd(*plot,
true,
true, 0);
251 void TabFeatures::startPlotting()
253 if(this->panel != NULL){
263 WidgetUtils::AlertError(
"Error Starting Data Source",
"There was an error starting the data source. \n("+
string(e.what())+
")");
266 if(!
getView()->getModel()->dataIsStarted())
268 WidgetUtils::AlertError(
"Error Starting Data Source",
"There was an error starting the data source. Check device configuration.");
272 this->continue_plotting =
true;
274 g_timeout_add(100, timedPlot,
this);
281 gint TabFeatures::timedPlot(gpointer parent)
292 if(!tab->continuePlotting())
302 if(
min(data.
size1(),72) != tab->plot_size)
304 tab->plot_size =
min(data.
size1(),72);
308 ublas::matrix<double> d = (data.
getMatrix());
312 tab->plot->
Plot(data);
321 cout << e.
what() <<
"\n";
325 string msg =
"Failed to process data. \n(" + string(e.what()) +
")";
333 void TabFeatures::stopPlotting()
335 this->continue_plotting =
false;
345 void TabFeatures::CB_startPlot(GtkWidget *w, gpointer data)
348 tab->startPlotting();
350 void TabFeatures::CB_stopPlot(GtkWidget *w, gpointer data)
357 void TabFeatures::CB_changeFeature(GtkWidget *w, gpointer data)
364 if(tab->num_features > 0 && !tab->updating_view)
366 string feature = gtk_combo_box_get_active_text(GTK_COMBO_BOX(tab->combo_features));
369 if(feature != tab->selected_feature)
372 if(tab->panel != NULL){
382 cerr <<
"Error selecting feature.\n";