unit-cell-gui 0.2.0__tar.gz → 0.2.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 (28) hide show
  1. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/CHANGELOG.md +14 -0
  2. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/CITATION.cff +2 -2
  3. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/MANIFEST.in +1 -0
  4. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/PKG-INFO +156 -151
  5. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/README.md +5 -0
  6. unit_cell_gui-0.2.1/RELEASE_NOTES_0.2.1.md +51 -0
  7. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/THIRD_PARTY_NOTICES.txt +1 -1
  8. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/pyproject.toml +1 -1
  9. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/setup.cfg +4 -4
  10. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/__init__.py +9 -1
  11. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/opengl_viewer.py +168 -43
  12. unit_cell_gui-0.2.1/src/unit_cell_gui/qt_config.py +47 -0
  13. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui.egg-info/PKG-INFO +156 -151
  14. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui.egg-info/SOURCES.txt +3 -0
  15. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/tests/test_unit_cell_gui.py +32 -1
  16. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/LICENSE +0 -0
  17. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/gl_geometry.py +0 -0
  18. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/hatching.py +0 -0
  19. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/models.py +0 -0
  20. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/py.typed +0 -0
  21. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/render_geometry.py +0 -0
  22. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/view_helpers.py +0 -0
  23. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui/viewer.py +0 -0
  24. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui.egg-info/dependency_links.txt +0 -0
  25. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui.egg-info/requires.txt +0 -0
  26. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/src/unit_cell_gui.egg-info/top_level.txt +0 -0
  27. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/tests/test_gl_geometry.py +0 -0
  28. {unit_cell_gui-0.2.0 → unit_cell_gui-0.2.1}/tests/test_render_geometry.py +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 - 2026-09-15
4
+
5
+ ### Fixed
6
+
7
+ - Configure one global OpenGL 3.3 surface format and enable shared OpenGL
8
+ contexts before `QApplication` construction. This prevents stale top-level
9
+ composition after moving or maximising a host window on mixed-DPI screens.
10
+ - Release GPU resources when Qt destroys a viewer context and rebuild every
11
+ buffer and shader when a new context is initialised.
12
+ - Reduce stair-stepping with 8-sample multisampling and pixel-coverage
13
+ antialiasing for polyhedron edges, hatching, bonds and atom contours.
14
+ - Double the period of the dashed unit-cell box while preserving the 2:1
15
+ dash-to-gap ratio.
16
+
3
17
  ## 0.2.0 - 2026-09-14
4
18
 
5
19
  ### Changed
@@ -8,7 +8,7 @@ authors:
8
8
  repository-code: https://github.com/ofussr/unit-cell-gui
9
9
  url: https://github.com/ofussr/unit-cell-gui
10
10
  orcid: https://orcid.org/0000-0002-5571-8525
11
- version: 0.2.0
12
- date-released: 2026-09-14
11
+ version: 0.2.1
12
+ date-released: 2026-09-15
13
13
  doi: 10.5281/zenodo.22714946
14
14
  license: MIT
@@ -2,5 +2,6 @@ include CHANGELOG.md
2
2
  include CITATION.cff
3
3
  include LICENSE
4
4
  include README.md
5
+ include RELEASE_NOTES_0.2.1.md
5
6
  include THIRD_PARTY_NOTICES.txt
6
7
  recursive-include tests *.py
@@ -1,151 +1,156 @@
1
- Metadata-Version: 2.4
2
- Name: unit-cell-gui
3
- Version: 0.2.0
4
- Summary: PySide6 widget for rendering caller-supplied unit-cell scenes
5
- Author-email: Mikhail Mirushchenko <miruschenko98@gmail.com>
6
- License-Expression: MIT
7
- Classifier: Development Status :: 3 - Alpha
8
- Classifier: Environment :: X11 Applications :: Qt
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3 :: Only
11
- Requires-Python: >=3.10
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: numpy>=1.24
15
- Requires-Dist: PySide6-Essentials<7,>=6.8
16
- Requires-Dist: PyOpenGL<4,>=3.1.7
17
- Dynamic: license-file
18
-
19
- # unit-cell-gui
20
-
21
- `unit-cell-gui` is a reusable PySide6 widget that draws complete unit-cell
22
- scenes supplied by another program. It does not read CIF files, expand
23
- symmetry, resolve atomic positions, infer bonds, construct polyhedra or
24
- calculate diffraction.
25
-
26
- The caller supplies ready Cartesian coordinates and presentation data:
27
-
28
- - atoms and their styled occupancy components;
29
- - bond indices;
30
- - unit-cell vertices and edges;
31
- - three basis vectors;
32
- - optional polyhedron vertices, polygon faces and centres.
33
-
34
- The package owns only display behaviour: camera projection, OpenGL depth buffering,
35
- left-button rotation, right-button panning, wheel zoom, occupancy sectors,
36
- colour and black-and-white drawing, and polyhedron hatching. Quadrilateral
37
- hatching uses one intact polygon with `2x + 1` full parallel strokes. Hatch
38
- directions on farther faces are refolded through real shared edges.
39
-
40
- <table>
41
- <tr>
42
- <td align="center" width="50%">
43
- <img src="https://raw.githubusercontent.com/ofussr/unit-cell-gui/main/docs/images/color-view.png" alt="Color view" width="100%">
44
- <br>
45
- <sub>Color view</sub>
46
- </td>
47
- <td align="center" width="50%">
48
- <img src="https://raw.githubusercontent.com/ofussr/unit-cell-gui/main/docs/images/hatched-view.png" alt="Hatched view" width="100%">
49
- <br>
50
- <sub>Hatched view</sub>
51
- </td>
52
- </tr>
53
- </table>
54
-
55
- ## Installation
56
-
57
- ```bash
58
- python -m pip install unit-cell-gui
59
- ```
60
-
61
- Python 3.10 or newer, NumPy, PySide6 Essentials and PyOpenGL are required. The renderer requests an OpenGL 3.3 core-profile context.
62
-
63
- ## Basic use
64
-
65
- ```python
66
- import numpy as np
67
- from PySide6.QtWidgets import QApplication
68
- from unit_cell_gui import Atom, AtomComponent, DisplayOptions, Scene, UnitCellViewer
69
-
70
- silicon = AtomComponent(
71
- key="Si:Si1", label="Si1", element="Si",
72
- occupancy=1.0, colour="#f0c8a0", radius=0.30,
73
- )
74
- scene = Scene(
75
- atoms=(Atom("Si:Si1", "Si1", (silicon,)),),
76
- atom_centers=np.array([[0.0, 0.0, 0.0]]),
77
- bonds=np.empty((0, 2), dtype=int),
78
- cell_vertices=np.array([
79
- [x, y, z]
80
- for x in (-1.0, 1.0)
81
- for y in (-1.0, 1.0)
82
- for z in (-1.0, 1.0)
83
- ]),
84
- cell_edges=np.array([
85
- [0, 1], [0, 2], [0, 4], [1, 3], [1, 5], [2, 3],
86
- [2, 6], [3, 7], [4, 5], [4, 6], [5, 7], [6, 7],
87
- ]),
88
- basis_vectors=np.eye(3),
89
- base_radius=2.0,
90
- )
91
-
92
- app = QApplication([])
93
- viewer = UnitCellViewer()
94
- viewer.set_scene(scene)
95
- viewer.set_display_options(DisplayOptions(show_polyhedra=False))
96
- viewer.show()
97
- app.exec()
98
- ```
99
-
100
- `Scene` copies its arrays and makes them read-only. Later changes in the caller
101
- therefore cannot alter an already submitted scene.
102
-
103
- ## Orientation synchronization
104
-
105
- `orientation` is a 3 by 3 world-to-camera matrix. For column vectors the
106
- camera coordinate is `orientation @ world`; the renderer's row arrays use the
107
- equivalent `world @ orientation.T`.
108
-
109
- Programmatic changes are silent by default:
110
-
111
- ```python
112
- viewer.set_orientation(matrix, emit=False)
113
- ```
114
-
115
- Interactive rotation emits the complete new matrix through
116
- `orientation_changed`. Connect that signal to a pole figure or another view,
117
- then send changes from the other view back with silent `set_orientation` calls.
118
- This supports bidirectional synchronization without a signal loop.
119
-
120
- ```python
121
- viewer.orientation_changed.connect(update_other_view)
122
- other_view.orientation_changed.connect(
123
- lambda matrix: viewer.set_orientation(matrix, emit=False)
124
- )
125
- ```
126
-
127
- Set `rotation_enabled=False` when an application temporarily forbids left-button
128
- rotation. Panning and zoom remain available. Polyhedra are hidden by default
129
- and must be enabled with `show_polyhedra=True`.
130
-
131
- Per-position colours, visibility and opaque-polyhedron selections are replaced
132
- atomically with `viewer.set_style_overrides(StyleOverrides(...))`. The widget
133
- copies these mappings, so the host can keep its own independent UI state.
134
-
135
-
136
- ## Renderer compatibility
137
-
138
- `UnitCellViewer` and the legacy alias `CrystalCanvas` now use the OpenGL
139
- renderer internally. Existing construction, scene submission, display-option,
140
- style-override, orientation-synchronization and interaction calls remain the
141
- same. `OpenGLUnitCellViewer` remains available as an explicit name and refers
142
- to the same renderer class.
143
-
144
-
145
- ## How to cite
146
-
147
- If you use `unit-cell-gui` in academic work, please cite the Zenodo record:
148
-
149
- [![DOI](https://zenodo.org/badge/1366573933.svg)](https://zenodo.org/badge/latestdoi/1366573933)
150
-
151
- You can also use the metadata provided in [`CITATION.cff`](CITATION.cff).
1
+ Metadata-Version: 2.4
2
+ Name: unit-cell-gui
3
+ Version: 0.2.1
4
+ Summary: PySide6 widget for rendering caller-supplied unit-cell scenes
5
+ Author-email: Mikhail Mirushchenko <miruschenko98@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Environment :: X11 Applications :: Qt
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy>=1.24
15
+ Requires-Dist: PySide6-Essentials<7,>=6.8
16
+ Requires-Dist: PyOpenGL<4,>=3.1.7
17
+ Dynamic: license-file
18
+
19
+ # unit-cell-gui
20
+
21
+ `unit-cell-gui` is a reusable PySide6 widget that draws complete unit-cell
22
+ scenes supplied by another program. It does not read CIF files, expand
23
+ symmetry, resolve atomic positions, infer bonds, construct polyhedra or
24
+ calculate diffraction.
25
+
26
+ The caller supplies ready Cartesian coordinates and presentation data:
27
+
28
+ - atoms and their styled occupancy components;
29
+ - bond indices;
30
+ - unit-cell vertices and edges;
31
+ - three basis vectors;
32
+ - optional polyhedron vertices, polygon faces and centres.
33
+
34
+ The package owns only display behaviour: camera projection, OpenGL depth buffering,
35
+ left-button rotation, right-button panning, wheel zoom, occupancy sectors,
36
+ colour and black-and-white drawing, and polyhedron hatching. Quadrilateral
37
+ hatching uses one intact polygon with `2x + 1` full parallel strokes. Hatch
38
+ directions on farther faces are refolded through real shared edges.
39
+
40
+ <table>
41
+ <tr>
42
+ <td align="center" width="50%">
43
+ <img src="https://raw.githubusercontent.com/ofussr/unit-cell-gui/main/docs/images/color-view.png" alt="Color view" width="100%">
44
+ <br>
45
+ <sub>Color view</sub>
46
+ </td>
47
+ <td align="center" width="50%">
48
+ <img src="https://raw.githubusercontent.com/ofussr/unit-cell-gui/main/docs/images/hatched-view.png" alt="Hatched view" width="100%">
49
+ <br>
50
+ <sub>Hatched view</sub>
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ python -m pip install unit-cell-gui
59
+ ```
60
+
61
+ Python 3.10 or newer, NumPy, PySide6 Essentials and PyOpenGL are required. The renderer requests an OpenGL 3.3 core-profile context.
62
+
63
+ Import `UnitCellViewer` or `CrystalCanvas` before constructing `QApplication`.
64
+ This lets the package establish one shared OpenGL format for every viewer and
65
+ keeps top-level Qt composition stable across screen and DPI changes. The basic
66
+ example below already uses this order.
67
+
68
+ ## Basic use
69
+
70
+ ```python
71
+ import numpy as np
72
+ from PySide6.QtWidgets import QApplication
73
+ from unit_cell_gui import Atom, AtomComponent, DisplayOptions, Scene, UnitCellViewer
74
+
75
+ silicon = AtomComponent(
76
+ key="Si:Si1", label="Si1", element="Si",
77
+ occupancy=1.0, colour="#f0c8a0", radius=0.30,
78
+ )
79
+ scene = Scene(
80
+ atoms=(Atom("Si:Si1", "Si1", (silicon,)),),
81
+ atom_centers=np.array([[0.0, 0.0, 0.0]]),
82
+ bonds=np.empty((0, 2), dtype=int),
83
+ cell_vertices=np.array([
84
+ [x, y, z]
85
+ for x in (-1.0, 1.0)
86
+ for y in (-1.0, 1.0)
87
+ for z in (-1.0, 1.0)
88
+ ]),
89
+ cell_edges=np.array([
90
+ [0, 1], [0, 2], [0, 4], [1, 3], [1, 5], [2, 3],
91
+ [2, 6], [3, 7], [4, 5], [4, 6], [5, 7], [6, 7],
92
+ ]),
93
+ basis_vectors=np.eye(3),
94
+ base_radius=2.0,
95
+ )
96
+
97
+ app = QApplication([])
98
+ viewer = UnitCellViewer()
99
+ viewer.set_scene(scene)
100
+ viewer.set_display_options(DisplayOptions(show_polyhedra=False))
101
+ viewer.show()
102
+ app.exec()
103
+ ```
104
+
105
+ `Scene` copies its arrays and makes them read-only. Later changes in the caller
106
+ therefore cannot alter an already submitted scene.
107
+
108
+ ## Orientation synchronization
109
+
110
+ `orientation` is a 3 by 3 world-to-camera matrix. For column vectors the
111
+ camera coordinate is `orientation @ world`; the renderer's row arrays use the
112
+ equivalent `world @ orientation.T`.
113
+
114
+ Programmatic changes are silent by default:
115
+
116
+ ```python
117
+ viewer.set_orientation(matrix, emit=False)
118
+ ```
119
+
120
+ Interactive rotation emits the complete new matrix through
121
+ `orientation_changed`. Connect that signal to a pole figure or another view,
122
+ then send changes from the other view back with silent `set_orientation` calls.
123
+ This supports bidirectional synchronization without a signal loop.
124
+
125
+ ```python
126
+ viewer.orientation_changed.connect(update_other_view)
127
+ other_view.orientation_changed.connect(
128
+ lambda matrix: viewer.set_orientation(matrix, emit=False)
129
+ )
130
+ ```
131
+
132
+ Set `rotation_enabled=False` when an application temporarily forbids left-button
133
+ rotation. Panning and zoom remain available. Polyhedra are hidden by default
134
+ and must be enabled with `show_polyhedra=True`.
135
+
136
+ Per-position colours, visibility and opaque-polyhedron selections are replaced
137
+ atomically with `viewer.set_style_overrides(StyleOverrides(...))`. The widget
138
+ copies these mappings, so the host can keep its own independent UI state.
139
+
140
+
141
+ ## Renderer compatibility
142
+
143
+ `UnitCellViewer` and the legacy alias `CrystalCanvas` now use the OpenGL
144
+ renderer internally. Existing construction, scene submission, display-option,
145
+ style-override, orientation-synchronization and interaction calls remain the
146
+ same. `OpenGLUnitCellViewer` remains available as an explicit name and refers
147
+ to the same renderer class.
148
+
149
+
150
+ ## How to cite
151
+
152
+ If you use `unit-cell-gui` in academic work, please cite the Zenodo record:
153
+
154
+ [![DOI](https://zenodo.org/badge/1366573933.svg)](https://zenodo.org/badge/latestdoi/1366573933)
155
+
156
+ You can also use the metadata provided in [`CITATION.cff`](CITATION.cff).
@@ -42,6 +42,11 @@ python -m pip install unit-cell-gui
42
42
 
43
43
  Python 3.10 or newer, NumPy, PySide6 Essentials and PyOpenGL are required. The renderer requests an OpenGL 3.3 core-profile context.
44
44
 
45
+ Import `UnitCellViewer` or `CrystalCanvas` before constructing `QApplication`.
46
+ This lets the package establish one shared OpenGL format for every viewer and
47
+ keeps top-level Qt composition stable across screen and DPI changes. The basic
48
+ example below already uses this order.
49
+
45
50
  ## Basic use
46
51
 
47
52
  ```python
@@ -0,0 +1,51 @@
1
+ # unit-cell-gui 0.2.1
2
+
3
+ ## Release description
4
+
5
+ This maintenance release improves the OpenGL backend introduced in version
6
+ 0.2.0 without changing the public viewer API.
7
+
8
+ ### Fixed
9
+
10
+ - Fixed stale or black host-window areas after maximising the application or
11
+ moving it between screens with different DPI settings.
12
+ - Configured one global OpenGL 3.3 surface format and shared contexts before
13
+ `QApplication` construction.
14
+ - Added safe GPU-resource cleanup and complete buffer and shader rebuilding
15
+ when Qt recreates an OpenGL context.
16
+ - Reduced stair-stepping on polyhedron edges, hatching, bonds and atom contours
17
+ using 8-sample multisampling and pixel-coverage antialiasing.
18
+
19
+ ### Changed
20
+
21
+ - Increased the spacing of the dashed unit-cell box while preserving the
22
+ dash-to-gap ratio.
23
+
24
+ Scene models, display options, style overrides, camera controls, orientation
25
+ synchronisation and the `UnitCellViewer` and `CrystalCanvas` names remain
26
+ compatible with version 0.2.0.
27
+
28
+ ## Перевод
29
+
30
+ Это исправляющий выпуск OpenGL-отрисовщика, появившегося в версии 0.2.0.
31
+ Публичный интерфейс просмотрщика не изменён.
32
+
33
+ ### Исправлено
34
+
35
+ - Устранены чёрные или не обновляющиеся области окна после разворачивания
36
+ приложения либо переноса между экранами с разным масштабированием.
37
+ - До создания `QApplication` теперь задаются единый формат OpenGL 3.3 и общие
38
+ контексты.
39
+ - Добавлено безопасное освобождение ресурсов видеокарты и полное пересоздание
40
+ буферов и шейдеров при пересоздании OpenGL-контекста средствами Qt.
41
+ - Уменьшены «лесенки» на рёбрах полиэдров, штриховке, связях и контурах атомов
42
+ благодаря восьмикратному мультисэмплингу и сглаживанию по покрытию пикселя.
43
+
44
+ ### Изменено
45
+
46
+ - Увеличен период пунктира рамки элементарной ячейки с сохранением отношения
47
+ длины штриха к пробелу.
48
+
49
+ Модели сцен, параметры отображения, индивидуальные стили, управление камерой,
50
+ синхронизация ориентации и имена `UnitCellViewer` и `CrystalCanvas` совместимы
51
+ с версией 0.2.0.
@@ -62,7 +62,7 @@ Notes
62
62
  -----
63
63
 
64
64
  The version ranges above describe the direct runtime dependencies declared by
65
- unit-cell-gui 0.2.0. Transitive dependencies may vary depending on the
65
+ unit-cell-gui 0.2.1. Transitive dependencies may vary depending on the
66
66
  platform and the versions selected by the Python package installer.
67
67
 
68
68
  This file does not replace the license files supplied by third-party packages.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "unit-cell-gui"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "PySide6 widget for rendering caller-supplied unit-cell scenes"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -8,10 +8,16 @@ from .hatching import (
8
8
  quadrilateral_hatch_line_count,
9
9
  )
10
10
  from .models import Atom, AtomComponent, DisplayOptions, Polyhedron, Scene, StyleOverrides
11
- __version__ = "0.2.0"
11
+ __version__ = "0.2.1"
12
12
 
13
13
 
14
14
  def __getattr__(name):
15
+ if name in {"configure_qt_opengl", "preferred_surface_format"}:
16
+ from .qt_config import configure_qt_opengl, preferred_surface_format
17
+ return {
18
+ "configure_qt_opengl": configure_qt_opengl,
19
+ "preferred_surface_format": preferred_surface_format,
20
+ }[name]
15
21
  if name in {"CrystalCanvas", "UnitCellViewer", "OpenGLUnitCellViewer", "screen_drag_orientation"}:
16
22
  from .viewer import CrystalCanvas, UnitCellViewer, screen_drag_orientation
17
23
  if name == "OpenGLUnitCellViewer":
@@ -34,10 +40,12 @@ __all__ = [
34
40
  "Scene",
35
41
  "StyleOverrides",
36
42
  "UnitCellViewer",
43
+ "configure_qt_opengl",
37
44
  "face_hatch_segments",
38
45
  "hatch_division_count",
39
46
  "occupancy_fractions",
40
47
  "propagated_hatch_directions",
41
48
  "quadrilateral_hatch_line_count",
49
+ "preferred_surface_format",
42
50
  "screen_drag_orientation",
43
51
  ]