Repository navigation
Conversation
set_layer_hidden_cells hides one layer (by layer properties node id) inside the given cells and their subtrees, while the cells stay visible on other layers. Keyed by cell index, so it works with the cell bitmap cache.
|
Hi @querielo, Thanks for the PR. I understand the feature is very specialized for you specific application and it is intentionally not fully functional. I personally like to have features which are useful for a broader audience. Anyway, from the perspective of architecture, I think the "per-layer hidden cells" should go into the LayerProperties object and should not be addressed by layer index. As a general rule, all attributes that control appearance of a layer are summarized in the LayerProperties object. I also think that fits well to the structure you have already proposed. More specifically, it would be part of the Are you planning to have huge number of hidden cells? Matthias |
The cells are given as -index entries in the layer source and accessed through LayerProperties#hidden_cells. The LayoutView API is removed.
|
Hi @klayoutmatthias , updated as suggested: the hidden cells are now part of The lists can be large. Update cost is 1 ms at 100k cells. Since it is now in the source it also ends up in .lyp files, if you would rather not persist it, I can keep it out of to_string. Could you take another look? |
|
Hi @querielo, Thanks for the fix, but I had a conversation with Maxim on a separate channel. The use case he describes is somewhat different, so I wonder if the hidden cells feature is the right now. Could you cross-check with him? There is a different proposal based on a cell tree selection scheme similar to the one the "RecursiveShapeIterator" or the DRC "select" feature provides. I think that is more suitable for your application as your goal is to highlight certain cells rather than hiding all others. Also, this scheme allows selectively highlighting shapes from the subtree of specific instances and I think that would be a more generic feature with a many applications. If that is the way to go, it will be redundant to the per-layer hidden cell feature and I'd not like to have both at the same time. Matthias |
|
Hi @querielo, I appreciate you modified the patch. Thank you for your efforts. I still feel however, there is a better solution. I have a proposal: Please take a look at this branch: https://github.com/KLayout/klayout/tree/cell_filters With this branch you can do the following for example: Layer source = The first part is the usual layer/datatype thing. In curly brackets you can now specify a sequence of on/off statements for cell selection. Think of switches that get triggered while you traverse a hierarchy from top to bottom and which enable of disable drawing. The traversal starts with "enabled=true". A So Correspondingly, That scheme was already there in a somewhat more complicated way, but not fully implemented. The implementation is pretty lean because I like about this solution that first it implements an idea I had long ago and second it allows turning on and off whole trees. It participates in the merge scheme of hierarchical property trees. This means you can create a group of layers, and assign a cell selection to the group node. All layers below will be subject to the cell selection. Also, the expression is persisted in the layer properties files. Let me know honestly what you think. I'm not trying to deprecate your idea, I just think that if you can use that alternative approach, there would be a general benefit for others as well. In the end we could also keep both, but I feel the features are redundant and there will be merge conflicts I assume. Best regards, Matthias |
|
Any feedback on my last comment? |
|
I have merged the cell_filter branch ... let me know if that is good enough for you or whether you still need this solution here. Thanks, Matthias |
This PR adds a per-layer variant of
hide_celltoLayoutView.set_layer_hidden_cells(layer_id, cell_indexes)stops drawing one layer (by layer properties node id) inside the given cells and their subtrees, while those cells stay fully visible on every other layer.layer_hidden_cells(layer_id)reads the list back, and an empty list clears it.Why: We need to control which cells are visible on each layer independently. A per-layer cell visibility restriction provides a lightweight way to show or hide specific cells on selected layers while keeping their visibility unchanged on other layers.
How it works: the view keeps a map from node id to a shared, immutable list of cell indexes and attaches it to the layer's
RedrawLayerInfoinredraw(), so the layer vector, the image cache and the redraw thread only copy a pointer. The worker expands the list into a bit vector once per task and tests it right next to the existing hidden-cell check, which is now a small helper shared by all six call sites. Since it is keyed by cell index it does not depend on the instance path, so the cell bitmap cache stays valid. Changes go throughredraw_later, so bursts of calls coalesce into one redraw. The restriction is dropped on reload, is not saved in sessions and is not undoable; it is meant to be driven from scripts. Without a restriction the hot path only gains a bounds check.test_22intestdata/ruby/layLayoutView.rbrenders two instances and checks that only the hidden one disappears.