32#include <drawing_sheet/drawing_sheet_lexer.h>
39#include <wx/mstream.h>
41using namespace DRAWINGSHEET_T;
47 return DRAWING_SHEET_LEXER::TokenName( aTok );
101 std::unique_ptr<PRETTIFIED_FILE_OUTPUTFORMATTER>
m_fileout;
122 wxMessageBox( ioe.
What(),
_(
"Error writing drawing sheet file" ) );
156 writer.
Format(
this, aItemsList );
164 m_out->Print(
"(kicad_wks (version %d) (generator %s) (generator_version %s)",
198 wxFAIL_MSG( wxT(
"Cannot format item" ) );
207 m_out->Print(
"(kicad_wks (version %d) (generator %s) (generator_version %s)",
215 m_out->Print(
"(setup" );
216 m_out->Print(
"(textsize %s %s)",
220 m_out->Print(
"(textlinewidth %s)",
232 for(
unsigned ii = 0; ii < aSheet->
GetCount(); ii++ )
258 if( write_thickness || write_size || aItem->
m_Bold || aItem->
m_Italic
261 m_out->Print(
"(font" );
266 if( write_thickness )
271 m_out->Print(
"(size %s %s)",
277 m_out->Print(
" bold" );
280 m_out->Print(
" italic" );
284 m_out->Print(
"(color %d %d %d %s)",
297 m_out->Print(
"(justify" );
302 m_out->Print(
" center" );
304 m_out->Print(
" right" );
307 m_out->Print(
" top" );
309 m_out->Print(
" bottom" );
323 if( !aItem->
m_Info.IsEmpty() )
333 m_out->Print(
"(rect" );
335 m_out->Print(
"(line" );
348 if( !aItem->
m_Info.IsEmpty() )
357 m_out->Print(
"(polygon" );
370 if( !aItem->
m_Info.IsEmpty() )
376 m_out->Print(
"(pts" );
385 m_out->Print(
"(xy %s %s)",
403 m_out->Print(
"(bitmap" );
412 if( !aItem->
m_Info.IsEmpty() )
416 wxMemoryOutputStream stream;
427 m_out->Print(
"(%s %s %s", aToken,
464 m_out->Print(
"(option page1only)" );
466 m_out->Print(
"(option notonpage1)" );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
const wxImage * GetOriginalImageData() const
bool SaveImageData(wxOutputStream &aOutStream) const
Write the bitmap data to aOutStream.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
BITMAP_BASE * m_ImageBitmap
unsigned GetPolyIndexStart(unsigned aContour) const
unsigned GetPolyIndexEnd(unsigned aContour) const
std::vector< VECTOR2D > m_Corners
GR_TEXT_H_ALIGN_T m_Hjustify
KIGFX::COLOR4D m_TextColor
VECTOR2D m_BoundingBoxSize
GR_TEXT_V_ALIGN_T m_Vjustify
Drawing sheet structure type definitions.
PAGE_OPTION GetPage1Option() const
DS_ITEM_TYPE GetType() const
VECTOR2D m_IncrementVector
A helper class to write a drawing sheet to a file.
~DS_DATA_MODEL_FILEIO()=default
DS_DATA_MODEL_FILEIO(const wxString &aFilename)
std::unique_ptr< PRETTIFIED_FILE_OUTPUTFORMATTER > m_fileout
void Format(DS_DATA_MODEL *aSheet) const
virtual ~DS_DATA_MODEL_IO()
void formatRepeatParameters(DS_DATA_ITEM *aItem) const
void formatOptions(DS_DATA_ITEM *aItem) const
void format(DS_DATA_ITEM_TEXT *aItem) const
void formatCoordinate(const char *aToken, POINT_COORD &aCoord) const
A helper class to write a drawing sheet to a string.
~DS_DATA_MODEL_STRINGIO()
STRING_FORMATTER * m_writer
DS_DATA_MODEL_STRINGIO(wxString *aOutputString)
Handle the graphic items list to draw/plot the frame and title block.
VECTOR2D m_DefaultTextSize
unsigned GetCount() const
double m_DefaultLineWidth
DS_DATA_ITEM * GetItem(unsigned aIdx) const
double m_DefaultTextThickness
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
const wxString & GetGenerator() const
void Save(const wxString &aFullFileName)
Save the description in a file.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
const char * NameAsToken() const
const wxString & GetName() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
static const char * getTokenName(T aTok)
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
wxString From_UTF8(const char *cstring)
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
VECTOR2< double > VECTOR2D