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

painter: better size of pad nums and pad netnames in opengl mode

parent 96912e6b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ static void AddModifierToKey( wxString& aFullKey, const wxString & aKey )
        // We can use Shift+<key> as accelerator and <key> for hot key
        aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
    else
        // We must use Alt+<key> as accelerator ans <key> for hot key
        // We must use Alt+<key> as accelerator and <key> for hot key
        aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
}

+3 −3
Original line number Diff line number Diff line
@@ -87,11 +87,11 @@ static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, '
static EDA_HOTKEY HkResetGridOrigin( wxT("Reset Grid Origin"), HK_RESET_GRID_ORIGIN, 'Z' );

static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ),
                                   HK_CANVAS_DEFAULT, GR_KB_ALT + WXK_F9 );
                                   HK_CANVAS_DEFAULT, WXK_F9 );
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ),
                                  HK_CANVAS_OPENGL, GR_KB_ALT + WXK_F11 );
                                  HK_CANVAS_OPENGL, WXK_F11 );
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ),
                                 HK_CANVAS_CAIRO, GR_KB_ALT + WXK_F12 );
                                 HK_CANVAS_CAIRO, WXK_F12 );

/* Fit on Screen */
#if !defined( __WXMAC__ )
+41 −46
Original line number Diff line number Diff line
@@ -376,8 +376,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
    PAD_SHAPE_T shape;
    double      m, n;
    double      orientation = aPad->GetOrientation();
    NORMALIZE_ANGLE_90( orientation );  // do not display descriptions upside down
    orientation = orientation * M_PI / 1800.0;
    wxString buffer;

    // Draw description layer
@@ -386,18 +384,21 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
        // Is anything that we can display enabled?
        if( m_pcbSettings->m_netNamesOnPads || m_pcbSettings->m_padNumbers )
        {
            // Min char count to calculate string size
            #define MIN_CHAR_COUNT 3

            bool displayNetname = ( m_pcbSettings->m_netNamesOnPads &&
                                    !aPad->GetNetname().empty() );
            VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
            size = padsize;
            double scale = m_gal->GetZoomFactor();
            double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
            double size = padsize.y;

            // Keep the size ratio for the font, but make it smaller
            if( padsize.x < padsize.y )
            {
                orientation -= M_PI / 2.0;
                size.y = size.x;
                orientation += 900.0;
                size = padsize.x;
                EXCHG( padsize.x, padsize.y );
            }
            else if( padsize.x == padsize.y )
            {
@@ -406,16 +407,18 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
            }
            else
            {
                size.x = size.y;
            }

            // Font size limits
            if( size.x > maxSize )
                size.x = size.y = maxSize;
            if( size > maxSize )
                size = maxSize;

            m_gal->Save();
            m_gal->Translate( position );
            m_gal->Rotate( -orientation );

            // do not display descriptions upside down
            NORMALIZE_ANGLE_90( orientation );
            m_gal->Rotate( -orientation * M_PI / 1800.0 );

            // Default font settings
            m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
@@ -434,52 +437,46 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
                m_gal->SetStrokeColor( labelColor );

            VECTOR2D textpos( 0.0, 0.0);

            // Divide the space, to display both pad numbers and netnames
            // and set the Y text position to display 2 lines
            if( displayNetname && m_pcbSettings->m_padNumbers )
            {
                m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
                m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );

                // Divide the space, when both pad numbers and netnames are enabled
                size = size / 2.0;
                aPad->ReturnStringPadName( buffer );
                VECTOR2D numsize = size / buffer.Length();
                VECTOR2D namesize = size / aPad->GetShortNetname().Length();

                textpos.y = size.y / 2.0;
                m_gal->SetGlyphSize( namesize );
                m_gal->SetLineWidth( namesize.y / 8.0 );
                m_gal->StrokeText( std::string( aPad->GetShortNetname().mb_str() ),
                                   textpos, 0.0 );

                textpos.y = -size.y / 2.0;
                m_gal->SetGlyphSize( numsize );
                m_gal->SetLineWidth( numsize.y / 8.0 );
                m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ),
                                   textpos, 0.0 );
                textpos.y = size / 2.0;
            }
            else
            {
                // There is only one thing to display

            if( displayNetname )
            {
                    VECTOR2D namesize = size / aPad->GetShortNetname().Length();
                    m_gal->SetGlyphSize( namesize / 2.0 );
                    m_gal->SetLineWidth( namesize.y / 8.0 );
                // calculate the size of net name text:
                double tsize = padsize.x / aPad->GetShortNetname().Length();
                tsize = std::min( tsize, size );
                // Use a smaller text size to handle interline, pen size..
                tsize *= 0.7;
                VECTOR2D namesize( tsize, tsize );
                m_gal->SetGlyphSize( namesize );
                m_gal->SetLineWidth( namesize.x / 12.0 );
                m_gal->StrokeText( std::string( aPad->GetShortNetname().mb_str() ),
                                   textpos, 0.0 );
            }

            if( m_pcbSettings->m_padNumbers )
            {
                textpos.y = -textpos.y;
                aPad->ReturnStringPadName( buffer );
                    VECTOR2D numsize = size / 2 / buffer.Length();
                int len = buffer.Length();
                double tsize = padsize.x / std::max( len, MIN_CHAR_COUNT );
                tsize = std::min( tsize, size );
                // Use a smaller text size to handle interline, pen size..
                tsize *= 0.7;
                tsize = std::min( tsize, size );
                VECTOR2D numsize( tsize, tsize );

                m_gal->SetGlyphSize( numsize );
                    m_gal->SetLineWidth( numsize.y / 8.0 );
                m_gal->SetLineWidth( numsize.x / 12.0 );
                m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ),
                                   textpos, 0.0 );
            }
            }

            m_gal->Restore();
        }
@@ -601,8 +598,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )

        VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
        VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
        VECTOR2D delta = VECTOR2D( aPad->GetDelta().x / 2,
                                   aPad->GetDelta().y / 2 );

        aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
        pointList.push_back( VECTOR2D( corners[0] ) );