mirror of https://github.com/KLayout/klayout.git
Experimental: do not list cells starting with underscore in library view
This commit is contained in:
parent
2221efd96e
commit
c15e24025e
|
|
@ -226,7 +226,7 @@ BEGIN_PROTECTED
|
||||||
layout = &cv->layout ();
|
layout = &cv->layout ();
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::LibraryCellSelectionForm form (this, layout, "browse_lib_cell", false, lib != 0 /*for libs show top cells only*/);
|
lay::LibraryCellSelectionForm form (this, layout, "browse_lib_cell", false, lib != 0 /*for libs show top cells only*/, lib != 0 /*for libs hide private cells*/);
|
||||||
if (lib) {
|
if (lib) {
|
||||||
form.setWindowTitle (tl::to_qstring (tl::to_string (QObject::tr ("Select Cell - Library: ")) + lib->get_description ()));
|
form.setWindowTitle (tl::to_qstring (tl::to_string (QObject::tr ("Select Cell - Library: ")) + lib->get_description ()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -550,7 +550,7 @@ CellSelectionForm::hide_cell ()
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells, bool top_cells_only)
|
LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells, bool top_cells_only, bool hide_private)
|
||||||
: QDialog (parent),
|
: QDialog (parent),
|
||||||
mp_lib (0), mp_layout (layout),
|
mp_lib (0), mp_layout (layout),
|
||||||
m_name_cb_enabled (true),
|
m_name_cb_enabled (true),
|
||||||
|
|
@ -559,7 +559,8 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout
|
||||||
m_pcell_id (-1),
|
m_pcell_id (-1),
|
||||||
m_is_pcell (false),
|
m_is_pcell (false),
|
||||||
m_all_cells (all_cells),
|
m_all_cells (all_cells),
|
||||||
m_top_cells_only (top_cells_only)
|
m_top_cells_only (top_cells_only),
|
||||||
|
m_hide_private (hide_private)
|
||||||
{
|
{
|
||||||
mp_ui = new Ui::LibraryCellSelectionForm ();
|
mp_ui = new Ui::LibraryCellSelectionForm ();
|
||||||
setObjectName (QString::fromUtf8 (name));
|
setObjectName (QString::fromUtf8 (name));
|
||||||
|
|
@ -586,7 +587,7 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout
|
||||||
update_cell_list ();
|
update_cell_list ();
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells, bool top_cells_only)
|
LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells, bool top_cells_only, bool hide_private)
|
||||||
: QDialog (parent),
|
: QDialog (parent),
|
||||||
mp_lib (0), mp_layout (0),
|
mp_lib (0), mp_layout (0),
|
||||||
m_name_cb_enabled (true),
|
m_name_cb_enabled (true),
|
||||||
|
|
@ -595,7 +596,8 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char
|
||||||
m_pcell_id (-1),
|
m_pcell_id (-1),
|
||||||
m_is_pcell (false),
|
m_is_pcell (false),
|
||||||
m_all_cells (all_cells),
|
m_all_cells (all_cells),
|
||||||
m_top_cells_only (top_cells_only)
|
m_top_cells_only (top_cells_only),
|
||||||
|
m_hide_private (hide_private)
|
||||||
{
|
{
|
||||||
mp_ui = new Ui::LibraryCellSelectionForm ();
|
mp_ui = new Ui::LibraryCellSelectionForm ();
|
||||||
|
|
||||||
|
|
@ -704,6 +706,9 @@ LibraryCellSelectionForm::update_cell_list ()
|
||||||
if (m_top_cells_only) {
|
if (m_top_cells_only) {
|
||||||
flags |= lay::CellTreeModel::TopCells;
|
flags |= lay::CellTreeModel::TopCells;
|
||||||
}
|
}
|
||||||
|
if (m_hide_private) {
|
||||||
|
flags |= lay::CellTreeModel::HidePrivate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get rid of that const_cast
|
// TODO: get rid of that const_cast
|
||||||
|
|
|
||||||
|
|
@ -122,18 +122,22 @@ public:
|
||||||
*
|
*
|
||||||
* This version does not provide library selection. \get_current_library will
|
* This version does not provide library selection. \get_current_library will
|
||||||
* always return 0.
|
* always return 0.
|
||||||
* If all_cells is true, all cells (not just top cells and basic cells) are shown.
|
*
|
||||||
* If top_cells_only is false, child cells are shown as well.
|
* If all_cells is true, all cells are shown. That includes proxies.
|
||||||
|
* If all_cells is false, proxies are not shown, but PCells are included.
|
||||||
|
* If all_cells is false, then also:
|
||||||
|
* Only top cells are shown if top_cells_only is true. PCells are always shown.
|
||||||
|
* Private cells (names start with underscore) or private PCells are not shown if hide_private is false
|
||||||
|
* top_cells_only and hide_private have no effect if all_cells is true.
|
||||||
*/
|
*/
|
||||||
LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells = false, bool top_cells_only = true);
|
LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells = false, bool top_cells_only = true, bool hide_private = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a selection form for cells plus the library
|
* @brief Create a selection form for cells plus the library
|
||||||
*
|
*
|
||||||
* If all_cells is true, all cells (not only top cells and basic cells) are shown.
|
* See above for the description of "all_cells", "top_cells_only" and "hide_private".
|
||||||
* If top_cells_only is false, child cells are shown as well.
|
|
||||||
*/
|
*/
|
||||||
LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells = false, bool top_cells_only = true);
|
LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells = false, bool top_cells_only = true, bool hide_private = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the selected library
|
* @brief Set the selected library
|
||||||
|
|
@ -200,6 +204,7 @@ private:
|
||||||
bool m_is_pcell;
|
bool m_is_pcell;
|
||||||
bool m_all_cells;
|
bool m_all_cells;
|
||||||
bool m_top_cells_only;
|
bool m_top_cells_only;
|
||||||
|
bool m_hide_private;
|
||||||
|
|
||||||
void select_entry (db::cell_index_type n);
|
void select_entry (db::cell_index_type n);
|
||||||
void select_pcell_entry (db::pcell_id_type n);
|
void select_pcell_entry (db::pcell_id_type n);
|
||||||
|
|
|
||||||
|
|
@ -569,10 +569,12 @@ CellTreeModel::build_top_level ()
|
||||||
if (mp_base) {
|
if (mp_base) {
|
||||||
m_toplevel.reserve (mp_base->child_cells ());
|
m_toplevel.reserve (mp_base->child_cells ());
|
||||||
for (db::Cell::child_cell_iterator child = mp_base->begin_child_cells (); ! child.at_end (); ++child) {
|
for (db::Cell::child_cell_iterator child = mp_base->begin_child_cells (); ! child.at_end (); ++child) {
|
||||||
|
if (name_selected (mp_layout->cell_name (*child))) {
|
||||||
CellTreeItem *item = new CellTreeItem (mp_layout, false, *child, true, m_sorting);
|
CellTreeItem *item = new CellTreeItem (mp_layout, false, *child, true, m_sorting);
|
||||||
m_toplevel.push_back (item);
|
m_toplevel.push_back (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if ((m_flags & Parents) != 0) {
|
} else if ((m_flags & Parents) != 0) {
|
||||||
|
|
||||||
|
|
@ -581,10 +583,12 @@ CellTreeModel::build_top_level ()
|
||||||
if (mp_base) {
|
if (mp_base) {
|
||||||
m_toplevel.reserve (mp_base->parent_cells ());
|
m_toplevel.reserve (mp_base->parent_cells ());
|
||||||
for (db::Cell::parent_cell_iterator parent = mp_base->begin_parent_cells (); parent != mp_base->end_parent_cells (); ++parent) {
|
for (db::Cell::parent_cell_iterator parent = mp_base->begin_parent_cells (); parent != mp_base->end_parent_cells (); ++parent) {
|
||||||
|
if (name_selected (mp_layout->cell_name (*parent))) {
|
||||||
CellTreeItem *item = new CellTreeItem (mp_layout, false, *parent, true, m_sorting);
|
CellTreeItem *item = new CellTreeItem (mp_layout, false, *parent, true, m_sorting);
|
||||||
m_toplevel.push_back (item);
|
m_toplevel.push_back (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
@ -595,7 +599,9 @@ CellTreeModel::build_top_level ()
|
||||||
db::Layout::top_down_const_iterator top = mp_layout->begin_top_down ();
|
db::Layout::top_down_const_iterator top = mp_layout->begin_top_down ();
|
||||||
while (top != mp_layout->end_top_down ()) {
|
while (top != mp_layout->end_top_down ()) {
|
||||||
|
|
||||||
if (m_flat) {
|
if (! name_selected (mp_layout->cell_name (*top))) {
|
||||||
|
// ignore cell
|
||||||
|
} else if (m_flat) {
|
||||||
if ((m_flags & BasicCells) == 0 || ! mp_layout->cell (*top).is_proxy ()) {
|
if ((m_flags & BasicCells) == 0 || ! mp_layout->cell (*top).is_proxy ()) {
|
||||||
CellTreeItem *item = new CellTreeItem (mp_layout, false, *top, true, m_sorting);
|
CellTreeItem *item = new CellTreeItem (mp_layout, false, *top, true, m_sorting);
|
||||||
m_toplevel.push_back (item);
|
m_toplevel.push_back (item);
|
||||||
|
|
@ -617,12 +623,16 @@ CellTreeModel::build_top_level ()
|
||||||
|
|
||||||
for (db::Layout::pcell_iterator pc = mp_layout->begin_pcells (); pc != mp_layout->end_pcells (); ++pc) {
|
for (db::Layout::pcell_iterator pc = mp_layout->begin_pcells (); pc != mp_layout->end_pcells (); ++pc) {
|
||||||
|
|
||||||
|
const auto *pcell_decl = mp_layout->pcell_declaration (pc->second);
|
||||||
|
if (name_selected (pcell_decl->name ())) {
|
||||||
|
|
||||||
CellTreeItem *item = new CellTreeItem (mp_layout, true, pc->second, true, m_sorting);
|
CellTreeItem *item = new CellTreeItem (mp_layout, true, pc->second, true, m_sorting);
|
||||||
m_toplevel.push_back (item);
|
m_toplevel.push_back (item);
|
||||||
|
|
||||||
if ((m_flags & WithVariants) != 0) {
|
if ((m_flags & WithVariants) != 0) {
|
||||||
|
|
||||||
const db::PCellHeader *pcell_header = mp_layout->pcell_header (pc->second);
|
const auto *pcell_header = mp_layout->pcell_header (pc->second);
|
||||||
|
|
||||||
for (db::PCellHeader::variant_iterator v = pcell_header->begin (); v != pcell_header->end (); ++v) {
|
for (db::PCellHeader::variant_iterator v = pcell_header->begin (); v != pcell_header->end (); ++v) {
|
||||||
if (mp_library && mp_library->is_retired (v->second->cell_index ())) {
|
if (mp_library && mp_library->is_retired (v->second->cell_index ())) {
|
||||||
// skip retired cells - this means we won't show variants which are just kept
|
// skip retired cells - this means we won't show variants which are just kept
|
||||||
|
|
@ -642,6 +652,8 @@ CellTreeModel::build_top_level ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::sort (m_toplevel.begin (), m_toplevel.end (), cmp_cell_tree_items_f (m_sorting));
|
std::sort (m_toplevel.begin (), m_toplevel.end (), cmp_cell_tree_items_f (m_sorting));
|
||||||
|
|
||||||
for (size_t i = 0; i < m_toplevel.size (); ++i) {
|
for (size_t i = 0; i < m_toplevel.size (); ++i) {
|
||||||
|
|
@ -649,6 +661,12 @@ CellTreeModel::build_top_level ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CellTreeModel::name_selected (const std::string &name) const
|
||||||
|
{
|
||||||
|
return ((m_flags & HidePrivate) == 0 || (! name.empty () && *name.begin () != '_'));
|
||||||
|
}
|
||||||
|
|
||||||
Qt::ItemFlags
|
Qt::ItemFlags
|
||||||
CellTreeModel::flags (const QModelIndex &index) const
|
CellTreeModel::flags (const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,8 @@ public:
|
||||||
BasicCells = 16, // show basic cells (PCells included, no proxies)
|
BasicCells = 16, // show basic cells (PCells included, no proxies)
|
||||||
WithVariants = 32, // show PCell variants below PCells
|
WithVariants = 32, // show PCell variants below PCells
|
||||||
WithIcons = 64, // show icons for the top level cell type
|
WithIcons = 64, // show icons for the top level cell type
|
||||||
NoPadding = 128 // disable padding of display string with a blank at the beginning and end
|
NoPadding = 128, // disable padding of display string with a blank at the beginning and end
|
||||||
|
HidePrivate = 256 // hide cells whose name starts with an underscore
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Sorting {
|
enum Sorting {
|
||||||
|
|
@ -273,6 +274,7 @@ private:
|
||||||
void clear_top_level ();
|
void clear_top_level ();
|
||||||
bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item);
|
bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item);
|
||||||
void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting);
|
void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting);
|
||||||
|
bool name_selected (const std::string &name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -634,7 +634,7 @@ LibrariesView::do_update_content (int lib_index)
|
||||||
|
|
||||||
LibraryTreeWidget *cell_list = new LibraryTreeWidget (cl_frame, "tree", mp_view->canvas ()->widget ());
|
LibraryTreeWidget *cell_list = new LibraryTreeWidget (cl_frame, "tree", mp_view->canvas ()->widget ());
|
||||||
cl_ly->addWidget (cell_list);
|
cl_ly->addWidget (cell_list);
|
||||||
cell_list->setModel (new CellTreeModel (cell_list, m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0));
|
cell_list->setModel (new CellTreeModel (cell_list, m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::HidePrivate | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0));
|
||||||
cell_list->setUniformRowHeights (true);
|
cell_list->setUniformRowHeights (true);
|
||||||
|
|
||||||
pl = cell_list->palette ();
|
pl = cell_list->palette ();
|
||||||
|
|
@ -707,7 +707,7 @@ LibrariesView::do_update_content (int lib_index)
|
||||||
|
|
||||||
CellTreeModel *model = dynamic_cast <CellTreeModel *> (mp_cell_lists [i]->model ());
|
CellTreeModel *model = dynamic_cast <CellTreeModel *> (mp_cell_lists [i]->model ());
|
||||||
if (model) {
|
if (model) {
|
||||||
model->configure (m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0);
|
model->configure (m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::HidePrivate | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue