CEBL  2.1
InfoBar.cpp
Go to the documentation of this file.
1 /*
2  * InfoBar.cpp
3  * \author Alex Klein
4  *
5  * Displays information at bottom of CEBL window about several settings
6  * and object statuses regardless of current tab
7  */
8 #include "InfoBar.hpp"
9 
11 {
12  this->cebl_gtk_widget_container = gtk_hbox_new(false, 10);
13 
14  //instantiate labels
15  for(int i=0;i<n_labels;i++){
16  this->setWidgetContainer(GTK_WIDGET(gtk_label_new(NULL)));
17  }
18 
19  this->view = v;
20 
21  n_lags=0;
22  n_classes=0;
23  trained = false;
24  classifier = "";
25  c_trained = false;
26  //Set label text
27  this->update();
28 
29  gtk_widget_show_all(cebl_gtk_widget_container);
30 }
31 
33 {
34 
35 }
36 
38 
39  //gchar * for label text
40  gchar * text;
41  //string representation of label text used to convert from string to gchar
42  string str_text;
43 
44  //buffer used for integer to string conversions
45  //max lags = 500 = 3 characters
46  //max classes = 50 = 2 characters
47  char buffer[3];
48 
49  //Get labels from container
50  GList* labels = gtk_container_get_children(
51  GTK_CONTAINER(this->getContainer()));
52 
53  //Make sure current feature is lag and update lags label
54  if (this->view->getModel()->featuresGetSelected()=="Lag")
55  {//Lags label
56 
57  std::map<std::string, CEBL::Param> params =
58  this->view->getModel()->featureGetParams();
59 
60  n_lags = params["lags"].getInt();
61  //convert int lags to string
62  std::sprintf(buffer,"%d",n_lags);
63  str_text = "Number of Lags: " + string(buffer);
64  text = (gchar *) str_text.c_str();
65 
66  gtk_label_set_text(GTK_LABEL(labels->data), text);
67  }//end lags label
68 
69  labels=labels->next;
70 
71  {//Classes label
72  n_classes = this->view->getModel()->trainingGetNumClasses();
73  //convert int classes to string
74  std::sprintf(buffer,"%d", n_classes);
75  str_text = "Number of Classes: " + string(buffer);
76  text = (gchar *)str_text.c_str();
77  gtk_label_set_text(GTK_LABEL(labels->data), text);
78  }
79 
80  labels=labels->next;
81 
82  {//Training data label
83  trained = this->view->getModel()->trainingDataIsLoaded();
84  if(trained)
85  text = (gchar *)"Training Data Ready: true";
86  else
87  text = (gchar *)"Training Data Ready: false";
88  gtk_label_set_text(GTK_LABEL(labels->data), text);
89  }
90  labels=labels->next;
91 
92  {//Classifier label
93  classifier = this->view->getModel()->classifiersGetSelected();
94  str_text = "Classifier: " + classifier;
95  text = (gchar *)str_text.c_str();
96  gtk_label_set_text(GTK_LABEL(labels->data), text);
97  }
98  labels=labels->next;
99 
100  {//Classifier Trained label
101  c_trained = this->view->getModel()->classifierIsTrained();
102  if(c_trained)
103  text = (gchar *)"Classifier Trained: true";
104  else
105  text = (gchar *)"Classifier Trained: false";
106  gtk_label_set_text(GTK_LABEL(labels->data), text);
107  }
108 }