void WORKSHEET_LAYOUT_IO::formatCoordinate( const char * aToken, POINT_COORD & aCoord ) const throw( IO_ERROR ) { m_out->Print( 0, " (%s %s %s", aToken, double2Str( aCoord.m_Pos.x ).c_str(), double2Str( aCoord.m_Pos.y ).c_str() ); switch( aCoord.m_Anchor ) { case RB_CORNER: break; case LT_CORNER: m_out->Print( 0, " %s", getTokenName(T_ltcorner ) ); break; case LB_CORNER: m_out->Print( 0, " %s", getTokenName(T_lbcorner ) ); break; case RT_CORNER: m_out->Print( 0, " %s", getTokenName(T_rtcorner ) ); break; } m_out->Print( 0, ")" ); }
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLevel ) const throw( IO_ERROR ) { m_out->Print( aNestLevel, "( %s", getTokenName( T_bitmap ) ); m_out->Print( 0, " (%s %s)", getTokenName( T_name ), m_out->Quotew( aItem->m_Name ).c_str() ); formatCoordinate( getTokenName( T_pos ), aItem->m_Pos ); formatOptions( aItem ); m_out->Print( 0, " (%s %s)", getTokenName( T_scale ), double2Str(aItem->m_ImageBitmap->m_Scale ).c_str() ); formatRepeatParameters( aItem ); m_out->Print( 0,"\n"); // Write image in png readable format m_out->Print( aNestLevel, "( %s\n", getTokenName( T_pngdata ) ); wxArrayString pngStrings; aItem->m_ImageBitmap->SaveData( pngStrings ); for( unsigned ii = 0; ii < pngStrings.GetCount(); ii++ ) m_out->Print( aNestLevel+1, "(data \"%s\")\n", TO_UTF8(pngStrings[ii]) ); m_out->Print( aNestLevel+1, ")\n" ); m_out->Print( aNestLevel, ")\n" ); }
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 LIB_POLYLINE::Save( OUTPUTFORMATTER& aFormatter ) { int ccount = GetCornerCount(); aFormatter.Print( 0, "P %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ); for( unsigned i = 0; i < GetCornerCount(); i++ ) { aFormatter.Print( 0, " %d %d", m_PolyPoints[i].x, m_PolyPoints[i].y ); } aFormatter.Print( 0, " %c\n", fill_tab[m_Fill] ); return true; }
bool LIB_RECTANGLE::Save( OUTPUTFORMATTER& aFormatter ) { aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, m_End.x, m_End.y, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ); return true; }
bool LIB_CIRCLE::Save( OUTPUTFORMATTER& aFormatter ) { aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, m_Radius, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ); return true; }
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNestLevel ) const throw( IO_ERROR ) { m_out->Print( aNestLevel, "( %s", getTokenName( T_polygon ) ); m_out->Print( 0, " (%s %s)", getTokenName( T_name ), m_out->Quotew( aItem->m_Name ).c_str() ); formatCoordinate( getTokenName( T_pos ), aItem->m_Pos ); formatOptions( aItem ); formatRepeatParameters( aItem ); if( aItem->m_Orient ) m_out->Print( 0, " (%s %s)", getTokenName( T_rotate ), double2Str(aItem->m_Orient ).c_str() ); if( aItem->m_LineWidth ) m_out->Print( 0, " (linewidth %s)\n", double2Str( aItem->m_LineWidth ).c_str() ); // Write polygon corners list for( int kk = 0; kk < aItem->GetPolyCount(); kk++ ) { m_out->Print( aNestLevel+1, "( %s", getTokenName( T_pts ) ); // Create current polygon corners list unsigned ist = aItem->GetPolyIndexStart( kk ); unsigned iend = aItem->GetPolyIndexEnd( kk ); int ii = 0; while( ist <= iend ) { DPOINT pos = aItem->m_Corners[ist++]; int nestLevel = 0; if( ii++ > 4) { m_out->Print( 0, "\n" ); nestLevel = aNestLevel+2; ii = 0; } m_out->Print( nestLevel, " (%s %s %s)", getTokenName( T_xy ), double2Str( pos.x ).c_str(), double2Str( pos.y ).c_str() ); } m_out->Print( 0, ")\n" ); } m_out->Print( aNestLevel, ")\n" ); }
void WORKSHEET_LAYOUT_IO::formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) const throw( IO_ERROR ) { if( aItem->m_RepeatCount <= 1 ) return; m_out->Print( 0, " (repeat %d)", aItem->m_RepeatCount ); if( aItem->m_IncrementVector.x ) m_out->Print( 0, " (incrx %s)", double2Str(aItem-> m_IncrementVector.x ).c_str() ); if( aItem->m_IncrementVector.y ) m_out->Print( 0, " (incry %s)", double2Str( aItem->m_IncrementVector.y ).c_str() ); if( aItem->m_IncrementLabel != 1 && aItem->GetType() == WORKSHEET_DATAITEM::WS_TEXT ) m_out->Print( 0, " (incrlabel %d)", aItem->m_IncrementLabel ); }
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; }
void WORKSHEET_LAYOUT_IO::formatOptions( WORKSHEET_DATAITEM* aItem ) const throw( IO_ERROR ) { switch( aItem->GetPage1Option() ) { default: case 0: break; case 1: m_out->Print( 0, " (%s %s)", getTokenName(T_option ), getTokenName(T_page1only ) ); break; case -1: m_out->Print( 0, " (%s %s)", getTokenName(T_option ), getTokenName(T_notonpage1 ) ); break; } }
bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter ) { wxString text = m_Text; if( text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) ) { // convert double quote to similar-looking two apostrophes text.Replace( wxT( "\"" ), wxT( "''" ) ); text = wxT( "\"" ) + text + wxT( "\"" ); } else { // Spaces are not allowed in text because it is not double quoted: // changed to '~' text.Replace( wxT( " " ), wxT( "~" ) ); } aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s ", GetOrientation(), m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) ); aFormatter.Print( 0, " %s %d", m_Italic ? "Italic" : "Normal", ( m_Bold > 0 ) ? 1 : 0 ); 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'; aFormatter.Print( 0, " %c %c\n", hjustify, vjustify ); return true; }
bool LIB_ARC::Save( OUTPUTFORMATTER& aFormatter ) { int x1 = m_t1; if( x1 > 1800 ) x1 -= 3600; int x2 = m_t2; if( x2 > 1800 ) x2 -= 3600; aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", m_Pos.x, m_Pos.y, m_Radius, x1, x2, m_Unit, m_Convert, m_Width, fill_tab[m_Fill], m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x, m_ArcEnd.y ); return true; }
unsigned GENDRILL_WRITER_BASE::printToolSummary( OUTPUTFORMATTER& out, bool aSummaryNPTH ) const { unsigned totalHoleCount = 0; for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ ) { const DRILL_TOOL& tool = m_toolListBuffer[ii]; if( aSummaryNPTH && !tool.m_Hole_NotPlated ) continue; if( !aSummaryNPTH && tool.m_Hole_NotPlated ) continue; // List the tool number assigned to each drill, // in mm then in inches. int tool_number = ii+1; out.Print( 0, " T%d %2.2fmm %2.3f\" ", tool_number, diameter_in_mm( tool.m_Diameter ), diameter_in_inches( tool.m_Diameter ) ); // Now list how many holes and ovals are associated with each drill. if( ( tool.m_TotalCount == 1 ) && ( tool.m_OvalCount == 0 ) ) out.Print( 0, "(1 hole)\n" ); else if( tool.m_TotalCount == 1 ) out.Print( 0, "(1 hole) (with 1 slot)\n" ); else if( tool.m_OvalCount == 0 ) out.Print( 0, "(%d holes)\n", tool.m_TotalCount ); else if( tool.m_OvalCount == 1 ) out.Print( 0, "(%d holes) (with 1 slot)\n", tool.m_TotalCount ); else // tool.m_OvalCount > 1 out.Print( 0, "(%d holes) (with %d slots)\n", tool.m_TotalCount, tool.m_OvalCount ); totalHoleCount += tool.m_TotalCount; } out.Print( 0, "\n" ); return totalHoleCount; }
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM* aItem, int aNestLevel ) const throw( IO_ERROR ) { if( aItem->GetType() == WORKSHEET_DATAITEM::WS_RECT ) m_out->Print( aNestLevel, "(%s", getTokenName( T_rect ) ); else m_out->Print( aNestLevel, "(%s", getTokenName( T_line ) ); m_out->Print( 0, " (%s %s)", getTokenName( T_name ), m_out->Quotew( aItem->m_Name ).c_str() ); formatCoordinate( getTokenName( T_start ), aItem->m_Pos ); formatCoordinate( getTokenName( T_end ), aItem->m_End ); formatOptions( aItem ); if( aItem->m_LineWidth && aItem->m_LineWidth != aItem->m_DefaultLineWidth ) m_out->Print( 0, " (linewidth %s)", double2Str( aItem->m_LineWidth ).c_str() ); formatRepeatParameters( aItem ); m_out->Print( 0, ")\n" ); }
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_TEXT* aItem, int aNestLevel ) const throw( IO_ERROR ) { m_out->Print( aNestLevel, "(%s", getTokenName( T_tbtext ) ); m_out->Print( 0, " %s", m_out->Quotew( aItem->m_TextBase ).c_str() ); m_out->Print( 0, " (%s %s)", getTokenName( T_name ), m_out->Quotew( aItem->m_Name ).c_str() ); formatCoordinate( getTokenName( T_pos ), aItem->m_Pos ); formatOptions( aItem ); if( aItem->m_Orient ) m_out->Print( 0, " (%s %s)", getTokenName( T_rotate ), double2Str(aItem->m_Orient ).c_str() ); // Write font info bool write_size = aItem->m_TextSize.x != 0.0 && aItem->m_TextSize.y != 0.0; if( write_size || aItem->IsBold() || aItem->IsItalic() ) { m_out->Print( 0, " (%s", getTokenName( T_font ) ); if( write_size ) { m_out->Print( 0, " (%s %s %s)", getTokenName( T_size ), double2Str(aItem->m_TextSize.x ).c_str(), double2Str(aItem->m_TextSize.y ).c_str() ); } if( aItem->IsBold() ) m_out->Print( 0, " %s", getTokenName( T_bold ) ); if( aItem->IsItalic() ) m_out->Print( 0, " %s", getTokenName( T_italic ) ); m_out->Print( 0, ")" ); } // Write text justification if( aItem->m_Hjustify != GR_TEXT_HJUSTIFY_LEFT || aItem->m_Vjustify != GR_TEXT_VJUSTIFY_CENTER ) { m_out->Print( 0, " (%s", getTokenName( T_justify ) ); // Write T_center opt first, because it is // also a center for both m_Hjustify and m_Vjustify if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_CENTER ) m_out->Print( 0, " %s", getTokenName( T_center ) ); if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_RIGHT ) m_out->Print( 0, " %s", getTokenName( T_right ) ); if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_TOP ) m_out->Print( 0, " %s", getTokenName( T_top ) ); if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) m_out->Print( 0, " %s", getTokenName( T_bottom ) ); m_out->Print( 0, ")" ); } // write constraints if( aItem->m_BoundingBoxSize.x ) m_out->Print( 0, " (%s %s)", getTokenName( T_maxlen ), double2Str(aItem->m_BoundingBoxSize.x ).c_str() ); if( aItem->m_BoundingBoxSize.y ) m_out->Print( 0, " (%s %s)", getTokenName( T_maxheight ), double2Str(aItem->m_BoundingBoxSize.y ).c_str() ); formatRepeatParameters( aItem ); m_out->Print( 0, ")\n" ); }
void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_LAYOUT* aPageLayout ) const throw( IO_ERROR ) { LOCALE_IO toggle; // switch on/off the locale "C" notation m_out->Print( 0, "( page_layout\n" ); // Setup int nestLevel = 1; // Write default values: m_out->Print( nestLevel, "(%s", getTokenName( T_setup ) ); m_out->Print( 0, "(textsize %s %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextSize.x ).c_str(), double2Str( WORKSHEET_DATAITEM::m_DefaultTextSize.y ).c_str() ); m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() ); m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() ); m_out->Print( 0, "\n" ); // Write margin values m_out->Print( nestLevel, "(%s %s)", getTokenName( T_left_margin ), double2Str( aPageLayout->GetLeftMargin() ).c_str() ); m_out->Print( 0, "(%s %s)", getTokenName( T_right_margin ), double2Str( aPageLayout->GetRightMargin() ).c_str() ); m_out->Print( 0, "(%s %s)", getTokenName( T_top_margin ), double2Str( aPageLayout->GetTopMargin() ).c_str() ); m_out->Print( 0, "(%s %s)", getTokenName( T_bottom_margin ), double2Str( aPageLayout->GetBottomMargin() ).c_str() ); m_out->Print( 0, ")\n" ); // Save the graphical items on the page layout for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ ) { WORKSHEET_DATAITEM* item = aPageLayout->GetItem( ii ); Format( item, nestLevel ); } m_out->Print( 0, ")\n" ); }