moleditpy 5.1.0__tar.gz → 5.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {moleditpy-5.1.0 → moleditpy-5.1.2}/PKG-INFO +1 -1
- {moleditpy-5.1.0 → moleditpy-5.1.2}/pyproject.toml +1 -1
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/PKG-INFO +1 -1
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/app_state.py +21 -4
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/compute_logic.py +5 -5
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/constrained_optimization_dialog.py +11 -10
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/edit_actions_logic.py +7 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/main_window.py +7 -1
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/molecular_scene_handler.py +29 -40
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/molecule_scene.py +18 -1
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/view_3d_logic.py +3 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/COPYING +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/DISTRIBUTION.md +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/LICENSE +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/LICENSING.md +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/README.md +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/THIRD_PARTY_NOTICES.md +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/setup.cfg +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/SOURCES.txt +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/dependency_links.txt +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/entry_points.txt +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/requires.txt +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/MoleditPy.egg-info/top_level.txt +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/__main__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/assets/file_icon.ico +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/assets/icon.icns +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/assets/icon.ico +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/assets/icon.png +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/formal_charge.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/mol_geometry.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/molecular_data.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/project_validation.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/core/stereo_check.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/main.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/plugins/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/plugins/plugin_interface.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/plugins/plugin_manager.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/plugins/plugin_manager_window.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/about_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/align_plane_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/alignment_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/analysis_window.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/angle_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/atom_item.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/atom_picking.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/base_picking_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/bond_item.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/bond_length_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/calculation_worker.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/chain_mixin.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/chirality_warning_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/color_settings_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/custom_interactor_style.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/custom_qt_interactor.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/dialog_3d_picking_mixin.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/dialog_logic.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/dihedral_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/edit_3d_logic.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/export_logic.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/geometry_base_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/io_logic.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/main_window_init.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/menu_utils.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/mirror_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/move_dialog_mixin.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/move_group_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/move_selected_atoms_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/periodic_table_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/planarize_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/plugin_menu_manager.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/preview_molecule.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/sdf_record_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_2d_tab.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_3d_tabs.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_labels_tab.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_other_tab.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_tab_base.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/string_importers.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/template_preview_item.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/template_preview_view.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/translation_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/ui_manager.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/user_template_dialog.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/zoomable_view.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/__init__.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/constants.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/default_settings.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/finite_float.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/hit_radius.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/label_style.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/sdf_records.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/sip_isdeleted_safe.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/suppress_log.py +0 -0
- {moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/utils/system_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MoleditPy
|
|
3
|
-
Version: 5.1.
|
|
3
|
+
Version: 5.1.2
|
|
4
4
|
Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
|
|
5
5
|
Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
|
|
6
6
|
License-Expression: LGPL-3.0-or-later
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MoleditPy
|
|
3
|
-
Version: 5.1.
|
|
3
|
+
Version: 5.1.2
|
|
4
4
|
Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
|
|
5
5
|
Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
|
|
6
6
|
License-Expression: LGPL-3.0-or-later
|
|
@@ -127,6 +127,9 @@ class StateManager:
|
|
|
127
127
|
state["constraints_3d"] = _serialize_constraints(
|
|
128
128
|
self.host.edit_3d_manager.constraints_3d
|
|
129
129
|
)
|
|
130
|
+
state["last_successful_optimization_method"] = getattr(
|
|
131
|
+
self.host.compute_manager, "last_successful_optimization_method", None
|
|
132
|
+
)
|
|
130
133
|
|
|
131
134
|
return state
|
|
132
135
|
|
|
@@ -266,6 +269,15 @@ class StateManager:
|
|
|
266
269
|
):
|
|
267
270
|
self.host.ui_manager.enable_3d_edit_actions(True)
|
|
268
271
|
|
|
272
|
+
# Restored after the 3D molecule, whose replacement clears it, and only
|
|
273
|
+
# with that molecule: a failed 3D restore leaves nothing it describes.
|
|
274
|
+
with suppress_log(AttributeError, RuntimeError, TypeError):
|
|
275
|
+
self.host.set_last_successful_optimization_method(
|
|
276
|
+
loaded_data.get("last_successful_optimization_method")
|
|
277
|
+
if self.host.view_3d_manager.current_mol is not None
|
|
278
|
+
else None
|
|
279
|
+
)
|
|
280
|
+
|
|
269
281
|
# Update labels after undo/redo
|
|
270
282
|
self.host.edit_3d_manager.update_2d_measurement_labels()
|
|
271
283
|
|
|
@@ -573,10 +585,6 @@ class StateManager:
|
|
|
573
585
|
|
|
574
586
|
# 3D viewer mode
|
|
575
587
|
is_3d_mode = json_data.get("is_3d_viewer_mode", False)
|
|
576
|
-
# Restore last successful optimization method if present in file
|
|
577
|
-
method = json_data.get("last_successful_optimization_method", None)
|
|
578
|
-
with suppress_log(AttributeError, RuntimeError, TypeError):
|
|
579
|
-
self.host.set_last_successful_optimization_method(method)
|
|
580
588
|
|
|
581
589
|
# Plugin State Restoration (Phase 3)
|
|
582
590
|
self._preserved_plugin_data = {} # Reset preserved data on new load
|
|
@@ -710,3 +718,12 @@ class StateManager:
|
|
|
710
718
|
except (RuntimeError, ValueError, TypeError, binascii.Error) as e:
|
|
711
719
|
logging.warning(f"Could not restore 3D molecular data: {e}")
|
|
712
720
|
self.host.set_current_molecule(None)
|
|
721
|
+
|
|
722
|
+
# Restore the last successful optimization method after the 3D molecule:
|
|
723
|
+
# setting a new molecule clears the method of the previous one. Without
|
|
724
|
+
# a restored molecule there is nothing for the method to describe.
|
|
725
|
+
method = json_data.get("last_successful_optimization_method", None)
|
|
726
|
+
if self.host.view_3d_manager.current_mol is None:
|
|
727
|
+
method = None
|
|
728
|
+
with suppress_log(AttributeError, RuntimeError, TypeError):
|
|
729
|
+
self.host.set_last_successful_optimization_method(method)
|
|
@@ -682,11 +682,8 @@ class ComputeManager:
|
|
|
682
682
|
self.host.view_3d_manager.draw_molecule_3d(mol)
|
|
683
683
|
self._remove_calculating_text()
|
|
684
684
|
self._refresh_ui_state()
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
self.host.view_3d_manager.plotter.reset_camera() # type: ignore[call-arg]
|
|
688
|
-
|
|
689
|
-
# Record the successful optimization method from mol property or current setting
|
|
685
|
+
# Record the successful optimization method from mol property or current
|
|
686
|
+
# setting, before the undo snapshot so that undo/redo carry it.
|
|
690
687
|
try:
|
|
691
688
|
method_key = None
|
|
692
689
|
if mol and mol.HasProp("_pme_optimization_method"):
|
|
@@ -701,6 +698,9 @@ class ComputeManager:
|
|
|
701
698
|
except (AttributeError, TypeError):
|
|
702
699
|
# Safe defensive fallback catching AttributeError, TypeError
|
|
703
700
|
logging.debug("Suppressed non-critical error", exc_info=True)
|
|
701
|
+
self.host.edit_actions_manager.push_undo_state()
|
|
702
|
+
if self.host.view_3d_manager.plotter:
|
|
703
|
+
self.host.view_3d_manager.plotter.reset_camera() # type: ignore[call-arg]
|
|
704
704
|
|
|
705
705
|
# Update 3D interactive features (hovers, menus)
|
|
706
706
|
self.host.view_3d_manager.setup_3d_hover()
|
|
@@ -736,16 +736,7 @@ class ConstrainedOptimizationDialog(QDialog, Dialog3DPickingMixin):
|
|
|
736
736
|
except (AttributeError, RuntimeError, ValueError, TypeError) as e:
|
|
737
737
|
logging.warning("Failed to save constraints post-optimization: %s", e)
|
|
738
738
|
|
|
739
|
-
#
|
|
740
|
-
self.main_window.view_3d_manager.draw_molecule_3d(self.mol)
|
|
741
|
-
self.main_window.view_3d_manager.update_chiral_labels()
|
|
742
|
-
self.main_window.edit_actions_manager.push_undo_state()
|
|
743
|
-
self.main_window.state_manager.has_unsaved_changes = True
|
|
744
|
-
self.main_window.state_manager.update_window_title()
|
|
745
|
-
status_bar = self.main_window.statusBar()
|
|
746
|
-
if status_bar is not None:
|
|
747
|
-
status_bar.showMessage("Constrained optimization finished.")
|
|
748
|
-
|
|
739
|
+
# Record the method before the undo snapshot so undo/redo carry it.
|
|
749
740
|
try:
|
|
750
741
|
constrained_method_name = f"Constrained_{ff_name}"
|
|
751
742
|
self.main_window.compute_manager.last_successful_optimization_method = (
|
|
@@ -756,6 +747,16 @@ class ConstrainedOptimizationDialog(QDialog, Dialog3DPickingMixin):
|
|
|
756
747
|
"Failed to set last_successful_optimization_method: %s", e
|
|
757
748
|
)
|
|
758
749
|
|
|
750
|
+
# Update 3D view
|
|
751
|
+
self.main_window.view_3d_manager.draw_molecule_3d(self.mol)
|
|
752
|
+
self.main_window.view_3d_manager.update_chiral_labels()
|
|
753
|
+
self.main_window.edit_actions_manager.push_undo_state()
|
|
754
|
+
self.main_window.state_manager.has_unsaved_changes = True
|
|
755
|
+
self.main_window.state_manager.update_window_title()
|
|
756
|
+
status_bar = self.main_window.statusBar()
|
|
757
|
+
if status_bar is not None:
|
|
758
|
+
status_bar.showMessage("Constrained optimization finished.")
|
|
759
|
+
|
|
759
760
|
except (AttributeError, RuntimeError, ValueError, TypeError) as e:
|
|
760
761
|
logging.exception("Optimization failed: %s", e)
|
|
761
762
|
|
|
@@ -183,6 +183,10 @@ class EditActionsManager:
|
|
|
183
183
|
if self.host.view_3d_manager.current_mol
|
|
184
184
|
else None,
|
|
185
185
|
"constraints_3d": self._constraints_for_comparison(),
|
|
186
|
+
# Saved with the project, so a change to it alone is a change.
|
|
187
|
+
"last_successful_optimization_method": getattr(
|
|
188
|
+
self.host.compute_manager, "last_successful_optimization_method", None
|
|
189
|
+
),
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
last_state_for_comparison = None
|
|
@@ -209,6 +213,9 @@ class EditActionsManager:
|
|
|
209
213
|
"mol_3d": last_state.get("mol_3d", None),
|
|
210
214
|
"mol_3d_atom_ids": last_state.get("mol_3d_atom_ids", None),
|
|
211
215
|
"constraints_3d": last_state.get("constraints_3d") or [],
|
|
216
|
+
"last_successful_optimization_method": last_state.get(
|
|
217
|
+
"last_successful_optimization_method"
|
|
218
|
+
),
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
if (
|
|
@@ -132,9 +132,15 @@ class MainWindow(QMainWindow):
|
|
|
132
132
|
# --- Mediator Methods ---
|
|
133
133
|
|
|
134
134
|
def set_current_molecule(self, mol: Optional[Chem.Mol]) -> None:
|
|
135
|
-
"""Set the current 3D molecule and trigger rendering updates.
|
|
135
|
+
"""Set the current 3D molecule and trigger rendering updates.
|
|
136
|
+
|
|
137
|
+
A different molecule clears the last optimization method, which
|
|
138
|
+
described the previous structure; callers that set the molecule as the
|
|
139
|
+
result of an optimization record the method afterwards.
|
|
140
|
+
"""
|
|
136
141
|
if mol is not self.view_3d_manager.current_mol:
|
|
137
142
|
self.edit_3d_manager.invalidate_molecule_dialogs()
|
|
143
|
+
self.compute_manager.last_successful_optimization_method = None
|
|
138
144
|
self.view_3d_manager.current_mol = mol
|
|
139
145
|
|
|
140
146
|
def set_3d_atom_positions(self, positions: Any) -> None:
|
|
@@ -936,6 +936,34 @@ class KeyboardMixin:
|
|
|
936
936
|
|
|
937
937
|
temp_line: Optional[QGraphicsLineItem]
|
|
938
938
|
|
|
939
|
+
def grow_carbon_from_atom(self, start_atom: Any, target_order: int = 1) -> None:
|
|
940
|
+
"""Bond a new carbon (or a nearby atom) to start_atom, as the 1/2/3 keys do."""
|
|
941
|
+
new_pos_offset = self._calculate_new_atom_position(
|
|
942
|
+
start_atom, DEFAULT_BOND_LENGTH, target_order
|
|
943
|
+
)
|
|
944
|
+
target_pos = start_atom.pos() + new_pos_offset
|
|
945
|
+
|
|
946
|
+
snap_dist = self.get_setting("bond_snapping_distance_2d", 14.0)
|
|
947
|
+
near_atom = self.find_atom_near(target_pos, tol=snap_dist)
|
|
948
|
+
|
|
949
|
+
if near_atom and near_atom is not start_atom:
|
|
950
|
+
self.create_bond(
|
|
951
|
+
start_atom, near_atom, bond_order=target_order, bond_stereo=0
|
|
952
|
+
)
|
|
953
|
+
else:
|
|
954
|
+
new_atom_id = self.create_atom("C", target_pos)
|
|
955
|
+
self.create_bond(
|
|
956
|
+
start_atom,
|
|
957
|
+
self.atom_items[new_atom_id],
|
|
958
|
+
bond_order=target_order,
|
|
959
|
+
bond_stereo=0,
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
if target_order != 3:
|
|
963
|
+
self.placement_direction_clockwise = not getattr(
|
|
964
|
+
self, "placement_direction_clockwise", True
|
|
965
|
+
)
|
|
966
|
+
|
|
939
967
|
def _calculate_new_atom_position(
|
|
940
968
|
self, start_atom: Any, bond_length: Any, target_order: int = 1
|
|
941
969
|
) -> Any:
|
|
@@ -1405,46 +1433,7 @@ class KeyboardMixin:
|
|
|
1405
1433
|
start_atom = selected_atoms[0]
|
|
1406
1434
|
|
|
1407
1435
|
if start_atom:
|
|
1408
|
-
|
|
1409
|
-
bond_len = DEFAULT_BOND_LENGTH
|
|
1410
|
-
new_pos_offset = self._calculate_new_atom_position(
|
|
1411
|
-
start_atom, bond_len, target_order
|
|
1412
|
-
)
|
|
1413
|
-
|
|
1414
|
-
# SNAP_DISTANCE is a module-level constant
|
|
1415
|
-
target_pos = start_pos + new_pos_offset
|
|
1416
|
-
|
|
1417
|
-
# Find nearby atom
|
|
1418
|
-
near_atom = None
|
|
1419
|
-
snap_dist = self.get_setting("bond_snapping_distance_2d", 14.0)
|
|
1420
|
-
near_atom = self.find_atom_near(target_pos, tol=snap_dist)
|
|
1421
|
-
|
|
1422
|
-
if near_atom and near_atom is not start_atom:
|
|
1423
|
-
# Bond if exists
|
|
1424
|
-
self.create_bond(
|
|
1425
|
-
start_atom,
|
|
1426
|
-
near_atom,
|
|
1427
|
-
bond_order=target_order,
|
|
1428
|
-
bond_stereo=0,
|
|
1429
|
-
)
|
|
1430
|
-
else:
|
|
1431
|
-
# Create new atom and bond
|
|
1432
|
-
new_atom_id = self.create_atom("C", target_pos)
|
|
1433
|
-
new_atom_item = self.atom_items[new_atom_id]
|
|
1434
|
-
self.create_bond(
|
|
1435
|
-
start_atom,
|
|
1436
|
-
new_atom_item,
|
|
1437
|
-
bond_order=target_order,
|
|
1438
|
-
bond_stereo=0,
|
|
1439
|
-
)
|
|
1440
|
-
|
|
1441
|
-
if target_order != 3:
|
|
1442
|
-
if hasattr(self, "placement_direction_clockwise"):
|
|
1443
|
-
self.placement_direction_clockwise = (
|
|
1444
|
-
not self.placement_direction_clockwise
|
|
1445
|
-
)
|
|
1446
|
-
else:
|
|
1447
|
-
self.placement_direction_clockwise = False
|
|
1436
|
+
self.grow_carbon_from_atom(start_atom, target_order)
|
|
1448
1437
|
self.clearSelection()
|
|
1449
1438
|
self.update_all_items()
|
|
1450
1439
|
self.window.edit_actions_manager.push_undo_state()
|
|
@@ -827,8 +827,16 @@ class MoleculeScene(
|
|
|
827
827
|
order_to_use = self.bond_order if self.mode.startswith("bond") else None
|
|
828
828
|
stereo_to_use = self.bond_stereo if self.mode.startswith("bond") else None
|
|
829
829
|
if is_click:
|
|
830
|
-
# Short click
|
|
830
|
+
# Short click on a carbon in carbon mode grows a chain like key 1
|
|
831
831
|
if (
|
|
832
|
+
self.mode == "atom_C"
|
|
833
|
+
and self.start_atom.symbol == "C"
|
|
834
|
+
and self.current_atom_symbol == "C"
|
|
835
|
+
):
|
|
836
|
+
self.grow_carbon_from_atom(self.start_atom, 1)
|
|
837
|
+
self.data_changed_in_event = True
|
|
838
|
+
# Short click: Update existing atom symbol (atom mode only)
|
|
839
|
+
elif (
|
|
832
840
|
self.mode.startswith("atom")
|
|
833
841
|
and self.start_atom.symbol != self.current_atom_symbol
|
|
834
842
|
):
|
|
@@ -1073,6 +1081,15 @@ class MoleculeScene(
|
|
|
1073
1081
|
# On any unexpected error, fall back to default handling
|
|
1074
1082
|
logging.warning(f"Error in connected component selection: {e}")
|
|
1075
1083
|
|
|
1084
|
+
elif (
|
|
1085
|
+
self.mode.startswith("atom")
|
|
1086
|
+
and event.button() == Qt.MouseButton.LeftButton
|
|
1087
|
+
and not event.modifiers() & Qt.KeyboardModifier.ShiftModifier
|
|
1088
|
+
):
|
|
1089
|
+
# Count the second click of a double-click as another single click;
|
|
1090
|
+
# right (delete) and middle/Shift (pan) double-clicks are left alone
|
|
1091
|
+
self.mousePressEvent(event)
|
|
1092
|
+
return
|
|
1076
1093
|
elif self.mode in ["bond_2_5"]:
|
|
1077
1094
|
event.accept()
|
|
1078
1095
|
return
|
|
@@ -233,6 +233,9 @@ class View3DManager:
|
|
|
233
233
|
# 3. End with background and axes if mol is None or empty
|
|
234
234
|
if mol is None or mol.GetNumAtoms() == 0:
|
|
235
235
|
self.atom_actor = None
|
|
236
|
+
if self.current_mol is not None:
|
|
237
|
+
# The structure is gone, and with it what its method described.
|
|
238
|
+
self.host.set_last_successful_optimization_method(None)
|
|
236
239
|
self.current_mol = None
|
|
237
240
|
self.plotter.render() # type: ignore[union-attr]
|
|
238
241
|
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{moleditpy-5.1.0 → moleditpy-5.1.2}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|