diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index aa16306d76..0881c0f96d 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -216,7 +216,7 @@ static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) // We can use Shift+ as accelerator and for hot key aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey; else - // We must use Alt+ as accelerator ans for hot key + // We must use Alt+ as accelerator and for hot key aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey; } diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index fe0571303a..173b09fffd 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -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__ ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 79aa37bda9..9e30b2ea94 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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 / 2.0; + } - textpos.y = size.y / 2.0; + if( displayNetname ) + { + // 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.y / 8.0 ); + 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 ); + 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 ); - textpos.y = -size.y / 2.0; 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 ); } - 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 ); - m_gal->StrokeText( std::string( aPad->GetShortNetname().mb_str() ), - textpos, 0.0 ); - } - - if( m_pcbSettings->m_padNumbers ) - { - aPad->ReturnStringPadName( buffer ); - VECTOR2D numsize = size / 2 / buffer.Length(); - - m_gal->SetGlyphSize( numsize ); - m_gal->SetLineWidth( numsize.y / 8.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] ) );