moleditpy 5.0.3__tar.gz → 5.1.1__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.
Files changed (100) hide show
  1. {moleditpy-5.0.3 → moleditpy-5.1.1}/PKG-INFO +1 -1
  2. {moleditpy-5.0.3 → moleditpy-5.1.1}/pyproject.toml +1 -1
  3. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/PKG-INFO +1 -1
  4. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/SOURCES.txt +1 -0
  5. moleditpy-5.1.1/src/moleditpy/core/formal_charge.py +75 -0
  6. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/edit_actions_logic.py +34 -0
  7. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/main_window_init.py +11 -0
  8. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/molecular_scene_handler.py +29 -40
  9. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/molecule_scene.py +18 -1
  10. {moleditpy-5.0.3 → moleditpy-5.1.1}/COPYING +0 -0
  11. {moleditpy-5.0.3 → moleditpy-5.1.1}/DISTRIBUTION.md +0 -0
  12. {moleditpy-5.0.3 → moleditpy-5.1.1}/LICENSE +0 -0
  13. {moleditpy-5.0.3 → moleditpy-5.1.1}/LICENSING.md +0 -0
  14. {moleditpy-5.0.3 → moleditpy-5.1.1}/README.md +0 -0
  15. {moleditpy-5.0.3 → moleditpy-5.1.1}/THIRD_PARTY_NOTICES.md +0 -0
  16. {moleditpy-5.0.3 → moleditpy-5.1.1}/setup.cfg +0 -0
  17. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/dependency_links.txt +0 -0
  18. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/entry_points.txt +0 -0
  19. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/requires.txt +0 -0
  20. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/MoleditPy.egg-info/top_level.txt +0 -0
  21. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/__init__.py +0 -0
  22. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/__main__.py +0 -0
  23. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/assets/file_icon.ico +0 -0
  24. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/assets/icon.icns +0 -0
  25. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/assets/icon.ico +0 -0
  26. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/assets/icon.png +0 -0
  27. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/core/__init__.py +0 -0
  28. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/core/mol_geometry.py +0 -0
  29. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/core/molecular_data.py +0 -0
  30. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/core/project_validation.py +0 -0
  31. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/core/stereo_check.py +0 -0
  32. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/main.py +0 -0
  33. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/plugins/__init__.py +0 -0
  34. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/plugins/plugin_interface.py +0 -0
  35. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/plugins/plugin_manager.py +0 -0
  36. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/plugins/plugin_manager_window.py +0 -0
  37. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/__init__.py +0 -0
  38. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/about_dialog.py +0 -0
  39. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/align_plane_dialog.py +0 -0
  40. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/alignment_dialog.py +0 -0
  41. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/analysis_window.py +0 -0
  42. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/angle_dialog.py +0 -0
  43. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/app_state.py +0 -0
  44. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/atom_item.py +0 -0
  45. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/atom_picking.py +0 -0
  46. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/base_picking_dialog.py +0 -0
  47. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/bond_item.py +0 -0
  48. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/bond_length_dialog.py +0 -0
  49. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/calculation_worker.py +0 -0
  50. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/chain_mixin.py +0 -0
  51. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/chirality_warning_dialog.py +0 -0
  52. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/color_settings_dialog.py +0 -0
  53. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/compute_logic.py +0 -0
  54. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/constrained_optimization_dialog.py +0 -0
  55. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/custom_interactor_style.py +0 -0
  56. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/custom_qt_interactor.py +0 -0
  57. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/dialog_3d_picking_mixin.py +0 -0
  58. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/dialog_logic.py +0 -0
  59. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/dihedral_dialog.py +0 -0
  60. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/edit_3d_logic.py +0 -0
  61. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/export_logic.py +0 -0
  62. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/geometry_base_dialog.py +0 -0
  63. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/io_logic.py +0 -0
  64. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/main_window.py +0 -0
  65. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/menu_utils.py +0 -0
  66. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/mirror_dialog.py +0 -0
  67. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/move_dialog_mixin.py +0 -0
  68. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/move_group_dialog.py +0 -0
  69. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/move_selected_atoms_dialog.py +0 -0
  70. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/periodic_table_dialog.py +0 -0
  71. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/planarize_dialog.py +0 -0
  72. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/plugin_menu_manager.py +0 -0
  73. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/preview_molecule.py +0 -0
  74. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/sdf_record_dialog.py +0 -0
  75. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_dialog.py +0 -0
  76. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/__init__.py +0 -0
  77. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py +0 -0
  78. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_2d_tab.py +0 -0
  79. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_3d_tabs.py +0 -0
  80. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_labels_tab.py +0 -0
  81. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_other_tab.py +0 -0
  82. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/settings_tabs/settings_tab_base.py +0 -0
  83. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/string_importers.py +0 -0
  84. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/template_preview_item.py +0 -0
  85. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/template_preview_view.py +0 -0
  86. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/translation_dialog.py +0 -0
  87. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/ui_manager.py +0 -0
  88. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/user_template_dialog.py +0 -0
  89. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/view_3d_logic.py +0 -0
  90. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/ui/zoomable_view.py +0 -0
  91. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/__init__.py +0 -0
  92. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/constants.py +0 -0
  93. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/default_settings.py +0 -0
  94. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/finite_float.py +0 -0
  95. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/hit_radius.py +0 -0
  96. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/label_style.py +0 -0
  97. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/sdf_records.py +0 -0
  98. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/sip_isdeleted_safe.py +0 -0
  99. {moleditpy-5.0.3 → moleditpy-5.1.1}/src/moleditpy/utils/suppress_log.py +0 -0
  100. {moleditpy-5.0.3 → moleditpy-5.1.1}/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.0.3
3
+ Version: 5.1.1
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
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "MoleditPy"
7
7
 
8
- version = "5.0.3"
8
+ version = "5.1.1"
9
9
 
10
10
  license = "LGPL-3.0-or-later"
11
11
  license-files = ["LICENSE", "COPYING", "THIRD_PARTY_NOTICES.md", "DISTRIBUTION.md", "LICENSING.md"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MoleditPy
3
- Version: 5.0.3
3
+ Version: 5.1.1
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
@@ -19,6 +19,7 @@ src/moleditpy/assets/icon.icns
19
19
  src/moleditpy/assets/icon.ico
20
20
  src/moleditpy/assets/icon.png
21
21
  src/moleditpy/core/__init__.py
22
+ src/moleditpy/core/formal_charge.py
22
23
  src/moleditpy/core/mol_geometry.py
23
24
  src/moleditpy/core/molecular_data.py
24
25
  src/moleditpy/core/project_validation.py
@@ -0,0 +1,75 @@
1
+ """Conservative formal-charge repair for drawn molecular graphs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Dict, Set
6
+
7
+ from rdkit import Chem, rdBase
8
+
9
+ if TYPE_CHECKING:
10
+ from .molecular_data import MolecularData
11
+
12
+
13
+ def infer_charge_adjustments(data: MolecularData) -> Dict[int, int]:
14
+ """Return unambiguous repairs without changing the editor's graph.
15
+
16
+ Keep RDKit-valid charges. For invalid B/C/N/O valences, accept a repair
17
+ only when exactly one of -1, 0, +1 passes RDKit's strict valence check.
18
+ Missing hydrogens do not establish a charge: a singly bonded neutral O,
19
+ for example, may be an alcohol and is left alone. Radicals, other elements,
20
+ and atoms adjacent to unsupported symbols are outside this heuristic.
21
+ """
22
+ mol = Chem.RWMol()
23
+ indices = {}
24
+ bond_types = {
25
+ 1.0: Chem.BondType.SINGLE,
26
+ 1.5: Chem.BondType.AROMATIC,
27
+ 2.0: Chem.BondType.DOUBLE,
28
+ 3.0: Chem.BondType.TRIPLE,
29
+ }
30
+ with rdBase.BlockLogs():
31
+ for atom_id, record in data.atoms.items():
32
+ try:
33
+ atom = Chem.Atom(record["symbol"])
34
+ except (RuntimeError, ValueError):
35
+ atom = Chem.Atom(0)
36
+ atom.SetFormalCharge(record.get("charge", 0))
37
+ atom.SetNumRadicalElectrons(record.get("radical", 0))
38
+ indices[atom_id] = mol.AddAtom(atom)
39
+
40
+ excluded: Set[int] = set()
41
+ for (first, second), record in data.bonds.items():
42
+ bond_type = bond_types.get(float(record["order"]))
43
+ if first not in indices or second not in indices or bond_type is None:
44
+ excluded.update((first, second))
45
+ continue
46
+ mol.AddBond(indices[first], indices[second], bond_type)
47
+
48
+ changes = {}
49
+ for atom_id, idx in indices.items():
50
+ atom = mol.GetAtomWithIdx(idx)
51
+ if (
52
+ atom_id in excluded
53
+ or atom.GetAtomicNum() not in (5, 6, 7, 8)
54
+ or atom.GetNumRadicalElectrons()
55
+ or any(n.GetAtomicNum() == 0 for n in atom.GetNeighbors())
56
+ ):
57
+ continue
58
+ try:
59
+ atom.UpdatePropertyCache(strict=True)
60
+ continue
61
+ except (RuntimeError, ValueError):
62
+ pass
63
+
64
+ candidates = []
65
+ for charge in (-1, 0, 1):
66
+ atom.SetFormalCharge(charge)
67
+ try:
68
+ atom.UpdatePropertyCache(strict=True)
69
+ candidates.append(charge)
70
+ except (RuntimeError, ValueError):
71
+ pass
72
+ atom.SetFormalCharge(data.atoms[atom_id].get("charge", 0))
73
+ if len(candidates) == 1:
74
+ changes[atom_id] = candidates[0]
75
+ return changes
@@ -21,6 +21,7 @@ from typing import Any, Dict, List, Optional, TYPE_CHECKING, TypedDict
21
21
  import numpy as np
22
22
 
23
23
  from ..core.mol_geometry import identify_valence_problems
24
+ from ..core.formal_charge import infer_charge_adjustments
24
25
  from .app_state import _serialize_constraints
25
26
 
26
27
  # RDKit imports (explicit to satisfy flake8 and used features)
@@ -680,6 +681,39 @@ class EditActionsManager:
680
681
  # Suppress transient errors during UI status reporting.
681
682
  self.host.statusBar().showMessage("Error removing hydrogen atoms.") # type: ignore[union-attr]
682
683
 
684
+ def adjust_formal_charges(self) -> None:
685
+ """Repair unambiguous invalid formal charges as one undoable edit."""
686
+ data = self.host.state_manager.data
687
+ if not data.atoms:
688
+ self.host.statusBar().showMessage( # type: ignore[union-attr]
689
+ "No molecule available to adjust charges.", 2000
690
+ )
691
+ return
692
+
693
+ changes = infer_charge_adjustments(data)
694
+ if not changes:
695
+ self.host.statusBar().showMessage( # type: ignore[union-attr]
696
+ "No unambiguous charge corrections found. Existing charges preserved.",
697
+ 4000,
698
+ )
699
+ return
700
+
701
+ scene = self.host.init_manager.scene
702
+ for atom_id, charge in changes.items():
703
+ item = scene.atom_items.get(atom_id)
704
+ if item is not None:
705
+ item.prepareGeometryChange()
706
+ item.charge = charge
707
+ item.update_style()
708
+ data.atoms[atom_id]["charge"] = charge
709
+ scene.update_all_items()
710
+ self.push_undo_state()
711
+ self.host.statusBar().showMessage( # type: ignore[union-attr]
712
+ f"Adjusted formal charges on {len(changes)} atoms. "
713
+ "Ambiguous cases left unchanged.",
714
+ 4000,
715
+ )
716
+
683
717
  def add_hydrogen_atoms(self) -> None:
684
718
  """Compute and add explicit hydrogens in 2D view using RDKit."""
685
719
 
@@ -1334,6 +1334,17 @@ class MainInitManager:
1334
1334
  )
1335
1335
  edit_menu.addAction(remove_hydrogen_action)
1336
1336
 
1337
+ adjust_charge_action = QAction("Adjust Charge", self.host)
1338
+ adjust_charge_action.setShortcut(QKeySequence("Ctrl+E"))
1339
+ adjust_charge_action.setToolTip(
1340
+ "Repair unambiguous invalid B/C/N/O formal charges using RDKit; "
1341
+ "preserve valid charges and ambiguous cases"
1342
+ )
1343
+ adjust_charge_action.triggered.connect(
1344
+ self.host.edit_actions_manager.adjust_formal_charges
1345
+ )
1346
+ edit_menu.addAction(adjust_charge_action)
1347
+
1337
1348
  edit_menu.addSeparator()
1338
1349
  rotate_2d_action = QAction("Rotate 2D...", self.host)
1339
1350
  rotate_2d_action.setShortcut(QKeySequence("Ctrl+R"))
@@ -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
- start_pos = start_atom.pos()
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: Update existing atom symbol (atom mode only)
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes