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)
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_PCBNEW_NANOMETRES
"Use nanometers for Pcbnew internal units instead of deci-mils (default OFF).")
# Russian GOST patch
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
......
......@@ -59,7 +59,7 @@
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#cmakedefine USE_PCBNEW_NANAMETERS
/// The file format revision of the *.brd file created by this build
#if defined(KICAD_NANOMETRE)
......
......@@ -426,3 +426,17 @@ bool EDA_APP::OnInit()
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 @@
#include <trigo.h>
#include <common.h>
#include <macros.h>
#include <kicad_string.h>
#include <wxstruct.h>
#include <class_drawpanel.h>
#include <class_base_screen.h>
......@@ -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)
// A function that should have been in wxWidgets
......@@ -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 */
/******************/
......
......@@ -24,6 +24,8 @@
#include <common.h>
#include <macros.h>
// late arriving wxPAPER_A0, wxPAPER_A1
#if wxABI_VERSION >= 20999
......@@ -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 )
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 @@
#include <confirm.h>
#include <wxstruct.h>
#include <appl_wxstruct.h>
#include <kicad_string.h>
#include <worksheet.h>
#include <class_title_block.h>
......@@ -1372,7 +1373,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi
{
if( jj < 26 )
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 );
if( ii < yg - PAS_REF / 2 )
......@@ -1626,7 +1627,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition )
yg = pageInfo.GetSizeMils().y - pageInfo.GetBottomMarginMils();
// 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( "?" );
else
{
......@@ -1637,7 +1638,7 @@ const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition )
}
// 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( "?" );
else
{
......@@ -1660,3 +1661,42 @@ wxString EDA_DRAW_FRAME::GetScreenDesc()
<< GetScreen()->m_NumberOfScreen;
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
* @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's
* default color.
* @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.
*/
virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
......
......@@ -29,6 +29,7 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <kicad_string.h>
#include <eeschema_id.h>
#include <appl_wxstruct.h>
......@@ -1497,3 +1498,20 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#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 @@
#include <colors.h>
#include <bitmaps.h>
#include <richio.h>
#include <boost/ptr_container/ptr_vector.hpp>
......@@ -712,6 +713,18 @@ public:
*/
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)
/**
......@@ -812,7 +825,7 @@ public:
double m_Orient; ///< Orient in 0.1 degrees
wxPoint m_Pos; ///< XY position of anchor 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.
bool m_Italic; ///< should be italic font (if available)
bool m_Bold; ///< should be bold font (if available)
......@@ -852,6 +865,8 @@ public:
void SetMirrored( bool isMirrored ) { m_Mirror = isMirrored; }
bool IsMirrored() const { return m_Mirror; }
bool IsDefaultFormatting() const;
/**
* Function SetSize
* sets text size.
......@@ -989,6 +1004,19 @@ public:
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = 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_
......@@ -26,6 +26,10 @@
#include <wx/string.h>
class OUTPUTFORMATTER;
class IO_ERROR;
extern wxString GenDate();
......@@ -81,6 +85,18 @@ public:
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:
wxString m_title;
wxString m_date;
......
......@@ -38,6 +38,7 @@
#include <wx/confbase.h>
#include <wx/fileconf.h>
#include <richio.h>
#if !wxUSE_PRINTING_ARCHITECTURE
# error "You must use '--enable-printarch' in your wx library configuration."
......@@ -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:
class LibNameList;
......@@ -185,12 +204,19 @@ public:
* and will be set according to <b>previous</b> calls to
* static PAGE_INFO::SetUserWidthMils() and
* 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 );
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
* returns true if the type is Custom
......@@ -327,6 +353,18 @@ public:
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:
// only the class implementation(s) may use this constructor
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 );
/**
* 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".
*/
wxString GenDate();
......
......@@ -298,3 +298,16 @@ void KICAD_MANAGER_FRAME::SaveSettings()
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 )
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 "";
}
This diff is collapsed.
......@@ -127,7 +127,7 @@ class HIGH_LIGHT_INFO
friend class BOARD;
protected:
int m_netCode; // net selected for highlight (-1 when no net selected )
bool m_highLightOn; // highlight active
bool m_highLightOn; // highlight active
protected:
void Clear()
......@@ -165,21 +165,21 @@ private:
ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used
HIGH_LIGHT_INFO m_hightLight; // current high light data
HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data
// if true m_highLight_NetCode is used
HIGH_LIGHT_INFO m_highLight; // current 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
EDA_RECT m_BoundingBox;
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
BOARD_DESIGN_SETTINGS m_designSettings;
ZONE_SETTINGS m_zoneSettings;
COLORS_DESIGN_SETTINGS* m_colorsSettings;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles; ///< text in lower right of screen and plots
TITLE_BLOCK m_titles; ///< text in lower right of screen and plots
/// Position of the origin axis, which is used in exports mostly
wxPoint m_originAxisPosition;
......@@ -195,6 +195,9 @@ private:
*/
void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList );
void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
int aControlBits ) const
throw( IO_ERROR );
public:
......@@ -342,15 +345,15 @@ public:
*/
void ResetHighLight()
{
m_hightLight.Clear();
m_hightLightPrevious.Clear();
m_highLight.Clear();
m_highLightPrevious.Clear();
}
/**
* Function GetHighLightNetCode
* @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
......@@ -358,27 +361,27 @@ public:
*/
void SetHighLightNet( int aNetCode)
{
m_hightLight.m_netCode = aNetCode;
m_highLight.m_netCode = aNetCode;
}
/**
* Function IsHighLightNetON
* @return true if a net is currently highlighted
*/
bool IsHighLightNetON() { return m_hightLight.m_highLightOn; }
bool IsHighLightNetON() { return m_highLight.m_highLightOn; }
/**
* Function HighLightOFF
* Disable highlight.
*/
void HighLightOFF() { m_hightLight.m_highLightOn = false; }
void HighLightOFF() { m_highLight.m_highLightOn = false; }
/**
* Function HighLightON
* 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
......@@ -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;
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT( "BOARD" );
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......@@ -1192,7 +1187,7 @@ public:
/**
* 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>
* The fast search method only works if the pad list has already been built.
* </p>
......@@ -1204,7 +1199,7 @@ public:
/**
* 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
* <p>
* 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
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
{
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,9 +44,9 @@ class DIMENSION : public BOARD_ITEM
public:
int m_Width;
wxPoint m_Pos;
int m_Shape;
int m_Shape; /// Current always 0.
int m_Unit; /// 0 = inches, 1 = mm
int m_Value; /// value of PCB dimensions.
int m_Value; /// value of PCB dimensions.
TEXTE_PCB m_Text;
int m_crossBarOx, m_crossBarOy, m_crossBarFx, m_crossBarFy;
......@@ -138,6 +138,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
......
......@@ -284,7 +284,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
}
break;
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++) {
if( mode == LINE )
......@@ -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)
void DRAWSEGMENT::Show( int nestLevel, std::ostream& os ) const
{
......
......@@ -51,7 +51,7 @@ protected:
int m_Type; ///< Used in complex associations ( Dimensions.. )
double m_Angle; ///< Used only for Arcs: Arc angle in 1/10 deg
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_PolyPoints;
......@@ -152,13 +152,13 @@ public:
m_PolyPoints = aPoints;
}
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( LINE_READER* aReader );
bool ReadDrawSegmentDescr( LINE_READER* aReader );
void Copy( DRAWSEGMENT* source );
void Copy( DRAWSEGMENT* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
int aDrawMode, const wxPoint& aOffset = ZeroOffset );
virtual void DisplayInfo( EDA_DRAW_FRAME* frame );
......@@ -219,6 +219,9 @@ public:
virtual EDA_ITEM* Clone() const;
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......
......@@ -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)
void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) const
......
......@@ -91,6 +91,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......
......@@ -223,3 +223,23 @@ EDA_ITEM* PCB_TARGET::Clone() const
{
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:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
......
......@@ -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)
void MODULE::Show( int nestLevel, std::ostream& os ) const
......
......@@ -346,6 +346,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......
......@@ -290,28 +290,55 @@ void NETCLASS::Show( int nestLevel, std::ostream& os ) const
#endif
int NETCLASS::GetTrackMinWidth() const
{
return m_Parent->GetDesignSettings().m_TrackMinWidth;
}
int NETCLASS::GetViaMinDiameter() const
{
return m_Parent->GetDesignSettings().m_ViasMinSize;
}
int NETCLASS::GetViaMinDrill() const
{
return m_Parent->GetDesignSettings().m_ViasMinDrill;
}
int NETCLASS::GetuViaMinDiameter() const
{
return m_Parent->GetDesignSettings().m_MicroViasMinSize;
}
int NETCLASS::GetuViaMinDrill() const
{
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 @@
#include <wx/string.h>
#include <richio.h>
class LINE_READER;
class BOARD;
......@@ -212,6 +214,18 @@ public:
*/
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)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......@@ -243,7 +257,7 @@ public:
/**
* Function Clear
* destroys any constained NETCLASS instances except the Default one.
* destroys any contained NETCLASS instances except the Default one.
*/
void Clear();
......@@ -306,4 +320,3 @@ public:
};
#endif // CLASS_NETCLASS_H
......@@ -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)
void D_PAD::Show( int nestLevel, std::ostream& os ) const
......
......@@ -176,7 +176,7 @@ public:
/**
* 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; }
......@@ -398,6 +398,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......
......@@ -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)
void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const
......
......@@ -91,7 +91,7 @@ public:
wxString GetClass() const
{
return wxT("PTEXT");
return wxT( "PTEXT" );
}
/**
......@@ -119,6 +119,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const;
#endif
......
......@@ -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)
void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) const
......
......@@ -175,6 +175,9 @@ public:
EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
......
......@@ -67,7 +67,7 @@ static bool ShowClearance( const TRACK* aTrack )
/*
* 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 )
{
......@@ -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)
void TRACK::Show( int nestLevel, std::ostream& os ) const
......
......@@ -40,11 +40,13 @@ class TRACK;
class D_PAD;
// Via attributes (m_Shape parameter)
#define VIA_THROUGH 3 /* Always a through hole via */
#define VIA_BLIND_BURIED 2 /* this via can be on internal layers */
#define VIA_MICROVIA 1 /* this via which connect from an external layer
* to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */
#define VIA_THROUGH 3 /* Always a through hole via */
#define VIA_BLIND_BURIED 2 /* this via can be on internal layers */
#define VIA_MICROVIA 1 /* this via which connect from an external layer
* to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */
#define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
/**
......@@ -206,9 +208,9 @@ public:
/**
* 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
......@@ -333,6 +335,9 @@ public:
virtual EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined (DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
......@@ -389,7 +394,7 @@ public:
* For a via m_Layer contains the 2 layers :
* top layer and bottom layer used by the via.
* 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 bottom_layer = last layer connected by the via
*/
......
......@@ -954,3 +954,124 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const
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:
CPolyLine* smoothedPoly; // Corner-smoothed version of m_Poly
int cornerSmoothingType;
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.
// if priorities are equal, a DRC erroc is set
// if priorities are equal, a DRC error is set
unsigned m_priority;
ZoneConnection m_PadConnection;
......@@ -552,9 +552,11 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; }
/** @copydoc EDA_ITEM::Clone() */
virtual EDA_ITEM* Clone() const;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
throw( IO_ERROR );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
......
......@@ -89,9 +89,6 @@
#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 UNKNOWN_GRAPHIC_FORMAT _( "unknown graphic type: %d")
#define UNKNOWN_PAD_FORMAT _( "unknown pad type: %d")
......@@ -344,7 +341,7 @@ void KICAD_PLUGIN::loadGENERAL()
if( !strcmp( data, "mm" ) )
{
#if defined(KICAD_NANOMETRE)
#if defined(USE_PCBNEW_NANOMETERS)
diskToBiu = 1000000.0;
#else
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 )
m_props = aProperties;
// 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
#else
biuToDisk = 1.0; // BIUs are deci-mils
......@@ -2673,7 +2670,7 @@ void KICAD_PLUGIN::init( PROPERTIES* aProperties )
// then, during the file loading process, to start a conversion from
// mm to nanometers.
#if defined(KICAD_NANOMETRE)
#if defined(USE_PCBNEW_NANOMETERS)
diskToBiu = 2540.0; // BIUs are nanometers
#else
diskToBiu = 1.0; // BIUs are deci-mils
......@@ -2750,7 +2747,7 @@ void KICAD_PLUGIN::saveGENERAL() const
fprintf( m_fp, "encoding utf-8\n" );
// 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" );
#else
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