@@ -10,7 +10,7 @@ all drawn with a pure-Python QPainter backend (no OpenGL required).
1010
1111![ Fastmolwidget showing an ORTEP-style crystal structure] ( https://github.com/user-attachments/assets/7946ef73-7e74-475d-a5c6-2012243b9f77 )
1212
13- * View of a crystal structure froma CIF file with ADP ellipsoids. The control bar allows toggling display options interactively.*
13+ * View of a crystal structure from a CIF file with ADP ellipsoids. The control bar allows toggling display options interactively.*
1414
1515## Features
1616
@@ -122,12 +122,85 @@ A self-contained widget combining `MoleculeWidget` with the control bar describe
122122
123123### ` MoleculeWidget(parent=None) `
124124
125- The low-level renderer. Feed it atom data directly via ` open_molecule() ` .
125+ The low-level renderer widget. It is a plain ` QWidget ` subclass that you can drop into any layout.
126+ Provide atom data directly via ` open_molecule() ` instead of loading a file through ` MoleculeLoader ` .
126127
127- - ` open_molecule(atoms, cell=None, adps=None, keep_view=False) ` — display a new structure
128- - ` grow_molecule(atoms, cell=None, adps=None) ` — update atoms while preserving zoom/rotation
129- - ` clear() ` — remove all atoms and bonds
130- - ` set_bond_width(width) ` , ` set_background_color(color) ` , ` setLabelFont(size) ` , ` reset_view() `
128+ #### Qt Signals
129+
130+ | Signal | Signature | Emitted when |
131+ | --------| -----------| --------------|
132+ | ` atomClicked ` | ` (label: str) ` | The user clicks on an atom; ` label ` is the atom name (e.g. ` "C1" ` ) |
133+ | ` bondClicked ` | ` (label1: str, label2: str) ` | The user clicks on a bond; both atom labels are passed |
134+
135+ #### Data Methods
136+
137+ - ** ` open_molecule(atoms, cell=None, adps=None, keep_view=False) ` **
138+ Load a new set of atoms and reset (or optionally preserve) the view.
139+ - ` atoms ` — list of ` Atomtuple(label, type, x, y, z, part) ` in Cartesian coordinates (Å)
140+ - ` cell ` — optional ` (a, b, c, α, β, γ) ` tuple of unit-cell parameters (Å / °); required for ADP rendering
141+ - ` adps ` — optional ` dict ` mapping atom labels to ` (U11, U22, U33, U23, U13, U12) ` ADP tensors
142+ - ` keep_view ` — when ` True ` , the current zoom, pan, and rotation are preserved (useful for live updates)
143+
144+ - ** ` grow_molecule(atoms, cell=None, adps=None) ` **
145+ Replace the atom set while always preserving the current view.
146+ Equivalent to calling ` open_molecule(..., keep_view=True) ` .
147+
148+ - ** ` clear() ` **
149+ Remove all atoms and bonds from the display.
150+
151+ #### Display Methods
152+
153+ - ** ` show_adps(value: bool) ` **
154+ Toggle ORTEP-style ADP ellipsoid rendering. When ` False ` , atoms are drawn as isotropic spheres.
155+
156+ - ** ` show_labels(value: bool) ` **
157+ Show or hide non-hydrogen atom labels.
158+
159+ - ** ` show_hydrogens(value: bool) ` **
160+ Show or hide hydrogen / deuterium atoms and their bonds.
161+
162+ - ** ` show_round_bonds(value: bool) ` **
163+ Switch between 3D-shaded cylinder-style bonds (` True ` , default) and flat single-colour bonds (` False ` ).
164+
165+ - ** ` set_bond_width(width: int) ` **
166+ Set the stroke width for bonds in pixels (valid range: 1–15).
167+
168+ - ** ` setLabelFont(font_size: int) ` **
169+ Set the pixel size used for atom labels.
170+
171+ - ** ` set_background_color(color: QColor) ` **
172+ Change the widget background colour.
173+
174+ - ** ` reset_view() ` **
175+ Reset zoom, pan, and rotation to their defaults.
176+
177+ #### Example — feeding atom data directly
178+
179+ ``` python
180+ from fastmolwidget import MoleculeWidget
181+ from fastmolwidget.sdm import Atomtuple
182+
183+ mol = MoleculeWidget(parent = self )
184+
185+ atoms = [
186+ Atomtuple(label = " C1" , type = " C" , x = 0.0 , y = 0.0 , z = 0.0 , part = 0 ),
187+ Atomtuple(label = " O1" , type = " O" , x = 1.22 , y = 0.0 , z = 0.0 , part = 0 ),
188+ Atomtuple(label = " H1" , type = " H" , x = - 0.5 , y = 0.94 , z = 0.0 , part = 0 ),
189+ ]
190+
191+ # ADP tensors: {atom_label: (U11, U22, U33, U23, U13, U12)}
192+ adps = {
193+ " C1" : (0.02 , 0.02 , 0.02 , 0.0 , 0.0 , 0.0 ),
194+ " O1" : (0.03 , 0.03 , 0.03 , 0.0 , 0.0 , 0.0 ),
195+ }
196+
197+ cell = (5.0 , 5.0 , 5.0 , 90.0 , 90.0 , 90.0 ) # optional
198+
199+ mol.open_molecule(atoms = atoms, cell = cell, adps = adps)
200+ mol.atomClicked.connect(lambda label : print (f " Selected: { label} " ))
201+
202+ layout.addWidget(mol)
203+ ```
131204
132205### ` MoleculeLoader(widget) `
133206
0 commit comments