~ubuntu-branches/debian/squeeze/gmsh/squeeze

« back to all changes in this revision

Viewing changes to Fltk/optionWindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme
  • Date: 2009-09-02 18:12:15 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090902181215-yla8zvcas2ucvkm9
[Christophe Prud'homme]
* New upstream release
  + fixed surface mesh orientation bug introduced in 2.4.0;
  + mesh and graphics code refactoring;
  + small usability enhancements and bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include "GmshConfig.h"
11
11
#include "GmshDefines.h"
12
12
#include "GmshMessage.h"
13
 
#include "GUI.h"
 
13
#include "FlGui.h"
14
14
#include "optionWindow.h"
15
15
#include "paletteWindow.h"
16
16
#include "menuWindow.h"
17
17
#include "extraDialogs.h"
18
 
#include "Draw.h"
 
18
#include "drawContext.h"
19
19
#include "Options.h"
20
20
#include "Solvers.h"
21
21
#include "GModel.h"
113
113
  uchar b = CTX::instance()->unpackBlue(fct(0, GMSH_GET, 0));
114
114
  if(fl_color_chooser("Color Chooser", r, g, b))
115
115
    fct(0, GMSH_SET | GMSH_GUI, CTX::instance()->packColor(r, g, b, 255));
116
 
  Draw();
 
116
  drawContext::global()->draw();
117
117
}
118
118
 
119
119
static void view_color_cb(Fl_Widget *w, void *data)
121
121
  unsigned int (*fct) (int, int, unsigned int);
122
122
  fct = (unsigned int (*)(int, int, unsigned int))data;
123
123
  uchar r = CTX::instance()->unpackRed
124
 
    (fct(GUI::instance()->options->view.index, GMSH_GET, 0));
 
124
    (fct(FlGui::instance()->options->view.index, GMSH_GET, 0));
125
125
  uchar g = CTX::instance()->unpackGreen
126
 
    (fct(GUI::instance()->options->view.index, GMSH_GET, 0));
 
126
    (fct(FlGui::instance()->options->view.index, GMSH_GET, 0));
127
127
  uchar b = CTX::instance()->unpackBlue
128
 
    (fct(GUI::instance()->options->view.index, GMSH_GET, 0));
 
128
    (fct(FlGui::instance()->options->view.index, GMSH_GET, 0));
129
129
  if(fl_color_chooser("Color Chooser", r, g, b))
130
 
    fct(GUI::instance()->options->view.index, 
 
130
    fct(FlGui::instance()->options->view.index, 
131
131
        GMSH_SET | GMSH_GUI, CTX::instance()->packColor(r, g, b, 255));
132
 
  Draw();
 
132
  drawContext::global()->draw();
133
133
}
134
134
 
135
135
void options_cb(Fl_Widget *w, void *data)
136
136
{
137
 
  GUI::instance()->options->win->show();
 
137
  FlGui::instance()->options->win->show();
138
138
}
139
139
 
140
140
static void options_browser_cb(Fl_Widget *w, void *data)
141
141
{
142
 
  GUI::instance()->options->showGroup(GUI::instance()->options->browser->value());
 
142
  FlGui::instance()->options->showGroup(FlGui::instance()->options->browser->value());
143
143
}
144
144
 
145
145
void options_save_cb(Fl_Widget *w, void *data)
157
157
  UnlinkFile(CTX::instance()->homeDir + CTX::instance()->optionsFileName);
158
158
  ReInitOptions(0);
159
159
  InitOptionsGUI(0);
160
 
  if(GUI::instance()->menu->module->value() == 3) // hack to refresh the buttons
161
 
    GUI::instance()->menu->setContext(menu_post, 0);
162
 
  Draw();
 
160
  if(FlGui::instance()->menu->module->value() == 3) // hack to refresh the buttons
 
161
    FlGui::instance()->menu->setContext(menu_post, 0);
 
162
  drawContext::global()->draw();
163
163
}
164
164
 
165
165
void general_options_cb(Fl_Widget *w, void *data)
166
166
{
167
 
  GUI::instance()->options->showGroup(1);
 
167
  FlGui::instance()->options->showGroup(1);
168
168
}
169
169
 
170
170
static void general_options_color_scheme_cb(Fl_Widget *w, void *data)
171
171
{
172
172
  opt_general_color_scheme
173
 
    (0, GMSH_SET, GUI::instance()->options->general.choice[3]->value());
174
 
  Draw();
 
173
    (0, GMSH_SET, FlGui::instance()->options->general.choice[3]->value());
 
174
  drawContext::global()->draw();
175
175
}
176
176
 
177
177
static void general_options_rotation_center_select_cb(Fl_Widget *w, void *data)
178
178
{
179
179
  Msg::StatusBar(3, false, "Select entity\n[Press 'q' to abort]");
180
 
  char ib = GUI::instance()->selectEntity(ENT_ALL);
 
180
  char ib = FlGui::instance()->selectEntity(ENT_ALL);
181
181
  if(ib == 'l') {
182
182
    SPoint3 pc(0., 0., 0.);
183
 
    if(GUI::instance()->selectedVertices.size())
184
 
      pc.setPosition(GUI::instance()->selectedVertices[0]->x(),
185
 
                     GUI::instance()->selectedVertices[0]->y(),
186
 
                     GUI::instance()->selectedVertices[0]->z());
187
 
    else if(GUI::instance()->selectedEdges.size())
188
 
      pc = GUI::instance()->selectedEdges[0]->bounds().center();
189
 
    else if(GUI::instance()->selectedFaces.size())
190
 
      pc = GUI::instance()->selectedFaces[0]->bounds().center();
191
 
    else if(GUI::instance()->selectedRegions.size())
192
 
      pc = GUI::instance()->selectedRegions[0]->bounds().center();
193
 
    else if(GUI::instance()->selectedElements.size())
194
 
      pc = GUI::instance()->selectedElements[0]->barycenter();
 
183
    if(FlGui::instance()->selectedVertices.size())
 
184
      pc.setPosition(FlGui::instance()->selectedVertices[0]->x(),
 
185
                     FlGui::instance()->selectedVertices[0]->y(),
 
186
                     FlGui::instance()->selectedVertices[0]->z());
 
187
    else if(FlGui::instance()->selectedEdges.size())
 
188
      pc = FlGui::instance()->selectedEdges[0]->bounds().center();
 
189
    else if(FlGui::instance()->selectedFaces.size())
 
190
      pc = FlGui::instance()->selectedFaces[0]->bounds().center();
 
191
    else if(FlGui::instance()->selectedRegions.size())
 
192
      pc = FlGui::instance()->selectedRegions[0]->bounds().center();
 
193
    else if(FlGui::instance()->selectedElements.size())
 
194
      pc = FlGui::instance()->selectedElements[0]->barycenter();
195
195
    opt_general_rotation_center_cg
196
 
      (0, GMSH_SET, GUI::instance()->options->general.butt[15]->value());
 
196
      (0, GMSH_SET, FlGui::instance()->options->general.butt[15]->value());
197
197
    opt_general_rotation_center0(0, GMSH_SET|GMSH_GUI, pc.x());
198
198
    opt_general_rotation_center1(0, GMSH_SET|GMSH_GUI, pc.y());
199
199
    opt_general_rotation_center2(0, GMSH_SET|GMSH_GUI, pc.z());
200
200
  }
201
201
  GModel::current()->setSelection(0);
202
 
  Draw();
 
202
  drawContext::global()->draw();
203
203
  Msg::StatusBar(3, false, "");
204
204
}
205
205
 
206
206
static void general_options_ok_cb(Fl_Widget *w, void *data)
207
207
{
208
 
  optionWindow *o = GUI::instance()->options;
 
208
  optionWindow *o = FlGui::instance()->options;
209
209
  o->activate((const char*)data);
210
210
 
211
211
  static double lc = 0.;
308
308
 
309
309
  if(CTX::instance()->fastRedraw)
310
310
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
311
 
  Draw();
 
311
  drawContext::global()->draw();
312
312
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
313
313
  CTX::instance()->drawRotationCenter = 0;
314
314
}
322
322
    opt_general_arrow_head_radius(0, GMSH_SET, a);
323
323
    opt_general_arrow_stem_length(0, GMSH_SET, b);
324
324
    opt_general_arrow_stem_radius(0, GMSH_SET, c);
325
 
    Draw();
 
325
    drawContext::global()->draw();
326
326
  }
327
327
}
328
328
 
329
329
void geometry_options_cb(Fl_Widget *w, void *data)
330
330
{
331
 
  GUI::instance()->options->showGroup(2);
 
331
  FlGui::instance()->options->showGroup(2);
332
332
}
333
333
 
334
334
static void geometry_options_ok_cb(Fl_Widget *w, void *data)
335
335
{
336
 
  optionWindow *o = GUI::instance()->options;
 
336
  optionWindow *o = FlGui::instance()->options;
337
337
  o->activate((const char*)data);
338
338
 
339
339
  opt_geometry_points(0, GMSH_SET, o->geo.butt[0]->value());
351
351
  opt_geometry_occ_fix_small_faces(0, GMSH_SET, o->geo.butt[12]->value());
352
352
  opt_geometry_occ_sew_faces(0, GMSH_SET, o->geo.butt[13]->value());
353
353
  opt_geometry_light_two_side(0, GMSH_SET, o->geo.butt[14]->value());
 
354
  opt_geometry_occ_connect_faces(0, GMSH_SET, o->geo.butt[15]->value());
354
355
 
355
356
  opt_geometry_normals(0, GMSH_SET, o->geo.value[0]->value());
356
357
  opt_geometry_tangents(0, GMSH_SET, o->geo.value[1]->value());
379
380
  
380
381
  if(CTX::instance()->fastRedraw)
381
382
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
382
 
  Draw();
 
383
  drawContext::global()->draw();
383
384
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
384
385
}
385
386
 
386
387
void mesh_options_cb(Fl_Widget *w, void *data)
387
388
{
388
 
  GUI::instance()->options->showGroup(3);
 
389
  FlGui::instance()->options->showGroup(3);
389
390
}
390
391
 
391
392
static void mesh_options_ok_cb(Fl_Widget *w, void *data)
392
393
{
393
 
  optionWindow *o = GUI::instance()->options;
 
394
  optionWindow *o = FlGui::instance()->options;
394
395
  o->activate((const char*)data);
395
396
 
396
397
  opt_mesh_reverse_all_normals(0, GMSH_SET, o->mesh.butt[0]->value());
440
441
 
441
442
  opt_mesh_point_type(0, GMSH_SET, o->mesh.choice[0]->value());
442
443
  opt_mesh_algo2d(0, GMSH_SET,
443
 
                  (o->mesh.choice[2]->value() == 0) ? ALGO_2D_FRONTAL : 
 
444
                  (o->mesh.choice[2]->value() == 0) ? ALGO_2D_MESHADAPT : 
444
445
                  (o->mesh.choice[2]->value() == 1) ? ALGO_2D_DELAUNAY :
445
 
                  ALGO_2D_MESHADAPT_DELAUNAY);
 
446
                  ALGO_2D_FRONTAL);
446
447
  opt_mesh_algo3d(0, GMSH_SET,
447
 
                  (o->mesh.choice[3]->value() == 0) ? ALGO_3D_TETGEN_DELAUNAY : 
448
 
                  ALGO_3D_NETGEN);
 
448
                  (o->mesh.choice[3]->value() == 0) ? ALGO_3D_DELAUNAY : 
 
449
                  ALGO_3D_FRONTAL);
449
450
  opt_mesh_algo_subdivide(0, GMSH_SET, o->mesh.choice[5]->value());
450
451
  opt_mesh_color_carousel(0, GMSH_SET, o->mesh.choice[4]->value());
451
452
  opt_mesh_quality_type(0, GMSH_SET, o->mesh.choice[6]->value());
453
454
 
454
455
  if(CTX::instance()->fastRedraw)
455
456
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
456
 
  Draw();
 
457
  drawContext::global()->draw();
457
458
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
458
459
}
459
460
 
460
461
void solver_options_cb(Fl_Widget *w, void *data)
461
462
{
462
 
  GUI::instance()->options->showGroup(4);
 
463
  FlGui::instance()->options->showGroup(4);
463
464
}
464
465
 
465
466
static void solver_options_ok_cb(Fl_Widget *w, void *data)
466
467
{
467
 
  optionWindow *o = GUI::instance()->options;
 
468
  optionWindow *o = FlGui::instance()->options;
468
469
  o->activate((const char*)data);
469
470
 
470
471
  int old_listen = (int)opt_solver_listen(0, GMSH_GET, o->solver.butt[0]->value());
476
477
 
477
478
  if(CTX::instance()->fastRedraw)
478
479
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
479
 
  Draw();
 
480
  drawContext::global()->draw();
480
481
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
481
482
}
482
483
 
483
484
void post_options_cb(Fl_Widget *w, void *data)
484
485
{
485
 
  GUI::instance()->options->showGroup(5);
 
486
  FlGui::instance()->options->showGroup(5);
486
487
}
487
488
 
488
489
static void post_options_ok_cb(Fl_Widget *w, void *data)
489
490
{
490
 
  optionWindow *o = GUI::instance()->options;
 
491
  optionWindow *o = FlGui::instance()->options;
491
492
  o->activate((const char*)data);
492
493
 
493
494
  opt_post_anim_cycle(0, GMSH_SET, o->post.butt[0]->value());
500
501
 
501
502
  if(CTX::instance()->fastRedraw)
502
503
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
503
 
  Draw();
 
504
  drawContext::global()->draw();
504
505
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
505
506
}
506
507
 
507
508
void view_options_cb(Fl_Widget *w, void *data)
508
509
{
509
 
  GUI::instance()->options->showGroup((int)(long)data + 6);
 
510
  FlGui::instance()->options->showGroup((int)(long)data + 6);
510
511
}
511
512
 
512
513
static void view_options_timestep_cb(Fl_Widget *w, void *data)
516
517
  for(int i = 0; i < (int)PView::list.size(); i++) {
517
518
    if((links == 2 || links == 4) ||
518
519
       ((links == 1 || links == 3) && opt_view_visible(i, GMSH_GET, 0)) ||
519
 
       (links == 0 && i == GUI::instance()->options->view.index)) {
 
520
       (links == 0 && i == FlGui::instance()->options->view.index)) {
520
521
      if(str == "=")
521
522
        opt_view_timestep(i, GMSH_SET, ((Fl_Value_Input *) w)->value());
522
523
      else if(str == "-")
527
528
                          opt_view_timestep(i, GMSH_GET, 0) + 1);
528
529
    }
529
530
  }
530
 
  Draw();
 
531
  drawContext::global()->draw();
531
532
}
532
533
 
533
534
static void view_options_ok_cb(Fl_Widget *w, void *data)
534
535
{
535
 
  int current = GUI::instance()->options->view.index;
 
536
  int current = FlGui::instance()->options->view.index;
536
537
 
537
538
  if(current < 0) return;
538
539
 
539
 
  optionWindow *o = GUI::instance()->options;
 
540
  optionWindow *o = FlGui::instance()->options;
540
541
  o->activate((const char*)data);
541
542
 
542
543
  if(data){
1110
1111
 
1111
1112
  if(CTX::instance()->fastRedraw)
1112
1113
    CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
1113
 
  Draw();
 
1114
  drawContext::global()->draw();
1114
1115
  CTX::instance()->post.draw = CTX::instance()->mesh.draw = 1;
1115
1116
}
1116
1117
 
1117
1118
static void view_options_max_recursion_cb(Fl_Widget *w, void *data)
1118
1119
{
1119
1120
  std::string str((const char*)data);
1120
 
  int val = (int)GUI::instance()->options->view.value[33]->value();
 
1121
  int val = (int)FlGui::instance()->options->view.value[33]->value();
1121
1122
  if(str == "-" && val > 0)
1122
 
    GUI::instance()->options->view.value[33]->value(val - 1);
 
1123
    FlGui::instance()->options->view.value[33]->value(val - 1);
1123
1124
  else if(str == "+")
1124
 
    GUI::instance()->options->view.value[33]->value(val + 1);
 
1125
    FlGui::instance()->options->view.value[33]->value(val + 1);
1125
1126
  view_options_ok_cb(0, 0);
1126
1127
}
1127
1128
 
1627
1628
        (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Sew faces in OpenCascade models");
1628
1629
      geo.butt[13]->type(FL_TOGGLE_BUTTON);
1629
1630
      geo.butt[13]->callback(geometry_options_ok_cb);
 
1631
      geo.butt[15] = new Fl_Check_Button
 
1632
        (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Cut and merge faces in OpenCascade models");
 
1633
      geo.butt[15]->type(FL_TOGGLE_BUTTON);
 
1634
      geo.butt[15]->callback(geometry_options_ok_cb);
1630
1635
 
1631
1636
#if !defined(HAVE_OCC)
1632
1637
      geo.butt[11]->deactivate();
1633
1638
      geo.butt[12]->deactivate();
1634
1639
      geo.butt[13]->deactivate();
 
1640
      geo.butt[15]->deactivate();
1635
1641
#endif
1636
1642
      o->end();
1637
1643
    }
1865
1871
      o->hide();
1866
1872
 
1867
1873
      static Fl_Menu_Item menu_2d_algo[] = {
 
1874
        {"MeshAdapt", 0, 0, 0},
 
1875
        {"Delaunay", 0, 0, 0},
1868
1876
        {"Frontal", 0, 0, 0},
1869
 
        {"Delaunay", 0, 0, 0},
1870
 
        {"MeshAdapt+Delaunay", 0, 0, 0},
1871
1877
        {0}
1872
1878
      };
1873
1879
      static Fl_Menu_Item menu_3d_algo[] = {
1874
 
        {"Tetgen+Delaunay", 0, 0, 0},
1875
 
        {"Netgen", 0, 0, 0},
 
1880
        {"Delaunay", 0, 0, 0},
 
1881
        {"Frontal", 0, 0, 0},
1876
1882
        {0}
1877
1883
      };
1878
1884
      static Fl_Menu_Item menu_subdivision_algo[] = {
3152
3158
  opt_view_axes_zmin(index, GMSH_GUI, 0);
3153
3159
  opt_view_axes_zmax(index, GMSH_GUI, 0);
3154
3160
  for(int i = 13; i <= 18; i++){
3155
 
    view.value[i]->step(CTX::instance()->lc/200.);
 
3161
    view.value[i]->step(CTX::instance()->lc / 200.);
3156
3162
    view.value[i]->minimum(-CTX::instance()->lc);
3157
3163
    view.value[i]->maximum(CTX::instance()->lc);
3158
3164
  }
3200
3206
  opt_view_offset1(index, GMSH_GUI, 0);
3201
3207
  opt_view_offset2(index, GMSH_GUI, 0);
3202
3208
  for(int i = 40; i <= 42; i++) {
3203
 
    view.value[i]->step(val1 / 100.);
 
3209
    view.value[i]->step(val1 / 200.);
3204
3210
    view.value[i]->minimum(-val1);
3205
3211
    view.value[i]->maximum(val1);
3206
3212
  }
3218
3224
  opt_view_raise2(index, GMSH_GUI, 0);
3219
3225
  opt_view_normal_raise(index, GMSH_GUI, 0);
3220
3226
  for(int i = 43; i <= 46; i++) {
3221
 
    view.value[i]->step(val2 / 100.);
 
3227
    view.value[i]->step(val2 / 200.);
3222
3228
    view.value[i]->minimum(-val2);
3223
3229
    view.value[i]->maximum(val2);
3224
3230
  }
3228
3234
  opt_view_gen_raise0(index, GMSH_GUI, "");
3229
3235
  opt_view_gen_raise1(index, GMSH_GUI, "");
3230
3236
  opt_view_gen_raise2(index, GMSH_GUI, "");
3231
 
  view.value[2]->step(val2 / 100.);
 
3237
  view.value[2]->step(val2 / 200.);
3232
3238
  view.value[2]->minimum(-val2);
3233
3239
  view.value[2]->maximum(val2);
3234
3240