moleditpy 1.2.2__tar.gz → 1.2.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moleditpy
3
- Version: 1.2.2
3
+ Version: 1.2.4
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
  Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "moleditpy"
7
7
 
8
- version = "1.2.2"
8
+ version = "1.2.4"
9
9
 
10
10
  authors = [
11
11
  { name="HiroYokoyama", email="titech.yoko.hiro@gmail.com" },
@@ -11,7 +11,7 @@ DOI 10.5281/zenodo.17268532
11
11
  """
12
12
 
13
13
  #Version
14
- VERSION = '1.2.2'
14
+ VERSION = '1.2.4'
15
15
 
16
16
  print("-----------------------------------------------------")
17
17
  print("MoleditPy — A Python-based molecular editing software")
@@ -879,7 +879,7 @@ class MoleculeScene(QGraphicsScene):
879
879
  stereo_to_use = self.bond_stereo if self.mode.startswith('bond') else None
880
880
 
881
881
 
882
- if line.length() < 10:
882
+ if is_click:
883
883
  # 短いクリック: 既存原子のシンボル更新 (atomモードのみ)
884
884
  if self.mode.startswith('atom') and self.start_atom.symbol != self.current_atom_symbol:
885
885
  self.start_atom.symbol=self.current_atom_symbol; self.data.atoms[self.start_atom.atom_id]['symbol']=self.current_atom_symbol; self.start_atom.update_style()
@@ -2139,6 +2139,7 @@ class CustomInteractorStyle(vtkInteractorStyleTrackballCamera):
2139
2139
  # その後、カーソルの表示を更新します
2140
2140
  is_edit_active = mw.is_3d_edit_mode or interactor.GetAltKey()
2141
2141
  if is_edit_active:
2142
+ # 編集がアクティブな場合のみ、原子のホバーチェックを行う
2142
2143
  atom_under_cursor = False
2143
2144
  click_pos = interactor.GetEventPosition()
2144
2145
  picker = mw.plotter.picker
@@ -2982,6 +2983,7 @@ class MainWindow(QMainWindow):
2982
2983
  self.optimize_3d_button.setEnabled(True)
2983
2984
  self.export_button.setEnabled(True)
2984
2985
  self.edit_3d_action.setEnabled(True)
2986
+ self.plotter.reset_camera()
2985
2987
 
2986
2988
  def on_calculation_error(self, error_message):
2987
2989
  self.dragged_atom_info = None
@@ -3150,8 +3152,11 @@ class MainWindow(QMainWindow):
3150
3152
  try:
3151
3153
  mol = self.data.to_rdkit_mol()
3152
3154
  if mol:
3155
+ # 水素原子を明示的に追加した分子オブジェクトを生成
3156
+ mol_with_hs = Chem.AddHs(mol)
3153
3157
  mol_formula = rdMolDescriptors.CalcMolFormula(mol)
3154
- num_atoms = mol.GetNumAtoms()
3158
+ # 水素を含む分子オブジェクトから原子数を取得
3159
+ num_atoms = mol_with_hs.GetNumAtoms()
3155
3160
  # 右側のラベルのテキストを更新
3156
3161
  self.formula_label.setText(f"Formula: {mol_formula} | Atoms: {num_atoms}")
3157
3162
  except Exception:
@@ -3483,6 +3488,7 @@ class MainWindow(QMainWindow):
3483
3488
 
3484
3489
  try:
3485
3490
  # 安定版:原子IDとRDKit座標の確実なマッピング
3491
+ view_center = self.view_2d.mapToScene(self.view_2d.viewport().rect().center())
3486
3492
  new_positions_map = {}
3487
3493
  AllChem.Compute2DCoords(mol)
3488
3494
  conf = mol.GetConformer()
@@ -3498,8 +3504,8 @@ class MainWindow(QMainWindow):
3498
3504
  self.statusBar().showMessage("Error: Atom items not found for optimized atoms."); return
3499
3505
 
3500
3506
  # 元の図形の中心を維持
3501
- original_center_x = sum(item.pos().x() for item in target_atom_items) / len(target_atom_items)
3502
- original_center_y = sum(item.pos().y() for item in target_atom_items) / len(target_atom_items)
3507
+ #original_center_x = sum(item.pos().x() for item in target_atom_items) / len(target_atom_items)
3508
+ #original_center_y = sum(item.pos().y() for item in target_atom_items) / len(target_atom_items)
3503
3509
 
3504
3510
  positions = list(new_positions_map.values())
3505
3511
  rdkit_cx = sum(p.x for p in positions) / len(positions)
@@ -3511,8 +3517,8 @@ class MainWindow(QMainWindow):
3511
3517
  for atom_id, rdkit_pos in new_positions_map.items():
3512
3518
  if atom_id in self.data.atoms:
3513
3519
  item = self.data.atoms[atom_id]['item']
3514
- sx = ((rdkit_pos.x - rdkit_cx) * SCALE) + original_center_x
3515
- sy = (-(rdkit_pos.y - rdkit_cy) * SCALE) + original_center_y
3520
+ sx = ((rdkit_pos.x - rdkit_cx) * SCALE) + view_center.x()
3521
+ sy = (-(rdkit_pos.y - rdkit_cy) * SCALE) + view_center.y()
3516
3522
  new_scene_pos = QPointF(sx, sy)
3517
3523
  item.setPos(new_scene_pos)
3518
3524
  self.data.atoms[atom_id]['pos'] = new_scene_pos
@@ -3686,6 +3692,7 @@ class MainWindow(QMainWindow):
3686
3692
 
3687
3693
 
3688
3694
  def draw_molecule_3d(self, mol):
3695
+ camera_state = self.plotter.camera.copy()
3689
3696
  self.plotter.clear()
3690
3697
  conf = mol.GetConformer()
3691
3698
 
@@ -3759,6 +3766,8 @@ class MainWindow(QMainWindow):
3759
3766
  except Exception: pass
3760
3767
  self.plotter.add_point_labels(np.array(pts), labels, font_size=20, point_size=0, text_color='k', name='chiral_labels', always_visible=True, tolerance=0.01, show_points=False)
3761
3768
  except Exception as e: self.statusBar().showMessage(f"3D chiral label drawing error: {e}")
3769
+
3770
+ self.plotter.camera = camera_state
3762
3771
 
3763
3772
 
3764
3773
  def toggle_chiral_labels_display(self, checked):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moleditpy
3
- Version: 1.2.2
3
+ Version: 1.2.4
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
  Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
File without changes
File without changes