When working with complex molecular models, even small visual elements like labels can make a world of difference. A well-placed label can help clarify a complex structure—but dozens of them can quickly become overwhelming. Molecular modelers working on intricate designs may often find themselves asking: “How do I quickly hide or show label nodes without manually clicking through object lists?”
This is where SAMSON’s Node Specification Language (NSL) comes in. With NSL, you can write simple expressions to control which nodes are shown, hidden, selected, or filtered—greatly speeding up even the most intricate labeling tasks.
Quick Intro to Label Attributes in NSL
NSL includes a set of attributes specifically for label nodes, which are accessible through the la (label attribute) short name. These attributes can be used to filter labels based on visibility, selection, name patterns, and more.
Controlling Visibility with la.v
If you have too many visible labels cluttering your workspace, you can use the la.v attribute to quickly get your view under control. Here’s how it works:
la.v: selects all label nodes that are currently visiblenot la.v: selects all label nodes that are currently hidden
This is especially useful if you’re working with large datasets, and you only want to focus on a subset of clearly labeled components. For instance, you might hide all labels initially with a selection expression, and then selectively enable labels for atoms of interest.
The Difference Between visible and visibilityFlag
It’s important to understand that SAMSON distinguishes between visible (short name v) and visibilityFlag (short name vf). While visible tells you whether a node is actually visible in the workspace, visibilityFlag tells you whether the node is intended to be visible—external factors might still hide it.
To illustrate this:
la.vf false: selects all label nodes that are set to be hiddenla.v: selects those that are effectively visible
This subtle difference can save you from confusion. For example, if you switch between different visualization modes or models, a label’s visibilityFlag might suggest it’s intended to display, while the actual visible status is false due to parent nodes being hidden.
Combine Filters for Power Use
The real power comes when you start combining these attributes. For example:
|
1 |
la.vf true and not la.v |
This expression finds label nodes that are intended to be visible but are currently not displaying. This might flag situations where labels are being accidentally occluded or impacted by parent node settings.
Similarly, you can use name patterns to find specific labels:
|
1 |
la.n "H*" and la.v |
This finds all visible label nodes with a name starting with “H”, useful when analyzing hydrogen atoms across a system.
Wrapping Up
Label visibility may seem like a small detail, but in the context of molecular design, it can directly impact clarity and productivity. Understanding how to leverage la.v and la.vf effectively through NSL allows for precise control and improved model management.
To learn more about label attributes in NSL, you can read the official documentation here: https://documentation.samson-connect.net/users/latest/nsl/label/
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
