Opened 6 years ago

Closed 6 years ago

#2282 closed enhancement (fixed)

Make 2D labels models

Reported by: pett Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Graphics Version:
Keywords: Cc: Elaine Meng
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

It would be very nice if overlays could be in the model hierarchy so that they could be shown and controlled via the Model Panel. 2D labels, arrows, etc.

Change History (5)

comment:1 by Tom Goddard, 6 years ago

Cc: Elaine Meng added

It would be nice to have 2D labels each be a model. They could all be children of one top-level model called "2D labels". This would allow hiding individual labels using Model Panel, changing their color, and closing individual or all 2d labels with Model panel.

Also commands could then operate on 2d labels, like "close #3.2" to remove a specific label, or "color #3.2 black" or "hide #3.2".

The current 2dlabel command syntax makes you specify a name for each label

2dlabel create label1 text "Hydrophobic patch"

The name allows changing and deleting with "2dlabel change label1 ..." and "2dlabel delete label1". If 2d labels are models we don't need the names to identify them and can just use model numbers. This would use a new 2dlabel command syntax, maybe

2dlabel "Hydrophopic patch" xpos .1 ypos .7

creates a label with that text. Then "2dlabel #3.1 size 50" would change an existing label. The normal "close #3.1" could be used to delete the label.

comment:2 by Tom Goddard, 6 years ago

A potential problem with having overlays be models is that they do not have 3d scene positions, instead they have screen positions. Currently all models have scene positions. Commands that make use of position might need special code to ignore overlay models. For example "view" uses the bounds of all models. Probably that would just work because a 2dlabel would return its bounds as None. The scene position of a 2D model would be ignored when drawing the label. Commands that change the position of models like "move x .5 model #3.1" would have no effect on a label. That might be unexpected. The "turn" command would not make sense on a label. The tile command would probably ignore labels since they have no scene bounds. Picking of 2d labels is currently not allowed, and in general overlays would probably disable picking. But possibly it would be useful to be able to select them.

It seems that overlay models not having scene positions should not cause too many problems.

comment:3 by Tom Goddard, 6 years ago

Some code that would need changing to make 2dlabels become models includes session saving and the move labels mouse mode. The graphics code would need to filter out the overlay models from the hierarchy so they can be drawn after (and on top of) the scene.

In addition to 2dlabels, in the future we would have arrows and colorkeys that would be models, children of the same "2d label" group model.

Currently 3d labels (e.g. residue numbers) are models. But each individual label is not a model because that would cause slow rendering for cases with 50 or more residue labels. Instead all 3d labels for a structure are currently a single submodel of the structure.

comment:4 by Tom Goddard, 6 years ago

II think making 2d labels be models will be simpler for users, allowing them to use model panel, and does not appear to introduce complications, so we should try it.

comment:5 by Tom Goddard, 6 years ago

Resolution: fixed
Status: assignedclosed
Summary: overlay modelsMake 2D labels models

Done.

Made 2d labels each be a model under a "2D labels" grouping model.

I added a new 2dlabels command that takes a model id of one or more labels to change that label, or with no model id it creates a label.

2dlabels text "Here is a new label" xpos .1 size 20
2dlabels #2.1 text "New text for the label" color pink

Labels created this way do not have a name. The older "2dlabels create <label-name>" and "2dlabels change <label-name>" commands still exist. We may want to remove those since model id numbers can now be used to identify labels. Or we may want to keep them for backwards compatibility with Chimera. Deleting a label can use "close #2.1" but can also use "2dlabels delete #2.1".

These models don't belong to the scene model tree since 2d models that are overlays are specific to the View, for instance 2D labels are shown in the main graphics window but not the side view. These models are added using View.add_overlays() as in the past. The are also add in the Models class -- the 2D labels top level model is added with Models.add([m], root_model = True) to indicate that it should not be added to the root of the scene model tree.

Note: See TracTickets for help on using tickets.