mirror of https://github.com/KLayout/klayout.git
Including sub-categories in RDB::apply, fixing handling of waived count in a category hierarchy in marker browser
This commit is contained in:
parent
86a2a6dd40
commit
7e32344287
|
|
@ -806,25 +806,43 @@ private:
|
||||||
|
|
||||||
size_t num_waived_per_cat (id_type cat_id) const
|
size_t num_waived_per_cat (id_type cat_id) const
|
||||||
{
|
{
|
||||||
auto ii = mp_database->items_by_category (cat_id);
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
|
auto ii = mp_database->items_by_category (cat_id);
|
||||||
for (auto i = ii.first; i != ii.second; ++i) {
|
for (auto i = ii.first; i != ii.second; ++i) {
|
||||||
if ((*i)->has_tag (m_waived_tag_id)) {
|
if ((*i)->has_tag (m_waived_tag_id)) {
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// include sub-categories
|
||||||
|
const rdb::Category *cat = mp_database->category_by_id (cat_id);
|
||||||
|
tl_assert (cat != 0);
|
||||||
|
for (auto c = cat->sub_categories ().begin (); c != cat->sub_categories ().end (); ++c) {
|
||||||
|
n += num_waived_per_cat (c->id ());
|
||||||
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t num_waived_per_cell_and_cat (id_type cell_id, id_type cat_id) const
|
size_t num_waived_per_cell_and_cat (id_type cell_id, id_type cat_id) const
|
||||||
{
|
{
|
||||||
auto ii = mp_database->items_by_cell_and_category (cell_id, cat_id);
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
|
auto ii = mp_database->items_by_cell_and_category (cell_id, cat_id);
|
||||||
for (auto i = ii.first; i != ii.second; ++i) {
|
for (auto i = ii.first; i != ii.second; ++i) {
|
||||||
if ((*i)->has_tag (m_waived_tag_id)) {
|
if ((*i)->has_tag (m_waived_tag_id)) {
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// include sub-categories
|
||||||
|
const rdb::Category *cat = mp_database->category_by_id (cat_id);
|
||||||
|
tl_assert (cat != 0);
|
||||||
|
for (auto c = cat->sub_categories ().begin (); c != cat->sub_categories ().end (); ++c) {
|
||||||
|
n += num_waived_per_cell_and_cat (cell_id, c->id ());
|
||||||
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1868,6 +1868,18 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void map_category (const rdb::Category &cat, const rdb::Database &db, std::map<id_type, id_type> &cat2cat)
|
||||||
|
{
|
||||||
|
const rdb::Category *this_cat = db.category_by_name (cat.path ());
|
||||||
|
if (this_cat) {
|
||||||
|
cat2cat.insert (std::make_pair (this_cat->id (), cat.id ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto c = cat.sub_categories ().begin (); c != cat.sub_categories ().end (); ++c) {
|
||||||
|
map_category (*c, db, cat2cat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Database::apply (const rdb::Database &other)
|
Database::apply (const rdb::Database &other)
|
||||||
{
|
{
|
||||||
|
|
@ -1886,10 +1898,7 @@ Database::apply (const rdb::Database &other)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto c = other.categories ().begin (); c != other.categories ().end (); ++c) {
|
for (auto c = other.categories ().begin (); c != other.categories ().end (); ++c) {
|
||||||
const rdb::Category *this_cat = category_by_name (c->path ());
|
map_category (*c, *this, cat2cat);
|
||||||
if (this_cat) {
|
|
||||||
cat2cat.insert (std::make_pair (this_cat->id (), c->id ()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, id_type> tags_by_name;
|
std::map<std::string, id_type> tags_by_name;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue