Commit d7feb9ab authored by Wayne Stambaugh's avatar Wayne Stambaugh

Initial Pcbnew s-expression file format commit.

* Add s-expression Format() function to all objects derived from
  BOARD_ITEM.
* Add s-expression Format() function to base objects as required.
* Add functions to convert coordinates from base internal units
  (nanometers) to millimeter string for writing to s-expression
  file.
* Add temporary dummy conversion functions to prevent link errors
  until schematic and board object and action code can be separated
  into DSO/DLL.
* Add CMake build option to build Pcbnew with nanometer internal
  units.
parent 57ede4af
...@@ -24,6 +24,8 @@ option(USE_PNG_BITMAPS "use PNG bitmaps instead of XPM (default ON)" ON) ...@@ -24,6 +24,8 @@ option(USE_PNG_BITMAPS "use PNG bitmaps instead of XPM (default ON)" ON)
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" OFF) option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" OFF)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" OFF) option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" OFF)
option(USE_PCBNEW_NANOMETRES
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")
# Russian GOST patch # Russian GOST patch
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)") option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#cmakedefine USE_NEW_PCBNEW_LOAD #cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE #cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANAMETERS
/// The file format revision of the *.brd file created by this build /// The file format revision of the *.brd file created by this build
#if defined(KICAD_NANOMETRE) #if defined(KICAD_NANOMETRE)
......
...@@ -426,3 +426,17 @@ bool EDA_APP::OnInit() ...@@ -426,3 +426,17 @@ bool EDA_APP::OnInit()
void EDA_APP::MacOpenFile(const wxString &fileName) void EDA_APP::MacOpenFile(const wxString &fileName)
{ {
} }
/**
* @copydoc
*
* This is a dummy since KiCad doesn't perform any interal unit formatting.
*/
/** @todo Remove FormatBIU() when the common DSO/DSL code is implemented. */
std::string FormatBIU( int aValue )
{
return "";
}
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <trigo.h> #include <trigo.h>
#include <common.h> #include <common.h>
#include <macros.h> #include <macros.h>
#include <kicad_string.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <class_base_screen.h> #include <class_base_screen.h>
...@@ -223,6 +224,14 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) ...@@ -223,6 +224,14 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
} }
void EDA_ITEM::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
wxFAIL_MSG( wxString::Format( wxT( "Format method not defined for item type %s." ),
GetChars( GetClass() ) ) );
}
#if defined(DEBUG) #if defined(DEBUG)
// A function that should have been in wxWidgets // A function that should have been in wxWidgets
...@@ -546,6 +555,85 @@ wxString EDA_TEXT::GetTextStyleName() ...@@ -546,6 +555,85 @@ wxString EDA_TEXT::GetTextStyleName()
} }
bool EDA_TEXT::IsDefaultFormatting() const
{
return ( ( m_Size.x == DEFAULT_SIZE_TEXT )
&& ( m_Size.y == DEFAULT_SIZE_TEXT )
&& ( m_Attributs == 0 )
&& ( m_Mirror == false )
&& ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER )
&& ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER )
&& ( m_Thickness == 0 )
&& ( m_Italic == false )
&& ( m_Bold == false )
&& ( m_MultilineAllowed == false ) );
}
void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(text %s (at %s",
EscapedUTF8( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );
if( m_Orient != 0.0 )
aFormatter->Print( aNestLevel, "%0.1f", m_Orient );
aFormatter->Print( aNestLevel, ")\n" );
if( !IsDefaultFormatting() )
{
aFormatter->Print( aNestLevel+1, "(effects\n" );
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) || m_Bold
|| m_Italic )
{
aFormatter->Print( aNestLevel+2, "(font" );
// Add font support here at some point in the future.
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) )
aFormatter->Print( aNestLevel+2, " (size %s)", FormatBIU( m_Size ).c_str() );
if( m_Bold )
aFormatter->Print( aNestLevel+2, " bold" );
if( m_Bold )
aFormatter->Print( aNestLevel+2, " italic" );
aFormatter->Print( aNestLevel+1, ")\n");
}
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|| ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
{
aFormatter->Print( aNestLevel+2, "(justify");
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
aFormatter->Print( aNestLevel+2,
(m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
aFormatter->Print( aNestLevel+2,
(m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
if( m_Mirror )
aFormatter->Print( aNestLevel+2, " mirror" );
aFormatter->Print( aNestLevel+2, ")\n" );
}
// As of now the only place this is used is in Eeschema to hide or show the text.
if( m_Attributs )
aFormatter->Print( aNestLevel+2, "hide" );
aFormatter->Print( aNestLevel+1, "\n)\n" );
}
aFormatter->Print( aNestLevel, ")\n" );
}
/******************/ /******************/
/* Class EDA_RECT */ /* Class EDA_RECT */
/******************/ /******************/
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <common.h> #include <common.h>
#include <macros.h>
// late arriving wxPAPER_A0, wxPAPER_A1 // late arriving wxPAPER_A0, wxPAPER_A1
#if wxABI_VERSION >= 20999 #if wxABI_VERSION >= 20999
...@@ -309,3 +311,22 @@ void PAGE_INFO::SetHeightMils( int aHeightInMils ) ...@@ -309,3 +311,22 @@ void PAGE_INFO::SetHeightMils( int aHeightInMils )
} }
} }
void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
// If page is A3 landscape, then it is assumed to be the default and is not written.
if( !IsDefault() )
{
aFormatter->Print( aNestLevel, "(page %s", TO_UTF8( GetType() ) );
// The page dimensions are only required for user defined page sizes.
if( GetType() == PAGE_INFO::Custom )
aFormatter->Print( aNestLevel, " %d %d", GetWidthMils(), GetHeightMils() );
if( IsCustom() && IsPortrait() )
aFormatter->Print( aNestLevel, " portrait" );
aFormatter->Print( aNestLevel, ")\n" );
}
}
...@@ -560,3 +560,15 @@ wxString& operator <<( wxString& aString, const wxPoint& aPos ) ...@@ -560,3 +560,15 @@ wxString& operator <<( wxString& aString, const wxPoint& aPos )
return aString; return aString;
} }
std::string FormatBIU( const wxPoint& aPoint )
{
return FormatBIU( aPoint.x ) + " " + FormatBIU( aPoint.y );
}
std::string FormatBIU( const wxSize& aSize )
{
return FormatBIU( aSize.GetWidth() ) + " " + FormatBIU( aSize.GetHeight() );
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <confirm.h> #include <confirm.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <kicad_string.h>
#include <worksheet.h> #include <worksheet.h>
#include <class_title_block.h> #include <class_title_block.h>
...@@ -1372,7 +1373,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi ...@@ -1372,7 +1373,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
{ {
if( jj < 26 ) if( jj < 26 )
Line.Printf( wxT( "%c" ), jj + 'A' ); Line.Printf( wxT( "%c" ), jj + 'A' );
else // I hope 52 identifiers are enought... else // I hope 52 identifiers are enough...
Line.Printf( wxT( "%c" ), 'a' + jj - 26 ); Line.Printf( wxT( "%c" ), 'a' + jj - 26 );
if( ii < yg - PAS_REF / 2 ) if( ii < yg - PAS_REF / 2 )
...@@ -1626,7 +1627,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition ) ...@@ -1626,7 +1627,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition )
yg = pageInfo.GetSizeMils().y - pageInfo.GetBottomMarginMils(); yg = pageInfo.GetSizeMils().y - pageInfo.GetBottomMarginMils();
// Get the Y axis identifier (A symbol A ... Z) // Get the Y axis identifier (A symbol A ... Z)
if( aPosition.y < refy || aPosition.y > yg ) // Ouside of Y limits if( aPosition.y < refy || aPosition.y > yg ) // Outside of Y limits
msg << wxT( "?" ); msg << wxT( "?" );
else else
{ {
...@@ -1637,7 +1638,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition ) ...@@ -1637,7 +1638,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition )
} }
// Get the X axis identifier (A number 1 ... n) // Get the X axis identifier (A number 1 ... n)
if( aPosition.x < refx || aPosition.x > xg ) // Ouside of X limits if( aPosition.x < refx || aPosition.x > xg ) // Outside of X limits
msg << wxT( "?" ); msg << wxT( "?" );
else else
{ {
...@@ -1660,3 +1661,42 @@ wxString EDA_DRAW_FRAME::GetScreenDesc() ...@@ -1660,3 +1661,42 @@ wxString EDA_DRAW_FRAME::GetScreenDesc()
<< GetScreen()->m_NumberOfScreen; << GetScreen()->m_NumberOfScreen;
return msg; return msg;
} }
void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
// Don't write the title block information if there is nothing to write.
if( !m_title.IsEmpty() || !m_date.IsEmpty() || !m_revision.IsEmpty()
|| !m_company.IsEmpty() || !m_comment1.IsEmpty() || !m_comment2.IsEmpty()
|| !m_comment3.IsEmpty() || !m_comment4.IsEmpty() )
{
aFormatter->Print( aNestLevel, "(title-block\n" );
if( !m_title.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(title %s)", EscapedUTF8( m_title ).c_str() );
if( !m_date.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(date %s)", EscapedUTF8( m_date ).c_str() );
if( !m_revision.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(rev %s)", EscapedUTF8( m_revision ).c_str() );
if( !m_company.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(company %s)", EscapedUTF8( m_company ).c_str() );
if( !m_comment1.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(comment1 %s)", EscapedUTF8( m_comment1 ).c_str() );
if( !m_comment2.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(comment2 %s)", EscapedUTF8( m_comment2 ).c_str() );
if( !m_comment3.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(comment3 %s)", EscapedUTF8( m_comment3 ).c_str() );
if( !m_comment4.IsEmpty() )
aFormatter->Print( aNestLevel+1, "\n(comment4 %s)", EscapedUTF8( m_comment4 ).c_str() );
aFormatter->Print( aNestLevel, "\n)\n" );
}
}
...@@ -84,7 +84,7 @@ class LIB_ITEM : public EDA_ITEM ...@@ -84,7 +84,7 @@ class LIB_ITEM : public EDA_ITEM
* @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's * @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's
* default color. * default color.
* @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.). * @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.).
* @param aDate A pointer to any object specific data required to perform the draw. * @param aData A pointer to any object specific data required to perform the draw.
* @param aTransform A reference to a #TRANSFORM object containing drawing transform. * @param aTransform A reference to a #TRANSFORM object containing drawing transform.
*/ */
virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <common.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -1497,3 +1498,20 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const ...@@ -1497,3 +1498,20 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
/**
* Function FormatBIU
* formats Eeschema internal units in mils to a string for s-expression output.
*
* @todo Move FormatBIU() where ever the common DSO/DSL code for Eeschema ends up.
*/
std::string FormatBIU( int aValue )
{
char buf[50];
int len;
len = snprintf( buf, 49, "%d", aValue );
return std::string( buf, len );
}
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <colors.h> #include <colors.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <richio.h>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
...@@ -712,6 +713,18 @@ public: ...@@ -712,6 +713,18 @@ public:
*/ */
virtual EDA_ITEM& operator=( const EDA_ITEM& aItem ); virtual EDA_ITEM& operator=( const EDA_ITEM& aItem );
/**
* Function Format
* outputs the object to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
/** /**
...@@ -812,7 +825,7 @@ public: ...@@ -812,7 +825,7 @@ public:
double m_Orient; ///< Orient in 0.1 degrees double m_Orient; ///< Orient in 0.1 degrees
wxPoint m_Pos; ///< XY position of anchor text. wxPoint m_Pos; ///< XY position of anchor text.
wxSize m_Size; ///< XY size of text wxSize m_Size; ///< XY size of text
bool m_Mirror; ///< true iff mirrored bool m_Mirror; ///< true if mirrored
int m_Attributs; ///< bit flags such as visible, etc. int m_Attributs; ///< bit flags such as visible, etc.
bool m_Italic; ///< should be italic font (if available) bool m_Italic; ///< should be italic font (if available)
bool m_Bold; ///< should be bold font (if available) bool m_Bold; ///< should be bold font (if available)
...@@ -852,6 +865,8 @@ public: ...@@ -852,6 +865,8 @@ public:
void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; } void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; }
bool IsMirrored() const { return m_Mirror; } bool IsMirrored() const { return m_Mirror; }
bool IsDefaultFormatting() const;
/** /**
* Function SetSize * Function SetSize
* sets text size. * sets text size.
...@@ -989,6 +1004,19 @@ public: ...@@ -989,6 +1004,19 @@ public:
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; }; EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; }; void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; }; void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; };
/**
* Function Format
* outputs the object to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
}; };
#endif // BASE_STRUCT_H_ #endif // BASE_STRUCT_H_
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#include <wx/string.h> #include <wx/string.h>
class OUTPUTFORMATTER;
class IO_ERROR;
extern wxString GenDate(); extern wxString GenDate();
...@@ -81,6 +85,18 @@ public: ...@@ -81,6 +85,18 @@ public:
m_comment4.clear(); m_comment4.clear();
} }
/**
* Function Format
* outputs the object to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
private: private:
wxString m_title; wxString m_title;
wxString m_date; wxString m_date;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <wx/confbase.h> #include <wx/confbase.h>
#include <wx/fileconf.h> #include <wx/fileconf.h>
#include <richio.h>
#if !wxUSE_PRINTING_ARCHITECTURE #if !wxUSE_PRINTING_ARCHITECTURE
# error "You must use '--enable-printarch' in your wx library configuration." # error "You must use '--enable-printarch' in your wx library configuration."
...@@ -134,6 +135,24 @@ enum EDA_UNITS_T { ...@@ -134,6 +135,24 @@ enum EDA_UNITS_T {
}; };
/**
* Function FormatBIU
* converts coordinate \a aValue from the application specific internal units to a string
* appropriate to write to an #OUTPUTFORMATTER in the s-expression file formats.
*
* @note A separate version of this function exists for Pcbnew and Eeschema. This removes
* the runtime dependency for converting coordinates to the appropriate application.
* Do not add any runtime conversions to either the Pcbnew or Eeschema implementation
* of this function.
* @param aValue The value in application specific internal units to convert.
* @return An s-expression appropriate string containing the converted value in millimeters.
*/
extern std::string FormatBIU( int aValue );
extern std::string FormatBIU( const wxPoint& aPoint );
extern std::string FormatBIU( const wxSize& aSize );
// forward declarations: // forward declarations:
class LibNameList; class LibNameList;
...@@ -185,12 +204,19 @@ public: ...@@ -185,12 +204,19 @@ public:
* and will be set according to <b>previous</b> calls to * and will be set according to <b>previous</b> calls to
* static PAGE_INFO::SetUserWidthMils() and * static PAGE_INFO::SetUserWidthMils() and
* static PAGE_INFO::SetUserHeightMils(); * static PAGE_INFO::SetUserHeightMils();
* @param IsPortrait Set to true to set page orientation to portrait mode.
* *
* @return bool - true iff @a aStandarePageDescription was a recognized type. * @return bool - true if @a aStandarePageDescription was a recognized type.
*/ */
bool SetType( const wxString& aStandardPageDescriptionName, bool IsPortrait = false ); bool SetType( const wxString& aStandardPageDescriptionName, bool IsPortrait = false );
const wxString& GetType() const { return m_type; } const wxString& GetType() const { return m_type; }
/**
* Function IsDefault
* @return True if the object has the default page settings which are A3, landscape.
*/
bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; }
/** /**
* Function IsCustom * Function IsCustom
* returns true if the type is Custom * returns true if the type is Custom
...@@ -327,6 +353,18 @@ public: ...@@ -327,6 +353,18 @@ public:
static wxArrayString GetStandardSizes(); static wxArrayString GetStandardSizes();
*/ */
/**
* Function Format
* outputs the page class to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
protected: protected:
// only the class implementation(s) may use this constructor // only the class implementation(s) may use this constructor
PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId ); PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId );
...@@ -612,7 +650,7 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); ...@@ -612,7 +650,7 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value );
/** /**
* Function GenDate * Function GenDate
* @return A wsString object containg the date in the format "day month year" like * @return A wxString object containing the date in the format "day month year" like
* "23 jun 2005". * "23 jun 2005".
*/ */
wxString GenDate(); wxString GenDate();
......
...@@ -298,3 +298,16 @@ void KICAD_MANAGER_FRAME::SaveSettings() ...@@ -298,3 +298,16 @@ void KICAD_MANAGER_FRAME::SaveSettings()
cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x );
} }
/**
* Function FormatBIU
* is a dummy function to prevent link errors since KiCad doesn't perform any interal
* unit formatting.
*
* @todo Remove FormatBIU() when the common DSO/DSL code is implemented.
*/
std::string FormatBIU( int aValue )
{
return "";
}
...@@ -243,3 +243,15 @@ void PCB_CALCULATOR_FRAME::OnPaintTranslinePanel( wxPaintEvent& event ) ...@@ -243,3 +243,15 @@ void PCB_CALCULATOR_FRAME::OnPaintTranslinePanel( wxPaintEvent& event )
event.Skip(); event.Skip();
} }
/**
* @copydoc
*
* This is a dummy since KiCad doesn't perform any interal unit formatting.
*/
/** @todo Remove FormatBIU() when the common DSO/DSL code is implemented. */
std::string FormatBIU( int aValue )
{
return "";
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <kicad_string.h>
#include <pcbcommon.h> #include <pcbcommon.h>
#include <wxBasePcbFrame.h> #include <wxBasePcbFrame.h>
...@@ -207,14 +208,14 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* ...@@ -207,14 +208,14 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS*
void BOARD::PushHighLight() void BOARD::PushHighLight()
{ {
m_hightLightPrevious = m_hightLight; m_highLightPrevious = m_highLight;
} }
void BOARD::PopHighLight() void BOARD::PopHighLight()
{ {
m_hightLight = m_hightLightPrevious; m_highLight = m_highLightPrevious;
m_hightLightPrevious.Clear(); m_highLightPrevious.Clear();
} }
...@@ -1065,7 +1066,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -1065,7 +1066,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
// So usually, connected tracks or vias are grouped in this list // So usually, connected tracks or vias are grouped in this list
// So the algorithm (used in ratsnest computations) which computes the // So the algorithm (used in ratsnest computations) which computes the
// track connectivity is faster (more than 100 time regarding to // track connectivity is faster (more than 100 time regarding to
// a non ordered list) because when it searches for a connexion, first // a non ordered list) because when it searches for a connection, first
// it tests the near (near in term of linked list) 50 items // it tests the near (near in term of linked list) 50 items
// from the current item (track or via) in test. // from the current item (track or via) in test.
// Usually, because of this sort, a connected item (if exists) is // Usually, because of this sort, a connected item (if exists) is
...@@ -2148,6 +2149,195 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS ...@@ -2148,6 +2149,195 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
} }
void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(general\n" );
aFormatter->Print( aNestLevel+1, "(links %d)\n", GetRatsnestsCount() );
aFormatter->Print( aNestLevel+1, "(no-connects %d)\n", m_NbNoconnect );
// Write Bounding box info
aFormatter->Print( aNestLevel+1, "(area %s %s %s %s)\n",
FormatBIU( m_BoundingBox.GetX() ).c_str(),
FormatBIU( m_BoundingBox.GetY() ).c_str(),
FormatBIU( m_BoundingBox.GetRight() ).c_str(),
FormatBIU( m_BoundingBox.GetBottom() ).c_str() );
aFormatter->Print( aNestLevel+1, "(thickness %s)\n",
FormatBIU( GetDesignSettings().m_BoardThickness ).c_str() );
aFormatter->Print( aNestLevel+1, "(drawings %d)\n", m_Drawings.GetCount() );
aFormatter->Print( aNestLevel+1, "(tracks %d)\n", GetNumSegmTrack() );
aFormatter->Print( aNestLevel+1, "(zones %d)\n", GetNumSegmZone() );
aFormatter->Print( aNestLevel+1, "(modules %d)\n", m_Modules.GetCount() );
aFormatter->Print( aNestLevel+1, "(nets %d)\n", GetNetCount() );
aFormatter->Print( aNestLevel, ")\n\n" );
m_paper.Format( aFormatter, aNestLevel, aControlBits );
m_titles.Format( aFormatter, aNestLevel, aControlBits );
// Layers.
aFormatter->Print( aNestLevel, "(layers %d %08X", GetCopperLayerCount(), GetEnabledLayers() );
if( GetEnabledLayers() != GetVisibleLayers() )
aFormatter->Print( aNestLevel+1, " %08X", GetVisibleLayers() );
unsigned layerMask = ALL_CU_LAYERS & GetEnabledLayers();
for( int layer = 0; layerMask; ++layer, layerMask >>= 1 )
{
if( layerMask & 1 )
{
aFormatter->Print( aNestLevel+1, "(layer%d %s %s\n", layer,
TO_UTF8( GetLayerName( layer ) ),
LAYER::ShowType( GetLayerType( layer ) ) );
}
}
aFormatter->Print( aNestLevel, ")\n\n" );
// Setup
aFormatter->Print( aNestLevel, "(setup\n" );
// Save current default track width, for compatibility with older Pcbnew version;
aFormatter->Print( aNestLevel+1, "(last-trace-width %s)\n",
FormatBIU( m_TrackWidthList[m_TrackWidthSelector] ).c_str() );
// Save custom tracks width list (the first is not saved here: this is the netclass value
for( unsigned ii = 1; ii < m_TrackWidthList.size(); ii++ )
aFormatter->Print( aNestLevel+1, "(user-trace-width%d %s)\n",
ii+1, FormatBIU( m_TrackWidthList[ii] ).c_str() );
aFormatter->Print( aNestLevel+1, "(trace-clearance %s)\n)",
FormatBIU( m_NetClasses.GetDefault()->GetClearance() ).c_str() );
// ZONE_SETTINGS
aFormatter->Print( aNestLevel+1, "(zone-clearance %s)\n",
FormatBIU( GetZoneSettings().m_ZoneClearance ).c_str() );
aFormatter->Print( aNestLevel+1, "(zone-45-only %d)\n", GetZoneSettings().m_Zone_45_Only );
aFormatter->Print( aNestLevel+1, "(trace-min %s)\n",
FormatBIU( GetDesignSettings().m_TrackMinWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(segment-width %s)\n",
FormatBIU( GetDesignSettings().m_DrawSegmentWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(edge-width %s)\n",
FormatBIU( GetDesignSettings().m_EdgeSegmentWidth ).c_str() );
// Save current default via size, for compatibility with older Pcbnew version;
aFormatter->Print( aNestLevel+1, "(via-size %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via-drill %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetViaDrill() ).c_str() );
aFormatter->Print( aNestLevel+1, "(via-min-size %s)\n",
FormatBIU( GetDesignSettings().m_ViasMinSize ).c_str() );
aFormatter->Print( aNestLevel+1, "(via_min_drill %s)\n",
FormatBIU( GetDesignSettings().m_ViasMinDrill ).c_str() );
// Save custom vias diameters list (the first is not saved here: this is
// the netclass value
for( unsigned ii = 1; ii < m_ViasDimensionsList.size(); ii++ )
aFormatter->Print( aNestLevel+1, "(user-via%d %s %s)\n", ii,
FormatBIU( m_ViasDimensionsList[ii].m_Diameter ).c_str(),
FormatBIU( m_ViasDimensionsList[ii].m_Drill ).c_str() );
// for old versions compatibility:
aFormatter->Print( aNestLevel+1, "(uvia-size %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetuViaDiameter() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia-drill %s)\n",
FormatBIU( m_NetClasses.GetDefault()->GetuViaDrill() ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvias_allow %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasAllowed ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia-min-size %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasMinSize ).c_str() );
aFormatter->Print( aNestLevel+1, "(uvia-min-drill %s)\n",
FormatBIU( GetDesignSettings().m_MicroViasMinDrill ).c_str() );
aFormatter->Print( aNestLevel+1, "(pcb-text-width %s)\n",
FormatBIU( GetDesignSettings().m_PcbTextWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(pcb-text-size %s %s)\n",
FormatBIU( GetDesignSettings().m_PcbTextSize.x ).c_str(),
FormatBIU( GetDesignSettings().m_PcbTextSize.y ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod-edge-width %s)\n",
FormatBIU( GetDesignSettings().m_ModuleSegmentWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod-text-size %s %s)\n",
FormatBIU( GetDesignSettings().m_ModuleTextSize.x ).c_str(),
FormatBIU( GetDesignSettings().m_ModuleTextSize.y ).c_str() );
aFormatter->Print( aNestLevel+1, "(mod-text-width %s)\n",
FormatBIU( GetDesignSettings().m_ModuleTextWidth ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad-size %s %s)\n",
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str(),
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad-drill %s)\n",
FormatBIU( GetDesignSettings().m_Pad_Master.GetDrillSize().x ).c_str() );
aFormatter->Print( aNestLevel+1, "(pad-to-mask-clearance %s)\n",
FormatBIU( GetDesignSettings().m_SolderMaskMargin ).c_str() );
if( GetDesignSettings().m_SolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(pad-to-paste-clearance %s)\n",
FormatBIU( GetDesignSettings().m_SolderPasteMargin ).c_str() );
if( GetDesignSettings().m_SolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(pad-to-paste-clearance-ratio %g)\n",
GetDesignSettings().m_SolderPasteMarginRatio );
aFormatter->Print( aNestLevel+1, "(aux-axis-origin %s %s)\n",
FormatBIU( GetOriginAxisPosition().x ).c_str(),
FormatBIU( GetOriginAxisPosition().y ).c_str() );
aFormatter->Print( aNestLevel+1, "(visible-elements %X)\n",
GetDesignSettings().GetVisibleElements() );
aFormatter->Print( aNestLevel, ")\n\n" );
int netcount = GetNetCount();
for( int i = 0; i < netcount; ++i )
aFormatter->Print( aNestLevel, "(net %d %s)\n",
FindNet( i )->GetNet(),
EscapedUTF8( FindNet( i )->GetNetname() ).c_str() );
// Save the default net class first.
m_NetClasses.GetDefault()->Format( aFormatter, aNestLevel, aControlBits );
// Save the rest of the net classes alphabetically.
for( NETCLASSES::const_iterator it = m_NetClasses.begin(); it != m_NetClasses.end(); ++it )
{
NETCLASS* netclass = it->second;
netclass->Format( aFormatter, aNestLevel, aControlBits );
}
// Save the modules.
for( MODULE* module = m_Modules; module; module = (MODULE*) module->Next() )
module->Format( aFormatter, aNestLevel, aControlBits );
// Save the graphical items on the board (not owned by a module)
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
item->Format( aFormatter, aNestLevel, aControlBits );
}
// Do not save MARKER_PCBs, they can be regenerated easily.
// Save the tracks and vias.
for( TRACK* track = m_Track; track; track = track->Next() )
track->Format( aFormatter, aNestLevel, aControlBits );
// Save the old obsolete zones which were done by segments (tracks).
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
zone->Format( aFormatter, aNestLevel, aControlBits );
// Save the polygon (which are the newer technology) zones.
for( int i=0; i < GetAreaCount(); ++i )
GetArea( i )->Format( aFormatter, aNestLevel, aControlBits );
aFormatter->Print( aNestLevel, "\n)\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void BOARD::Show( int nestLevel, std::ostream& os ) const void BOARD::Show( int nestLevel, std::ostream& os ) const
......
...@@ -165,9 +165,9 @@ private: ...@@ -165,9 +165,9 @@ private:
ZONE_CONTAINERS m_ZoneDescriptorList; ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_COPPER_LAYERS]; LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used // if true m_highLight_NetCode is used
HIGH_LIGHT_INFO m_hightLight; // current high light data HIGH_LIGHT_INFO m_highLight; // current high light data
HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
int m_fileFormatVersionAtLoad; ///< the version in the *.brd header on first line int m_fileFormatVersionAtLoad; ///< the version in the *.brd header on first line
...@@ -195,6 +195,9 @@ private: ...@@ -195,6 +195,9 @@ private:
*/ */
void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList ); void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList );
void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
int aControlBits ) const
throw( IO_ERROR );
public: public:
...@@ -342,15 +345,15 @@ public: ...@@ -342,15 +345,15 @@ public:
*/ */
void ResetHighLight() void ResetHighLight()
{ {
m_hightLight.Clear(); m_highLight.Clear();
m_hightLightPrevious.Clear(); m_highLightPrevious.Clear();
} }
/** /**
* Function GetHighLightNetCode * Function GetHighLightNetCode
* @return netcode of net to highlight (-1 when no net selected) * @return netcode of net to highlight (-1 when no net selected)
*/ */
int GetHighLightNetCode() { return m_hightLight.m_netCode; } int GetHighLightNetCode() { return m_highLight.m_netCode; }
/** /**
* Function SetHighLightNet * Function SetHighLightNet
...@@ -358,27 +361,27 @@ public: ...@@ -358,27 +361,27 @@ public:
*/ */
void SetHighLightNet( int aNetCode) void SetHighLightNet( int aNetCode)
{ {
m_hightLight.m_netCode = aNetCode; m_highLight.m_netCode = aNetCode;
} }
/** /**
* Function IsHighLightNetON * Function IsHighLightNetON
* @return true if a net is currently highlighted * @return true if a net is currently highlighted
*/ */
bool IsHighLightNetON() { return m_hightLight.m_highLightOn; } bool IsHighLightNetON() { return m_highLight.m_highLightOn; }
/** /**
* Function HighLightOFF * Function HighLightOFF
* Disable highlight. * Disable highlight.
*/ */
void HighLightOFF() { m_hightLight.m_highLightOn = false; } void HighLightOFF() { m_highLight.m_highLightOn = false; }
/** /**
* Function HighLightON * Function HighLightON
* Enable highlight. * Enable highlight.
* if m_hightLight_NetCode >= 0, this net will be highlighted * if m_highLight_NetCode >= 0, this net will be highlighted
*/ */
void HighLightON() { m_hightLight.m_highLightOn = true; } void HighLightON() { m_highLight.m_highLightOn = true; }
/** /**
* Function PushHighLight * Function PushHighLight
...@@ -877,24 +880,16 @@ public: ...@@ -877,24 +880,16 @@ public:
/***************************************************************************/ /***************************************************************************/
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const wxString GetClass() const
{ {
return wxT( "BOARD" ); return wxT( "BOARD" );
} }
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
...@@ -1192,7 +1187,7 @@ public: ...@@ -1192,7 +1187,7 @@ public:
/** /**
* Function GetPadFast * Function GetPadFast
* return pad found at \a aPosition on \a aLayer uning the fast search method. * return pad found at \a aPosition on \a aLayer using the fast search method.
* <p> * <p>
* The fast search method only works if the pad list has already been built. * The fast search method only works if the pad list has already been built.
* </p> * </p>
...@@ -1204,7 +1199,7 @@ public: ...@@ -1204,7 +1199,7 @@ public:
/** /**
* Function GetPad * Function GetPad
* locates the pad connected at \a aPosition on \a aLayer starting at list postion * locates the pad connected at \a aPosition on \a aLayer starting at list position
* \a aPad * \a aPad
* <p> * <p>
* This function uses a fast search in this sorted pad list and it is faster than * This function uses a fast search in this sorted pad list and it is faster than
......
...@@ -62,3 +62,34 @@ wxString BOARD_ITEM::GetLayerName() const ...@@ -62,3 +62,34 @@ wxString BOARD_ITEM::GetLayerName() const
return layerName; return layerName;
} }
/** @todo Move Pcbnew version of FormatBIU() where ever the common DSO/DSL code ends up. */
std::string FormatBIU( int aValue )
{
#if !defined( USE_PCBNEW_NANOMETERS )
wxFAIL_MSG( wxT( "Cannot use FormatBIU() unless Pcbnew is build with PCBNEW_NANOMETERS=ON." ) );
#endif
char buf[50];
double engUnits = aValue / 1000000.0;
int len;
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
{
// printf( "f: " );
len = snprintf( buf, 49, "%.10f", engUnits );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
++len;
}
else
{
// printf( "g: " );
len = snprintf( buf, 49, "%.10g", engUnits );
}
return std::string( buf, len );
}
...@@ -606,3 +606,58 @@ EDA_ITEM* DIMENSION::Clone() const ...@@ -606,3 +606,58 @@ EDA_ITEM* DIMENSION::Clone() const
{ {
return new DIMENSION( *this ); return new DIMENSION( *this );
} }
void DIMENSION::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(dimension %s\n", FormatBIU( m_Value ).c_str() );
aFormatter->Print( aNestLevel+1, "(width %s)\n(layer %d)\n(tstamp %lX)\n",
FormatBIU( m_Width ).c_str(), GetLayer(), GetTimeStamp() );
m_Text.EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );
aFormatter->Print( aNestLevel+1, "(feature1 pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_featureLineDOx ).c_str(),
FormatBIU( m_featureLineDOy ).c_str(),
FormatBIU( m_featureLineDFx ).c_str(),
FormatBIU( m_featureLineDFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(feature2 pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_featureLineGOx ).c_str(),
FormatBIU( m_featureLineGOy ).c_str(),
FormatBIU( m_featureLineGFx ).c_str(),
FormatBIU( m_featureLineGFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(crossbar pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_crossBarOx ).c_str(),
FormatBIU( m_crossBarOy ).c_str(),
FormatBIU( m_crossBarFx ).c_str(),
FormatBIU( m_crossBarFy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow1a pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowD1Ox ).c_str(),
FormatBIU( m_arrowD1Oy ).c_str(),
FormatBIU( m_arrowD1Fx ).c_str(),
FormatBIU( m_arrowD1Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow1b pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowD2Ox ).c_str(),
FormatBIU( m_arrowD2Oy ).c_str(),
FormatBIU( m_arrowD2Fx ).c_str(),
FormatBIU( m_arrowD2Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow2a pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowG1Ox ).c_str(),
FormatBIU( m_arrowG1Oy ).c_str(),
FormatBIU( m_arrowG1Fx ).c_str(),
FormatBIU( m_arrowG1Fy ).c_str() );
aFormatter->Print( aNestLevel+1, "(arrow2b pts((xy %s %s) (xy %s %s)))\n",
FormatBIU( m_arrowG2Ox ).c_str(),
FormatBIU( m_arrowG2Oy ).c_str(),
FormatBIU( m_arrowG2Fx ).c_str(),
FormatBIU( m_arrowG2Fy ).c_str() );
aFormatter->Print( aNestLevel, ")\n" );
}
...@@ -44,7 +44,7 @@ class DIMENSION : public BOARD_ITEM ...@@ -44,7 +44,7 @@ class DIMENSION : public BOARD_ITEM
public: public:
int m_Width; int m_Width;
wxPoint m_Pos; wxPoint m_Pos;
int m_Shape; int m_Shape; /// Current always 0.
int m_Unit; /// 0 = inches, 1 = mm int m_Unit; /// 0 = inches, 1 = mm
int m_Value; /// value of PCB dimensions. int m_Value; /// value of PCB dimensions.
...@@ -138,6 +138,9 @@ public: ...@@ -138,6 +138,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
......
...@@ -284,7 +284,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx ...@@ -284,7 +284,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
} }
break; break;
case S_CURVE: case S_CURVE:
m_BezierPoints = Bezier2Poly(m_Start,m_BezierC1, m_BezierC2, m_End); m_BezierPoints = Bezier2Poly(m_Start, m_BezierC1, m_BezierC2, m_End);
for (unsigned int i=1; i < m_BezierPoints.size(); i++) { for (unsigned int i=1; i < m_BezierPoints.size(); i++) {
if( mode == LINE ) if( mode == LINE )
...@@ -544,6 +544,70 @@ EDA_ITEM* DRAWSEGMENT::Clone() const ...@@ -544,6 +544,70 @@ EDA_ITEM* DRAWSEGMENT::Clone() const
} }
void DRAWSEGMENT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
unsigned i;
aFormatter->Print( aNestLevel, "(draw " );
switch( m_Shape )
{
case S_SEGMENT: // Line
aFormatter->Print( aNestLevel, "line (pts xy(%s) xy(%s))",
FormatBIU( m_Start ).c_str(),
FormatBIU( m_End ).c_str() );
break;
case S_CIRCLE: // Circle
aFormatter->Print( aNestLevel, "circle (center (xy %s)) (end (xy %s))",
FormatBIU( m_Start ).c_str(),
FormatBIU( m_End ).c_str() );
break;
case S_ARC: // Arc
aFormatter->Print( aNestLevel, "arc (start (xy %s)) (end (xy %s)) (angle %0.1f)",
FormatBIU( m_Start ).c_str(),
FormatBIU( m_End ).c_str(),
m_Angle );
break;
case S_POLYGON: // Polygon
aFormatter->Print( aNestLevel, "line (pts" );
for( i = 0; i<m_PolyPoints.size(); ++i )
aFormatter->Print( aNestLevel, " (xy %s)", FormatBIU( m_PolyPoints[i] ).c_str() );
aFormatter->Print( aNestLevel, ")" );
break;
case S_CURVE: // Bezier curve
aFormatter->Print( aNestLevel, "curve pts(xy(%s) xy(%s) xy(%s) xy(%s))",
FormatBIU( m_Start ).c_str(),
FormatBIU( m_BezierC1 ).c_str(),
FormatBIU( m_BezierC2 ).c_str(),
FormatBIU( m_End ).c_str() );
break;
default:
wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
};
aFormatter->Print( aNestLevel, " (layer %d)", GetLayer() );
if( m_Width != 0 )
aFormatter->Print( aNestLevel, " (width %s)", FormatBIU( m_Width ).c_str() );
if( GetTimeStamp() )
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
if( GetStatus() )
aFormatter->Print( aNestLevel, " (status %X)", GetStatus() );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void DRAWSEGMENT::Show( int nestLevel, std::ostream& os ) const void DRAWSEGMENT::Show( int nestLevel, std::ostream& os ) const
{ {
......
...@@ -51,7 +51,7 @@ protected: ...@@ -51,7 +51,7 @@ protected:
int m_Type; ///< Used in complex associations ( Dimensions.. ) int m_Type; ///< Used in complex associations ( Dimensions.. )
double m_Angle; ///< Used only for Arcs: Arc angle in 1/10 deg double m_Angle; ///< Used only for Arcs: Arc angle in 1/10 deg
wxPoint m_BezierC1; ///< Bezier Control Point 1 wxPoint m_BezierC1; ///< Bezier Control Point 1
wxPoint m_BezierC2; ///< Bezier Control Point 1 wxPoint m_BezierC2; ///< Bezier Control Point 2
std::vector<wxPoint> m_BezierPoints; std::vector<wxPoint> m_BezierPoints;
std::vector<wxPoint> m_PolyPoints; std::vector<wxPoint> m_PolyPoints;
...@@ -219,6 +219,9 @@ public: ...@@ -219,6 +219,9 @@ public:
virtual EDA_ITEM* Clone() const; virtual EDA_ITEM* Clone() const;
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -279,6 +279,16 @@ EDA_ITEM* EDGE_MODULE::Clone() const ...@@ -279,6 +279,16 @@ EDA_ITEM* EDGE_MODULE::Clone() const
} }
void EDGE_MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(edge (start (xy %s)) (end (xy %s))\n",
FormatBIU( m_Start0 ).c_str(), FormatBIU( m_End0 ).c_str() );
DRAWSEGMENT::Format( aFormatter, aNestLevel+1, aControlBits );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) const void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) const
......
...@@ -91,6 +91,9 @@ public: ...@@ -91,6 +91,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -223,3 +223,23 @@ EDA_ITEM* PCB_TARGET::Clone() const ...@@ -223,3 +223,23 @@ EDA_ITEM* PCB_TARGET::Clone() const
{ {
return new PCB_TARGET( *this ); return new PCB_TARGET( *this );
} }
void PCB_TARGET::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(target %c (pos (xy %s)) (size %s)",
( m_Shape ) ? 'x' : '+',
FormatBIU( m_Pos ).c_str(),
FormatBIU( m_Size ).c_str() );
if( m_Width != 0 )
aFormatter->Print( aNestLevel, " (width %s)", FormatBIU( m_Width ).c_str() );
aFormatter->Print( aNestLevel, " (layer %d)", GetLayer() );
if( GetTimeStamp() )
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
aFormatter->Print( aNestLevel, ")\n" );
}
...@@ -107,6 +107,9 @@ public: ...@@ -107,6 +107,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
......
...@@ -663,6 +663,125 @@ EDA_ITEM* MODULE::Clone() const ...@@ -663,6 +663,125 @@ EDA_ITEM* MODULE::Clone() const
} }
void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(module %s" , EscapedUTF8( m_LibRef ).c_str() );
if( IsLocked() )
aFormatter->Print( aNestLevel, " locked" );
if( IsPlaced() )
aFormatter->Print( aNestLevel, " placed" );
aFormatter->Print( aNestLevel, " (tedit %lX) (tstamp %lX)\n",
GetLastEditTime(), GetTimeStamp() );
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos ).c_str() );
if( m_Orient != 0.0 )
aFormatter->Print( aNestLevel+1, " %0.1f", m_Orient );
aFormatter->Print( aNestLevel+1, ")\n" );
if( !m_Doc.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(descr %s)\n", EscapedUTF8( m_Doc ).c_str() );
if( !m_KeyWord.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(tags %s)\n", EscapedUTF8( m_KeyWord ).c_str() );
if( !m_Path.IsEmpty() )
aFormatter->Print( aNestLevel+1, "(path %s)\n", EscapedUTF8( m_Path ).c_str() );
if( m_CntRot90 != 0 )
aFormatter->Print( aNestLevel+1, "(autoplace-cost90 %d)\n", m_CntRot90 );
if( m_CntRot180 != 0 )
aFormatter->Print( aNestLevel+1, "(autoplace-cost180 %d)\n", m_CntRot180 );
if( m_LocalSolderMaskMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder-mask-margin %s)\n",
FormatBIU( m_LocalSolderMaskMargin ).c_str() );
if( m_LocalSolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder-paste-margin %s)\n",
FormatBIU( m_LocalSolderPasteMargin ).c_str() );
if( m_LocalSolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(solder-paste-ratio %g)\n",
m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 )
aFormatter->Print( aNestLevel+1, "(clearance %s)\n",
FormatBIU( m_LocalClearance ).c_str() );
if( m_ZoneConnection != UNDEFINED_CONNECTION )
aFormatter->Print( aNestLevel+1, "(zone-connect %d)\n", m_ZoneConnection );
if( m_ThermalWidth != 0 )
aFormatter->Print( aNestLevel+1, "(thermal-width %s)\n",
FormatBIU( m_ThermalWidth ).c_str() );
if( m_ThermalGap != 0 )
aFormatter->Print( aNestLevel+1, "(thermal-gap %s)\n",
FormatBIU( m_ThermalGap ).c_str() );
// Attributes
if( m_Attributs != MOD_DEFAULT )
{
aFormatter->Print( aNestLevel+1, "(attr " );
if( m_Attributs & MOD_CMS )
aFormatter->Print( aNestLevel+1, " smd" );
if( m_Attributs & MOD_VIRTUAL )
aFormatter->Print( aNestLevel+1, " virtual" );
aFormatter->Print( aNestLevel+1, ")\n" );
}
m_Reference->Format( aFormatter, aNestLevel+1, aControlBits );
m_Value->Format( aFormatter, aNestLevel+1, aControlBits );
// Save drawing elements.
for( BOARD_ITEM* gr = m_Drawings; gr; gr = gr->Next() )
gr->Format( aFormatter+1, aNestLevel, aControlBits );
// Save pads.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
pad->Format( aFormatter+1, aNestLevel, aControlBits );
// Save 3D info.
for( S3D_MASTER* t3D = m_3D_Drawings; t3D; t3D = t3D->Next() )
{
if( !t3D->m_Shape3DName.IsEmpty() )
{
aFormatter->Print( aNestLevel+1, "(3d-shape %s\n",
EscapedUTF8( t3D->m_Shape3DName ).c_str() );
aFormatter->Print( aNestLevel+2, "(at (xyz %.16g %.16g %.16g))\n",
t3D->m_MatPosition.x,
t3D->m_MatPosition.y,
t3D->m_MatPosition.z );
aFormatter->Print( aNestLevel+2, "(scale (xyz %lf %lf %lf))\n",
t3D->m_MatScale.x,
t3D->m_MatScale.y,
t3D->m_MatScale.z );
aFormatter->Print( aNestLevel+2, "(rotate (xyz %.16g %.16g %.16g))\n",
t3D->m_MatRotation.x,
t3D->m_MatRotation.y,
t3D->m_MatRotation.z );
aFormatter->Print( aNestLevel+1, ")\n" );
}
}
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void MODULE::Show( int nestLevel, std::ostream& os ) const void MODULE::Show( int nestLevel, std::ostream& os ) const
......
...@@ -346,6 +346,9 @@ public: ...@@ -346,6 +346,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -290,28 +290,55 @@ void NETCLASS::Show( int nestLevel, std::ostream& os ) const ...@@ -290,28 +290,55 @@ void NETCLASS::Show( int nestLevel, std::ostream& os ) const
#endif #endif
int NETCLASS::GetTrackMinWidth() const int NETCLASS::GetTrackMinWidth() const
{ {
return m_Parent->GetDesignSettings().m_TrackMinWidth; return m_Parent->GetDesignSettings().m_TrackMinWidth;
} }
int NETCLASS::GetViaMinDiameter() const int NETCLASS::GetViaMinDiameter() const
{ {
return m_Parent->GetDesignSettings().m_ViasMinSize; return m_Parent->GetDesignSettings().m_ViasMinSize;
} }
int NETCLASS::GetViaMinDrill() const int NETCLASS::GetViaMinDrill() const
{ {
return m_Parent->GetDesignSettings().m_ViasMinDrill; return m_Parent->GetDesignSettings().m_ViasMinDrill;
} }
int NETCLASS::GetuViaMinDiameter() const int NETCLASS::GetuViaMinDiameter() const
{ {
return m_Parent->GetDesignSettings().m_MicroViasMinSize; return m_Parent->GetDesignSettings().m_MicroViasMinSize;
} }
int NETCLASS::GetuViaMinDrill() const int NETCLASS::GetuViaMinDrill() const
{ {
return m_Parent->GetDesignSettings().m_MicroViasMinDrill; return m_Parent->GetDesignSettings().m_MicroViasMinDrill;
} }
void NETCLASS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(net-class %s %s\n",
EscapedUTF8( GetName() ).c_str(),
EscapedUTF8( GetDescription() ).c_str() );
aFormatter->Print( aNestLevel+1, "(clearance %d)\n", GetClearance() );
aFormatter->Print( aNestLevel+1, "(trace-width %d)\n", GetTrackWidth() );
aFormatter->Print( aNestLevel+1, "(via-dia %d)\n", GetViaDiameter() );
aFormatter->Print( aNestLevel+1, "(via-drill %d)\n", GetViaDrill() );
aFormatter->Print( aNestLevel+1, "(uvia-dia %d)\n", GetuViaDiameter() );
aFormatter->Print( aNestLevel+1, "(uvia-drill %d)\n", GetuViaDrill() );
for( NETCLASS::const_iterator it = begin(); it!= end(); ++it )
aFormatter->Print( aNestLevel+1, "(add-net %s)\n", EscapedUTF8( *it ).c_str() );
aFormatter->Print( aNestLevel, ")\n" );
}
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <wx/string.h> #include <wx/string.h>
#include <richio.h>
class LINE_READER; class LINE_READER;
class BOARD; class BOARD;
...@@ -212,6 +214,18 @@ public: ...@@ -212,6 +214,18 @@ public:
*/ */
bool ReadDescr( LINE_READER* aReader ); bool ReadDescr( LINE_READER* aReader );
/**
* Function Format
* outputs the net class to \a aFormatter in s-expression form.
*
* @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level.
* @param aControlBits The control bit definition for object specific formatting.
* @throw IO_ERROR on write error.
*/
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
...@@ -243,7 +257,7 @@ public: ...@@ -243,7 +257,7 @@ public:
/** /**
* Function Clear * Function Clear
* destroys any constained NETCLASS instances except the Default one. * destroys any contained NETCLASS instances except the Default one.
*/ */
void Clear(); void Clear();
...@@ -306,4 +320,3 @@ public: ...@@ -306,4 +320,3 @@ public:
}; };
#endif // CLASS_NETCLASS_H #endif // CLASS_NETCLASS_H
...@@ -829,6 +829,100 @@ EDA_ITEM* D_PAD::Clone() const ...@@ -829,6 +829,100 @@ EDA_ITEM* D_PAD::Clone() const
} }
void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
std::string shape;
switch( m_PadShape )
{
case PAD_CIRCLE: shape = "circle"; break;
case PAD_RECT: shape = "rectangle"; break;
case PAD_OVAL: shape = "oval"; break;
case PAD_TRAPEZOID: shape = "trapezoid"; break;
default:
THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), m_PadShape ) );
}
std::string type;
switch( m_Attribute )
{
case PAD_STANDARD: type = "thru-hole"; break;
case PAD_SMD: type = "smd"; break;
case PAD_CONN: type = "connect"; break;
case PAD_HOLE_NOT_PLATED: type = "np-thru-hole"; break;
default:
THROW_IO_ERROR( wxString::Format( _( "unknown pad attribute: %d" ), m_Attribute ) );
}
aFormatter->Print( aNestLevel, "(pad %s %s %s (size %s)\n",
EscapedUTF8( GetPadName() ).c_str(), type.c_str(), shape.c_str(),
FormatBIU( m_Size ).c_str() );
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos0 ).c_str() );
if( m_Orient != 0.0 )
aFormatter->Print( aNestLevel+1, " %0.1f", m_Orient );
aFormatter->Print( aNestLevel+1, ")\n" );
if( (m_Drill.GetWidth() > 0) || (m_Drill.GetHeight() > 0) )
{
std::string drill = (m_Drill.GetHeight() > 0) ? FormatBIU( m_Drill ).c_str() :
FormatBIU( m_Drill.GetWidth() ).c_str();
aFormatter->Print( aNestLevel+1, "(drill %s\n", drill.c_str() );
if( (m_Offset.x > 0) || (m_Offset.y > 0) )
{
std::string drillOffset = ( m_Offset.x > 0 ) ?
FormatBIU( m_Offset ).c_str() :
FormatBIU( m_Offset.x ).c_str();
aFormatter->Print( aNestLevel+1, " (offset %s)", drillOffset.c_str() );
}
aFormatter->Print( aNestLevel+1, ")\n" );
}
aFormatter->Print( aNestLevel+1, "(layers %08X)\n", GetLayerMask() );
aFormatter->Print( aNestLevel+1, "(net %d %s)\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
if( m_LengthDie != 0 )
aFormatter->Print( aNestLevel+1, "(die-length %s)\n", FormatBIU( m_LengthDie ).c_str() );
if( m_LocalSolderMaskMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder-mask-margin %s)\n",
FormatBIU( m_LocalSolderMaskMargin ).c_str() );
if( m_LocalSolderPasteMargin != 0 )
aFormatter->Print( aNestLevel+1, "(solder-paste-margin %s)\n",
FormatBIU( m_LocalSolderPasteMargin ).c_str() );
if( m_LocalSolderPasteMarginRatio != 0 )
aFormatter->Print( aNestLevel+1, "(solder-paste-margin-ratio %g)\n",
m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 )
aFormatter->Print( aNestLevel+1, "(clearance %s)\n",
FormatBIU( m_LocalClearance ).c_str() );
if( GetZoneConnection() != UNDEFINED_CONNECTION )
aFormatter->Print( aNestLevel+1, "(zone-connect %d)\n", GetZoneConnection() );
if( GetThermalWidth() != 0 )
aFormatter->Print( aNestLevel+1, "(thermal-width %s)\n",
FormatBIU( GetThermalWidth() ).c_str() );
if( GetThermalGap() != 0 )
aFormatter->Print( aNestLevel+1, "(thermal-gap %s)\n",
FormatBIU( GetThermalGap() ).c_str() );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void D_PAD::Show( int nestLevel, std::ostream& os ) const void D_PAD::Show( int nestLevel, std::ostream& os ) const
......
...@@ -176,7 +176,7 @@ public: ...@@ -176,7 +176,7 @@ public:
/** /**
* Function GetOrientation * Function GetOrientation
* returns the rotation angle of the pad in tenths of degress, but soon degrees. * returns the rotation angle of the pad in tenths of degrees, but soon degrees.
*/ */
double GetOrientation() const { return m_Orient; } double GetOrientation() const { return m_Orient; }
...@@ -398,6 +398,9 @@ public: ...@@ -398,6 +398,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -191,6 +191,22 @@ EDA_ITEM* TEXTE_PCB::Clone() const ...@@ -191,6 +191,22 @@ EDA_ITEM* TEXTE_PCB::Clone() const
} }
void TEXTE_PCB::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(pcb-text (layer %d)", GetLayer() );
if( GetTimeStamp() )
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
aFormatter->Print( aNestLevel, "\n" );
EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const
......
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
wxString GetClass() const wxString GetClass() const
{ {
return wxT("PTEXT"); return wxT( "PTEXT" );
} }
/** /**
...@@ -119,6 +119,9 @@ public: ...@@ -119,6 +119,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; void Show( int nestLevel, std::ostream& os ) const;
#endif #endif
......
...@@ -480,6 +480,26 @@ EDA_ITEM* TEXTE_MODULE::Clone() const ...@@ -480,6 +480,26 @@ EDA_ITEM* TEXTE_MODULE::Clone() const
} }
void TEXTE_MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
MODULE* parent = (MODULE*) GetParent();
double orient = GetOrientation();
// Due to the Pcbnew history, m_Orient is saved in screen value
// but it is handled as relative to its parent footprint
if( parent )
orient += parent->GetOrientation();
aFormatter->Print( aNestLevel, "(module-text %d (at %s %0.1f)%s)\n", m_Type,
FormatBIU( m_Pos0 ).c_str(), orient, (m_NoShow) ? "hide" : "" );
EDA_TEXT::Format( aFormatter+1, aNestLevel, aControlBits );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) const void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) const
......
...@@ -175,6 +175,9 @@ public: ...@@ -175,6 +175,9 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
......
...@@ -67,7 +67,7 @@ static bool ShowClearance( const TRACK* aTrack ) ...@@ -67,7 +67,7 @@ static bool ShowClearance( const TRACK* aTrack )
/* /*
* return true if the dist between p1 and p2 < max_dist * return true if the dist between p1 and p2 < max_dist
* Currently in test (currently rasnest algos work only if p1 == p2) * Currently in test (currently ratsnest algos work only if p1 == p2)
*/ */
inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist ) inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist )
{ {
...@@ -1559,6 +1559,47 @@ wxString TRACK::GetSelectMenuText() const ...@@ -1559,6 +1559,47 @@ wxString TRACK::GetSelectMenuText() const
} }
void TRACK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
if( Type() == PCB_VIA_T )
{
std::string type;
switch( m_Shape )
{
case VIA_THROUGH: type = "thru"; break;
case VIA_BLIND_BURIED: type = "blind"; break;
case VIA_MICROVIA: type = "micro"; break;
default:
THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), m_Shape ) );
}
aFormatter->Print( aNestLevel, "(via %s (at %s) (size %s)", type.c_str(),
FormatBIU( m_Start ).c_str(), FormatBIU( m_Width ).c_str() );
if( m_Drill != UNDEFINED_DRILL_DIAMETER )
aFormatter->Print( aNestLevel, " (drill %s)", FormatBIU( m_Drill ).c_str() );
}
else
{
aFormatter->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)",
FormatBIU( m_Start ).c_str(), FormatBIU( m_End ).c_str(),
FormatBIU( m_Width ).c_str() );
}
aFormatter->Print( aNestLevel, " (layer %d) (net %d)", GetLayer(), GetNet() );
if( GetTimeStamp() != 0 )
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
if( GetStatus() != 0 )
aFormatter->Print( aNestLevel, " (status %X)", GetStatus() );
aFormatter->Print( aNestLevel, ")\n" );
}
#if defined(DEBUG) #if defined(DEBUG)
void TRACK::Show( int nestLevel, std::ostream& os ) const void TRACK::Show( int nestLevel, std::ostream& os ) const
......
...@@ -46,6 +46,8 @@ class D_PAD; ...@@ -46,6 +46,8 @@ class D_PAD;
* to the near neighbor internal layer */ * to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */ #define VIA_NOT_DEFINED 0 /* not yet used */
#define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
/** /**
* Function GetTrace * Function GetTrace
...@@ -206,9 +208,9 @@ public: ...@@ -206,9 +208,9 @@ public:
/** /**
* Function SetDrillDefault * Function SetDrillDefault
* Set the drill value for vias at default value (-1) * sets the drill value for vias to the default value #UNDEFINED_DRILL_DIAMETER.
*/ */
void SetDrillDefault() { m_Drill = -1; } void SetDrillDefault() { m_Drill = UNDEFINED_DRILL_DIAMETER; }
/** /**
* Function IsDrillDefault * Function IsDrillDefault
...@@ -333,6 +335,9 @@ public: ...@@ -333,6 +335,9 @@ public:
virtual EDA_ITEM* Clone() const; virtual EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined (DEBUG) #if defined (DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
...@@ -389,7 +394,7 @@ public: ...@@ -389,7 +394,7 @@ public:
* For a via m_Layer contains the 2 layers : * For a via m_Layer contains the 2 layers :
* top layer and bottom layer used by the via. * top layer and bottom layer used by the via.
* The via connect all layers from top layer to bottom layer * The via connect all layers from top layer to bottom layer
* 4 bits for the first layer and 4 next bits for the secaon layer * 4 bits for the first layer and 4 next bits for the second layer
* @param top_layer = first layer connected by the via * @param top_layer = first layer connected by the via
* @param bottom_layer = last layer connected by the via * @param bottom_layer = last layer connected by the via
*/ */
......
...@@ -954,3 +954,124 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const ...@@ -954,3 +954,124 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const
return text; return text;
} }
void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR )
{
aFormatter->Print( aNestLevel, "(zone (net %d %s) (layer %d) (tstamp %lX)\n",
GetNet(), EscapedUTF8( m_Netname ).c_str(), GetLayer(), GetTimeStamp() );
// Save the outline aux info
std::string hatch;
switch( GetHatchStyle() )
{
default:
case CPolyLine::NO_HATCH: hatch = "none"; break;
case CPolyLine::DIAGONAL_EDGE: hatch = "edge"; break;
case CPolyLine::DIAGONAL_FULL: hatch = "full"; break;
}
aFormatter->Print( aNestLevel+1, "(hatch %s)\n", hatch.c_str() );
if( m_priority > 0 )
aFormatter->Print( aNestLevel+1, "(priority %d)\n", m_priority );
// Save pad option and clearance
std::string padoption;
switch( GetPadConnection() )
{
default:
case PAD_IN_ZONE: padoption = "yes"; break;
case THERMAL_PAD: padoption = "use-thermal"; break;
case PAD_NOT_IN_ZONE: padoption = "no"; break;
}
aFormatter->Print( aNestLevel+1, "(connect-pads %s (clearance %s))\n",
padoption.c_str(), FormatBIU( m_ZoneClearance ).c_str() );
aFormatter->Print( aNestLevel+1, "(min-thickness %s)\n",
FormatBIU( m_ZoneMinThickness ).c_str() );
aFormatter->Print( aNestLevel+1,
"(fill %s (mode %s) (arc-segments %d) (thermal-gap %s) (thermal-bridge-width %s)\n",
(m_IsFilled) ? "yes" : "no",
(m_FillMode) ? "segment" : "polygon",
m_ArcToSegmentsCount,
FormatBIU( m_ThermalReliefGap ).c_str(),
FormatBIU( m_ThermalReliefCopperBridge ).c_str() );
std::string smoothing;
switch( cornerSmoothingType )
{
case ZONE_SETTINGS::SMOOTHING_NONE: smoothing = "none"; break;
case ZONE_SETTINGS::SMOOTHING_CHAMFER: smoothing = "chamfer"; break;
case ZONE_SETTINGS::SMOOTHING_FILLET: smoothing = "fillet"; break;
default:
THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
cornerSmoothingType ) );
}
aFormatter->Print( aNestLevel+1, "(smoothing %s (radius %s))\n",
smoothing.c_str(), FormatBIU( cornerRadius ).c_str() );
const std::vector< CPolyPt >& cv = m_Poly->corner;
if( cv.size() )
{
aFormatter->Print( aNestLevel+1, "(polygon (pts" );
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
aFormatter->Print( aNestLevel+1, " (xy %s %s)",
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
if( it->end_contour )
aFormatter->Print( aNestLevel+1, ")\n(polygon (pts" );
}
aFormatter->Print( aNestLevel+1, ")\n" );
}
// Save the PolysList
const std::vector< CPolyPt >& fv = m_FilledPolysList;
if( fv.size() )
{
aFormatter->Print( aNestLevel+1, "(filled-polygon (pts" );
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
aFormatter->Print( aNestLevel+1, " (xy %s %s)",
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
if( it->end_contour )
aFormatter->Print( aNestLevel+1, ")\n(filled-polygon (pts" );
}
aFormatter->Print( aNestLevel+1, ")\n" );
}
// Save the filling segments list
const std::vector< SEGMENT >& segs = m_FillSegmList;
if( segs.size() )
{
aFormatter->Print( aNestLevel+1, "(fill-segments\n" );
for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it )
{
aFormatter->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n",
FormatBIU( it->m_Start ).c_str(),
FormatBIU( it->m_End ).c_str() );
}
aFormatter->Print( aNestLevel+1, ")\n" );
}
aFormatter->Print( aNestLevel, ")\n" );
}
...@@ -122,9 +122,9 @@ private: ...@@ -122,9 +122,9 @@ private:
CPolyLine* smoothedPoly; // Corner-smoothed version of m_Poly CPolyLine* smoothedPoly; // Corner-smoothed version of m_Poly
int cornerSmoothingType; int cornerSmoothingType;
unsigned int cornerRadius; unsigned int cornerRadius;
// Priority: when a zone outline is inside and other zone, if its priority is highter // Priority: when a zone outline is inside and other zone, if its priority is higher
// the other zone priority, it will be created inside. // the other zone priority, it will be created inside.
// if priorities are equal, a DRC erroc is set // if priorities are equal, a DRC error is set
unsigned m_priority; unsigned m_priority;
ZoneConnection m_PadConnection; ZoneConnection m_PadConnection;
...@@ -552,9 +552,11 @@ public: ...@@ -552,9 +552,11 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; } virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; }
/** @copydoc EDA_ITEM::Clone() */
virtual EDA_ITEM* Clone() const; virtual EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
......
...@@ -89,9 +89,6 @@ ...@@ -89,9 +89,6 @@
#include <wx/ffile.h> #include <wx/ffile.h>
//#define KICAD_NANOMETRE
#define VERSION_ERROR_FORMAT _( "File '%s' is format version: %d.\nI only support format version <= %d.\nPlease upgrade PCBNew to load this file." ) #define VERSION_ERROR_FORMAT _( "File '%s' is format version: %d.\nI only support format version <= %d.\nPlease upgrade PCBNew to load this file." )
#define UNKNOWN_GRAPHIC_FORMAT _( "unknown graphic type: %d") #define UNKNOWN_GRAPHIC_FORMAT _( "unknown graphic type: %d")
#define UNKNOWN_PAD_FORMAT _( "unknown pad type: %d") #define UNKNOWN_PAD_FORMAT _( "unknown pad type: %d")
...@@ -344,7 +341,7 @@ void KICAD_PLUGIN::loadGENERAL() ...@@ -344,7 +341,7 @@ void KICAD_PLUGIN::loadGENERAL()
if( !strcmp( data, "mm" ) ) if( !strcmp( data, "mm" ) )
{ {
#if defined(KICAD_NANOMETRE) #if defined(USE_PCBNEW_NANOMETERS)
diskToBiu = 1000000.0; diskToBiu = 1000000.0;
#else #else
THROW_IO_ERROR( _( "May not load new *.brd file into 'PCBNew compiled for deci-mils'" ) ); THROW_IO_ERROR( _( "May not load new *.brd file into 'PCBNew compiled for deci-mils'" ) );
...@@ -2659,7 +2656,7 @@ void KICAD_PLUGIN::init( PROPERTIES* aProperties ) ...@@ -2659,7 +2656,7 @@ void KICAD_PLUGIN::init( PROPERTIES* aProperties )
m_props = aProperties; m_props = aProperties;
// conversion factor for saving RAM BIUs to KICAD legacy file format. // conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined(KICAD_NANOMETRE) #if defined(USE_PCBNEW_NANOMETERS)
biuToDisk = 1/1000000.0; // BIUs are nanometers & file is mm biuToDisk = 1/1000000.0; // BIUs are nanometers & file is mm
#else #else
biuToDisk = 1.0; // BIUs are deci-mils biuToDisk = 1.0; // BIUs are deci-mils
...@@ -2673,7 +2670,7 @@ void KICAD_PLUGIN::init( PROPERTIES* aProperties ) ...@@ -2673,7 +2670,7 @@ void KICAD_PLUGIN::init( PROPERTIES* aProperties )
// then, during the file loading process, to start a conversion from // then, during the file loading process, to start a conversion from
// mm to nanometers. // mm to nanometers.
#if defined(KICAD_NANOMETRE) #if defined(USE_PCBNEW_NANOMETERS)
diskToBiu = 2540.0; // BIUs are nanometers diskToBiu = 2540.0; // BIUs are nanometers
#else #else
diskToBiu = 1.0; // BIUs are deci-mils diskToBiu = 1.0; // BIUs are deci-mils
...@@ -2750,7 +2747,7 @@ void KICAD_PLUGIN::saveGENERAL() const ...@@ -2750,7 +2747,7 @@ void KICAD_PLUGIN::saveGENERAL() const
fprintf( m_fp, "encoding utf-8\n" ); fprintf( m_fp, "encoding utf-8\n" );
// tell folks the units used within the file, as early as possible here. // tell folks the units used within the file, as early as possible here.
#if defined(KICAD_NANOMETRE) #if defined(USE_PCBNEW_NANOMETERS)
fprintf( m_fp, "Units mm\n" ); fprintf( m_fp, "Units mm\n" );
#else #else
fprintf( m_fp, "Units deci-mils\n" ); fprintf( m_fp, "Units deci-mils\n" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment