From 86c652f8ce2e2b2071dbfc9c488ed18dd73964e1 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 11 Jan 2001 07:34:25 +0000 Subject: [PATCH] *** empty log message *** --- Fltk/Callbacks.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++--- Fltk/GUI.cpp | 9 ++-- Fltk/GUI.h | 1 + Fltk/Opengl.cpp | 28 ++++++------ Graphics/XDump.cpp | 10 ++--- Motif/CbMesh.cpp | 6 +-- tutorial/t1.geo | 3 ++ 7 files changed, 129 insertions(+), 32 deletions(-) diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 8322c79669..e7b3c82533 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.12 2001-01-10 21:28:18 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.13 2001-01-11 07:32:35 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -60,10 +60,48 @@ void MarkAllViewsChanged(int action){ } } +#ifdef _USETHREADS + +#include <pthread.h> + +int MeshDim ; +pthread_t MeshThread ; + +void* StartMeshThread(void * data){ + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + mai3d(&M,MeshDim); + Msg(STATUS,"Ready"); + CTX.mesh.draw = 1; + CTX.threads_lock = 0; + XtSetSensitive(WID.G.Butt[6], 0); + Init(); + Draw(); + pthread_exit(NULL); + return NULL ; +} + +void CancelMeshThread(void){ + if(CTX.threads){ + pthread_cancel(MeshThread); + CTX.mesh.draw = 1; + CTX.threads_lock = 0; + XtSetSensitive(WID.G.Butt[6], 0); + Msg(INFO,"Mesh Aborted"); + mesh_event_handler(MESH_DELETE); + Msg(STATUS,"Ready"); + Init(); + Draw(); + } +} + +#else + void CancelMeshThread(void){ } +#endif + int SetGlobalShortcut(int event){ return WID->global_shortcuts(event); } @@ -714,16 +752,70 @@ void mesh_define_cb(CALLBACK_ARGS){ WID->set_context(menu_mesh_define, 0); } void mesh_1d_cb(CALLBACK_ARGS){ - printf("mesh 1d\n"); +#ifdef _USETHREADS + if(CTX.threads){ + XtSetSensitive(WID.G.Butt[6], 1); + CTX.mesh.draw = 0; CTX.threads_lock = 1 ; MeshDim = 1 ; + pthread_create(&MeshThread, NULL, StartMeshThread, NULL); + } + else +#endif + mai3d(&M, 1); } void mesh_2d_cb(CALLBACK_ARGS){ - printf("mesh 2d\n"); +#ifdef _USETHREADS + if(CTX.threads){ + XtSetSensitive(WID.G.Butt[6], 1); + CTX.mesh.draw = 0; CTX.threads_lock = 1 ; MeshDim = 2 ; + pthread_create(&MeshThread, NULL, StartMeshThread, NULL); + } + else +#endif + mai3d(&M, 2); } void mesh_3d_cb(CALLBACK_ARGS){ - printf("mesh 3d\n"); +#ifdef _USETHREADS + if(CTX.threads){ + XtSetSensitive(WID.G.Butt[6], 1); + CTX.mesh.draw = 0; CTX.threads_lock = 1 ; MeshDim = 3 ; + pthread_create(&MeshThread, NULL, StartMeshThread, NULL); + } + else +#endif + mai3d(&M, 3); } void mesh_define_length_cb (CALLBACK_ARGS){ - printf("mesh define length\n"); + Vertex *v; + Curve *c; + Surface *s; + int ib; + static int n=0, p[100]; + + WID->create_mesh_context_window(0); + + while(1){ + Msg(STATUS,"Select Point ('e'=end, 'q'=quit)"); + ib = SelectEntity(ENT_POINT, &v,&c,&s); + if(ib == 1){ /* left mouse butt */ + p[n++] = v->Num; + } + if (ib == -1){ /* 'e' */ + if(n >= 1) { + add_charlength(n,p,CTX.filename); + break; + } + n=0; + ZeroHighlight(&M); + Replot(); + } + if(ib == 0){ /* 'q' */ + n=0 ; + ZeroHighlight(&M); + Replot(); + break; + } + } + if(!CTX.threads) Msg(STATUS,"Ready"); } void mesh_define_recombine_cb (CALLBACK_ARGS){ printf("mesh define reco\n"); @@ -732,12 +824,14 @@ void mesh_define_transfinite_cb (CALLBACK_ARGS){ WID->set_context(menu_mesh_define_transfinite, 0); } void mesh_define_transfinite_line_cb(CALLBACK_ARGS){ + WID->create_mesh_context_window(1); printf("mesh define tr line\n"); } void mesh_define_transfinite_surface_cb(CALLBACK_ARGS){ printf("mesh define tr su\n"); } void mesh_define_transfinite_volume_cb(CALLBACK_ARGS){ + WID->create_mesh_context_window(3); printf("mesh define tr vol\n"); } diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index db1d82aadb..1a801b923a 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -249,9 +249,12 @@ int GUI::global_shortcuts(int event){ if(event != FL_SHORTCUT) return 0 ; // test... - if(Fl::test_shortcut(FL_CTRL+'z')){ - gen_butt[0]->do_callback(); - printf("CACACACAC\n"); + if(Fl::test_shortcut('e')){ + end_selection = 1; + return 1; + } + else if(Fl::test_shortcut('q')){ + quit_selection = 1; return 1; } diff --git a/Fltk/GUI.h b/Fltk/GUI.h index dc35db84d5..83abd0cda4 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -179,6 +179,7 @@ public: void activate_custom(int val); void add_handler(); int global_shortcuts(int event); + int quit_selection, end_selection; // geometry contexts queries char *get_geometry_parameter(int num); diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index 9bab4cc344..83f9ba2876 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.9 2001-01-10 21:20:39 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.10 2001-01-11 07:32:35 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -109,21 +109,23 @@ int check_type(int type, Vertex *v, Curve *c, Surface *s){ } int SelectEntity(int type, Vertex **v, Curve **c, Surface **s){ - return 0; - /* - int hits; - GLuint ii[SELECTION_BUFFER_SIZE],jj[SELECTION_BUFFER_SIZE]; - int event; + int hits; + GLuint ii[SELECTION_BUFFER_SIZE],jj[SELECTION_BUFFER_SIZE]; *v = NULL; *c = NULL; *s = NULL; - - printf("select entity...\n"); - + + WID->quit_selection = 0; + WID->end_selection = 0; + while(1){ Fl::check(); - if((event = Fl::event_key())){ - if(event == 'q') return(0); - if(event == 'e') return(-1); + if(WID->quit_selection){ + WID->quit_selection = 0; + return 0; + } + if(WID->end_selection){ + WID->end_selection = 0; + return -1; } if(Fl::event_is_click()){ Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj); @@ -136,7 +138,7 @@ int SelectEntity(int type, Vertex **v, Curve **c, Surface **s){ } } } - */ + } diff --git a/Graphics/XDump.cpp b/Graphics/XDump.cpp index c8ad9ca1f7..5adbb10c22 100644 --- a/Graphics/XDump.cpp +++ b/Graphics/XDump.cpp @@ -1,4 +1,4 @@ -// $Id: XDump.cpp,v 1.3 2001-01-09 19:40:56 remacle Exp $ +// $Id: XDump.cpp,v 1.4 2001-01-11 07:34:25 geuzaine Exp $ /* This is a modified version for Gmsh (mainly for c++ compliance) */ @@ -56,10 +56,7 @@ * 12 so a correct file is written. BEP July-21-95 */ -#ifdef WIN32 - -#else - +#ifndef WIN32 typedef struct { unsigned int /*long*/ pixel; @@ -455,4 +452,5 @@ void Window_Dump(Display *display, int scr, Window window, FILE *out){ */ XDestroyImage(image); } -#endif \ No newline at end of file +#endif + diff --git a/Motif/CbMesh.cpp b/Motif/CbMesh.cpp index c0ca0fa6d0..e56b142a26 100644 --- a/Motif/CbMesh.cpp +++ b/Motif/CbMesh.cpp @@ -1,4 +1,4 @@ -// $Id: CbMesh.cpp,v 1.1 2001-01-08 08:20:10 geuzaine Exp $ +// $Id: CbMesh.cpp,v 1.2 2001-01-11 07:32:35 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -13,10 +13,6 @@ extern Widgets_T WID; extern Context_T CTX; extern Mesh M; -extern char trsf_pts_text[100], trsf_type_text[100]; -extern char trsf_vol_text[100], char_length_text[100]; -extern char attrx_text[100], attry_text[100], attrz_text[100], attrdec_text[100]; - /* ------------------------------------------------------------------------ */ /* m e s h _ e v e n t _ h a n d l e r */ /* ------------------------------------------------------------------------ */ diff --git a/tutorial/t1.geo b/tutorial/t1.geo index f49bbfbe3a..4acaf765ed 100644 --- a/tutorial/t1.geo +++ b/tutorial/t1.geo @@ -97,3 +97,6 @@ Physical Surface(100) = {6} ; // description of the mesh and post-processing formats, see the FORMATS // file. +Characteristic Length {2 ,2 ,2 ,2 ,2 ,1 ,1 ,1 ,1 } = 1.0; +Characteristic Length {1 ,1 ,1 ,1 ,1 ,4 ,4 ,4 ,4 } = 1.0; +Characteristic Length {2 ,2 ,2 ,2 ,2 ,2 } = 1.0; -- GitLab