diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 42b8b4aaab394f550862901abac7ecd5334193c4..01ade4c1bdaede202f0a781ba23ad785770b027a 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -209,7 +209,6 @@ std::vector<std::pair<std::string, std::string> > GetShortcutsUsage(const std::s s.push_back(mp("Alt+Shift+b", "Hide/show mesh volume faces")); s.push_back(mp("Alt+Shift+d", "Hide/show mesh surface faces")); s.push_back(mp("Alt+Shift+l", "Hide/show mesh lines")); - s.push_back(mp("Alt+Shift+o", "Adjust projection parameters")); s.push_back(mp("Alt+Shift+p", "Hide/show mesh points")); s.push_back(mp("Alt+Shift+s", "Hide/show mesh surface edges")); s.push_back(mp("Alt+Shift+v", "Hide/show mesh volume edges")); diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 19d6fc7d9a31161336527df804fbd5967d1df52c..e843725be8cc7a70eb357f1fecf959fadebb4730 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -121,17 +121,6 @@ static void gmsh_back(Fl_Color c) gmsh_forward(c); } -static void gmsh_ortho(Fl_Color c) -{ - fl_color(c); - bl; vv(-0.8,0.8); vv(0.3,0.8); vv(0.3,-0.3); vv(-0.8,-0.3); el; - bl; vv(-0.3,0.3); vv(0.8,0.3); vv(0.8,-0.8); vv(-0.3,-0.8); el; - fl_begin_line(); vv(-0.8,0.8); vv(-0.3,0.3); fl_end_line(); - fl_begin_line(); vv(0.3,0.8); vv(0.8,0.3); fl_end_line(); - fl_begin_line(); vv(0.3,-0.3); vv(0.8,-0.8); fl_end_line(); - fl_begin_line(); vv(-0.8,-0.3); vv(-0.3,-0.8); fl_end_line(); -} - static void gmsh_rotate(Fl_Color c) { fl_color(c); @@ -148,13 +137,6 @@ static void gmsh_models(Fl_Color c) bl; vv(-0.8,0.8); vv(0.8,0.8); el; } -static void gmsh_clscale(Fl_Color c) -{ - fl_color(c); - bl; vv(-0.8,0.8); vv(-0.1,0.8); vv(-0.8,0.1); el; - bl; vv(-0.2,0.2); vv(0.9,0.2); vv(-0.2,-0.9); el; -} - static void gmsh_gear(Fl_Color c) { fl_color(c); @@ -263,10 +245,8 @@ FlGui::FlGui(int argc, char **argv) fl_add_symbol("gmsh_play", gmsh_play, 1); fl_add_symbol("gmsh_pause", gmsh_pause, 1); fl_add_symbol("gmsh_forward", gmsh_forward, 1); - fl_add_symbol("gmsh_ortho", gmsh_ortho, 1); fl_add_symbol("gmsh_rotate", gmsh_rotate, 1); fl_add_symbol("gmsh_models", gmsh_models, 1); - fl_add_symbol("gmsh_clscale", gmsh_clscale, 1); fl_add_symbol("gmsh_gear", gmsh_gear, 1); fl_add_symbol("gmsh_graph", gmsh_graph, 1); fl_add_symbol("gmsh_search", gmsh_search, 1); @@ -541,12 +521,7 @@ int FlGui::testGlobalShortcuts(int event) status = 1; } else if(Fl::test_shortcut(FL_SHIFT + 'w')) { - if(PView::list.size()){ - if(options->view.index >= 0 && options->view.index < (int)PView::list.size()) - options->showGroup(options->view.index + 6); - else - options->showGroup(6); - } + view_options_cb(0, (void*)-1); status = 1; } else if(Fl::test_shortcut(FL_SHIFT + 'u')) { @@ -611,8 +586,7 @@ int FlGui::testGlobalShortcuts(int event) status_xyz1p_cb(0, (void *)"z"); status = 1; } - else if(Fl::test_shortcut(FL_ALT + 'o') || - Fl::test_shortcut(FL_ALT + FL_SHIFT + 'o')) { + else if(Fl::test_shortcut(FL_ALT + 'o')) { status_options_cb(0, (void *)"p"); status = 1; } @@ -684,7 +658,7 @@ int FlGui::testGlobalShortcuts(int event) status = 2; } else if(Fl::test_shortcut(FL_ALT + 'm')) { - quick_visibility_cb(0, (void *)"mesh_toggle"); + quick_access_cb(0, (void *)"mesh_toggle"); status = 2; } else if(Fl::test_shortcut(FL_ALT + 't')) { diff --git a/Fltk/extraDialogs.cpp b/Fltk/extraDialogs.cpp index fde66bcb4958fdb44b098c98e24f228425d6db28..4e64af9a16fb466046928b0086d40e3d2b492149 100644 --- a/Fltk/extraDialogs.cpp +++ b/Fltk/extraDialogs.cpp @@ -89,101 +89,6 @@ int arrowEditor(const char *title, double &a, double &b, double &c) return 0; } -// Perspective editor (aka z-clipping planes factor slider) - -class Release_Slider : public Fl_Value_Slider { - int handle(int event) - { - switch (event) { - case FL_RELEASE: - if(window()) - window()->hide(); - return 1; - default: - return Fl_Value_Slider::handle(event); - } - }; -public: - Release_Slider(int x, int y, int w, int h, const char *l=0) - : Fl_Value_Slider(x, y, w, h, l) {} -}; - -static void persp_change_factor(Fl_Widget* w, void* data) -{ - opt_general_clip_factor(0, GMSH_SET|GMSH_GUI, ((Fl_Value_Slider*)w)->value()); - drawContext::global()->draw(); -} - -int perspectiveEditor() -{ - struct _editor{ - Fl_Menu_Window *window; - Release_Slider *sa; - }; - static _editor *editor = 0; - - if(!editor){ - editor = new _editor; - editor->window = new Fl_Menu_Window(200, 20); - if(CTX::instance()->nonModalWindows) editor->window->set_non_modal(); - editor->sa = new Release_Slider(0, 0, 200, 20); - editor->sa->type(FL_HOR_NICE_SLIDER); - editor->sa->minimum(0.1); - editor->sa->maximum(20); - editor->sa->callback(persp_change_factor); - editor->window->border(0); - editor->window->end(); - } - - editor->window->hotspot(editor->window); - editor->sa->value(CTX::instance()->clipFactor); - - if(editor->window->non_modal() && !editor->window->shown()) - editor->window->show(); // fix ordering - editor->window->show(); - return 0; -} - -// Mesh element size editor - -static void mesh_size_factor(Fl_Widget* w, void* data) -{ - opt_mesh_lc_factor(0, GMSH_SET|GMSH_GUI, ((Fl_Value_Slider*)w)->value()); - drawContext::global()->draw(); -} - -int meshSizeEditor() -{ - struct _editor{ - Fl_Menu_Window *window; - Release_Slider *sa; - }; - static _editor *editor = 0; - - if(!editor){ - editor = new _editor; - editor->window = new Fl_Menu_Window(200, 20); - if(CTX::instance()->nonModalWindows) editor->window->set_non_modal(); - editor->sa = new Release_Slider(0, 0, 200, 20); - editor->sa->type(FL_HOR_NICE_SLIDER); - editor->sa->minimum(0.01); - editor->sa->maximum(2.5); - editor->sa->callback(mesh_size_factor); - editor->window->border(0); - editor->window->end(); - } - - editor->window->hotspot(editor->window); - editor->sa->value(CTX::instance()->mesh.lcFactor); - - if(editor->window->non_modal() && !editor->window->shown()) - editor->window->show(); // fix ordering - editor->window->show(); - return 0; - - return CTX::instance()->mesh.lcFactor; -} - // Model chooser static void model_switch_cb(Fl_Widget* w, void *data) diff --git a/Fltk/extraDialogs.h b/Fltk/extraDialogs.h index 46976ba4f3da5c9733aff38dbf5312289064eeee..78222821f23dcbfdb06422b8cfa389a14ac21d3a 100644 --- a/Fltk/extraDialogs.h +++ b/Fltk/extraDialogs.h @@ -9,8 +9,6 @@ #include <string> int arrowEditor(const char *title, double &a, double &b, double &c); -int perspectiveEditor(); -int meshSizeEditor(); int modelChooser(); std::string connectionChooser(); diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index d2a2f61683880f729ba51108b0cbf72f9c3ca21a..f14c26c09d9d9545464a9900f275ee4f132a8f4e 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -2186,66 +2186,170 @@ void status_xyz1p_cb(Fl_Widget *w, void *data) FlGui::instance()->manip->update(); } -void quick_visibility_cb(Fl_Widget *w, void *data) +void quick_access_cb(Fl_Widget *w, void *data) { if(!data) return; std::string what((const char*)data); - if(what == "axes"){ + if(what == "general") + general_options_cb(0, 0); + else if(what == "geometry") + geometry_options_cb(0, 0); + else if(what == "mesh") + mesh_options_cb(0, 0); + else if(what == "view") + view_options_cb(0, (void *)-1); + else if(what == "axes"){ opt_general_axes(0, GMSH_SET|GMSH_GUI, !opt_general_axes(0, GMSH_GET, 0)); for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) opt_view_axes(i, GMSH_SET | GMSH_GUI, !opt_view_axes(i, GMSH_GET, 0)); } - if(what == "geometry_points") - opt_geometry_points(0, GMSH_SET|GMSH_GUI, !opt_geometry_points(0, GMSH_GET, 0)); + else if(what == "orthographic") + opt_general_orthographic(0, GMSH_SET | GMSH_GUI, 1); + else if(what == "perspective"){ + opt_general_orthographic(0, GMSH_SET | GMSH_GUI, 0); + drawContext::global()->draw(); + numberOrStringOptionChooser("General", 0, "ClipFactor", + true, true, 0.1, 20., 0.1); + } + else if(what == "geometry_points") + opt_geometry_points(0, GMSH_SET|GMSH_GUI, + !opt_geometry_points(0, GMSH_GET, 0)); else if(what == "geometry_lines") - opt_geometry_lines(0, GMSH_SET|GMSH_GUI, !opt_geometry_lines(0, GMSH_GET, 0)); + opt_geometry_lines(0, GMSH_SET|GMSH_GUI, + !opt_geometry_lines(0, GMSH_GET, 0)); else if(what == "geometry_surfaces") - opt_geometry_surfaces(0, GMSH_SET|GMSH_GUI, !opt_geometry_surfaces(0, GMSH_GET, 0)); + opt_geometry_surfaces(0, GMSH_SET|GMSH_GUI, + !opt_geometry_surfaces(0, GMSH_GET, 0)); else if(what == "geometry_volumes") - opt_geometry_volumes(0, GMSH_SET|GMSH_GUI, !opt_geometry_volumes(0, GMSH_GET, 0)); + opt_geometry_volumes(0, GMSH_SET|GMSH_GUI, + !opt_geometry_volumes(0, GMSH_GET, 0)); else if(what == "mesh_points") - opt_mesh_points(0, GMSH_SET|GMSH_GUI, !opt_mesh_points(0, GMSH_GET, 0)); + opt_mesh_points(0, GMSH_SET|GMSH_GUI, + !opt_mesh_points(0, GMSH_GET, 0)); else if(what == "mesh_lines") - opt_mesh_lines(0, GMSH_SET|GMSH_GUI, !opt_mesh_lines(0, GMSH_GET, 0)); + opt_mesh_lines(0, GMSH_SET|GMSH_GUI, + !opt_mesh_lines(0, GMSH_GET, 0)); else if(what == "mesh_surfaces_edges") - opt_mesh_surfaces_edges(0, GMSH_SET|GMSH_GUI, !opt_mesh_surfaces_edges(0, GMSH_GET, 0)); + opt_mesh_surfaces_edges(0, GMSH_SET|GMSH_GUI, + !opt_mesh_surfaces_edges(0, GMSH_GET, 0)); else if(what == "mesh_surfaces_faces") - opt_mesh_surfaces_faces(0, GMSH_SET|GMSH_GUI, !opt_mesh_surfaces_faces(0, GMSH_GET, 0)); + opt_mesh_surfaces_faces(0, GMSH_SET|GMSH_GUI, + !opt_mesh_surfaces_faces(0, GMSH_GET, 0)); else if(what == "mesh_volumes_edges") - opt_mesh_volumes_edges(0, GMSH_SET|GMSH_GUI, !opt_mesh_volumes_edges(0, GMSH_GET, 0)); + opt_mesh_volumes_edges(0, GMSH_SET|GMSH_GUI, + !opt_mesh_volumes_edges(0, GMSH_GET, 0)); else if(what == "mesh_volumes_faces") - opt_mesh_volumes_faces(0, GMSH_SET|GMSH_GUI, !opt_mesh_volumes_faces(0, GMSH_GET, 0)); + opt_mesh_volumes_faces(0, GMSH_SET|GMSH_GUI, + !opt_mesh_volumes_faces(0, GMSH_GET, 0)); + else if(what == "mesh_size") + numberOrStringOptionChooser("Mesh", 0, "CharacteristicLengthFactor", + true, true, 0.01, 100, 0.01); else if(what == "view_element_outlines"){ int set = 0; for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0) && (set = opt_view_show_element(i, GMSH_GET, 0))) break; + if(opt_view_visible(i, GMSH_GET, 0) && + (set = opt_view_show_element(i, GMSH_GET, 0))) + break; + for(unsigned int i = 0; i < PView::list.size(); i++) + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_show_element(i, GMSH_SET|GMSH_GUI, !set); + } + else if(what == "view_normal_raise"){ + double val = 0.; + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(opt_view_visible(i, GMSH_GET, 0)){ + double maxval = std::max(fabs(opt_view_min(i, GMSH_GET, 0)), + fabs(opt_view_max(i, GMSH_GET, 0))); + if(!maxval) maxval = 1.; + double val2 = 2. * CTX::instance()->lc / maxval; + val = numberOrStringOptionChooser("View", i, "NormalRaise", + true, true, -val2, val2, val2 / 200.); + break; + } + } for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_show_element(i, GMSH_SET|GMSH_GUI, !set); + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_normal_raise(i, GMSH_SET|GMSH_GUI, val); } else if(what == "view_iso"){ + double val; + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(opt_view_visible(i, GMSH_GET, 0)){ + val = numberOrStringOptionChooser("View", i, "NbIso", + true, true, 1, 100, 1); + break; + } + } for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 1); + if(opt_view_visible(i, GMSH_GET, 0)){ + opt_view_nb_iso(i, GMSH_SET|GMSH_GUI, val); + opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 1); + } } else if(what == "view_continous"){ for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 2); + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 2); } else if(what == "view_filled"){ + double val; + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(opt_view_visible(i, GMSH_GET, 0)){ + val = numberOrStringOptionChooser("View", i, "NbIso", + true, true, 1, 100, 1); + break; + } + } for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 3); + if(opt_view_visible(i, GMSH_GET, 0)){ + opt_view_nb_iso(i, GMSH_SET|GMSH_GUI, val); + opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 3); + } } else if(what == "view_numeric"){ for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 4); + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_intervals_type(i, GMSH_SET|GMSH_GUI, 4); + } + else if(what == "view_line"){ + for(unsigned int i = 0; i < PView::list.size(); i++) + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_vector_type(i, GMSH_SET|GMSH_GUI, 1); + } + else if(what == "view_3d_arrow"){ + for(unsigned int i = 0; i < PView::list.size(); i++) + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_vector_type(i, GMSH_SET|GMSH_GUI, 4); + } + else if(what == "view_displacement"){ + double val; + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(opt_view_visible(i, GMSH_GET, 0)){ + double maxval = std::max(fabs(opt_view_min(i, GMSH_GET, 0)), + fabs(opt_view_max(i, GMSH_GET, 0))); + if(!maxval) maxval = 1.; + double val3 = 2. * CTX::instance()->lc / maxval; + val = numberOrStringOptionChooser("View", i, "DisplacementFactor", + true, true, 0, val3, val3 / 100.); + break; + } + } + for(unsigned int i = 0; i < PView::list.size(); i++) + if(opt_view_visible(i, GMSH_GET, 0)){ + opt_view_displacement_factor(i, GMSH_SET|GMSH_GUI, val); + opt_view_vector_type(i, GMSH_SET|GMSH_GUI, 5); + } } else if(what == "view_range_default"){ for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_range_type(i, GMSH_SET|GMSH_GUI, 1); + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_range_type(i, GMSH_SET|GMSH_GUI, 1); } else if(what == "view_range_per_step"){ for(unsigned int i = 0; i < PView::list.size(); i++) - if(opt_view_visible(i, GMSH_GET, 0)) opt_view_range_type(i, GMSH_SET|GMSH_GUI, 3); + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_range_type(i, GMSH_SET|GMSH_GUI, 3); } else if(what == "mesh_toggle"){ static int value = 1; @@ -2295,89 +2399,104 @@ void status_options_cb(Fl_Widget *w, void *data) FlGui::instance()->help->options->show(); } else if(!strcmp(str, "p")){ // toggle projection mode - if(!Fl::event_state(FL_SHIFT)) - opt_general_orthographic(0, GMSH_SET | GMSH_GUI, - !opt_general_orthographic(0, GMSH_GET, 0)); - else - perspectiveEditor(); + opt_general_orthographic(0, GMSH_SET | GMSH_GUI, + !opt_general_orthographic(0, GMSH_GET, 0)); drawContext::global()->draw(); } - else if(!strcmp(str, "quickvis") || - !strcmp(str, "quickvis_toggle")){ // quick visibility menu + else if(!strcmp(str, "quick_access")){ // quick access menu static Fl_Menu_Item menu[] = { - { "Axes", 0, quick_visibility_cb, (void*)"axes", - FL_MENU_TOGGLE|FL_MENU_DIVIDER }, - { "Geometry points", 0, quick_visibility_cb, (void*)"geometry_points", + { "Axes", 0, quick_access_cb, (void*)"axes", + FL_MENU_TOGGLE }, + { "Projection mode", 0, 0, 0, FL_SUBMENU }, + { "Orthographic", 0, quick_access_cb, (void*)"orthographic"}, + { "Perspective", 0, quick_access_cb, (void*)"perspective"}, + { 0 }, + { "All general options...", 0, quick_access_cb, (void*)"general", + FL_MENU_DIVIDER, 0, FL_ITALIC }, + { "Geometry points", 0, quick_access_cb, (void*)"geometry_points", FL_MENU_TOGGLE }, - { "Geometry lines", 0, quick_visibility_cb, (void*)"geometry_lines", + { "Geometry lines", 0, quick_access_cb, (void*)"geometry_lines", FL_MENU_TOGGLE }, - { "Geometry surfaces", 0, quick_visibility_cb, (void*)"geometry_surfaces", + { "Geometry surfaces", 0, quick_access_cb, (void*)"geometry_surfaces", FL_MENU_TOGGLE }, - { "Geometry volumes", 0, quick_visibility_cb, (void*)"geometry_volumes", - FL_MENU_TOGGLE|FL_MENU_DIVIDER }, - { "Mesh nodes", 0, quick_visibility_cb, (void*)"mesh_points", + { "Geometry volumes", 0, quick_access_cb, (void*)"geometry_volumes", FL_MENU_TOGGLE }, - { "Mesh lines", 0, quick_visibility_cb, (void*)"mesh_lines", + { "All geometry options...", 0, quick_access_cb, (void*)"geometry", + FL_MENU_DIVIDER, 0, FL_ITALIC }, + { "Mesh nodes", 0, quick_access_cb, (void*)"mesh_points", FL_MENU_TOGGLE }, - { "Mesh surface edges", 0, quick_visibility_cb, (void*)"mesh_surfaces_edges", + { "Mesh lines", 0, quick_access_cb, (void*)"mesh_lines", FL_MENU_TOGGLE }, - { "Mesh surface faces", 0, quick_visibility_cb, (void*)"mesh_surfaces_faces", + { "Mesh surface edges", 0, quick_access_cb, (void*)"mesh_surfaces_edges", FL_MENU_TOGGLE }, - { "Mesh volume edges", 0, quick_visibility_cb, (void*)"mesh_volumes_edges", + { "Mesh surface faces", 0, quick_access_cb, (void*)"mesh_surfaces_faces", FL_MENU_TOGGLE }, - { "Mesh volume faces", 0, quick_visibility_cb, (void*)"mesh_volumes_faces", - FL_MENU_TOGGLE|FL_MENU_DIVIDER }, - { "View element outlines ", 0, quick_visibility_cb, (void*)"view_element_outlines", + { "Mesh volume edges", 0, quick_access_cb, (void*)"mesh_volumes_edges", FL_MENU_TOGGLE }, + { "Mesh volume faces", 0, quick_access_cb, (void*)"mesh_volumes_faces", + FL_MENU_TOGGLE }, + { "Toggle mesh display", 0, quick_access_cb, (void*)"mesh_toggle" }, + { "Global mesh size factor", 0, quick_access_cb, (void*)"mesh_size" }, + { "All mesh options...", 0, quick_access_cb, (void*)"mesh", + FL_MENU_DIVIDER, 0, FL_ITALIC }, + { "View element outlines ", 0, quick_access_cb, (void*)"view_element_outlines", + FL_MENU_TOGGLE }, + { "View normal raise", 0, quick_access_cb, (void*)"view_normal_raise" }, { "View intervals", 0, 0, 0, FL_SUBMENU }, - { "Iso-values", 0, quick_visibility_cb, (void*)"view_iso"}, - { "Continuous map", 0, quick_visibility_cb, (void*)"view_continous"}, - { "Filled iso-values", 0, quick_visibility_cb, (void*)"view_filled"}, - { "Numeric values", 0, quick_visibility_cb, (void*)"view_numeric"}, + { "Iso-values", 0, quick_access_cb, (void*)"view_iso"}, + { "Continuous map", 0, quick_access_cb, (void*)"view_continous"}, + { "Filled iso-values", 0, quick_access_cb, (void*)"view_filled"}, + { "Numeric values", 0, quick_access_cb, (void*)"view_numeric"}, { 0 }, - { "View range", 0, 0, 0, FL_SUBMENU|FL_MENU_DIVIDER }, - { "Default", 0, quick_visibility_cb, (void*)"view_range_default"}, - { "Per time step", 0, quick_visibility_cb, (void*)"view_range_per_step"}, + { "View vector display", 0, 0, 0, FL_SUBMENU }, + { "Line", 0, quick_access_cb, (void*)"view_line"}, + { "3D arrow", 0, quick_access_cb, (void*)"view_3d_arrow"}, + { "Displacement", 0, quick_access_cb, (void*)"view_displacement"}, { 0 }, - { "Toggle mesh display", 0, quick_visibility_cb, (void*)"mesh_toggle" }, + { "View range", 0, 0, 0, FL_SUBMENU }, + { "Default", 0, quick_access_cb, (void*)"view_range_default"}, + { "Per time step", 0, quick_access_cb, (void*)"view_range_per_step"}, + { 0 }, + { "All view options...", 0, quick_access_cb, (void*)"view", + 0, 0, FL_ITALIC }, { 0 } }; if(opt_general_axes(0, GMSH_GET, 0)) menu[0].set(); else menu[0].clear(); for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0) && opt_view_axes(i, GMSH_GET, 0)) menu[0].set(); - if(opt_geometry_points(0, GMSH_GET, 0)) menu[1].set(); else menu[1].clear(); - if(opt_geometry_lines(0, GMSH_GET, 0)) menu[2].set(); else menu[2].clear(); - if(opt_geometry_surfaces(0, GMSH_GET, 0)) menu[3].set(); else menu[3].clear(); - if(opt_geometry_volumes(0, GMSH_GET, 0)) menu[4].set(); else menu[4].clear(); - if(opt_mesh_points(0, GMSH_GET, 0)) menu[5].set(); else menu[5].clear(); - if(opt_mesh_lines(0, GMSH_GET, 0)) menu[6].set(); else menu[6].clear(); - if(opt_mesh_surfaces_edges(0, GMSH_GET, 0)) menu[7].set(); else menu[7].clear(); - if(opt_mesh_surfaces_faces(0, GMSH_GET, 0)) menu[8].set(); else menu[8].clear(); - if(opt_mesh_volumes_edges(0, GMSH_GET, 0)) menu[9].set(); else menu[9].clear(); - if(opt_mesh_volumes_faces(0, GMSH_GET, 0)) menu[10].set(); else menu[10].clear(); - menu[11].clear(); - for(unsigned int i = 0; i < PView::list.size(); i++){ - if(opt_view_visible(i, GMSH_GET, 0) && opt_view_show_element(i, GMSH_GET, 0)){ - menu[11].set(); - break; - } - } - if(!strcmp(str, "quickvis_toggle")){ - const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, &menu[22], 0); - if(m) m->do_callback(0, m->user_data()); + if(opt_geometry_points(0, GMSH_GET, 0)) menu[5].set(); else menu[5].clear(); + if(opt_geometry_lines(0, GMSH_GET, 0)) menu[6].set(); else menu[6].clear(); + if(opt_geometry_surfaces(0, GMSH_GET, 0)) menu[7].set(); else menu[7].clear(); + if(opt_geometry_volumes(0, GMSH_GET, 0)) menu[8].set(); else menu[8].clear(); + if(opt_mesh_points(0, GMSH_GET, 0)) menu[11].set(); else menu[11].clear(); + if(opt_mesh_lines(0, GMSH_GET, 0)) menu[12].set(); else menu[12].clear(); + if(opt_mesh_surfaces_edges(0, GMSH_GET, 0)) menu[13].set(); else menu[13].clear(); + if(opt_mesh_surfaces_faces(0, GMSH_GET, 0)) menu[14].set(); else menu[14].clear(); + if(opt_mesh_volumes_edges(0, GMSH_GET, 0)) menu[15].set(); else menu[15].clear(); + if(opt_mesh_volumes_faces(0, GMSH_GET, 0)) menu[16].set(); else menu[16].clear(); + if(PView::list.empty()){ + menu[19].flags = 0; + for(int i = 20; i < 38; i++) menu[i].hide(); } else{ - static Fl_Menu_Item *picked = &menu[22]; - picked = (Fl_Menu_Item*)menu->popup(Fl::event_x(), Fl::event_y(), 0, - picked ? picked : &menu[22], 0); - if(picked) picked->do_callback(0, picked->user_data()); + menu[19].flags = FL_MENU_DIVIDER; + for(int i = 20; i < 38; i++) menu[i].show(); + menu[20].clear(); + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(opt_view_visible(i, GMSH_GET, 0) && opt_view_show_element(i, GMSH_GET, 0)){ + menu[20].set(); + break; + } + } } + static Fl_Menu_Item *picked = &menu[17]; + picked = (Fl_Menu_Item*)menu->popup(Fl::event_x(), Fl::event_y(), 0, + (picked && picked->visible()) ? picked : + &menu[17], 0); + if(picked) picked->do_callback(0, picked->user_data()); drawContext::global()->draw(); } - else if(!strcmp(str, "clscale")){ - meshSizeEditor(); - } else if(!strcmp(str, "S")){ // mouse selection if(CTX::instance()->mouseSelection){ opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0); @@ -2698,6 +2817,11 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu) _butt[5]->callback(status_options_cb, (void *)"model"); _butt[5]->tooltip("Select active model"); x += sw; + _butt[8] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "O"); + _butt[8]->callback(status_options_cb, (void *)"quick_access"); + _butt[8]->tooltip("Quick option access (also available by double-clicking anywhere " + "in the graphic window)"); + x += sw; _butt[0] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "X"); _butt[0]->callback(status_xyz1p_cb, (void *)"x"); _butt[0]->tooltip("Set +X or -X view (Alt+x or Alt+Shift+x)"); @@ -2718,23 +2842,12 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu) _butt[3]->callback(status_xyz1p_cb, (void *)"1:1"); _butt[3]->tooltip("Set unit scale, sync scale between viewports (Alt), " "or reset bounding box around visible entities (Shift)"); - x += 2 * FL_NORMAL_SIZE; - _butt[8] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "@-1gmsh_ortho"); - _butt[8]->callback(status_options_cb, (void *)"p"); - _butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)"); - x += sw; - _butt[12] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "M"); - _butt[12]->callback(status_options_cb, (void *)"quickvis_toggle"); - _butt[12]->tooltip("Quick visibility menu (Alt+m to toggle mesh display)"); - x += sw; - _butt[13] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "@-1gmsh_clscale"); - _butt[13]->callback(status_options_cb, (void *)"clscale"); - _butt[13]->tooltip("Change mesh element size factor"); - x += sw; + x += 1.75 * FL_NORMAL_SIZE; _butt[9] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "S"); _butt[9]->callback(status_options_cb, (void *)"S"); _butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)"); x += sw; + x += 4; _butt[6] = new Fl_Button(x, mh + glheight + mheight + 2, sw, sht, "@-1gmsh_rewind"); _butt[6]->callback(status_rewind_cb); _butt[6]->tooltip("Rewind animation"); @@ -2756,7 +2869,7 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu) _butt[11]->deactivate(); x += sw; - for(int i = 0; i < 14; i++) { + for(int i = 0; i < 12; i++) { _butt[i]->box(FL_FLAT_BOX); _butt[i]->selection_color(FL_WHITE); _butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h index 7d08bf0b14896035a61e1397fad4ac8755c19b9f..5deaba9dd2d0c2c4e97fa46808e95a159110ac80 100644 --- a/Fltk/graphicWindow.h +++ b/Fltk/graphicWindow.h @@ -100,7 +100,7 @@ void help_about_cb(Fl_Widget *w, void *data); void status_xyz1p_cb(Fl_Widget *w, void *data); void status_options_cb(Fl_Widget *w, void *data); void status_play_manual(int time, int incr, bool redraw=true); -void quick_visibility_cb(Fl_Widget *w, void *data); +void quick_access_cb(Fl_Widget *w, void *data); void show_hide_message_cb(Fl_Widget *w, void *data); void show_hide_menu_cb(Fl_Widget *w, void *data); void attach_detach_menu_cb(Fl_Widget *w, void *data); diff --git a/Fltk/helpWindow.cpp b/Fltk/helpWindow.cpp index 473b9366dfbe8a122c55935d6c0003f37b707506..297d8ab98c49e7723d091506890230bd890e3a29 100644 --- a/Fltk/helpWindow.cpp +++ b/Fltk/helpWindow.cpp @@ -26,36 +26,71 @@ static const char *help_link(Fl_Widget *w, const char *uri) return 0; } -static void numberOrStringChooser(const std::string &category, int index, - const std::string &name, bool num) +struct opt_data{ + std::string category; + int index; + std::string name; +}; + +static void interactive_cb(Fl_Widget* w, void* data) +{ + if(!data) return; + Fl_Value_Input *v = (Fl_Value_Input*)w; + opt_data *d = (opt_data*)data; + double val = v->value(); + NumberOption(GMSH_SET|GMSH_GUI, d->category.c_str(), d->index, + d->name.c_str(), val); + drawContext::global()->draw(); +} + +double numberOrStringOptionChooser(const std::string &category, int index, + const std::string &name, bool isNumber, + bool isInteractive, double minimum, + double maximum, double step) { double valn = 0.; std::string vals = ""; - if(num) + if(isNumber) NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn); else StringOption(GMSH_GET, category.c_str(), index, name.c_str(), vals); - int width = 3 * BB + 4 * WB, height = 2 * BH + 3 * WB; + + int nn = (isInteractive ? 2 : 3); + int width = nn * BB + (nn + 1) * WB, height = 2 * BH + 3 * WB; Fl_Window *win = new paletteWindow(width, height, false, - num ? "Number Chooser" : "String Chooser"); + isNumber ? "Number Chooser" : "String Chooser"); win->set_modal(); win->hotspot(win); + if(isInteractive) win->clear_border(); Fl_Value_Input *number = 0; Fl_Input *string = 0; - if(num){ + if(isNumber){ number = new Fl_Value_Input(WB, WB, width - 2 * WB, BH); number->value(valn); + if(isInteractive){ + static opt_data d; + d.category = category; + d.index = index; + d.name = name; + number->minimum(minimum); + number->maximum(maximum); + number->step(step); + number->callback(interactive_cb, (void*)&d); + number->when(FL_WHEN_RELEASE); + } } else{ string = new Fl_Input(WB, WB, width - 2 * WB, BH); string->value(vals.c_str()); } Fl_Button *ok = new Fl_Return_Button - (width - 3 * BB - 3 * WB, 2 * WB + BH, BB, BH, "OK"); + (width - nn * BB - nn * WB, 2 * WB + BH, BB, BH, "OK"); Fl_Button *def = new Fl_Button - (width - 2 * BB - 2 * WB, 2 * WB + BH, BB, BH, "Default"); - Fl_Button *cancel = new Fl_Button - (width - BB - WB, 2 * WB + BH, BB, BH, "Cancel"); + (width - (nn - 1) * BB - (nn - 1) * WB, 2 * WB + BH, BB, BH, "Default"); + Fl_Button *cancel = 0; + if(!isInteractive) + cancel = new Fl_Button + (width - BB - WB, 2 * WB + BH, BB, BH, "Cancel"); win->end(); win->show(); if(number) number->take_focus(); @@ -72,7 +107,7 @@ static void numberOrStringChooser(const std::string &category, int index, break; } if(o == ok){ - if(num){ + if(isNumber){ valn = number->value(); NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), valn); @@ -86,10 +121,11 @@ static void numberOrStringChooser(const std::string &category, int index, break; } if(o == def){ - if(num){ + if(isNumber){ NumberOption(GMSH_GET_DEFAULT, category.c_str(), index, name.c_str(), valn); number->value(valn); + if(isInteractive) number->do_callback(); } else{ StringOption(GMSH_GET_DEFAULT, category.c_str(), index, @@ -101,10 +137,11 @@ static void numberOrStringChooser(const std::string &category, int index, } } delete win; + return valn; } -static void colorChooser(const std::string &category, int index, - const std::string &name) +static void colorOptionChooser(const std::string &category, int index, + const std::string &name) { unsigned int col; ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), col); @@ -130,11 +167,11 @@ static void editOption(const std::string &type, const std::string &cat, } if(type == "number") - numberOrStringChooser(category, index, name, true); + numberOrStringOptionChooser(category, index, name, true); else if(type == "string") - numberOrStringChooser(category, index, name, false); + numberOrStringOptionChooser(category, index, name, false); else if(type == "color") - colorChooser(category, index, name); + colorOptionChooser(category, index, name); } static void browser_cb(Fl_Widget *w, void *data) diff --git a/Fltk/helpWindow.h b/Fltk/helpWindow.h index ccc6d112917d2d2eb04a586e6315929a335ae217..a8d43abba80a30d1bf8b67a6ea28df818e9b2ee2 100644 --- a/Fltk/helpWindow.h +++ b/Fltk/helpWindow.h @@ -20,5 +20,9 @@ class helpWindow{ }; void help_options_cb(Fl_Widget *w, void *data); +double numberOrStringOptionChooser(const std::string &category, int index, + const std::string &name, bool isNumber=true, + bool isInteractive=false, double minimum=0., + double maximum=0., double step=0.); #endif diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 372031c0a3fd05ab73a880d4c42f705c4eb87dda..60bd1ccb172f461ed8ec31fcd61ab7ecf14a6efd 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -343,7 +343,7 @@ int openglWindow::handle(int event) case FL_PUSH: if(Fl::event_clicks() == 1){ // double-click - status_options_cb(0, (void*)"quickvis"); + status_options_cb(0, (void*)"quick_access"); Fl::event_clicks(-1); return 1; } diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 9cad0ecc97024acdf5e351183ce884ca6a4d5514..bdc7892d5fe23c2b029073289d153e4cbe6bfe89 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -624,7 +624,16 @@ static void post_options_ok_cb(Fl_Widget *w, void *data) void view_options_cb(Fl_Widget *w, void *data) { - FlGui::instance()->options->showGroup((intptr_t)data + 6); + int num = (intptr_t)data; + if(num < 0){ // automatic + int current = FlGui::instance()->options->view.index; + if(current >= 0 && current < (int)PView::list.size()) + num = current; + else + num = 0; + } + if(num >= 0 && num < (int)PView::list.size()) + FlGui::instance()->options->showGroup(num + 6); } static void view_options_timestep_cb(Fl_Widget *w, void *data)