bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter ) { int hjustify, vjustify; wxString text = m_Text; hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; vjustify = 'C'; if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; /* Dick 24-May-2013: What the hell is this?. There was no comment here. Hell no. You don't want this in the *.lib files, it is crap. Fields get read back in and they have a tilda in them. if( text.IsEmpty() ) text = wxT( "~" ); */ aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", m_id, EscapedUTF8( text ).c_str(), // wraps in quotes m_Pos.x, m_Pos.y, m_Size.x, m_Orient == 0 ? 'H' : 'V', (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', hjustify, vjustify, m_Italic ? 'I' : 'N', m_Bold ? 'B' : 'N' ); /* Save field name, if necessary * Field name is saved only if it is not the default name. * Just because default name depends on the language and can change from * a country to an other */ wxString defName = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); if( m_id >= FIELD1 && !m_name.IsEmpty() && m_name != defName ) aFormatter.Print( 0, " %s", EscapedUTF8( m_name ).c_str() ); aFormatter.Print( 0, "\n" ); return true; }
bool SCH_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; char vjustify = 'C'; if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, hjustify, vjustify, m_Italic ? 'I' : 'N', m_Bold ? 'B' : 'N' ) == EOF ) { return false; } // Save field name, if the name is user definable if( m_id >= FIELD1 ) { if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF ) { return false; } } if( fprintf( aFile, "\n" ) == EOF ) { return false; } return true; }
bool SCH_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; char vjustify = 'C'; if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', GetTextPos().x, GetTextPos().y, GetTextWidth(), !IsVisible(), hjustify, vjustify, IsItalic() ? 'I' : 'N', IsBold() ? 'B' : 'N' ) == EOF ) { return false; } // Save field name, if the name is user definable if( m_id >= FIELD1 ) { if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF ) { return false; } } if( fprintf( aFile, "\n" ) == EOF ) { return false; } return true; }
bool SCH_SCREEN::Save( FILE* aFile ) const { // Creates header if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP, SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0 ) return false; BOOST_FOREACH( const PART_LIB& lib, *Prj().SchLibs() ) { if( fprintf( aFile, "LIBS:%s\n", TO_UTF8( lib.GetName() ) ) < 0 ) return false; } // This section is not used, but written for file compatibility if( fprintf( aFile, "EELAYER %d %d\n", LAYERSCH_ID_COUNT, 0 ) < 0 || fprintf( aFile, "EELAYER END\n" ) < 0 ) return false; /* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for * SheetNumber and Sheet Count in a complex hierarchy, but useful in * simple hierarchy and flat hierarchy. Used also to search the root * sheet ( ScreenNumber = 1 ) within the files */ const TITLE_BLOCK& tb = GetTitleBlock(); if( fprintf( aFile, "$Descr %s %d %d%s\n", TO_UTF8( m_paper.GetType() ), m_paper.GetWidthMils(), m_paper.GetHeightMils(), !m_paper.IsCustom() && m_paper.IsPortrait() ? " portrait" : "" ) < 0 || fprintf( aFile, "encoding utf-8\n") < 0 || fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreens ) < 0 || fprintf( aFile, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() ) < 0 || fprintf( aFile, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() ) < 0 || fprintf( aFile, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() ) < 0 || fprintf( aFile, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() ) < 0 || fprintf( aFile, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() ) < 0 || fprintf( aFile, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() ) < 0 || fprintf( aFile, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() ) < 0 || fprintf( aFile, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() ) < 0 || fprintf( aFile, "$EndDescr\n" ) < 0 ) return false; for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( !item->Save( aFile ) ) return false; } if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 ) return false; return true; }
bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter ) { int hjustify, vjustify; wxString text = m_Text; hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; vjustify = 'C'; if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", m_id, EscapedUTF8( text ).c_str(), // wraps in quotes m_Pos.x, m_Pos.y, m_Size.x, m_Orient == 0 ? 'H' : 'V', (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', hjustify, vjustify, m_Italic ? 'I' : 'N', m_Bold ? 'B' : 'N' ); /* Save field name, if necessary * Field name is saved only if it is not the default name. * Just because default name depends on the language and can change from * a country to an other */ wxString defName = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); if( m_id >= FIELD1 && !m_name.IsEmpty() && m_name != defName ) aFormatter.Print( 0, " %s", EscapedUTF8( m_name ).c_str() ); aFormatter.Print( 0, "\n" ); return true; }
bool SCH_SHEET_PIN::Save( FILE* aFile ) const { int type = 'U', side = 'L'; if( m_Text.IsEmpty() ) return true; switch( m_edge ) { case 0: //pin on left side side = 'L'; break; case 1: //pin on right side side = 'R'; break; case 2: //pin on top side side = 'T'; break; case 3: //pin on bottom side side = 'B'; break; } switch( m_shape ) { case NET_INPUT: type = 'I'; break; case NET_OUTPUT: type = 'O'; break; case NET_BIDI: type = 'B'; break; case NET_TRISTATE: type = 'T'; break; case NET_UNSPECIFIED: type = 'U'; break; } if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_number, EscapedUTF8( m_Text ).c_str(), // supplies wrapping quotes type, side, m_Pos.x, m_Pos.y, m_Size.x ) == EOF ) { return false; } return true; }
bool SCH_SHEET::Save( FILE* aFile ) const { if( fprintf( aFile, "$Sheet\n" ) == EOF || fprintf( aFile, "S %-4d %-4d %-4d %-4d\n", m_pos.x, m_pos.y, m_size.x, m_size.y ) == EOF ) return false; //save the unique timestamp, like other schematic parts. if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF ) return false; /* Save schematic sheetname and filename. */ if( !m_name.IsEmpty() ) { if( fprintf( aFile, "F0 %s %d\n", EscapedUTF8( m_name ).c_str(), m_sheetNameSize ) == EOF ) return false; } if( !m_fileName.IsEmpty() ) { if( fprintf( aFile, "F1 %s %d\n", EscapedUTF8( m_fileName ).c_str(), m_fileNameSize ) == EOF ) return false; } /* Save the list of labels in the sheet. */ BOOST_FOREACH( const SCH_SHEET_PIN& label, m_pins ) { if( !label.Save( aFile ) ) return false; } if( fprintf( aFile, "$EndSheet\n" ) == EOF ) return false; return true; }