mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-06 17:33:25 +02:00
Convenience methods Shape#properties, Layout#properties, Cell#properties, Instance#properties
This commit is contained in:
Vendored
+2
@@ -1334,6 +1334,7 @@ class DBLayoutTests1_TestClass < TestBase
|
||||
i0 = nil
|
||||
c0c.each_inst { |i| i.cell_index == l.cell("c1$1").cell_index && i0 = i }
|
||||
assert_equal(i0.property("p"), 18)
|
||||
assert_equal(i0.properties, {"p" => 18})
|
||||
assert_equal(l.cell("c1$1").begin_shapes_rec(0).shape.property("p"), 17)
|
||||
|
||||
assert_equal(collect(c0c.begin_shapes_rec(0), l), "[c0$1](0,100;1000,1200)/[c2$1](100,0;1100,1100)/[c3$1](1200,0;2200,1100)/[c3$1](-1200,0;-100,1000)/[c1$1](0,100;1000,1200)")
|
||||
@@ -1379,6 +1380,7 @@ class DBLayoutTests1_TestClass < TestBase
|
||||
|
||||
tt = RBA::Trans.new
|
||||
i0 = c0.insert(RBA::CellInstArray.new(c1.cell_index, tt))
|
||||
assert_equal(i0.properties, {})
|
||||
i0.set_property("p", 18)
|
||||
c0.insert(RBA::CellInstArray.new(c2.cell_index, RBA::Trans.new(RBA::Point.new(100, -100))))
|
||||
c0.insert(RBA::CellInstArray.new(c3.cell_index, RBA::Trans.new(1)))
|
||||
|
||||
Vendored
+4
@@ -674,6 +674,7 @@ class DBLayoutTests2_TestClass < TestBase
|
||||
lindex = ly.insert_layer( linfo )
|
||||
|
||||
c1 = ly.cell( ci1 )
|
||||
assert_equal( c1.properties, {} )
|
||||
c2 = ly.cell( ci2 )
|
||||
tr = RBA::Trans::new
|
||||
inst = c2.insert( RBA::CellInstArray::new( c1.cell_index, tr ) )
|
||||
@@ -701,6 +702,7 @@ class DBLayoutTests2_TestClass < TestBase
|
||||
c1.prop_id = pid
|
||||
assert_equal( c1.prop_id, pid )
|
||||
assert_equal( c1.property( 17 ).inspect, "\"a\"" )
|
||||
assert_equal( c1.properties, { 17 => "a", "b" => [1, 5, 7] } )
|
||||
c1.set_property( 5, 23 )
|
||||
c1.delete_property( 17 )
|
||||
assert_equal( c1.property( 17 ).inspect, "nil" )
|
||||
@@ -1027,6 +1029,7 @@ class DBLayoutTests2_TestClass < TestBase
|
||||
def test_11
|
||||
|
||||
ly = RBA::Layout::new
|
||||
assert_equal(ly.properties, {})
|
||||
|
||||
assert_equal(ly.prop_id, 0)
|
||||
ly.prop_id = 1
|
||||
@@ -1037,6 +1040,7 @@ class DBLayoutTests2_TestClass < TestBase
|
||||
ly.set_property("x", 1)
|
||||
assert_equal(ly.prop_id, 1)
|
||||
assert_equal(ly.property("x"), 1)
|
||||
assert_equal(ly.properties, {"x" => 1})
|
||||
ly.set_property("x", 17)
|
||||
assert_equal(ly.prop_id, 2)
|
||||
assert_equal(ly.property("x"), 17)
|
||||
|
||||
Vendored
+22
@@ -1656,6 +1656,28 @@ class DBShapes_TestClass < TestBase
|
||||
|
||||
end
|
||||
|
||||
# Shape objects and properties
|
||||
def test_13
|
||||
|
||||
ly = RBA::Layout::new
|
||||
l1 = ly.layer(1, 0)
|
||||
tc = ly.create_cell("TOP")
|
||||
sh = tc.shapes(l1).insert(RBA::Box::new(0, 0, 100, 200))
|
||||
|
||||
assert_equal(sh.property("k").inspect, "nil")
|
||||
assert_equal(sh.properties.inspect, "{}")
|
||||
|
||||
sh.set_property("k", 17)
|
||||
|
||||
assert_equal(sh.property("k").inspect, "17")
|
||||
assert_equal(sh.property("u").inspect, "nil")
|
||||
assert_equal(sh.properties.inspect, "{\"k\"=>17}")
|
||||
|
||||
sh.set_property("u", "42")
|
||||
assert_equal(sh.properties.inspect, "{\"k\"=>17, \"u\"=>\"42\"}")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
||||
Reference in New Issue
Block a user