Opened 7 years ago

Closed 7 years ago

#1264 closed defect (fixed)

Drawing.selected inaccurate

Reported by: Eric Pettersen Owned by: Tom Goddard
Priority: major Milestone:
Component: Core Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

If I open any model (e.g. 1a0m) and 'sel #1', the model instance's 'selected' attribute returns False. The instance's any_part_selected() call returns True though.

Change History (7)

comment:1 by Tom Goddard, 7 years ago

If the Drawing.selected flag is True then the entire drawing is selected (not including children). This attribute can be False and all subparts are selected. There is no current API which tells whether all subparts of a model are selected.

comment:2 by Eric Pettersen, 7 years ago

Well, it certainly seems weird that 'sel #1' doesn't cause that model's 'selected' attr to become True. Seems like something we should fix somehow! Yeah, I know that by the time the 'sel' command sees the argument, it doesn't really know that it encompasses the whole model.

--Eric

in reply to:  3 ; comment:3 by goddard@…, 7 years ago

If you need to distinguish whether a model is partially selected or fully selected then probably we should add a new Drawing method all_parts_selected() similar to the current any_part_selected().  The any_part_selected() method considers all children and descendants of the model — I’m not sure if that is what you need.

comment:4 by Eric Pettersen, 7 years ago

Well, that would work -- though it's still ugly that 'selected' returns False when the entire thing is in fact selected. As it stands right now, if I had the model panel 'select buttons' issue the command 'sel #!1' instead of directly setting 'selected' for model 1, then the model panel will _never_ show the model as fully selected, since 'selected' will continue to return False. Adding 'all_parts_selected' would work around that problem at the cost of a somewhat more expensive call.

in reply to:  5 ; comment:5 by goddard@…, 7 years ago

You misunderstand the Drawing selected attribute.  The selected state is somewhat confusing because some models can only be entirely selected or unselected, and other models have subparts that can be individually selected.  Drawing is part of the graphics module that has no knowledge of which subparts or whether subparts can be selected.  Drawing offers a single “selected” boolean to handle the case of simple models with no selectable subparts.  To handle the case of selectable subparts it has a “selected_triangles_mask” attribute and to handle instances (e.g. Atoms as sphere instances) it has a “selected_positions” attribute.  The semantics of the “selected” attribute is that if it is set to true it means the entire model is selected (all triangles and all instances).  If a model uses subpart selection then it leaves the “selected” attribute false, and specifies which triangles and instances to select using “selected_triangles_mask” and “selected_positions”.

in reply to:  6 ; comment:6 by goddard@…, 7 years ago

What I said is not quite right.  There is no Drawing.selected attribute.  Drawing.selected is a property computed from selected_triangles_mask and selected_positions.

So the real reason that Structure.selected  is False after command "sel #1” is because the Drawing.selected property only refers to the Structure Drawing, not any of the subdrawings which actually render the atoms, bonds, and ribbons.  It is those subdrawings that are selected.

comment:7 by Eric Pettersen, 7 years ago

Resolution: fixed
Status: assignedclosed

Implemented Model.all_parts_selected, which defaults to return Model.any_part_selected() for a generic model, and overridden in Structure and PseudobondGroup. Will open a ticket for a Drawing API for any_part_selected to become the more accurately named any_part_highlighted, at which time a generic Model.any_part_selected() [probably returning False] will be implemented.

Note: See TracTickets for help on using tickets.