Esempio n. 1
0
void print_hitlist(struct hitlist *hl, FILE *fp)
{
  struct hit_entry *he;
  int lab;

  for (he = hl->head; he; he = he->next)
    {
      lab = he->label;
      fprintf(fp, "%s,%ld", 
	      (lab != LABEL_EMPTY) ? find_conv_to_lab(lab) : "EMPTY",
	      he->freq);
      if (he->next)
	fputs(", ", fp);
    }
  fputs("\n", fp);
}
Esempio n. 2
0
int print_eps(FILE *fp, struct eps_info *einfo)
{
  float color;
  float xstep, ystep, radius;
  int x, y, numlabs, i;
  char *label;
  eptr p;
  char *select_topol_s, *draw_block_s, *start_row_s, *end_row_s;
  struct data_entry *dtmp;
  struct umatrix *umat = einfo->umat;

  end_row_s = "NL";

  switch (umat->topol) 
    {
    case TOPOL_HEXA:
      select_topol_s = "topol_hexa";
      draw_block_s = "H";
      start_row_s = "XSH";
      break;
    case TOPOL_RECT:
      select_topol_s = "topol_rect";
      draw_block_s = "R";
      start_row_s = "XSR";
      break;
    default:
      fprintf(stderr, "can't print topology %d\n", umat->topol);
      return 0;
      break;
    }

  /*  radius = eps_width / (2.0 * sqrt(3) * (float)umat->mxdim); */
  xstep = einfo->xstep;
  ystep = einfo->ystep;
  radius = einfo->radius;

  /* print eps headers */
  fprintf(fp, "%%!PS-Adobe-3.0 EPSF-3.0\n");
  fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", 
	  (int)ceil(einfo->width), (int)ceil(einfo->height));
  
  fprintf(fp, "%%%%Title: %s\n%%%%Creator: umat V1.0\n", 
	  ps_string_filter(einfo->title));
  
  fprintf(fp, "%%%%CreationDate: %s", ps_string_filter(get_date()));
  fprintf(fp, "%%%%Pages: 0\n");
  fprintf(fp, "%%%%DocumentFonts: %s\n%%%%DocumentNeededFonts: %s\n",
	  fontname, fontname);
  fprintf(fp, "%%%%EndComments\n");
  
  /* COPY HEADER */
  if (print_header(fp, headerfile))
    return 1; /* error */

  fprintf(fp, "/radius %f def\n/xstep %f def\n/ystep %f def\n",
	  radius, xstep, ystep);

  /* font selection */
  fprintf(fp, "%%%%IncludeFont: %s\n", fontname);
  fprintf(fp, "/fontname /%s def\n", fontname);
  if (fontsize > 0.0) 
    fprintf(fp, "/fontsize %f def\n", fontsize);
  fprintf(fp, "selfont\n");
  
  fprintf(fp, "/doborder %s def\n", doborder ? "true" : "false");
  /* print umat */

  fprintf(fp, "/wt %f def /bt %f def\n", white_treshold, black_treshold);

  fprintf(fp, "/y 0 def\n/xoff %f def\n/yoff %f def\n", 
	  einfo->x0, (einfo->height - einfo->y0));

  if (drawblocks)
    for (y = 0; y < umat->uydim; y++)
      {
	fprintf(fp, "%s ", start_row_s);
	for (x = 0; x < umat->uxdim; x++)
	  fprintf(fp, "%d %s ", (int)(100 * umat->uvalue[x][y]), draw_block_s);
	fprintf(fp, "%s\n", end_row_s);
      }
  
  /* print labels */

  fprintf(fp, "/y 0 def\n/xoff %f def\n/yoff %f def\n", 
	  einfo->x0, (einfo->height - einfo->y0));

  if (drawlabels)
    {
      dtmp = rewind_entries(umat->codes, &p);
      
	/*---------------------------------------------------------------------------
	* Modificado para reportar los datos de la umatrix en formato legible
	* para Nams ( Nucleic Acid Modeling System ). El formato tiene la siguiente
	* forma:
	*         --------------------------------------------
	*       |  <type>   |  <i>   |  <j>    |    <value>   |
	*        --------------------------------------------
	* Siendo type = { Hexagon o Label }, i, j, las cooredenadas sobre el mapa
	* y value y string para el caso de type = Label y un double para el caso
	* de type = Hexagon
	* 
	* Author :
	*     Nestor Aguirre 
	*     Univerisdad Nacional de Colombia
	*     Grupo de Química Teórica
	*     Nov. de 2005
	*/
	
	FILE* tmp ;
	tmp = fopen( "tmp/umatrixdata.dat", "w" ) ;
	
	/*-------------------------------------------------
	* Se imprimen los hexagonos
	*/
	int i = 0 ;
	for ( i = 0; i < umat->uxdim; i++ ){
		int j = 0 ;
		for ( j = 0; j < umat->uydim; j++ ){
			fprintf( tmp, "Hexagon   %5d   %5d   %10.3f\n", i, j, umat->uvalue[i][j] );
		}
	}
	//-------------------------------------------------
	      
	for (y = 0; y < umat->mydim; y++){
		fprintf(fp, "%s ", start_row_s);
		
		for (x = 0; x < umat->mxdim; x++){
			
			numlabs = dtmp->num_labs;
			
			if (!drawblocks)
				color = 100;
			else
				color = (umat->uvalue[2 * x][2 * y] * 100);
			
			if (numlabs){
				if (numlabs == 1){
					/* one label */
					label = find_conv_to_lab(get_entry_label(dtmp));
					fprintf(fp, "(%s) %d LAB ", ps_string_filter(label), (int)color);
					
					/*-----------------------------------------------------------
					* Se imprime el label
					*/
					fprintf( tmp, "Label     %5d   %5d   %s\n", x, y, label );
					//-----------------------------------------------------------
				}
				else{
					/* multiple labels */
					for (i = 0; i < numlabs; i++){
						label = find_conv_to_lab(get_entry_labels(dtmp, i));
						
						if (label == LABEL_EMPTY) {
							numlabs = i;
							break;
						}
						
						fprintf(fp, "(%s) ", ps_string_filter(label));
					}
					
					fprintf(fp, "%d %d ML ", numlabs, (int)color);
					
					/*-------------------------------------------------------------
					* Se imprime el label:
					*
					* Hay que reformarlo ya que solo se reporta el ultimo
					* valor de los posibles labels en caso que haya muchos
					*/
					fprintf( tmp, "Label     %5d   %5d   %s\n", x, y, label );
					//-----------------------------------------------------------
				}
			}else{
				fprintf(fp, "%d LN ", (int)color);
			}
			
			dtmp = next_entry(&p);
		}
		
		/* do newline twice because labels are printed on every other row */
		fprintf(fp, "%s %s\n", end_row_s, end_row_s);
	}
	
	fclose(tmp) ;
	//---------------------------------------------------------------------------
	
    }
	
  fprintf(fp, "end\n");
  fprintf(fp, "%% end of EPS object\n");

  return 0;
}
Esempio n. 3
0
int print_eps(FILE *fp, struct eps_info *einfo)
{
  float color;
  float xstep, ystep, radius;
  int x, y, numlabs, i;
  char *label;
  eptr p;
  char *select_topol_s, *draw_block_s, *start_row_s, *end_row_s;
  struct data_entry *dtmp;
  struct umatrix *umat = einfo->umat;

  end_row_s = "NL";

  switch (umat->topol) 
    {
    case TOPOL_HEXA:
      select_topol_s = "topol_hexa";
      draw_block_s = "H";
      start_row_s = "XSH";
      break;
    case TOPOL_RECT:
      select_topol_s = "topol_rect";
      draw_block_s = "R";
      start_row_s = "XSR";
      break;
    default:
      fprintf(stderr, "can't print topology %d\n", umat->topol);
      return 0;
      break;
    }

  /*  radius = eps_width / (2.0 * sqrt(3) * (float)umat->mxdim); */
  xstep = einfo->xstep;
  ystep = einfo->ystep;
  radius = einfo->radius;

  /* print eps headers */
  fprintf(fp, "%%!PS-Adobe-3.0 EPSF-3.0\n");
  fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", 
	  (int)ceil(einfo->width), (int)ceil(einfo->height));
  
  fprintf(fp, "%%%%Title: %s\n%%%%Creator: umat V1.0\n", 
	  ps_string_filter(einfo->title));
  
  fprintf(fp, "%%%%CreationDate: %s", ps_string_filter(get_date()));
  fprintf(fp, "%%%%Pages: 0\n");
  fprintf(fp, "%%%%DocumentFonts: %s\n%%%%DocumentNeededFonts: %s\n",
	  fontname, fontname);
  fprintf(fp, "%%%%EndComments\n");
  
  /* COPY HEADER */
  if (print_header(fp, headerfile))
    return 1; /* error */

  fprintf(fp, "/radius %f def\n/xstep %f def\n/ystep %f def\n",
	  radius, xstep, ystep);

  /* font selection */
  fprintf(fp, "%%%%IncludeFont: %s\n", fontname);
  fprintf(fp, "/fontname /%s def\n", fontname);
  if (fontsize > 0.0) 
    fprintf(fp, "/fontsize %f def\n", fontsize);
  fprintf(fp, "selfont\n");
  
  fprintf(fp, "/doborder %s def\n", doborder ? "true" : "false");
  /* print umat */

  fprintf(fp, "/wt %f def /bt %f def\n", white_treshold, black_treshold);

  fprintf(fp, "/y 0 def\n/xoff %f def\n/yoff %f def\n", 
	  einfo->x0, (einfo->height - einfo->y0));

  if (drawblocks)
    for (y = 0; y < umat->uydim; y++)
      {
	fprintf(fp, "%s ", start_row_s);
	for (x = 0; x < umat->uxdim; x++)
	  fprintf(fp, "%d %s ", (int)(100 * umat->uvalue[x][y]), draw_block_s);
	fprintf(fp, "%s\n", end_row_s);
      }
  
  /* print labels */

  fprintf(fp, "/y 0 def\n/xoff %f def\n/yoff %f def\n", 
	  einfo->x0, (einfo->height - einfo->y0));

  if (drawlabels)
    {
      dtmp = rewind_entries(umat->codes, &p);
      
      for (y = 0; y < umat->mydim; y++)
	{
	  fprintf(fp, "%s ", start_row_s);
	  for (x = 0; x < umat->mxdim; x++)
	    {
	      numlabs = dtmp->num_labs;
	      if (!drawblocks)
		color = 100;
	      else
		color = (umat->uvalue[2 * x][2 * y] * 100);
	      
	      if (numlabs)
		{
		  if (numlabs == 1)
		    {
		      /* one label */
		      label = find_conv_to_lab(get_entry_label(dtmp));
		      fprintf(fp, "(%s) %d LAB ", 
			      ps_string_filter(label), (int)color);
		    }
		  else
		    {
		      /* multiple labels */
		      for (i = 0; i < numlabs; i++)
			{
			  label = find_conv_to_lab(get_entry_labels(dtmp, i));
			  
			  if (label == LABEL_EMPTY) 
			    {
			      numlabs = i;
			      break;
			    }
			  
			  fprintf(fp, "(%s) ", ps_string_filter(label));
			}
		      
		      fprintf(fp, "%d %d ML ", numlabs, (int)color);
		    }
		}
	      else
		fprintf(fp, "%d LN ", (int)color);
	      dtmp = next_entry(&p);
	    }
	  /* do newline twice because labels are printed on every other row */
	  fprintf(fp, "%s %s\n", end_row_s, end_row_s);
	}
    }
  fprintf(fp, "end\n");
  fprintf(fp, "%% end of EPS object\n");

  return 0;
}