diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 97a999ea10d4af1b6d8a1167f0e9ddd35c0d2ad8..9f230f0209cbea2b6f0fdbd5ec0063b8a4b8646b 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -408,20 +408,19 @@ void Msg::ProgressMeter(int n, int N, const char *fmt, ...) if(strlen(fmt)) strcat(str, " "); char str2[1024]; - sprintf(str2, "(%d %%)", _progressMeterCurrent); - strcat(str, str2); + sprintf(str2, "%s(%d %%)", _progressMeterCurrent); - if(_client) _client->Progress(str); + if(_client) _client->Progress(str2); #if defined(HAVE_FLTK) - if(FlGui::available()){ - if(_verbosity > 4) FlGui::instance()->setStatus(str, 1); + if(FlGui::available() && _verbosity > 4){ FlGui::instance()->check(); + FlGui::instance()->setProgress(str, n, N); } #endif if(CTX::instance()->terminal){ - fprintf(stdout, "%s \r", str); + fprintf(stdout, "%s \r", str2); fflush(stdout); } @@ -433,8 +432,9 @@ void Msg::ProgressMeter(int n, int N, const char *fmt, ...) if(_client) _client->Progress("Done!"); #if defined(HAVE_FLTK) - if(FlGui::available()){ - if(_verbosity > 4) FlGui::instance()->setStatus("", 1); + if(FlGui::available() && _verbosity > 4){ + FlGui::instance()->check(); + FlGui::instance()->setProgress("", 0, N); } #endif diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 18dafee6d349403bd555674442b4548845811288..a17853ff5043b37992f074ffbed320345bb93683 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -71,7 +71,7 @@ class Msg { static void Debug(const char *fmt, ...); static void ProgressMeter(int n, int N, const char *fmt, ...); static void ProgressMeter(int n, int N){ ProgressMeter(n, N, ""); } - static void SetProgressMeterStep(int step){ _progressMeterStep = step; } + static void SetProgressMeterStep(int step){ _progressMeterStep = (step > 0) ? step : 1; } static void ResetProgressMeter(){ if(!_commRank) _progressMeterCurrent = 0; } static double &Timer(std::string str){ return _timers[str]; } static void PrintTimers(); diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 8c18de758f8798380c0a2dc0119135552a6340dd..d8b45ae4306a182f8a199a3c6ba2837ac3172945 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -810,6 +810,19 @@ void FlGui::setStatus(const char *msg, int num) } } +void FlGui::setProgress(const char *msg, int n, int N) +{ + for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++){ + if(FlGui::instance()->graph[i]->label[1]->minimum() != 0) + FlGui::instance()->graph[i]->label[1]->minimum(0); + if(FlGui::instance()->graph[i]->label[1]->maximum() != N) + FlGui::instance()->graph[i]->label[1]->maximum(N); + if(FlGui::instance()->graph[i]->label[1]->value() != n) + FlGui::instance()->graph[i]->label[1]->value(n); + } + setStatus(msg, 1); +} + void FlGui::storeCurrentWindowsInfo() { CTX::instance()->menuPosition[0] = menu->win->x(); diff --git a/Fltk/FlGui.h b/Fltk/FlGui.h index 7e08c61aa99af07b241ab51eb657b5fe4a0661fb..a52131318b07aa3b4c4be4adfd7cd81b83a0b033 100644 --- a/Fltk/FlGui.h +++ b/Fltk/FlGui.h @@ -108,6 +108,8 @@ class FlGui{ char selectEntity(int type); // display status message void setStatus(const char *msg, int num); + // display status message and update progress bar + void setProgress(const char *msg, int n, int N); // create the window for physical context dependant definitions void callForSolverPlugin(int dim); // add line in message console(s) diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index b0a005f934b8d5a20a94d2c122e937f47d20a2a4..311a3721e63fdc0a3bc16a1733c786239de13360 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -632,11 +632,12 @@ graphicWindow::graphicWindow(bool main, int numTiles) : _autoScrollMessages(true int wleft = (width - x) / 3 - 1; int wright = (width - x) - (width - x) / 3 - 1; - label[0] = new Fl_Box(x, glheight + mheight + 2, wleft, sht); - label[1] = new Fl_Box(x + (width - x) / 3, glheight + mheight + 2, wright, sht); + label[0] = new Fl_Progress(x, glheight + mheight + 2, wleft, sht); + label[1] = new Fl_Progress(x + (width - x) / 3, glheight + mheight + 2, wright, sht); for(int i = 0; i < 2; i++) { label[i]->box(FL_THIN_DOWN_BOX); label[i]->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); + label[i]->color(FL_BACKGROUND_COLOR, FL_DARK2); // FL_DARK_GREEN } // dummy resizable box diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h index e60d9513d6029ae75c865550145319bb12dc4d4b..a5abb931dcc52c6bc7e77332538456ef7b5c5307 100644 --- a/Fltk/graphicWindow.h +++ b/Fltk/graphicWindow.h @@ -14,6 +14,7 @@ #include <FL/Fl_Box.H> #include <FL/Fl_Tile.H> #include <FL/Fl_Browser.H> +#include <FL/Fl_Progress.H> #include "openglWindow.h" class graphicWindow{ @@ -28,7 +29,7 @@ class graphicWindow{ Fl_Browser *browser; Fl_Box *bottom; Fl_Button *butt[14]; - Fl_Box *label[2]; + Fl_Progress *label[2]; int minWidth, minHeight; public: graphicWindow(bool main=true, int numTiles=1); diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index a6a7c185651c6e663619fbdf35c491466418f67f..6320d17a553fcb177581c29eaa8548847a3b85e4 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -277,6 +277,8 @@ bool onelab::localNetworkClient::run() } else if(type == "number"){ onelab::number p; p.fromChar(message); set(p); + if(p.getName() == getName() + "/Progress") + FlGui::instance()->setProgress(p.getLabel().c_str(), p.getValue(), p.getMax()); } else if(type == "string"){ onelab::string p; p.fromChar(message); set(p);