← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] - fix bug #968345.

 

Alexander,

This looks promising.

My only concern is the name of the automatic variable

   aLogicalPaperSize.


We normally only use the 'a' prefix for use by 'a'rguments to a function, not local
automatic variables.

Also, it is not evident what "logical" brings to the understanding.

I suggest

 psPaperSize

instead of aLogicalPaperSize.   psPaperSize starts with a *lower case* letter, does not
start with 'a', and indicates that is something special for postscript.

If you can think of something this good or better, please re-submit the patch and I will
commit it.

Thanks,

Dick



> This bug is not evident for the first glance because most PS viewers fix this issue and print well.
> But when using raw printing (for linux - 'lpr some_file.ps') the bug gets out.
>
> Alexander.
> common_plot_ps.diff
>
>
> === modified file 'common/common_plotPS_functions.cpp'
> --- common/common_plotPS_functions.cpp	2012-03-26 21:45:05 +0000
> +++ common/common_plotPS_functions.cpp	2012-04-07 05:43:09 +0000
> @@ -375,9 +375,14 @@
>      // The coordinates of the lower left corner of the boundary
>      // box need to be "rounded down", but the coordinates of its
>      // upper right corner need to be "rounded up" instead.
> +    wxSize  aLogicalPaperSize = paper_size;
> +
> +    if( !pageInfo.IsPortrait() )
> +        aLogicalPaperSize.Set( paper_size.y, paper_size.x );
> +
>      fprintf( output_file, "%%%%BoundingBox: 0 0 %d %d\n",
> -            (int) ceil( paper_size.y * CONV_SCALE ),
> -            (int) ceil( paper_size.x * CONV_SCALE ) );
> +            (int) ceil( aLogicalPaperSize.x * CONV_SCALE ),
> +            (int) ceil( aLogicalPaperSize.y * CONV_SCALE ) );
>  
>      // Specify the size of the sheet and the name associated with that size.
>      // (If the "User size" option has been selected for the sheet size,
> @@ -393,20 +398,26 @@
>      // the order in which they are specified is not wrong!)
>      // Also note pageSize is given in mils, not in internal units and must be
>      // converted to internal units.
> -    wxSize pageSize = pageInfo.GetSizeMils();
> +    wxSize aLogicalPageSize = pageInfo.GetSizeMils();
> +
> +    if( !pageInfo.IsPortrait() )
> +        aLogicalPageSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
>  
>      if( pageInfo.IsCustom() )
>          fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
> -                 wxRound( pageSize.y * 10 * CONV_SCALE ),
> -                 wxRound( pageSize.x * 10 * CONV_SCALE ) );
> +                 wxRound( aLogicalPageSize.x * 10 * CONV_SCALE ),
> +                 wxRound( aLogicalPageSize.y * 10 * CONV_SCALE ) );
>  
>      else  // a standard paper size
>          fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
>                   TO_UTF8( pageInfo.GetType() ),
> -                 wxRound( pageSize.y * 10 * CONV_SCALE ),
> -                 wxRound( pageSize.x * 10 * CONV_SCALE ) );
> +                 wxRound( aLogicalPageSize.x * 10 * CONV_SCALE ),
> +                 wxRound( aLogicalPageSize.y * 10 * CONV_SCALE ) );
>  
> -    fprintf( output_file, "%%%%Orientation: Landscape\n" );
> +    if( pageInfo.IsPortrait() )
> +        fprintf( output_file, "%%%%Orientation: Portrait\n" );
> +    else
> +        fprintf( output_file, "%%%%Orientation: Landscape\n" );
>  
>      fprintf( output_file, "%%%%EndComments\n" );
>  
> @@ -426,7 +437,8 @@
>      // (If support for creating postscript files with a portrait orientation
>      // is ever provided, determine whether it would be necessary to provide
>      // an "else" command and then an appropriate "sprintf" command here.)
> -    fprintf( output_file, "%d 0 translate 90 rotate\n", paper_size.y );
> +    if( !pageInfo.IsPortrait() )
> +        fprintf( output_file, "%d 0 translate 90 rotate\n", paper_size.y );
>  
>      // Apply the scale adjustments
>      if( plot_scale_adjX != 1.0 || plot_scale_adjY != 1.0 )
>



Follow ups

References