Commit 6d856f60 authored by charras's avatar charras
Browse files

Pcbnew: Added display a short net name on vias and pads. Also, code cleaning

parent 9dae370c
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2008-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++pcbnew
    Display a short net name on vias and pads (if zoom level allows it).
    Short net names are net names without hierarchy path
    Add m_ShortNetname and change m_Netname to private in classes D_PAD and EQUIPOT


2008-Dec-08 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
2008-Dec-08 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
================================================================================
++all
++all
+0 −3
Original line number Original line Diff line number Diff line
@@ -138,9 +138,6 @@ void WinEDA_BasicFrame::PrintMsg( const wxString& text )
/******************************************************/
/******************************************************/
{
{
    SetStatusText( text );
    SetStatusText( text );
#ifdef DEBUG
    printf( "%s\n", (const char*) text.mb_str() );
#endif
}
}




+1 −1
Original line number Original line Diff line number Diff line
@@ -92,7 +92,7 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
    int               ii, jj, xg, yg, ipas, gxpas, gypas;
    int               ii, jj, xg, yg, ipas, gxpas, gypas;
    wxSize            PageSize;
    wxSize            PageSize;
    wxPoint           pos, ref;
    wxPoint           pos, ref;
    int               color;
    EDA_Colors        color;
    Ki_WorkSheetData* WsItem;
    Ki_WorkSheetData* WsItem;
    int               conv_unit = screen->GetInternalUnits() / 1000; /* Scale to convert dimension in 1/1000 in into internal units
    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 */
+85 −76
Original line number Original line Diff line number Diff line
@@ -21,22 +21,23 @@
/* fonctions locales : */
/* fonctions locales : */




/****************************************************************************/
/****************************************************************************************************/
void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
                      const wxPoint& Pos, int gcolor, const wxString& Text,
                      const wxPoint& aPos, enum EDA_Colors aColor, const wxString& aText,
                      int orient, const wxSize& Size, int h_justify, int v_justify, int width )
                      int aOrient, const wxSize& aSize, int aH_justify, int aV_justify, int aWidth )
/*****************************************************************************/
/****************************************************************************************************/


/* Draw a graphic text (like module texts)
/** Function DrawGraphicText
 *  Text = text to draw
 * Draw a graphic text (like module texts)
 *  Pos = text position (according to h_justify, v_justify)
 *  @param aPanel = the current DrawPanel
 *  Size = text size (size.x or size.y can be < 0 for mirrored texts)
 *  @param aPos = text position (according to aH_justify, aV_justify)
 *  orient = angle in 0.1 degree
 *  @param aColor (enum EDA_Colors) = text color
 *  mode_color = GR_OR, GR_XOR..
 *  @param aText = text to draw
 *  h_justify = horizontal justification (Left, center, right)
 *  @param aOrient = angle in 0.1 degree
 *  v_justify = vertical justification (bottom, center, top)
 *  @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
 *  width = line width (pen width) (default = 0)
 *  @param aH_justify = horizontal justification (Left, center, right)
 *      if width < 0 : draw segments in sketch mode, width = abs(width)
 *  @param aV_justify = vertical justification (bottom, center, top)
 *  @param aWidth = line aWidth (pen aWidth) (default = 0)
 */
 */
{
{
    int            ii, kk, nbchar, AsciiCode, endcar;
    int            ii, kk, nbchar, AsciiCode, endcar;
@@ -52,29 +53,29 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
    int            coord[100];          // Buffer coordinate used to draw polylines (char shapes)
    int            coord[100];          // Buffer coordinate used to draw polylines (char shapes)
    bool           sketch_mode = FALSE;
    bool           sketch_mode = FALSE;


    zoom = panel->GetZoom();
    zoom = aPanel->GetZoom();


    size_h = Size.x;
    size_h = aSize.x;
    size_v = Size.y;
    size_v = aSize.y;


    if( width < 0 )
    if( aWidth < 0 )
    {
    {
        width = -width;
        aWidth = -aWidth;
        sketch_mode = TRUE;
        sketch_mode = TRUE;
    }
    }
    kk = 0;
    kk = 0;
    ptr = 0;   /* ptr = text index */
    ptr = 0;   /* ptr = text index */


    nbchar = Text.Len();
    nbchar = aText.Len();
    if( nbchar == 0 )
    if( nbchar == 0 )
        return;
        return;


    espacement = (10 * size_h ) / 9;    // this is the pitch between chars
    espacement = (10 * size_h ) / 9;    // this is the pitch between chars
    ox = cX = Pos.x;
    ox = cX = aPos.x;
    oy = cY = Pos.y;
    oy = cY = aPos.y;


    /* Do not draw the text if out of draw area! */
    /* Do not draw the text if out of draw area! */
    if( panel )
    if( aPanel )
    {
    {
        int xm, ym, ll, xc, yc;
        int xm, ym, ll, xc, yc;
        int textsize = ABS( espacement );
        int textsize = ABS( espacement );
@@ -83,10 +84,10 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
        xc = GRMapX( cX );
        xc = GRMapX( cX );
        yc = GRMapY( cY );
        yc = GRMapY( cY );


        x0 = panel->m_ClipBox.GetX() - ll;
        x0 = aPanel->m_ClipBox.GetX() - ll;
        y0 = panel->m_ClipBox.GetY() - ll;
        y0 = aPanel->m_ClipBox.GetY() - ll;
        xm = panel->m_ClipBox.GetRight() + ll;
        xm = aPanel->m_ClipBox.GetRight() + ll;
        ym = panel->m_ClipBox.GetBottom() + ll;
        ym = aPanel->m_ClipBox.GetBottom() + ll;


        if( xc < x0 )
        if( xc < x0 )
            return;
            return;
@@ -105,9 +106,9 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,


    ux0 = uy0 = 0;                          /* Decalage du centre du texte / coord de ref */
    ux0 = uy0 = 0;                          /* Decalage du centre du texte / coord de ref */


    if( (orient == 0) || (orient == 1800) ) /* Horizontal Text */
    if( (aOrient == 0) || (aOrient == 1800) ) /* Horizontal Text */
    {
    {
        switch( h_justify )
        switch( aH_justify )
        {
        {
        case GR_TEXT_HJUSTIFY_CENTER:
        case GR_TEXT_HJUSTIFY_CENTER:
            break;
            break;
@@ -121,7 +122,7 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
            break;
            break;
        }
        }


        switch( v_justify )
        switch( aV_justify )
        {
        {
        case GR_TEXT_VJUSTIFY_CENTER:
        case GR_TEXT_VJUSTIFY_CENTER:
            break;
            break;
@@ -137,7 +138,7 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
    }
    }
    else    /* Vertical Text */
    else    /* Vertical Text */
    {
    {
        switch( h_justify )
        switch( aH_justify )
        {
        {
        case GR_TEXT_HJUSTIFY_CENTER:
        case GR_TEXT_HJUSTIFY_CENTER:
            break;
            break;
@@ -151,7 +152,7 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
            break;
            break;
        }
        }


        switch( v_justify )
        switch( aV_justify )
        {
        {
        case GR_TEXT_VJUSTIFY_CENTER:
        case GR_TEXT_VJUSTIFY_CENTER:
            break;
            break;
@@ -172,10 +173,10 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
    ox = cX - dx;
    ox = cX - dx;
    oy = cY + dy;
    oy = cY + dy;


    if( (Size.x / zoom) == 0 )
    if( (aSize.x / zoom) == 0 )
        return;
        return;


    if( ABS( (Size.x / zoom) ) < 3 )    /* chars trop petits pour etre dessines */
    if( ABS( (aSize.x / zoom) ) < 3 )    /* chars trop petits pour etre dessines */
    {                                   /* le texte est symbolise par une barre */
    {                                   /* le texte est symbolise par une barre */
        dx = (espacement * nbchar) / 2;
        dx = (espacement * nbchar) / 2;
        dy = size_v / 2;                /* Decalage du debut du texte / centre */
        dy = size_v / 2;                /* Decalage du debut du texte / centre */
@@ -186,10 +187,10 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
        dx += cX;
        dx += cX;
        dy = cY;
        dy = cY;


        RotatePoint( &ux0, &uy0, cX, cY, orient );
        RotatePoint( &ux0, &uy0, cX, cY, aOrient );
        RotatePoint( &dx, &dy, cX, cY, orient );
        RotatePoint( &dx, &dy, cX, cY, aOrient );


        GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, width, gcolor );
        GRLine( &aPanel->m_ClipBox, DC, ux0, uy0, dx, dy, aWidth, aColor );


        return;
        return;
    }
    }
@@ -204,15 +205,15 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
    dx += cX;
    dx += cX;
    dy = cY;
    dy = cY;


    RotatePoint( &ux0, &uy0, cX, cY, orient );
    RotatePoint( &ux0, &uy0, cX, cY, aOrient );
    RotatePoint( &dx, &dy, cX, cY, orient );
    RotatePoint( &dx, &dy, cX, cY, aOrient );


    DC->SetTextForeground( wxColour(
    DC->SetTextForeground( wxColour(
                              ColorRefs[gcolor].r,
                              ColorRefs[aColor].r,
                              ColorRefs[gcolor].g,
                              ColorRefs[aColor].g,
                              ColorRefs[gcolor].b ) );
                              ColorRefs[aColor].b ) );


    DC->DrawRotatedText( Text, GRMapX( ux0 ), GRMapY( uy0 ), (double) orient / 10.0 );
    DC->DrawRotatedText( Text, GRMapX( ux0 ), GRMapY( uy0 ), (double) aOrient / 10.0 );
    return;
    return;
#endif
#endif


@@ -220,13 +221,13 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
    {
    {
        x0 = 0; y0 = 0;
        x0 = 0; y0 = 0;
#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC)
#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC)
	AsciiCode = Text.GetChar(ptr) & 0x7FF;
	AsciiCode = aText.GetChar(ptr) & 0x7FF;
	if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr
	if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr
	    AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF;
	    AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF;
	else
	else
	    AsciiCode = AsciiCode & 0xFF;
	    AsciiCode = AsciiCode & 0xFF;
#else
#else
         AsciiCode = Text.GetChar( ptr ) & 255;
        AsciiCode = aText.GetChar( ptr ) & 0xFF;
#endif
#endif
        ptcar = graphic_fonte_shape[AsciiCode];  /* ptcar pointe la description
        ptcar = graphic_fonte_shape[AsciiCode];  /* ptcar pointe la description
                                                  *  du caractere a dessiner */
                                                  *  du caractere a dessiner */
@@ -245,20 +246,20 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
            case 'U':
            case 'U':
                if( ii && (plume == 'D' ) )
                if( ii && (plume == 'D' ) )
                {
                {
                    if( width <= 1 )
                    if( aWidth <= 1 )
                        GRPoly( &panel->m_ClipBox, DC, ii / 2, coord, 0, 0,
                        GRPoly( &aPanel->m_ClipBox, DC, ii / 2, coord, 0, 0,
                                gcolor, gcolor );
                                aColor, aColor );
                    else if( sketch_mode )
                    else if( sketch_mode )
                    {
                    {
                        int ik, * coordptr;
                        int ik, * coordptr;
                        coordptr = coord;
                        coordptr = coord;
                        for( ik = 0; ik < (ii - 2); ik += 2, coordptr += 2 )
                        for( ik = 0; ik < (ii - 2); ik += 2, coordptr += 2 )
                            GRCSegm( &panel->m_ClipBox, DC, *coordptr, *(coordptr + 1),
                            GRCSegm( &aPanel->m_ClipBox, DC, *coordptr, *(coordptr + 1),
                                     *(coordptr + 2), *(coordptr + 3), width, gcolor );
                                     *(coordptr + 2), *(coordptr + 3), aWidth, aColor );
                    }
                    }
                    else
                    else
                        GRPoly( &panel->m_ClipBox, DC, ii / 2, coord, 0,
                        GRPoly( &aPanel->m_ClipBox, DC, ii / 2, coord, 0,
                                width, gcolor, gcolor );
                                aWidth, aColor, aColor );
                }
                }
                plume = f_cod; ii = 0;
                plume = f_cod; ii = 0;
                break;
                break;
@@ -279,7 +280,7 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,
                    k2    = (k2 * size_h) / 9;
                    k2    = (k2 * size_h) / 9;
                    dx    = k2 + ox; dy = k1 + oy;
                    dx    = k2 + ox; dy = k1 + oy;


                    RotatePoint( &dx, &dy, cX, cY, orient );
                    RotatePoint( &dx, &dy, cX, cY, aOrient );
                    coord[ii++] = dx;
                    coord[ii++] = dx;
                    coord[ii++] = dy;
                    coord[ii++] = dy;
                    break;
                    break;
@@ -299,13 +300,21 @@ void DrawGraphicText( WinEDA_DrawPanel* panel, wxDC* DC,




/******************************************************************************************/
/******************************************************************************************/
void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aColor,
                      const wxString& Text,
                      const wxString& aText,
                      int orient, const wxSize& Size, int h_justify, int v_justify )
                      int aOrient, const wxSize& aSize, int aH_justify, int aV_justify )
/******************************************************************************************/
/******************************************************************************************/


/*
/** Function PlotGraphicText
 *  id DrawGraphicText, for plot graphic text
 *  same as DrawGraphicText, but plot graphic text insteed of draw it
 *  @param aFormat_plot = plot format (PLOT_FORMAT_POST, PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER)
 *  @param aPos = text position (according to aH_justify, aV_justify)
 *  @param aColor (enum EDA_Colors) = text color
 *  @param aText = text to draw
 *  @param aOrient = angle in 0.1 degree
 *  @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
 *  @param aH_justify = horizontal justification (Left, center, right)
 *  @param aV_justify = vertical justification (bottom, center, top)
 */
 */
{
{
    int            kk, nbchar, end, AsciiCode;
    int            kk, nbchar, end, AsciiCode;
@@ -319,7 +328,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,


    void           (*FctPlume)( wxPoint pos, int state );
    void           (*FctPlume)( wxPoint pos, int state );


    switch( format_plot )
    switch( aFormat_plot )
    {
    {
    case PLOT_FORMAT_POST:
    case PLOT_FORMAT_POST:
        FctPlume = LineTo_PS;
        FctPlume = LineTo_PS;
@@ -334,11 +343,11 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
        return;
        return;
    }
    }


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


    size_h = Size.x;
    size_h = aSize.x;
    size_v = Size.y;
    size_v = aSize.y;
    if( size_h == 0 )
    if( size_h == 0 )
        size_h = DEFAULT_SIZE_TEXT;
        size_h = DEFAULT_SIZE_TEXT;
    if( size_v == 0 )
    if( size_v == 0 )
@@ -348,11 +357,11 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
    ptr = 0; /* ptr = text index */
    ptr = 0; /* ptr = text index */


    /* calcul de la position du debut des textes: ox et oy */
    /* calcul de la position du debut des textes: ox et oy */
    nbchar = Text.Len();
    nbchar = aText.Len();


    espacement = (10 * size_h ) / 9;
    espacement = (10 * size_h ) / 9;
    ox = cX = Pos.x;
    ox = cX = aPos.x;
    oy = cY = Pos.y;
    oy = cY = aPos.y;


    /* Calcul du cadrage du texte */
    /* Calcul du cadrage du texte */
    dx = (espacement * nbchar) / 2;
    dx = (espacement * nbchar) / 2;
@@ -360,9 +369,9 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,


    ux0 = uy0 = 0;                          /* Decalage du centre du texte / ccord de ref */
    ux0 = uy0 = 0;                          /* Decalage du centre du texte / ccord de ref */


    if( (orient == 0) || (orient == 1800) ) /* Texte Horizontal */
    if( (aOrient == 0) || (aOrient == 1800) ) /* Texte Horizontal */
    {
    {
        switch( h_justify )
        switch( aH_justify )
        {
        {
        case GR_TEXT_HJUSTIFY_CENTER:
        case GR_TEXT_HJUSTIFY_CENTER:
            break;
            break;
@@ -376,7 +385,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
            break;
            break;
        }
        }


        switch( v_justify )
        switch( aV_justify )
        {
        {
        case GR_TEXT_VJUSTIFY_CENTER:
        case GR_TEXT_VJUSTIFY_CENTER:
            break;
            break;
@@ -392,7 +401,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
    }
    }
    else    /* Texte Vertical */
    else    /* Texte Vertical */
    {
    {
        switch( h_justify )
        switch( aH_justify )
        {
        {
        case GR_TEXT_HJUSTIFY_CENTER:
        case GR_TEXT_HJUSTIFY_CENTER:
            break;
            break;
@@ -406,7 +415,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
            break;
            break;
        }
        }


        switch( v_justify )
        switch( aV_justify )
        {
        {
        case GR_TEXT_VJUSTIFY_CENTER:
        case GR_TEXT_VJUSTIFY_CENTER:
            break;
            break;
@@ -432,13 +441,13 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
    while( kk++ < nbchar )
    while( kk++ < nbchar )
    {
    {
#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC)
#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC)
	AsciiCode = Text.GetChar(ptr) & 0x7FF;
	AsciiCode = aText.GetChar(ptr) & 0x7FF;
	if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr
	if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr
	    AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF;
	    AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF;
	else
	else
	    AsciiCode = AsciiCode & 0xFF;
	    AsciiCode = AsciiCode & 0xFF;
#else
#else
        AsciiCode = Text.GetChar( ptr ) & 0xFF;
        AsciiCode = aText.GetChar( ptr ) & 0xFF;
#endif
#endif
        ptcar = graphic_fonte_shape[AsciiCode];  /* ptcar pointe la description
        ptcar = graphic_fonte_shape[AsciiCode];  /* ptcar pointe la description
                                                  *  du caractere a dessiner */
                                                  *  du caractere a dessiner */
@@ -469,7 +478,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
                dx    = k2 + ox;
                dx    = k2 + ox;
                dy = k1 + oy;
                dy = k1 + oy;


                RotatePoint( &dx, &dy, orient );
                RotatePoint( &dx, &dy, aOrient );
                FctPlume( wxPoint( cX + dx, cY + dy ), plume );
                FctPlume( wxPoint( cX + dx, cY + dy ), plume );


                x0 = k2;
                x0 = k2;
+4 −3
Original line number Original line Diff line number Diff line
@@ -26,7 +26,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
    Ki_PageDescr*     Sheet = screen->m_CurrentSheetDesc;
    Ki_PageDescr*     Sheet = screen->m_CurrentSheetDesc;
    int               ii, jj, xg, yg, ipas, gxpas, gypas;
    int               ii, jj, xg, yg, ipas, gxpas, gypas;
    wxPoint           pos;
    wxPoint           pos;
    int               refx, refy, Color;
    int               refx, refy;
    EDA_Colors        Color;
    wxString          Line;
    wxString          Line;
    Ki_WorkSheetData* WsItem;
    Ki_WorkSheetData* WsItem;
    int               scale = m_InternalUnits / 1000;
    int               scale = m_InternalUnits / 1000;
Loading