KiCad PCB EDA Suite
DS_DATA_MODEL_FILEIO Class Reference
Inheritance diagram for DS_DATA_MODEL_FILEIO:
DS_DATA_MODEL_IO

Public Member Functions

 DS_DATA_MODEL_FILEIO (const wxString &aFilename)
 
 ~DS_DATA_MODEL_FILEIO ()
 
void Format (DS_DATA_MODEL *aSheet) const
 
void Format (DS_DATA_MODEL *aModel, std::vector< DS_DATA_ITEM * > &aItemsList) const
 
void Format (DS_DATA_MODEL *aModel, DS_DATA_ITEM *aItem, int aNestLevel) const
 

Protected Attributes

OUTPUTFORMATTERm_out
 

Private Attributes

FILE_OUTPUTFORMATTERm_fileout
 

Detailed Description

Definition at line 79 of file ds_data_model_io.cpp.

Constructor & Destructor Documentation

◆ DS_DATA_MODEL_FILEIO()

DS_DATA_MODEL_FILEIO::DS_DATA_MODEL_FILEIO ( const wxString &  aFilename)
inline

Definition at line 82 of file ds_data_model_io.cpp.

82  :
84  {
85  try
86  {
87  m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
88  m_out = m_fileout;
89  }
90  catch( const IO_ERROR& ioe )
91  {
92  wxMessageBox( ioe.What(), _( "Error writing drawing sheet file" ) );
93  }
94  }
FILE_OUTPUTFORMATTER * m_fileout
OUTPUTFORMATTER * m_out
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
#define _(s)
Used for text file output.
Definition: richio.h:456
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References _, and IO_ERROR::What().

◆ ~DS_DATA_MODEL_FILEIO()

DS_DATA_MODEL_FILEIO::~DS_DATA_MODEL_FILEIO ( )
inline

Definition at line 96 of file ds_data_model_io.cpp.

97  {
98  delete m_fileout;
99  }
FILE_OUTPUTFORMATTER * m_fileout

Member Function Documentation

◆ Format() [1/3]

void DS_DATA_MODEL_IO::Format ( DS_DATA_MODEL aSheet) const
inherited

Definition at line 199 of file ds_data_model_io.cpp.

200 {
201  LOCALE_IO toggle; // switch on/off the locale "C" notation
202 
203  m_out->Print( 0, "(kicad_wks (version %d) (generator pl_editor)\n",
205 
206  // Setup
207  int nestLevel = 1;
208  // Write default values:
209  m_out->Print( nestLevel, "(setup " );
210  m_out->Print( 0, "(textsize %s %s)",
211  double2Str( aSheet->m_DefaultTextSize.x ).c_str(),
212  double2Str( aSheet->m_DefaultTextSize.y ).c_str() );
213  m_out->Print( 0, "(linewidth %s)", double2Str( aSheet->m_DefaultLineWidth ).c_str() );
214  m_out->Print( 0, "(textlinewidth %s)", double2Str( aSheet->m_DefaultTextThickness ).c_str() );
215  m_out->Print( 0, "\n" );
216 
217  // Write margin values
218  m_out->Print( nestLevel, "(left_margin %s)", double2Str( aSheet->GetLeftMargin() ).c_str() );
219  m_out->Print( 0, "(right_margin %s)", double2Str( aSheet->GetRightMargin() ).c_str() );
220  m_out->Print( 0, "(top_margin %s)", double2Str( aSheet->GetTopMargin() ).c_str() );
221  m_out->Print( 0, "(bottom_margin %s)", double2Str( aSheet->GetBottomMargin() ).c_str() );
222  m_out->Print( 0, ")\n" );
223 
224  // Save the graphical items on the drawing sheet
225  for( unsigned ii = 0; ii < aSheet->GetCount(); ii++ )
226  {
227  DS_DATA_ITEM* item = aSheet->GetItem( ii );
228  Format( aSheet, item, nestLevel );
229  }
230 
231  m_out->Print( 0, ")\n" );
232 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
double GetRightMargin()
Definition: ds_data_model.h:66
double m_DefaultLineWidth
double GetTopMargin()
Definition: ds_data_model.h:69
double GetLeftMargin()
Definition: ds_data_model.h:63
double m_DefaultTextThickness
OUTPUTFORMATTER * m_out
DSIZE m_DefaultTextSize
double GetBottomMargin()
Definition: ds_data_model.h:72
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_ITEM * GetItem(unsigned aIdx) const
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
unsigned GetCount() const
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
#define double2Str

References double2Str, Format(), DS_DATA_MODEL::GetBottomMargin(), DS_DATA_MODEL::GetCount(), DS_DATA_MODEL::GetItem(), DS_DATA_MODEL::GetLeftMargin(), DS_DATA_MODEL::GetRightMargin(), DS_DATA_MODEL::GetTopMargin(), DS_DATA_MODEL::m_DefaultLineWidth, DS_DATA_MODEL::m_DefaultTextSize, DS_DATA_MODEL::m_DefaultTextThickness, SEXPR_WORKSHEET_FILE_VERSION, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DS_DATA_MODEL::Save(), and DS_DATA_MODEL::SaveInString().

◆ Format() [2/3]

void DS_DATA_MODEL_IO::Format ( DS_DATA_MODEL aModel,
std::vector< DS_DATA_ITEM * > &  aItemsList 
) const
inherited

Definition at line 158 of file ds_data_model_io.cpp.

159 {
160  LOCALE_IO toggle; // switch on/off the locale "C" notation
161 
162  m_out->Print( 0, "(kicad_wks (version %d) (generator pl_editor)\n",
164 
165  for( DS_DATA_ITEM* item : aItemsList )
166  Format( aModel, item, 1 );
167 
168  m_out->Print( 0, ")\n" );
169 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
OUTPUTFORMATTER * m_out
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...
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

References Format(), and SEXPR_WORKSHEET_FILE_VERSION.

◆ Format() [3/3]

void DS_DATA_MODEL_IO::Format ( DS_DATA_MODEL aModel,
DS_DATA_ITEM aItem,
int  aNestLevel 
) const
inherited

Definition at line 172 of file ds_data_model_io.cpp.

173 {
174  switch( aItem->GetType() )
175  {
177  format( (DS_DATA_ITEM_TEXT*) aItem, aNestLevel );
178  break;
179 
182  format( aModel, aItem, aNestLevel );
183  break;
184 
186  format( (DS_DATA_ITEM_POLYGONS*) aItem, aNestLevel );
187  break;
188 
190  format( (DS_DATA_ITEM_BITMAP*) aItem, aNestLevel );
191  break;
192 
193  default:
194  wxFAIL_MSG( wxT( "Cannot format item" ) );
195  }
196 }
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
void format(DS_DATA_ITEM_TEXT *aItem, int aNestLevel) const

References DS_DATA_ITEM::DS_BITMAP, DS_DATA_ITEM::DS_POLYPOLYGON, DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, DS_DATA_ITEM::DS_TEXT, and DS_DATA_ITEM::GetType().

Member Data Documentation

◆ m_fileout

FILE_OUTPUTFORMATTER* DS_DATA_MODEL_FILEIO::m_fileout
private

Definition at line 102 of file ds_data_model_io.cpp.

◆ m_out

OUTPUTFORMATTER* DS_DATA_MODEL_IO::m_out
protectedinherited

Definition at line 74 of file ds_data_model_io.cpp.


The documentation for this class was generated from the following file: