📄 xgprint.c
字号:
fprintf(fp, "%d %d moveto\n", x2 + 5, (int) (c2 * theString[6].y + d2 + 5)); fprintf(fp, "(%s) show\n", theString[6].buffer); fprintf(fp, "%d %d moveto\n", x2 + 5, (int) (c2 * theString[7].y + d2)); fprintf(fp, "(%s) prtstrfromlftup\n", theString[7].buffer); } /***********************************************/ /* Used for scaling the arrays before rotating */ if (Is_X_Log(theWindow)) { a1 = 1.0 / log10(max(label_Ptr->X_Max/(label_Ptr->X_Min+DBL_MIN),DBL_MIN)); b1 = log10(max(label_Ptr->X_Min / (label_Ptr->X_Scale+DBL_MIN),DBL_MIN)) / log10(max(label_Ptr->X_Max / (label_Ptr->X_Min+DBL_MIN),DBL_MIN)); } else { a1 = label_Ptr->X_Scale / (label_Ptr->X_Max - label_Ptr->X_Min+DBL_MIN); b1 = label_Ptr->X_Min / (label_Ptr->X_Max - label_Ptr->X_Min+DBL_MIN); } if (Is_Y_Log(theWindow)) { a2 = 1.0 / log10(max(label_Ptr->Y_Max/(label_Ptr->Y_Min+DBL_MIN),DBL_MIN)); b2 = log10(max(label_Ptr->Y_Min / (label_Ptr->Y_Scale+DBL_MIN),DBL_MIN)) / log10(max(label_Ptr->Y_Max / (label_Ptr->Y_Min+DBL_MIN),DBL_MIN)); } else { a2 = label_Ptr->Y_Scale / (label_Ptr->Y_Max - label_Ptr->Y_Min+DBL_MIN); b2 = label_Ptr->Y_Min / (label_Ptr->Y_Max - label_Ptr->Y_Min+DBL_MIN); } if (Is_Z_Log(theWindow)) { a3 = 1.0 / log10(max(label_Ptr->Z_Max/(label_Ptr->Z_Min+DBL_MIN),DBL_MIN)); b3 = log10(max(label_Ptr->Z_Min / (label_Ptr->Z_Scale+DBL_MIN),DBL_MIN)) / log10(max(label_Ptr->Z_Max / (label_Ptr->Z_Min+DBL_MIN),DBL_MIN)); } else { a3 = label_Ptr->Z_Scale / (label_Ptr->Z_Max - label_Ptr->Z_Min+DBL_MIN); b3 = label_Ptr->Z_Min / (label_Ptr->Z_Max - label_Ptr->Z_Min+DBL_MIN); } /********************************************/ /* do the actual 3d drawing onto the pixmap */ if (Is_Scatter(data_Ptr)) { fprintf(fp, "0 setgray\n"); fprintf(fp, "/Times-Bold findfont 6 scalefont setfont\n"); fprintf(fp, "newpath\n"); for (i = 0; i < n; i++) { if (Is_X_Log(theWindow)) xtemp = a1 * log10(max(ScatterX(data_Ptr,i),DBL_MIN)) - b1; else xtemp = a1 * ScatterX(data_Ptr,i) - b1; if (Is_Y_Log(theWindow)) ytemp = a2 * log10(max(ScatterY(data_Ptr,i),DBL_MIN)) - b2; else ytemp = a2 * ScatterY(data_Ptr,i) - b2; if (Is_Z_Log(theWindow)) ztemp = a3 * log10(max(ScatterZ(data_Ptr,i),DBL_MIN)) - b3; else ztemp = a3 * ScatterZ(data_Ptr,i) - b3; if (0.0 < xtemp && xtemp < 1.0 && 0.0 < ytemp && ytemp < 1.0 && 0.0 < ztemp && ztemp < 1.0) fprintf(fp, "%g %g moveto sp0\n", c1 * (u1 * xtemp + u2 * ytemp + u3 * ztemp) + d1, c2 * (v1 * xtemp + v2 * ytemp + v3 * ztemp) + d2); } fprintf(fp, "stroke\n\n"); } else { theMeshPoint = (MeshType **) malloc(m * sizeof(MeshType *)); for (i = 0; i < m; i++) { theMeshPoint[i] = (MeshType *) malloc(n * sizeof(MeshType)); if (Is_Irr_Surf(data_Ptr)) { for (j = 0; j < n; j++) { if (Is_X_Log(theWindow)) xtemp = a1 * log10(fabs(IrregularX(data_Ptr,i,j))+DBL_MIN) - b1; else xtemp = a1 * IrregularX(data_Ptr,i,j) - b1; if (Is_Y_Log(theWindow)) ytemp = a2 * log10(fabs(IrregularY(data_Ptr,i,j))+DBL_MIN) - b2; else ytemp = a2 * IrregularY(data_Ptr,i,j) - b2; if (Is_Z_Log(theWindow)) ztemp = a3 * log10(fabs(IrregularZ(data_Ptr,i,j))+DBL_MIN) - b3; else ztemp = a3 * IrregularZ(data_Ptr,i,j) - b3; if (ztemp > 1.0) ztemp = 1.0; else if (ztemp < 0.0) ztemp = 0.0; theMeshPoint[i][j].x = u1 * xtemp + u2 * ytemp + u3 * ztemp; theMeshPoint[i][j].y = v1 * xtemp + v2 * ytemp + v3 * ztemp; } } else { for (j = 0; j < n; j++) { if (Is_X_Log(theWindow)) xtemp = a1 * log10(max(SurfaceX(data_Ptr,i),DBL_MIN)) - b1; else xtemp = a1 * SurfaceX(data_Ptr,i) - b1; if (Is_Y_Log(theWindow)) ytemp = a2 * log10(max(SurfaceY(data_Ptr,j),DBL_MIN)) - b2; else ytemp = a2 * SurfaceY(data_Ptr,j) - b2; if (Is_Z_Log(theWindow)) ztemp = a3 * log10(max(SurfaceZ(data_Ptr,i,j),DBL_MIN)) - b3; else ztemp = a3 * SurfaceZ(data_Ptr,i,j) - b3; if (ztemp > 1.0) ztemp = 1.0; else if (ztemp < 0.0) ztemp = 0.0; theMeshPoint[i][j].x = u1 * xtemp + u2 * ytemp + u3 * ztemp; theMeshPoint[i][j].y = v1 * xtemp + v2 * ytemp + v3 * ztemp; } } } /*********************************/ switch (phi_flag) { case FIRST_QUAD: xstart = mstart; xend = mend - 1; xstep = 1; ystart = nstart; yend = nend - 1; ystep = 1; break; case SECOND_QUAD: xstart = mend - 2; xend = mstart - 1; xstep = -1; ystart = nstart; yend = nend - 1; ystep = 1; break; case THIRD_QUAD: xstart = mend - 2; xend = mstart - 1; xstep = -1; ystart = nend - 2; yend = nstart - 1; ystep = -1; break; case FOURTH_QUAD: xstart = mstart; xend = mend - 1; xstep = 1; ystart = nend - 2; yend = nstart - 1; ystep = -1; break; } if ((!Is_Shading_On(theWindow) && Is_Grid_On(theWindow)) || (Is_Shading_On(theWindow) && Is_ColorCode_On(theWindow)) || (Is_Shading_On(theWindow) && Is_Grid_On(theWindow) && !Is_ColorCode_On(theWindow))) { fprintf(fp, "\n.4 setlinewidth\n"); for (i = xstart; i != xend; i += xstep) for (j = ystart; j != yend; j += ystep) { if (Is_ColorCode_On(theWindow)) { if (Is_Z_Log(theWindow)) colornumber = MAXTHREEDCOLORS * (.25 * a3 * log10(fabs(SurfaceZ(data_Ptr,i,j) * SurfaceZ(data_Ptr,i + 1,j) * SurfaceZ(data_Ptr,i + 1,j + 1) * SurfaceZ(data_Ptr,i,j + 1)) + DBL_MIN) - b3); else colornumber = MAXTHREEDCOLORS * (.25 * a3 * (SurfaceZ(data_Ptr,i,j) + SurfaceZ(data_Ptr,i+1,j)+ SurfaceZ(data_Ptr,i + 1,j + 1) + SurfaceZ(data_Ptr,i,j + 1)) - b3); if (colornumber >= MAXTHREEDCOLORS) colornumber = MAXTHREEDCOLORS - 1; else if (colornumber < 0) colornumber = 0; fprintf(fp, "%s setrgbcolor\n", ThreeDPSColor[colornumber]); } fprintf(fp, "%d %d %d %d %d %d %d %d", (int) (c1 * theMeshPoint[i][j].x + d1), (int) (c2 * theMeshPoint[i][j].y + d2), (int) (c1 * theMeshPoint[i + 1][j].x + d1), (int) (c2 * theMeshPoint[i + 1][j].y + d2), (int) (c1 * theMeshPoint[i + 1][j + 1].x + d1), (int) (c2 * theMeshPoint[i + 1][j + 1].y + d2), (int) (c1 * theMeshPoint[i][j + 1].x + d1), (int) (c2 * theMeshPoint[i][j + 1].y + d2)); if (Is_Grid_On(theWindow) && !Is_ColorCode_On(theWindow)) fprintf(fp, " bbwfpoly\n"); else if (!Is_Shading_On(theWindow) && Is_ColorCode_On(theWindow) && Is_Grid_On(theWindow)) fprintf(fp, " cbwfpoly\n"); else if (Is_Shading_On(theWindow) && Is_ColorCode_On(theWindow) && !Is_Grid_On(theWindow)) fprintf(fp, " nbcfpoly\n"); else if (Is_Shading_On(theWindow) && Is_ColorCode_On(theWindow) && Is_Grid_On(theWindow)) fprintf(fp, " bbcfpoly\n"); } } /*********************************************************/ /* Free up the memory for the memory for the mesh points */ for (i = 0; i < m; i++) free(theMeshPoint[i]); free(theMeshPoint); } /***********************/ /* Draw the front walls */ fprintf(fp, "\n1 setlinewidth\n"); fprintf(fp, "0 setgray\n"); if (theta_flag != ABOVE) { switch (phi_flag) { case FIRST_QUAD: if (theta_flag == UPPER) PaintWall(theBox, c1, d1, c2, d2, 5, FRONT, fp); else PaintWall(theBox, c1, d1, c2, d2, 0, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 2, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 3, FRONT, fp); break; case SECOND_QUAD: if (theta_flag == UPPER) PaintWall(theBox, c1, d1, c2, d2, 5, FRONT, fp); else PaintWall(theBox, c1, d1, c2, d2, 0, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 3, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 4, FRONT, fp); break; case THIRD_QUAD: if (theta_flag == UPPER) PaintWall(theBox, c1, d1, c2, d2, 5, FRONT, fp); else PaintWall(theBox, c1, d1, c2, d2, 0, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 1, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 4, FRONT, fp); break; case FOURTH_QUAD: if (theta_flag == UPPER) PaintWall(theBox, c1, d1, c2, d2, 5, FRONT, fp); else PaintWall(theBox, c1, d1, c2, d2, 0, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 1, FRONT, fp); PaintWall(theBox, c1, d1, c2, d2, 2, FRONT, fp); break; } } /*********************************************************/ /* fprintf(fp, "\ngrestore\n"); no matching gsave! */ fprintf(fp, "\nshowpage\n"); if (fclose(fp)) printf("PostScriptOpenWindow(): File was not closed properly!");}/****************************************************************//****************************************************************/void Ascii_TwoD_Window(WindowType theWindow, char *filename, char type){ FILE *fp; DataType theData = theWindow->data; LabelType theLabel= theWindow->label; int i,n; double xscale, yscale; double xoffset, yoffset; xscale = theLabel->X_Scale; yscale = theLabel->Y_Scale; xoffset = theLabel->X_Offset; yoffset = theLabel->Y_Offset; if (type == 'a') { fp = fopen(filename,"a"); } else { fp = fopen(filename,"w"); } if(fp == NULL) { printf("Ascii_TwoD_Window couldn't create file\n"); return; } while(theData) { n = *(theData->npoints); fprintf(fp,"\n##### time= %g \n", *theTimeStep); for(i=0;i<n;i++) fprintf(fp,"%.6G\t\t%.6G\n", xscale*CurveX(theData,i)+xoffset, yscale*CurveY(theData,i)+yoffset); theData = theData->next; } fclose(fp);}/****************************************************************/void Ascii_ThreeD_Window(WindowType theWindow, char *filename, char type){ FILE *fp; DataType theData = theWindow->data; LabelType theLabel= theWindow->label; int i,j,m,n; double xscale, yscale, zscale; xscale = theLabel->X_Scale; yscale = theLabel->Y_Scale; zscale = theLabel->Z_Scale; if (type == 'a') { fp = fopen(filename,"a"); } else { fp = fopen(filename,"w"); } if(fp == NULL) { printf("Ascii_ThreeD_Window couldn't create file\n"); return; } fprintf(fp,"\n##### time= %g \n", *theTimeStep); n = *(theData->npoints); if (Is_Scatter(theData)) { for(i=0;i<n;i++) { fprintf(fp,"%.6G\t\t%.6G\t\t%.6G\n", xscale*(ScatterX(theData,i)), yscale*(ScatterY(theData,i)), zscale*(ScatterZ(theData,i))); } } else { m = *(theData->mpoints); if (Is_Irr_Surf(theData)) { for (i=0;i<m;i++) { for (j=0;j<n;j++) { fprintf(fp,"%.6G\t\t%.6G\t\t%.6G\n", xscale*(IrregularX(theData,i,j)), yscale*(IrregularY(theData,i,j)), zscale*(IrregularZ(theData,i,j))); } } } else { for (i=0;i<m;i++) { for (j=0;j<n;j++) { fprintf(fp,"%.6G\t\t%.6G\t\t%.6G\n", xscale*(SurfaceX(theData,i)), yscale*(SurfaceY(theData,j)), zscale*(SurfaceZ(theData,i,j))); } } } } fclose(fp);}/****************************************************************/void Ascii_Vector_Window(WindowType theWindow, char *filename, char type){ FILE *fp; DataType theData = theWindow->data; int i,j,m,n; if (type == 'a') { fp = fopen(filename,"a"); } else { fp = fopen(filename,"w"); } if(fp == NULL) { printf("Ascii_Vector_Window couldn't create file\n"); return; } fprintf(fp,"\n####################\n"); m = *(theData->mpoints); n = *(theData->npoints); for (i=0;i<m;i++) { for (j=0;j<n;j++) { fprintf(fp,"%.6G\t%.6G\t%.6G\t%.6G\n",VectorX(theData,i), VectorY(theData,j),VectorW(theData,i,j), VectorZ(theData,i,j)); } } fclose(fp);}void Bin_TwoD_Window(WindowType theWindow, char *filename, char type) { BXG_Write_2D(theWindow->data,theWindow->label,theWindow->structures, filename, type, theTimeStep);}void Bin_ThreeD_Window(WindowType theWindow, char *filename, char type) { BXG_Write_3D(theWindow->data,theWindow->label,filename,type, theTimeStep);}void Bin_Vector_Window(WindowType theWindow, char *filename, char type) { BXG_Write_Vector(theWindow->data,theWindow->label,theWindow->structures,filename,type,theTimeStep);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -