List markers in current view false false true ruby # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # DESCRIPTION: # Choose a marker database and a category. The markers in the current # view are listed in a browser window. # # Disclaimer: is not linked to marker database browser - does not # use the settings of the marker database browser and does not use # the selected database or category. Projects the markers into the # current cell irregardless of settings in the marker database browser. # mw = RBA::Application::instance.main_window view = mw.current_view rdb = nil if view.num_rdbs == 0 raise("No report database loaded") elsif view.num_rdbs == 1 rdb = view.rdb(0) else rdbs = (0..(view.num_rdbs - 1)).collect { |i| view.rdb(i).name + " (" + view.rdb(i).description + ")" } rdb_sel = RBA::InputDialog::ask_item("Select A Report Database", "Choose the database", rdbs, 0) if rdb_sel rdb = view.rdb(rdbs.index(rdb_sel)) end end if rdb categories = [] cat = nil rdb.each_category { |c| categories << c } if categories.size == 0 raise("Report database does not have categories") elsif categories.size == 1 cat = categories[0] else cat_names = [ "All" ] categories.each { |c| cat_names << c.name } cat_sel = RBA::InputDialog::ask_item("Select A Category", "Choose a database category", cat_names, 0) if cat_sel && cat_sel != cat_names[0] cat = categories[cat_names.index(cat_sel) - 1] end end if cat categories = [cat] end item_texts = [] stop = false nmax = 100 categories.each do |cat| stop && break cat.each_item do |item| stop && break bbox = RBA::DBox::new item.each_value do |v| if v.is_path? bbox += v.path.bbox elsif v.is_polygon? bbox += v.polygon.bbox elsif v.is_box? bbox += v.box elsif v.is_edge? bbox += v.edge.bbox elsif v.is_edge_pair? bbox += v.edge_pair.bbox end end cell = rdb.cell_by_id(item.cell_id) trans = [] cell.each_reference { |r| trans << r.trans } if trans.empty? trans << RBA::DCplxTrans::new end trans.each do |t| if bbox.transformed(t).overlaps?(view.box) if item_texts.size > nmax item_texts << "More than #{nmax} entries - list is shortened" stop = true else text = "<li>Category #{cat.name} - Cell #{cell.name}:<br><tt>" item.each_value do |v| text += v.to_s + "<br>" end text += "</li>" item_texts << text end end end end end html = "<html><h1>Markers in view</h1><ul>" + item_texts.join("\n") + "</ul></html>" RBA::BrowserDialog::new(html).exec end