From 997323f9abb13de3542be32741a79f3d3fbd488b Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 24 Jul 2014 19:54:06 +0000 Subject: [PATCH] Graph attribute can now be used to select graph type --- Common/onelabUtils.cpp | 10 +++++++--- Fltk/inputRange.h | 10 ++++++---- Fltk/outputRange.h | 10 ++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index 40541f5be2..ca96de7da9 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -243,18 +243,22 @@ namespace onelabUtils { int num = atoi(graphNum.c_str()); std::vector<double> x, y; std::string xName, yName; + int graphType = 0; std::vector<onelab::number> numbers; onelab::server::instance()->get(numbers); for(unsigned int i = 0; i < numbers.size(); i++){ std::string v = numbers[i].getAttribute("Graph"); v.resize(36, '0'); - if(v[2 * num] == '1'){ + if(v[2 * num] != '0'){ x = getRange(numbers[i]); xName = numbers[i].getShortName(); } - if(v[2 * num + 1] == '1'){ + if(v[2 * num + 1] != '0'){ y = getRange(numbers[i]); yName = numbers[i].getShortName(); + char t = v[2 * num + 1]; + graphType = (t == '1') ? 1 : (t == '2') ? 2 : (t == '3') ? 3 : + (t == '4') ? 4 : 3; } } if(x.empty()){ @@ -274,7 +278,7 @@ namespace onelabUtils { else{ view = new PView(xName, yName, x, y); view->getData()->setFileName("ONELAB" + graphNum); - view->getOptions()->intervalsType = PViewOptions::Discrete; + view->getOptions()->intervalsType = graphType; view->getOptions()->autoPosition = num / 2 + 2; } changed = true; diff --git a/Fltk/inputRange.h b/Fltk/inputRange.h index 7b799d958d..b755b33658 100644 --- a/Fltk/inputRange.h +++ b/Fltk/inputRange.h @@ -173,14 +173,14 @@ class inputRange : public Fl_Group { 37, 38, 39, 40, 43, 44, 45, 46, 49, 50, 51, 52}; for(int i = 0; i < 36; i++){ - if(_graph_val[i] == '1') + if(_graph_val[i] != '0') ((Fl_Menu_Item*)_graph_menu->menu())[index[i]].set(); else ((Fl_Menu_Item*)_graph_menu->menu())[index[i]].clear(); } } bool yellow = false; - for(int i = 0; i < 36; i++) if(_graph_val[i] == '1') yellow = true; + for(int i = 0; i < 36; i++) if(_graph_val[i] != '0') yellow = true; if(yellow){ _graph_butt->value(1); _graph_butt->selection_color(FL_YELLOW); @@ -222,8 +222,10 @@ class inputRange : public Fl_Group { 25, 26, 27, 28, 31, 32, 33, 34, 37, 38, 39, 40, 43, 44, 45, 46, 49, 50, 51, 52}; - for(int i = 0; i < 36; i++) - v[i] = b->_graph_menu->menu()[index[i]].value() ? '1' : '0'; + for(int i = 0; i < 36; i++){ + // 1=iso, 2=continuous, 3=discrete, 4=numeric + v[i] = b->_graph_menu->menu()[index[i]].value() ? '3' : '0'; + } b->_set_graph_value(v, false); b->doCallbackOnValues(false); b->do_callback(); diff --git a/Fltk/outputRange.h b/Fltk/outputRange.h index 72d09f5185..4bcf7237da 100644 --- a/Fltk/outputRange.h +++ b/Fltk/outputRange.h @@ -32,14 +32,14 @@ class outputRange : public Fl_Group { 37, 38, 39, 40, 43, 44, 45, 46, 49, 50, 51, 52}; for(int i = 0; i < 36; i++){ - if(_graph_val[i] == '1') + if(_graph_val[i] != '0') ((Fl_Menu_Item*)_graph_menu->menu())[index[i]].set(); else ((Fl_Menu_Item*)_graph_menu->menu())[index[i]].clear(); } } bool yellow = false; - for(int i = 0; i < 36; i++) if(_graph_val[i] == '1') yellow = true; + for(int i = 0; i < 36; i++) if(_graph_val[i] != '0') yellow = true; if(yellow){ _graph_butt->value(1); _graph_butt->selection_color(FL_YELLOW); @@ -60,8 +60,10 @@ class outputRange : public Fl_Group { 25, 26, 27, 28, 31, 32, 33, 34, 37, 38, 39, 40, 43, 44, 45, 46, 49, 50, 51, 52}; - for(int i = 0; i < 36; i++) - v[i] = b->_graph_menu->menu()[index[i]].value() ? '1' : '0'; + for(int i = 0; i < 36; i++){ + // 1=iso, 2=continuous, 3=discrete, 4=numeric + v[i] = b->_graph_menu->menu()[index[i]].value() ? '3' : '0'; + } b->_set_graph_value(v, false); b->do_callback(); } -- GitLab