Pcbnew: Add pcad2kicad pcb plugin, to import PCAD boards ( .pcb ASCII data file PCad 2000 format ) from Alexander Lunef
This commit is contained in:
parent
7c86749ca6
commit
40f4304b2f
|
@ -349,6 +349,7 @@ add_subdirectory(eeschema)
|
||||||
add_subdirectory(gerbview)
|
add_subdirectory(gerbview)
|
||||||
add_subdirectory(kicad)
|
add_subdirectory(kicad)
|
||||||
add_subdirectory(pcbnew)
|
add_subdirectory(pcbnew)
|
||||||
|
add_subdirectory(pcbnew/pcad2kicadpcb_plugin)
|
||||||
add_subdirectory(polygon)
|
add_subdirectory(polygon)
|
||||||
add_subdirectory(potrace)
|
add_subdirectory(potrace)
|
||||||
add_subdirectory(bitmap2component)
|
add_subdirectory(bitmap2component)
|
||||||
|
|
|
@ -70,6 +70,7 @@ const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
|
||||||
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
|
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
|
||||||
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
|
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
|
||||||
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) );
|
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) );
|
||||||
|
const wxString PCadPcbFileWildcard( _( "P-Cad 2002/2004 ASCII PCB files (*.pcb)|*.pcb" ) );
|
||||||
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
|
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
|
||||||
const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
|
const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
|
||||||
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );
|
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );
|
||||||
|
|
|
@ -95,6 +95,7 @@ endif(APPLE)
|
||||||
target_link_libraries(cvpcb
|
target_link_libraries(cvpcb
|
||||||
3d-viewer
|
3d-viewer
|
||||||
pcbcommon
|
pcbcommon
|
||||||
|
pcad2kicadpcb
|
||||||
common
|
common
|
||||||
bitmaps
|
bitmaps
|
||||||
polygon
|
polygon
|
||||||
|
|
|
@ -212,7 +212,7 @@ protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function expandCapacity
|
* Function expandCapacity
|
||||||
* will exand the capacity of @a line up to maxLineLength but not greater, so
|
* will expand the capacity of @a line up to maxLineLength but not greater, so
|
||||||
* be careful about making assumptions of @a capacity after calling this.
|
* be careful about making assumptions of @a capacity after calling this.
|
||||||
*/
|
*/
|
||||||
void expandCapacity( unsigned newsize );
|
void expandCapacity( unsigned newsize );
|
||||||
|
|
|
@ -79,6 +79,7 @@ extern const wxString GerberFileWildcard;
|
||||||
extern const wxString LegacyPcbFileWildcard;
|
extern const wxString LegacyPcbFileWildcard;
|
||||||
extern const wxString PcbFileWildcard;
|
extern const wxString PcbFileWildcard;
|
||||||
extern const wxString EaglePcbFileWildcard;
|
extern const wxString EaglePcbFileWildcard;
|
||||||
|
extern const wxString PCadPcbFileWildcard;
|
||||||
extern const wxString PdfFileWildcard;
|
extern const wxString PdfFileWildcard;
|
||||||
extern const wxString PSFileWildcard;
|
extern const wxString PSFileWildcard;
|
||||||
extern const wxString MacrosFileWildcard;
|
extern const wxString MacrosFileWildcard;
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
class XNODE : public wxXmlNode
|
class XNODE : public wxXmlNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//-----<overloads>---------------------------------------------------------
|
||||||
XNODE() :
|
XNODE() :
|
||||||
wxXmlNode()
|
wxXmlNode()
|
||||||
{
|
{
|
||||||
|
@ -62,6 +63,22 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XNODE* GetChildren() const
|
||||||
|
{
|
||||||
|
return (XNODE* )wxXmlNode::GetChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
XNODE* GetNext() const
|
||||||
|
{
|
||||||
|
return (XNODE* )wxXmlNode::GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
XNODE* GetParent() const
|
||||||
|
{
|
||||||
|
return (XNODE* )wxXmlNode::GetParent();
|
||||||
|
}
|
||||||
|
//-----</overloads>--------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Format
|
* Function Format
|
||||||
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
|
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
|
||||||
|
|
|
@ -416,6 +416,7 @@ target_link_libraries(pcbnew
|
||||||
common
|
common
|
||||||
bitmaps
|
bitmaps
|
||||||
polygon
|
polygon
|
||||||
|
pcad2kicadpcb
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
|
|
|
@ -190,6 +190,7 @@ the changes?" ) ) )
|
||||||
{ PcbFileWildcard, IO_MGR::KICAD },
|
{ PcbFileWildcard, IO_MGR::KICAD },
|
||||||
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
|
{ LegacyPcbFileWildcard, IO_MGR::LEGACY },
|
||||||
{ EaglePcbFileWildcard, IO_MGR::EAGLE },
|
{ EaglePcbFileWildcard, IO_MGR::EAGLE },
|
||||||
|
{ PCadPcbFileWildcard, IO_MGR::PCAD },
|
||||||
};
|
};
|
||||||
|
|
||||||
if( !fileName.IsOk() || !fileName.FileExists() || aForceFileDialog )
|
if( !fileName.IsOk() || !fileName.FileExists() || aForceFileDialog )
|
||||||
|
@ -326,13 +327,28 @@ the changes?" ) ) )
|
||||||
GetBoard()->SetFileName( new_filename );
|
GetBoard()->SetFileName( new_filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix the directory separator on Windows
|
// Fix the directory separator on Windows and
|
||||||
wxString fn( GetBoard()->GetFileName() );
|
// force the new file format for not Kicad boards,
|
||||||
|
// to ensure the right format when saving the board
|
||||||
|
bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD;
|
||||||
|
wxString fn;
|
||||||
|
|
||||||
|
if( converted )
|
||||||
|
fn = GetBoard()->GetFileName().BeforeLast( '.' );
|
||||||
|
else
|
||||||
|
fn = GetBoard()->GetFileName();
|
||||||
|
|
||||||
fn.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
fn.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||||
|
|
||||||
|
if( converted )
|
||||||
|
fn += wxT( "." ) + PcbFileExtension;
|
||||||
|
|
||||||
GetBoard()->SetFileName( fn );
|
GetBoard()->SetFileName( fn );
|
||||||
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
UpdateFileHistory( GetBoard()->GetFileName() );
|
|
||||||
|
if( !converted )
|
||||||
|
UpdateFileHistory( GetBoard()->GetFileName() );
|
||||||
|
|
||||||
// Rebuild the new pad list (for drc and ratsnet control ...)
|
// Rebuild the new pad list (for drc and ratsnet control ...)
|
||||||
GetBoard()->m_Status_Pcb = 0;
|
GetBoard()->m_Status_Pcb = 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <legacy_plugin.h>
|
#include <legacy_plugin.h>
|
||||||
#include <kicad_plugin.h>
|
#include <kicad_plugin.h>
|
||||||
#include <eagle_plugin.h>
|
#include <eagle_plugin.h>
|
||||||
|
#include <pcad2kicadpcb_plugin/pcad_plugin.h>
|
||||||
#include <gpcb_plugin.h>
|
#include <gpcb_plugin.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
|
||||||
|
@ -66,6 +67,9 @@ PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
|
||||||
case EAGLE:
|
case EAGLE:
|
||||||
return new EAGLE_PLUGIN();
|
return new EAGLE_PLUGIN();
|
||||||
|
|
||||||
|
case PCAD:
|
||||||
|
return new PCAD_PLUGIN();
|
||||||
|
|
||||||
case GEDA_PCB:
|
case GEDA_PCB:
|
||||||
return new GPCB_PLUGIN();
|
return new GPCB_PLUGIN();
|
||||||
}
|
}
|
||||||
|
@ -104,6 +108,9 @@ const wxString IO_MGR::ShowType( PCB_FILE_T aType )
|
||||||
case EAGLE:
|
case EAGLE:
|
||||||
return wxString( wxT( "Eagle" ) );
|
return wxString( wxT( "Eagle" ) );
|
||||||
|
|
||||||
|
case PCAD:
|
||||||
|
return wxString( wxT( "P-Cad" ) );
|
||||||
|
|
||||||
case GEDA_PCB:
|
case GEDA_PCB:
|
||||||
return wxString( wxT( "Geda-PCB" ) );
|
return wxString( wxT( "Geda-PCB" ) );
|
||||||
}
|
}
|
||||||
|
@ -125,6 +132,9 @@ IO_MGR::PCB_FILE_T IO_MGR::EnumFromStr( const wxString& aType )
|
||||||
if( aType == wxT( "Eagle" ) )
|
if( aType == wxT( "Eagle" ) )
|
||||||
return EAGLE;
|
return EAGLE;
|
||||||
|
|
||||||
|
if( aType == wxT( "P-Cad" ) )
|
||||||
|
return PCAD;
|
||||||
|
|
||||||
if( aType == wxT( "Geda-PCB" ) )
|
if( aType == wxT( "Geda-PCB" ) )
|
||||||
return GEDA_PCB;
|
return GEDA_PCB;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
LEGACY, //< Legacy Pcbnew file formats prior to s-expression.
|
LEGACY, //< Legacy Pcbnew file formats prior to s-expression.
|
||||||
KICAD, //< S-expression Pcbnew file format.
|
KICAD, //< S-expression Pcbnew file format.
|
||||||
EAGLE,
|
EAGLE,
|
||||||
|
PCAD,
|
||||||
GEDA_PCB, //< Geda PCB file formats.
|
GEDA_PCB, //< Geda PCB file formats.
|
||||||
// add your type here.
|
// add your type here.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
add_definitions(-DPCBNEW)
|
||||||
|
|
||||||
|
include_directories(BEFORE ${INC_BEFORE})
|
||||||
|
include_directories(
|
||||||
|
../../include
|
||||||
|
../../pcbnew
|
||||||
|
../../polygon
|
||||||
|
${INC_AFTER}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PCAD2PCBNEW_SRCS
|
||||||
|
pcad2kicad_common.cpp
|
||||||
|
pcad_plugin.cpp
|
||||||
|
pcb.cpp
|
||||||
|
pcb_arc.cpp
|
||||||
|
pcb_component.cpp
|
||||||
|
pcb_copper_pour.cpp
|
||||||
|
pcb_cutout.cpp
|
||||||
|
pcb_keepout.cpp
|
||||||
|
pcb_line.cpp
|
||||||
|
pcb_module.cpp
|
||||||
|
pcb_net.cpp
|
||||||
|
pcb_pad.cpp
|
||||||
|
pcb_pad_shape.cpp
|
||||||
|
pcb_plane.cpp
|
||||||
|
pcb_polygon.cpp
|
||||||
|
pcb_text.cpp
|
||||||
|
pcb_via.cpp
|
||||||
|
pcb_via_shape.cpp
|
||||||
|
s_expr_loader.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(pcad2kicadpcb STATIC ${PCAD2PCBNEW_SRCS})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
Examples description
|
||||||
|
====================
|
||||||
|
|
||||||
|
CK1202_V1.pcb - provided by author Andrey Manin <pcadbegin[at]rambler.ru>,
|
||||||
|
downloaded from http://www.pcadbegin.webtm.ru/schetchik.php?scach=1
|
|
@ -0,0 +1,460 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcad2kicad_common.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcad2kicad_common.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
wxString GetWord( wxString* aStr )
|
||||||
|
{
|
||||||
|
wxString result = wxEmptyString;
|
||||||
|
|
||||||
|
*aStr = aStr->Trim( false );
|
||||||
|
|
||||||
|
if( aStr->Len() == 0 )
|
||||||
|
return result;
|
||||||
|
|
||||||
|
if( (*aStr)[0] == wxT( '"' ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 ); // remove Frot apostrofe
|
||||||
|
|
||||||
|
while( aStr->Len() > 0 && (*aStr)[0] != wxT( '"' ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aStr->Len() > 0 && (*aStr)[0] == wxT( '"' ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 ); // remove ending apostrophe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while( aStr->Len() > 0
|
||||||
|
&& !( (*aStr)[0] == wxT( ' ' )
|
||||||
|
|| (*aStr)[0] == wxT( '(' )
|
||||||
|
|| (*aStr)[0] == wxT( ')' ) ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Trim( true );
|
||||||
|
result.Trim( false );
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XNODE* FindPinMap( XNODE* aNode )
|
||||||
|
{
|
||||||
|
XNODE* result, * lNode;
|
||||||
|
|
||||||
|
result = NULL;
|
||||||
|
lNode = FindNode( aNode, wxT( "attachedPattern" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
result = FindNode( lNode, wxT( "padPinMap" ) );
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
wxString ls;
|
||||||
|
double i;
|
||||||
|
char u;
|
||||||
|
|
||||||
|
ls = aStr;
|
||||||
|
ls.Trim( true );
|
||||||
|
ls.Trim( false );
|
||||||
|
|
||||||
|
if( ls.Len() > 0 )
|
||||||
|
{
|
||||||
|
u = ls[ls.Len() - 1];
|
||||||
|
|
||||||
|
while( ls.Len() > 0
|
||||||
|
&& !( ls[ls.Len() - 1] == wxT( '.' )
|
||||||
|
|| ls[ls.Len() - 1] == wxT( ',' )
|
||||||
|
|| (ls[ls.Len() - 1] >= wxT( '0' ) && ls[ls.Len() - 1] <= wxT( '9' ) ) ) )
|
||||||
|
{
|
||||||
|
ls = ls.Left( ls.Len() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
while( ls.Len() > 0
|
||||||
|
&& !( ls[0] == wxT( '-' )
|
||||||
|
|| ls[0] == wxT( '+' )
|
||||||
|
|| ls[0] == wxT( '.' )
|
||||||
|
|| ls[0] == wxT( ',' )
|
||||||
|
|| (ls[0] >= wxT( '0' ) && ls[0] <= wxT( '9' ) ) ) )
|
||||||
|
{
|
||||||
|
ls = ls.Mid( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( u == wxT( 'm' ) )
|
||||||
|
{
|
||||||
|
ls.ToDouble( &i );
|
||||||
|
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
|
||||||
|
if( aActualConversion == wxT( "SCH" ) )
|
||||||
|
i = i * (0.0254 / 0.025);
|
||||||
|
#endif
|
||||||
|
i = Millimeter2iu( i );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ls.ToDouble( &i );
|
||||||
|
i = Mils2iu( i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i = 0.0;
|
||||||
|
|
||||||
|
if( ( aActualConversion == wxT( "PCB" ) || aActualConversion == wxT( "SCH" ) )
|
||||||
|
&& aAxe == wxT( 'Y' ) )
|
||||||
|
return -i;
|
||||||
|
else
|
||||||
|
return i; // Y axe is mirrored compared to P-Cad
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int StrToIntUnits( wxString aStr, char aAxe, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString GetAndCutWordWithMeasureUnits( wxString* aStr, wxString aDefaultMeasurementUnit )
|
||||||
|
{
|
||||||
|
wxString s1, s2, result;
|
||||||
|
|
||||||
|
aStr->Trim( false );
|
||||||
|
result = wxEmptyString;
|
||||||
|
|
||||||
|
// value
|
||||||
|
while( aStr->Len() > 0 && (*aStr)[0] != wxT( ' ' ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
aStr->Trim( false );
|
||||||
|
|
||||||
|
// if there is also measurement unit
|
||||||
|
while( aStr->Len() > 0
|
||||||
|
&& ( ( (*aStr)[0] >= wxT( 'a' ) && (*aStr)[0] <= wxT( 'z' ) )
|
||||||
|
|| ( (*aStr)[0] >= wxT( 'A' ) && (*aStr)[0] <= wxT( 'Z' ) ) ) )
|
||||||
|
{
|
||||||
|
result += (*aStr)[0];
|
||||||
|
*aStr = aStr->Mid( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// and if not, add default....
|
||||||
|
if( result.Len() > 0
|
||||||
|
&& ( result[result.Len() - 1] == wxT( '.' )
|
||||||
|
|| result[result.Len() - 1] == wxT( ',' )
|
||||||
|
|| (result[result.Len() - 1] >= wxT( '0' )
|
||||||
|
&& result[result.Len() - 1] <= wxT( '9' ) ) ) )
|
||||||
|
{
|
||||||
|
result += aDefaultMeasurementUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int StrToInt1Units( wxString aStr )
|
||||||
|
{
|
||||||
|
double num, precision = 10;
|
||||||
|
|
||||||
|
// TODO: Is the following commented string necessary?
|
||||||
|
// if (pos(',',s)>0) then DecimalSeparator:=',' else DecimalSeparator:='.';
|
||||||
|
aStr.ToDouble( &num );
|
||||||
|
return KiROUND( num * precision );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString ValidateName( wxString aName )
|
||||||
|
{
|
||||||
|
aName.Replace( wxT( " " ), wxT( "_" ) );
|
||||||
|
|
||||||
|
return aName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetWidth( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
int* aWidth,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
*aWidth = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( ' ' ),
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetHeight( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
int* aHeight,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
*aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( ' ' ),
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetPosition( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
int* aX,
|
||||||
|
int* aY,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
*aX = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( 'X' ),
|
||||||
|
aActualConversion );
|
||||||
|
*aY = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( 'Y' ),
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetDoublePrecisionPosition( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
double* aX,
|
||||||
|
double* aY,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
*aX = StrToDoublePrecisionUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( 'X' ),
|
||||||
|
aActualConversion );
|
||||||
|
*aY = StrToDoublePrecisionUnits( GetAndCutWordWithMeasureUnits( &aStr,
|
||||||
|
aDefaultMeasurementUnit ), wxT( 'Y' ),
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetTextParameters( XNODE* aNode,
|
||||||
|
TTEXTVALUE* aTextValue,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* tNode;
|
||||||
|
wxString str;
|
||||||
|
|
||||||
|
tNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
SetPosition( tNode->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit,
|
||||||
|
&aTextValue->textPositionX,
|
||||||
|
&aTextValue->textPositionY,
|
||||||
|
aActualConversion );
|
||||||
|
|
||||||
|
tNode = FindNode( aNode, wxT( "rotation" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
str = tNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
aTextValue->textRotation = StrToInt1Units( str );
|
||||||
|
}
|
||||||
|
|
||||||
|
str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
|
||||||
|
|
||||||
|
if( str == wxT( "True" ) )
|
||||||
|
aTextValue->textIsVisible = 1;
|
||||||
|
else if( str == wxT( "False" ) )
|
||||||
|
aTextValue->textIsVisible = 0;
|
||||||
|
|
||||||
|
tNode = FindNode( aNode, wxT( "textStyleRef" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetFontProperty( XNODE* aNode,
|
||||||
|
TTEXTVALUE* aTextValue,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
wxString n, propValue;
|
||||||
|
|
||||||
|
aNode->GetAttribute( wxT( "Name" ), &n );
|
||||||
|
|
||||||
|
while( aNode->GetName() != wxT( "www.lura.sk" ) )
|
||||||
|
aNode = aNode->GetParent();
|
||||||
|
|
||||||
|
aNode = FindNode( aNode, wxT( "library" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
aNode = FindNode( aNode, wxT( "textStyleDef" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
aNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
|
||||||
|
if( propValue == n )
|
||||||
|
break;
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "font" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
if( FindNode( aNode, wxT( "fontHeight" ) ) )
|
||||||
|
// // SetWidth(iNode.ChildNodes.FindNode('fontHeight').Text,
|
||||||
|
// // DefaultMeasurementUnit,tv.TextHeight);
|
||||||
|
// Fixed By Lubo, 02/2008
|
||||||
|
SetHeight( FindNode( aNode, wxT(
|
||||||
|
"fontHeight" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &aTextValue->textHeight,
|
||||||
|
aActualConversion );
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "strokeWidth" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT(
|
||||||
|
"strokeWidth" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &aTextValue->textstrokeWidth,
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CorrectTextPosition( TTEXTVALUE* aValue, int aRotation )
|
||||||
|
{
|
||||||
|
aValue->correctedPositionX = aValue->textPositionX;
|
||||||
|
aValue->correctedPositionY = aValue->textPositionY;
|
||||||
|
aValue->correctedPositionY = aValue->correctedPositionY - KiROUND(
|
||||||
|
(double) aValue->textHeight / 3.0 );
|
||||||
|
aValue->correctedPositionX = aValue->correctedPositionX +
|
||||||
|
KiROUND( ( (double) aValue->text.Len() /
|
||||||
|
1.4 ) * ( (double) aValue->textHeight / 1.8 ) );
|
||||||
|
|
||||||
|
if( aRotation == 900 )
|
||||||
|
{
|
||||||
|
aValue->correctedPositionX = -aValue->textPositionY;
|
||||||
|
aValue->correctedPositionY = aValue->textPositionX;
|
||||||
|
aValue->correctedPositionX = aValue->correctedPositionX + KiROUND(
|
||||||
|
(double) aValue->textHeight / 3.0 );
|
||||||
|
aValue->correctedPositionY = aValue->correctedPositionY +
|
||||||
|
KiROUND( ( (double) aValue->text.Len() /
|
||||||
|
1.4 ) * ( (double) aValue->textHeight / 1.8 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aRotation == 1800 )
|
||||||
|
{
|
||||||
|
aValue->correctedPositionX = -aValue->textPositionX;
|
||||||
|
aValue->correctedPositionY = -aValue->textPositionY;
|
||||||
|
aValue->correctedPositionY = aValue->correctedPositionY +
|
||||||
|
KiROUND( (double) aValue->textHeight / 3.0 );
|
||||||
|
aValue->correctedPositionX = aValue->correctedPositionX -
|
||||||
|
KiROUND( ( (double) aValue->text.Len() /
|
||||||
|
1.4 ) * ( (double) aValue->textHeight / 1.8 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aRotation == 2700 )
|
||||||
|
{
|
||||||
|
aValue->correctedPositionX = aValue->textPositionY;
|
||||||
|
aValue->correctedPositionY = -aValue->textPositionX;
|
||||||
|
aValue->correctedPositionX = aValue->correctedPositionX +
|
||||||
|
KiROUND( (double) aValue->textHeight / 1.0 );
|
||||||
|
aValue->correctedPositionY = aValue->correctedPositionY -
|
||||||
|
KiROUND( ( (double) aValue->text.Len() /
|
||||||
|
3.4 ) * ( (double) aValue->textHeight / 1.8 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XNODE* FindNode( XNODE* aChild, wxString aTag )
|
||||||
|
{
|
||||||
|
aChild = aChild->GetChildren();
|
||||||
|
|
||||||
|
while( aChild )
|
||||||
|
{
|
||||||
|
if( aChild->GetName() == aTag )
|
||||||
|
return aChild;
|
||||||
|
|
||||||
|
aChild = aChild->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString FindNodeGetContent( XNODE* aChild, wxString aTag )
|
||||||
|
{
|
||||||
|
wxString str = wxEmptyString;
|
||||||
|
|
||||||
|
aChild = FindNode( aChild, aTag );
|
||||||
|
|
||||||
|
if( aChild )
|
||||||
|
{
|
||||||
|
str = aChild->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
str.Trim( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitTTextValue( TTEXTVALUE* aTextValue )
|
||||||
|
{
|
||||||
|
aTextValue->text = wxEmptyString;
|
||||||
|
aTextValue->textPositionX = 0;
|
||||||
|
aTextValue->textPositionY = 0;
|
||||||
|
aTextValue->textRotation = 0;
|
||||||
|
aTextValue->textHeight = 0;
|
||||||
|
aTextValue->textstrokeWidth = 0;
|
||||||
|
aTextValue->textIsVisible = 0;
|
||||||
|
aTextValue->mirror = 0;
|
||||||
|
aTextValue->textUnit = 0;
|
||||||
|
aTextValue->correctedPositionX = 0;
|
||||||
|
aTextValue->correctedPositionY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcad2kicad_common.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCAD2KICAD_COMMON_H_
|
||||||
|
#define PCAD2KICAD_COMMON_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/xml/xml.h>
|
||||||
|
#include <xnode.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD
|
||||||
|
{
|
||||||
|
|
||||||
|
#define PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
|
||||||
|
|
||||||
|
typedef struct _TTEXTVALUE
|
||||||
|
{
|
||||||
|
wxString text;
|
||||||
|
int textPositionX, textPositionY,
|
||||||
|
textRotation, textHeight, textstrokeWidth;
|
||||||
|
int textIsVisible, mirror, textUnit;
|
||||||
|
int correctedPositionX, correctedPositionY;
|
||||||
|
} TTEXTVALUE;
|
||||||
|
|
||||||
|
extern wxString GetWord( wxString* aStr );
|
||||||
|
extern XNODE* FindPinMap( XNODE* aNode );
|
||||||
|
extern int StrToIntUnits( wxString aStr, char aAxe, wxString aActualConversion );
|
||||||
|
extern wxString GetAndCutWordWithMeasureUnits( wxString* aStr,
|
||||||
|
wxString aDefaultMeasurementUnit );
|
||||||
|
extern int StrToInt1Units( wxString aStr );
|
||||||
|
extern wxString ValidateName( wxString aName );
|
||||||
|
extern void SetWidth( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
int* aWidth,
|
||||||
|
wxString aActualConversion );
|
||||||
|
extern void SetPosition( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
int* aX,
|
||||||
|
int* aY,
|
||||||
|
wxString aActualConversion );
|
||||||
|
extern void SetDoublePrecisionPosition( wxString aStr,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
double* aX,
|
||||||
|
double* aY,
|
||||||
|
wxString aActualConversion );
|
||||||
|
extern void SetTextParameters( XNODE* aNode,
|
||||||
|
TTEXTVALUE* aTextValue,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
extern void SetFontProperty( XNODE* aNode,
|
||||||
|
TTEXTVALUE* aTextValue,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
extern void CorrectTextPosition( TTEXTVALUE* aValue, int aRotation );
|
||||||
|
|
||||||
|
extern XNODE* FindNode( XNODE* aChild, wxString aTag );
|
||||||
|
extern wxString FindNodeGetContent( XNODE* aChild, wxString aTag );
|
||||||
|
extern void InitTTextValue( TTEXTVALUE* aTextValue );
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCAD2KICAD_COMMON_H_
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcad_plugin.cpp
|
||||||
|
* @brief Pcbnew PLUGIN for P-Cad 2002/2004 ASCII *.pcb format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/filename.h>
|
||||||
|
#include <wx/xml/xml.h>
|
||||||
|
|
||||||
|
#include <pcad_plugin.h>
|
||||||
|
#include <s_expr_loader.h>
|
||||||
|
#include <pcb.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <macros.h>
|
||||||
|
#include <fctsys.h>
|
||||||
|
|
||||||
|
using namespace PCAD2KICAD;
|
||||||
|
|
||||||
|
PCAD_PLUGIN::PCAD_PLUGIN()
|
||||||
|
{
|
||||||
|
m_board = NULL;
|
||||||
|
m_props = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCAD_PLUGIN::~PCAD_PLUGIN()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wxString& PCAD_PLUGIN::PluginName() const
|
||||||
|
{
|
||||||
|
static const wxString name = wxT( "P-Cad" );
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wxString& PCAD_PLUGIN::GetFileExtension() const
|
||||||
|
{
|
||||||
|
static const wxString extension = wxT( "pcb" );
|
||||||
|
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
|
||||||
|
{
|
||||||
|
wxXmlDocument xmlDoc;
|
||||||
|
|
||||||
|
m_props = aProperties;
|
||||||
|
|
||||||
|
m_board = aAppendToMe ? aAppendToMe : new BOARD();
|
||||||
|
|
||||||
|
// Give the filename to the board if it's new
|
||||||
|
if( !aAppendToMe )
|
||||||
|
m_board->SetFileName( aFileName );
|
||||||
|
|
||||||
|
PCB pcb( m_board );
|
||||||
|
|
||||||
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
|
|
||||||
|
LoadInputFile( aFileName, &xmlDoc );
|
||||||
|
pcb.Parse( NULL, &xmlDoc, wxT( "PCB" ) );
|
||||||
|
pcb.AddToBoard();
|
||||||
|
|
||||||
|
return m_board;
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcad_plugin.h
|
||||||
|
* @brief Pcbnew PLUGIN for P-Cad 2002/2004 ASCII *.pcb format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCAD_PLUGIN_H_
|
||||||
|
#define PCAD_PLUGIN_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <io_mgr.h>
|
||||||
|
|
||||||
|
class PCAD_PLUGIN : public PLUGIN
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||||
|
|
||||||
|
const wxString& PluginName() const;
|
||||||
|
|
||||||
|
BOARD* Load( const wxString& aFileName,
|
||||||
|
BOARD* aAppendToMe,
|
||||||
|
PROPERTIES* aProperties = NULL );
|
||||||
|
|
||||||
|
const wxString& GetFileExtension() const;
|
||||||
|
|
||||||
|
// -----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||||
|
|
||||||
|
PCAD_PLUGIN();
|
||||||
|
~PCAD_PLUGIN();
|
||||||
|
private:
|
||||||
|
PROPERTIES* m_props;
|
||||||
|
BOARD* m_board;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PCAD_PLUGIN_H_
|
|
@ -0,0 +1,957 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb.h>
|
||||||
|
#include <pcb_arc.h>
|
||||||
|
#include <pcb_copper_pour.h>
|
||||||
|
#include <pcb_cutout.h>
|
||||||
|
#include <pcb_keepout.h>
|
||||||
|
#include <pcb_line.h>
|
||||||
|
#include <pcb_module.h>
|
||||||
|
#include <pcb_pad_shape.h>
|
||||||
|
#include <pcb_via_shape.h>
|
||||||
|
#include <pcb_pad.h>
|
||||||
|
#include <pcb_text.h>
|
||||||
|
#include <pcb_via.h>
|
||||||
|
#include <s_expr_loader.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
int PCB::GetKiCadLayer( int aPCadLayer )
|
||||||
|
{
|
||||||
|
assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER );
|
||||||
|
return m_layersMap[aPCadLayer].KiCadLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer )
|
||||||
|
{
|
||||||
|
assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER );
|
||||||
|
return m_layersMap[aPCadLayer].layerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString PCB::GetLayerNetNameRef( int aPCadLayer )
|
||||||
|
{
|
||||||
|
assert( aPCadLayer >= FIRST_COPPER_LAYER && aPCadLayer <= LAST_NO_COPPER_LAYER );
|
||||||
|
return m_layersMap[aPCadLayer].netNameRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCB::PCB( BOARD* aBoard ) : PCB_MODULE( this, aBoard )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
m_defaultMeasurementUnit = wxT( "mil" );
|
||||||
|
|
||||||
|
for( i = 0; i < NB_LAYERS; i++ )
|
||||||
|
{
|
||||||
|
m_layersMap[i].KiCadLayer = SOLDERMASK_N_FRONT; // default
|
||||||
|
m_layersMap[i].layerType = LAYER_TYPE_NONSIGNAL; // default
|
||||||
|
m_layersMap[i].netNameRef = wxT( "" ); // default
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sizeX = 0;
|
||||||
|
m_sizeY = 0;
|
||||||
|
|
||||||
|
m_layersMap[1].KiCadLayer = LAST_COPPER_LAYER;
|
||||||
|
m_layersMap[1].layerType = LAYER_TYPE_SIGNAL;
|
||||||
|
|
||||||
|
m_layersMap[2].KiCadLayer = FIRST_COPPER_LAYER;
|
||||||
|
m_layersMap[2].layerType = LAYER_TYPE_SIGNAL;
|
||||||
|
|
||||||
|
m_layersMap[3].KiCadLayer = ECO2_N;
|
||||||
|
m_layersMap[6].KiCadLayer = SILKSCREEN_N_FRONT;
|
||||||
|
m_layersMap[7].KiCadLayer = SILKSCREEN_N_BACK;
|
||||||
|
m_timestamp_cnt = 0x10000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB::~PCB()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_pcbComponents[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_pcbNetlist[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PCB::GetNewTimestamp()
|
||||||
|
{
|
||||||
|
return m_timestamp_cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PCB::GetNetCode( wxString aNetName )
|
||||||
|
{
|
||||||
|
PCB_NET* net;
|
||||||
|
|
||||||
|
for( int i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
net = m_pcbNetlist[i];
|
||||||
|
|
||||||
|
if( net->m_name == aNetName )
|
||||||
|
{
|
||||||
|
return net->m_netCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
XNODE* PCB::FindCompDefName( XNODE* aNode, wxString aName )
|
||||||
|
{
|
||||||
|
XNODE* result = NULL, * lNode;
|
||||||
|
wxString propValue;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "compDef" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "compDef" ) )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
|
||||||
|
if( propValue == aName )
|
||||||
|
{
|
||||||
|
result = lNode;
|
||||||
|
lNode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue,
|
||||||
|
wxString aPatGraphRefName, wxString aXmlName,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* tNode, * t1Node;
|
||||||
|
wxString n, pn, propValue, str;
|
||||||
|
|
||||||
|
// aNode is pattern now
|
||||||
|
tNode = aNode;
|
||||||
|
t1Node = aNode;
|
||||||
|
n = aXmlName;
|
||||||
|
|
||||||
|
// new file foramat version
|
||||||
|
if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( tNode,
|
||||||
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&pn );
|
||||||
|
pn.Trim( false );
|
||||||
|
pn.Trim( true );
|
||||||
|
tNode = FindNode( tNode, wxT( "patternGraphicsRef" ) );
|
||||||
|
|
||||||
|
while( tNode )
|
||||||
|
{
|
||||||
|
if( tNode->GetName() == wxT( "patternGraphicsRef" ) )
|
||||||
|
{
|
||||||
|
if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( tNode,
|
||||||
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&propValue );
|
||||||
|
|
||||||
|
if( propValue == pn )
|
||||||
|
{
|
||||||
|
t1Node = tNode; // find correct section with same name.
|
||||||
|
str = aTextValue->text;
|
||||||
|
str.Trim( false );
|
||||||
|
str.Trim( true );
|
||||||
|
n = n + wxT( ' ' ) + str; // changed in new file version.....
|
||||||
|
tNode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
tNode = tNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// old version and compatibile fr both from this point
|
||||||
|
tNode = FindNode( t1Node, wxT( "attr" ) );
|
||||||
|
|
||||||
|
while( tNode )
|
||||||
|
{
|
||||||
|
tNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
|
||||||
|
if( propValue == n )
|
||||||
|
break;
|
||||||
|
|
||||||
|
tNode = tNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
SetTextParameters( tNode, aTextValue, m_defaultMeasurementUnit, aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB::DoPCBComponents( XNODE* aNode,
|
||||||
|
wxXmlDocument* aXmlDoc,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar )
|
||||||
|
{
|
||||||
|
XNODE* lNode, * tNode, * mNode;
|
||||||
|
PCB_MODULE* mc;
|
||||||
|
PCB_PAD* pad;
|
||||||
|
PCB_VIA* via;
|
||||||
|
PCB_KEEPOUT* keepOut;
|
||||||
|
wxString cn, str, propValue;
|
||||||
|
|
||||||
|
lNode = aNode->GetChildren();
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
mc = NULL;
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "pattern" ) )
|
||||||
|
{
|
||||||
|
FindNode( lNode, wxT( "patternRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&cn );
|
||||||
|
cn = ValidateName( cn );
|
||||||
|
tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
||||||
|
|
||||||
|
if( tNode && cn.Len() > 0 )
|
||||||
|
{
|
||||||
|
tNode = FindModulePatternDefName( tNode, cn );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
mc = new PCB_MODULE( this, m_board );
|
||||||
|
mc->Parse( tNode, aStatusBar, m_defaultMeasurementUnit, aActualConversion );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mc )
|
||||||
|
{
|
||||||
|
mc->m_compRef = cn; // default - in new version of file it is updated later....
|
||||||
|
tNode = FindNode( lNode, wxT( "refDesRef" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
tNode->GetAttribute( wxT( "Name" ), &mc->m_name.text );
|
||||||
|
SetTextProperty( lNode, &mc->m_name, mc->m_patGraphRefName, wxT(
|
||||||
|
"RefDes" ), aActualConversion );
|
||||||
|
SetTextProperty( lNode, &mc->m_value, mc->m_patGraphRefName, wxT(
|
||||||
|
"Value" ), aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
tNode = FindNode( lNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
SetPosition( tNode->GetNodeContent(),
|
||||||
|
m_defaultMeasurementUnit,
|
||||||
|
&mc->m_positionX,
|
||||||
|
&mc->m_positionY,
|
||||||
|
aActualConversion );
|
||||||
|
|
||||||
|
tNode = FindNode( lNode, wxT( "rotation" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
str = tNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
mc->m_rotation = StrToInt1Units( str );
|
||||||
|
}
|
||||||
|
|
||||||
|
str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );
|
||||||
|
|
||||||
|
if( str == wxT( "True" ) )
|
||||||
|
mc->m_mirror = 1;
|
||||||
|
|
||||||
|
tNode = aNode;
|
||||||
|
|
||||||
|
while( tNode->GetName() != wxT( "www.lura.sk" ) )
|
||||||
|
tNode = tNode->GetParent();
|
||||||
|
|
||||||
|
tNode = FindNode( tNode, wxT( "netlist" ) );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
tNode = FindNode( tNode, wxT( "compInst" ) );
|
||||||
|
|
||||||
|
while( tNode )
|
||||||
|
{
|
||||||
|
tNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
|
||||||
|
if( propValue == mc->m_name.text )
|
||||||
|
{
|
||||||
|
if( FindNode( tNode, wxT( "compValue" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( tNode,
|
||||||
|
wxT( "compValue" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&mc->m_value.text );
|
||||||
|
mc->m_value.text.Trim( false );
|
||||||
|
mc->m_value.text.Trim( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FindNode( tNode, wxT( "compRef" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( tNode,
|
||||||
|
wxT( "compRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&mc->m_compRef );
|
||||||
|
mc->m_compRef.Trim( false );
|
||||||
|
mc->m_compRef.Trim( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
tNode = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tNode = tNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// map pins
|
||||||
|
tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
||||||
|
tNode = FindCompDefName( tNode, mc->m_compRef );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
tNode = FindPinMap( tNode );
|
||||||
|
|
||||||
|
if( tNode )
|
||||||
|
{
|
||||||
|
mNode = tNode->GetChildren();
|
||||||
|
|
||||||
|
while( mNode )
|
||||||
|
{
|
||||||
|
if( mNode->GetName() == wxT( "padNum" ) )
|
||||||
|
{
|
||||||
|
str = mNode->GetNodeContent();
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
|
||||||
|
if( !mNode )
|
||||||
|
break;
|
||||||
|
|
||||||
|
mNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
mc->SetPadName( str, propValue );
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
|
||||||
|
if( !mNode )
|
||||||
|
break;
|
||||||
|
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pcbComponents.Add( mc );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( lNode->GetName() == wxT( "pad" ) )
|
||||||
|
{
|
||||||
|
pad = new PCB_PAD( this, m_board );
|
||||||
|
pad->Parse( lNode, m_defaultMeasurementUnit, aActualConversion );
|
||||||
|
m_pcbComponents.Add( pad );
|
||||||
|
}
|
||||||
|
else if( lNode->GetName() == wxT( "via" ) )
|
||||||
|
{
|
||||||
|
via = new PCB_VIA( this, m_board );
|
||||||
|
via->Parse( lNode, m_defaultMeasurementUnit, aActualConversion );
|
||||||
|
m_pcbComponents.Add( via );
|
||||||
|
}
|
||||||
|
else if( lNode->GetName() == wxT( "polyKeepOut" ) )
|
||||||
|
{
|
||||||
|
keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 );
|
||||||
|
|
||||||
|
if( keepOut->Parse( lNode, m_defaultMeasurementUnit, aActualConversion ) )
|
||||||
|
m_pcbComponents.Add( keepOut );
|
||||||
|
else
|
||||||
|
delete keepOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB::ConnectPinToNet( wxString aCompRef, wxString aPinRef, wxString aNetName )
|
||||||
|
{
|
||||||
|
PCB_MODULE* module;
|
||||||
|
PCB_PAD* cp;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
module = (PCB_MODULE*) m_pcbComponents[i];
|
||||||
|
|
||||||
|
if( module->m_objType == wxT( 'M' ) && module->m_name.text == aCompRef )
|
||||||
|
{
|
||||||
|
for( j = 0; j < (int) module->m_moduleObjects.GetCount(); j++ )
|
||||||
|
{
|
||||||
|
if( module->m_moduleObjects[j]->m_objType == wxT( 'P' ) )
|
||||||
|
{
|
||||||
|
cp = (PCB_PAD*) module->m_moduleObjects[j];
|
||||||
|
|
||||||
|
if( cp->m_name.text == aPinRef )
|
||||||
|
cp->m_net = aNetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PCB::FindLayer( wxString aLayerName )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for ( i = 0; i < (int) m_layersStackup.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_layersStackup[i] == aLayerName )
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* KiCad layers
|
||||||
|
* 0 Copper layer
|
||||||
|
* 1 to 14 Inner layers
|
||||||
|
* 15 Component layer
|
||||||
|
* 16 Copper side adhesive layer Technical layers
|
||||||
|
* 17 Component side adhesive layer
|
||||||
|
* 18 Copper side Solder paste layer
|
||||||
|
* 19 Component Solder paste layer
|
||||||
|
* 20 Copper side Silk screen layer
|
||||||
|
* 21 Component Silk screen layer
|
||||||
|
* 22 Copper side Solder mask layer
|
||||||
|
* 23 Component Solder mask layer
|
||||||
|
* 24 Draw layer (Used for general drawings)
|
||||||
|
* 25 Comment layer (Other layer used for general drawings)
|
||||||
|
* 26 ECO1 layer (Other layer used for general drawings) // BUG
|
||||||
|
* 26 ECO2 layer (Other layer used for general drawings) // BUG 27
|
||||||
|
* 27 Edge layer. Items on Edge layer are seen on all layers // BUG 28
|
||||||
|
*/
|
||||||
|
void PCB::MapLayer( XNODE* aNode )
|
||||||
|
{
|
||||||
|
wxString lName, layerType;
|
||||||
|
int KiCadLayer;
|
||||||
|
long num = 0;
|
||||||
|
|
||||||
|
aNode->GetAttribute( wxT( "Name" ), &lName );
|
||||||
|
lName = lName.MakeUpper();
|
||||||
|
|
||||||
|
if( lName == wxT( "TOP ASSY" ) )
|
||||||
|
KiCadLayer = COMMENT_N;
|
||||||
|
else if( lName == wxT( "TOP SILK" ) )
|
||||||
|
KiCadLayer = SILKSCREEN_N_FRONT;
|
||||||
|
else if( lName == wxT( "TOP PASTE" ) )
|
||||||
|
KiCadLayer = SOLDERPASTE_N_FRONT;
|
||||||
|
else if( lName == wxT( "TOP MASK" ) )
|
||||||
|
KiCadLayer = SOLDERMASK_N_FRONT;
|
||||||
|
else if( lName == wxT( "TOP" ) )
|
||||||
|
KiCadLayer = LAST_COPPER_LAYER;
|
||||||
|
else if( lName == wxT( "BOTTOM" ) )
|
||||||
|
KiCadLayer = FIRST_COPPER_LAYER;
|
||||||
|
else if( lName == wxT( "BOT MASK" ) )
|
||||||
|
KiCadLayer = SOLDERMASK_N_BACK;
|
||||||
|
else if( lName == wxT( "BOT PASTE" ) )
|
||||||
|
KiCadLayer = SOLDERPASTE_N_BACK;
|
||||||
|
else if( lName == wxT( "BOT SILK" ) )
|
||||||
|
KiCadLayer = SILKSCREEN_N_BACK;
|
||||||
|
else if( lName == wxT( "BOT ASSY" ) )
|
||||||
|
KiCadLayer = DRAW_N;
|
||||||
|
else if( lName == wxT( "BOARD" ) )
|
||||||
|
KiCadLayer = EDGE_N;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KiCadLayer = FindLayer( lName );
|
||||||
|
|
||||||
|
if( KiCadLayer == -1 )
|
||||||
|
KiCadLayer = DRAW_N; // default
|
||||||
|
else
|
||||||
|
KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - KiCadLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "layerNum" ) ) )
|
||||||
|
FindNode( aNode, wxT( "layerNum" ) )->GetNodeContent().ToLong( &num );
|
||||||
|
|
||||||
|
assert( num >= FIRST_COPPER_LAYER && num <= LAST_NO_COPPER_LAYER );
|
||||||
|
m_layersMap[(int) num].KiCadLayer = KiCadLayer;
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "layerType" ) ) )
|
||||||
|
{
|
||||||
|
layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim( false );
|
||||||
|
|
||||||
|
if( layerType == wxT( "NonSignal" ) )
|
||||||
|
m_layersMap[(int) num].layerType = LAYER_TYPE_NONSIGNAL;
|
||||||
|
if( layerType == wxT( "Signal" ) )
|
||||||
|
m_layersMap[(int) num].layerType = LAYER_TYPE_SIGNAL;
|
||||||
|
if( layerType == wxT( "Plane" ) )
|
||||||
|
m_layersMap[(int) num].layerType = LAYER_TYPE_PLANE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "netNameRef" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&m_layersMap[(int) num].netNameRef );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PCB::FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) aOutline->GetCount(); i++ )
|
||||||
|
if( *((*aOutline)[i]) == aPoint )
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int cmpFunc( wxRealPoint **first, wxRealPoint **second )
|
||||||
|
{
|
||||||
|
return sqrt( pow( (double) aPointA.x - (double) aPointB.x, 2 ) +
|
||||||
|
pow( (double) aPointA.y - (double) aPointB.y, 2 ) );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
double PCB::GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 )
|
||||||
|
{
|
||||||
|
return sqrt( ( aPoint1->x - aPoint2->x ) *
|
||||||
|
( aPoint1->x - aPoint2->x ) +
|
||||||
|
( aPoint1->y - aPoint2->y ) *
|
||||||
|
( aPoint1->y - aPoint2->y ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* iNode, *lNode, *pNode;
|
||||||
|
long PCadLayer = 0;
|
||||||
|
int x, y, i, j, targetInd;
|
||||||
|
wxRealPoint* xchgPoint;
|
||||||
|
double minDistance, distance;
|
||||||
|
|
||||||
|
iNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
||||||
|
|
||||||
|
if( iNode )
|
||||||
|
{
|
||||||
|
// COMPONENTS AND OBJECTS
|
||||||
|
iNode = iNode->GetChildren();
|
||||||
|
|
||||||
|
while( iNode )
|
||||||
|
{
|
||||||
|
// objects
|
||||||
|
if( iNode->GetName() == wxT( "layerContents" ) )
|
||||||
|
{
|
||||||
|
if( FindNode( iNode, wxT( "layerNumRef" ) ) )
|
||||||
|
FindNode( iNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
|
||||||
|
|
||||||
|
if( GetKiCadLayer( PCadLayer ) == EDGE_N )
|
||||||
|
{
|
||||||
|
lNode = iNode->GetChildren();
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "line" ) )
|
||||||
|
{
|
||||||
|
pNode = FindNode( lNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( pNode )
|
||||||
|
{
|
||||||
|
SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit,
|
||||||
|
&x, &y, aActualConversion );
|
||||||
|
|
||||||
|
if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 )
|
||||||
|
m_boardOutline.Add( new wxRealPoint( x, y ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pNode = pNode->GetNext();
|
||||||
|
|
||||||
|
if( pNode )
|
||||||
|
{
|
||||||
|
SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit,
|
||||||
|
&x, &y, aActualConversion );
|
||||||
|
|
||||||
|
if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 )
|
||||||
|
m_boardOutline.Add( new wxRealPoint( x, y ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
//m_boardOutline.Sort( cmpFunc );
|
||||||
|
// sort vertices according to the distances between them
|
||||||
|
if( m_boardOutline.GetCount() > 3 )
|
||||||
|
{
|
||||||
|
for( i = 0; i < (int) m_boardOutline.GetCount() - 1; i++ )
|
||||||
|
{
|
||||||
|
minDistance = GetDistance( m_boardOutline[i], m_boardOutline[i + 1] );
|
||||||
|
targetInd = i + 1;
|
||||||
|
|
||||||
|
for( j = i + 2; j < (int) m_boardOutline.GetCount(); j++ )
|
||||||
|
{
|
||||||
|
distance = GetDistance( m_boardOutline[i], m_boardOutline[j] );
|
||||||
|
if( distance < minDistance )
|
||||||
|
{
|
||||||
|
minDistance = distance;
|
||||||
|
targetInd = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xchgPoint = m_boardOutline[i + 1];
|
||||||
|
m_boardOutline[i + 1] = m_boardOutline[targetInd];
|
||||||
|
m_boardOutline[targetInd] = xchgPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iNode = iNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCB::Parse( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* aNode;//, *aaNode;
|
||||||
|
PCB_NET* net;
|
||||||
|
PCB_COMPONENT* comp;
|
||||||
|
PCB_MODULE* module;
|
||||||
|
wxString compRef, pinRef, layerName, layerType;
|
||||||
|
int i, j, netCode;
|
||||||
|
|
||||||
|
// Defaut measurement units
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "asciiHeader" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "fileUnits" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
m_defaultMeasurementUnit = aNode->GetNodeContent();
|
||||||
|
m_defaultMeasurementUnit.Trim( true );
|
||||||
|
m_defaultMeasurementUnit.Trim( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine layers stackup
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
||||||
|
|
||||||
|
/*if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "layersStackup" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "layerStackupData" ) );
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
if( aNode->GetName() == wxT( "layerStackupData" ) )
|
||||||
|
{
|
||||||
|
aaNode = FindNode( aNode, wxT( "layerStackupName" ) );
|
||||||
|
|
||||||
|
if( aaNode ) {
|
||||||
|
aaNode->GetAttribute( wxT( "Name" ), &layerName );
|
||||||
|
layerName = layerName.MakeUpper();
|
||||||
|
m_layersStackup.Add( layerName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "layerDef" ) );
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
if( aNode->GetName() == wxT( "layerDef" ) )
|
||||||
|
{
|
||||||
|
if( FindNode( aNode, wxT( "layerType" ) ) )
|
||||||
|
{
|
||||||
|
layerType = FindNode( aNode,
|
||||||
|
wxT( "layerType" ) )->GetNodeContent().Trim( false );
|
||||||
|
|
||||||
|
if( layerType == wxT( "Signal" ) || layerType == wxT( "Plane" ) )
|
||||||
|
{
|
||||||
|
aNode->GetAttribute( wxT( "Name" ), &layerName );
|
||||||
|
layerName = layerName.MakeUpper();
|
||||||
|
m_layersStackup.Add( layerName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Layers mapping
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "layerDef" ) );
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
if( aNode->GetName() == wxT( "layerDef" ) )
|
||||||
|
MapLayer( aNode );
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetBoardOutline( aXmlDoc, aActualConversion );
|
||||||
|
|
||||||
|
// NETLIST
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Loading NETLIST " ) );
|
||||||
|
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "netlist" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "net" ) );
|
||||||
|
|
||||||
|
netCode = 1;
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
net = new PCB_NET( netCode++ );
|
||||||
|
net->Parse( aNode );
|
||||||
|
m_pcbNetlist.Add( net );
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOARD FILE
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Loading BOARD DEFINITION " ) );
|
||||||
|
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
// COMPONENTS AND OBJECTS
|
||||||
|
aNode = aNode->GetChildren();
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
// Components/modules
|
||||||
|
if( aNode->GetName() == wxT( "multiLayer" ) )
|
||||||
|
DoPCBComponents( aNode, aXmlDoc, aActualConversion, aStatusBar );
|
||||||
|
|
||||||
|
// objects
|
||||||
|
if( aNode->GetName() == wxT( "layerContents" ) )
|
||||||
|
DoLayerContentsObjects( aNode, NULL, &m_pcbComponents, aStatusBar,
|
||||||
|
m_defaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POSTPROCESS -- SET NETLIST REFERENCES
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Processing NETLIST " ) );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
net = m_pcbNetlist[i];
|
||||||
|
|
||||||
|
for( j = 0; j < (int) net->m_netNodes.GetCount(); j++ )
|
||||||
|
{
|
||||||
|
compRef = net->m_netNodes[j]->m_compRef;
|
||||||
|
compRef.Trim( false );
|
||||||
|
compRef.Trim( true );
|
||||||
|
pinRef = net->m_netNodes[j]->m_pinRef;
|
||||||
|
pinRef.Trim( false );
|
||||||
|
pinRef.Trim( true );
|
||||||
|
ConnectPinToNet( compRef, pinRef, net->m_name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POSTPROCESS -- FLIP COMPONENTS
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_pcbComponents[i]->m_objType == wxT( 'M' ) )
|
||||||
|
( (PCB_MODULE*) m_pcbComponents[i] )->Flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POSTPROCESS -- SET/OPTIMIZE NEW PCB POSITION
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Optimizing BOARD POSITION " ) );
|
||||||
|
|
||||||
|
m_sizeX = 10000000;
|
||||||
|
m_sizeY = 0;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
comp = m_pcbComponents[i];
|
||||||
|
|
||||||
|
if( comp->m_positionY < m_sizeY )
|
||||||
|
m_sizeY = comp->m_positionY; // max Y
|
||||||
|
|
||||||
|
if( comp->m_positionX < m_sizeX && comp->m_positionX > 0 )
|
||||||
|
m_sizeX = comp->m_positionX; // Min X
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sizeY -= 10000;
|
||||||
|
m_sizeX -= 10000;
|
||||||
|
// aStatusBar->SetStatusText( wxT( " POSITIONING POSTPROCESS " ) );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
m_pcbComponents[i]->SetPosOffset( -m_sizeX, -m_sizeY );
|
||||||
|
|
||||||
|
m_sizeX = 0;
|
||||||
|
m_sizeY = 0;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
comp = m_pcbComponents[i];
|
||||||
|
|
||||||
|
if( comp->m_positionY < m_sizeY )
|
||||||
|
m_sizeY = comp->m_positionY; // max Y
|
||||||
|
|
||||||
|
if( comp->m_positionX > m_sizeX )
|
||||||
|
m_sizeX = comp->m_positionX; // Min X
|
||||||
|
}
|
||||||
|
|
||||||
|
// SHEET SIZE CALCULATION
|
||||||
|
m_sizeY = -m_sizeY; // it is in absolute units
|
||||||
|
m_sizeX += 10000;
|
||||||
|
m_sizeY += 10000;
|
||||||
|
|
||||||
|
// A4 is minimum $Descr A4 11700 8267
|
||||||
|
if( m_sizeX < 11700 )
|
||||||
|
m_sizeX = 11700;
|
||||||
|
|
||||||
|
if( m_sizeY < 8267 )
|
||||||
|
m_sizeY = 8267;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// LIBRARY FILE
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Processing LIBRARY FILE " ) );
|
||||||
|
|
||||||
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
||||||
|
|
||||||
|
if( aNode )
|
||||||
|
{
|
||||||
|
aNode = FindNode( aNode, wxT( "compDef" ) );
|
||||||
|
|
||||||
|
while( aNode )
|
||||||
|
{
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Processing COMPONENTS " ) );
|
||||||
|
|
||||||
|
if( aNode->GetName() == wxT( "compDef" ) )
|
||||||
|
{
|
||||||
|
module = new PCB_MODULE( this, m_board );
|
||||||
|
module->Parse( aNode, aStatusBar, m_defaultMeasurementUnit,
|
||||||
|
aActualConversion );
|
||||||
|
m_pcbComponents.Add( module );
|
||||||
|
}
|
||||||
|
|
||||||
|
aNode = aNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB::WriteToFile( wxString aFileName )
|
||||||
|
{
|
||||||
|
wxFile f;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
f.Open( aFileName, wxFile::write );
|
||||||
|
|
||||||
|
// LIBRARY
|
||||||
|
f.Write( wxT( "PCBNEW-LibModule-V1 01/01/2001-01:01:01\n" ) );
|
||||||
|
f.Write( wxT( "\n" ) );
|
||||||
|
f.Write( wxT( "$INDEX\n" ) );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_pcbComponents[i]->m_objType == wxT( 'M' ) )
|
||||||
|
f.Write( m_pcbComponents[i]->m_name.text + wxT( "\n" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Write( wxT( "$EndINDEX\n" ) );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_pcbComponents[i]->m_objType == wxT( 'M' ) )
|
||||||
|
m_pcbComponents[i]->WriteToFile( &f, wxT( 'L' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Write( wxT( "$EndLIBRARY\n" ) );
|
||||||
|
|
||||||
|
f.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB::AddToBoard()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
PCB_NET* net;
|
||||||
|
|
||||||
|
m_board->SetCopperLayerCount( m_layersStackup.GetCount() );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
m_pcbComponents[i]->AddToBoard();
|
||||||
|
}
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
net = m_pcbNetlist[i];
|
||||||
|
|
||||||
|
m_board->AppendNet( new NETINFO_ITEM( m_board, net->m_name, net->m_netCode ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef pcb_H_
|
||||||
|
#define pcb_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <xnode.h>
|
||||||
|
|
||||||
|
#include <pcb_module.h>
|
||||||
|
#include <pcb_net.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB : public PCB_MODULE, public PCB_CALLBACKS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PCB_COMPONENTS_ARRAY m_pcbComponents; // PCB Modules,Lines,Routes,Texts, .... and so on
|
||||||
|
PCB_NETS_ARRAY m_pcbNetlist; // net objects collection
|
||||||
|
wxString m_defaultMeasurementUnit;
|
||||||
|
TLAYER m_layersMap[NB_LAYERS]; // flexible layers mapping
|
||||||
|
int m_sizeX;
|
||||||
|
int m_sizeY;
|
||||||
|
|
||||||
|
PCB( BOARD* aBoard );
|
||||||
|
~PCB();
|
||||||
|
|
||||||
|
int GetKiCadLayer( int aPCadLayer );
|
||||||
|
LAYER_TYPE_T GetLayerType( int aPCadLayer );
|
||||||
|
wxString GetLayerNetNameRef( int aPCadLayer );
|
||||||
|
int GetNewTimestamp();
|
||||||
|
int GetNetCode( wxString aNetName );
|
||||||
|
|
||||||
|
void Parse( wxStatusBar* aStatusBar,
|
||||||
|
wxXmlDocument* aXmlDoc,
|
||||||
|
wxString aActualConversion );
|
||||||
|
|
||||||
|
virtual void WriteToFile( wxString aFileName );
|
||||||
|
void AddToBoard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_timestamp_cnt;
|
||||||
|
wxArrayString m_layersStackup;
|
||||||
|
|
||||||
|
XNODE* FindCompDefName( XNODE* aNode, wxString aName );
|
||||||
|
void SetTextProperty( XNODE* aNode,
|
||||||
|
TTEXTVALUE* aTextValue,
|
||||||
|
wxString aPatGraphRefName,
|
||||||
|
wxString aXmlName,
|
||||||
|
wxString aActualConversion );
|
||||||
|
void DoPCBComponents( XNODE* aNode,
|
||||||
|
wxXmlDocument* aXmlDoc,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar );
|
||||||
|
void ConnectPinToNet( wxString aCr, wxString aPr, wxString aNetName );
|
||||||
|
int FindLayer( wxString aLayerName );
|
||||||
|
void MapLayer( XNODE* aNode );
|
||||||
|
int FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint );
|
||||||
|
double GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 );
|
||||||
|
void GetBoardOutline( wxXmlDocument* aXmlDoc, wxString aActualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // pcb_H_
|
|
@ -0,0 +1,186 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_arc.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <trigo.h>
|
||||||
|
|
||||||
|
#include <pcb_arc.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_ARC::PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'A' );
|
||||||
|
m_startX = 0;
|
||||||
|
m_startY = 0;
|
||||||
|
m_angle = 0;
|
||||||
|
m_width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_ARC::~PCB_ARC()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ARC::Parse( XNODE* aNode,
|
||||||
|
int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
double r = 0.0, a = 0.0;
|
||||||
|
int endPointX, endPointY;
|
||||||
|
|
||||||
|
m_PCadLayer = aLayer;
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
if( FindNode( aNode, wxT( "width" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &m_width, aActualConversion );
|
||||||
|
|
||||||
|
if( aNode->GetName() == wxT( "triplePointArc" ) )
|
||||||
|
{
|
||||||
|
// center point
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
// start point
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_startX, &m_startY, aActualConversion );
|
||||||
|
|
||||||
|
// end point
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&endPointX, &endPointY, aActualConversion );
|
||||||
|
|
||||||
|
int alpha1 = ArcTangente( m_startY - m_positionY, m_startX - m_positionX );
|
||||||
|
int alpha2 = ArcTangente( endPointY - m_positionY, endPointX - m_positionX );
|
||||||
|
m_angle = alpha1 - alpha2;
|
||||||
|
|
||||||
|
if( m_angle < 0 )
|
||||||
|
m_angle = 3600 + m_angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aNode->GetName() == wxT( "arc" ) )
|
||||||
|
{
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "radius" ) );
|
||||||
|
if( lNode)
|
||||||
|
r = StrToIntUnits( lNode->GetNodeContent(), wxT( ' ' ), aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "startAngle" ) );
|
||||||
|
if( lNode )
|
||||||
|
a = StrToInt1Units( lNode->GetNodeContent() );
|
||||||
|
|
||||||
|
m_startX = KiROUND( m_positionX + r * sin( (a - 900.0) * M_PI / 1800.0 ) );
|
||||||
|
m_startY = KiROUND( m_positionY - r * cos( (a - 900.0) * M_PI / 1800.0 ) );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "sweepAngle" ) );
|
||||||
|
if( lNode )
|
||||||
|
m_angle = StrToInt1Units( lNode->GetNodeContent() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ARC::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* DC ox oy fx fy w DC is a Draw Circle DC Xcentre Ycentre Xpoint Ypoint Width Layer
|
||||||
|
* DA x0 y0 x1 y1 angle width layer DA is a Draw ArcX0,y0 = Start point x1,y1 = end point
|
||||||
|
*/
|
||||||
|
if( aFileType == wxT( 'L' ) ) // Library component
|
||||||
|
{
|
||||||
|
aFile->Write( wxString::Format( wxT( "DA %d %d %d %d %d %d %d\n" ),
|
||||||
|
m_positionX, m_positionY, m_startX,
|
||||||
|
m_startY, m_angle, m_width,
|
||||||
|
m_KiCadLayer ) ); // ValueString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ARC::SetPosOffset( int aX_offs, int aY_offs )
|
||||||
|
{
|
||||||
|
PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
|
||||||
|
|
||||||
|
m_startX += aX_offs;
|
||||||
|
m_startY += aY_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ARC::AddToModule( MODULE* aModule )
|
||||||
|
{
|
||||||
|
if( IsValidNonCopperLayerIndex( m_KiCadLayer ) )
|
||||||
|
{
|
||||||
|
EDGE_MODULE* arc = new EDGE_MODULE( aModule, S_ARC );
|
||||||
|
aModule->m_Drawings.PushBack( arc );
|
||||||
|
|
||||||
|
arc->SetAngle( -m_angle );
|
||||||
|
arc->m_Start0 = wxPoint( m_positionX, m_positionY );
|
||||||
|
arc->m_End0 = wxPoint( m_startX, m_startY );
|
||||||
|
|
||||||
|
arc->SetWidth( m_width );
|
||||||
|
arc->SetLayer( m_KiCadLayer );
|
||||||
|
|
||||||
|
arc->SetDrawCoord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ARC::AddToBoard()
|
||||||
|
{
|
||||||
|
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
|
||||||
|
|
||||||
|
m_board->Add( dseg, ADD_APPEND );
|
||||||
|
|
||||||
|
dseg->SetShape( S_ARC );
|
||||||
|
dseg->SetTimeStamp( m_timestamp );
|
||||||
|
dseg->SetLayer( m_KiCadLayer );
|
||||||
|
dseg->SetStart( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
dseg->SetEnd( wxPoint( m_startX, m_startY ) );
|
||||||
|
dseg->SetAngle( -m_angle );
|
||||||
|
dseg->SetWidth( m_width );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_arc.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_ARC_H_
|
||||||
|
#define PCB_ARC_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_ARC : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_startX;
|
||||||
|
int m_startY;
|
||||||
|
int m_angle;
|
||||||
|
int m_width;
|
||||||
|
|
||||||
|
PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_ARC();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode, int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit, wxString aActualConversion );
|
||||||
|
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void SetPosOffset( int aX_offs, int aY_offs );
|
||||||
|
void AddToModule( MODULE* aModule );
|
||||||
|
void AddToBoard();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_ARC_H_
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_callbacks.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_CALLBACKS_H_
|
||||||
|
#define PCB_CALLBACKS_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
enum LAYER_TYPE_T
|
||||||
|
{
|
||||||
|
LAYER_TYPE_SIGNAL,
|
||||||
|
LAYER_TYPE_NONSIGNAL,
|
||||||
|
LAYER_TYPE_PLANE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _TLAYER
|
||||||
|
{
|
||||||
|
int KiCadLayer;
|
||||||
|
LAYER_TYPE_T layerType;
|
||||||
|
wxString netNameRef;
|
||||||
|
} TLAYER;
|
||||||
|
|
||||||
|
namespace PCAD2KICAD
|
||||||
|
{
|
||||||
|
|
||||||
|
class PCB_CALLBACKS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int GetKiCadLayer( int aPCadLayer ) = 0;
|
||||||
|
virtual LAYER_TYPE_T GetLayerType( int aPCadLayer ) = 0;
|
||||||
|
virtual wxString GetLayerNetNameRef( int aPCadLayer ) = 0;
|
||||||
|
virtual int GetNewTimestamp() = 0;
|
||||||
|
virtual int GetNetCode( wxString netName ) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PCB_CALLBACKS_H_
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_component.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard ) : m_callbacks( aCallbacks ),
|
||||||
|
m_board( aBoard )
|
||||||
|
{
|
||||||
|
m_tag = 0;
|
||||||
|
m_objType = wxT( '?' );
|
||||||
|
m_PCadLayer = 0;
|
||||||
|
m_KiCadLayer = 0;
|
||||||
|
m_timestamp = 0;
|
||||||
|
m_positionX = 0;
|
||||||
|
m_positionY = 0;
|
||||||
|
m_rotation = 0;
|
||||||
|
InitTTextValue( &m_name );
|
||||||
|
m_net = wxEmptyString;
|
||||||
|
m_netCode = 0;
|
||||||
|
m_compRef = wxEmptyString;
|
||||||
|
m_patGraphRefName = wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_COMPONENT::~PCB_COMPONENT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_COMPONENT::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_COMPONENT::AddToModule( MODULE* aModule )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_COMPONENT::SetPosOffset( int aX_offs, int aY_offs )
|
||||||
|
{
|
||||||
|
m_positionX += aX_offs;
|
||||||
|
m_positionY += aY_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_component.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_COMPONENT_H_
|
||||||
|
#define PCB_COMPONENT_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/file.h>
|
||||||
|
|
||||||
|
#include <pcad2kicad_common.h>
|
||||||
|
#include <pcb_callbacks.h>
|
||||||
|
#include <class_board.h>
|
||||||
|
#include <class_module.h>
|
||||||
|
#include <class_track.h>
|
||||||
|
#include <class_edge_mod.h>
|
||||||
|
#include <class_zone.h>
|
||||||
|
#include <class_pcb_text.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
// basic parent class for PCB objects
|
||||||
|
class PCB_COMPONENT : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_tag;
|
||||||
|
char m_objType;
|
||||||
|
int m_PCadLayer;
|
||||||
|
int m_KiCadLayer;
|
||||||
|
int m_timestamp;
|
||||||
|
int m_positionX;
|
||||||
|
int m_positionY;
|
||||||
|
int m_rotation;
|
||||||
|
TTEXTVALUE m_name; // name has also privete positions, rotations nand so on....
|
||||||
|
wxString m_net;
|
||||||
|
int m_netCode;
|
||||||
|
wxString m_compRef; // internal ussage for XL parsing
|
||||||
|
wxString m_patGraphRefName; // internal ussage for XL parsing
|
||||||
|
|
||||||
|
PCB_COMPONENT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_COMPONENT();
|
||||||
|
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void SetPosOffset( int aX_offs, int aY_offs );
|
||||||
|
virtual void AddToModule( MODULE* aModule );
|
||||||
|
virtual void AddToBoard() = 0;
|
||||||
|
|
||||||
|
int GetKiCadLayer() { return m_callbacks->GetKiCadLayer( m_PCadLayer ); }
|
||||||
|
int GetNewTimestamp() { return m_callbacks->GetNewTimestamp(); }
|
||||||
|
int GetNetCode( wxString aNetName ) { return m_callbacks->GetNetCode( aNetName ); }
|
||||||
|
protected:
|
||||||
|
PCB_CALLBACKS* m_callbacks;
|
||||||
|
BOARD* m_board;
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY( PCB_COMPONENT*, PCB_COMPONENTS_ARRAY );
|
||||||
|
WX_DEFINE_ARRAY( wxRealPoint*, VERTICES_ARRAY );
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_COMPONENT_H_
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_copper_pour.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_copper_pour.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_COPPER_POUR::PCB_COPPER_POUR( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard,
|
||||||
|
int aPCadLayer ) :
|
||||||
|
PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_COPPER_POUR::~PCB_COPPER_POUR()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_COPPER_POUR::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString pourType, str, propValue;
|
||||||
|
int pourSpacing, thermalWidth;
|
||||||
|
|
||||||
|
// aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " CooperPour..." ) );
|
||||||
|
|
||||||
|
//str = FindNode( aNode, wxT( "pourType" ) )->GetNodeContent();
|
||||||
|
//str.Trim( false );
|
||||||
|
//pourType = str.MakeUpper();
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_net = propValue;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "width" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &m_width, aActualConversion );
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "pourSpacing" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT( "pourSpacing" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &pourSpacing, aActualConversion );
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "thermalWidth" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &thermalWidth, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pcbPoly" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
// retrieve copper pour outline
|
||||||
|
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_copper_pour.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_COPPER_POUR_H_
|
||||||
|
#define PCB_COPPER_POUR_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_COPPER_POUR : public PCB_POLYGON
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_COPPER_POUR( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
|
||||||
|
~PCB_COPPER_POUR();
|
||||||
|
|
||||||
|
virtual bool Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_COPPER_POUR_H_
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_cutout.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <pcb_cutout.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_CUTOUT::PCB_CUTOUT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer ) :
|
||||||
|
PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'C' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_CUTOUT::~PCB_CUTOUT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_CUTOUT::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pcbPoly" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
// retrieve cutout outline
|
||||||
|
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_cutout.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_CUTOUT_H_
|
||||||
|
#define PCB_CUTOUT_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_CUTOUT : public PCB_POLYGON
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_CUTOUT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
|
||||||
|
~PCB_CUTOUT();
|
||||||
|
|
||||||
|
virtual bool Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString actualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_CUTOUT_H_
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_keepout.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_keepout.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_KEEPOUT::PCB_KEEPOUT( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard,
|
||||||
|
int aPCadLayer ) :
|
||||||
|
PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'K' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_KEEPOUT::~PCB_KEEPOUT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_KEEPOUT::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pcbPoly" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
// retrieve keepOut outline
|
||||||
|
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_keepout.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_KEEPOUT_H_
|
||||||
|
#define PCB_KEEPOUT_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_KEEPOUT : public PCB_POLYGON
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_KEEPOUT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
|
||||||
|
~PCB_KEEPOUT();
|
||||||
|
|
||||||
|
virtual bool Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_KEEPOUT_H_
|
|
@ -0,0 +1,166 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_line.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_line.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_LINE::PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
|
||||||
|
aBoard )
|
||||||
|
{
|
||||||
|
m_width = 0;
|
||||||
|
m_toX = 0;
|
||||||
|
m_toY = 0;
|
||||||
|
m_objType = wxT( 'L' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_LINE::~PCB_LINE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LINE::Parse( XNODE* aNode,
|
||||||
|
int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString propValue;
|
||||||
|
|
||||||
|
m_PCadLayer = aLayer;
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
m_positionX = 0;
|
||||||
|
m_positionY = 0;
|
||||||
|
m_toX = 0;
|
||||||
|
m_toY = 0;
|
||||||
|
m_width = 0;
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_toX, &m_toY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "width" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_net = propValue;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LINE::SetPosOffset( int aX_offs, int aY_offs )
|
||||||
|
{
|
||||||
|
PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
|
||||||
|
|
||||||
|
m_toX += aX_offs;
|
||||||
|
m_toY += aY_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LINE::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
if( aFileType == wxT( 'L' ) ) // Library
|
||||||
|
{
|
||||||
|
aFile->Write( wxString::Format( wxT( "DS %d %d %d %d %d %d\n" ), m_positionX, m_positionY,
|
||||||
|
m_toX, m_toY, m_width, m_KiCadLayer ) ); // Position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LINE::AddToModule( MODULE* aModule )
|
||||||
|
{
|
||||||
|
if( IsValidNonCopperLayerIndex( m_KiCadLayer ) )
|
||||||
|
{
|
||||||
|
EDGE_MODULE* segment = new EDGE_MODULE( aModule, S_SEGMENT );
|
||||||
|
aModule->m_Drawings.PushBack( segment );
|
||||||
|
|
||||||
|
segment->m_Start0 = wxPoint( m_positionX, m_positionY );
|
||||||
|
segment->m_End0 = wxPoint( m_toX, m_toY );
|
||||||
|
|
||||||
|
segment->SetWidth( m_width );
|
||||||
|
segment->SetLayer( m_KiCadLayer );
|
||||||
|
|
||||||
|
segment->SetDrawCoord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LINE::AddToBoard()
|
||||||
|
{
|
||||||
|
if( IsValidCopperLayerIndex( m_KiCadLayer ) )
|
||||||
|
{
|
||||||
|
TRACK* track = new TRACK( m_board );
|
||||||
|
m_board->m_Track.Append( track );
|
||||||
|
|
||||||
|
track->SetTimeStamp( m_timestamp );
|
||||||
|
|
||||||
|
track->SetPosition( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
track->SetEnd( wxPoint( m_toX, m_toY ) );
|
||||||
|
|
||||||
|
track->SetWidth( m_width );
|
||||||
|
|
||||||
|
track->SetLayer( m_KiCadLayer );
|
||||||
|
track->SetNet( m_netCode );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
|
||||||
|
m_board->Add( dseg, ADD_APPEND );
|
||||||
|
|
||||||
|
dseg->SetTimeStamp( m_timestamp );
|
||||||
|
dseg->SetLayer( m_KiCadLayer );
|
||||||
|
dseg->SetStart( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
dseg->SetEnd( wxPoint( m_toX, m_toY ) );
|
||||||
|
dseg->SetWidth( m_width );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_line.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_LINE_H_
|
||||||
|
#define PCB_LINE_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
// Line , routes and drawings
|
||||||
|
class PCB_LINE : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_width;
|
||||||
|
int m_toX;
|
||||||
|
int m_toY;
|
||||||
|
|
||||||
|
PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_LINE();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void SetPosOffset( int aX_offs, int aY_offs );
|
||||||
|
void AddToModule( MODULE* aModule );
|
||||||
|
void AddToBoard();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_LINE_H_
|
|
@ -0,0 +1,801 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_module.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_arc.h>
|
||||||
|
#include <pcb_copper_pour.h>
|
||||||
|
#include <pcb_cutout.h>
|
||||||
|
#include <pcb_plane.h>
|
||||||
|
#include <pcb_line.h>
|
||||||
|
#include <pcb_module.h>
|
||||||
|
#include <pcb_pad.h>
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
#include <pcb_text.h>
|
||||||
|
#include <pcb_via.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_MODULE::PCB_MODULE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
|
||||||
|
aBoard )
|
||||||
|
{
|
||||||
|
InitTTextValue( &m_value );
|
||||||
|
m_mirror = 0;
|
||||||
|
m_objType = wxT( 'M' ); // MODULE
|
||||||
|
m_KiCadLayer = SILKSCREEN_N_FRONT; // default
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_MODULE::~PCB_MODULE()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_moduleObjects[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XNODE* PCB_MODULE::FindModulePatternDefName( XNODE* aNode, wxString aName )
|
||||||
|
{
|
||||||
|
XNODE* result, * lNode;
|
||||||
|
wxString propValue1, propValue2;
|
||||||
|
|
||||||
|
result = NULL;
|
||||||
|
lNode = FindNode( aNode, wxT( "patternDef" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "patternDef" ) )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue1 );
|
||||||
|
FindNode( lNode,
|
||||||
|
wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 );
|
||||||
|
|
||||||
|
if( ValidateName( propValue1 ) == aName
|
||||||
|
|| ValidateName( propValue2 ) == aName )
|
||||||
|
{
|
||||||
|
result = lNode;
|
||||||
|
lNode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( result == NULL )
|
||||||
|
{
|
||||||
|
lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "patternDefExtended" ) )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue1 );
|
||||||
|
|
||||||
|
if( ValidateName( propValue1 ) == aName )
|
||||||
|
{
|
||||||
|
result = lNode;
|
||||||
|
lNode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XNODE* PCB_MODULE::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName )
|
||||||
|
{
|
||||||
|
XNODE* result, * pNode, * lNode;
|
||||||
|
wxString propValue, patName;
|
||||||
|
|
||||||
|
result = NULL;
|
||||||
|
pNode = aNode; // pattern;
|
||||||
|
lNode = aNode;
|
||||||
|
|
||||||
|
// calling from library conversion we need to find pattern
|
||||||
|
if( lNode->GetName() == wxT( "compDef" ) )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
patName = ValidateName( propValue );
|
||||||
|
|
||||||
|
if( FindNode( lNode, wxT( "attachedPattern" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( FindNode( lNode, wxT( "attachedPattern" ) ),
|
||||||
|
wxT( "patternName" ) )->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
patName = ValidateName( propValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindModulePatternDefName( lNode->GetParent(), patName );
|
||||||
|
pNode = lNode; // pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = NULL;
|
||||||
|
|
||||||
|
if( pNode )
|
||||||
|
lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format
|
||||||
|
|
||||||
|
*aPatGraphRefName = wxEmptyString; // default
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
result = lNode;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// New file format
|
||||||
|
if( FindNode( aNode, wxT( "patternGraphicsNameRef" ) ) )
|
||||||
|
{
|
||||||
|
FindNode( aNode,
|
||||||
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
aPatGraphRefName );
|
||||||
|
}
|
||||||
|
|
||||||
|
// /////////////////////////////////////////////////////////////////////
|
||||||
|
// lNode:=iNode.ChildNodes.FindNode('patternGraphicsDef'); before
|
||||||
|
// Fixed 02/08, Sergeys input file format
|
||||||
|
// Did it work before ????
|
||||||
|
// lNode:=pNode.ChildNodes.FindNode('patternGraphicsDef'); Nw for some files
|
||||||
|
// ////////////////////////////////////////////////////////////////////
|
||||||
|
if( FindNode( aNode, wxT( "patternGraphicsDef" ) ) )
|
||||||
|
lNode = FindNode( aNode, wxT( "patternGraphicsDef" ) );
|
||||||
|
else
|
||||||
|
lNode = FindNode( pNode, wxT( "patternGraphicsDef" ) );
|
||||||
|
|
||||||
|
if( *aPatGraphRefName == wxEmptyString ) // no patern delection, the first is actual...
|
||||||
|
{
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
result = FindNode( lNode, wxT( "multiLayer" ) );
|
||||||
|
lNode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while( lNode ) // selected by name
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "patternGraphicsDef" ) )
|
||||||
|
{
|
||||||
|
FindNode( lNode,
|
||||||
|
wxT( "patternGraphicsNameDef" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&propValue );
|
||||||
|
|
||||||
|
if( propValue == *aPatGraphRefName )
|
||||||
|
{
|
||||||
|
result = FindNode( lNode, wxT( "multiLayer" ) );
|
||||||
|
lNode = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::DoLayerContentsObjects( XNODE* aNode,
|
||||||
|
PCB_MODULE* aPCBModule,
|
||||||
|
PCB_COMPONENTS_ARRAY* aList,
|
||||||
|
wxStatusBar* aStatusBar,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
PCB_ARC* arc;
|
||||||
|
PCB_POLYGON* polygon;
|
||||||
|
PCB_POLYGON *plane_layer = NULL;
|
||||||
|
PCB_COPPER_POUR* copperPour;
|
||||||
|
PCB_CUTOUT* cutout;
|
||||||
|
PCB_PLANE* plane;
|
||||||
|
VERTICES_ARRAY* plane_layer_polygon;
|
||||||
|
PCB_LINE* line;
|
||||||
|
PCB_TEXT* text;
|
||||||
|
XNODE* lNode, * tNode;
|
||||||
|
wxString propValue;
|
||||||
|
long long i;
|
||||||
|
int PCadLayer;
|
||||||
|
long num = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Processing LAYER CONTENT OBJECTS " ) );
|
||||||
|
if( FindNode( aNode, wxT( "layerNumRef" ) ) )
|
||||||
|
FindNode( aNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &num );
|
||||||
|
|
||||||
|
PCadLayer = (int) num;
|
||||||
|
|
||||||
|
if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
|
||||||
|
{
|
||||||
|
plane_layer = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
|
||||||
|
plane_layer->AssignNet( m_callbacks->GetLayerNetNameRef( PCadLayer ) );
|
||||||
|
plane_layer->SetOutline( &m_boardOutline );
|
||||||
|
aList->Add( plane_layer );
|
||||||
|
|
||||||
|
// fill the polygon with the same contour as its outline is
|
||||||
|
//plane_layer->AddIsland( &m_boardOutline );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = aNode->GetChildren();
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
// aStatusBar->SetStatusText( wxString::Format( "Processing LAYER CONTENT OBJECTS :%lld",
|
||||||
|
// i ) );
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "line" ) )
|
||||||
|
{
|
||||||
|
line = new PCB_LINE( m_callbacks, m_board );
|
||||||
|
line->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
aList->Add( line );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "text" ) )
|
||||||
|
{
|
||||||
|
text = new PCB_TEXT( m_callbacks, m_board );
|
||||||
|
text->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
aList->Add( text );
|
||||||
|
}
|
||||||
|
|
||||||
|
// added as Sergeys request 02/2008
|
||||||
|
if( lNode->GetName() == wxT( "attr" ) )
|
||||||
|
{
|
||||||
|
// assign fonts to Module Name,Value,Type,....s
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
|
||||||
|
if( propValue == wxT( "Type" ) )
|
||||||
|
{
|
||||||
|
tNode = FindNode( lNode, wxT( "textStyleRef" ) );
|
||||||
|
|
||||||
|
if( tNode && aPCBModule )
|
||||||
|
{
|
||||||
|
// TODO: to understand and may be repair
|
||||||
|
// Alexander Lunev: originally in Delphi version of the project there was
|
||||||
|
// a strange access to pcbModule->m_name (it was global variable). This access
|
||||||
|
// is necessary when the function DoLayerContentsObjects() is called from
|
||||||
|
// function CreatePCBModule(). However it is not clear whether the access is
|
||||||
|
// required when the function DoLayerContentsObjects() is called from
|
||||||
|
// function ProcessXMLtoPCBLib().
|
||||||
|
SetFontProperty( tNode,
|
||||||
|
&aPCBModule->m_name,
|
||||||
|
aDefaultMeasurementUnit,
|
||||||
|
aActualConversion );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// added as Sergeys request 02/2008
|
||||||
|
if( lNode->GetName() == wxT( "arc" ) || lNode->GetName() == wxT( "triplePointArc" ) )
|
||||||
|
{
|
||||||
|
arc = new PCB_ARC( m_callbacks, m_board );
|
||||||
|
arc->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
aList->Add( arc );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "pcbPoly" ) )
|
||||||
|
{
|
||||||
|
if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
|
||||||
|
{
|
||||||
|
plane_layer_polygon = new VERTICES_ARRAY;
|
||||||
|
wxASSERT( plane_layer );
|
||||||
|
plane_layer->FormPolygon( lNode, plane_layer_polygon, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
plane_layer->m_cutouts.Add( plane_layer_polygon );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
polygon = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
|
||||||
|
if( polygon->Parse( lNode,
|
||||||
|
aDefaultMeasurementUnit,
|
||||||
|
aActualConversion,
|
||||||
|
aStatusBar ) )
|
||||||
|
aList->Add( polygon );
|
||||||
|
else
|
||||||
|
delete polygon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "copperPour95" ) )
|
||||||
|
{
|
||||||
|
copperPour = new PCB_COPPER_POUR( m_callbacks, m_board, PCadLayer );
|
||||||
|
|
||||||
|
if( copperPour->Parse( lNode, aDefaultMeasurementUnit, aActualConversion,
|
||||||
|
aStatusBar ) )
|
||||||
|
aList->Add( copperPour );
|
||||||
|
else
|
||||||
|
delete copperPour;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "polyCutOut" ) )
|
||||||
|
{
|
||||||
|
cutout = new PCB_CUTOUT( m_callbacks, m_board, PCadLayer );
|
||||||
|
|
||||||
|
if( cutout->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
|
||||||
|
aList->Add( cutout );
|
||||||
|
else
|
||||||
|
delete cutout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lNode->GetName() == wxT( "planeObj" ) )
|
||||||
|
{
|
||||||
|
plane = new PCB_PLANE( m_callbacks, m_board, PCadLayer );
|
||||||
|
|
||||||
|
if( plane->Parse( lNode, aDefaultMeasurementUnit, aActualConversion,
|
||||||
|
aStatusBar ) )
|
||||||
|
aList->Add( plane );
|
||||||
|
else
|
||||||
|
delete plane;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::SetPadName( wxString aPin, wxString aName )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
long num;
|
||||||
|
|
||||||
|
aPin.ToLong( &num );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
|
||||||
|
if( ( (PCB_PAD*) m_moduleObjects[i] )->m_number == num )
|
||||||
|
( (PCB_PAD*) m_moduleObjects[i] )->m_name.text = aName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
|
||||||
|
wxString aDefaultMeasurementUnit, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode, * tNode, * mNode;
|
||||||
|
PCB_PAD* pad;
|
||||||
|
PCB_VIA* via;
|
||||||
|
wxString propValue, str;
|
||||||
|
|
||||||
|
FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ),
|
||||||
|
&propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
m_name.text = propValue;
|
||||||
|
|
||||||
|
// aStatusBar->SetStatusText( wxT( "Creating Component : " ) + m_name.text );
|
||||||
|
lNode = aNode;
|
||||||
|
lNode = FindPatternMultilayerSection( lNode, &m_patGraphRefName );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
tNode = lNode;
|
||||||
|
tNode = tNode->GetChildren();
|
||||||
|
|
||||||
|
while( tNode )
|
||||||
|
{
|
||||||
|
if( tNode->GetName() == wxT( "pad" ) )
|
||||||
|
{
|
||||||
|
pad = new PCB_PAD( m_callbacks, m_board );
|
||||||
|
pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
m_moduleObjects.Add( pad );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tNode->GetName() == wxT( "via" ) )
|
||||||
|
{
|
||||||
|
via = new PCB_VIA( m_callbacks, m_board );
|
||||||
|
via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
m_moduleObjects.Add( via );
|
||||||
|
}
|
||||||
|
|
||||||
|
tNode = tNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetParent();
|
||||||
|
lNode = FindNode( lNode, wxT( "layerContents" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "layerContents" ) )
|
||||||
|
DoLayerContentsObjects( lNode, this, &m_moduleObjects, aStatusBar,
|
||||||
|
aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
// map pins
|
||||||
|
lNode = FindPinMap( aNode );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
mNode = lNode->GetChildren();
|
||||||
|
|
||||||
|
while( mNode )
|
||||||
|
{
|
||||||
|
if( mNode->GetName() == wxT( "padNum" ) )
|
||||||
|
{
|
||||||
|
str = mNode->GetNodeContent();
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
|
||||||
|
if( !mNode )
|
||||||
|
break;
|
||||||
|
|
||||||
|
mNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
SetPadName( str, propValue );
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
|
||||||
|
if( !mNode )
|
||||||
|
break;
|
||||||
|
|
||||||
|
mNode = mNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString PCB_MODULE::ModuleLayer( int aMirror )
|
||||||
|
{
|
||||||
|
wxString result;
|
||||||
|
|
||||||
|
// ///NOT ! {IntToStr(KiCadLayer)} NOT !
|
||||||
|
// / MODULES ARE HARD PLACED ON COMPONENT OR COPPER LAYER.
|
||||||
|
// / IsFLIPPED--> MIRROR attribute is decision Point!!!
|
||||||
|
|
||||||
|
if( aMirror == 0 )
|
||||||
|
result = wxT( "15" ); // Components side
|
||||||
|
else
|
||||||
|
result = wxT( "0" ); // Copper side
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
char visibility, mirrored;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// transform text positions ....
|
||||||
|
CorrectTextPosition( &m_name, m_rotation );
|
||||||
|
CorrectTextPosition( &m_value, m_rotation );
|
||||||
|
// Go out
|
||||||
|
aFile->Write( wxT( "\n" ) );
|
||||||
|
aFile->Write( wxT( "$MODULE " ) + m_name.text + wxT( "\n" ) );
|
||||||
|
aFile->Write( wxString::Format( wxT( "Po %d %d %d " ), m_positionX, m_positionY, m_rotation ) +
|
||||||
|
ModuleLayer( m_mirror ) + wxT( " 00000000 00000000 ~~\n" ) ); // Position
|
||||||
|
aFile->Write( wxT( "Li " ) + m_name.text + wxT( "\n" ) ); // Modulename
|
||||||
|
aFile->Write( wxT( "Sc 00000000\n" ) ); // Timestamp
|
||||||
|
aFile->Write( wxT( "Op 0 0 0\n" ) ); // Orientation
|
||||||
|
aFile->Write( wxT( "At SMD\n" ) ); // ??
|
||||||
|
|
||||||
|
// MODULE STRINGS
|
||||||
|
if( m_name.textIsVisible == 1 )
|
||||||
|
visibility = wxT( 'V' );
|
||||||
|
else
|
||||||
|
visibility = wxT( 'I' );
|
||||||
|
|
||||||
|
if( m_name.mirror == 1 )
|
||||||
|
mirrored = wxT( 'M' );
|
||||||
|
else
|
||||||
|
mirrored = wxT( 'N' );
|
||||||
|
|
||||||
|
aFile->Write( wxString::Format( wxT( "T0 %d %d %d %d %d %d" ), m_name.correctedPositionX,
|
||||||
|
m_name.correctedPositionY,
|
||||||
|
KiROUND( m_name.textHeight / 2 ),
|
||||||
|
KiROUND( m_name.textHeight / 1.5 ),
|
||||||
|
m_name.textRotation,
|
||||||
|
/* TODO: Is it correct to use m_value.textstrokeWidth here? */
|
||||||
|
m_value.textstrokeWidth ) +
|
||||||
|
wxT( ' ' ) + mirrored + wxT( ' ' ) + visibility +
|
||||||
|
wxString::Format( wxT( " %d \"" ), m_KiCadLayer ) +
|
||||||
|
m_name.text + wxT( "\"\n" ) ); // NameString
|
||||||
|
|
||||||
|
if( m_value.textIsVisible == 1 )
|
||||||
|
visibility = wxT( 'V' );
|
||||||
|
else
|
||||||
|
visibility = wxT( 'I' );
|
||||||
|
|
||||||
|
if( m_value.mirror == 1 )
|
||||||
|
mirrored = wxT( 'M' );
|
||||||
|
else
|
||||||
|
mirrored = wxT( 'N' );
|
||||||
|
|
||||||
|
aFile->Write( wxString::Format( wxT( "T1 %d %d %d %d %d %d" ), m_value.correctedPositionX,
|
||||||
|
m_value.correctedPositionY,
|
||||||
|
KiROUND( m_value.textHeight / 2 ),
|
||||||
|
KiROUND( m_value.textHeight / 1.5 ),
|
||||||
|
m_value.textRotation, m_value.textstrokeWidth ) +
|
||||||
|
wxT( ' ' ) + mirrored + wxT( ' ' ) + visibility +
|
||||||
|
wxString::Format( wxT( " %d \"" ), m_KiCadLayer ) + m_value.text +
|
||||||
|
wxT( "\"\n" ) ); // ValueString
|
||||||
|
|
||||||
|
// TEXTS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'T' ) )
|
||||||
|
{
|
||||||
|
( (PCB_TEXT*) m_moduleObjects[i] )->m_tag = i + 2;
|
||||||
|
m_moduleObjects[i]->WriteToFile( aFile, aFileType );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE LINES
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) )
|
||||||
|
m_moduleObjects[i]->WriteToFile( aFile, aFileType );
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE Arcs
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'A' ) )
|
||||||
|
m_moduleObjects[i]->WriteToFile( aFile, aFileType );
|
||||||
|
}
|
||||||
|
|
||||||
|
// PADS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
|
||||||
|
( (PCB_PAD*) m_moduleObjects[i] )->WriteToFile( aFile, aFileType, m_rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
// VIAS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'V' ) )
|
||||||
|
( (PCB_VIA*) m_moduleObjects[i] )->WriteToFile( aFile, aFileType, m_rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
// END
|
||||||
|
aFile->Write( wxT( "$EndMODULE " ) + m_name.text + wxT( "\n" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::AddToBoard()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// transform text positions
|
||||||
|
CorrectTextPosition( &m_name, m_rotation );
|
||||||
|
CorrectTextPosition( &m_value, m_rotation );
|
||||||
|
|
||||||
|
MODULE* module = new MODULE( m_board );
|
||||||
|
m_board->Add( module, ADD_APPEND );
|
||||||
|
|
||||||
|
module->SetPosition( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
module->SetLayer( m_mirror ? LAYER_N_BACK : LAYER_N_FRONT );
|
||||||
|
module->SetOrientation( m_rotation );
|
||||||
|
module->SetTimeStamp( 0 );
|
||||||
|
module->SetLastEditTime( 0 );
|
||||||
|
|
||||||
|
module->SetLibRef( m_compRef );
|
||||||
|
|
||||||
|
module->SetAttributes( MOD_DEFAULT | MOD_CMS );
|
||||||
|
|
||||||
|
// reference text
|
||||||
|
TEXTE_MODULE* ref_text = module->m_Reference;
|
||||||
|
|
||||||
|
ref_text->SetText( m_name.text );
|
||||||
|
ref_text->SetType( TEXT_is_REFERENCE );
|
||||||
|
|
||||||
|
ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );
|
||||||
|
ref_text->SetSize( wxSize( KiROUND( m_name.textHeight / 2 ),
|
||||||
|
KiROUND( m_name.textHeight / 1.5 ) ) );
|
||||||
|
|
||||||
|
ref_text->SetOrientation( m_name.textRotation );
|
||||||
|
ref_text->SetThickness( m_name.textstrokeWidth );
|
||||||
|
|
||||||
|
ref_text->SetMirrored( m_name.mirror );
|
||||||
|
ref_text->SetVisible( m_name.textIsVisible );
|
||||||
|
|
||||||
|
ref_text->SetLayer( m_KiCadLayer );
|
||||||
|
|
||||||
|
// Calculate the actual position.
|
||||||
|
ref_text->SetDrawCoord();
|
||||||
|
|
||||||
|
// value text
|
||||||
|
TEXTE_MODULE* val_text = module->m_Value;
|
||||||
|
|
||||||
|
val_text->SetText( m_value.text );
|
||||||
|
val_text->SetType( TEXT_is_REFERENCE );
|
||||||
|
|
||||||
|
val_text->SetPos0( wxPoint( m_value.correctedPositionX, m_value.correctedPositionY ) );
|
||||||
|
val_text->SetSize( wxSize( KiROUND( m_value.textHeight / 2 ),
|
||||||
|
KiROUND( m_value.textHeight / 1.5 ) ) );
|
||||||
|
|
||||||
|
val_text->SetOrientation( m_value.textRotation );
|
||||||
|
val_text->SetThickness( m_value.textstrokeWidth );
|
||||||
|
|
||||||
|
val_text->SetMirrored( m_value.mirror );
|
||||||
|
val_text->SetVisible( m_value.textIsVisible );
|
||||||
|
|
||||||
|
val_text->SetLayer( m_KiCadLayer );
|
||||||
|
|
||||||
|
// Calculate the actual position.
|
||||||
|
val_text->SetDrawCoord();
|
||||||
|
|
||||||
|
// TEXTS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'T' ) )
|
||||||
|
{
|
||||||
|
( (PCB_TEXT*) m_moduleObjects[i] )->m_tag = i + 2;
|
||||||
|
m_moduleObjects[i]->AddToModule( module );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE LINES
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) )
|
||||||
|
m_moduleObjects[i]->AddToModule( module );
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE Arcs
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'A' ) )
|
||||||
|
m_moduleObjects[i]->AddToModule( module );
|
||||||
|
}
|
||||||
|
|
||||||
|
// PADS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
|
||||||
|
( (PCB_PAD*) m_moduleObjects[i] )->AddToModule( module, m_rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
// VIAS
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'V' ) )
|
||||||
|
( (PCB_VIA*) m_moduleObjects[i] )->AddToModule( module, m_rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
module->CalculateBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PCB_MODULE::FlipLayers( int aLayer )
|
||||||
|
{
|
||||||
|
int result = aLayer; // no swap default....
|
||||||
|
|
||||||
|
// routed layers
|
||||||
|
if( aLayer == 0 )
|
||||||
|
result = 15;
|
||||||
|
|
||||||
|
if( aLayer == 15 )
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
// Silk
|
||||||
|
if( aLayer == 21 )
|
||||||
|
result = 20;
|
||||||
|
|
||||||
|
if( aLayer == 20 )
|
||||||
|
result = 21;
|
||||||
|
|
||||||
|
// Paste
|
||||||
|
if( aLayer == 19 )
|
||||||
|
result = 18;
|
||||||
|
|
||||||
|
if( aLayer == 18 )
|
||||||
|
result = 19;
|
||||||
|
|
||||||
|
// Mask
|
||||||
|
if( aLayer == 23 )
|
||||||
|
result = 22;
|
||||||
|
|
||||||
|
if( aLayer == 22 )
|
||||||
|
result = 23;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_MODULE::Flip()
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
if( m_mirror == 1 )
|
||||||
|
{
|
||||||
|
// Flipped
|
||||||
|
m_KiCadLayer = FlipLayers( m_KiCadLayer );
|
||||||
|
m_rotation = -m_rotation;
|
||||||
|
m_name.textPositionX = -m_name.textPositionX;
|
||||||
|
m_name.mirror = m_mirror;
|
||||||
|
m_value.textPositionX = -m_value.textPositionX;
|
||||||
|
m_value.mirror = m_mirror;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
// MODULE LINES
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'L' ) )
|
||||||
|
{
|
||||||
|
m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX;
|
||||||
|
( (PCB_LINE*) m_moduleObjects[i] )->m_toX =
|
||||||
|
-( (PCB_LINE*) m_moduleObjects[i] )->m_toX;
|
||||||
|
m_moduleObjects[i]->m_KiCadLayer = FlipLayers( m_moduleObjects[i]->m_KiCadLayer );
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE Arcs
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'A' ) )
|
||||||
|
{
|
||||||
|
m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX;
|
||||||
|
( (PCB_ARC*) m_moduleObjects[i] )->m_startX =
|
||||||
|
-( (PCB_ARC*) m_moduleObjects[i] )->m_startX;
|
||||||
|
m_moduleObjects[i]->m_KiCadLayer = FlipLayers( m_moduleObjects[i]->m_KiCadLayer );
|
||||||
|
}
|
||||||
|
|
||||||
|
// PADS
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
|
||||||
|
{
|
||||||
|
m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX;
|
||||||
|
m_moduleObjects[i]->m_rotation = -m_moduleObjects[i]->m_rotation;
|
||||||
|
|
||||||
|
for( j = 0; j < (int) ( (PCB_PAD*) m_moduleObjects[i] )->m_shapes.GetCount(); j++ )
|
||||||
|
( (PCB_PAD*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer =
|
||||||
|
FlipLayers( ( (PCB_PAD*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// VIAS
|
||||||
|
if( m_moduleObjects[i]->m_objType == wxT( 'V' ) )
|
||||||
|
{
|
||||||
|
m_moduleObjects[i]->m_positionX = -m_moduleObjects[i]->m_positionX;
|
||||||
|
|
||||||
|
for( j = 0; j < (int) ( (PCB_VIA*) m_moduleObjects[i] )->m_shapes.GetCount(); j++ )
|
||||||
|
( (PCB_VIA*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer =
|
||||||
|
FlipLayers( ( (PCB_VIA*) m_moduleObjects[i] )->m_shapes[j]->m_KiCadLayer );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_module.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_MODULE_H_
|
||||||
|
#define PCB_MODULE_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcad2kicad_common.h>
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_MODULE : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TTEXTVALUE m_value; // has reference (Name from parent) and value
|
||||||
|
PCB_COMPONENTS_ARRAY m_moduleObjects; // set of objects like PCB_LINE, PCB_PAD, PCB_VIA,....
|
||||||
|
int m_mirror;
|
||||||
|
VERTICES_ARRAY m_boardOutline;
|
||||||
|
|
||||||
|
PCB_MODULE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_MODULE();
|
||||||
|
|
||||||
|
XNODE* FindModulePatternDefName( XNODE* aNode, wxString aName );
|
||||||
|
|
||||||
|
void DoLayerContentsObjects( XNODE* aNode,
|
||||||
|
PCB_MODULE* aPCBModule,
|
||||||
|
PCB_COMPONENTS_ARRAY* aList,
|
||||||
|
wxStatusBar* aStatusBar,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
|
||||||
|
void SetPadName( wxString aPin, wxString aName );
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode, wxStatusBar* aStatusBar,
|
||||||
|
wxString aDefaultMeasurementUnit, wxString aActualConversion );
|
||||||
|
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void Flip();
|
||||||
|
void AddToBoard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
XNODE* FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName );
|
||||||
|
wxString ModuleLayer( int aMirror );
|
||||||
|
int FlipLayers( int aLayer );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_MODULE_H_
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_net.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <pcb_net.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_NET_NODE::PCB_NET_NODE()
|
||||||
|
{
|
||||||
|
m_compRef = wxEmptyString;
|
||||||
|
m_pinRef = wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_NET_NODE::~PCB_NET_NODE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_NET::PCB_NET( int aNetCode ) : m_netCode( aNetCode )
|
||||||
|
{
|
||||||
|
m_name = wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_NET::~PCB_NET()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_netNodes.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_netNodes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_NET::Parse( XNODE* aNode )
|
||||||
|
{
|
||||||
|
wxString propValue, s1, s2;
|
||||||
|
PCB_NET_NODE* netNode;
|
||||||
|
XNODE* lNode;
|
||||||
|
|
||||||
|
aNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_name = propValue;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "node" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &s2 );
|
||||||
|
s2.Trim( false );
|
||||||
|
s1 = wxEmptyString;
|
||||||
|
|
||||||
|
while( s2.Len() > 0 && s2[0] != wxT( ' ' ) )
|
||||||
|
{
|
||||||
|
s1 = s1 + s2[0];
|
||||||
|
s2 = s2.Mid( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
netNode = new PCB_NET_NODE;
|
||||||
|
s1.Trim( false );
|
||||||
|
s1.Trim( true );
|
||||||
|
netNode->m_compRef = s1;
|
||||||
|
|
||||||
|
s2.Trim( false );
|
||||||
|
s2.Trim( true );
|
||||||
|
netNode->m_pinRef = s2;
|
||||||
|
m_netNodes.Add( netNode );
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_net.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_NET_H_
|
||||||
|
#define PCB_NET_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcad2kicad_common.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_NET_NODE : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxString m_compRef;
|
||||||
|
wxString m_pinRef;
|
||||||
|
|
||||||
|
PCB_NET_NODE();
|
||||||
|
~PCB_NET_NODE();
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY( PCB_NET_NODE*, PCB_NET_NODES_ARRAY );
|
||||||
|
|
||||||
|
class PCB_NET : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxString m_name;
|
||||||
|
int m_netCode;
|
||||||
|
PCB_NET_NODES_ARRAY m_netNodes;
|
||||||
|
|
||||||
|
PCB_NET( int aNetCode );
|
||||||
|
~PCB_NET();
|
||||||
|
|
||||||
|
void Parse( XNODE* aNode );
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY( PCB_NET*, PCB_NETS_ARRAY );
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_NET_H_
|
|
@ -0,0 +1,425 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_pad.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
#include <trigo.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <pcb_pad.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_PAD::PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'P' );
|
||||||
|
m_number = 0;
|
||||||
|
m_hole = 0;
|
||||||
|
m_isHolePlated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_PAD::~PCB_PAD()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_shapes.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_shapes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode, *cNode;
|
||||||
|
long num;
|
||||||
|
wxString propValue, str, emsg;
|
||||||
|
PCB_PAD_SHAPE* padShape;
|
||||||
|
|
||||||
|
m_rotation = 0;
|
||||||
|
lNode = FindNode( aNode, wxT( "padNum" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetNodeContent().ToLong( &num );
|
||||||
|
m_number = (int) num;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "padStyleRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
m_name.text = propValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "rotation" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
str = lNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
m_rotation = StrToInt1Units( str );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = aNode;
|
||||||
|
|
||||||
|
while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) )
|
||||||
|
lNode = lNode->GetParent();
|
||||||
|
|
||||||
|
lNode = FindNode( lNode, wxT( "library" ) );
|
||||||
|
if ( !lNode )
|
||||||
|
THROW_IO_ERROR( wxT( "Unable to find library section" ) );
|
||||||
|
|
||||||
|
lNode = FindNode( lNode, wxT( "padStyleDef" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
|
||||||
|
if( propValue.IsSameAs( m_name.text, false) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !lNode )
|
||||||
|
THROW_IO_ERROR( wxString::Format( wxT( "Unable to find padStyleDef " ) + m_name.text ) );
|
||||||
|
|
||||||
|
cNode = FindNode( lNode, wxT( "holeDiam" ) );
|
||||||
|
|
||||||
|
if( cNode )
|
||||||
|
SetWidth( cNode->GetNodeContent(), aDefaultMeasurementUnit, &m_hole, aActualConversion );
|
||||||
|
|
||||||
|
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ) == wxT( "False" ) )
|
||||||
|
m_isHolePlated = false;
|
||||||
|
|
||||||
|
cNode = FindNode( lNode, wxT( "padShape" ) );
|
||||||
|
|
||||||
|
while( cNode )
|
||||||
|
{
|
||||||
|
if( cNode->GetName() == wxT( "padShape" ) )
|
||||||
|
{
|
||||||
|
// we support only Pads on specific layers......
|
||||||
|
// we do not support pads on "Plane", "NonSignal" , "Signal" ... layerr
|
||||||
|
if( FindNode( cNode, wxT( "layerNumRef" ) ) )
|
||||||
|
{
|
||||||
|
padShape = new PCB_PAD_SHAPE( m_callbacks, m_board );
|
||||||
|
padShape->Parse( cNode, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
m_shapes.Add( padShape );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cNode = cNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD::WriteToFile( wxFile* aFile, char aFileType, int aRotation )
|
||||||
|
{
|
||||||
|
PCB_PAD_SHAPE* padShape;
|
||||||
|
wxString padShapeName = wxT( "Ellipse" );
|
||||||
|
wxString s, padType;
|
||||||
|
uint32_t layerMask;
|
||||||
|
int i;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
|
||||||
|
if( !m_isHolePlated && m_hole )
|
||||||
|
{
|
||||||
|
aFile->Write( wxT( "$PAD\n" ) );
|
||||||
|
|
||||||
|
// Name, Shape, Xsize Ysize Xdelta Ydelta Orientation
|
||||||
|
aFile->Write( wxT( "Sh \"" ) + m_name.text + wxT( "\" " ) + s +
|
||||||
|
wxString::Format( wxT( " %d %d 0 0 %d\n" ),
|
||||||
|
m_hole, m_hole, m_rotation + aRotation ) );
|
||||||
|
|
||||||
|
// Hole size , OffsetX, OffsetY
|
||||||
|
aFile->Write( wxString::Format( wxT( "Dr %d 0 0\n" ), m_hole ) );
|
||||||
|
|
||||||
|
layerMask = ALL_CU_LAYERS | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT;
|
||||||
|
|
||||||
|
// <Pad type> N <layer mask>
|
||||||
|
aFile->Write( wxT( "At HOLE N " ) + wxString::Format( wxT( "%8X" ), layerMask ) +
|
||||||
|
wxT( "\n" ) );
|
||||||
|
|
||||||
|
// Reference
|
||||||
|
aFile->Write( wxT( "Ne 0 \"\"\n" ) );
|
||||||
|
|
||||||
|
// Position
|
||||||
|
aFile->Write( wxString::Format( wxT( "Po %d %d\n" ), m_positionX, m_positionY ) );
|
||||||
|
aFile->Write( wxT( "$EndPAD\n" ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
( m_hole ) ? padType = wxT( "STD" ) : padType = wxT( "SMD" );
|
||||||
|
|
||||||
|
// form layer mask
|
||||||
|
layerMask = 0;
|
||||||
|
for( i = 0; i < (int) m_shapes.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
padShape = m_shapes[i];
|
||||||
|
|
||||||
|
if( padShape->m_width > 0 && padShape->m_height > 0 )
|
||||||
|
{
|
||||||
|
if( padShape->m_KiCadLayer == LAYER_N_FRONT
|
||||||
|
|| padShape->m_KiCadLayer == LAYER_N_BACK )
|
||||||
|
{
|
||||||
|
padShapeName = padShape->m_shape;
|
||||||
|
width = padShape->m_width;
|
||||||
|
height = padShape->m_height;
|
||||||
|
|
||||||
|
// assume this is SMD pad
|
||||||
|
if( padShape->m_KiCadLayer == LAYER_N_FRONT )
|
||||||
|
layerMask = LAYER_FRONT | SOLDERPASTE_LAYER_FRONT | SOLDERMASK_LAYER_FRONT;
|
||||||
|
else
|
||||||
|
layerMask = LAYER_BACK | SOLDERPASTE_LAYER_BACK | SOLDERMASK_LAYER_BACK;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( padType == wxT( "STD" ) )
|
||||||
|
// actually this is a thru-hole pad
|
||||||
|
layerMask = ALL_CU_LAYERS | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT;
|
||||||
|
|
||||||
|
if( width == 0 || height == 0 )
|
||||||
|
THROW_IO_ERROR( wxT( "pad with zero size" ) );
|
||||||
|
|
||||||
|
|
||||||
|
if( padShapeName == wxT( "Oval" )
|
||||||
|
|| padShapeName == wxT( "Ellipse" )
|
||||||
|
|| padShapeName == wxT( "MtHole" ) )
|
||||||
|
{
|
||||||
|
if( width != height )
|
||||||
|
s = wxT( "O" );
|
||||||
|
else
|
||||||
|
s = wxT( "C" );
|
||||||
|
}
|
||||||
|
else if( padShapeName == wxT( "Rect" )
|
||||||
|
|| padShapeName == wxT( "RndRect" ) )
|
||||||
|
s = wxT( "R" );
|
||||||
|
else if( padShapeName == wxT( "Polygon" ) )
|
||||||
|
s = wxT( "R" ); // approximation.....
|
||||||
|
|
||||||
|
aFile->Write( wxT( "$PAD\n" ) );
|
||||||
|
|
||||||
|
// Name, Shape, Xsize Ysize Xdelta Ydelta Orientation
|
||||||
|
aFile->Write( wxT( "Sh \"" ) + m_name.text + wxT( "\" " ) + s +
|
||||||
|
wxString::Format( wxT( " %d %d 0 0 %d\n" ),
|
||||||
|
width, height, m_rotation + aRotation ) );
|
||||||
|
|
||||||
|
// Hole size , OffsetX, OffsetY
|
||||||
|
aFile->Write( wxString::Format( wxT( "Dr %d 0 0\n" ), m_hole ) );
|
||||||
|
|
||||||
|
// <Pad type> N <layer mask>
|
||||||
|
aFile->Write( wxT( "At " ) + padType + wxT( " N " ) +
|
||||||
|
wxString::Format( wxT( "%8X" ), layerMask ) + wxT( "\n" ) );
|
||||||
|
|
||||||
|
// Reference
|
||||||
|
aFile->Write( wxT( "Ne 0 \"" ) + m_net + wxT( "\"\n" ) );
|
||||||
|
|
||||||
|
// Position
|
||||||
|
aFile->Write( wxString::Format( wxT( "Po %d %d\n" ), m_positionX, m_positionY ) );
|
||||||
|
aFile->Write( wxT( "$EndPAD\n" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD::AddToModule( MODULE* aModule, int aRotation )
|
||||||
|
{
|
||||||
|
PCB_PAD_SHAPE* padShape;
|
||||||
|
wxString padShapeName = wxT( "Ellipse" );
|
||||||
|
PAD_ATTR_T padType;
|
||||||
|
int i;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
|
||||||
|
if( !m_isHolePlated && m_hole )
|
||||||
|
{
|
||||||
|
// mechanical hole
|
||||||
|
D_PAD* pad = new D_PAD( aModule );
|
||||||
|
aModule->m_Pads.PushBack( pad );
|
||||||
|
|
||||||
|
pad->SetShape( PAD_CIRCLE );
|
||||||
|
pad->SetAttribute( PAD_HOLE_NOT_PLATED );
|
||||||
|
|
||||||
|
pad->SetDrillShape( PAD_CIRCLE );
|
||||||
|
pad->SetDrillSize( wxSize( m_hole, m_hole ) );
|
||||||
|
pad->SetSize( wxSize( m_hole, m_hole ) );
|
||||||
|
|
||||||
|
// pad's "Position" is not relative to the module's,
|
||||||
|
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
|
||||||
|
wxPoint padpos( m_positionX, m_positionY );
|
||||||
|
pad->SetPos0( padpos );
|
||||||
|
RotatePoint( &padpos, aModule->GetOrientation() );
|
||||||
|
pad->SetPosition( padpos + aModule->GetPosition() );
|
||||||
|
|
||||||
|
pad->SetLayerMask( ALL_CU_LAYERS | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
D_PAD* pad = new D_PAD( aModule );
|
||||||
|
aModule->m_Pads.PushBack( pad );
|
||||||
|
|
||||||
|
( m_hole ) ? padType = PAD_STANDARD : padType = PAD_SMD;
|
||||||
|
|
||||||
|
// form layer mask
|
||||||
|
for( i = 0; i < (int) m_shapes.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
padShape = m_shapes[i];
|
||||||
|
|
||||||
|
if( padShape->m_width > 0 && padShape->m_height > 0 )
|
||||||
|
{
|
||||||
|
if( padShape->m_KiCadLayer == LAYER_N_FRONT
|
||||||
|
|| padShape->m_KiCadLayer == LAYER_N_BACK )
|
||||||
|
{
|
||||||
|
padShapeName = padShape->m_shape;
|
||||||
|
width = padShape->m_width;
|
||||||
|
height = padShape->m_height;
|
||||||
|
|
||||||
|
// assume this is SMD pad
|
||||||
|
if( padShape->m_KiCadLayer == LAYER_N_FRONT )
|
||||||
|
pad->SetLayerMask( LAYER_FRONT | SOLDERPASTE_LAYER_FRONT |
|
||||||
|
SOLDERMASK_LAYER_FRONT );
|
||||||
|
else
|
||||||
|
pad->SetLayerMask( LAYER_BACK | SOLDERPASTE_LAYER_BACK |
|
||||||
|
SOLDERMASK_LAYER_BACK );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( padType == PAD_STANDARD )
|
||||||
|
// actually this is a thru-hole pad
|
||||||
|
pad->SetLayerMask( ALL_CU_LAYERS | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT );
|
||||||
|
|
||||||
|
if( width == 0 || height == 0 )
|
||||||
|
THROW_IO_ERROR( wxT( "pad with zero size" ) );
|
||||||
|
|
||||||
|
pad->SetPadName( m_name.text );
|
||||||
|
|
||||||
|
if( padShapeName == wxT( "Oval" )
|
||||||
|
|| padShapeName == wxT( "Ellipse" )
|
||||||
|
|| padShapeName == wxT( "MtHole" ) )
|
||||||
|
{
|
||||||
|
if( width != height )
|
||||||
|
pad->SetShape( PAD_OVAL );
|
||||||
|
else
|
||||||
|
pad->SetShape( PAD_CIRCLE );
|
||||||
|
}
|
||||||
|
else if( padShapeName == wxT( "Rect" )
|
||||||
|
|| padShapeName == wxT( "RndRect" ) )
|
||||||
|
pad->SetShape( PAD_RECT );
|
||||||
|
else if( padShapeName == wxT( "Polygon" ) )
|
||||||
|
pad->SetShape( PAD_RECT ); // approximation
|
||||||
|
|
||||||
|
pad->SetSize( wxSize( width, height ) );
|
||||||
|
pad->SetDelta( wxSize( 0, 0 ) );
|
||||||
|
pad->SetOrientation( m_rotation + aRotation );
|
||||||
|
|
||||||
|
pad->SetDrillShape( PAD_CIRCLE );
|
||||||
|
pad->SetOffset( wxPoint( 0, 0 ) );
|
||||||
|
pad->SetDrillSize( wxSize( m_hole, m_hole ) );
|
||||||
|
|
||||||
|
pad->SetAttribute( padType );
|
||||||
|
|
||||||
|
pad->SetNet( 0 );
|
||||||
|
pad->SetNetname( m_net );
|
||||||
|
|
||||||
|
// pad's "Position" is not relative to the module's,
|
||||||
|
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
|
||||||
|
wxPoint padpos( m_positionX, m_positionY );
|
||||||
|
pad->SetPos0( padpos );
|
||||||
|
RotatePoint( &padpos, aModule->GetOrientation() );
|
||||||
|
pad->SetPosition( padpos + aModule->GetPosition() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD::AddToBoard()
|
||||||
|
{
|
||||||
|
PCB_PAD_SHAPE* padShape;
|
||||||
|
int i;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
|
||||||
|
// choose one of the shapes
|
||||||
|
for( i = 0; i < (int) m_shapes.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
padShape = m_shapes[i];
|
||||||
|
|
||||||
|
if( padShape->m_width > 0 && padShape->m_height > 0 )
|
||||||
|
{
|
||||||
|
if( padShape->m_KiCadLayer == LAYER_N_FRONT
|
||||||
|
|| padShape->m_KiCadLayer == LAYER_N_BACK )
|
||||||
|
{
|
||||||
|
width = padShape->m_width;
|
||||||
|
height = padShape->m_height;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( width == 0 || height == 0 )
|
||||||
|
THROW_IO_ERROR( wxT( "pad or via with zero size" ) );
|
||||||
|
|
||||||
|
if( IsValidCopperLayerIndex( m_KiCadLayer ) )
|
||||||
|
{
|
||||||
|
SEGVIA* via = new SEGVIA( m_board );
|
||||||
|
m_board->m_Track.Append( via );
|
||||||
|
|
||||||
|
via->SetTimeStamp( 0 );
|
||||||
|
|
||||||
|
via->SetPosition( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
via->SetEnd( wxPoint( m_positionX, m_positionY ) );
|
||||||
|
|
||||||
|
via->SetWidth( height );
|
||||||
|
via->SetShape( VIA_THROUGH );
|
||||||
|
( (SEGVIA*) via )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
|
||||||
|
via->SetDrill( m_hole );
|
||||||
|
|
||||||
|
via->SetLayer( m_KiCadLayer );
|
||||||
|
via->SetNet( m_netCode );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_pad.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_PAD_H_
|
||||||
|
#define PCB_PAD_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
#include <pcb_pad_shape.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_PAD : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_number;
|
||||||
|
int m_hole;
|
||||||
|
bool m_isHolePlated;
|
||||||
|
PCB_PAD_SHAPES_ARRAY m_shapes;
|
||||||
|
|
||||||
|
PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_PAD();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType, int aRotation );
|
||||||
|
void AddToModule( MODULE* aModule, int aRotation );
|
||||||
|
void AddToBoard();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_PAD_H_
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_pad_shape.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_pad_shape.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
m_shape = wxEmptyString;
|
||||||
|
m_width = 0;
|
||||||
|
m_height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_PAD_SHAPE::~PCB_PAD_SHAPE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD_SHAPE::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
wxString str, s;
|
||||||
|
long num;
|
||||||
|
int minX, maxX, minY, maxY, x, y;
|
||||||
|
XNODE* lNode;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "padShapeType" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
str = lNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
m_shape = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "layerNumRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetNodeContent().ToLong( &num );
|
||||||
|
m_PCadLayer = (int) num;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
|
||||||
|
if( m_shape == wxT( "Oval" )
|
||||||
|
|| m_shape == wxT( "Rect" )
|
||||||
|
|| m_shape == wxT( "Ellipse" )
|
||||||
|
|| m_shape == wxT( "MtHole" )
|
||||||
|
|| m_shape == wxT( "RndRect" ) )
|
||||||
|
{
|
||||||
|
lNode = FindNode( aNode, wxT( "shapeWidth" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width,
|
||||||
|
aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "shapeHeight" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth(
|
||||||
|
lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_height, aActualConversion );
|
||||||
|
}
|
||||||
|
else if( m_shape == wxT( "Polygon" ) )
|
||||||
|
{
|
||||||
|
// aproximation to simplier pad shape .....
|
||||||
|
lNode = FindNode( aNode, wxT( "shapeOutline" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
lNode = FindNode( lNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
minX = 0;
|
||||||
|
maxX = 0;
|
||||||
|
minY = 0;
|
||||||
|
maxY = 0;
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
s = lNode->GetNodeContent();
|
||||||
|
SetPosition( s, aDefaultMeasurementUnit, &x, &y, aActualConversion );
|
||||||
|
|
||||||
|
if( minX > x )
|
||||||
|
minX = x;
|
||||||
|
|
||||||
|
if( maxX < x )
|
||||||
|
maxX = x;
|
||||||
|
|
||||||
|
if( minY > y )
|
||||||
|
minY = y;
|
||||||
|
|
||||||
|
if( maxY < y )
|
||||||
|
maxY = y;
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_width = maxX - minX;
|
||||||
|
m_height = maxY - minY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAD_SHAPE::AddToBoard()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_pad_shape.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_PAD_SHAPE_H_
|
||||||
|
#define PCB_PAD_SHAPE_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/dynarray.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_PAD_SHAPE : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxString m_shape;
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
|
||||||
|
PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_PAD_SHAPE();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
|
||||||
|
void AddToBoard();
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY( PCB_PAD_SHAPE*, PCB_PAD_SHAPES_ARRAY );
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_PAD_SHAPE_H_
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_plane.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_plane.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_PLANE::PCB_PLANE( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard,
|
||||||
|
int aPCadLayer ) :
|
||||||
|
PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
|
||||||
|
{
|
||||||
|
m_priority = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_PLANE::~PCB_PLANE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_PLANE::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString pourType, str, propValue;
|
||||||
|
|
||||||
|
// aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " Plane..." ) );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_net = propValue;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FindNode( aNode, wxT( "width" ) ) )
|
||||||
|
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
|
||||||
|
aDefaultMeasurementUnit, &m_width, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pcbPoly" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
// retrieve plane outline
|
||||||
|
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_plane.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_PLANE_H_
|
||||||
|
#define PCB_PLANE_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_PLANE : public PCB_POLYGON
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_PLANE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
|
||||||
|
~PCB_PLANE();
|
||||||
|
|
||||||
|
virtual bool Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_PLANE_H_
|
|
@ -0,0 +1,258 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_polygon.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_polygon.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_POLYGON::PCB_POLYGON( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer ) :
|
||||||
|
PCB_COMPONENT( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
m_width = 0;
|
||||||
|
m_priority = 0;
|
||||||
|
m_objType = wxT( 'Z' );
|
||||||
|
m_PCadLayer = aPCadLayer;
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
m_timestamp = GetNewTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_POLYGON::~PCB_POLYGON()
|
||||||
|
{
|
||||||
|
int i, island;
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_outline.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete m_outline[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
|
||||||
|
{
|
||||||
|
for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete (*m_cutouts[island])[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_cutouts[island];
|
||||||
|
}
|
||||||
|
|
||||||
|
for( island = 0; island < (int) m_islands.GetCount(); island++ )
|
||||||
|
{
|
||||||
|
for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
|
||||||
|
{
|
||||||
|
delete (*m_islands[island])[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_islands[island];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCB_POLYGON::AssignNet( wxString aNetName )
|
||||||
|
{
|
||||||
|
m_net = aNetName;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCB_POLYGON::SetOutline( VERTICES_ARRAY* aOutline )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
m_outline.Empty();
|
||||||
|
|
||||||
|
for( i = 0; i < (int) aOutline->GetCount(); i++ )
|
||||||
|
m_outline.Add( new wxRealPoint( (*aOutline)[i]->x, (*aOutline)[i]->y ) );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
|
||||||
|
wxString aDefaultMeasurementUnit, wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "pt" ) )
|
||||||
|
{
|
||||||
|
SetDoublePrecisionPosition(
|
||||||
|
lNode->GetNodeContent(), aDefaultMeasurementUnit, &x, &y, aActualConversion );
|
||||||
|
aPolygon->Add( new wxRealPoint( x, y ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_POLYGON::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString propValue;
|
||||||
|
|
||||||
|
// aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " Polygon..." ) );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_net = propValue;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve polygon outline
|
||||||
|
FormPolygon( aNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
m_positionX = m_outline[0]->x;
|
||||||
|
m_positionY = m_outline[0]->y;
|
||||||
|
|
||||||
|
// fill the polygon with the same contour as its outline is
|
||||||
|
m_islands.Add( new VERTICES_ARRAY );
|
||||||
|
FormPolygon( aNode, m_islands[0], aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_POLYGON::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_POLYGON::WriteOutlineToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_POLYGON::AddToModule( MODULE* aModule )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_POLYGON::AddToBoard()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if( m_outline.GetCount() > 0 )
|
||||||
|
{
|
||||||
|
ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
|
||||||
|
m_board->Add( zone, ADD_APPEND );
|
||||||
|
|
||||||
|
zone->SetTimeStamp( m_timestamp );
|
||||||
|
zone->SetLayer( m_KiCadLayer );
|
||||||
|
zone->SetNet( m_netCode );
|
||||||
|
zone->SetNetName( m_net );
|
||||||
|
|
||||||
|
// add outline
|
||||||
|
int outline_hatch = CPolyLine::DIAGONAL_EDGE;
|
||||||
|
|
||||||
|
zone->m_Poly->Start( m_KiCadLayer, KiROUND( m_outline[i]->x ),
|
||||||
|
KiROUND( m_outline[i]->y ), outline_hatch );
|
||||||
|
|
||||||
|
for( i = 1; i < (int) m_outline.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
zone->AppendCorner( wxPoint( KiROUND( m_outline[i]->x ),
|
||||||
|
KiROUND( m_outline[i]->y ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
zone->m_Poly->CloseLastContour();
|
||||||
|
|
||||||
|
zone->SetZoneClearance( m_width );
|
||||||
|
|
||||||
|
zone->SetPriority( m_priority );
|
||||||
|
|
||||||
|
zone->m_Poly->SetHatch( outline_hatch,
|
||||||
|
Mils2iu( zone->m_Poly->GetDefaultHatchPitchMils() ),
|
||||||
|
true );
|
||||||
|
|
||||||
|
if ( m_objType == wxT( 'K' ) )
|
||||||
|
{
|
||||||
|
zone->SetIsKeepout( true );
|
||||||
|
zone->SetDoNotAllowTracks( true );
|
||||||
|
zone->SetDoNotAllowVias( true );
|
||||||
|
zone->SetDoNotAllowCopperPour( true );
|
||||||
|
}
|
||||||
|
else if( m_objType == wxT( 'C' ) )
|
||||||
|
{
|
||||||
|
// convert cutouts to keepouts because standalone cutouts are not supported in KiCad
|
||||||
|
zone->SetIsKeepout( true );
|
||||||
|
zone->SetDoNotAllowCopperPour( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
//zone->BuildFilledPolysListData( m_board );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_POLYGON::SetPosOffset( int aX_offs, int aY_offs )
|
||||||
|
{
|
||||||
|
int i, island;
|
||||||
|
|
||||||
|
PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
|
||||||
|
|
||||||
|
for( i = 0; i < (int) m_outline.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
m_outline[i]->x += aX_offs;
|
||||||
|
m_outline[i]->y += aY_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( island = 0; island < (int) m_islands.GetCount(); island++ )
|
||||||
|
{
|
||||||
|
for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
|
||||||
|
{
|
||||||
|
(*m_islands[island])[i]->x += aX_offs;
|
||||||
|
(*m_islands[island])[i]->y += aY_offs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
|
||||||
|
{
|
||||||
|
for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
|
||||||
|
{
|
||||||
|
(*m_cutouts[island])[i]->x += aX_offs;
|
||||||
|
(*m_cutouts[island])[i]->y += aY_offs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file PCBPolygon.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_POLYGON_H_
|
||||||
|
#define PCB_POLYGON_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
//WX_DEFINE_ARRAY( wxRealPoint*, VERTICES_ARRAY );
|
||||||
|
WX_DEFINE_ARRAY( VERTICES_ARRAY*, ISLANDS_ARRAY );
|
||||||
|
|
||||||
|
class PCB_POLYGON : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_width;
|
||||||
|
int m_priority;
|
||||||
|
VERTICES_ARRAY m_outline; // collection of boundary/outline lines - objects
|
||||||
|
ISLANDS_ARRAY m_islands;
|
||||||
|
ISLANDS_ARRAY m_cutouts;
|
||||||
|
|
||||||
|
PCB_POLYGON( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
|
||||||
|
~PCB_POLYGON();
|
||||||
|
|
||||||
|
virtual bool Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion,
|
||||||
|
wxStatusBar* aStatusBar );
|
||||||
|
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void WriteOutlineToFile( wxFile* aFile, char aFileType );
|
||||||
|
virtual void SetPosOffset( int aX_offs, int aY_offs );
|
||||||
|
void AddToModule( MODULE* aModule );
|
||||||
|
void AddToBoard();
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
void AssignNet( wxString aNetName );
|
||||||
|
void SetOutline( VERTICES_ARRAY* aOutline );
|
||||||
|
|
||||||
|
void FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
|
||||||
|
wxString aDefaultMeasurementUnit, wxString actualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_POLYGON_H_
|
|
@ -0,0 +1,171 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_text.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_text.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_TEXT::PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
|
||||||
|
aBoard )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'T' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_TEXT::~PCB_TEXT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_TEXT::Parse( XNODE* aNode,
|
||||||
|
int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString str;
|
||||||
|
|
||||||
|
m_PCadLayer = aLayer;
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
m_positionX = 0;
|
||||||
|
m_positionY = 0;
|
||||||
|
m_name.mirror = 0; // Normal, not mirrored
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "rotation" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
str = lNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
m_rotation = StrToInt1Units( str );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "value" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
m_name.text = lNode->GetNodeContent();
|
||||||
|
|
||||||
|
str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
|
||||||
|
|
||||||
|
if( str == wxT( "True" ) )
|
||||||
|
m_name.mirror = 1;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "textStyleRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetFontProperty( lNode, &m_name, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_TEXT::WriteToFile( wxFile* aFile, char aFileType )
|
||||||
|
{
|
||||||
|
char visibility, mirrored;
|
||||||
|
|
||||||
|
if( m_name.textIsVisible == 1 )
|
||||||
|
visibility = wxT( 'V' );
|
||||||
|
else
|
||||||
|
visibility = wxT( 'I' );
|
||||||
|
|
||||||
|
if( m_name.mirror == 1 )
|
||||||
|
mirrored = wxT( 'M' );
|
||||||
|
else
|
||||||
|
mirrored = wxT( 'N' );
|
||||||
|
|
||||||
|
// Simple, not the best, but acceptable text positioning.....
|
||||||
|
m_name.textPositionX = m_positionX;
|
||||||
|
m_name.textPositionY = m_positionY;
|
||||||
|
CorrectTextPosition( &m_name, m_rotation );
|
||||||
|
|
||||||
|
// Go out
|
||||||
|
if( aFileType == wxT( 'L' ) ) // Library component
|
||||||
|
{
|
||||||
|
aFile->Write( wxString::Format( wxT( "T%d %d %d %d %d %d %d " ), m_tag,
|
||||||
|
m_name.correctedPositionX,
|
||||||
|
m_name.correctedPositionY,
|
||||||
|
KiROUND( m_name.textHeight / 2 ),
|
||||||
|
KiROUND( m_name.textHeight / 1.1 ),
|
||||||
|
m_rotation, m_name.textstrokeWidth ) +
|
||||||
|
mirrored + wxT( ' ' ) + visibility +
|
||||||
|
wxString::Format( wxT( " %d \"" ), m_KiCadLayer ) +
|
||||||
|
m_name.text + wxT( "\"\n" ) ); // ValueString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_TEXT::AddToModule( MODULE* aModule )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_TEXT::AddToBoard()
|
||||||
|
{
|
||||||
|
// Simple, not the best, but acceptable text positioning.
|
||||||
|
m_name.textPositionX = m_positionX;
|
||||||
|
m_name.textPositionY = m_positionY;
|
||||||
|
CorrectTextPosition( &m_name, m_rotation );
|
||||||
|
|
||||||
|
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
|
||||||
|
m_board->Add( pcbtxt, ADD_APPEND );
|
||||||
|
|
||||||
|
pcbtxt->SetText( m_name.text );
|
||||||
|
|
||||||
|
pcbtxt->SetSize( wxSize( KiROUND( m_name.textHeight / 2 ),
|
||||||
|
KiROUND( m_name.textHeight / 1.1 ) ) );
|
||||||
|
|
||||||
|
pcbtxt->SetThickness( m_name.textstrokeWidth );
|
||||||
|
pcbtxt->SetOrientation( m_rotation );
|
||||||
|
|
||||||
|
pcbtxt->SetPosition( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );
|
||||||
|
|
||||||
|
pcbtxt->SetMirrored( m_name.mirror );
|
||||||
|
pcbtxt->SetTimeStamp( 0 );
|
||||||
|
|
||||||
|
pcbtxt->SetLayer( m_KiCadLayer );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// void PCB_TEXT::SetPosOffset( int aX_offs, int aY_offs )
|
||||||
|
// {
|
||||||
|
// PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
|
||||||
|
|
||||||
|
// m_name.textPositionX += aX_offs;
|
||||||
|
// m_name.textPositionY += aY_offs;
|
||||||
|
// }
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_text.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_TEXT_H_
|
||||||
|
#define PCB_TEXT_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_component.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
// Name property of parent is used for text value
|
||||||
|
class PCB_TEXT : public PCB_COMPONENT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_TEXT();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
int aLayer,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
virtual void WriteToFile( wxFile* aFile, char aFileType );
|
||||||
|
void AddToModule( MODULE* aModule );
|
||||||
|
void AddToBoard();
|
||||||
|
|
||||||
|
// virtual void SetPosOffset( int aX_offs, int aY_offs );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_TEXT_H_
|
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_via.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <pcb_via.h>
|
||||||
|
#include <pcb_via_shape.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_VIA::PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_PAD( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
m_objType = wxT( 'V' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_VIA::~PCB_VIA()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_VIA::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode, * tNode;
|
||||||
|
wxString propValue;
|
||||||
|
PCB_VIA_SHAPE* viaShape;
|
||||||
|
|
||||||
|
m_rotation = 0;
|
||||||
|
lNode = FindNode( aNode, wxT( "viaStyleRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_name.text = propValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
|
||||||
|
&m_positionX, &m_positionY, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
propValue.Trim( false );
|
||||||
|
propValue.Trim( true );
|
||||||
|
m_net = propValue;
|
||||||
|
m_netCode = GetNetCode( m_net );
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = aNode;
|
||||||
|
|
||||||
|
while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) )
|
||||||
|
lNode = lNode->GetParent();
|
||||||
|
|
||||||
|
lNode = FindNode( lNode, wxT( "library" ) );
|
||||||
|
|
||||||
|
if ( !lNode )
|
||||||
|
THROW_IO_ERROR( wxT( "Unable to find library section" ) );
|
||||||
|
|
||||||
|
lNode = FindNode( lNode, wxT( "viaStyleDef" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
||||||
|
|
||||||
|
if( propValue.IsSameAs( m_name.text, false ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !lNode )
|
||||||
|
THROW_IO_ERROR( wxString::Format( wxT( "Unable to find viaStyleDef " ) + m_name.text ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
tNode = lNode;
|
||||||
|
lNode = FindNode( tNode, wxT( "holeDiam" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_hole,
|
||||||
|
aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( tNode, wxT( "viaShape" ) );
|
||||||
|
|
||||||
|
while( lNode )
|
||||||
|
{
|
||||||
|
if( lNode->GetName() == wxT( "viaShape" ) )
|
||||||
|
{
|
||||||
|
// we support only Vias on specific layers......
|
||||||
|
// we do not support vias on "Plane", "NonSignal" , "Signal" ... layerr
|
||||||
|
if( FindNode( lNode, wxT( "layerNumRef" ) ) )
|
||||||
|
{
|
||||||
|
viaShape = new PCB_VIA_SHAPE( m_callbacks, m_board );
|
||||||
|
viaShape->Parse( lNode, aDefaultMeasurementUnit, aActualConversion );
|
||||||
|
m_shapes.Add( viaShape );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = lNode->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_via.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_VIA_H_
|
||||||
|
#define PCB_VIA_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_pad.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
// will be replaced by pad in next version ????
|
||||||
|
class PCB_VIA : public PCB_PAD
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_VIA();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_VIA_H_
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_via_shape.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#include <pcb_via_shape.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
PCB_VIA_SHAPE::PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks,
|
||||||
|
BOARD* aBoard ) : PCB_PAD_SHAPE( aCallbacks, aBoard )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_VIA_SHAPE::~PCB_VIA_SHAPE()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_VIA_SHAPE::Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion )
|
||||||
|
{
|
||||||
|
XNODE* lNode;
|
||||||
|
wxString str;
|
||||||
|
long num;
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "viaShapeType" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
str = lNode->GetNodeContent();
|
||||||
|
str.Trim( false );
|
||||||
|
m_shape = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "layerNumRef" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
{
|
||||||
|
lNode->GetNodeContent().ToLong( &num );
|
||||||
|
m_PCadLayer = (int) num;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_KiCadLayer = GetKiCadLayer();
|
||||||
|
lNode = FindNode( aNode, wxT( "shapeWidth" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion );
|
||||||
|
|
||||||
|
lNode = FindNode( aNode, wxT( "shapeHeight" ) );
|
||||||
|
|
||||||
|
if( lNode )
|
||||||
|
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_height, aActualConversion );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
||||||
|
* Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pcb_via_shape.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCB_VIA_SHAPE_H_
|
||||||
|
#define PCB_VIA_SHAPE_H_
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include <pcb_pad_shape.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
class PCB_VIA_SHAPE : public PCB_PAD_SHAPE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
|
||||||
|
~PCB_VIA_SHAPE();
|
||||||
|
|
||||||
|
virtual void Parse( XNODE* aNode,
|
||||||
|
wxString aDefaultMeasurementUnit,
|
||||||
|
wxString aActualConversion );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
||||||
|
|
||||||
|
#endif // PCB_VIA_SHAPE_H_
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file s_expr_loader.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <dsnlexer.h>
|
||||||
|
#include <macros.h>
|
||||||
|
#include <wx/xml/xml.h>
|
||||||
|
#include <xnode.h>
|
||||||
|
|
||||||
|
namespace PCAD2KICAD {
|
||||||
|
|
||||||
|
static KEYWORD empty_keywords[1] = {};
|
||||||
|
|
||||||
|
void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
|
||||||
|
{
|
||||||
|
int tok;
|
||||||
|
XNODE* iNode = NULL, *cNode = NULL;
|
||||||
|
wxString str;
|
||||||
|
bool growing = false;
|
||||||
|
bool attr = false;
|
||||||
|
wxCSConv conv( wxT( "windows-1251" ) );
|
||||||
|
|
||||||
|
FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
|
||||||
|
|
||||||
|
if( !fp )
|
||||||
|
THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName );
|
||||||
|
|
||||||
|
// lexer now owns fp, will close on exception or return
|
||||||
|
DSNLEXER lexer( empty_keywords, 0, fp, aFileName );
|
||||||
|
|
||||||
|
iNode = new XNODE( wxXML_ELEMENT_NODE, wxT( "www.lura.sk" ) );
|
||||||
|
|
||||||
|
while( ( tok = lexer.NextTok() ) != DSN_EOF )
|
||||||
|
{
|
||||||
|
if( growing && ( tok == DSN_LEFT || tok == DSN_RIGHT ) )
|
||||||
|
{
|
||||||
|
if( attr )
|
||||||
|
{
|
||||||
|
cNode->AddAttribute( wxT( "Name" ), str.Trim( false ) );
|
||||||
|
}
|
||||||
|
else if( str != wxEmptyString )
|
||||||
|
{
|
||||||
|
cNode->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, str ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
growing = false;
|
||||||
|
attr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tok == DSN_RIGHT )
|
||||||
|
{
|
||||||
|
iNode = iNode->GetParent();
|
||||||
|
}
|
||||||
|
else if( tok == DSN_LEFT )
|
||||||
|
{
|
||||||
|
tok = lexer.NextTok();
|
||||||
|
str = wxEmptyString;
|
||||||
|
cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) );
|
||||||
|
iNode->AddChild( cNode );
|
||||||
|
iNode = cNode;
|
||||||
|
growing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str += wxT( ' ' );
|
||||||
|
str += wxString( lexer.CurText(), conv );
|
||||||
|
if( tok == DSN_STRING )
|
||||||
|
attr = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( iNode )
|
||||||
|
{
|
||||||
|
aXmlDoc->SetRoot( iNode );
|
||||||
|
//aXmlDoc->Save( wxT( "test.xml" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PCAD2KICAD
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||||
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file s_expr_loader.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef S_EXPR_LOADER_H_
|
||||||
|
#define S_EXPR_LOADER_H_
|
||||||
|
|
||||||
|
namespace PCAD2KICAD
|
||||||
|
{
|
||||||
|
void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // S_EXPR_LOADER_H_
|
Loading…
Reference in New Issue