Skip to content

Commit 99dfd38

Browse files
authored
Add files via upload
1 parent 027b7ae commit 99dfd38

File tree

7 files changed

+34
-8
lines changed

7 files changed

+34
-8
lines changed

moleditpy/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "MoleditPy"
77

8-
version = "2.4.1"
8+
version = "2.4.3"
99

1010
license = {file = "LICENSE"}
1111

moleditpy/src/moleditpy.egg-info/PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: MoleditPy
3-
Version: 2.4.1
3+
Version: 2.4.3
44
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.
55
Author-email: HiroYokoyama <[email protected]>
66
License: GNU GENERAL PUBLIC LICENSE

moleditpy/src/moleditpy/modules/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from rdkit import Chem
1717

1818
#Version
19-
VERSION = '2.4.1'
19+
VERSION = '2.4.3'
2020

2121
ATOM_RADIUS = 18
2222
BOND_OFFSET = 3.5

moleditpy/src/moleditpy/modules/main_window.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ def open_rotate_2d_dialog(self):
532532
# --- MOVED TO main_window_edit_actions.py ---
533533
return self.main_window_edit_actions.open_rotate_2d_dialog()
534534

535+
def rotate_molecule_2d(self, angle_degrees):
536+
# --- MOVED TO main_window_edit_actions.py ---
537+
return self.main_window_edit_actions.rotate_molecule_2d(angle_degrees)
538+
535539
def draw_molecule_3d(self, mol):
536540
# --- MOVED TO main_window_view_3d.py ---
537541
return self.main_window_view_3d.draw_molecule_3d(mol)

moleditpy/src/moleditpy/modules/main_window_edit_actions.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
)
4848

4949
class Rotate2DDialog(QDialog):
50-
def __init__(self, parent=None):
50+
def __init__(self, parent=None, initial_angle=0):
5151
super().__init__(parent)
5252
self.setWindowTitle("Rotate 2D")
5353
self.setFixedWidth(300)
@@ -59,14 +59,14 @@ def __init__(self, parent=None):
5959
input_layout.addWidget(QLabel("Angle (degrees):"))
6060
self.angle_spin = QSpinBox()
6161
self.angle_spin.setRange(-360, 360)
62-
self.angle_spin.setValue(45)
62+
self.angle_spin.setValue(initial_angle)
6363
input_layout.addWidget(self.angle_spin)
6464
layout.addLayout(input_layout)
6565

6666
# Slider
6767
self.slider = QSlider(Qt.Orientation.Horizontal)
6868
self.slider.setRange(-180, 180)
69-
self.slider.setValue(45)
69+
self.slider.setValue(initial_angle)
7070
self.slider.setTickPosition(QSlider.TickPosition.TicksBelow)
7171
self.slider.setTickInterval(15)
7272
layout.addWidget(self.slider)
@@ -612,9 +612,14 @@ def update_edit_menu_actions(self):
612612

613613
def open_rotate_2d_dialog(self):
614614
"""2D回転ダイアログを開く"""
615-
dialog = Rotate2DDialog(self)
615+
# Initialize last_rotation_angle if not present
616+
if not hasattr(self, 'last_rotation_angle'):
617+
self.last_rotation_angle = 0
618+
619+
dialog = Rotate2DDialog(self, initial_angle=self.last_rotation_angle)
616620
if dialog.exec() == QDialog.DialogCode.Accepted:
617621
angle = dialog.get_angle()
622+
self.last_rotation_angle = angle # Remember for next time
618623
self.rotate_molecule_2d(angle)
619624

620625
def rotate_molecule_2d(self, angle_degrees):
@@ -663,6 +668,8 @@ def rotate_molecule_2d(self, angle_degrees):
663668
self.push_undo_state()
664669
self.statusBar().showMessage(f"Rotated {len(target_atoms)} atoms by {angle_degrees} degrees.")
665670
self.scene.update()
671+
# Force full redraw as requested
672+
self.scene.update_all_items()
666673

667674
except Exception as e:
668675
print(f"Error rotating molecule: {e}")

moleditpy/src/moleditpy/modules/main_window_main_init.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ def init_menu_bar(self):
992992
edit_menu.addSeparator()
993993

994994
rotate_2d_action = QAction("Rotate 2D...", self)
995+
rotate_2d_action.setShortcut(QKeySequence("Ctrl+R"))
995996
rotate_2d_action.triggered.connect(self.open_rotate_2d_dialog)
996997
edit_menu.addAction(rotate_2d_action)
997998

@@ -1054,7 +1055,7 @@ def init_menu_bar(self):
10541055

10551056
reset_3d_view_action = QAction("Reset 3D View", self)
10561057
reset_3d_view_action.triggered.connect(lambda: self.plotter.reset_camera() if hasattr(self, 'plotter') else None)
1057-
reset_3d_view_action.setShortcut(QKeySequence("Ctrl+R"))
1058+
reset_3d_view_action.setShortcut(QKeySequence("Ctrl+Shift+R"))
10581059
view_menu.addAction(reset_3d_view_action)
10591060

10601061
view_menu.addSeparator()

moleditpy/src/moleditpy/modules/molecule_scene.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ def __init__(self, data, window):
116116
self.reinitialize_items()
117117

118118

119+
def update_connected_bonds(self, atoms):
120+
"""指定された原子リストに接続する全ての結合の位置を更新する"""
121+
bonds_to_update = set()
122+
for atom in atoms:
123+
if hasattr(atom, 'bonds'):
124+
bonds_to_update.update(atom.bonds)
125+
126+
for bond in bonds_to_update:
127+
try:
128+
if not sip_isdeleted_safe(bond):
129+
bond.update_position()
130+
except Exception:
131+
continue
132+
119133
def update_all_items(self):
120134
"""全てのアイテムを強制的に再描画する"""
121135
for item in self.items():

0 commit comments

Comments
 (0)