diff --git a/Common/Context.h b/Common/Context.h index 0140f048adf42e01bb410d71616f64d8fafd183d..a399fb76fdd973a1d41d88f49543c616c898b0ea 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -50,6 +50,7 @@ class Context_T { int gl_position[2]; // position of the graphic window on the screen int msg_position[2]; // position of the message window on the screen int msg_size[2]; // size of the message window on the screen + int msg_auto_scroll; // scroll automatically to last message int opt_position[2]; // position of the option window on the screen int vis_position[2]; // position of the visibility window on the screen int clip_position[2]; // position of the clipping planes window on the screen diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 7d242b32f1acad25c6ac15b6505f607320ffca10..5ff3dc5e7e2aa730e7aad7e862dde19f0039d726 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -657,6 +657,8 @@ StringXNumber GeneralOptions_Number[] = { "Horizontal position (in pixels) of the upper left corner of the menu window" }, { F|S, "MenuPositionY" , opt_general_menu_position1 , 50. , "Vertical position (in pixels) of the upper left corner of the menu window" }, + { F|S, "MessageAutoScroll" , opt_general_message_auto_scroll , 1. , + "Automatically scroll message window" }, { F|S, "MessagePositionX" , opt_general_message_position0 , 650. , "Horizontal position (in pixels) of the upper left corner of the message window" }, { F|S, "MessagePositionY" , opt_general_message_position1 , 490. , diff --git a/Common/GmshDaemon.cpp b/Common/GmshDaemon.cpp index 3ddb1c3474e5b82ee3f18f946f67c1deb1f02e0a..051893543e02db0279f3ee9bbf9498d83edd29cf 100644 --- a/Common/GmshDaemon.cpp +++ b/Common/GmshDaemon.cpp @@ -18,21 +18,31 @@ int GmshDaemon(std::string socket) } client.Start(); - int i = 0; while(1){ - if(!client.Select(0, 1000)){ - // data is available to read: deal with it + // wait (at most 10ms) until data is available to read + if(!client.Select(0, 10000)){ int type, length; if(client.ReceiveHeader(&type, &length)){ - printf("received header: %d %d\n", type, length); + Msg::Info("Received header: type=%d length=%d", type, length); char *msg = new char[length]; if(client.ReceiveString(length, msg)){ - printf("received string: %s\n", msg); + Msg::Info("received string: %s", msg); + Msg::Info("replying by sending post data"); + std::ostringstream tmp; + tmp<<"View \"test\" {\n"; + for(int i= 0; i < 100; i++){ + for(int j= 0; j < 100; j++){ + tmp << "SQ("<<i<<","<<j<<",0, "<<i+1<<","<<j<<",0, " + <<i+1<<","<<j+1<<",0, "<<i<<","<<j+1<<",0){" + <<i+j<<","<<i+j<<","<<i+j<<","<<i+j<<"};\n"; + } + } + tmp<<"};BoundingBox;\n"; + client.ParseString(tmp.str().c_str()); } delete [] msg; - - printf("stopping connection!\n"); - break; + //printf("stopping connection!\n"); + //break; } } } diff --git a/Common/Options.cpp b/Common/Options.cpp index 9036103aeae40c7e04ded1dcb36a25de90e8e9e9..5fedc14b732d8864e998eac5cff0b732f58e50d1 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -2549,6 +2549,17 @@ double opt_general_message_size1(OPT_ARGS_NUM) return CTX.msg_size[1]; } +double opt_general_message_auto_scroll(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.msg_auto_scroll = (int)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->msg_butt->value(CTX.msg_auto_scroll); +#endif + return CTX.msg_auto_scroll; +} + double opt_general_option_position0(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index d14062799947b3b29cf3a5de026d3464e37b0101..2beecfcd63b81c3e2080c0c684e3c4343237f94c 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -234,6 +234,7 @@ double opt_general_message_position0(OPT_ARGS_NUM); double opt_general_message_position1(OPT_ARGS_NUM); double opt_general_message_size0(OPT_ARGS_NUM); double opt_general_message_size1(OPT_ARGS_NUM); +double opt_general_message_auto_scroll(OPT_ARGS_NUM); double opt_general_option_position0(OPT_ARGS_NUM); double opt_general_option_position1(OPT_ARGS_NUM); double opt_general_plugin_position0(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index eb2a4bcf4b0b34b047d2ab7814d4718b3726ab88..44415810dff07372c4ea8cfa927273dcc304bf9f 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1894,6 +1894,11 @@ void message_cb(CALLBACK_ARGS) WID->create_message_window(); } +void message_auto_scroll_cb(CALLBACK_ARGS) +{ + CTX.msg_auto_scroll = WID->msg_butt->value(); +} + void message_copy_cb(CALLBACK_ARGS) { #define BUFFL 50000 diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index 363b57fc54bb111f9e55a875edeae053f4a3cb09..d9a199a05d758b92a235bccc9475f2a6fa70c57f 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -143,6 +143,7 @@ void statistics_histogram_cb(CALLBACK_ARGS); // Message Menu void message_cb(CALLBACK_ARGS); +void message_auto_scroll_cb(CALLBACK_ARGS); void message_copy_cb(CALLBACK_ARGS); void message_clear_cb(CALLBACK_ARGS); void message_save_cb(CALLBACK_ARGS); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index bbe104116b8ad091020695cc9ff034bd296c1215..864cef904cc0856e26985af20eb86e4e1c3878e1 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -508,6 +508,8 @@ int GetFontSize() // Definition of global shortcuts +#include "GmshSocket.h" + int GUI::global_shortcuts(int event) { // we only handle shortcuts here @@ -519,6 +521,15 @@ int GUI::global_shortcuts(int event) mod_geometry_cb(0, 0); return 1; } + // FIXME TESTING ONLY -- TO REMOVE LATER + else if(Fl::test_shortcut(FL_CTRL + 'p')) { + Msg::Info("TEST DAEMON!"); + if(SINFO[2].server){ + Msg::Info("SENDING COMMAND!"); + SINFO[2].server->SendString(GmshSocket::CLIENT_INFO, "HEY YOU!"); + } + return 1; + } else if(Fl::test_shortcut('1') || Fl::test_shortcut(FL_F + 1)) { mesh_1d_cb(0, 0); mod_mesh_cb(0, 0); @@ -4246,6 +4257,11 @@ void GUI::create_message_window(bool redraw_only) msg_browser->type(FL_MULTI_BROWSER); msg_browser->callback(message_copy_cb); + { + msg_butt = new Fl_Check_Button(width - 4 * BB - 4 * WB, height - BH - WB, BB, BH, "Auto scroll"); + msg_butt->type(FL_TOGGLE_BUTTON); + msg_butt->callback(message_auto_scroll_cb); + } { Fl_Return_Button *o = new Fl_Return_Button(width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Clear"); o->callback(message_clear_cb); @@ -4259,7 +4275,7 @@ void GUI::create_message_window(bool redraw_only) o->callback(cancel_cb, (void *)msg_window); } - msg_window->resizable(new Fl_Box(WB, WB, 100, 10)); + msg_window->resizable(new Fl_Box(1, 1, 4, 4)); msg_window->size_range(WB + 100 + 3 * BB + 4 * WB, 100); msg_window->position(CTX.msg_position[0], CTX.msg_position[1]); @@ -4269,7 +4285,8 @@ void GUI::create_message_window(bool redraw_only) void GUI::add_message(const char *msg) { msg_browser->add(msg, 0); - msg_browser->bottomline(msg_browser->size()); + if(CTX.msg_auto_scroll) + msg_browser->bottomline(msg_browser->size()); } void GUI::save_message(const char *filename) diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 62eb30e78ffff19f864d85567f42e6b275ecee4b..67fb543162c241bbc66e29edf7c764d8b1e8b79d 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -229,6 +229,7 @@ public: // message window Fl_Window *msg_window; Fl_Browser *msg_browser; + Fl_Check_Button *msg_butt; // visibility window Fl_Window *vis_window; diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp index d327375e7c6ec0fdf714785dfeaf6dc2a35dc1d2..44f92777ff88b7a73098397251fd6a5183ce9b2e 100644 --- a/Fltk/Solvers.cpp +++ b/Fltk/Solvers.cpp @@ -56,8 +56,10 @@ class myGmshServer : public GmshServer{ } else{ // an error happened - if(num >= 0) + if(num >= 0){ SINFO[num].pid = -1; + SINFO[num].server = 0; + } return 1; } } @@ -165,6 +167,7 @@ int Solver(int num, const char *args) for(int i = 0; i < SINFO[num].nboptions; i++) SINFO[num].nbval[i] = 0; SINFO[num].pid = 0; + SINFO[num].server = 0; } Msg::StatusBar(2, false, "Running '%s'", prog.c_str()); @@ -188,13 +191,17 @@ int Solver(int num, const char *args) if(server->ReceiveString(length, message)){ switch (type) { case GmshServer::CLIENT_START: - if(num >= 0) + if(num >= 0){ SINFO[num].pid = atoi(message); + SINFO[num].server = server; + } break; case GmshServer::CLIENT_STOP: stop = 1; - if(num >= 0) + if(num >= 0){ SINFO[num].pid = -1; + SINFO[num].server = 0; + } break; case GmshServer::CLIENT_PROGRESS: if(num >= 0) diff --git a/Fltk/Solvers.h b/Fltk/Solvers.h index dd8ca5d2f396adb7b28622424795e538eda64d11..e5fcc2cb723f2809fb0dc4afa0992144c612e6f8 100644 --- a/Fltk/Solvers.h +++ b/Fltk/Solvers.h @@ -8,6 +8,8 @@ #define MAXSOLVERS 5 +class GmshServer; + typedef struct{ char name[256], extension[32], executable_name[256]; char mesh_name[256], mesh_command[256]; @@ -20,6 +22,7 @@ typedef struct{ const char *help; int client_server, popup_messages, merge_views; int pid; + GmshServer *server; } SolverInfo ; extern SolverInfo SINFO[MAXSOLVERS] ;