BOARD::Add(): fix an issue for tracks: parent not set (could be an issue only in python scripts, because the parent is set by the constructor)

*.i : fix coding style issues.
python method: add BOARD_ITEM Duplicate, which is a wrapper to Clone(). ( defined as Cast_to_BOARD_ITEM(selt.Clone()).Cast() )
update some .py examples.
This commit is contained in:
jean-pierre charras 2014-10-02 19:09:32 +02:00
parent 7c747c1a44
commit e6274f70b0
11 changed files with 169 additions and 159 deletions

View File

@ -663,6 +663,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
TRACK* insertAid;
insertAid = ( (TRACK*) aBoardItem )->GetBestInsertPoint( this );
m_Track.Insert( (TRACK*) aBoardItem, insertAid );
aBoardItem->SetParent( this );
break;
case PCB_ZONE_T:

View File

@ -804,7 +804,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
SetTimeStamp( src->m_TimeStamp );
m_Poly->RemoveAllContours();
m_Poly->Copy( src->m_Poly ); // copy outlines
m_CornerSelection = -1; // For corner moving, corner index to drag, or -1 if no selection
m_CornerSelection = -1; // For corner moving, corner index to drag,
// or -1 if no selection
m_ZoneClearance = src->m_ZoneClearance; // clearance value
m_ZoneMinThickness = src->m_ZoneMinThickness;
m_FillMode = src->m_FillMode; // Filling mode (segments/polygons)

View File

@ -36,7 +36,6 @@
def GetDrawings(self): return self.m_Drawings
def GetTracks(self): return self.m_Track
def GetFullRatsnest(self): return self.m_FullRatsnest
def GetZones(self): return self.m_ZoneDescriptorList
def Save(self,filename):
return SaveBoard(filename,self,IO_MGR.KICAD)

View File

@ -81,5 +81,15 @@
return self.Cast_to_ZONE_CONTAINER()
else:
return None
def Duplicate(self):
ct = self.GetClass()
if ct=="BOARD":
return None
else:
return Cast_to_BOARD_ITEM(self.Clone()).Cast()
}
}

View File

@ -55,12 +55,12 @@ print "track w cnt:",len(pcb.GetTrackWidthList())
print "via s cnt:",len(pcb.GetViasDimensionsList())
print ""
print "LIST ZONES:"
print "LIST ZONES:", pcb.GetAreaCount()
for idx in range(0, pcb.GetAreaCount()):
zone=pcb.GetArea(idx)
print "zone:", idx, "priority:", zone.GetPriority(), "netname", zone.GetNetname()
print ""
print "NetClasses:", pcb.GetNetClasses().GetCount()
print "NetClasses:", pcb.GetNetClasses().GetCount(),

View File

@ -1,9 +1,12 @@
#!/usr/bin/env python
from pcbnew import *
lst = FootprintEnumerate("/usr/share/kicad/modules/sockets.mod")
for name in lst:
m = FootprintLoad("/usr/share/kicad/modules/sockets.mod",name)
print name,"->",m.GetLibRef(), m.GetReference()
for p in m.Pads():
print "\t",p.GetPadName(),p.GetPosition(),p.GetPos0(), p.GetOffset()

View File

@ -88,8 +88,6 @@ def FootprintLibDelete(lpath):
def FootprintIsWritable(lpath):
plug = GetPluginForPath(lpath)
plug.FootprintLibIsWritable(lpath)
}
%{

View File

@ -155,7 +155,6 @@
%include <io_mgr.h>
%include <kicad_plugin.h>
%include "board.i"
%include "module.i"
%include "plugins.i"

View File

@ -4,7 +4,7 @@ pcb = pcbnew.GetBoard()
for m in pcb.GetModules():
print m.GetPosition()
for p in m.GetPads()
for p in m.Pads():
print "p=>",p.GetPosition(),p.GetPadName()
print p.GetPosition()

View File

@ -4,7 +4,5 @@ pcb = pcbnew.GetBoard()
for m in pcb.GetModules():
print m.GetReference(),"(",m.GetValue(),") at ", m.GetPosition()
for p in m.GetPads()
for p in m.Pads():
print " pad",p.GetPadName(), "at",p.GetPosition()

View File

@ -29,6 +29,7 @@
%include <std_vector.i>
%include <std_string.i>
%include <std_map.i>
/* ignore some constructors of EDA_ITEM that will make the build fail */