Opened 8 years ago

Closed 8 years ago

#684 closed defect (fixed)

Bugs in changes.py

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

Description

At the moment, the 'model display changed' trigger only fires when an entire model is shown or hidden, but there doesn't appear to be a trigger that fires to indicate when part of a model has changed its display. In my case I want to tie the visibility of my restraint target "atoms" and pseudobonds to the visibility of the restrained atoms, e.g.:

        self._display_changed_handler = self.session.triggers.add_handler(
            'model display changed', self._update_target_display)

    def _update_target_display(self, model):
        if model == self.master_model:
            self.target_indicators.displays = self.atoms.displays

... but that doesn't appear to be possible at the moment.

Attachments (1)

testchanges.py (407 bytes ) - added by Tom Goddard 8 years ago.
Python code demonstrating how to detect atom changes.

Download all attachments as: .zip

Change History (5)

comment:1 by Tom Goddard, 8 years ago

Resolution: not a bug
Status: assignedclosed

There is a trigger to detect Atom display state changes and many other molecular object changes, the "changes" trigger. The API is defined in the Changes class in

core/atomic/changes.py

and take a look at the attached example python code.

by Tom Goddard, 8 years ago

Attachment: testchanges.py added

Python code demonstrating how to detect atom changes.

comment:2 by Tristan Croll, 8 years ago

Ah, thanks! Sorry - was poring over the list of trigger names, and somehow that one didn't register with me.

comment:3 by Tristan Croll, 8 years ago

Resolution: not a bug
Status: closedreopened
Summary: Have 'model display changed' trigger fire when part of a model is shown/hiddenBugs in changes.py
Type: enhancementdefect

I see now why I couldn't find it - I was unaware that more than one triggerset existed. Working now, but I did run into a couple of bugs in changes.py:

    def created_atomic_structures(self):
<        return _atomic_structures(self._changes["Structure"].created)
>        return self._atomic_structures(self._changes["Structure"].created)

    def modified_atomic_structures(self):
<        return _atomic_structures(self._changes["Structure"].modified)
>        return self._atomic_structures(self._changes["Structure"].modified)

    def _atomic_structures(self, collection):
        from . import AtomicStructure, AtomicStructures
        ass = []
        for g in collection:
            if isinstance(g, AtomicStructure):
                ass.append(g)
        from . import AtomicStructures
<        return AtomicStructrures(ass)
>        return AtomicStructures(ass)


comment:4 by Tom Goddard, 8 years ago

Resolution: fixed
Status: reopenedclosed

Ok, I fixed these 3 problems in atomic/changes.py

Note: See TracTickets for help on using tickets.