From 63eac42d07ebb4a25c9aaf1da55a5495e85f2c29 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 13 Feb 2014 18:27:48 +0100 Subject: [PATCH] Fix a minor error in class D_PAD: void D_PAD::Flip( int Y ) changed to virtual void D_PAD::Flip( const wxPoint& aCentre ) (as defined in BOARD_ITEM) Scripting: fix compatibility current pcbnew version in 2 examples and the default extension of board files in board.i (was .kicad_brd, now is .kicad_pcb) --- Documentation/compiling/COMPILING.txt | 8 ++++++ pcbnew/class_module.cpp | 2 +- pcbnew/class_pad.cpp | 6 ++--- pcbnew/class_pad.h | 2 +- pcbnew/scripting/board.i | 34 ++++++++++++------------ pcbnew/scripting/examples/createFPC40.py | 9 ++++--- pcbnew/scripting/examples/createPcb.py | 8 +++--- 7 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Documentation/compiling/COMPILING.txt b/Documentation/compiling/COMPILING.txt index fde596fa3a..8457885384 100644 --- a/Documentation/compiling/COMPILING.txt +++ b/Documentation/compiling/COMPILING.txt @@ -138,9 +138,17 @@ bzr branch lp:kicad/stable kicad_src Components and Footprints libraries all (schematic libs, 3D shapes ...) but new footprints libraries (use Download zip tool) https://github.com/KiCad/kicad-library/ + New footprints libraries (use Download zip tool for each lib you want) https://github.com/KiCad/ for footprint libs (*.pretty folders) +A mirror of github is available, using bzr: +(schematic libs, 3D shapes ... all but new footprints libraries) +bzr checkout lp:~kicad-product-committers/kicad/library + +Old legacy libraries: +bzr checkout lp:~dickelbeck/kicad/library-read-only + Note also Kicad is able to read on github.com/KiCad/ the *.pretty folders without download, using github plugin. (however the time to read them can be long) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 11f14217fe..95db2ce46f 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -799,7 +799,7 @@ void MODULE::Flip( const wxPoint& aCentre ) // Mirror pads to other side of board about the x axis, i.e. vertically. for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) - pad->Flip( m_Pos.y ); + pad->Flip( m_Pos ); // Mirror reference. text = m_Reference; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 5a48ac461a..7ebcc376b9 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -214,13 +214,13 @@ void D_PAD::SetOrientation( double aAngle ) } -void D_PAD::Flip( int aTranslationY ) +void D_PAD::Flip( const wxPoint& aCentre ) { - int y = GetPosition().y - aTranslationY; + int y = GetPosition().y - aCentre.y; y = -y; // invert about x axis. - y += aTranslationY; + y += aCentre.y; SetY( y ); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 0391d92b4b..a32bb06acf 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -167,7 +167,7 @@ public: void SetOffset( const wxPoint& aOffset ) { m_Offset = aOffset; } const wxPoint& GetOffset() const { return m_Offset; } - void Flip( int aTranslationY ); + void Flip( const wxPoint& aCentre ); // Virtual function /** * Function SetOrientation diff --git a/pcbnew/scripting/board.i b/pcbnew/scripting/board.i index e5b51cdef3..7c6f8e1985 100644 --- a/pcbnew/scripting/board.i +++ b/pcbnew/scripting/board.i @@ -29,7 +29,7 @@ %extend BOARD -{ +{ %pythoncode { def GetModules(self): return self.m_Modules @@ -42,35 +42,35 @@ def GetCurrentNetClassName(self): return self.m_CurrentNetClassName def GetViasDimensionsList(self): return self.m_ViasDimensionsList def GetTrackWidthList(self): return self.m_TrackWidthList - + def Save(self,filename,format = None): if format is None: str_filename = str(filename) if str_filename.endswith(".brd"): format = IO_MGR.LEGACY - if str_filename.endswith(".kicad_brd"): - format = IO_MGR.KICAD + if str_filename.endswith(".kicad_pcb"): + format = IO_MGR.KICAD return SaveBoard(filename,self,format) - + # # add function, clears the thisown to avoid python from deleting # the object in the garbage collector # - - def Add(self,item): + + def Add(self,item): item.thisown=0 self.AddNative(item) } - + } -// this is to help python with the * accessor of DLIST templates +// this is to help python with the * accessor of DLIST templates -%rename(Get) operator BOARD_ITEM*; -%rename(Get) operator TRACK*; -%rename(Get) operator D_PAD*; -%rename(Get) operator MODULE*; -%rename(Get) operator SEGZONE*; +%rename(Get) operator BOARD_ITEM*; +%rename(Get) operator TRACK*; +%rename(Get) operator D_PAD*; +%rename(Get) operator MODULE*; +%rename(Get) operator SEGZONE*; // we must translate C++ templates to scripting languages @@ -81,14 +81,14 @@ %template(TRACK_List) DLIST; %template(PAD_List) DLIST; -// std::vector templates +// std::vector templates %template(VIA_DIMENSION_Vector) std::vector; %template (RASTNET_Vector) std::vector; %extend DRAWSEGMENT { - %pythoncode + %pythoncode { def GetShapeStr(self): return self.ShowShape(self.GetShape()) @@ -102,7 +102,7 @@ def SetPos(self,p): self.SetPosition(p) self.SetPos0(p) - + def SetStartEnd(self,start,end): self.SetStart(start) self.SetStart0(start) diff --git a/pcbnew/scripting/examples/createFPC40.py b/pcbnew/scripting/examples/createFPC40.py index 95f4678e7c..7c6568e730 100755 --- a/pcbnew/scripting/examples/createFPC40.py +++ b/pcbnew/scripting/examples/createFPC40.py @@ -34,10 +34,10 @@ def smdRectPad(module,size,pos,name): for n in range (0,pads): pad = smdRectPad(module,size_025_160mm,wxPointMM(0.5*n,0),str(n+1)) module.Add(pad) - + pad_s0 = smdRectPad(module,size_150_200mm,wxPointMM(-1.6,1.3),"0") -pad_s1 = smdRectPad(module,size_150_200mm,wxPointMM((pads-1)*0.5+1.6,1.3),"0") +pad_s1 = smdRectPad(module,size_150_200mm,wxPointMM((pads-1)*0.5+1.6,1.3),"0") module.Add(pad_s0) module.Add(pad_s1) @@ -50,10 +50,11 @@ e.SetShape(S_SEGMENT) module.Add(e) # save the PCB to disk -module.SetLibRef("FPC"+str(pads)) +fpid = FPID("FPC"+str(pads)) #the name in library +module.SetFPID( fpid ) + try: FootprintLibCreate("fpc40.mod") except: pass # we try to create, but may be it exists already FootprintSave("fpc40.mod",module) - diff --git a/pcbnew/scripting/examples/createPcb.py b/pcbnew/scripting/examples/createPcb.py index b3c977d24e..21c38036c6 100755 --- a/pcbnew/scripting/examples/createPcb.py +++ b/pcbnew/scripting/examples/createPcb.py @@ -30,13 +30,13 @@ for y in range (0,10): pad.SetPadName(str(n)) module.Add(pad) n+=1 - + # save the PCB to disk -pcb.Save("/tmp/my2.kicad_brd") -pcb.Save("/tmp/my2.brd") +pcb.Save("my2.kicad_pcb") +pcb.Save("my2.brd") -pcb = LoadBoard("/tmp/my2.brd") +pcb = LoadBoard("my2.kicad_pcb") print map( lambda x: x.GetReference() , list(pcb.GetModules()))