Commit 2da432b2 authored by dickelbeck's avatar dickelbeck
Browse files

plot fix, beautification

parent 11d8f51b
Loading
Loading
Loading
Loading
+136 −128
Original line number Diff line number Diff line
@@ -30,9 +30,10 @@ void Plume_HPGL( int plume );
/***********************************************************************************/
void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient )
/***********************************************************************************/

/* Set the plot offset for the current plotting
 xscale,yscale = coordinate scale (scale coefficient for coordinates)
 device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device)
  * xscale,yscale = coordinate scale (scale coefficient for coordinates)
  * device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device)
 */
{
    PlotOffset = offset;
@@ -44,7 +45,6 @@ void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int or
}



/*****************************************************************/
bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num )
/*****************************************************************/
@@ -58,6 +58,7 @@ char Line[256];
    return TRUE;
}


/**********************************/
bool CloseFileHPGL( FILE* plot_file )
/**********************************/
@@ -78,7 +79,8 @@ char Line[256];
    UserToDeviceCoordinate( centre );
    rayon = (int) (diameter / 2 * XScale);

	if(rayon < 0 ) rayon = 0 ;
    if( rayon < 0 )
        rayon = 0;

    Plume_HPGL( 'U' );
    sprintf( Line, "PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon, CHORD_ANGLE );
@@ -91,13 +93,14 @@ char Line[256];
/********************************************************************/
void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int width )
/********************************************************************/

/* trace d'un arc de cercle:
	centre = coord du centre
	StAngle, EndAngle = angle de debut et fin
	rayon = rayon de l'arc
	commande
		PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU;
	ou	PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU;
  * centre = coord du centre
  * StAngle, EndAngle = angle de debut et fin
  * rayon = rayon de l'arc
  * commande
  *     PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU;
  * ou	PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU;
 */
{
    char    Line[256];
@@ -105,7 +108,8 @@ wxPoint cmap; /* point de depart */
    wxPoint cpos;           /* centre */
    float   angle;          /* angle de l'arc*/

	if(rayon <= 0 ) return ;
    if( rayon <= 0 )
        return;

    cpos = centre; UserToDeviceCoordinate( cpos );

@@ -135,14 +139,17 @@ float angle; /* angle de l'arc*/
/*****************************************************/
void PlotPolyHPGL( int nb, int* coord, int fill, int width )
/*****************************************************/

/* Trace un polygone (ferme si rempli) en format HPGL
	coord = tableau des coord des sommets
	nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
	fill : si != 0 polygone rempli
  * coord = tableau des coord des sommets
  * nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
  * fill : si != 0 polygone rempli
 */
{
    int ii;
	if( nb <= 1 ) return;

    if( nb <= 1 )
        return;

    Move_Plume_HPGL( wxPoint( coord[0], coord[1] ), 'U' );
    for( ii = 1; ii < nb; ii++ )
@@ -164,11 +171,12 @@ int ii;
/**********************************************/
void Move_Plume_HPGL( wxPoint pos, int plume )
/**********************************************/

/*
	deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
	en position x,y
	Unites en Unites DESSIN
	Si plume = 'Z' lever de plume sans deplacement
  * deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
  * en position x,y
  * Unites en Unites DESSIN
  * Si plume = 'Z' lever de plume sans deplacement
 */
{
    char Line[256];
@@ -188,20 +196,20 @@ char Line[256];
/***************************/
void Plume_HPGL( int plume )
/***************************/

/* leve (plume = 'U') ou baisse (plume = 'D') la plume
 */
{
    if( plume == 'U' )
    {
		if(etat_plume != 'U' ) fputs("PU;",PlotOutputFile) ;
        if( etat_plume != 'U' )
            fputs( "PU;", PlotOutputFile );
        etat_plume = 'U';
    }
    else
    {
		if(etat_plume != 'D' )fputs("PD;",PlotOutputFile) ;
        if( etat_plume != 'D' )
            fputs( "PD;", PlotOutputFile );
        etat_plume = 'D';
    }
}


+271 −244
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ void SetCurrentLineWidthPS(int width)
/* Set the Current line width (in 1/1000 inch) for the next plot
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    int pen_width;

    if( width > 0 )
@@ -88,6 +90,8 @@ void SetColorMapPS(int color)
 * color = color index in ColorRefs[]
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    char Line[1024];

    sprintf( Line, "%.3f %.3f %.3f setrgbcolor\n",
@@ -106,6 +110,8 @@ void PlotFilledSegmentPS(wxPoint start, wxPoint end, int width)
/* Plot 1 segment like a track segment
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    UserToDeviceCoordinate( start );
    UserToDeviceCoordinate( end );

@@ -118,6 +124,8 @@ void PlotFilledSegmentPS(wxPoint start, wxPoint end, int width)
void PlotCircle_PS( wxPoint pos, int diametre, int width )
/******************************************************/
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    int  rayon;
    char Line[256];

@@ -141,12 +149,15 @@ void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width)
 * StAngle, EndAngle = start and end arc in 0.1 degree
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    char Line[256];

    if( rayon <= 0 )
        return;

    SetCurrentLineWidthPS( width );

    // Calcul des coord du point de depart :
    UserToDeviceCoordinate( centre );

@@ -156,6 +167,7 @@ char Line[256];
    else
        sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y,
            (int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10 );

    // Undo internationalization printf (float x.y printed x,y)
    to_point( Line );
    fputs( Line, PlotOutputFile );
@@ -173,6 +185,8 @@ void PlotPolyPS(int nb_segm, int * coord, int fill, int width)
 * @param  width = line width
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    int     ii;
    wxPoint pos;

@@ -210,6 +224,8 @@ void LineTo_PS(wxPoint pos, int plume)
/* Routine to draw to a new position
 */
{
    D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)

    if( plume == 'Z' )
        return;

@@ -251,7 +267,8 @@ void PrintHeaderPS(FILE * file, const wxString & Creator,
{
    wxString     msg;
    char         Line[1024];
const char *PSMacro[] = {

    static const char*  PSMacro[] = {
        "/line {\n",
        "    newpath\n",
        "    moveto\n",
@@ -265,12 +282,16 @@ const char *PSMacro[] = {
        "1 setlinewidth\n",
        NULL
    };

    const double MIL_TO_INCH = 0.001;
    int          ii;
    time_t       time1970 = time( NULL );

    PlotOutputFile = file;

    D(printf( "PrintHeaderPS PlotOutputFile = %p\n", PlotOutputFile );)


    fputs( "%!PS-Adobe-3.0\n", PlotOutputFile );    // Print header

    sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8( Creator ) );
@@ -292,12 +313,14 @@ time_t time1970 = time(NULL);

    // Print boundary box en 1/72 pouce, box is in mils
    const double CONV_SCALE = MIL_TO_INCH * 72;

    // 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.
    sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n",
        (int) floor( (BBox[1] * CONV_SCALE) ), (int) floor( (BBox[0] * CONV_SCALE) ),
        (int) ceil( (BBox[3] * CONV_SCALE) ), (int) ceil( (BBox[2] * CONV_SCALE) ) );

    fputs( Line, PlotOutputFile );

    // Specify the size of the sheet and the name associated with that size.
@@ -316,6 +339,7 @@ time_t time1970 = time(NULL);
        sprintf( Line, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
            (int) round( SheetPS->m_Size.y * CONV_SCALE ),
            (int) round( SheetPS->m_Size.x * CONV_SCALE ) );

    else  // ( if SheetPS->m_Name does not equal "User" )
        sprintf( Line, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
            CONV_TO_UTF8( SheetPS->m_Name ),
@@ -327,6 +351,7 @@ time_t time1970 = time(NULL);
        sprintf( Line, "%%%%Orientation: Portrait\n" );
    else
        sprintf( Line, "%%%%Orientation: Landscape\n" );

    fputs( Line, PlotOutputFile );

    sprintf( Line, "%%%%EndComments\n" );
@@ -349,6 +374,7 @@ time_t time1970 = time(NULL);
    if( PaperOrientation == wxLANDSCAPE )
        sprintf( Line, "%f %f translate 90 rotate\n",
            (float) BBox[3] * MIL_TO_INCH, (float) BBox[0] * MIL_TO_INCH );

    // (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.)
@@ -372,6 +398,8 @@ time_t time1970 = time(NULL);
bool CloseFilePS( FILE* plot_file )
/******************************************/
{
    D(printf( "CloseFilePS\n" );)

    fputs( "showpage\n", plot_file );
    fputs( "grestore\n", plot_file );
    fputs( "%%EOF\n", plot_file );
@@ -380,4 +408,3 @@ bool CloseFilePS(FILE * plot_file)

    return TRUE;
}
+310 −295
Original line number Diff line number Diff line
@@ -29,16 +29,19 @@ static Ki_PageDescr * SheetPS;
/*************************/
void ForcePenReinit()
/*************************/

/* set the flag g_CurrentPenWidth to -1 in order to force a pen width redefinition
	for the next draw command
  * for the next draw command
 */
{
    g_CurrentPenWidth = -1;
}


/**********************************************/
void SetPlotScale( double xscale, double yscale )
/**********************************************/

/* Set the plot scale for the current plotting)
 */
{
@@ -46,20 +49,24 @@ void SetPlotScale(double xscale, double yscale)
    YScale = yscale;
}


/*********************************/
void SetPlotOffset( wxPoint offset )
/*********************************/

/* Set the plot offset for the current plotting)
 */
{
    PlotOffset = offset;
}


/***************************************************************************/
void InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale )
/***************************************************************************/

/* Set the plot offset for the current plotting
 xscale,yscale = coordinate scale (scale coefficient for coordinates)
  * xscale,yscale = coordinate scale (scale coefficient for coordinates)
 */
{
    PlotOrientOptions = 0;
@@ -75,8 +82,9 @@ void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale)
/*******************************************************/
void PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
/*******************************************************/

/* Plot sheet references
	margin is in mils (1/1000 inch)
  * margin is in mils (1/1000 inch)
 */
{
#define WSTEXTSIZE 50   // Text size in mils
@@ -87,7 +95,7 @@ wxPoint pos, ref;
    int               color;
    Ki_WorkSheetData* WsItem;
    int               conv_unit = screen->GetInternalUnits() / 1000; /* Scale to convert dimension in 1/1000 in into internal units
				(1/1000 inc for EESchema, 1/10000 for pcbnew */
                                                      * (1/1000 inc for EESchema, 1/10000 for pcbnew */
    wxString          msg;
    wxSize            text_size;
    void              (*FctPlume)( wxPoint pos, int state );
@@ -217,8 +225,11 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
    {
        pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
        pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
		if(WsItem->m_Legende) msg = WsItem->m_Legende;
		else msg.Empty();
        if( WsItem->m_Legende )
            msg = WsItem->m_Legende;
        else
            msg.Empty();

        switch( WsItem->m_Type )
        {
        case WS_DATE:
@@ -250,6 +261,7 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
            break;

        case WS_FULLSHEETNAME:

//				msg += GetScreenDesc();
            break;

@@ -288,12 +300,15 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
            break;

        case WS_UPPER_SEGMENT:
				if (UpperLimit == 0 ) break;
            if( UpperLimit == 0 )
                break;

        case WS_LEFT_SEGMENT:
            WS_MostUpperLine.m_Posy        =
                WS_MostUpperLine.m_Endy    =
                    WS_MostLeftLine.m_Posy = UpperLimit;
            pos.y = (ref.y - WsItem->m_Posy) * conv_unit;

        case WS_SEGMENT:
        {
            wxPoint auxpos;
@@ -303,8 +318,8 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
            FctPlume( auxpos, 'D' );
        }
            break;

        }

        if( !msg.IsEmpty() )
        {
            PlotGraphicText( format_plot, pos, color,
@@ -318,6 +333,7 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
    case PLOT_FORMAT_HPGL:
        Plume_HPGL( 'U' );
        break;

    case PLOT_FORMAT_POST:
        break;
    }
@@ -327,10 +343,10 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
/******************************************/
void UserToDeviceCoordinate( wxPoint& pos )
/******************************************/

/* modifie les coord pos.x et pos.y pour le trace selon l'orientation,
	l'echelle, les offsets de trace */
  * l'echelle, les offsets de trace */
{

    pos.x = (int) (pos.x * XScale);
    pos.y = (int) (pos.y * YScale);

@@ -343,10 +359,10 @@ void UserToDeviceCoordinate(wxPoint & pos )
    case PLOT_MIROIR:
        pos.x -= PlotOffset.x; pos.y = -PlotOffset.y + pos.y;
        break;

    }
}


/************************************/
void UserToDeviceSize( wxSize& size )
/************************************/
@@ -355,4 +371,3 @@ void UserToDeviceSize(wxSize & size )
    size.x = (int) (size.x * XScale);
    size.y = (int) (size.y * YScale);
}
+38 −38
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
        return;
    }

    if( (gcolor >= 0) && (format_plot == PLOT_FORMAT_POST) )
    if( gcolor >= 0 &&  IsPostScript( format_plot ) )
        SetColorMapPS( gcolor );

    size_h = Size.x;
+475 −459
Original line number Diff line number Diff line
@@ -17,12 +17,12 @@ extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp


/*****************************************************************************
Put out pin number and pin text info, given the pin line coordinates.
The line must be vertical or horizontal.
If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
Current Zoom factor is taken into account.
If TextInside then the text is been put inside,otherwise all is drawn outside.
Pin Name:	substring beteween '~' is negated
 *  Put out pin number and pin text info, given the pin line coordinates.
 *  The line must be vertical or horizontal.
 *  If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
 *  Current Zoom factor is taken into account.
 *  If TextInside then the text is been put inside,otherwise all is drawn outside.
 *  Pin Name:	substring beteween '~' is negated
*****************************************************************************/
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
                               wxPoint& pin_pos, int orient,
@@ -37,8 +37,10 @@ int PinTextBarPos[256];
    int      PinTextBarCount;
    int      NameColor, NumColor;
    int      PinTxtLen;

    wxSize  PinNameSize( m_PinNameSize, m_PinNameSize );
    wxSize  PinNumSize( m_PinNumSize, m_PinNumSize );

    int LineWidth = g_DrawMinimunLineWidth;

    GRSetDrawMode( DC, DrawMode );
@@ -51,12 +53,20 @@ int LineWidth = g_DrawMinimunLineWidth;
    ReturnPinStringNum( StringPinNum );

    x1 = pin_pos.x; y1 = pin_pos.y;

    switch( orient )
    {
		case PIN_UP: y1 -= m_PinLen; break;
		case PIN_DOWN: y1 += m_PinLen; break;
		case PIN_LEFT: x1 -= m_PinLen; break;
		case PIN_RIGHT: x1 += m_PinLen; break;
    case PIN_UP:
        y1 -= m_PinLen; break;

    case PIN_DOWN:
        y1 += m_PinLen; break;

    case PIN_LEFT:
        x1 -= m_PinLen; break;

    case PIN_RIGHT:
        x1 += m_PinLen; break;
    }

    const wxChar* textsrc = m_PinName.GetData();
@@ -82,11 +92,13 @@ int LineWidth = g_DrawMinimunLineWidth;
    PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
    PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'

	if (PinText[0] == 0) DrawPinName = FALSE;
    if( PinText[0] == 0 )
        DrawPinName = FALSE;

    if( TextInside )  /* Draw the text inside, but the pin numbers outside. */
    {
        if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )

        // It is an horizontal line
        {
            if( PinText && DrawPinName )
@@ -139,9 +151,9 @@ int LineWidth = g_DrawMinimunLineWidth;
                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
            }
        }

        else            /* Its a vertical line. */
		{	// Text is drawn from bottom to top (i.e. to negative value for Y axis)
        {
                        // Text is drawn from bottom to top (i.e. to negative value for Y axis)
            if( PinText && DrawPinName )
            {
                if( orient == PIN_DOWN )
@@ -163,7 +175,6 @@ int LineWidth = g_DrawMinimunLineWidth;
                        GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
                    }
                }

                else    /* PIN_UP */
                {
                    y = y1 - TextInside;
@@ -194,7 +205,6 @@ int LineWidth = g_DrawMinimunLineWidth;
            }
        }
    }
	
    else     /**** Draw num & text pin outside  ****/
    {
        if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
@@ -259,6 +269,7 @@ int LineWidth = g_DrawMinimunLineWidth;
    }
}


/*****************************************************************************
* Plot pin number and pin text info, given the pin line coordinates.	  *
* Same as DrawPinTexts((), but output is the plotter
@@ -290,12 +301,20 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
    /* Create the pin num string */
    ReturnPinStringNum( StringPinNum );
    x1 = pin_pos.x; y1 = pin_pos.y;

    switch( orient )
    {
		case PIN_UP: y1 -= m_PinLen; break;
		case PIN_DOWN: y1 += m_PinLen; break;
		case PIN_LEFT: x1 -= m_PinLen; break;
		case PIN_RIGHT: x1 += m_PinLen; break;
    case PIN_UP:
        y1 -= m_PinLen; break;

    case PIN_DOWN:
        y1 += m_PinLen; break;

    case PIN_LEFT:
        x1 -= m_PinLen; break;

    case PIN_RIGHT:
        x1 += m_PinLen; break;
    }

    const wxChar* textsrc = m_PinName.GetData();
@@ -321,7 +340,8 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
    PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
    PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'

	if (PinText[0] == 0) DrawPinName = FALSE;
    if( PinText[0] == 0 )
        DrawPinName = FALSE;

    if( TextInside )  /* Draw the text inside, but the pin numbers outside. */
    {
@@ -373,7 +393,6 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
            }
        }

        else         /* Its a vertical line. */
        {
            if( PinText && DrawPinName )
@@ -395,7 +414,6 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
                        Move_Plume( wxPoint( cte, y + PinTxtLen - len ), 'D' );
                    }
                }

                else    /* PIN_UP */
                {
                    y = y1 - TextInside;
@@ -424,7 +442,6 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
            }
        }
    }
	
    else     /* Draw num & text pin outside */
    {
        if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
@@ -488,4 +505,3 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
        }
    }
}
Loading