Alert message popup

Hello,

I am super new to KLayout and started becasue of work.
I`ve gotten a lot of nice tips from this forum. So appriciate it :smile:

I have a question how to popup alert message when it is not available input.

' ' '
class SquarePCell < PCellDeclarationHelper

include RBA

def initialize

  # Important: initialize the super class
  super

  # declare the parameters
  param(:l1, TypeLayer, "Layer1", :default => LayerInfo::new(1, 0))
  param(:l2, TypeLayer, "Layer2", :default => LayerInfo::new(1, 0))
  param(:l3, TypeLayer, "Layer3", :default => LayerInfo::new(1, 0))
  param(:l4, TypeLayer, "Layer4", :default => LayerInfo::new(1, 0))
  param(:w, TypeDouble, "Width of PCell", :default => 400, :unit => "µm")   
  param(:g, TypeDouble, "Gap between upper & lower PCell", :default => 800, :unit => "µm")
  param(:g_oi, TypeDouble, "Gap between outer & inner square", :default => 100, :unit => "µm")
  param(:h_1st, TypeDouble, "Hight of 1st square", :default => 800, :unit => "µm")
  param(:h_2nd, TypeDouble, "Hight of 2nd square", :default => 800, :unit => "µm")
  param(:p_2nd, TypeDouble, "Position of 2nd square", :default => 50, :unit => "%")
  param(:hight, TypeInt, "Total hight", :default => 20000)
  param(:width, TypeInt, "Total width", :default => 100000)
end

def display_text_impl
  # Provide a descriptive text for the cell
  "SquarePCell"
end

def produce_impl

  # This is the main part of the implementation: create the layout

  # compute the ray parts and produce the polygons      
  app = RBA::Application.instance
  mw = app.main_window
  lv = mw.current_view
  #new_layout = mw.create_layout(2)

  raise "No view selected" if lv.nil?      
  dbu = lv.active_cellview.layout.dbu



  w_3rd = w - 2*g_oi
  h_3rd = h_1st*p_2nd/100.0 - 2*g_oi

  #Code: origin at bottom left chip corner
  #Choose manual coordinate origin 
  x0 = 0 
  y0 = 0     
  g_1st_c = 0
  g_1st_f = 0
  g_2nd_c = 0      
  g_2nd_f = 0              
  g_3rd_c = 0
  g_3rd_f = 0
  h_whole = 0

  col = width.div(w) # .div returns integer value by floor 
  row = 0 # it will initiate in the for loop 
  i = 0 # for do loop because total hight is calculated after the first run ( get hight of one PCell)
  loop do # x axis
    col.times do |j| # y axis
        # lb_u => Left Below point  of upper PCell  //  ru_u => Right Upper point of upper PCell
        # lu_l => Left Upper point of Lower PCell   //  rb_l => Right Below point of Lower PCell

        # Upper PCell
        x_1st_lb_u = x0 + j * w
        y_1st_lb_u = y0 + g/2 + i*h_whole
        x_1st_ru_u = x_1st_lb_u + w
        y_1st_ru_u = y_1st_lb_u + h_1st 

        x_2nd_lb_u = x_1st_lb_u
        y_2nd_lb_u = y_1st_lb_u + h_1st*p_2nd/100.0
        x_2nd_ru_u = x_2nd_lb_u + w
        y_2nd_ru_u = y_2nd_lb_u + h_2nd

        x_3rd_lb_u = x_1st_lb_u + g_oi
        y_3rd_lb_u = y_1st_lb_u + g_oi
        x_3rd_ru_u = x_3rd_lb_u + w_3rd
        y_3rd_ru_u = y_3rd_lb_u + h_3rd

        raise "2nd position should be larger then now!\n" if y_3rd_ru_u - y_3rd_lb_u < 0

        # Calculating gap with respect to 1st/2nd/3rd boxes.
        # _c is closer bound gap  //  _f is further bound gap
        if i == 0 and j == 0
          g_1st_c = 2 * y_1st_lb_u
          g_1st_f = 2 * y_1st_ru_u

          g_2nd_c = 2 * y_2nd_lb_u
          g_2nd_f = 2 * y_2nd_ru_u

          g_3rd_c = 2 * y_3rd_lb_u
          g_3rd_f = 2 * y_3rd_ru_u

          h_whole = 2 * y_2nd_ru_u
          row = hight.div(h_whole)
        end

        # Lower PCell
        x_1st_lu_l = x_1st_lb_u
        y_1st_lu_l = y_1st_lb_u - g_1st_c
        x_1st_rb_l = x_1st_ru_u
        y_1st_rb_l = y_1st_ru_u - g_1st_f

        x_2nd_lu_l = x_2nd_lb_u
        y_2nd_lu_l = y_2nd_lb_u - g_2nd_c
        x_2nd_rb_l = x_2nd_ru_u
        y_2nd_rb_l = y_2nd_ru_u - g_2nd_f

        x_3rd_lu_l = x_3rd_lb_u
        y_3rd_lu_l = y_3rd_lb_u - g_3rd_c
        x_3rd_rb_l = x_3rd_ru_u
        y_3rd_rb_l = y_3rd_ru_u - g_3rd_f

        # Wrapping PCell
        x_4th_lb = x_1st_lb_u
        x_4th_ru = x_1st_lb_u + w
        y_4th_lb = y_2nd_rb_l
        y_4th_ru = y_2nd_ru_u


        cell.shapes(l1_layer).insert(RBA::Box::new(x_1st_lb_u/dbu, y_1st_lb_u/dbu, x_1st_rb_l/dbu, y_1st_ru_u/dbu))
        cell.shapes(l2_layer).insert(RBA::Box::new(x_2nd_lb_u/dbu, y_2nd_lb_u/dbu, x_2nd_rb_l/dbu, y_2nd_ru_u/dbu))
        cell.shapes(l3_layer).insert(RBA::Box::new(x_3rd_lb_u/dbu, y_3rd_lb_u/dbu, x_3rd_rb_l/dbu, y_3rd_ru_u/dbu))

        cell.shapes(l1_layer).insert(RBA::Box::new(x_1st_lu_l/dbu, y_1st_lu_l/dbu, x_1st_rb_l/dbu, y_1st_rb_l/dbu))
        cell.shapes(l2_layer).insert(RBA::Box::new(x_2nd_lu_l/dbu, y_2nd_lu_l/dbu, x_2nd_rb_l/dbu, y_2nd_rb_l/dbu))
        cell.shapes(l3_layer).insert(RBA::Box::new(x_3rd_lu_l/dbu, y_3rd_lu_l/dbu, x_3rd_rb_l/dbu, y_3rd_rb_l/dbu))

        cell.shapes(l4_layer).insert(RBA::Box::new(x_4th_lb/dbu, y_4th_lb/dbu, x_4th_ru/dbu, y_4th_ru/dbu))       
    end

    i += 1        
    break if i == row

  end
end

end
' ' '

In this code, if you see raise part, I want to pop up a message window to user to inform it is not available.
How can I change the code?

Comments

  • Hi,

    please use backticks in the lines before and after the code to make it formatted as such.

    Regarding the question: you cannot pop up anything in the "produce_impl" method. This method is called by the system to generate the layout's geometry. It's called on unspecified occasions and you cannot implement any user interface features there.

    Specifically you should not access RBA::Application or RBA::LayoutView in this method. The only supported case is to raise an exception in case of an error. The exception will be indicated by an error label replacing the layout of the PCell.

    You can however reimplement the "coerce_parameters_impl". This method is intended to modify the parameters so they conform to your rules. But in the more generic sense it is a callback which is involved whenever a parameter changes.

    If you raise an exception in this implementation, you will receive a suitable error message in the parameter dialog:

        def coerce_parameters_impl
          r < 0 && raise("Radius must be positive")
        end
    

    This is the only supported way to check parameters.

    Matthias

  • Thank you very much Matthias, I will try that.

    And I dont get "please use backticks in the lines before and after the code to make it formatted as such." what is backticks and whats the meaning of this line?

  • That's the "Markdown" way to format code.

    Please see here here for details: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet ("Code and Syntax Highlighting").

    Matthias

Sign In or Register to comment.