⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpe_graphics.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 3 页
字号:
  handle->capture_cnt  = 0;  return MPE_SUCCESS;}/*@    MPE_Draw_point - Draws a point on an X Windows display     Input Parameters:+   handle - MPE graphics handle .   x,y - pixel position to draw.  Coordinates are upper-left origin (standard    X11)-   color - Color `index` value.  See 'MPE_MakeColorArray'.      By default, the colors    'MPE_WHITE', 'MPE_BLACK', 'MPE_RED', 'MPE_YELLOW', 'MPE_GREEN', 'MPE_CYAN',    'MPE_BLUE',  'MPE_MAGENTA', 'MPE_AQUAMARINE',             'MPE_FORESTGREEN', 'MPE_ORANGE', 'MPE_VIOLET', 'MPE_BROWN',             'MPE_PINK', 'MPE_CORAL' and 'MPE_GRAY' are defined..N XGRAPHICS_FORTRAN@*/int MPE_Draw_point( handle, x, y, color )MPE_XGraph handle;int        x, y;MPE_Color  color;{  if (handle->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }#ifndef MPE_NOMPI  if (handle->is_collective) {  } else#endif  {    XBSetPixVal( handle->xwin, handle->xwin->cmapping[color] );    XDrawPoint( handle->xwin->disp, handle->xwin->win, 	       handle->xwin->gc.set, x, y );  }  return MPE_SUCCESS;}/*@    MPE_Draw_points - Draws points on an X Windows display     Input Parameters:+   handle - MPE graphics handle .   points - list of points to draw-   npoints - number of points to draw.N XGRAPHICS_FORTRAN@*/int MPE_Draw_points( handle, points, npoints )MPE_XGraph handle;MPE_Point *points;int npoints;{  XPoint *sortedPoints;  int *colorRanges, ncolors, colorNum, n;  MPE_Color *colorList;  if (handle->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }#if 0  /* temporary debug */  {int i;  fprintf( stderr, "MPE_Draw_points\n" );  for (i=0; i<npoints; i++) {    fprintf( stderr, "%d. (%d %d) %d\n", i, points[i].x, points[i].y,	     points[i].c );  }}#endif      SortPoints( points, npoints, &sortedPoints, &colorList, &colorRanges,	      &ncolors );#if 0  /* another temporary debug */  fprintf( stderr, "Sorted points.  %d colors\n", ncolors );  for (i=0; i<ncolors; i++) {    fprintf( stderr, "%d %d's.\n", colorRanges[i], colorList[i] );  }#endif  for (colorNum = 0; colorNum < ncolors; colorNum++) {    n = (colorNum < ncolors-1)      ? colorRanges[colorNum+1] - colorRanges[colorNum]      : npoints - colorRanges[colorNum];/*    printf( "xxx: %d %d %d %d\n", (colorNum < ncolors-1),	   colorRanges[colorNum+1] - colorRanges[colorNum],	   ncolors - colorNum,	   (colorNum < ncolors-1)      ? colorRanges[colorNum+1] - colorRanges[colorNum]      : npoints - colorRanges[colorNum] );    printf( "Sending %d points of color %d starting at %d\n", n,	    colorList[colorNum],	    colorRanges[colorNum] );        for (i = 0; i<n; i++) {      printf( "sending (%hd %hd)\n", 	      sortedPoints[colorRanges[colorNum]+i].x,	      sortedPoints[colorRanges[colorNum]+i].y );    }*/    XBSetPixVal( handle->xwin, handle->xwin->cmapping[colorList[colorNum]] );    XDrawPoints( handle->xwin->disp, handle->xwin->win, 		 handle->xwin->gc.set,		 sortedPoints + colorRanges[colorNum],		 n, CoordModeOrigin );  }  free( sortedPoints );  free( colorList );  free( colorRanges );  return MPE_SUCCESS;}static void SortPoints( lista, a, listb, colorList, boundaryPoints, ncolors )MPE_Point *lista;XPoint **listb;MPE_Color **colorList;int a, **boundaryPoints, *ncolors;{  int top, bottom, outoforder;  MPE_Color thisColor, tempColor, *keyList;    XPoint *list, tempPt;  xpand_list_Int *boundaryList;  boundaryList = Int_CreateList( 20 );  list = *listb = (XPoint *) malloc( sizeof( XPoint ) * a );  keyList = (MPE_Color *) malloc( sizeof( MPE_Color ) * a );  for (top = 0; top < a; top++) {    list[top].x = lista[top].x;    list[top].y = lista[top].y;    keyList[top] = lista[top].c;/*    fprintf( stderr, "unsorted %d = %d %d %d\n", top, lista[top].x,	     lista[top].y,	     lista[top].c );*/  }  /* copy the list over */  top = 0;  outoforder = 1;  while (top < a && outoforder) {    Int_AddItem( boundaryList, top );    /* keep a list of the start of each different color */    /* temp. debugging */    /* fprintf( */    thisColor = keyList[top];    bottom = a-1;    outoforder = 0;    while (top < bottom) {      if (keyList[top] != thisColor) {	outoforder = 1;	while (bottom>top && keyList[bottom] != thisColor) bottom--;	if (bottom>top) {	  tempPt = list[bottom];	  list[bottom] = list[top];	  list[top] = tempPt;	  tempColor = keyList[bottom];	  keyList[bottom] = keyList[top];	  keyList[top] = tempColor;	  top++;	}      } else {	top++;      }    }  }  ListClose( boundaryList, *boundaryPoints, *ncolors );  *colorList = (MPE_Color *) malloc( sizeof( MPE_Color ) * *ncolors );  for (top=0; top < *ncolors; top++) {    (*colorList)[top] = keyList[(*boundaryPoints)[top]];/*    printf( "color %d = %d\n", top, (*colorList)[top] );*/  }/*  bottom = 0;  for (top = 0; top < a; top++) {    if ((*boundaryPoints)[bottom] == top) {      fprintf( stderr, "color = %d\n", (*colorList)[bottom] );      bottom++;    }    fprintf( stderr, "sorted %d = %hu %hu\n", top, list[top].x, list[top].y );  }*/  free( keyList );}/*@    MPE_Draw_line - Draws a line on an X11 display    Input Parameters:+   handle - MPE graphics handle .   x1,y_1 - pixel position of one end of the line to draw.  Coordinates are             upper-left origin (standard X11).   x2,y_2 - pixel position of the other end of the line to draw.  Coordinates             are upper-left origin (standard X11)-   color - Color `index` value.  See 'MPE_MakeColorArray'.      By default, the colors    'MPE_WHITE', 'MPE_BLACK', 'MPE_RED', 'MPE_YELLOW', 'MPE_GREEN', 'MPE_CYAN',    'MPE_BLUE',  'MPE_MAGENTA', 'MPE_AQUAMARINE',             'MPE_FORESTGREEN', 'MPE_ORANGE', 'MPE_VIOLET', 'MPE_BROWN',             'MPE_PINK', 'MPE_CORAL' and 'MPE_GRAY' are defined..N XGRAPHICS_FORTRAN@*/int MPE_Draw_line( handle, x1, y_1, x2, y_2, color )MPE_XGraph handle;int        x1, y_1, x2, y_2;MPE_Color  color;{  if (handle->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }#ifndef MPE_NOMPI  if (handle->is_collective) {  } else#endif  {    XBSetPixVal( handle->xwin, handle->xwin->cmapping[color] );    XDrawLine( handle->xwin->disp, handle->xwin->win, 	      handle->xwin->gc.set, x1, y_1, x2, y_2 );  }  return MPE_SUCCESS;}/*@    MPE_Fill_rectangle - Draws a filled rectangle on an X11 display     Input Parameters:+   handle - MPE graphics handle .   x,y - pixel position of the upper left (low coordinate) corner of the             rectangle to draw..   w,h - width and height of the rectangle-   color - Color `index` value.  See 'MPE_MakeColorArray'.      By default, the colors    'MPE_WHITE', 'MPE_BLACK', 'MPE_RED', 'MPE_YELLOW', 'MPE_GREEN', 'MPE_CYAN',    'MPE_BLUE',  'MPE_MAGENTA', 'MPE_AQUAMARINE',             'MPE_FORESTGREEN', 'MPE_ORANGE', 'MPE_VIOLET', 'MPE_BROWN',             'MPE_PINK', 'MPE_CORAL' and 'MPE_GRAY' are defined.    Notes:    This uses the X11 definition of width and height, so you may want to     add 1 to both of them..N XGRAPHICS_FORTRAN@*/int MPE_Fill_rectangle( handle, x, y, w, h, color )MPE_XGraph handle;int        x, y, w, h;MPE_Color  color;{  if (handle->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }#ifndef MPE_NOMPI  if (handle->is_collective) {  } else#endif  {    XBSetPixVal( handle->xwin, handle->xwin->cmapping[color] );    XFillRectangle( handle->xwin->disp, handle->xwin->win, 		   handle->xwin->gc.set, x, y, w, h );  }  return MPE_SUCCESS;}/*@    MPE_Update - Updates an X11 display    Input Parameter:.   handle - MPE graphics handle.    Note:    Only after an 'MPE_Update' can you count on seeing the results of MPE     drawing routines.  This is caused by the buffering of graphics requests    for improved performance..N XGRAPHICS_FORTRAN@*/int MPE_Update( handle )MPE_XGraph handle;{  if (handle->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }#ifndef MPE_NOMPI  if (handle->is_collective) {  } else#endif  {    XFlush( handle->xwin->disp );  }  if (handle->capture_file) {#ifdef HAVE_SYSTEM      /* Place into a file */      char cmdbuf[1024];      if ((handle->capture_num % handle->capture_freq) == 0) {	  /* This will need to be configured for the location of xwd ... */	  sprintf( cmdbuf, "%sxwd -display %s -id %ld > %s%.3d.xwd\n", 		   "/usr/local/X11R5/bin/", 		   handle->display_name, 		   (long) handle->xwin->win, handle->capture_file, 		   handle->capture_cnt++ );	  system( cmdbuf );	  }      handle->capture_num++;#else      fprintf( stderr, "Could not call system routine for file capture\n" );#endif      }  return MPE_SUCCESS;}/*    MPE_Create_contour -  *//*    MPE_Draw_contour -  *//*@    MPE_Close_graphics - Closes an X11 graphics device    Input Parameter:.   handle - MPE graphics handle.    Return Values:+   MPE_ERR_BAD_ARGS - 'handle' parameter is bad-   MPE_SUCCESS - success.N XGRAPHICS_FORTRAN@*/int MPE_Close_graphics( handle )MPE_XGraph *handle;{  if (!handle || !*handle || (*handle)->Cookie != MPE_G_COOKIE) {    fprintf( stderr, "Handle argument is incorrect or corrupted\n" );    return MPE_ERR_BAD_ARGS;  }  XBWinDestroy( (*handle)->xwin );  FREE( *handle );  *handle = 0;  return MPE_SUCCESS;}/*@    MPE_Make_color_array - Makes an array of color indices    Input Parameters:+   handle - MPE graphics handle.   nc     - Number of colors    Output Parameter:-   array - Array of color indices    Notes:    The new colors for a uniform distribution in hue space and replace the    existing colors `except` for 'MPE_WHITE' and 'MPE_BLACK'..N XGRAPHICS_FORTRAN

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -