📄 glrgraph.hpp
字号:
windowPart = FindWindow(myEvent.where, &whichWindow); if((whichWindow==grafWindow0) /* && (inContent == windowPart)*/) { if (grafWindow0 != FrontWindow()) { SelectWindow(whichWindow); SetPortWindowPort(whichWindow); GetPort(&grafPort0); } char1 = (myEvent.message & 127L); } break;} case updateEvt: /* if (ours((WindowPtr) myEvent.message)) { BeginUpdate((WindowPtr) myEvent.message); EndUpdate((WindowPtr) myEvent.message); } */ break; // cout << "End HandleEvent" << int(char1) << endl;} return char1;}#endifchar Getijc(int & x,int & y){ char char1=0;#ifdef AGL viderbuff(); showgraphic(); EventRecord myEvent; int flag=1;// HLock( (Handle) WatchCurseur);// SetCursor(*CrossCurseur);// HUnlock( (Handle) WatchCurseur); SelectWindow(grafWindow0); while (char1==0) { if (GetNextEvent(everyEvent, &myEvent) /* ,OxFFFFFFFF,h)*/) char1=HandleEvent(myEvent); } GlobalToLocal( & myEvent.where); x = myEvent.where.h; y = myEvent.where.v;#endif#ifdef XGL XEvent event; int flag,nb; XComposeStatus status; char buffer[20]; KeySym keysym; /* incidence */ XDefineCursor(dpy,win,cursor_arrow); flag=0; while (!flag) { XNextEvent(dpy, &event); if(event.type == ButtonRelease) { x = event.xbutton.x; y = event.xbutton.y; if (event.xbutton.button == Button1) char1=shift?248:251; else if (event.xbutton.button == Button2) char1=shift?249:252; else char1=shift?250:253; // printf(" mouse release %d\n",(int) char1); flag=1; } else if(event.type == KeyPress) { x = event.xkey.x; y = event.xkey.y; char1= event.xkey.keycode ; keysym=0; nb=XLookupString(&event.xkey,buffer,20,&keysym,&status);/* printf("nb= %d keysym= %d buffer=",nb,keysym);/* for(i=0;i<20;i++)/* printf(" %d ",(int)buffer[i]);/* printf("\n");*//* voir /usr/include/X11/keysymdef.h + ap_keysym */ if (nb != 0) {char1 = buffer[0]; flag= 1; } else {/* if (IsFunctionKey(keysym)) printf("function down\n"); else if(IsModifierKey(keysym)) printf("modifier down\n"); else if(IsKeypadKey(keysym)) printf(" keypad down\n"); else if(IsMiscFunctionKey(keysym)) printf(" misc function down\n"); else if(IsPFKey(keysym)) printf(" PF key down\n");*/#ifdef XK_MISCELLANY switch(keysym) {/* Cursor control & motion */ /* case XK_Left : flag = 1; char1 = call(keyboa).curs_left; break; case XK_Up : flag = 1; char1 = call(keyboa).curs_up; break; case XK_Right : flag = 1; char1 = call(keyboa).curs_right; break; case XK_Down : flag = 1; char1 = call(keyboa).curs_down; break; case XK_Next : flag = 1; char1 = call(keyboa).pad_down; break; case XK_Prior : flag = 1; char1 = call(keyboa).pad_up; break; case XK_End : flag = 1; char1 = call(keyboa).marg_right; break; case XK_Begin : flag = 1; char1 = call(keyboa).marg_left; break; *//* Misc Functions */ /* case XK_Select : flag = 1; char1 = call(keyboa).mark; break; *//* case XK_Print : flag = 1; char1 = ; break; case XK_Execute : flag = 1; char1 = ; break; case XK_Insert : flag = 1; char1 = ; break; case XK_Undo : flag = 1; char1 = call(keyboa).undo; break; case XK_Redo : flag = 1; char1 = ; break; case XK_Menu : flag = 1; char1 = ; break; case XK_Find : flag = 1; char1 = ; break; case XK_Cancel : flag = 1; char1 = call(keyboa).line_del; break; case XK_Help : flag = 1; char1 = call(keyboa).help; break; case XK_Break : flag = 1; char1 = ; break; case XK_Mode_switch : flag = 1; char1 = ; break; case XK_script_switch : flag = 1; char1 = ; break; case XK_Num_Lock : flag = 1; char1 = ; break; case XK_F1 : flag = 1; char1 = shift ? call(keyboa).sfunct1 : call(keyboa).funct1 ; break; case XK_F2 : flag = 1; char1 = shift ? call(keyboa).sfunct2 : call(keyboa).funct2 ; break; case XK_F3 : flag = 1; char1 = shift ? call(keyboa).sfunct3 : call(keyboa).funct3 ; break; case XK_F4 : flag = 1; char1 = shift ? call(keyboa).sfunct4 : call(keyboa).funct4 ; break; case XK_F5 : flag = 1; char1 = shift ? call(keyboa).sfunct5 : call(keyboa).funct5 ; break; case XK_F6 : flag = 1; char1 = shift ? call(keyboa).sfunct6 : call(keyboa).funct6 ; break; case XK_F7 : flag = 1; char1 = shift ? call(keyboa).sfunct7 : call(keyboa).funct7 ; break; case XK_F8 : flag = 1; char1 = shift ? call(keyboa).sfunct8 : call(keyboa).funct8 ; break; case XK_F9 : flag = 1; char1 = shift ? call(keyboa).sfunct9 : call(keyboa).funct9 ; break; case XK_F10 : flag = 1; char1 = shift ? call(keyboa).sfunct10 : call(keyboa).funct10 ; break; case XK_F11 : flag = 1; char1 = shift ? call(keyboa).sfunct11 : call(keyboa).funct11 ; break; case XK_F12 : flag = 1; char1 = shift ? call(keyboa).sfunct12 : call(keyboa).funct12 ; break; */ case XK_Shift_L : shift=1; break; case XK_Shift_R : shift=1; break; case XK_Control_L : control=1; break; case XK_Control_R : control=1; break; case XK_Caps_Lock : shiftlock = 1 ; break; case XK_Shift_Lock : shiftlock = 1 ; break; case XK_Meta_L : alt=1; break; case XK_Meta_R : alt=1; break; case XK_Alt_L : alt=1; break; case XK_Alt_R : alt=1; break; } /* end switch */#endif } } else if(event.type == KeyRelease) { x = event.xkey.x; y = event.xkey.y; char1= event.xkey.keycode ; keysym=0; nb=XLookupString(&event.xkey,buffer,20,&keysym,&status);/* if (IsFunctionKey(keysym)) printf("function up\n"); else if(IsModifierKey(keysym)) printf("modifier up\n"); else if(IsKeypadKey(keysym)) printf(" keypad up\n"); else if(IsMiscFunctionKey(keysym)) printf(" misc function up\n"); else if(IsPFKey(keysym)) printf(" PF key up\n");*/ if (nb == 0) {#ifdef XK_MISCELLANY switch(keysym) { case XK_Shift_L : shift=0; break; case XK_Shift_R : shift=0; break; case XK_Control_L : control=0; break; case XK_Control_R : control=0; break; case XK_Caps_Lock : shiftlock = 0 ; break; case XK_Shift_Lock : shiftlock = 0 ; break; case XK_Meta_L : alt=0; break; case XK_Meta_R : alt=0; break; case XK_Alt_L : alt=0; break; case XK_Alt_R : alt=0; break; } /* end switch */#endif } } } XDefineCursor(dpy,win,cursor_watch); XFlush(dpy);#endif#ifdef WGL a faire #endif return char1; }char Getxyc(float &x,float &y){ char c; int i,j; // cout << "getxyc \n"; c = Getijc( i,j); x = scali(i); y = scalj(j);// cout << "getxyc out \n"; return c;}void viderbuff(){ glFinish();#ifdef AGL aglSwapBuffers (ctx); // send swap command#endif#ifdef XGL glXSwapBuffers (dpy,win); // send swap command#endif}void rattente(int waitm){ int i,j; char c=0; if(waitm) c = Getijc( i,j); if ( c == 3) {cout << "rattente: ^c => abort " << endl;closegraphique();exit(1);}// ^c => exit/* you may prefer to use carriage return to move to the next graph *//* getc(stdin);*/// if(waitm) while(!Button()){ };}//void GetSizeScreen(int & ix,int &iy);// GetScreenSize_void GetScreenSize(int & ix,int &iy){ ix = width ; iy = height;}void openPS(const char *filename ){ char ffff[32]; int count=0; if(psfile_save) closePS(); time_t t_loc; float s=0.5; const int shiftx=50,shifty=50; // char username[10]; time(&t_loc); bool notfound; if( !filename) do { struct stat buf; sprintf(ffff,"rgraph_%.3d.ps",count++); volatile int r= stat(ffff,&buf) ; notfound = r !=0; if(count>1000) break; } while ( !notfound ); psfile=fopen(filename?filename:ffff,"w"); if(psfile==0) {printf("Erreur %s errno %d\n",filename?filename:ffff,errno);exit(1);} if(psfile) { fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); fprintf(psfile,"%%%%Pages: 1\n"); fprintf(psfile,"%%%%BoundingBox: %d %d %d %d\n",shiftx,shifty,int(shiftx+width*s),int(shifty+height*s)); fprintf(psfile,"%%%%EndComments\n"); fprintf(psfile," /L { lineto currentpoint stroke newpath moveto} def\n"); fprintf(psfile," /M { moveto } def\n"); fprintf(psfile," /C {setrgbcolor} def\n"); fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); fprintf(psfile," %d %d translate \n",shiftx,shifty); fprintf(psfile," %f %f scale \n",s,s); fprintf(psfile," 0 %d 0 %d rec clip newpath\n",int(width),int(height)); fprintf(psfile," /Helvetica findfont 10 scalefont setfont\n"); fprintf(psfile," /S { show} def\n"); fprintf(psfile," /bF { mark} def \n"); fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); fprintf(psfile," 1 setlinewidth\n"); psfile_save=psfile; }}void closePS(void){ if(psfile_save) { fprintf(psfile_save,"showpage\n"); fclose(psfile_save); } psfile=0; psfile_save=0; } void Commentaire(const char * c) { if(psfile) { fprintf(psfile,"%% %s\n",c); } }; void NoirEtBlanc(int NB) { if(NB) LastColor=1; else LastColor=ncolortable?ncolortable:2; } void MettreDansPostScript(int in) { if(in) psfile=psfile_save; else psfile=0; }static void FillRect(float x0,float y0, float x1, float y1) { float r[8]; r[0]=x0;r[1]=y0; r[2]=x1;r[3]=y0; r[4]=x1;r[5]=y1; r[6]=x0;r[7]=y1; fillpoly(4,r); }float GetHeigthFont(){ // FontInfo MyFontInfo; // GetFontInfo(&MyFontInfo); #ifdef XGL int dir,asc,desc,k; XCharStruct overall; XTextExtents(font_info,"gML",3,&dir,&asc,&desc,&overall); return (asc+desc)*(0.9/echy);#else int interligne = 9;// MyFontInfo.ascent + MyFontInfo.descent + MyFontInfo.leading; return interligne/echy;#endif}int PutLevel(int lineno, float xf, int col){ float xmin,xmax,ymin,ymax; getcadre(xmin,xmax,ymin,ymax); float xleft = xmax - (xmax-xmin)*0.1; float ytop = ymax; float ydelta = (ymax-ymin)/40; ydelta=GetHeigthFont(); xleft = xmax - 6*ydelta; ytop -= ydelta*(col+2); couleur(col); FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.); rmoveto(xleft+ydelta*1.4,ytop+ydelta/4); char buf[30]; sprintf(buf,"%g",xf); couleur(1); plotstring(buf); return lineno;} void ShowHelp(const char * s,int k){ if(k) { MettreDansPostScript(0); couleur(1); float xmin,xmax,ymin,ymax; getcadre(xmin,xmax,ymin,ymax); rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); plotstring(s); MettreDansPostScript(1); // couleur(1); }}class Grid; void setgrey(bool gg ){grey=gg;} int getgrey(){ return grey;}void SaveMesh(Grid &t){}void SavePlot(int D, Grid& t, double *f){}void SavePlot(int D, Grid& t, float *f){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -