📄 xginitc.c
字号:
theBlackPixel = BlackPixel(theDisplay, theScreen); theWhitePixel = WhitePixel(theDisplay, theScreen); theColormap = DefaultColormap(theDisplay, theScreen); theRootWindow = RootWindow(theDisplay, theScreen); theDisplayWidth = DisplayWidth(theDisplay, theScreen); theDisplayHeight = DisplayHeight(theDisplay, theScreen); printf("\nXGrafix version %s\n",xgversion); printf("(c) Copyright 1991-2002 The Regents of the University of California\n\n"); printf("XGrafix is running on %s version %d of the X Window System, X%d R%d\n", ServerVendor(theDisplay), VendorRelease(theDisplay), ProtocolVersion(theDisplay), ProtocolRevision(theDisplay)); /* * 7.20.93 XDisplayName takes a (char *) and not a (Display *) ! The NULL * is because XDisplay name returns it's own argument if the NULL string is * not specified. With a NULL argument it returns the DISPLAY environment * variable. */ printf("Display name .............. %s\n", ReqDisp); printf("Display width ............. %d\n", theDisplayWidth); printf("Display height ............ %d\n", theDisplayHeight); if (theDepth == 1) printf("Color plane depth ......... %d (monochrome)\n\n", theDepth); else printf("Color plane depth ......... %d\n\n", theDepth); /*****************************************/ if (theDepth > 1) { for (i = 0; i < MAXCOLORS; i++) { if (XLookupColor(theDisplay, theColormap, theColorNames[i], &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) Color[i] = theHardwareColor.pixel; RedColor[i] = (SCALAR)theHardwareColor.red/65535.0; GreenColor[i] = (SCALAR)theHardwareColor.green/65535.0; BlueColor[i] = (SCALAR)theHardwareColor.blue/65535.0; } if (XLookupColor(theDisplay, theColormap, WindowTextColor, &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) theWinTextColor = theHardwareColor.pixel; if (XLookupColor(theDisplay, theColormap, BorderColor, &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) theBorderColor = theHardwareColor.pixel; if (XLookupColor(theDisplay, theColormap, TickMarkColor, &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) theTickMarkColor = theHardwareColor.pixel; if (XLookupColor(theDisplay, theColormap, BackgroundColor, &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) theBKGDColor = theHardwareColor.pixel; for (i = 0; i < MAXGRAYSHADES; i++) { if (XLookupColor(theDisplay, theColormap, theGrayShades[i], &theRGBColor, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) GrayShade[i] = theHardwareColor.pixel; } /************* the ThreeD Colors ***************/ for (i = 0; i <= 60; i++) { if (0 <= i && i < 10) { sprintf(temp, "#%s%s%s", theTDColorNames[10], theTDColorNames[i], theTDColorNames[0]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[10], theTDPSColorNames[i], theTDPSColorNames[0]); } else if (10 <= i && i < 20) { sprintf(temp, "#%s%s%s", theTDColorNames[20 - i], theTDColorNames[10], theTDColorNames[0]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[20 - i], theTDPSColorNames[10], theTDPSColorNames[0]); } else if (20 <= i && i < 30) { sprintf(temp, "#%s%s%s", theTDColorNames[0], theTDColorNames[10], theTDColorNames[i - 20]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[0], theTDPSColorNames[10], theTDPSColorNames[i - 20]); } else if (30 <= i && i < 40) { sprintf(temp, "#%s%s%s", theTDColorNames[0], theTDColorNames[40 - i], theTDColorNames[10]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[0], theTDPSColorNames[40 - i], theTDPSColorNames[10]); } else if (40 <= i && i < 50) { sprintf(temp, "#%s%s%s", theTDColorNames[i - 40], theTDColorNames[0], theTDColorNames[10]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[i - 40], theTDPSColorNames[0], theTDPSColorNames[10]); } else if (50 <= i && i < 60) { sprintf(temp, "#%s%s%s", theTDColorNames[10], theTDColorNames[i - 50], theTDColorNames[10]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[10], theTDPSColorNames[i - 50], theTDPSColorNames[10]); } else if (i == 60) { sprintf(temp, "#%s%s%s", theTDColorNames[10], theTDColorNames[10], theTDColorNames[10]); sprintf(ThreeDPSColor[i], "%s%s%s", theTDPSColorNames[10], theTDPSColorNames[10], theTDPSColorNames[10]); } /* sprintf(temp, "#%x%x%x", 64+3*i, 64+3*i, 64+3*i); */ if (XParseColor(theDisplay, theColormap, temp, &theHardwareColor)) if (XAllocColor(theDisplay, theColormap, &theHardwareColor)) ThreeDColor[i] = theHardwareColor.pixel; } } else { for (i = 0; i < MAXCOLORS; i++) Color[i] = theWhitePixel; for (i = 0; i < MAXTHREEDCOLORS; i++) ThreeDColor[i] = theWhitePixel; theWinTextColor = theWhitePixel; theDBTextColor = theWhitePixel; theBorderColor = theWhitePixel; theTickMarkColor = theWhitePixel; theBKGDColor = theBlackPixel; for (i = 0; i < MAXGRAYSHADES; i++) GrayShade[i] = theWhitePixel; GrayShade[1] = theBlackPixel; GrayShade[3] = theBlackPixel; GrayShade[5] = theBlackPixel; GrayShade[6] = theBlackPixel; GrayShade[10] = theBlackPixel; } /************************************/ /* Initializing the XGrafix font */ if ((theFontStruct = XLoadQueryFont(theDisplay, theFontName)) == NULL) { printf("can't open the specified font\n"); exit(-1); } theFont = theFontStruct->fid; theFontAscent = theFontStruct->ascent; theFontDescent = theFontStruct->descent; theFontHeight = theFontAscent + theFontDescent;}void XGInitTclTk() { char *str, str2[200]; /************************************/ /* Initializing the Tcl/Tk stuff */#ifdef Tcl75_Tk41 interp = Tcl_CreateInterp(); Tcl_Init(interp); sprintf(str2, "-display %s", ReqDisp); Tcl_SetVar(interp, "argv", str2, 0); Tk_Init(interp); mainWindow = Tk_MainWindow(interp);#endif#ifdef Tcl74_Tk40 interp = Tcl_CreateInterp(); mainWindow = Tk_CreateMainWindow(interp, ReqDisp, "", "");#endif /***************************/ /* Create the Tcl Commands */ InitTclCommands(); /******************************/ /* Sourcing the main Tcl file */ /*if XGTCL is set in ENV then use it else use compile time default*/ if(getenv("XGTCL")) { str = (char *)malloc((strlen(getenv("XGTCL"))+20)*sizeof(char)); sprintf(str, "%s", getenv("XGTCL")); sprintf(TclCommand,"set XGrafixPath %s; source %s/xgsetup250.tcl; InitMainMenu %d \"%s\"\n",str, str, WasInputFileGiven,theInputFile); free(str); } else { sprintf(TclCommand,"set XGrafixPath " XGTCL "; source " XGTCL "/xgsetup250.tcl; InitMainMenu %d \"%s\"\n",WasInputFileGiven,theInputFile); } if(Tcl_Eval(interp,TclCommand)!=TCL_OK) { printf("Error in initialization\n"); if(*interp->result != 0) { printf("%s\n",interp->result); } if (theCodeName) free(theCodeName); if (theInputFile) free(theInputFile); if (theDumpFile) free(theDumpFile); if (theEPSFile) free(theEPSFile); Tcl_DeleteInterp(interp); XFreeFont(theDisplay,theFontStruct); XCloseDisplay(theDisplay); exit(1); } #ifndef XPMENABLED Tcl_Eval(interp,".printdialog.top.type.menu disable 1\n"); Tcl_Eval(interp,".printdialog.top.type.menu disable 2\n");#endif}#ifdef __STDC__void XGStructure(int numPoints,...) {#elsevoid XGStructure(va_alist) va_dcl { int numPoints;#endif int i, lineColor, fillColor; va_list ap; STRUCT_FILL fillFlag; StructType *structure = (StructType *)malloc(sizeof(StructType));#ifdef __STDC__ va_start(ap,numPoints);#else va_start(ap); numPoints = va_arg(ap,int);#endif fillFlag = va_arg(ap,int); lineColor = va_arg(ap,int); fillColor = va_arg(ap,int); structure->x = (double *)malloc(numPoints * sizeof(double)); structure->y = (double *)malloc(numPoints * sizeof(double)); structure->numberPoints = numPoints; structure->fillFlag = fillFlag; structure->lineColor = lineColor; structure->fillColor = fillColor; for (i=0;i<numPoints;i++) { structure->x[i] = va_arg(ap,double); structure->y[i] = va_arg(ap,double); } va_end(ap); structure->next = theNewWindow->structures; theNewWindow->structures = structure;}void XGStructureArray(int numPoints,STRUCT_FILL fillFlag,int lineColor, int fillColor, SCALAR *points ) { int i; StructType *structure = (StructType *)malloc(sizeof(StructType)); structure->x = (double *)malloc(numPoints * sizeof(double)); structure->y = (double *)malloc(numPoints * sizeof(double)); structure->numberPoints = numPoints; structure->fillFlag = fillFlag; structure->lineColor = lineColor; structure->fillColor = fillColor; for (i=0;i<numPoints;i++) { structure->x[i] = points[2*i]; structure->y[i] = points[2*i+1]; } structure->next = theNewWindow->structures; theNewWindow->structures = structure;}void XGSetVec(char *PlotType, char *X_Label, char *Y_Label, char *Z_Label, char *State, int ulx, int uly, SCALAR X_Scale, SCALAR Y_Scale, int X_Auto_Rescale, int Y_Auto_Rescale, SCALAR X_Min, SCALAR X_Max, SCALAR Y_Min, SCALAR Y_Max){ int plottype; DataType data_ptr = NULL; LabelType label_ptr; label_ptr = SetupLabelStruct(); label_ptr->Z_Label = strdup(Z_Label); label_ptr->Z_Auto_Rescale = 0; label_ptr->Y_Label = strdup(Y_Label); label_ptr->Y_Min = Y_Min; label_ptr->Y_Max = Y_Max; label_ptr->Y_Scale = Y_Scale; label_ptr->Y_Auto_Rescale = Y_Auto_Rescale; label_ptr->X_Label = strdup(X_Label); label_ptr->X_Min = X_Min; label_ptr->X_Max = X_Max; label_ptr->X_Scale = X_Scale; label_ptr->X_Auto_Rescale = X_Auto_Rescale; if (!strcmp(PlotType, "vecvec")) plottype = VEC_VEC; else { printf("Unrecognized plot string '%s' for Window '%s'.\n", PlotType, Y_Label); exit(-1); } XGSetupWindow(Z_Label, State, ulx, uly, VECD, data_ptr, label_ptr, plottype);}void XGSetVecFlag(char *PlotType, char *X_Label, char *Y_Label, char *Z_Label, char *State, int ulx, int uly, SCALAR X_Scale,SCALAR Y_Scale, int X_Auto_Rescale, int Y_Auto_Rescale, SCALAR X_Min, SCALAR X_Max, SCALAR Y_Min, SCALAR Y_Max, int *openFlag){ XGSetVec(PlotType, X_Label, Y_Label, Z_Label, State, ulx, uly, X_Scale, Y_Scale, X_Auto_Rescale, Y_Auto_Rescale, X_Min, X_Max, Y_Min,Y_Max); theWindowArray[numberOfWindows-1]->openFlag = openFlag;} void XGSet3D(char *PlotType, char *X_Label, char *Y_Label, char *Z_Label, SCALAR Theta, SCALAR Phi, char *State, int ulx, int uly, SCALAR X_Scale, SCALAR Y_Scale, SCALAR Z_Scale, int X_Auto_Rescale, int Y_Auto_Rescale, int Z_Auto_Rescale, SCALAR X_Min, SCALAR X_Max, SCALAR Y_Min, SCALAR Y_Max, SCALAR Z_Min, SCALAR Z_Max){ int plottype; DataType data_ptr = NULL; LabelType label_ptr; init_theta = Theta; init_phi = Phi; label_ptr = SetupLabelStruct(); label_ptr->Z_Label = strdup(Z_Label); label_ptr->Z_Min = Z_Min; label_ptr->Z_Max = Z_Max; label_ptr->Z_Scale = Z_Scale; label_ptr->Z_Auto_Rescale = Z_Auto_Rescale; label_ptr->Y_Label = strdup(Y_Label); label_ptr->Y_Min = Y_Min; label_ptr->Y_Max = Y_Max; label_ptr->Y_Scale = Y_Scale; label_ptr->Y_Auto_Rescale = Y_Auto_Rescale; label_ptr->X_Label = strdup(X_Label); label_ptr->X_Min = X_Min; label_ptr->X_Max = X_Max; label_ptr->X_Scale = X_Scale; label_ptr->X_Auto_Rescale = X_Auto_Rescale; if (!strcmp(PlotType, "linlinlin")) plottype = LIN_LIN_LIN; else if (!strcmp(PlotType, "linlinlog")) plottype = LIN_LIN_LOG; else if (!strcmp(PlotType, "linloglin")) plottype = LIN_LOG_LIN; else if (!strcmp(PlotType, "linloglog")) plottype = LIN_LOG_LOG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -