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
 
void Format (WORKSHEET_DATAITEM *aItem, int aNestLevel) const
 

Protected Attributes

OUTPUTFORMATTERm_out
 

Private Attributes

FILE_OUTPUTFORMATTERm_fileout
 

Detailed Description

Definition at line 85 of file page_layout_writer.cpp.

Constructor & Destructor Documentation

WORKSHEET_LAYOUT_FILEIO::WORKSHEET_LAYOUT_FILEIO ( const wxString &  aFilename)
inline

Definition at line 90 of file page_layout_writer.cpp.

References IO_ERROR::What().

90  :
92  {
93  try
94  {
95  m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
96  m_out = m_fileout;
97  }
98  catch( const IO_ERROR& ioe )
99  {
100  wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
101  }
102  }
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 104 of file page_layout_writer.cpp.

105  {
106  delete m_fileout;
107  }
FILE_OUTPUTFORMATTER * m_fileout

Member Function Documentation

void WORKSHEET_LAYOUT_IO::Format ( WORKSHEET_LAYOUT aPageLayout) const
inherited

Definition at line 186 of file page_layout_writer.cpp.

References double2Str, Format(), WORKSHEET_LAYOUT::GetBottomMargin(), WORKSHEET_LAYOUT::GetCount(), WORKSHEET_LAYOUT::GetItem(), WORKSHEET_LAYOUT::GetLeftMargin(), WORKSHEET_LAYOUT::GetRightMargin(), getTokenName(), WORKSHEET_LAYOUT::GetTopMargin(), WORKSHEET_DATAITEM::m_DefaultLineWidth, WORKSHEET_DATAITEM::m_DefaultTextSize, WORKSHEET_DATAITEM::m_DefaultTextThickness, 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().

187 {
188  LOCALE_IO toggle; // switch on/off the locale "C" notation
189 
190  m_out->Print( 0, "(page_layout\n" );
191 
192  // Setup
193  int nestLevel = 1;
194  // Write default values:
195  m_out->Print( nestLevel, "(%s ", getTokenName( T_setup ) );
196  m_out->Print( 0, "(textsize %s %s)",
199  m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() );
200  m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() );
201  m_out->Print( 0, "\n" );
202 
203  // Write margin values
204  m_out->Print( nestLevel, "(%s %s)", getTokenName( T_left_margin ),
205  double2Str( aPageLayout->GetLeftMargin() ).c_str() );
206  m_out->Print( 0, "(%s %s)", getTokenName( T_right_margin ),
207  double2Str( aPageLayout->GetRightMargin() ).c_str() );
208  m_out->Print( 0, "(%s %s)", getTokenName( T_top_margin ),
209  double2Str( aPageLayout->GetTopMargin() ).c_str() );
210  m_out->Print( 0, "(%s %s)", getTokenName( T_bottom_margin ),
211  double2Str( aPageLayout->GetBottomMargin() ).c_str() );
212  m_out->Print( 0, ")\n" );
213 
214  // Save the graphical items on the page layout
215  for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ )
216  {
217  WORKSHEET_DATAITEM* item = aPageLayout->GetItem( ii );
218  Format( item, nestLevel );
219  }
220 
221  m_out->Print( 0, ")\n" );
222 }
#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
inherited

Definition at line 159 of file page_layout_writer.cpp.

References WORKSHEET_DATAITEM::GetType(), WORKSHEET_DATAITEM::WS_BITMAP, WORKSHEET_DATAITEM::WS_POLYPOLYGON, WORKSHEET_DATAITEM::WS_RECT, WORKSHEET_DATAITEM::WS_SEGMENT, and WORKSHEET_DATAITEM::WS_TEXT.

160 {
161  switch( aItem->GetType() )
162  {
164  format( (WORKSHEET_DATAITEM_TEXT*) aItem, aNestLevel );
165  break;
166 
169  format( aItem, aNestLevel );
170  break;
171 
173  format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
174  break;
175 
177  format( (WORKSHEET_DATAITEM_BITMAP*) aItem, aNestLevel );
178  break;
179 
180  default:
181  wxFAIL_MSG( wxT( "Cannot format item" ) );
182  }
183 }
void format(WORKSHEET_LAYOUT *aPageLayout) const
WS_ItemType GetType() const

Member Data Documentation

FILE_OUTPUTFORMATTER* WORKSHEET_LAYOUT_FILEIO::m_fileout
private

Definition at line 87 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: