📄 xgcommands.c
字号:
Grid_On(theNewWindow); Z_AutoRescale(Window); } else { Set_ThreeD(theNewWindow); ColorCode_On(theNewWindow); Grid_On(theNewWindow); Z_AutoRescale_Off(Window); } if(atoi(argv[13])) Set_Z_Log(Window); else Set_Z_Lin(Window); Iconic_Before(Window); RedrawWindow(Window); return TCL_OK;}int C_TraceProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; if (Is_Trace_On(theWindow)) { Trace_Off(theWindow); } else { Trace_On(theWindow); } return TCL_OK;}int C_PrintProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ char fileType, printMode; WindowType theWindow = theWindowArray[atoi(argv[1])]; char **xpmData; fileType = argv[4][0]; printMode = argv[5][0]; switch(fileType) { case 'x':#ifdef XPMENABLED if(argv[6][0]!='n' && (!Is_Trace_On(theWindow) || Is_X_AutoRescale(theWindow) || Is_Y_AutoRescale(theWindow))) { Iconic_Before(theWindow); C_RefreshGraphicsProc(NULL,NULL,1,argv); } XpmWriteFileFromPixmap(theDisplay,argv[2],theWindow->pixmap_buffer, 0,NULL);#endif break; case 'p':#ifdef XPMENABLED if(argv[4][1]=='n') /* png */ { if(argv[6][0]!='n' && (!Is_Trace_On(theWindow) || Is_X_AutoRescale(theWindow) || Is_Y_AutoRescale(theWindow))) { Iconic_Before(theWindow); C_RefreshGraphicsProc(NULL,NULL,1,argv); } XpmWriteFileFromPixmap(theDisplay,argv[2],theWindow->pixmap_buffer,0,0); { char name[512]; char name2[512]; char buffer[512]; int i; sprintf(name,"%s",argv[2]); i = strlen(name); if(i<5) return 0; /* invalid name */ sprintf(name+i-4,"%s",".xpm"); sprintf(name2,"%s",name); sprintf(name2+i-4,"%s",".png"); sprintf(buffer,"mv %s %s;convert %s %s; rm %s",name2,name,name,name2,name); system(buffer); break; } }#else break;#endif /* XPMENABLED */ case 'e': if(access(argv[2],F_OK) || printMode=='o' || printMode=='c') PSHeader(argv[2]); (*(theWindow->print_function)) (theWindow, argv[2], argv[3]); break; case 'a': (*(theWindow->ascii_print_function)) (theWindow, argv[2], printMode); break; case 'b': (*(theWindow->xgrafix_print_function)) (theWindow, argv[2], printMode); break; case 'g':#ifdef XPMENABLED if(argv[6][0]!='n' && (!Is_Trace_On(theWindow) || Is_X_AutoRescale(theWindow) || Is_Y_AutoRescale(theWindow))) { Iconic_Before(theWindow); C_RefreshGraphicsProc(NULL,NULL,1,argv); } XpmCreateDataFromPixmap(theDisplay, &xpmData, theWindow->pixmap_buffer, 0,NULL); XpmToGif(xpmData,argv[2]); XpmFree(xpmData);#endif break; } return TCL_OK;} int C_3DViewProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType Window = theWindowArray[atoi(argv[1])]; Window->theta = atof(argv[2]); Window->phi = atof(argv[3]); if(atoi(argv[4])) Shading_On(Window); else Shading_Off(Window); if(atoi(argv[5])) ColorCode_On(Window); else ColorCode_Off(Window); if(atoi(argv[6])) Grid_On(Window); else Grid_Off(Window); RedrawWindow(Window); return TCL_OK;}int C_GetSpecialValuesProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ int i; strcpy(TclCommand,""); for(i=0;i<numberOfSpecials;i++) { if (theSpecialArray[i]->Type == DOUBLE) { sprintf(TclCommand,"%s %g",TclCommand,*(double*)(theSpecialArray[i]->data)); } else if (theSpecialArray[i]->Type == INTEGER) { sprintf(TclCommand,"%s %d",TclCommand,*(int*)(theSpecialArray[i]->data)); } else if (theSpecialArray[i]->Type == FLOAT) { sprintf(TclCommand,"%s %f",TclCommand,*(float*)(theSpecialArray[i]->data)); } else { sprintf(TclCommand,"%s %c",TclCommand,*(char*)(theSpecialArray[i]->data)); } } sprintf(TclCommand,"%s\n",TclCommand); interp->result = TclCommand; return TCL_OK;}int C_SetNewSpecialProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ int index = atoi(argv[1]); if (theSpecialArray[index]->Type == DOUBLE) { *(double*)(theSpecialArray[index]->data) = atof(argv[2]); } else if (theSpecialArray[index]->Type == INTEGER) { *(int*)(theSpecialArray[index]->data) = atoi(argv[2]); } else if (theSpecialArray[index]->Type == FLOAT) { *(float*)(theSpecialArray[index]->data) = atof(argv[2]); } else { *(char*)(theSpecialArray[index]->data) = argv[2][0]; } Tcl_Eval(interp,"DoGraphics\n"); return TCL_OK;}int C_GetRangesProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; LabelType theLabel = theWindow->label; sprintf(TclCommand,"%g %g %d %d %g %g %d %d %g %g %d %d\n",theLabel->X_Min, theLabel->X_Max, theLabel->X_Auto_Rescale, Is_X_Log(theWindow), theLabel->Y_Min, theLabel->Y_Max, theLabel->Y_Auto_Rescale, Is_Y_Log(theWindow), theLabel->Z_Min, theLabel->Z_Max, theLabel->Z_Auto_Rescale, Is_Z_Log(theWindow)); interp->result = TclCommand; return TCL_OK;}int C_3dCrossProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; DataType theData = theWindow->data; if (!(Is_Irr_Surf(theData)) && !(Is_Scatter(theData))) { DrawCrosshair(theWindow, atoi(argv[2]), atoi(argv[3])); } return TCL_OK;}int C_3dCrossOnProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; Crosshair_On(theWindow); return TCL_OK;}int C_3dCrossOffProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; Crosshair_Off(theWindow); return TCL_OK;}int C_ShouldRefreshProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ WindowType theWindow = theWindowArray[atoi(argv[1])]; if (Is_Trace_On(theWindow) && !Is_X_AutoRescale(theWindow) && !Is_Y_AutoRescale(theWindow)) TclCommand[0] = '1'; else TclCommand[0] = '0'; TclCommand[1] = '\0'; interp->result = TclCommand; return TCL_OK;}int C_DefineULProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ double x1, y1; WindowType theWindow = theWindowArray[atoi(argv[1])]; x1 = atof(argv[2]); y1 = atof(argv[3]); if (Is_X_Log(theWindow)) { xtemp1 = theWindow->c1 * log10(max(x1, DBL_MIN)) + theWindow->d1; } else { xtemp1 = theWindow->c1 * x1 + theWindow->d1; } if (Is_Y_Log(theWindow)) { ytemp1 = theWindow->c2 * log10(max(y1, DBL_MIN)) + theWindow->d2; } else { ytemp1 = theWindow->c2 * y1 + theWindow->d2; } return TCL_OK;}int C_StretchBoxProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv){ double x2,y2,xtemp2,ytemp2; Pixmap pm; XRectangle theClientArea; Tk_Window tkwin; WindowType theWindow = theWindowArray[atoi(argv[1])]; tkwin = theWindow->tkwin; theClientArea.x = 0; theClientArea.y = 0; theClientArea.width = Tk_Width(tkwin); theClientArea.height = Tk_Height(tkwin); XSetClipRectangles(theDisplay, theWindow->xwingc, 0, 0, &theClientArea, 1, Unsorted); pm = XCreatePixmap(theDisplay, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); XCopyArea(theDisplay, theWindow->pixmap_buffer, pm, theWindow->xwingc, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0); x2 = atof(argv[2]); y2 = atof(argv[3]); if (Is_X_Log(theWindow)) { xtemp2 = theWindow->c1 * log10(max(x2, DBL_MIN)) + theWindow->d1; } else { xtemp2 = theWindow->c1 * x2 + theWindow->d1; } if (Is_Y_Log(theWindow)) { ytemp2 = theWindow->c2 * log10(max(y2, DBL_MIN)) + theWindow->d2; } else { ytemp2 = theWindow->c2 * y2 + theWindow->d2; } XSetForeground(theDisplay, theWindow->xwingc, theWhitePixel); XDrawRectangle(theDisplay, pm, theWindow->xwingc, min(xtemp1,xtemp2), min(ytemp1,ytemp2), fabs(xtemp2 - xtemp1), fabs(ytemp2 - ytemp1)); XCopyArea(theDisplay, pm, Tk_WindowId(tkwin), theWindow->xwingc, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0); XFlush(theDisplay); XFreePixmap(theDisplay, pm); return TCL_OK;}void InitTclCommands(){ Tcl_CreateCommand(interp, "C_Run", C_RunProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Quit", C_QuitProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_KillGraphics", C_KillGraphicsProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Close", C_CloseProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Open", C_OpenProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Stop", C_StopProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Step", C_StepProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Save", C_SaveProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_printf", C_printfProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_pause", C_pauseProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_RefreshGraphics", C_RefreshGraphicsProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Rescale", C_RescaleProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Trace", C_TraceProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_Print", C_PrintProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_UpdateCrosshair", C_UpdateCrosshairProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_SetCrosshairParameters", C_SetCrosshairParametersProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_3DView", C_3DViewProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_GetSpecialValues", C_GetSpecialValuesProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_SetNewSpecials", C_SetNewSpecialProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_GetRanges", C_GetRangesProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_CreateWindow", C_CreateWindowProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_3dCross", C_3dCrossProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_3dCrossOn", C_3dCrossOnProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_3dCrossOff", C_3dCrossOffProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_ShouldRefresh", C_ShouldRefreshProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_DefineUL", C_DefineULProc, (ClientData) NULL, (void (*)()) NULL); Tcl_CreateCommand(interp, "C_StretchBox", C_StretchBoxProc, (ClientData) NULL, (void (*)()) NULL);}void SortWindows(){ int i; int j; WindowType *newWindowArray = (WindowType *) malloc(sizeof(struct window_struct)*sizeOfWindowArray); for (i=0;i<numberOfWindows;i++) { j = Search(theWindowArray[i]->plot_title); newWindowArray[j] = theWindowArray[i]; } free(theWindowArray); theWindowArray=newWindowArray;}int Search(char *WinTitle){ sprintf(TclCommand,"set temp \"\"; set \"WinData([append temp . [string tolower \"%s\"]],index)\"\n",WinTitle); Tcl_Eval(interp,TclCommand); return atoi(interp->result);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -