KiCad PCB EDA Suite
WORKSHEET_LAYOUT_FILEIO Class Reference
Inheritance diagram for WORKSHEET_LAYOUT_FILEIO:
WORKSHEET_LAYOUT_IO

Public Member Functions

 WORKSHEET_LAYOUT_FILEIO (const wxString &aFilename)
 
 ~WORKSHEET_LAYOUT_FILEIO ()
 
void Format (WORKSHEET_LAYOUT *aPageLayout) const throw ( IO_ERROR )
 
void Format (WORKSHEET_DATAITEM *aItem, int aNestLevel) const throw ( IO_ERROR )
 

Protected Attributes

OUTPUTFORMATTERm_out
 

Private Attributes

FILE_OUTPUTFORMATTERm_fileout
 

Detailed Description

Definition at line 90 of file page_layout_writer.cpp.

Constructor & Destructor Documentation

WORKSHEET_LAYOUT_FILEIO::WORKSHEET_LAYOUT_FILEIO ( const wxString &  aFilename)
inline

Definition at line 95 of file page_layout_writer.cpp.

References IO_ERROR::What().

95  :
97  {
98  try
99  {
100  m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
101  m_out = m_fileout;
102  }
103  catch( const IO_ERROR& ioe )
104  {
105  wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
106  }
107  }
OUTPUTFORMATTER * m_out
FILE_OUTPUTFORMATTER * m_fileout
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
WORKSHEET_LAYOUT_FILEIO::~WORKSHEET_LAYOUT_FILEIO ( )
inline

Definition at line 109 of file page_layout_writer.cpp.

110  {
111  delete m_fileout;
112  }
FILE_OUTPUTFORMATTER * m_fileout

Member Function Documentation

void WORKSHEET_LAYOUT_IO::Format ( WORKSHEET_LAYOUT aPageLayout) const
throw (IO_ERROR
)
inherited

Definition at line 192 of file page_layout_writer.cpp.

References double2Str, Format(), getTokenName(), WORKSHEET_DATAITEM::m_DefaultLineWidth, WORKSHEET_DATAITEM::m_DefaultTextSize, WORKSHEET_DATAITEM::m_DefaultTextThickness, OUTPUTFORMATTER::Print(), TB_READER_T::T_bottom_margin, TB_READER_T::T_left_margin, TB_READER_T::T_right_margin, TB_READER_T::T_setup, and TB_READER_T::T_top_margin.

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

194 {
195  LOCALE_IO toggle; // switch on/off the locale "C" notation
196 
197  m_out->Print( 0, "(page_layout\n" );
198 
199  // Setup
200  int nestLevel = 1;
201  // Write default values:
202  m_out->Print( nestLevel, "(%s ", getTokenName( T_setup ) );
203  m_out->Print( 0, "(textsize %s %s)",
206  m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() );
207  m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() );
208  m_out->Print( 0, "\n" );
209 
210  // Write margin values
211  m_out->Print( nestLevel, "(%s %s)", getTokenName( T_left_margin ),
212  double2Str( aPageLayout->GetLeftMargin() ).c_str() );
213  m_out->Print( 0, "(%s %s)", getTokenName( T_right_margin ),
214  double2Str( aPageLayout->GetRightMargin() ).c_str() );
215  m_out->Print( 0, "(%s %s)", getTokenName( T_top_margin ),
216  double2Str( aPageLayout->GetTopMargin() ).c_str() );
217  m_out->Print( 0, "(%s %s)", getTokenName( T_bottom_margin ),
218  double2Str( aPageLayout->GetBottomMargin() ).c_str() );
219  m_out->Print( 0, ")\n" );
220 
221  // Save the graphical items on the page layout
222  for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ )
223  {
224  WORKSHEET_DATAITEM* item = aPageLayout->GetItem( ii );
225  Format( item, nestLevel );
226  }
227 
228  m_out->Print( 0, ")\n" );
229 }
#define double2Str
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
OUTPUTFORMATTER * m_out
void Format(WORKSHEET_LAYOUT *aPageLayout) const
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
unsigned GetCount() const
static double m_DefaultTextThickness
static const char * getTokenName(T aTok)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
void WORKSHEET_LAYOUT_IO::Format ( WORKSHEET_DATAITEM aItem,
int  aNestLevel 
) const
throw (IO_ERROR
)
inherited

Definition at line 164 of file page_layout_writer.cpp.

References WORKSHEET_DATAITEM::WS_BITMAP, WORKSHEET_DATAITEM::WS_POLYPOLYGON, WORKSHEET_DATAITEM::WS_RECT, WORKSHEET_DATAITEM::WS_SEGMENT, and WORKSHEET_DATAITEM::WS_TEXT.

166 {
167  switch( aItem->GetType() )
168  {
170  format( (WORKSHEET_DATAITEM_TEXT*) aItem, aNestLevel );
171  break;
172 
175  format( aItem, aNestLevel );
176  break;
177 
179  format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
180  break;
181 
183  format( (WORKSHEET_DATAITEM_BITMAP*) aItem, aNestLevel );
184  break;
185 
186  default:
187  wxFAIL_MSG( wxT( "Cannot format item" ) );
188  }
189 }
void format(WORKSHEET_LAYOUT *aPageLayout) const
WS_ItemType GetType() const

Member Data Documentation

FILE_OUTPUTFORMATTER* WORKSHEET_LAYOUT_FILEIO::m_fileout
private

Definition at line 92 of file page_layout_writer.cpp.

OUTPUTFORMATTER* WORKSHEET_LAYOUT_IO::m_out
protectedinherited

Definition at line 60 of file page_layout_writer.cpp.


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