Remove python-based board_item duplicate method
This method shadows the C++ method, and doesn't properly handle updating the duplicated object's KIID to be unique. Also add tests to ensure the KIIDs are unique after duplication. Fixes https://gitlab.com/kicad/code/kicad/issues/14460
This commit is contained in:
parent
a77e94d16f
commit
5d0b5e16ff
|
@ -166,13 +166,6 @@ static PCB_BITMAP* Cast_to_PCB_BITMAP( BOARD_ITEM* );
|
|||
else:
|
||||
raise TypeError("Unsupported drawing class: %s" % ct)
|
||||
|
||||
def Duplicate(self):
|
||||
ct = self.GetClass()
|
||||
if ct=="BOARD":
|
||||
return None
|
||||
else:
|
||||
return Cast_to_BOARD_ITEM(self.Clone()).Cast()
|
||||
|
||||
def SetPos(self,p):
|
||||
self.SetPosition(p)
|
||||
self.SetPos0(p)
|
||||
|
|
|
@ -15,6 +15,10 @@ class TestTracks(unittest.TestCase):
|
|||
self.assertEqual(250000, track.GetWidth())
|
||||
self.assertEqual('McNetty', track.GetNetname())
|
||||
|
||||
dup_track = track.Duplicate()
|
||||
self.assertTrue( dup_track.m_Uuid != track.m_Uuid )
|
||||
|
||||
|
||||
def test_arcs(self):
|
||||
arcs = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_ARC']
|
||||
self.assertEqual(13, len(arcs))
|
||||
|
@ -24,9 +28,15 @@ class TestTracks(unittest.TestCase):
|
|||
round(arc.GetArcAngleEnd().AsTenthsOfADegree())])
|
||||
self.assertEqual(2414200, round(arc.GetRadius()))
|
||||
|
||||
dup_arc = arc.Duplicate()
|
||||
self.assertTrue( dup_arc.m_Uuid != arc.m_Uuid )
|
||||
|
||||
def test_vias(self):
|
||||
vias = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_VIA']
|
||||
self.assertEqual(2, len(vias))
|
||||
via = sorted(vias, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
|
||||
self.assertEqual([29000000, 41000000], [via.GetStart()[0], via.GetStart()[1]])
|
||||
self.assertEqual(400000, via.GetDrillValue())
|
||||
|
||||
dup_via = via.Duplicate()
|
||||
self.assertTrue( dup_via.m_Uuid != via.m_Uuid )
|
||||
|
|
Loading…
Reference in New Issue