34 #include <drawing_sheet/drawing_sheet_lexer.h> 37 #include <wx/msgdlg.h> 39 using namespace DRAWINGSHEET_T;
41 #define double2Str Double2Str 46 return DRAWING_SHEET_LEXER::TokenName( aTok );
69 void formatCoordinate(
const char* aToken,
POINT_COORD& aCoord )
const;
70 void formatRepeatParameters(
DS_DATA_ITEM* aItem )
const;
92 wxMessageBox( ioe.
What(),
_(
"Error writing drawing sheet file" ) );
112 m_output( aOutputString )
121 wxMessageBox( ioe.
What(),
_(
"Error writing drawing sheet file" ) );
127 *m_output =
FROM_UTF8( m_writer->GetString().c_str() );
154 writer.
Format(
this, aItemsList );
162 m_out->Print( 0,
"(kicad_wks (version %d) (generator pl_editor)\n",
166 Format( aModel, item, 1 );
168 m_out->Print( 0,
")\n" );
182 format( aModel, aItem, aNestLevel );
194 wxFAIL_MSG( wxT(
"Cannot format item" ) );
203 m_out->Print( 0,
"(kicad_wks (version %d) (generator pl_editor)\n",
209 m_out->Print( nestLevel,
"(setup " );
210 m_out->Print( 0,
"(textsize %s %s)",
215 m_out->Print( 0,
"\n" );
222 m_out->Print( 0,
")\n" );
225 for(
unsigned ii = 0; ii < aSheet->
GetCount(); ii++ )
228 Format( aSheet, item, nestLevel );
231 m_out->Print( 0,
")\n" );
237 m_out->Print( aNestLevel,
"(tbtext" );
238 m_out->Print( 0,
" %s", m_out->Quotew( aItem->
m_TextBase ).c_str() );
239 m_out->Print( 0,
" (name %s)", m_out->Quotew( aItem->
m_Name ).c_str() );
242 formatOptions( aItem );
251 if( write_thickness || write_size || aItem->
m_Bold || aItem->
m_Italic )
253 m_out->Print( 0,
" (font" );
255 if( write_thickness )
260 m_out->Print( 0,
" (size %s %s)",
266 m_out->Print( 0,
" bold" );
269 m_out->Print( 0,
" italic" );
271 m_out->Print( 0,
")" );
277 m_out->Print( 0,
" (justify" );
282 m_out->Print( 0,
" center" );
284 m_out->Print( 0,
" right" );
287 m_out->Print( 0,
" top" );
289 m_out->Print( 0,
" bottom" );
291 m_out->Print( 0,
")" );
301 formatRepeatParameters( aItem );
303 if( !aItem->
m_Info.IsEmpty() )
304 m_out->Print( 0,
" (comment %s)\n", m_out->Quotew( aItem->
m_Info ).c_str() );
306 m_out->Print( 0,
")\n" );
313 m_out->Print( aNestLevel,
"(rect" );
315 m_out->Print( aNestLevel,
"(line" );
317 m_out->Print( 0,
" (name %s)", m_out->Quotew( aItem->
m_Name ).c_str() );
321 formatOptions( aItem );
326 formatRepeatParameters( aItem );
328 if( !aItem->
m_Info.IsEmpty() )
329 m_out->Print( 0,
" (comment %s)\n", m_out->Quotew( aItem->
m_Info ).c_str() );
331 m_out->Print( 0,
")\n" );
337 m_out->Print( aNestLevel,
"(polygon" );
338 m_out->Print( 0,
" (name %s)", m_out->Quotew( aItem->
m_Name ).c_str() );
339 formatCoordinate(
"pos", aItem->
m_Pos );
340 formatOptions( aItem );
342 formatRepeatParameters( aItem );
350 if( !aItem->
m_Info.IsEmpty() )
351 m_out->Print( 0,
" (comment %s)\n", m_out->Quotew( aItem->
m_Info ).c_str() );
356 m_out->Print( aNestLevel+1,
"(pts" );
369 m_out->Print( 0,
"\n" );
370 nestLevel = aNestLevel+2;
374 m_out->Print( nestLevel,
" (xy %s %s)",
379 m_out->Print( 0,
")\n" );
382 m_out->Print( aNestLevel,
")\n" );
388 m_out->Print( aNestLevel,
"(bitmap" );
389 m_out->Print( 0,
" (name %s)", m_out->Quotew( aItem->
m_Name ).c_str() );
390 formatCoordinate(
"pos", aItem->
m_Pos );
391 formatOptions( aItem );
395 formatRepeatParameters( aItem );
396 m_out->Print( 0,
"\n");
398 if( !aItem->
m_Info.IsEmpty() )
399 m_out->Print( 0,
" (comment %s)\n", m_out->Quotew( aItem->
m_Info ).c_str() );
402 m_out->Print( aNestLevel,
"(pngdata\n" );
403 wxArrayString pngStrings;
406 for(
unsigned ii = 0; ii < pngStrings.GetCount(); ii++ )
407 m_out->Print( aNestLevel+1,
"(data \"%s\")\n",
TO_UTF8(pngStrings[ii]) );
409 m_out->Print( aNestLevel+1,
")\n" );
411 m_out->Print( aNestLevel,
")\n" );
417 m_out->Print( 0,
" (%s %s %s", aToken,
424 case LT_CORNER: m_out->Print( 0,
" ltcorner" );
break;
425 case LB_CORNER: m_out->Print( 0,
" lbcorner" );
break;
426 case RT_CORNER: m_out->Print( 0,
" rtcorner" );
break;
429 m_out->Print( 0,
")" );
441 m_out->Print( 0,
" (incrx %s)",
double2Str(aItem-> m_IncrementVector.x ).c_str() );
454 m_out->Print( 0,
" (option page1only)" );
456 m_out->Print( 0,
" (option notonpage1)" );
void formatCoordinate(const char *aToken, POINT_COORD &aCoord) const
unsigned GetPolyIndexStart(unsigned aContour) const
Handle the graphic items list to draw/plot the frame and title block.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
EDA_TEXT_VJUSTIFY_T m_Vjustify
bool SaveData(FILE *aFile) const
Write the bitmap data to aFile.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
double m_DefaultLineWidth
static const char * getTokenName(T aTok)
std::vector< DPOINT > m_Corners
unsigned GetPolyIndexEnd(unsigned aContour) const
void Save(const wxString &aFullFileName)
Save the description in a file.
double m_DefaultTextThickness
This file contains miscellaneous commonly used macros and functions.
FILE_OUTPUTFORMATTER * m_fileout
EDA_TEXT_HJUSTIFY_T m_Hjustify
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
DS_ITEM_TYPE GetType() const
virtual ~DS_DATA_MODEL_IO()
BITMAP_BASE * m_ImageBitmap
virtual const wxString What() const
A composite of Problem() and Where()
void Format(DS_DATA_MODEL *aSheet) const
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
DS_DATA_MODEL_FILEIO(const wxString &aFilename)
STRING_FORMATTER * m_writer
~DS_DATA_MODEL_STRINGIO()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void format(DS_DATA_ITEM_TEXT *aItem, int aNestLevel) const
DS_DATA_ITEM * GetItem(unsigned aIdx) const
Drawing sheet structure type definitions.
void formatRepeatParameters(DS_DATA_ITEM *aItem) const
DS_DATA_MODEL_STRINGIO(wxString *aOutputString)
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
unsigned GetCount() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
PAGE_OPTION GetPage1Option() const
void formatOptions(DS_DATA_ITEM *aItem) const