Commit 3668f4cc authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: cleanup functions: now, cleanup uses same algorithm as connectivity...

Pcbnew: cleanup functions: now, cleanup uses same algorithm as connectivity calculations to detect pads connections, and is faster.
therefore tracks which have a end point inside a pad, but not necessaryexactly  to the pad position are seen as connected, and are no more removed.
Side effect: reconnect to pads option is removed, because it is useless.
TODO: use this algorithm in drag functions.
Minor other fixes
parent 5aec4604
Loading
Loading
Loading
Loading
+14 −16
Original line number Original line Diff line number Diff line
@@ -55,6 +55,13 @@
double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;
double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;




/* Helper function for texts with over bar
 */
int OverbarPositionY( int size_v, int thickness )
{
    return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) );
}

/**
/**
 * Function GetPensizeForBold
 * Function GetPensizeForBold
 * @return the "best" value for a pen size to draw/plot a bold text
 * @return the "best" value for a pen size to draw/plot a bold text
@@ -219,14 +226,6 @@ static void DrawGraphicTextPline(
}
}




/* Helper function for texts with over bar
 */
static int overbar_position( int size_v, int thickness )
{
    return KiROUND( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
}


/**
/**
 * Function DrawGraphicText
 * Function DrawGraphicText
 * Draw a graphic text (like module texts)
 * Draw a graphic text (like module texts)
@@ -271,7 +270,6 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
    int       dx, dy;                       // Draw coordinate for segments to draw. also used in some other calculation
    int       dx, dy;                       // Draw coordinate for segments to draw. also used in some other calculation
    wxPoint   current_char_pos;             // Draw coordinates for the current char
    wxPoint   current_char_pos;             // Draw coordinates for the current char
    wxPoint   overbar_pos;                  // Start point for the current overbar
    wxPoint   overbar_pos;                  // Start point for the current overbar
    int       overbars;                     // Number of ~ seen
    int       overbar_italic_comp;          // Italic compensation for overbar
    int       overbar_italic_comp;          // Italic compensation for overbar
    EDA_RECT* clipBox;                      // Clip box used in basic draw functions
    EDA_RECT* clipBox;                      // Clip box used in basic draw functions


@@ -400,7 +398,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,


    if( aItalic )
    if( aItalic )
    {
    {
        overbar_italic_comp = overbar_position( size_v, aWidth ) / 8;
        overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8;
        if( italic_reverse )
        if( italic_reverse )
        {
        {
            overbar_italic_comp = -overbar_italic_comp;
            overbar_italic_comp = -overbar_italic_comp;
@@ -411,7 +409,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
        overbar_italic_comp = 0;
        overbar_italic_comp = 0;
    };
    };


    overbars = 0;
    int overbars = 0;       // Number of ~ seen
    ptr = 0;   /* ptr = text index */
    ptr = 0;   /* ptr = text index */
    while( ptr < char_count )
    while( ptr < char_count )
    {
    {
@@ -420,12 +418,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
            /* Found an overbar, adjust the pointers */
            /* Found an overbar, adjust the pointers */
            overbars++;
            overbars++;


            if( overbars % 2 )
            if( overbars & 1 )      // odd overbars count
            {
            {
                /* Starting the overbar */
                /* Starting the overbar */
                overbar_pos    = current_char_pos;
                overbar_pos    = current_char_pos;
                overbar_pos.x += overbar_italic_comp;
                overbar_pos.x += overbar_italic_comp;
                overbar_pos.y -= overbar_position( size_v, aWidth );
                overbar_pos.y -= OverbarPositionY( size_v, aWidth );
                RotatePoint( &overbar_pos, aPos, aOrient );
                RotatePoint( &overbar_pos, aPos, aOrient );
            }
            }
            else
            else
@@ -434,7 +432,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
                coord[0]       = overbar_pos;
                coord[0]       = overbar_pos;
                overbar_pos    = current_char_pos;
                overbar_pos    = current_char_pos;
                overbar_pos.x += overbar_italic_comp;
                overbar_pos.x += overbar_italic_comp;
                overbar_pos.y -= overbar_position( size_v, aWidth );
                overbar_pos.y -= OverbarPositionY( size_v, aWidth );
                RotatePoint( &overbar_pos, aPos, aOrient );
                RotatePoint( &overbar_pos, aPos, aOrient );
                coord[1] = overbar_pos;
                coord[1] = overbar_pos;
                /* Plot the overbar segment */
                /* Plot the overbar segment */
@@ -516,7 +514,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
        /* Close the last overbar */
        /* Close the last overbar */
        coord[0]       = overbar_pos;
        coord[0]       = overbar_pos;
        overbar_pos    = current_char_pos;
        overbar_pos    = current_char_pos;
        overbar_pos.y -= overbar_position( size_v, aWidth );
        overbar_pos.y -= OverbarPositionY( size_v, aWidth );
        RotatePoint( &overbar_pos, aPos, aOrient );
        RotatePoint( &overbar_pos, aPos, aOrient );
        coord[1] = overbar_pos;
        coord[1] = overbar_pos;
        /* Plot the overbar segment */
        /* Plot the overbar segment */
+13 −6
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@




extern void IncrementLabelMember( wxString& name );
extern void IncrementLabelMember( wxString& name );
extern int OverbarPositionY( int size_v, int thickness );




/* Names of sheet label types. */
/* Names of sheet label types. */
@@ -273,19 +274,19 @@ void SCH_TEXT::Rotate( wxPoint aPosition )


    switch( GetOrientation() )
    switch( GetOrientation() )
    {
    {
    case 0:             /* horizontal text */
    case 0:     // horizontal text
        dy = m_Size.y;
        dy = m_Size.y;
        break;
        break;


    case 1: /* Vert Orientation UP */
    case 1:     // Vert Orientation UP
        dy = 0;
        dy = 0;
        break;
        break;


    case 2:        /* invert horizontal text*/
    case 2:     // invert horizontal text
        dy = m_Size.y;
        dy = m_Size.y;
        break;
        break;


    case 3: /*  Vert Orientation BOTTOM */
    case 3:     // Vert Orientation BOTTOM
        dy = 0;
        dy = 0;
        break;
        break;


@@ -1241,8 +1242,14 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
    // Create outline shape : 6 points
    // Create outline shape : 6 points
    int x = symb_len + linewidth + 3;
    int x = symb_len + linewidth + 3;


    // 50% more for negation bar
    // Use negation bar Y position to calculate full vertical size
    int y = KiROUND( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
    #define Y_CORRECTION 1.22
    // Note: this factor is due to the fact the negation bar Y position
    // does not give exactly the full Y size of text
    // and is experimentally set  to this value
    int y = KiROUND( OverbarPositionY( HalfSize, linewidth ) * Y_CORRECTION );
    // add room for line thickness and space between top of text and graphic shape
    y += linewidth;


    // Starting point(anchor)
    // Starting point(anchor)
    aPoints.push_back( wxPoint( 0, 0 ) );
    aPoints.push_back( wxPoint( 0, 0 ) );
Loading