Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#1551 closed defect (fixed)

Model.get_selected() doesn't consider child Drawings

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

Description

The symptoms mainly show up in the Model Panel "Selected" column. If a Model object is an empty drawing and has no child Model instances (e.g. when it's acting as a container for some Drawing instances, then get_selected(include_children=True, fully=True) will always return True. ISOLDE and Clipper between them create quite a number of classes that fit the above description. The below modification to Model.set_selected() seems to behave correctly:

    def get_selected(self, include_children=False, fully=False):
        '''Is this model selected?  If fully is true then are all parts of this model selected?'''
        if fully:
            if not self.highlighted and not self.empty_drawing():
                return False
            if include_children:
                for d in self.child_drawings():
                    if isinstance(d, Model):
                        if not d.get_selected(include_children=True, fully=True):
                            return False
                    else:
                        if not d.highlighted and not d.empty_drawing():
                            return False

            return True

        if self.highlighted:
            return True

        if include_children:
            for d in self.child_drawings():
                if isinstance(d, Model):
                    if d.get_selected(include_children=True):
                        return True
                    else:
                        if d.highlighted:
                            return True

        return False

Change History (3)

comment:1 by pett, 7 years ago

Owner: changed from pett to Tom Goddard

Tom wrote get_selected()...

comment:2 by Tom Goddard, 7 years ago

Resolution: fixed
Status: assignedclosed

Ok. This behavior was intentional. If a Model has Drawing children it is assumed that the Model fully manages those Drawings including overriding Model.get_selected() to say whether the Drawings are selected. The reason for that is that the concept of "selected" is a Model level concept and not the same as "highlighted" which is a Drawing level concept. For instance an Atom may be selected but if it is not shown then there is no graphics created for it and so there is nothing highlighted. So the Structure class has to override get_selected() so that it checks if Atom is selected, not whether something is highlighted.

That said, the Model.get_selected() is a default implementation, and as a default assuming selected and highlighted are the same seems reasonable. So I've added your code. The 0.8 release was made yesterday so this fix is only in the daily builds.

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

No problem - it’s more of a cosmetic thing in any case. For most of the cases I’m talking about, the concept of “selected” either doesn’t really make sense or is an all-or-nothing thing, so I should probably do my own overrides anyway.

 
 
Tristan Croll
Research Fellow
Cambridge Institute for Medical Research
University of Cambridge CB2 0XY
 

 


Note: See TracTickets for help on using tickets.