Skip to content
Snippets Groups Projects
Commit cdf7975c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

easy way to hide/show mesh + set clscale directly from the main

gui window
parent 2f20a238
Branches
Tags
No related merge requests found
...@@ -582,16 +582,7 @@ int FlGui::testGlobalShortcuts(int event) ...@@ -582,16 +582,7 @@ int FlGui::testGlobalShortcuts(int event)
status = 2; status = 2;
} }
else if(Fl::test_shortcut(FL_ALT + 'm')) { else if(Fl::test_shortcut(FL_ALT + 'm')) {
int old = opt_mesh_points(0, GMSH_GET, 0) || status_options_cb(0, (void *)"M");
opt_mesh_lines(0, GMSH_GET, 0) ||
opt_mesh_surfaces_edges(0, GMSH_GET, 0) ||
opt_mesh_surfaces_faces(0, GMSH_GET, 0);
opt_mesh_points(0, GMSH_SET | GMSH_GUI, !old);
opt_mesh_lines(0, GMSH_SET | GMSH_GUI, !old);
opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI, !old);
opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, !old);
opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI, !old);
opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI, !old);
status = 2; status = 2;
} }
else if(Fl::test_shortcut(FL_ALT + 't')) { else if(Fl::test_shortcut(FL_ALT + 't')) {
......
...@@ -90,13 +90,7 @@ int arrowEditor(const char *title, double &a, double &b, double &c) ...@@ -90,13 +90,7 @@ int arrowEditor(const char *title, double &a, double &b, double &c)
// Perspective editor (aka z-clipping planes factor slider) // Perspective editor (aka z-clipping planes factor slider)
static void persp_change_factor(Fl_Widget* w, void* data) class Release_Slider : public Fl_Value_Slider {
{
opt_general_clip_factor(0, GMSH_SET|GMSH_GUI, ((Fl_Slider*)w)->value());
drawContext::global()->draw();
}
class Release_Slider : public Fl_Slider {
int handle(int event) int handle(int event)
{ {
switch (event) { switch (event) {
...@@ -105,14 +99,20 @@ class Release_Slider : public Fl_Slider { ...@@ -105,14 +99,20 @@ class Release_Slider : public Fl_Slider {
window()->hide(); window()->hide();
return 1; return 1;
default: default:
return Fl_Slider::handle(event); return Fl_Value_Slider::handle(event);
} }
}; };
public: public:
Release_Slider(int x, int y, int w, int h, const char *l=0) Release_Slider(int x, int y, int w, int h, const char *l=0)
: Fl_Slider(x, y, w, h, l) {} : 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() int perspectiveEditor()
{ {
struct _editor{ struct _editor{
...@@ -123,12 +123,12 @@ int perspectiveEditor() ...@@ -123,12 +123,12 @@ int perspectiveEditor()
if(!editor){ if(!editor){
editor = new _editor; editor = new _editor;
editor->window = new Fl_Menu_Window(20, 100); editor->window = new Fl_Menu_Window(150, 20);
if(CTX::instance()->nonModalWindows) editor->window->set_non_modal(); if(CTX::instance()->nonModalWindows) editor->window->set_non_modal();
editor->sa = new Release_Slider(0, 0, 20, 100); editor->sa = new Release_Slider(0, 0, 150, 20);
editor->sa->type(FL_VERT_NICE_SLIDER); editor->sa->type(FL_HOR_NICE_SLIDER);
editor->sa->minimum(12); editor->sa->minimum(0.75);
editor->sa->maximum(0.75); editor->sa->maximum(12);
editor->sa->callback(persp_change_factor); editor->sa->callback(persp_change_factor);
editor->window->border(0); editor->window->border(0);
editor->window->end(); editor->window->end();
...@@ -143,6 +143,44 @@ int perspectiveEditor() ...@@ -143,6 +143,44 @@ int perspectiveEditor()
return 0; return 0;
} }
// Perspective editor (aka z-clipping planes factor slider)
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(150, 20);
if(CTX::instance()->nonModalWindows) editor->window->set_non_modal();
editor->sa = new Release_Slider(0, 0, 150, 20);
editor->sa->type(FL_HOR_NICE_SLIDER);
editor->sa->minimum(0.1);
editor->sa->maximum(2);
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;
}
// Model chooser // Model chooser
static void model_switch_cb(Fl_Widget* w, void *data) static void model_switch_cb(Fl_Widget* w, void *data)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
int arrowEditor(const char *title, double &a, double &b, double &c); int arrowEditor(const char *title, double &a, double &b, double &c);
int perspectiveEditor(); int perspectiveEditor();
int meshSizeEditor();
int modelChooser(); int modelChooser();
std::string connectionChooser(); std::string connectionChooser();
std::string patternChooser(); std::string patternChooser();
......
...@@ -79,10 +79,18 @@ static void gmsh_rotate(Fl_Color c) ...@@ -79,10 +79,18 @@ static void gmsh_rotate(Fl_Color c)
static void gmsh_models(Fl_Color c) static void gmsh_models(Fl_Color c)
{ {
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.8,-0.8); vv(0.8,-0.8); el;
bl; vv(0.3,-0.8); vv(0.8,-0.8); vv(0.8,-0.3); vv(0.3,-0.3); el; bl; vv(-0.8,-0.4); vv(0.8,-0.4); el;
bl; vv(-0.8,0.3); vv(-0.3,0.3); vv(-0.3,0.8); vv(-0.8,0.8); el; bl; vv(-0.8,-0.); vv(0.8,-0.); el;
bl; vv(0.3,0.3); vv(0.8,0.3); vv(0.8,0.8); vv(0.3,0.8); el; bl; vv(-0.8,0.4); vv(0.8,0.4); el;
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.2,0.8); vv(-0.8,0.2); el;
bl; vv(-0.3,0.4); vv(0.8,0.4); vv(-0.3,-0.8); el;
} }
#undef vv #undef vv
...@@ -205,6 +213,43 @@ void status_options_cb(Fl_Widget *w, void *data) ...@@ -205,6 +213,43 @@ void status_options_cb(Fl_Widget *w, void *data)
} }
drawContext::global()->draw(); drawContext::global()->draw();
} }
else if(!strcmp(str, "M")){ // toggle mesh display
static int value = 1;
static int old_p = (int)opt_mesh_points(0, GMSH_GET, 0.);
static int old_l = (int)opt_mesh_lines(0, GMSH_GET, 0.);
static int old_se = (int)opt_mesh_surfaces_edges(0, GMSH_GET, 0.);
static int old_sf = (int)opt_mesh_surfaces_faces(0, GMSH_GET, 0.);
static int old_ve = (int)opt_mesh_volumes_edges(0, GMSH_GET, 0.);
static int old_vf = (int)opt_mesh_volumes_faces(0, GMSH_GET, 0.);
if(!value){ // retore visibility
value = 1;
opt_mesh_points(0, GMSH_SET | GMSH_GUI, old_p);
opt_mesh_lines(0, GMSH_SET | GMSH_GUI, old_l);
opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI, old_se);
opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, old_sf);
opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI, old_ve);
opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI, old_vf);
}
else{
value = 0;
old_p = (int)opt_mesh_points(0, GMSH_GET, 0.);
old_l = (int)opt_mesh_lines(0, GMSH_GET, 0.);
old_se = (int)opt_mesh_surfaces_edges(0, GMSH_GET, 0.);
old_sf = (int)opt_mesh_surfaces_faces(0, GMSH_GET, 0.);
old_ve = (int)opt_mesh_volumes_edges(0, GMSH_GET, 0.);
old_vf = (int)opt_mesh_volumes_faces(0, GMSH_GET, 0.);
opt_mesh_points(0, GMSH_SET | GMSH_GUI, 0);
opt_mesh_lines(0, GMSH_SET | GMSH_GUI, 0);
opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI, 0);
opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, 0);
opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI, 0);
opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI, 0);
}
drawContext::global()->draw();
}
else if(!strcmp(str, "clscale")){
meshSizeEditor();
}
else if(!strcmp(str, "S")){ // mouse selection else if(!strcmp(str, "S")){ // mouse selection
if(CTX::instance()->mouseSelection){ if(CTX::instance()->mouseSelection){
opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0); opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0);
...@@ -356,6 +401,7 @@ graphicWindow::graphicWindow(bool main, int numTiles) ...@@ -356,6 +401,7 @@ graphicWindow::graphicWindow(bool main, int numTiles)
fl_add_symbol("gmsh_ortho", gmsh_ortho, 1); fl_add_symbol("gmsh_ortho", gmsh_ortho, 1);
fl_add_symbol("gmsh_rotate", gmsh_rotate, 1); fl_add_symbol("gmsh_rotate", gmsh_rotate, 1);
fl_add_symbol("gmsh_models", gmsh_models, 1); fl_add_symbol("gmsh_models", gmsh_models, 1);
fl_add_symbol("gmsh_clscale", gmsh_clscale, 1);
first = false; first = false;
} }
...@@ -411,6 +457,14 @@ graphicWindow::graphicWindow(bool main, int numTiles) ...@@ -411,6 +457,14 @@ graphicWindow::graphicWindow(bool main, int numTiles)
butt[8]->callback(status_options_cb, (void *)"p"); butt[8]->callback(status_options_cb, (void *)"p");
butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)"); butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)");
x += sw; x += sw;
butt[12] = new Fl_Button(x, glheight + 2, sw, sht, "M");
butt[12]->callback(status_options_cb, (void *)"M");
butt[12]->tooltip("Toggle mesh visibility (Alt+m)");
x += sw;
butt[13] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_clscale");
butt[13]->callback(status_options_cb, (void *)"clscale");
butt[13]->tooltip("Change mesh element size factor");
x += sw;
butt[9] = new Fl_Button(x, glheight + 2, sw, sht, "S"); butt[9] = new Fl_Button(x, glheight + 2, sw, sht, "S");
butt[9]->callback(status_options_cb, (void *)"S"); butt[9]->callback(status_options_cb, (void *)"S");
butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)"); butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)");
...@@ -436,7 +490,7 @@ graphicWindow::graphicWindow(bool main, int numTiles) ...@@ -436,7 +490,7 @@ graphicWindow::graphicWindow(bool main, int numTiles)
butt[11]->deactivate(); butt[11]->deactivate();
x += sw; x += sw;
for(int i = 0; i < 12; i++) { for(int i = 0; i < 14; i++) {
butt[i]->box(FL_FLAT_BOX); butt[i]->box(FL_FLAT_BOX);
butt[i]->selection_color(FL_WHITE); butt[i]->selection_color(FL_WHITE);
butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
......
...@@ -22,7 +22,7 @@ class graphicWindow{ ...@@ -22,7 +22,7 @@ class graphicWindow{
Fl_Tile *tile; Fl_Tile *tile;
std::vector<openglWindow*> gl; std::vector<openglWindow*> gl;
Fl_Box *bottom; Fl_Box *bottom;
Fl_Button *butt[12]; Fl_Button *butt[14];
Fl_Box *label[2]; Fl_Box *label[2];
int minWidth, minHeight; int minWidth, minHeight;
public: public:
......
...@@ -4,6 +4,6 @@ Mesh.CharacteristicLengthFactor=0.05; ...@@ -4,6 +4,6 @@ Mesh.CharacteristicLengthFactor=0.05;
Merge "artery.stl"; Merge "artery.stl";
CreateTopology; CreateTopology;
Compound Surface(100)={1} Conformal; Compound Surface(100)={1} Harmonic;
Physical Surface(101)={100}; Physical Surface(101)={100};
\ No newline at end of file
Mesh.CharacteristicLengthFactor=0.1; Mesh.CharacteristicLengthFactor=0.1;
Mesh.Algorithm3D = 4; //Frontal (4) Delaunay(1) Mesh.Algorithm3D = 1; //Frontal (4) Delaunay(1)
Merge "pelvis.stl"; Merge "pelvis.stl";
Compound Surface(200)={1} Conformal; Compound Surface(200)={1};// Conformal;
Surface Loop(300)={200}; Surface Loop(300)={200};
Volume(301)={300}; Volume(301)={300};
Physical Surface (501)={200}; Physical Surface (501)={200};
Physical Volume(502)={301}; Physical Volume(502)={301};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment