From 0acdd9f02e06bfc81cddc9ee06b8736f0bcdf48c Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 27 Nov 2017 10:18:30 -0500 Subject: [PATCH] Remove obsolete symbol library item load code. --- eeschema/class_libentry.cpp | 306 ------------------------------------ eeschema/class_libentry.h | 13 -- eeschema/lib_arc.cpp | 52 ------ eeschema/lib_arc.h | 4 +- eeschema/lib_bezier.cpp | 62 -------- eeschema/lib_bezier.h | 4 +- eeschema/lib_circle.cpp | 24 --- eeschema/lib_circle.h | 4 +- eeschema/lib_draw_item.h | 6 +- eeschema/lib_field.cpp | 126 --------------- eeschema/lib_field.h | 4 +- eeschema/lib_pin.cpp | 217 +------------------------ eeschema/lib_pin.h | 6 +- eeschema/lib_polyline.cpp | 62 -------- eeschema/lib_polyline.h | 4 +- eeschema/lib_rectangle.cpp | 25 --- eeschema/lib_rectangle.h | 4 +- eeschema/lib_text.cpp | 95 ----------- eeschema/lib_text.h | 4 +- 19 files changed, 13 insertions(+), 1009 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index b6f46f8c2d..db581166a8 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -833,312 +833,6 @@ bool LIB_PART::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_PART::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - int unused; - char* p; - char* componentName; - char* prefix = NULL; - char* line; - - bool result; - wxString Msg; - - line = aLineReader.Line(); - - p = strtok( line, " \t\r\n" ); - - if( strcmp( p, "DEF" ) != 0 ) - { - aErrorMsg.Printf( wxT( "DEF command expected in line %d, aborted." ), - aLineReader.LineNumber() ); - return false; - } - - // Read DEF line: - char drawnum = 0; - char drawname = 0; - - if( ( componentName = strtok( NULL, " \t\n" ) ) == NULL // Part name: - || ( prefix = strtok( NULL, " \t\n" ) ) == NULL // Prefix name: - || ( p = strtok( NULL, " \t\n" ) ) == NULL // NumOfPins: - || sscanf( p, "%d", &unused ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL // TextInside: - || sscanf( p, "%d", &m_pinNameOffset ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL // DrawNums: - || sscanf( p, "%c", &drawnum ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL // DrawNums: - || sscanf( p, "%c", &drawname ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL // m_unitCount: - || sscanf( p, "%d", &m_unitCount ) != 1 ) - { - aErrorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), - aLineReader.LineNumber() ); - - while( (line = aLineReader.ReadLine()) != NULL ) - { - p = strtok( line, " \t\n" ); - - if( p && strcasecmp( p, "ENDDEF" ) == 0 ) - break; - } - - return false; - } - - // Ensure m_unitCount is >= 1 (could be read as 0 in old libraries) - if( m_unitCount < 1 ) - m_unitCount = 1; - - m_showPinNumbers = ( drawnum == 'N' ) ? false : true; - m_showPinNames = ( drawname == 'N' ) ? false : true; - - // Copy part name and prefix. - if( componentName[0] != '~' ) - { - SetName( FROM_UTF8( componentName ) ); - } - else - { - SetName( FROM_UTF8( &componentName[1] ) ); - GetValueField().SetVisible( false ); - } - - LIB_FIELD& reference = GetReferenceField(); - - if( strcmp( prefix, "~" ) == 0 ) - { - reference.Empty(); - reference.SetVisible( false ); - } - else - { - reference.SetText( FROM_UTF8( prefix ) ); - } - - // Copy optional infos - if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' ) - m_unitsLocked = true; - - if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' ) - m_options = ENTRY_POWER; - - // Read next lines, until "ENDDEF" is found - while( ( line = aLineReader.ReadLine() ) != NULL ) - { - p = strtok( line, " \t\r\n" ); - - // This is the error flag ( if an error occurs, result = false) - result = true; - - if( *line == '#' ) // a comment - continue; - - if( p == NULL ) // empty line - continue; - - if( line[0] == 'T' && line[1] == 'i' ) - result = LoadDateAndTime( aLineReader ); - else if( *line == 'F' ) - result = LoadField( aLineReader, Msg ); - else if( strcmp( p, "ENDDEF" ) == 0 ) // End of component description - goto ok; - else if( strcmp( p, "DRAW" ) == 0 ) - result = LoadDrawEntries( aLineReader, Msg ); - else if( strncmp( p, "ALIAS", 5 ) == 0 ) - { - p = strtok( NULL, "\r\n" ); - result = LoadAliases( p, aErrorMsg ); - } - else if( strncmp( p, "$FPLIST", 5 ) == 0 ) - result = LoadFootprints( aLineReader, Msg ); - - // End line or block analysis: test for an error - if( !result ) - { - if( Msg.IsEmpty() ) - aErrorMsg.Printf( wxT( "error occurred at line %d " ), aLineReader.LineNumber() ); - else - aErrorMsg.Printf( wxT( "error <%s> occurred at line %d " ), - GetChars( Msg ), aLineReader.LineNumber() ); - - return false; - } - } - - return false; - -ok: - // If we are here, this part is O.k. - put it in: - - return true; -} - - -bool LIB_PART::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char* line; - LIB_ITEM* newEntry = NULL; - - while( true ) - { - if( !( line = aLineReader.ReadLine() ) ) - { - aErrorMsg = wxT( "file ended prematurely loading component draw element" ); - return false; - } - - if( strncmp( line, "ENDDRAW", 7 ) == 0 ) - break; - - newEntry = NULL; - - switch( line[0] ) - { - case 'A': // Arc - newEntry = ( LIB_ITEM* ) new LIB_ARC( this ); - break; - - case 'C': // Circle - newEntry = ( LIB_ITEM* ) new LIB_CIRCLE( this ); - break; - - case 'T': // Text - newEntry = ( LIB_ITEM* ) new LIB_TEXT( this ); - break; - - case 'S': // Square - newEntry = ( LIB_ITEM* ) new LIB_RECTANGLE( this ); - break; - - case 'X': // Pin Description - newEntry = ( LIB_ITEM* ) new LIB_PIN( this ); - break; - - case 'P': // Polyline - newEntry = ( LIB_ITEM* ) new LIB_POLYLINE( this ); - break; - - case 'B': // Bezier Curves - newEntry = ( LIB_ITEM* ) new LIB_BEZIER( this ); - break; - - case '#': // Comment - continue; - - case '\n': - case '\r': - case 0: // empty line - continue; - - default: - aErrorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] ); - return false; - } - - if( !newEntry->Load( aLineReader, aErrorMsg ) ) - { - aErrorMsg.Printf( wxT( "error '%s' in DRAW command %c" ), - GetChars( aErrorMsg ), line[0] ); - delete newEntry; - - // Flush till end of draw section - do - { - if( !aLineReader.ReadLine() ) - { - aErrorMsg = wxT( "file ended prematurely while attempting " - "to flush to end of drawing section." ); - return false; - } - } while( strncmp( line, "ENDDRAW", 7 ) != 0 ); - - return false; - } - else - { - m_drawings.push_back( newEntry ); - } - } - - return true; -} - - -bool LIB_PART::LoadAliases( char* aLine, wxString& aErrorMsg ) -{ - char* text = strtok( aLine, " \t\r\n" ); - - while( text ) - { - m_aliases.push_back( new LIB_ALIAS( FROM_UTF8( text ), this ) ); - text = strtok( NULL, " \t\r\n" ); - } - - return true; -} - - -bool LIB_PART::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - LIB_FIELD* field = new LIB_FIELD( this ); - - if( !field->Load( aLineReader, aErrorMsg ) ) - { - delete field; - return false; - } - - if( (unsigned) field->GetId() < MANDATORY_FIELDS ) - { - LIB_FIELD* fixedField = GetField( field->GetId() ); - - // this will fire only if somebody broke a constructor or editor. - // MANDATORY_FIELDS are always present in ram resident components, no - // exceptions, and they always have their names set, even fixed fields. - wxASSERT( fixedField ); - - *fixedField = *field; - - if( field->GetId() == VALUE ) - SetName( field->GetText() ); - - delete field; - } - else - { - m_drawings.push_back( field ); - } - - return true; -} - - -bool LIB_PART::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char* line; - char* p; - - while( true ) - { - if( !( line = aLineReader.ReadLine() ) ) - { - aErrorMsg = wxT( "file ended prematurely while loading footprints" ); - return false; - } - - p = strtok( line, " \t\r\n" ); - - if( strcasecmp( p, "$ENDFPLIST" ) == 0 ) - break; - - m_FootprintList.Add( FROM_UTF8( p ) ); - } - - return true; -} - - const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const { EDA_RECT bBox; diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 6c2f1ee1ed..a819074546 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -372,19 +372,6 @@ public: */ bool Save( OUTPUTFORMATTER& aFormatter ); - /** - * Load part definition from \a aReader. - * - * @param aReader A LINE_READER object to load file from. - * @param aErrorMsg - Description of error on load failure. - * @return True if the load was successful, false if there was an error. - */ - bool Load( LINE_READER& aReader, wxString& aErrorMsg ); - bool LoadField( LINE_READER& aReader, wxString& aErrorMsg ); - bool LoadDrawEntries( LINE_READER& aReader, wxString& aErrorMsg ); - bool LoadAliases( char* aLine, wxString& aErrorMsg ); - bool LoadFootprints( LINE_READER& aReader, wxString& aErrorMsg ); - bool IsPower() const { return m_options == ENTRY_POWER; } bool IsNormal() const { return m_options == ENTRY_NORMAL; } diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 3e89354068..18cec21649 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -123,58 +123,6 @@ bool LIB_ARC::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - int startx, starty, endx, endy, cnt; - char tmp[256] = ""; - char* line = (char*) aLineReader; - - cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %d %255s %d %d %d %d", - &m_Pos.x, &m_Pos.y, &m_Radius, &m_t1, &m_t2, &m_Unit, - &m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy ); - if( cnt < 8 ) - { - aErrorMsg.Printf( _( "Arc only had %d parameters of the required 8" ), cnt ); - return false; - } - - if( tmp[0] == 'F' ) - m_Fill = FILLED_SHAPE; - - if( tmp[0] == 'f' ) - m_Fill = FILLED_WITH_BG_BODYCOLOR; - - NORMALIZE_ANGLE_POS( m_t1 ); - NORMALIZE_ANGLE_POS( m_t2 ); - - // Actual Coordinates of arc ends are read from file - if( cnt >= 13 ) - { - m_ArcStart.x = startx; - m_ArcStart.y = starty; - m_ArcEnd.x = endx; - m_ArcEnd.y = endy; - } - else - { - // Actual Coordinates of arc ends are not read from file - // (old library), calculate them - m_ArcStart.x = m_Radius; - m_ArcStart.y = 0; - m_ArcEnd.x = m_Radius; - m_ArcEnd.y = 0; - RotatePoint( &m_ArcStart.x, &m_ArcStart.y, -m_t1 ); - m_ArcStart.x += m_Pos.x; - m_ArcStart.y += m_Pos.y; - RotatePoint( &m_ArcEnd.x, &m_ArcEnd.y, -m_t2 ); - m_ArcEnd.x += m_Pos.x; - m_ArcEnd.y += m_Pos.y; - } - - return true; -} - - bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) const { int mindist = GetPenSize() / 2; diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 2c870c9c3d..dac11e3e4c 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -94,8 +94,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - bool HitTest( const wxPoint& aPosition ) const override; bool HitTest( const wxPoint& aPosition, int aThreshold, const TRANSFORM& aTransform ) const override; diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index fbbca13193..788a852d49 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -66,68 +66,6 @@ bool LIB_BEZIER::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_BEZIER::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char* p; - int i, ccount = 0; - wxPoint pt; - char* line = (char*) aLineReader; - - i = sscanf( line + 2, "%d %d %d %d", &ccount, &m_Unit, &m_Convert, &m_Width ); - - if( i !=4 ) - { - aErrorMsg.Printf( _( "Bezier only had %d parameters of the required 4" ), i ); - return false; - } - - if( ccount <= 0 ) - { - aErrorMsg.Printf( _( "Bezier count parameter %d is invalid" ), ccount ); - return false; - } - - strtok( line + 2, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); - - for( i = 0; i < ccount; i++ ) - { - p = strtok( NULL, " \t\n" ); - - if( sscanf( p, "%d", &pt.x ) != 1 ) - { - aErrorMsg.Printf( _( "Bezier point %d X position not defined" ), i ); - return false; - } - - p = strtok( NULL, " \t\n" ); - - if( sscanf( p, "%d", &pt.y ) != 1 ) - { - aErrorMsg.Printf( _( "Bezier point %d Y position not defined" ), i ); - return false; - } - - m_BezierPoints.push_back( pt ); - } - - m_Fill = NO_FILL; - - if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) - { - if( p[0] == 'F' ) - m_Fill = FILLED_SHAPE; - - if( p[0] == 'f' ) - m_Fill = FILLED_WITH_BG_BODYCOLOR; - } - - return true; -} - - EDA_ITEM* LIB_BEZIER::Clone() const { return new LIB_BEZIER( *this ); diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 850706b658..5a8604e9ea 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -61,8 +61,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - void AddPoint( const wxPoint& aPoint ) { m_BezierPoints.push_back( aPoint ); } void SetOffset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 01c6074c5d..622214c7bf 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -64,30 +64,6 @@ bool LIB_CIRCLE::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char tmp[256]; - char* line = (char*) aLineReader; - - int cnt = sscanf( line + 2, "%d %d %d %d %d %d %255s", &m_Pos.x, &m_Pos.y, - &m_Radius, &m_Unit, &m_Convert, &m_Width, tmp ); - - if( cnt < 6 ) - { - aErrorMsg.Printf( _( "Circle only had %d parameters of the required 6" ), cnt ); - return false; - } - - if( tmp[0] == 'F' ) - m_Fill = FILLED_SHAPE; - - if( tmp[0] == 'f' ) - m_Fill = FILLED_WITH_BG_BODYCOLOR; - - return true; -} - - bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) const { int mindist = GetPenSize() / 2; diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index c3da81b7ed..6ec8efc321 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -59,8 +59,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - bool HitTest( const wxPoint& aPosition ) const override; bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override; diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 1e72a85dd6..ab411ae380 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -227,8 +227,6 @@ public: */ virtual bool Save( OUTPUTFORMATTER& aFormatter ) = 0; - virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0; - LIB_PART* GetParent() const { return (LIB_PART *)m_Parent; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 219db866b1..36a650f795 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -154,132 +154,6 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) -{ - int cnt; - int x, y, size; - char textOrient; - char textVisible; - char textHJustify; - char textVJustify[256]; - - char* line = (char*) aLineReader; - char* limit = line + aLineReader.Length(); - - if( sscanf( line + 1, "%d", &m_id ) != 1 || m_id < 0 ) - { - errorMsg = wxT( "invalid field header" ); - return false; - } - - // Caller did a strtok(), which inserts a nul, so next few bytes are ugly: - // digit(s), a nul, some whitespace, then a double quote. - while( line < limit && *line != '"' ) - line++; - - if( line == limit ) - return false; - - line += ReadDelimitedText( &m_Text, line ); - - // Doctor the *.lib file field which has a "~" in blank fields. New saves will - // not save like this, and eventually these two lines can be removed. - if( m_Text.size() == 1 && m_Text[0] == wxChar( '~' ) ) - m_Text.clear(); - - memset( textVJustify, 0, sizeof( textVJustify ) ); - - cnt = sscanf( line, " %d %d %d %c %c %c %255s", &x, &y, &size, - &textOrient, &textVisible, &textHJustify, textVJustify ); - - if( cnt < 5 ) - { - errorMsg.Printf( wxT( "field %d does not have the correct number of parameters" ), - m_id ); - return false; - } - - SetTextPos( wxPoint( x, y ) ); - SetTextSize( wxSize( size, size ) ); - - if( textOrient == 'H' ) - SetTextAngle( TEXT_ANGLE_HORIZ ); - else if( textOrient == 'V' ) - SetTextAngle( TEXT_ANGLE_VERT ); - else - { - errorMsg.Printf( wxT( "field %d text orientation parameter <%c> is not valid" ), - textOrient ); - return false; - } - - if( textVisible == 'V' ) - SetVisible( true ); - else if( textVisible == 'I' ) - SetVisible( false ); - else - { - errorMsg.Printf( wxT( "field %d text visible parameter <%c> is not valid" ), - textVisible ); - return false; - } - - SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - - if( cnt >= 6 ) - { - if( textHJustify == 'C' ) - SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - else if( textHJustify == 'L' ) - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - else if( textHJustify == 'R' ) - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - else - { - errorMsg.Printf( - wxT( "field %d text horizontal justification parameter <%c> is not valid" ), - textHJustify ); - return false; - } - - if( textVJustify[0] == 'C' ) - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - else if( textVJustify[0] == 'B' ) - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - else if( textVJustify[0] == 'T' ) - SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - else - { - errorMsg.Printf( - wxT( "field %d text vertical justification parameter <%c> is not valid" ), - textVJustify[0] ); - return false; - } - - if( textVJustify[1] == 'I' ) // Italic - SetItalic( true ); - if( textVJustify[2] == 'B' ) // Bold - SetBold( true ); - } - - // fields in RAM must always have names. - if( (unsigned) m_id < MANDATORY_FIELDS ) - { - // Fields in RAM must always have names, because we are trying to get - // less dependent on field ids and more dependent on names. - // Plus assumptions are made in the field editors. - m_name = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); - } - else - { - ReadDelimitedText( &m_name, line ); - } - - return true; -} - - int LIB_FIELD::GetPenSize() const { return GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index d2882e24d1..ba3c61d667 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -141,8 +141,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& errorMsg ) override; - /** * Copy parameters of this field to another field. Pointers are not copied. * diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index c8e0563b19..1743702fd4 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -679,219 +679,6 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter ) #include -bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char pinAttrs[64]; - char pinOrient[64]; - char pinType[64]; - - *pinAttrs = 0; - - // We cannot use sscanf, at least on Windows, to parse the pin description. - // The reason is the pin name is free, and use UTF8 encoding. - // We encourtered issues (Windows specific) to read this name for some UTF8 - // cyrillic codes - // So, read the pin name (and num) after conversion from UTF8, and read the others - // parameters (in ASCII) using sscanf - - // the full line starts by "X ". The pin data starts at line + 2. - wxString utf8line = FROM_UTF8( aLineReader.Line() + 2 ); - wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) ); - int prms_count = tokenizer.CountTokens(); - - if( prms_count < 11 ) - { - aErrorMsg.Printf( wxT( "pin had %d parameters of the required 11 or 12" ), prms_count ); - return false; - } - - // Extract the pinName (UTF8 encoded) - m_name = tokenizer.GetNextToken(); - - wxString tmp; - - // Extract the pinName (UTF8 encoded accepted, but should be only ASCII8.) - tmp = tokenizer.GetNextToken(); - SetNumber( tmp ); - - // Read other parameters, in pure ASCII - char line[1024]; - tmp = tokenizer.GetString(); - - unsigned len = tmp.Length(); - - if( len >= sizeof( line ) ) // Should not occur. - len = sizeof( line) - 1; - - strncpy( line, TO_UTF8( tmp ), len ); - line[len] = 0; - - int cnt = sscanf( line, "%d %d %d %63s %d %d %d %d %63s %63s", - &m_position.x, &m_position.y, &m_length, pinOrient, &m_numTextSize, - &m_nameTextSize, &m_Unit, &m_Convert, pinType, pinAttrs ); - - if( cnt != (prms_count - 2) ) - { - aErrorMsg.Printf( wxT( "pin parameters read issue" ) ); - return false; - } - - m_orientation = pinOrient[0] & 255; - - switch( *pinType & 255 ) - { - case 'I': - m_type = PIN_INPUT; - break; - - case 'O': - m_type = PIN_OUTPUT; - break; - - case 'B': - m_type = PIN_BIDI; - break; - - case 'T': - m_type = PIN_TRISTATE; - break; - - case 'P': - m_type = PIN_PASSIVE; - break; - - case 'U': - m_type = PIN_UNSPECIFIED; - break; - - case 'W': - m_type = PIN_POWER_IN; - break; - - case 'w': - m_type = PIN_POWER_OUT; - break; - - case 'C': - m_type = PIN_OPENCOLLECTOR; - break; - - case 'E': - m_type = PIN_OPENEMITTER; - break; - - case 'N': - m_type = PIN_NC; - break; - - default: - aErrorMsg.Printf( wxT( "unknown pin type [%c]" ), *pinType & 255 ); - return false; - } - - if( prms_count >= 12 ) /* Special Symbol defined */ - { - enum - { - INVERTED = 1 << 0, - CLOCK = 1 << 1, - LOWLEVEL_IN = 1 << 2, - LOWLEVEL_OUT = 1 << 3, - FALLING_EDGE = 1 << 4, - NONLOGIC = 1 << 5 - }; - - int flags = 0; - - for( int j = strlen( pinAttrs ); j > 0; ) - { - switch( pinAttrs[--j] ) - { - case '~': - break; - - case 'N': - m_attributes |= PIN_INVISIBLE; - break; - - case 'I': - flags |= INVERTED; - break; - - case 'C': - flags |= CLOCK; - break; - - case 'L': - flags |= LOWLEVEL_IN; - break; - - case 'V': - flags |= LOWLEVEL_OUT; - break; - - case 'F': - flags |= FALLING_EDGE; - break; - - case 'X': - flags |= NONLOGIC; - break; - - default: - aErrorMsg.Printf( wxT( "unknown pin attribute [%c]" ), pinAttrs[j] ); - return false; - } - } - - switch( flags ) - { - case 0: - m_shape = PINSHAPE_LINE; - break; - - case INVERTED: - m_shape = PINSHAPE_INVERTED; - break; - - case CLOCK: - m_shape = PINSHAPE_CLOCK; - break; - - case INVERTED | CLOCK: - m_shape = PINSHAPE_INVERTED_CLOCK; - break; - - case LOWLEVEL_IN: - m_shape = PINSHAPE_INPUT_LOW; - break; - - case LOWLEVEL_IN | CLOCK: - m_shape = PINSHAPE_CLOCK_LOW; - break; - - case LOWLEVEL_OUT: - m_shape = PINSHAPE_OUTPUT_LOW; - break; - - case FALLING_EDGE: - m_shape = PINSHAPE_FALLING_EDGE_CLOCK; - break; - - case NONLOGIC: - m_shape = PINSHAPE_NONLOGIC; - break; - - default: - aErrorMsg.Printf( wxT( "pin attributes do not give a valid pin shape [%s]" ), pinAttrs ); - return false; - } - } - - return true; -} - - int LIB_PIN::GetPenSize() const { return ( m_width == 0 ) ? GetDefaultLineThickness() : m_width; diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index ab5ebd3b7b..4c5a8deb87 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -116,8 +116,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - bool HitTest( const wxPoint& aPosition ) const override; bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override; diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 2a232072c1..22e0cb6182 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -71,68 +71,6 @@ bool LIB_POLYLINE::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_POLYLINE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - char* p; - int i, ccount = 0; - wxPoint pt; - char* line = (char*) aLineReader; - - i = sscanf( line + 2, "%d %d %d %d", &ccount, &m_Unit, &m_Convert, &m_Width ); - - m_Fill = NO_FILL; - - if( i < 4 ) - { - aErrorMsg.Printf( _( "Polyline only had %d parameters of the required 4" ), i ); - return false; - } - - if( ccount <= 0 ) - { - aErrorMsg.Printf( _( "Polyline count parameter %d is invalid" ), ccount ); - return false; - } - - strtok( line + 2, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); // Skip field - strtok( NULL, " \t\n" ); - - for( i = 0; i < ccount; i++ ) - { - p = strtok( NULL, " \t\n" ); - - if( p == NULL || sscanf( p, "%d", &pt.x ) != 1 ) - { - aErrorMsg.Printf( _( "Polyline point %d X position not defined" ), i ); - return false; - } - - p = strtok( NULL, " \t\n" ); - - if( p == NULL || sscanf( p, "%d", &pt.y ) != 1 ) - { - aErrorMsg.Printf( _( "Polyline point %d Y position not defined" ), i ); - return false; - } - - AddPoint( pt ); - } - - if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) - { - if( p[0] == 'F' ) - m_Fill = FILLED_SHAPE; - - if( p[0] == 'f' ) - m_Fill = FILLED_WITH_BG_BODYCOLOR; - } - - return true; -} - - EDA_ITEM* LIB_POLYLINE::Clone() const { return new LIB_POLYLINE( *this ); diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 167db0d660..43e3d2f8fa 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -60,8 +60,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - void AddPoint( const wxPoint& aPoint ); /** diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index c9622f2699..b27db2cd23 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -65,31 +65,6 @@ bool LIB_RECTANGLE::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_RECTANGLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) -{ - int cnt; - char tmp[256] = ""; - char* line = (char*)aLineReader; - - cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %255s", &m_Pos.x, &m_Pos.y, - &m_End.x, &m_End.y, &m_Unit, &m_Convert, &m_Width, tmp ); - - if( cnt < 7 ) - { - aErrorMsg.Printf( _( "Rectangle only had %d parameters of the required 7" ), cnt ); - return false; - } - - if( tmp[0] == 'F' ) - m_Fill = FILLED_SHAPE; - - if( tmp[0] == 'f' ) - m_Fill = FILLED_WITH_BG_BODYCOLOR; - - return true; -} - - EDA_ITEM* LIB_RECTANGLE::Clone() const { return new LIB_RECTANGLE( *this ); diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 6391b5f004..ba8940eacb 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,8 +63,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - bool HitTest( const wxPoint& aPosition ) const override; bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 021f11600c..17c9301342 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -98,101 +98,6 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter ) } -bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) -{ - int cnt, thickness = 0; - char hjustify = 'C', vjustify = 'C'; - char buf[256]; - char tmp[256]; - char* line = (char*) aLineReader; - double angle; - int not_visible; - int x, y, size; - - buf[0] = 0; - tmp[0] = 0; // For italic option, Not in old versions - - cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c", - &angle, &x, &y, &size, ¬_visible, - &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, - &vjustify ); - - SetVisible( !not_visible ); - - if( cnt >= 8 ) // if quoted loading failed, load as not quoted - { - m_Text = FROM_UTF8( buf ); - - // convert two apostrophes back to double quote - m_Text.Replace( wxT( "''" ), wxT( "\"" ) ); - } - else - { - cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c", - &angle, &x, &y, &size, ¬_visible, - &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, - &vjustify ); - - if( cnt < 8 ) - { - errorMsg.Printf( _( "Text only had %d parameters of the required 8" ), cnt ); - return false; - } - - SetVisible( !not_visible ); - - /* Convert '~' to spaces (only if text is not quoted). */ - m_Text = FROM_UTF8( buf ); - m_Text.Replace( wxT( "~" ), wxT( " " ) ); - } - - SetTextAngle( angle ); - - SetTextSize( wxSize( size, size ) ); - SetTextPos( wxPoint( x, y ) ); - - if( strncasecmp( tmp, "Italic", 6 ) == 0 ) - SetItalic( true ); - - if( thickness > 0 ) - { - SetBold( true ); - } - - switch( hjustify ) - { - case 'L': - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; - - case 'C': - SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - break; - - case 'R': - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - break; - } - - switch( vjustify ) - { - case 'T': - SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - break; - - case 'C': - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; - - case 'B': - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - break; - } - - return true; -} - - bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const { return HitTest( aPosition, 0, DefaultTransform ); diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 3ab8c6b5da..391c4641b5 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -80,8 +80,6 @@ public: bool Save( OUTPUTFORMATTER& aFormatter ) override; - bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override; - bool HitTest( const wxPoint& aPosition ) const override; bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;