moleditpy 1.2.3__tar.gz → 1.2.5__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.3
3
+ Version: 1.2.5
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.3"
8
+ version = "1.2.5"
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.3'
14
+ VERSION = '1.2.5'
15
15
 
16
16
  print("-----------------------------------------------------")
17
17
  print("MoleditPy — A Python-based molecular editing software")
@@ -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
@@ -3068,6 +3070,7 @@ class MainWindow(QMainWindow):
3068
3070
  try:
3069
3071
  self.current_mol = Chem.Mol(loaded_data['mol_3d'])
3070
3072
  self.draw_molecule_3d(self.current_mol)
3073
+ self.plotter.reset_camera()
3071
3074
  self.analysis_action.setEnabled(True)
3072
3075
  self.optimize_3d_button.setEnabled(True)
3073
3076
  self.export_button.setEnabled(True)
@@ -3413,6 +3416,7 @@ class MainWindow(QMainWindow):
3413
3416
  self.set_state_from_data(loaded_data)
3414
3417
  self.statusBar().showMessage(f"Project loaded from {file_path}")
3415
3418
  self.reset_undo_stack()
3419
+ self.fit_to_view()
3416
3420
  except Exception as e: self.statusBar().showMessage(f"Error loading project file: {e}")
3417
3421
 
3418
3422
  def save_as_mol(self):
@@ -3486,6 +3490,7 @@ class MainWindow(QMainWindow):
3486
3490
 
3487
3491
  try:
3488
3492
  # 安定版:原子IDとRDKit座標の確実なマッピング
3493
+ view_center = self.view_2d.mapToScene(self.view_2d.viewport().rect().center())
3489
3494
  new_positions_map = {}
3490
3495
  AllChem.Compute2DCoords(mol)
3491
3496
  conf = mol.GetConformer()
@@ -3501,8 +3506,8 @@ class MainWindow(QMainWindow):
3501
3506
  self.statusBar().showMessage("Error: Atom items not found for optimized atoms."); return
3502
3507
 
3503
3508
  # 元の図形の中心を維持
3504
- original_center_x = sum(item.pos().x() for item in target_atom_items) / len(target_atom_items)
3505
- original_center_y = sum(item.pos().y() for item in target_atom_items) / len(target_atom_items)
3509
+ #original_center_x = sum(item.pos().x() for item in target_atom_items) / len(target_atom_items)
3510
+ #original_center_y = sum(item.pos().y() for item in target_atom_items) / len(target_atom_items)
3506
3511
 
3507
3512
  positions = list(new_positions_map.values())
3508
3513
  rdkit_cx = sum(p.x for p in positions) / len(positions)
@@ -3514,8 +3519,8 @@ class MainWindow(QMainWindow):
3514
3519
  for atom_id, rdkit_pos in new_positions_map.items():
3515
3520
  if atom_id in self.data.atoms:
3516
3521
  item = self.data.atoms[atom_id]['item']
3517
- sx = ((rdkit_pos.x - rdkit_cx) * SCALE) + original_center_x
3518
- sy = (-(rdkit_pos.y - rdkit_cy) * SCALE) + original_center_y
3522
+ sx = ((rdkit_pos.x - rdkit_cx) * SCALE) + view_center.x()
3523
+ sy = (-(rdkit_pos.y - rdkit_cy) * SCALE) + view_center.y()
3519
3524
  new_scene_pos = QPointF(sx, sy)
3520
3525
  item.setPos(new_scene_pos)
3521
3526
  self.data.atoms[atom_id]['pos'] = new_scene_pos
@@ -3689,6 +3694,7 @@ class MainWindow(QMainWindow):
3689
3694
 
3690
3695
 
3691
3696
  def draw_molecule_3d(self, mol):
3697
+ camera_state = self.plotter.camera.copy()
3692
3698
  self.plotter.clear()
3693
3699
  conf = mol.GetConformer()
3694
3700
 
@@ -3762,6 +3768,8 @@ class MainWindow(QMainWindow):
3762
3768
  except Exception: pass
3763
3769
  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)
3764
3770
  except Exception as e: self.statusBar().showMessage(f"3D chiral label drawing error: {e}")
3771
+
3772
+ self.plotter.camera = camera_state
3765
3773
 
3766
3774
 
3767
3775
  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.3
3
+ Version: 1.2.5
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