From 9d3b21ccbd218f49fa6fa329386982033a04327d Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Mon, 26 May 2025 23:04:48 -0700 Subject: [PATCH 1/6] rm(viewdock): "Show all" and "Hide All" buttons Remove the "Show all" and "Hide all" buttons as part of refactor to make table row selection control visibility. --- src/bundles/viewdock/src/tool.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index ac2e8cbd14..9ab407dc30 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -76,20 +76,6 @@ def top_buttons_setup(self): """ Create the top buttons for the tool (HBonds and Clashes). """ - # Add "Show All" button - self.show_all_button = QPushButton("Show All") - self.show_all_button.clicked.connect( - lambda: self.set_visibility(self.structures, True) - ) - self.top_buttons_layout.addWidget(self.show_all_button) - - # Add "Hide All" button - self.hide_all_button = QPushButton("Hide All") - self.hide_all_button.clicked.connect( - lambda: self.set_visibility(self.structures, False) - ) - self.top_buttons_layout.addWidget(self.hide_all_button) - self.hbonds_button = QPushButton("HBonds") self.hbonds_button.clicked.connect( lambda: self.popup_callback( From 69d1f8a10c85ef5204a4279d246e2cfe4785a6e1 Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Mon, 26 May 2025 23:09:53 -0700 Subject: [PATCH 2/6] rm(viewdock): "Show" column Purpose: refactoring the viewdock tool to use table selection for model display. - remove the "Show" column from the viewdock tool - remove the "MODEL_DISPLAY_CHANGED" trigger handler which was associated with the "Show" col. --- src/bundles/viewdock/src/tool.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index 9ab407dc30..2c96f0d410 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -145,7 +145,7 @@ def ok_cb(): def table_setup(self): """ - Create the ItemTable for the structures. Add a column for the display with check boxes, a column for the + Create the ItemTable for the structures. Add a for the structure ID, a column for the Rating with a custom delegate, and columns for each key in the viewdock_data attribute of each structure (e.g., Name, Description, Energy Score...). If a structure does not have a key from the set, the cell will be empty. @@ -158,8 +158,7 @@ def table_setup(self): table_group_layout.addWidget(self.col_display_widget) table_group.setLayout(table_group_layout) - # Fixed columns. Generic based on ChimeraX model attributes. - self.display_col = self.struct_table.add_column('Show', lambda s: s.display, data_set=self.set_visibility, format=ItemTable.COL_FORMAT_BOOLEAN) + # Fixed columns. Generic based on ChimeraX model attribute(s). self.struct_table.add_column('ID', lambda s: s.id_string) # Custom Rating delegate @@ -288,11 +287,6 @@ def add_handlers(self): REMOVE_MODELS, lambda trigger_name, trigger_data: self.remove_models_cb(trigger_name, trigger_data) )) - self.handlers.append(self.session.triggers.add_handler( - MODEL_DISPLAY_CHANGED, - lambda trigger_name, trigger_data: self.struct_table.update_cell(self.display_col, trigger_data) - if trigger_data in self.structures else None - )) def remove_models_cb(self, trigger_name, trigger_data): """ From 63bf2aa675ea217a0dc9ca6973c6cb67daf825c2 Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Mon, 26 May 2025 23:26:35 -0700 Subject: [PATCH 3/6] refactor(viewdock): table selection change callback Purpose: refactoring the viewdock tool to use table selection for model display. - add table_selection_changed function between the table callback an updating the model description - table_selection_changed function can handle model display adjustment --- src/bundles/viewdock/src/tool.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index 2c96f0d410..27e228824c 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -208,7 +208,7 @@ def description_box_setup(self): self.description_group.setFont(title_font) self.struct_table.selection_changed.connect( - lambda newly_selected, newly_deselected: self.update_model_description(newly_selected) + lambda newly_selected, newly_deselected: self.table_selection_changed(newly_selected, newly_deselected) ) # Add the group box to the main layout @@ -216,6 +216,17 @@ def description_box_setup(self): # Select the first structure in the table to display its data in the description box self.struct_table.selected = [self.structures[0]] + def table_selection_changed(self, newly_selected, newly_deselected): + """ + Callback for when the selection in the ItemTable changes. Updates what docking structure is visibla and the + description box with the newly selected structure's data. + + Args: + newly_selected (list): The newly selected structure(s) in the ItemTable. + newly_deselected (list): The previously selected structure(s) in the ItemTable. + """ + self.update_model_description(newly_selected) + def update_model_description(self, newly_selected): """ Update the description box with the most recently selected structure's data. If more than one structure is From dac4166bd75ce9a62f449cf5e47774b7da70d6cb Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Mon, 26 May 2025 23:45:39 -0700 Subject: [PATCH 4/6] feat(viewdock): table selection change updates docking model displays Purpose: refactoring the viewdock tool to use table selection for model display. - new method update_structure_displays which accpets structures to display and hides all other docking structures. - table_selection_changed method calls update_structure displays. --- src/bundles/viewdock/src/tool.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index 27e228824c..45c2021ed1 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -225,8 +225,25 @@ def table_selection_changed(self, newly_selected, newly_deselected): newly_selected (list): The newly selected structure(s) in the ItemTable. newly_deselected (list): The previously selected structure(s) in the ItemTable. """ + self.update_structure_displays(newly_selected) self.update_model_description(newly_selected) + def update_structure_displays(self, newly_selected): + """ + Update the display of the docking structures. The newly selected structures will be shown and all other docking + structures will be hidden. + + Args: + newly_selected (list): The newly selected structure(s) in the ItemTable. + """ + # Generate arrays for newly selected and the difference + newly_selected_array = newly_selected + others_array = [s for s in self.structures if s not in newly_selected_array] + + # Call set_visibility to show newly selected and hide others + self.set_visibility(newly_selected_array, True) + self.set_visibility(others_array, False) + def update_model_description(self, newly_selected): """ Update the description box with the most recently selected structure's data. If more than one structure is From 7acc7c15dd33ac3b457ccca52302624ff601ae65 Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Sun, 1 Jun 2025 22:55:24 -0700 Subject: [PATCH 5/6] refactor(viewdock): don't log show/hide commands from tool Hide the show/hide commands from the log when the ViewDock tool changes selection. Table gets scrolled a lot and this change prevents the log from getting cluttered. --- src/bundles/viewdock/src/tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index 45c2021ed1..894d851370 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -347,9 +347,9 @@ def set_visibility(self, structs, value): model_spec = concise_model_spec(self.session, structs) if value: - run(self.session, f'show {model_spec} models') + run(self.session, f'show {model_spec} models', log=False) else: - run(self.session, f'hide {model_spec} models') + run(self.session, f'hide {model_spec} models', log=False) def delete(self): """ From dcfbfa24c79323e57e8aee2be3410212e10132e1 Mon Sep 17 00:00:00 2001 From: pRottinghuis <70864925+pRottinghuis@users.noreply.github.com> Date: Sun, 1 Jun 2025 23:06:10 -0700 Subject: [PATCH 6/6] docs(viewdock): tool.py typo corrections --- src/bundles/viewdock/src/tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundles/viewdock/src/tool.py b/src/bundles/viewdock/src/tool.py index 894d851370..00ecbfebfe 100644 --- a/src/bundles/viewdock/src/tool.py +++ b/src/bundles/viewdock/src/tool.py @@ -218,7 +218,7 @@ def description_box_setup(self): def table_selection_changed(self, newly_selected, newly_deselected): """ - Callback for when the selection in the ItemTable changes. Updates what docking structure is visibla and the + Callback for when the selection in the ItemTable changes. Updates what docking structure is visible and the description box with the newly selected structure's data. Args: @@ -230,7 +230,7 @@ def table_selection_changed(self, newly_selected, newly_deselected): def update_structure_displays(self, newly_selected): """ - Update the display of the docking structures. The newly selected structures will be shown and all other docking + Update the display of the docking structures. The newly selected structures will be shown, and all other docking structures will be hidden. Args: