From ed64d4a59bf10ae5b0f16394d3812aa1c15a969b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 27 Apr 2024 23:02:54 +0200 Subject: [PATCH] DRC enhancements: - Shapes are added to existing categories rather than creating a new category with the same name - The category name in "output" can be an array creating a hierarchy of categories. --- src/drc/drc/built-in-macros/_drc_engine.rb | 18 +++++++++++++++++- src/drc/drc/built-in-macros/_drc_layer.rb | 6 +++++- src/rdb/rdb/gsiDeclRdb.cc | 1 + src/rdb/rdb/rdb.cc | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/drc/drc/built-in-macros/_drc_engine.rb b/src/drc/drc/built-in-macros/_drc_engine.rb index 81e325ff3..0d198f1f8 100644 --- a/src/drc/drc/built-in-macros/_drc_engine.rb +++ b/src/drc/drc/built-in-macros/_drc_engine.rb @@ -3226,7 +3226,23 @@ CODE output_rdb = channel.rdb output_cell = channel.cell - cat = output_rdb.create_category(args[0].to_s) + categories = args[0] + if !categories.is_a?(Array) + categories = [ categories.to_s ] + end + + cat = nil + categories.each do |c| + ccat = nil + if cat + ccat = cat.each_sub_category.find { |i| i.name == c } + else + ccat = output_rdb.each_category.find { |i| i.name == c } + end + cat = ccat ? ccat : output_rdb.create_category(cat, c) + end + cat ||= output_rdb.create_category("default") + args[1] && cat.description = args[1] cat.scan_collection(output_cell, RBA::CplxTrans::new(self.dbu), data) diff --git a/src/drc/drc/built-in-macros/_drc_layer.rb b/src/drc/drc/built-in-macros/_drc_layer.rb index 870591330..2d514d687 100644 --- a/src/drc/drc/built-in-macros/_drc_layer.rb +++ b/src/drc/drc/built-in-macros/_drc_layer.rb @@ -5111,7 +5111,11 @@ CODE # This method will copy the content of the layer to the specified output. # # If a report database is selected for the output, the specification has to include a - # category name and optionally a category description. + # category name and optionally a category description. The category name can be an + # array of strings - in that case, a hierarchy of categories is created + # with the first array item being the top level category name. + # Shapes are added to an existing category, if a category with the given + # name already exists. # # If the layout is selected for the output, the specification can consist of # one to three parameters: a layer number, a data type (optional, default is 0) diff --git a/src/rdb/rdb/gsiDeclRdb.cc b/src/rdb/rdb/gsiDeclRdb.cc index 36e134da3..920334d43 100644 --- a/src/rdb/rdb/gsiDeclRdb.cc +++ b/src/rdb/rdb/gsiDeclRdb.cc @@ -1342,6 +1342,7 @@ Class decl_ReportDatabase ("rdb", "ReportDatabase", "@brief Creates a new sub-category\n" "@param parent The category under which the category should be created\n" "@param name The name of the category\n" + "Since version 0.29.1, 'parent' can be nil. In that case, a top-level category is created." ) + gsi::method ("category_by_path", &rdb::Database::category_by_name, gsi::arg ("path"), "@brief Gets a category by path\n" diff --git a/src/rdb/rdb/rdb.cc b/src/rdb/rdb/rdb.cc index a2e352144..df19f88dc 100644 --- a/src/rdb/rdb/rdb.cc +++ b/src/rdb/rdb/rdb.cc @@ -1275,6 +1275,10 @@ Database::import_cells (const Cells &cells) Category * Database::create_category (Category *parent, const std::string &name) { + if (! parent) { + return create_category (name); + } + set_modified (); Category *cat = create_category (&parent->sub_categories (), name);