diff --git a/src/plugins/tools/view_25d/lay_plugin/built-in-macros/_d25_engine.rb b/src/plugins/tools/view_25d/lay_plugin/built-in-macros/_d25_engine.rb index e4a0e6376..534d72650 100644 --- a/src/plugins/tools/view_25d/lay_plugin/built-in-macros/_d25_engine.rb +++ b/src/plugins/tools/view_25d/lay_plugin/built-in-macros/_d25_engine.rb @@ -20,12 +20,47 @@ module D25 class D25Display - attr_accessor :fill, :frame, :like + attr_accessor :fill, :frame, :like, :name def initialize self.fill = nil self.frame = nil self.like = nil + self.name = nil + end + + def set_fill(arg) + if !arg.is_a?(0xffffff.class) + raise("'fill' must be a color value (an integer)") + end + self.fill = arg + end + + def set_frame(arg) + if !arg.is_a?(0xffffff.class) + raise("'frame' must be a color value (an integer)") + end + self.frame = arg + end + + def set_color(arg) + if !arg.is_a?(0xffffff.class) + raise("'color' must be a color value (an integer)") + end + self.fill = arg + self.frame = nil + end + + def set_like(arg) + li = nil + if arg.is_a?(String) + li = RBA::LayerInfo::from_string(arg) + elsif arg.is_a?(RBA::LayerInfo) + li = arg + else + raise("'like' must be a string or LayerInfo object") + end + self.like = li end end @@ -58,6 +93,7 @@ module D25 zstart = nil zstop = nil height = nil + display = D25Display::new args.each do |a| @@ -88,19 +124,31 @@ module D25 end height = a[:height] end + if a[:zstart] if zstart raise("Duplicate zstart specification") end zstart = a[:zstart] end + if a[:zstop] if zstop raise("Duplicate zstop specification") end zstop = a[:zstop] end - invalid_keys = a.keys.select { |k| ![ :height, :zstart, :zstop ].member?(k) } + + a[:color] && display.set_color(a[:color]) + a[:frame] && display.set_frame(a[:frame]) + a[:fill] && display.set_fill(a[:fill]) + a[:like] && display.set_like(a[:like]) + + if a[:name] + display.name = a[:name].to_s + end + + invalid_keys = a.keys.select { |k| ![ :height, :zstart, :zstop, :color, :frame, :fill, :like, :name ].member?(k) } if invalid_keys.size > 0 raise("Keyword argument(s) not understood: #{invalid_keys.collect(&:to_s).join(',')}") end @@ -128,7 +176,7 @@ module D25 raise("No layer specified") end - info = D25ZInfo::new(layer, zstart, zstop, @display || D25Display::new) + info = D25ZInfo::new(layer, zstart, zstop, @display || display) @zstack << info return info @@ -137,7 +185,7 @@ module D25 end - def display(*args, &block) + def zz(*args, &block) begin @@ -156,46 +204,16 @@ module D25 elsif a.is_a?(Hash) - hollow_fill = 0xffffffff + a[:color] && display.set_color(a[:color]) + a[:frame] && display.set_frame(a[:frame]) + a[:fill] && display.set_fill(a[:fill]) + a[:like] && display.set_like(a[:like]) - if a[:color] - if !a[:color].is_a?(0xffffff.class) - raise("'color' must be a color value (an integer)") - end - display.fill = a[:color] - display.frame = nil - end - if a[:frame] - if !a[:frame].is_a?(0xffffff.class) - raise("'frame' must be a color value (an integer)") - end - display.frame = a[:frame] - end - if a[:fill] - if !a[:fill].is_a?(0xffffff.class) - raise("'fill' must be a color value (an integer)") - end - display.fill = a[:fill] - end - if a[:hollow] - if a[:hollow] - display.fill = hollow_fill - end + if a[:name] + display.name = a[:name].to_s end - if a[:like] - li = nil - if a[:like].is_a?(String) - li = RBA::LayerInfo::from_string(a[:like]) - elsif a[:like].is_a?(RBA::LayerInfo) - li = a[:like] - else - raise("'like' must be a string or LayerInfo object") - end - display.like = li - end - - invalid_keys = a.keys.select { |k| ![ :fill, :frame, :color, :hollow, :like ].member?(k) } + invalid_keys = a.keys.select { |k| ![ :fill, :frame, :color, :hollow, :like, :name ].member?(k) } if invalid_keys.size > 0 raise("Keyword argument(s) not understood: #{invalid_keys.collect(&:to_s).join(',')}") end diff --git a/src/plugins/tools/view_25d/lay_plugin/templates/d25.lym b/src/plugins/tools/view_25d/lay_plugin/templates/d25.lym index b3049e1c7..7580c81c6 100644 --- a/src/plugins/tools/view_25d/lay_plugin/templates/d25.lym +++ b/src/plugins/tools/view_25d/lay_plugin/templates/d25.lym @@ -22,34 +22,38 @@ # z(layer, options ...): # # This function generates a extruded view from the given layer. -# The "options" describe the z extension. Valid forms are: +# +# Some options control the z extrusion: # # z(layer, 0.1 .. 0.2) extrude layer to z = 0.1 to 0.2 um # z(layer, zstart: 0.1, zstop: 0.2) same as above # z(layer, zstart: 0.1, height: 0.1) same as above, but with height instead of zstop # z(layer, height: 200.nm) extrude layer from last z position with a height of 200nm +# +# You can specify display options: +# +# z(..., color: 0xff0000) use bright red for the material color (RGB) +# z(..., frame: 0xff0000) use bright red for the frame color (combine with "fill" for the fill color) +# z(..., fill: 0x00ff00) use bright green for the fill color along (combine with "frame" for the frame color) +# z(..., like: "7/0") borrow style from layout view's style for layer "7/0" +# z(..., name: "M1") assigns a name to show for the material # -# If layer is an original layer, the display options (colors, hollow) are taken +# If no display options are given and layer is an original layer, the colors are taken # from the original layer's display style. Otherwise KLayout decides about the -# initial display options. Use "display(...)" to control the display options. +# colors itself using the application's palette. # -# display(options) { block } -# display(z(...), z(...), ..., options): +# zz(options) { block } +# zz(z(...), z(...), ..., options): # -# Specify the display options to use for the layers generated inside the block -# (which must contains at least one "z" call) or the given z calls: -# -# Options are: -# -# display(..., color: 0xff0000) use bright red for the material color (RGB) -# display(..., frame: 0xff0000) use bright red for the frame color (combine with "fill" for the fill color) -# display(..., fill: 0x00ff00) use bright green for the fill color along (combine with "frame" for the frame color) -# display(..., like: "7/0") borrow style from layout view's style for layer "7/0" +# Creates a display group. The display options are the same for all +# extrusion specs within the group. # +# The options of "zz" are "name", "color", "frame", "fill" and "like". z(input(1, 0), 0.1 .. 0.2) +z(input(2, 0), height: 250.nm, color: 0xffbc80) -display(like: 7/0) do +zz(like: 7/0, name: "Metal") do z(input(7, 0), height: 100.nm) z(input(8, 0), height: 150.nm) end