Commit e6274f70 authored by jean-pierre charras's avatar jean-pierre charras

BOARD::Add(): fix an issue for tracks: parent not set (could be an issue only...

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.
parent 7c747c1a
...@@ -663,6 +663,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -663,6 +663,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
TRACK* insertAid; TRACK* insertAid;
insertAid = ( (TRACK*) aBoardItem )->GetBestInsertPoint( this ); insertAid = ( (TRACK*) aBoardItem )->GetBestInsertPoint( this );
m_Track.Insert( (TRACK*) aBoardItem, insertAid ); m_Track.Insert( (TRACK*) aBoardItem, insertAid );
aBoardItem->SetParent( this );
break; break;
case PCB_ZONE_T: case PCB_ZONE_T:
......
...@@ -804,7 +804,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src ) ...@@ -804,7 +804,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
SetTimeStamp( src->m_TimeStamp ); SetTimeStamp( src->m_TimeStamp );
m_Poly->RemoveAllContours(); m_Poly->RemoveAllContours();
m_Poly->Copy( src->m_Poly ); // copy outlines 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_ZoneClearance = src->m_ZoneClearance; // clearance value
m_ZoneMinThickness = src->m_ZoneMinThickness; m_ZoneMinThickness = src->m_ZoneMinThickness;
m_FillMode = src->m_FillMode; // Filling mode (segments/polygons) m_FillMode = src->m_FillMode; // Filling mode (segments/polygons)
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
def GetDrawings(self): return self.m_Drawings def GetDrawings(self): return self.m_Drawings
def GetTracks(self): return self.m_Track def GetTracks(self): return self.m_Track
def GetFullRatsnest(self): return self.m_FullRatsnest def GetFullRatsnest(self): return self.m_FullRatsnest
def GetZones(self): return self.m_ZoneDescriptorList
def Save(self,filename): def Save(self,filename):
return SaveBoard(filename,self,IO_MGR.KICAD) return SaveBoard(filename,self,IO_MGR.KICAD)
......
...@@ -81,5 +81,15 @@ ...@@ -81,5 +81,15 @@
return self.Cast_to_ZONE_CONTAINER() return self.Cast_to_ZONE_CONTAINER()
else: else:
return None return None
def Duplicate(self):
ct = self.GetClass()
if ct=="BOARD":
return None
else:
return Cast_to_BOARD_ITEM(self.Clone()).Cast()
} }
} }
...@@ -55,12 +55,12 @@ print "track w cnt:",len(pcb.GetTrackWidthList()) ...@@ -55,12 +55,12 @@ print "track w cnt:",len(pcb.GetTrackWidthList())
print "via s cnt:",len(pcb.GetViasDimensionsList()) print "via s cnt:",len(pcb.GetViasDimensionsList())
print "" print ""
print "LIST ZONES:" print "LIST ZONES:", pcb.GetAreaCount()
for idx in range(0, pcb.GetAreaCount()): for idx in range(0, pcb.GetAreaCount()):
zone=pcb.GetArea(idx) zone=pcb.GetArea(idx)
print "zone:", idx, "priority:", zone.GetPriority(), "netname", zone.GetNetname() print "zone:", idx, "priority:", zone.GetPriority(), "netname", zone.GetNetname()
print "" print ""
print "NetClasses:", pcb.GetNetClasses().GetCount() print "NetClasses:", pcb.GetNetClasses().GetCount(),
#!/usr/bin/env python #!/usr/bin/env python
from pcbnew import * from pcbnew import *
lst = FootprintEnumerate("/usr/share/kicad/modules/sockets.mod") lst = FootprintEnumerate("/usr/share/kicad/modules/sockets.mod")
for name in lst: for name in lst:
m = FootprintLoad("/usr/share/kicad/modules/sockets.mod",name) m = FootprintLoad("/usr/share/kicad/modules/sockets.mod",name)
print name,"->",m.GetLibRef(), m.GetReference() print name,"->",m.GetLibRef(), m.GetReference()
for p in m.Pads(): for p in m.Pads():
print "\t",p.GetPadName(),p.GetPosition(),p.GetPos0(), p.GetOffset() print "\t",p.GetPadName(),p.GetPosition(),p.GetPos0(), p.GetOffset()
...@@ -58,38 +58,36 @@ ...@@ -58,38 +58,36 @@
%pythoncode %pythoncode
{ {
def GetPluginForPath(lpath): def GetPluginForPath(lpath):
return IO_MGR.PluginFind(IO_MGR.LEGACY) return IO_MGR.PluginFind(IO_MGR.LEGACY)
def FootprintEnumerate(lpath): def FootprintEnumerate(lpath):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
return plug.FootprintEnumerate(lpath) return plug.FootprintEnumerate(lpath)
def FootprintLoad(lpath,name): def FootprintLoad(lpath,name):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
return plug.FootprintLoad(lpath,name) return plug.FootprintLoad(lpath,name)
def FootprintSave(lpath,module): def FootprintSave(lpath,module):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
return plug.FootprintSave(lpath,module) return plug.FootprintSave(lpath,module)
def FootprintDelete(lpath,name): def FootprintDelete(lpath,name):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
plug.FootprintDelete(lpath,name) plug.FootprintDelete(lpath,name)
def FootprintLibCreate(lpath): def FootprintLibCreate(lpath):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
plug.FootprintLibCreate(lpath) plug.FootprintLibCreate(lpath)
def FootprintLibDelete(lpath): def FootprintLibDelete(lpath):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
plug.FootprintLibDelete(lpath) plug.FootprintLibDelete(lpath)
def FootprintIsWritable(lpath): def FootprintIsWritable(lpath):
plug = GetPluginForPath(lpath) plug = GetPluginForPath(lpath)
plug.FootprintLibIsWritable(lpath) plug.FootprintLibIsWritable(lpath)
} }
%{ %{
......
...@@ -155,7 +155,6 @@ ...@@ -155,7 +155,6 @@
%include <io_mgr.h> %include <io_mgr.h>
%include <kicad_plugin.h> %include <kicad_plugin.h>
%include "board.i" %include "board.i"
%include "module.i" %include "module.i"
%include "plugins.i" %include "plugins.i"
......
...@@ -4,7 +4,7 @@ pcb = pcbnew.GetBoard() ...@@ -4,7 +4,7 @@ pcb = pcbnew.GetBoard()
for m in pcb.GetModules(): for m in pcb.GetModules():
print m.GetPosition() print m.GetPosition()
for p in m.GetPads() for p in m.Pads():
print "p=>",p.GetPosition(),p.GetPadName() print "p=>",p.GetPosition(),p.GetPadName()
print p.GetPosition() print p.GetPosition()
......
...@@ -4,7 +4,5 @@ pcb = pcbnew.GetBoard() ...@@ -4,7 +4,5 @@ pcb = pcbnew.GetBoard()
for m in pcb.GetModules(): for m in pcb.GetModules():
print m.GetReference(),"(",m.GetValue(),") at ", m.GetPosition() 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() print " pad",p.GetPadName(), "at",p.GetPosition()
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
%include <std_vector.i> %include <std_vector.i>
%include <std_string.i> %include <std_string.i>
%include <std_map.i>
/* ignore some constructors of EDA_ITEM that will make the build fail */ /* ignore some constructors of EDA_ITEM that will make the build fail */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment