Loading CMakeLists.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ option(KICAD_STABLE_VERSION ) ) option(KICAD_TESTING_VERSION option(KICAD_TESTING_VERSION "set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)" "set this option to ON to build the testing version of KICAD. mainly used to set version ID (default OFF)" ) ) option(KICAD_SCRIPTING option(KICAD_SCRIPTING Loading common/drawtxt.cpp +118 −91 Original line number Original line Diff line number Diff line Loading @@ -40,13 +40,15 @@ #include <class_base_screen.h> #include <class_base_screen.h> #define EDA_DRAWBASE #include <newstroke_font.h> #include <newstroke_font.h> #include <plot_common.h> #include <plot_common.h> /* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name) /* factor used to calculate actual size of shapes from hershey fonts * Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter * (could be adjusted depending on the font name) * Of course some shapes can be bigger or smaller than the vertical char size parameter * Its value is choosen in order to have letters like M, P .. vertical size * equal to the vertical char size parameter * Of course some shapes can be bigger or smaller than the vertical char size * parameter */ */ #define HERSHEY_SCALE_FACTOR 1 / 21.0 #define HERSHEY_SCALE_FACTOR 1 / 21.0 double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; Loading @@ -59,6 +61,7 @@ int OverbarPositionY( int size_v, int thickness ) return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) ); 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 Loading Loading @@ -90,6 +93,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold ) if( penSize > maxWidth ) if( penSize > maxWidth ) penSize = maxWidth; penSize = maxWidth; return penSize; return penSize; } } Loading @@ -112,17 +116,19 @@ int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold ) /** /** * Function NegableTextLength * Function NegableTextLength * Return the text length of a negable string, excluding the ~ markers */ * Return the text length (char count) of a negable string, * excluding the ~ markers */ int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText ) { { int char_count = aText.length(); int char_count = aText.length(); /* Fix the character count, removing the ~ found */ // Fix the character count, removing the ~ found for( int i = char_count - 1; i >= 0; i-- ) for( int i = char_count - 1; i >= 0; i-- ) { { if( aText[i] == '~' ) if( aText[i] == '~' ) { { /* '~~' draw as '~' and count as two chars */ // '~~' draw as '~' and count as two chars if( i > 0 && aText[i - 1] == '~' ) if( i > 0 && aText[i - 1] == '~' ) i--; i--; else else Loading @@ -142,13 +148,15 @@ int NegableTextLength( const wxString& aText ) */ */ static const char* GetHersheyShapeDescription( int AsciiCode ) static const char* GetHersheyShapeDescription( int AsciiCode ) { { /* calculate font length */ // calculate font length int font_length_max = newstroke_font_bufsize; int font_length_max = newstroke_font_bufsize; if( AsciiCode >= (32 + font_length_max) ) if( AsciiCode >= (32 + font_length_max) ) AsciiCode = '?'; AsciiCode = '?'; if( AsciiCode < 32 ) if( AsciiCode < 32 ) AsciiCode = 32; /* Clamp control chars */ AsciiCode = 32; /* Clamp control chars */ AsciiCode -= 32; AsciiCode -= 32; return newstroke_font[AsciiCode]; return newstroke_font[AsciiCode]; Loading @@ -162,36 +170,37 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo for( int i = 0; i < char_count; i++ ) for( int i = 0; i < char_count; i++ ) { { int AsciiCode = aText[i]; int asciiCode = aText[i]; /* Skip the negation marks /* Skip the negation marks * and first '~' char of '~~' * and first '~' char of '~~' * ('~~' draw as '~') */ * ('~~' draw as '~') if( AsciiCode == '~' ) */ if( asciiCode == '~' ) { { if( i > 0 && aText[i - 1] != '~' ) if( i == 0 || aText[i - 1] != '~' ) continue; continue; } } const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* shape_ptr = GetHersheyShapeDescription( asciiCode ); /* Get metrics */ // Get metrics int xsta = *ptcar++ - 'R'; int xsta = *shape_ptr++ - 'R'; int xsto = *ptcar++ - 'R'; int xsto = *shape_ptr++ - 'R'; tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); } } /* Italic correction, 1/8em */ // For italic correction, add 1/8 size if( aItalic ) if( aItalic ) { { tally += KiROUND( aXSize * 0.125 ); tally += KiROUND( aXSize * 0.125 ); } } return tally; return tally; } } /* Helper function for drawing character polygons */ // Helper function for drawing character polylines static void DrawGraphicTextPline( static void DrawGraphicTextPline( EDA_RECT* aClipBox, EDA_RECT* aClipBox, wxDC* aDC, wxDC* aDC, EDA_COLOR_T aColor, EDA_COLOR_T aColor, int aWidth, int aWidth, Loading @@ -204,6 +213,7 @@ static void DrawGraphicTextPline( if( aPlotter ) if( aPlotter ) { { aPlotter->MoveTo( coord[0] ); aPlotter->MoveTo( coord[0] ); for( int ik = 1; ik < point_count; ik++ ) for( int ik = 1; ik < point_count; ik++ ) { { aPlotter->LineTo( coord[ik] ); aPlotter->LineTo( coord[ik] ); Loading Loading @@ -304,6 +314,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, italic_reverse = true; italic_reverse = true; unsigned char_count = NegableTextLength( aText ); unsigned char_count = NegableTextLength( aText ); if( char_count == 0 ) if( char_count == 0 ) return; return; Loading @@ -328,10 +339,13 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( xc < x0 ) if( xc < x0 ) return; return; if( yc < y0 ) if( yc < y0 ) return; return; if( xc > xm ) if( xc > xm ) return; return; if( yc > ym ) if( yc > ym ) return; return; } } Loading Loading @@ -404,6 +418,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( aItalic ) if( aItalic ) { { overbar_italic_comp = OverbarPositionY( 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; Loading @@ -412,16 +427,19 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, else else { { overbar_italic_comp = 0; overbar_italic_comp = 0; }; } ; int overbars = 0; /* Number of '~' seen (except '~~') */ int overbars = 0; /* Number of '~' seen (except '~~') */ ptr = 0; /* ptr = text index */ ptr = 0; /* ptr = text index */ while( ptr < char_count ) while( ptr < char_count ) { { if( aText[ptr + overbars] == '~' ) if( aText[ptr + overbars] == '~' ) { { if( ptr + overbars + 1 < aText.length() && if( ptr + overbars + 1 < aText.length() aText[ptr + overbars + 1] == '~' ) /* '~~' draw as '~' */ && aText[ptr + overbars + 1] == '~' ) /* '~~' draw as '~' */ ptr++; // skip first '~' char and draw second ptr++; // skip first '~' char and draw second else else Loading @@ -431,7 +449,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( overbars & 1 ) // odd overbars count 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 -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v, aWidth ); Loading @@ -439,17 +457,18 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, } } else else { { /* Ending the overbar */ // Ending the overbar 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 -= OverbarPositionY( 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 DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, sketch_mode, 2, coord, aCallback, aPlotter ); sketch_mode, 2, coord, aCallback, aPlotter ); } } continue; /* Skip ~ processing */ continue; /* Skip ~ processing */ } } } } Loading @@ -457,15 +476,17 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, AsciiCode = aText.GetChar( ptr + overbars ); AsciiCode = aText.GetChar( ptr + overbars ); const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* ptcar = GetHersheyShapeDescription( AsciiCode ); /* Get metrics */ // Get metrics int xsta = *ptcar++ - 'R'; int xsta = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; int point_count = 0; int point_count = 0; bool endcar = false; bool endcar = false; while( !endcar ) while( !endcar ) { { int hc1, hc2; int hc1, hc2; hc1 = *ptcar++; hc1 = *ptcar++; if( hc1 ) if( hc1 ) { { hc2 = *ptcar++; hc2 = *ptcar++; Loading @@ -477,8 +498,11 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, hc2 = 'R'; hc2 = 'R'; endcar = true; endcar = true; } } // Do the Hershey decode thing: coordinates values are coded as <value> + 'R' hc1 -= 'R'; hc2 -= 'R'; // Do the Hershey decode thing: // coordinates values are coded as <value> + 'R' hc1 -= 'R'; hc2 -= 'R'; /* Pen up request */ /* Pen up request */ if( hc1 == -50 && hc2 == 0 ) if( hc1 == -50 && hc2 == 0 ) Loading @@ -487,33 +511,36 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, { { if( aWidth <= 1 ) if( aWidth <= 1 ) aWidth = 0; aWidth = 0; DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, sketch_mode, point_count, coord, sketch_mode, point_count, coord, aCallback, aPlotter ); aCallback, aPlotter ); } } point_count = 0; point_count = 0; } } else else { { wxPoint currpoint; wxPoint currpoint; hc1 -= xsta; hc2 -= 11; /* Align the midpoint */ hc1 -= xsta; hc2 -= 11; // Align the midpoint hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); // To simulate an italic font, add a x offset depending on the y offset // To simulate an italic font, // add a x offset depending on the y offset if( aItalic ) if( aItalic ) hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); currpoint.x = hc1 + current_char_pos.x; currpoint.x = hc1 + current_char_pos.x; currpoint.y = hc2 + current_char_pos.y; currpoint.y = hc2 + current_char_pos.y; RotatePoint( &currpoint, aPos, aOrient ); RotatePoint( &currpoint, aPos, aOrient ); coord[point_count] = currpoint; coord[point_count] = currpoint; if( point_count < BUF_SIZE - 1 ) if( point_count < BUF_SIZE - 1 ) point_count++; point_count++; } } } } // end draw 1 char /* end draw 1 char */ ptr++; ptr++; Loading pcbnew/netlist_reader_common.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -236,6 +236,7 @@ void NETLIST_READER::TestFootprintsMatchingAndExchange() break; break; } } } } if( cmp_info == NULL ) // not found in netlist if( cmp_info == NULL ) // not found in netlist continue; continue; Loading Loading @@ -296,9 +297,11 @@ int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & a int padcount = 0; int padcount = 0; MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule ); MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule ); if( module ) if( module ) { { D_PAD * pad = module->FindPadByName( aPadname ); D_PAD * pad = module->FindPadByName( aPadname ); if( pad ) if( pad ) { { padcount++; padcount++; Loading @@ -316,6 +319,7 @@ int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & a } } return padcount; return padcount; } } if( m_messageWindow ) if( m_messageWindow ) { { wxString msg; wxString msg; Loading pcbnew/netlist_reader_kicad.cpp +84 −42 Original line number Original line Diff line number Diff line Loading @@ -173,21 +173,35 @@ void NETLIST_READER_KICAD_PARSER::SkipCurrent() throw( IO_ERROR, PARSE_ERROR ) void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR ) throw( IO_ERROR, PARSE_ERROR ) { { wxString text; int plevel = 0; // the count of ')' to read and end of file, // after parsing all sections while( ( token = NextTok() ) != T_EOF ) while( ( token = NextTok() ) != T_EOF ) { { if( token == T_LEFT ) if( token == T_LEFT ) token = NextTok(); token = NextTok(); if( token == T_components ) switch( token ) { { // The section comp starts here. case T_export: // The netlist starts here. // nothing to do here, // just increment the count of ')' to read and end of file plevel++; break; case T_version: // The netlist starts here. // version id not yet used: read it but does not use it NextTok(); NeedRIGHT(); break; case T_components: // The section comp starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) token = NextTok(); token = NextTok(); if( token == T_comp ) if( token == T_comp ) // A comp section if found. Read it { { // A comp section if found. Read it COMPONENT_INFO* cmp_info = ParseComp(); COMPONENT_INFO* cmp_info = ParseComp(); netlist_reader->AddModuleInfo( cmp_info ); netlist_reader->AddModuleInfo( cmp_info ); } } Loading @@ -197,11 +211,9 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) // Load new footprints // Load new footprints netlist_reader->InitializeModules(); netlist_reader->InitializeModules(); netlist_reader->TestFootprintsMatchingAndExchange(); netlist_reader->TestFootprintsMatchingAndExchange(); } break; if( token == T_nets ) case T_nets: // The section nets starts here. { // The section nets starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) Loading @@ -212,11 +224,11 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) ParseNet( aBrd ); ParseNet( aBrd ); } } } } } break; if( token == T_libparts && netlist_reader->ReadLibpartSectionOpt() ) case T_libparts: // The section libparts starts here. if( netlist_reader->ReadLibpartSectionOpt() ) { { // The section libparts starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) Loading @@ -228,6 +240,36 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) } } } } } } else SkipCurrent(); break; case T_libraries: // The section libraries starts here. // List of libraries in use. // Not used here, just skip it SkipCurrent(); break; case T_design: // The section design starts here. // Not used (mainly thet are comments), just skip it SkipCurrent(); break; case T_RIGHT: // The closing parenthesis of the file. // Not used (mainly thet are comments), just skip it plevel--; break; default: SkipCurrent(); break; } } if( plevel != 0 ) { wxLogDebug(wxT("NETLIST_READER_KICAD_PARSER::Parse(): bad parenthesis count (count = %d"), plevel ); } } } } Loading Loading
CMakeLists.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ option(KICAD_STABLE_VERSION ) ) option(KICAD_TESTING_VERSION option(KICAD_TESTING_VERSION "set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)" "set this option to ON to build the testing version of KICAD. mainly used to set version ID (default OFF)" ) ) option(KICAD_SCRIPTING option(KICAD_SCRIPTING Loading
common/drawtxt.cpp +118 −91 Original line number Original line Diff line number Diff line Loading @@ -40,13 +40,15 @@ #include <class_base_screen.h> #include <class_base_screen.h> #define EDA_DRAWBASE #include <newstroke_font.h> #include <newstroke_font.h> #include <plot_common.h> #include <plot_common.h> /* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name) /* factor used to calculate actual size of shapes from hershey fonts * Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter * (could be adjusted depending on the font name) * Of course some shapes can be bigger or smaller than the vertical char size parameter * Its value is choosen in order to have letters like M, P .. vertical size * equal to the vertical char size parameter * Of course some shapes can be bigger or smaller than the vertical char size * parameter */ */ #define HERSHEY_SCALE_FACTOR 1 / 21.0 #define HERSHEY_SCALE_FACTOR 1 / 21.0 double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; Loading @@ -59,6 +61,7 @@ int OverbarPositionY( int size_v, int thickness ) return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) ); 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 Loading Loading @@ -90,6 +93,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold ) if( penSize > maxWidth ) if( penSize > maxWidth ) penSize = maxWidth; penSize = maxWidth; return penSize; return penSize; } } Loading @@ -112,17 +116,19 @@ int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold ) /** /** * Function NegableTextLength * Function NegableTextLength * Return the text length of a negable string, excluding the ~ markers */ * Return the text length (char count) of a negable string, * excluding the ~ markers */ int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText ) { { int char_count = aText.length(); int char_count = aText.length(); /* Fix the character count, removing the ~ found */ // Fix the character count, removing the ~ found for( int i = char_count - 1; i >= 0; i-- ) for( int i = char_count - 1; i >= 0; i-- ) { { if( aText[i] == '~' ) if( aText[i] == '~' ) { { /* '~~' draw as '~' and count as two chars */ // '~~' draw as '~' and count as two chars if( i > 0 && aText[i - 1] == '~' ) if( i > 0 && aText[i - 1] == '~' ) i--; i--; else else Loading @@ -142,13 +148,15 @@ int NegableTextLength( const wxString& aText ) */ */ static const char* GetHersheyShapeDescription( int AsciiCode ) static const char* GetHersheyShapeDescription( int AsciiCode ) { { /* calculate font length */ // calculate font length int font_length_max = newstroke_font_bufsize; int font_length_max = newstroke_font_bufsize; if( AsciiCode >= (32 + font_length_max) ) if( AsciiCode >= (32 + font_length_max) ) AsciiCode = '?'; AsciiCode = '?'; if( AsciiCode < 32 ) if( AsciiCode < 32 ) AsciiCode = 32; /* Clamp control chars */ AsciiCode = 32; /* Clamp control chars */ AsciiCode -= 32; AsciiCode -= 32; return newstroke_font[AsciiCode]; return newstroke_font[AsciiCode]; Loading @@ -162,36 +170,37 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo for( int i = 0; i < char_count; i++ ) for( int i = 0; i < char_count; i++ ) { { int AsciiCode = aText[i]; int asciiCode = aText[i]; /* Skip the negation marks /* Skip the negation marks * and first '~' char of '~~' * and first '~' char of '~~' * ('~~' draw as '~') */ * ('~~' draw as '~') if( AsciiCode == '~' ) */ if( asciiCode == '~' ) { { if( i > 0 && aText[i - 1] != '~' ) if( i == 0 || aText[i - 1] != '~' ) continue; continue; } } const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* shape_ptr = GetHersheyShapeDescription( asciiCode ); /* Get metrics */ // Get metrics int xsta = *ptcar++ - 'R'; int xsta = *shape_ptr++ - 'R'; int xsto = *ptcar++ - 'R'; int xsto = *shape_ptr++ - 'R'; tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); } } /* Italic correction, 1/8em */ // For italic correction, add 1/8 size if( aItalic ) if( aItalic ) { { tally += KiROUND( aXSize * 0.125 ); tally += KiROUND( aXSize * 0.125 ); } } return tally; return tally; } } /* Helper function for drawing character polygons */ // Helper function for drawing character polylines static void DrawGraphicTextPline( static void DrawGraphicTextPline( EDA_RECT* aClipBox, EDA_RECT* aClipBox, wxDC* aDC, wxDC* aDC, EDA_COLOR_T aColor, EDA_COLOR_T aColor, int aWidth, int aWidth, Loading @@ -204,6 +213,7 @@ static void DrawGraphicTextPline( if( aPlotter ) if( aPlotter ) { { aPlotter->MoveTo( coord[0] ); aPlotter->MoveTo( coord[0] ); for( int ik = 1; ik < point_count; ik++ ) for( int ik = 1; ik < point_count; ik++ ) { { aPlotter->LineTo( coord[ik] ); aPlotter->LineTo( coord[ik] ); Loading Loading @@ -304,6 +314,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, italic_reverse = true; italic_reverse = true; unsigned char_count = NegableTextLength( aText ); unsigned char_count = NegableTextLength( aText ); if( char_count == 0 ) if( char_count == 0 ) return; return; Loading @@ -328,10 +339,13 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( xc < x0 ) if( xc < x0 ) return; return; if( yc < y0 ) if( yc < y0 ) return; return; if( xc > xm ) if( xc > xm ) return; return; if( yc > ym ) if( yc > ym ) return; return; } } Loading Loading @@ -404,6 +418,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( aItalic ) if( aItalic ) { { overbar_italic_comp = OverbarPositionY( 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; Loading @@ -412,16 +427,19 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, else else { { overbar_italic_comp = 0; overbar_italic_comp = 0; }; } ; int overbars = 0; /* Number of '~' seen (except '~~') */ int overbars = 0; /* Number of '~' seen (except '~~') */ ptr = 0; /* ptr = text index */ ptr = 0; /* ptr = text index */ while( ptr < char_count ) while( ptr < char_count ) { { if( aText[ptr + overbars] == '~' ) if( aText[ptr + overbars] == '~' ) { { if( ptr + overbars + 1 < aText.length() && if( ptr + overbars + 1 < aText.length() aText[ptr + overbars + 1] == '~' ) /* '~~' draw as '~' */ && aText[ptr + overbars + 1] == '~' ) /* '~~' draw as '~' */ ptr++; // skip first '~' char and draw second ptr++; // skip first '~' char and draw second else else Loading @@ -431,7 +449,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( overbars & 1 ) // odd overbars count 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 -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v, aWidth ); Loading @@ -439,17 +457,18 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, } } else else { { /* Ending the overbar */ // Ending the overbar 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 -= OverbarPositionY( 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 DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, sketch_mode, 2, coord, aCallback, aPlotter ); sketch_mode, 2, coord, aCallback, aPlotter ); } } continue; /* Skip ~ processing */ continue; /* Skip ~ processing */ } } } } Loading @@ -457,15 +476,17 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, AsciiCode = aText.GetChar( ptr + overbars ); AsciiCode = aText.GetChar( ptr + overbars ); const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* ptcar = GetHersheyShapeDescription( AsciiCode ); /* Get metrics */ // Get metrics int xsta = *ptcar++ - 'R'; int xsta = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; int point_count = 0; int point_count = 0; bool endcar = false; bool endcar = false; while( !endcar ) while( !endcar ) { { int hc1, hc2; int hc1, hc2; hc1 = *ptcar++; hc1 = *ptcar++; if( hc1 ) if( hc1 ) { { hc2 = *ptcar++; hc2 = *ptcar++; Loading @@ -477,8 +498,11 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, hc2 = 'R'; hc2 = 'R'; endcar = true; endcar = true; } } // Do the Hershey decode thing: coordinates values are coded as <value> + 'R' hc1 -= 'R'; hc2 -= 'R'; // Do the Hershey decode thing: // coordinates values are coded as <value> + 'R' hc1 -= 'R'; hc2 -= 'R'; /* Pen up request */ /* Pen up request */ if( hc1 == -50 && hc2 == 0 ) if( hc1 == -50 && hc2 == 0 ) Loading @@ -487,33 +511,36 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, { { if( aWidth <= 1 ) if( aWidth <= 1 ) aWidth = 0; aWidth = 0; DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, sketch_mode, point_count, coord, sketch_mode, point_count, coord, aCallback, aPlotter ); aCallback, aPlotter ); } } point_count = 0; point_count = 0; } } else else { { wxPoint currpoint; wxPoint currpoint; hc1 -= xsta; hc2 -= 11; /* Align the midpoint */ hc1 -= xsta; hc2 -= 11; // Align the midpoint hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); // To simulate an italic font, add a x offset depending on the y offset // To simulate an italic font, // add a x offset depending on the y offset if( aItalic ) if( aItalic ) hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); currpoint.x = hc1 + current_char_pos.x; currpoint.x = hc1 + current_char_pos.x; currpoint.y = hc2 + current_char_pos.y; currpoint.y = hc2 + current_char_pos.y; RotatePoint( &currpoint, aPos, aOrient ); RotatePoint( &currpoint, aPos, aOrient ); coord[point_count] = currpoint; coord[point_count] = currpoint; if( point_count < BUF_SIZE - 1 ) if( point_count < BUF_SIZE - 1 ) point_count++; point_count++; } } } } // end draw 1 char /* end draw 1 char */ ptr++; ptr++; Loading
pcbnew/netlist_reader_common.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -236,6 +236,7 @@ void NETLIST_READER::TestFootprintsMatchingAndExchange() break; break; } } } } if( cmp_info == NULL ) // not found in netlist if( cmp_info == NULL ) // not found in netlist continue; continue; Loading Loading @@ -296,9 +297,11 @@ int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & a int padcount = 0; int padcount = 0; MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule ); MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule ); if( module ) if( module ) { { D_PAD * pad = module->FindPadByName( aPadname ); D_PAD * pad = module->FindPadByName( aPadname ); if( pad ) if( pad ) { { padcount++; padcount++; Loading @@ -316,6 +319,7 @@ int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & a } } return padcount; return padcount; } } if( m_messageWindow ) if( m_messageWindow ) { { wxString msg; wxString msg; Loading
pcbnew/netlist_reader_kicad.cpp +84 −42 Original line number Original line Diff line number Diff line Loading @@ -173,21 +173,35 @@ void NETLIST_READER_KICAD_PARSER::SkipCurrent() throw( IO_ERROR, PARSE_ERROR ) void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR ) throw( IO_ERROR, PARSE_ERROR ) { { wxString text; int plevel = 0; // the count of ')' to read and end of file, // after parsing all sections while( ( token = NextTok() ) != T_EOF ) while( ( token = NextTok() ) != T_EOF ) { { if( token == T_LEFT ) if( token == T_LEFT ) token = NextTok(); token = NextTok(); if( token == T_components ) switch( token ) { { // The section comp starts here. case T_export: // The netlist starts here. // nothing to do here, // just increment the count of ')' to read and end of file plevel++; break; case T_version: // The netlist starts here. // version id not yet used: read it but does not use it NextTok(); NeedRIGHT(); break; case T_components: // The section comp starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) token = NextTok(); token = NextTok(); if( token == T_comp ) if( token == T_comp ) // A comp section if found. Read it { { // A comp section if found. Read it COMPONENT_INFO* cmp_info = ParseComp(); COMPONENT_INFO* cmp_info = ParseComp(); netlist_reader->AddModuleInfo( cmp_info ); netlist_reader->AddModuleInfo( cmp_info ); } } Loading @@ -197,11 +211,9 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) // Load new footprints // Load new footprints netlist_reader->InitializeModules(); netlist_reader->InitializeModules(); netlist_reader->TestFootprintsMatchingAndExchange(); netlist_reader->TestFootprintsMatchingAndExchange(); } break; if( token == T_nets ) case T_nets: // The section nets starts here. { // The section nets starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) Loading @@ -212,11 +224,11 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) ParseNet( aBrd ); ParseNet( aBrd ); } } } } } break; if( token == T_libparts && netlist_reader->ReadLibpartSectionOpt() ) case T_libparts: // The section libparts starts here. if( netlist_reader->ReadLibpartSectionOpt() ) { { // The section libparts starts here. while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT ) { { if( token == T_LEFT ) if( token == T_LEFT ) Loading @@ -228,6 +240,36 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) } } } } } } else SkipCurrent(); break; case T_libraries: // The section libraries starts here. // List of libraries in use. // Not used here, just skip it SkipCurrent(); break; case T_design: // The section design starts here. // Not used (mainly thet are comments), just skip it SkipCurrent(); break; case T_RIGHT: // The closing parenthesis of the file. // Not used (mainly thet are comments), just skip it plevel--; break; default: SkipCurrent(); break; } } if( plevel != 0 ) { wxLogDebug(wxT("NETLIST_READER_KICAD_PARSER::Parse(): bad parenthesis count (count = %d"), plevel ); } } } } Loading