diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 47b86f0aea569e66c4ce50fa24645e64493a7168..8457fa0eba74f2ff64599143116838fd87132e92 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.218 2004-04-21 04:26:44 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.219 2004-04-23 17:44:24 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -148,6 +148,63 @@ int file_chooser_get_filter() #endif +// arrow editor + +#include <FL/Fl_Value_Slider.H> + +int arrow_editor(char *title, double &a, double &b, double &c) +{ + struct _editor{ + Fl_Window *window; + Fl_Value_Slider *sa, *sb, *sc; + Fl_Button *apply, *cancel; + }; + static _editor *editor = NULL; + + if(!editor){ + editor = new _editor; + editor->window = new Fl_Window(200, 140); + editor->sa = new Fl_Value_Slider(10, 10, 100, 25, "Head radius"); + editor->sa->type(FL_HOR_SLIDER); + editor->sa->align(FL_ALIGN_RIGHT); + editor->sb = new Fl_Value_Slider(10, 40, 100, 25, "Stem length"); + editor->sb->type(FL_HOR_SLIDER); + editor->sb->align(FL_ALIGN_RIGHT); + editor->sc = new Fl_Value_Slider(10, 70, 100, 25, "Stem radius"); + editor->sc->type(FL_HOR_SLIDER); + editor->sc->align(FL_ALIGN_RIGHT); + editor->apply = new Fl_Return_Button(10, 105, 85, 25, "Apply"); + editor->cancel = new Fl_Button(105, 105, 85, 25, "Cancel"); + editor->window->end(); + editor->window->hotspot(editor->window); + } + + editor->window->label(title); + editor->sa->value(a); + editor->sb->value(b); + editor->sc->value(c); + editor->window->show(); + + while(editor->window->shown()){ + Fl::wait(); + for (;;) { + Fl_Widget* o = Fl::readqueue(); + if (!o) break; + if (o == editor->apply) { + a = editor->sa->value(); + b = editor->sb->value(); + c = editor->sc->value(); + return 1; + } + if (o == editor->window || o == editor->cancel){ + editor->window->hide(); + return 0; + } + } + } + return 0; +} + // Compatibility/local routines void UpdateViewsInGUI() @@ -1019,6 +1076,19 @@ void general_options_ok_cb(CALLBACK_ARGS) opt_general_vector_type(0, GMSH_SET, val); } +void general_arrow_param_cb(CALLBACK_ARGS) +{ + double a = opt_general_arrow_head_radius(0, GMSH_GET, 0); + double b = opt_general_arrow_stem_length(0, GMSH_GET, 0); + double c = opt_general_arrow_stem_radius(0, GMSH_GET, 0); + while(arrow_editor("Edit General 3D Arrow", a, b, c)){ + opt_general_arrow_head_radius(0, GMSH_SET, a); + opt_general_arrow_stem_length(0, GMSH_SET, b); + opt_general_arrow_stem_radius(0, GMSH_SET, c); + Draw(); + } +} + // Geometry options void geometry_options_cb(CALLBACK_ARGS) @@ -3494,6 +3564,19 @@ void view_options_ok_cb(CALLBACK_ARGS) } } +void view_arrow_param_cb(CALLBACK_ARGS) +{ + double a = opt_view_arrow_head_radius((long int)data, GMSH_GET, 0); + double b = opt_view_arrow_stem_length((long int)data, GMSH_GET, 0); + double c = opt_view_arrow_stem_radius((long int)data, GMSH_GET, 0); + while(arrow_editor("Edit View 3D Arrow", a, b, c)){ + opt_view_arrow_head_radius((long int)data, GMSH_SET, a); + opt_view_arrow_stem_length((long int)data, GMSH_SET, b); + opt_view_arrow_stem_radius((long int)data, GMSH_SET, c); + Draw(); + } +} + // Contextual windows for geometry void con_geometry_define_parameter_cb(CALLBACK_ARGS) diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index 6156b966a006b196e3473cb9b1d610124fccb332..983c8a1b43b1ed4f5b63fb869c82e3f4c32abea0 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -275,5 +275,10 @@ void solver_kill_cb(CALLBACK_ARGS); void solver_choose_executable_cb(CALLBACK_ARGS); void solver_ok_cb(CALLBACK_ARGS); +// Arrow editor windows + +void general_arrow_param_cb(CALLBACK_ARGS); +void view_arrow_param_cb(CALLBACK_ARGS); + #endif diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index dd78e592e7908f0adca62e2271a9e237b2325584..cb9f1ed5a603e0c29d671f33bbe1bac6f3a97346 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.289 2004-04-22 05:45:14 geuzaine Exp $ +// $Id: GUI.cpp,v 1.290 2004-04-23 17:44:24 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1596,7 +1596,7 @@ void GUI::create_option_window() {"Line", 0, 0, 0}, {"Arrow", 0, 0, 0}, {"Pyramid", 0, 0, 0}, - {"3D Arrow", 0, 0, 0}, + {"3D arrow", 0, 0, 0}, {0} }; gen_choice[0] = new Fl_Choice(2 * WB, 2 * WB + 8 * BH, IW, BH, "Vector display"); @@ -1604,6 +1604,9 @@ void GUI::create_option_window() gen_choice[0]->align(FL_ALIGN_RIGHT); gen_choice[0]->callback(set_changed_cb, 0); + Fl_Button *b = new Fl_Button(2 * IW - 2 * WB, 2 * WB + 5 * BH, (int)(1.5*BB), BH, "Edit 3D arrow"); + b->callback(general_arrow_param_cb); + o->end(); } { @@ -2264,13 +2267,13 @@ void GUI::create_option_window() view_value[62]->callback(set_changed_cb, 0); { - view_vector = new Fl_Group(2 * WB, 2 * WB + 4 * BH, width / 2, 6 * BH, 0); + view_vector = new Fl_Group(2 * WB, 2 * WB + 4 * BH, width - 2 * WB, 6 * BH, 0); static Fl_Menu_Item menu_vectype[] = { {"Line", 0, 0, 0}, {"Arrow", 0, 0, 0}, {"Pyramid", 0, 0, 0}, - {"3D Arrow", 0, 0, 0}, + {"3D arrow", 0, 0, 0}, {"Displacement", 0, 0, 0}, {0} }; @@ -2279,6 +2282,8 @@ void GUI::create_option_window() view_choice[2]->align(FL_ALIGN_RIGHT); view_choice[2]->callback(set_changed_cb, 0); + view_push_butt[0] = new Fl_Button(2 * IW - 2 * WB, 2 * WB + 5 * BH, (int)(1.5*BB), BH, "Edit 3D arrow"); + view_value[60] = new Fl_Value_Input(2 * WB, 2 * WB + 6 * BH, IW, BH, "Arrow size"); view_value[60]->minimum(0); view_value[60]->maximum(500); @@ -2469,6 +2474,7 @@ void GUI::update_view_window(int num) opt_view_displacement_factor(num, GMSH_GUI, 0); opt_view_arrow_location(num, GMSH_GUI, 0); opt_view_tensor_type(num, GMSH_GUI, 0); + view_push_butt[0]->callback(view_arrow_param_cb, (void*)num); // colors view_colorbar_window->update(v->Name, v->Min, v->Max, &v->CT, &v->Changed); @@ -3429,3 +3435,4 @@ void GUI::create_solver_window(int num) solver[num].window->position(CTX.solver_position[0], CTX.solver_position[1]); solver[num].window->end(); } + diff --git a/Fltk/GUI.h b/Fltk/GUI.h index ee9736795649ae6ab78c4a3b8989010146bbc91d..5ee62d9cada5d25bef007c0d6bd3dde1076ed166 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -196,6 +196,7 @@ public: Fl_Value_Input *view_value[VIEW_OPT_BUTT] ; Fl_Input *view_input[VIEW_OPT_BUTT] ; Fl_Repeat_Button *view_butt_rep[VIEW_OPT_BUTT] ; + Fl_Button *view_push_butt[VIEW_OPT_BUTT] ; Fl_Choice *view_choice[VIEW_OPT_BUTT] ; Colorbar_Window *view_colorbar_window ; @@ -285,6 +286,5 @@ public: }; - #endif diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index 779db3c103b9ea718048f03f3a5e9aba095cddc0..190c1e3ab7cbc1a6a41d85154bde6571442824d5 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.35 2004-04-20 01:26:13 geuzaine Exp $ +// $Id: Entity.cpp,v 1.36 2004-04-23 17:44:24 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -367,12 +367,14 @@ void Draw_3DArrow(double relHeadRadius, double relStemLength, double relStemRadi glTranslated(x, y, z); glRotated(phi, axis[0], axis[1], axis[2]); - if(head_l && head_r){ - glTranslated(0., 0., stem_l); + glTranslated(0., 0., stem_l); + if(head_l && head_r) gluCylinder(qua, head_r, 0., head_l, subdiv, 1); + if(head_r > stem_r) gluDisk(qua, stem_r, head_r, subdiv, 1); - glTranslated(0., 0., -stem_l); - } + else + gluDisk(qua, head_r, stem_r, subdiv, 1); + glTranslated(0., 0., -stem_l); if(stem_l && stem_r){ gluCylinder(qua, stem_r, stem_r, stem_l, subdiv, 1);