picogl.examples.utils.molecular_glut_window =========================================== .. py:module:: picogl.examples.utils.molecular_glut_window .. autoapi-nested-parse:: Shared GLUT molecular viewer: atoms as points, bonds as lines. Used by ``modern_molecular_viewer.py`` and ``modern_pdb_picogl_simple.py``. Never draws atom positions through ObjectRenderer / GL_TRIANGLES (that produces triangle soup). Attributes ---------- .. autoapisummary:: picogl.examples.utils.molecular_glut_window._EXAMPLES_DIR picogl.examples.utils.molecular_glut_window._PICOGL_ROOT picogl.examples.utils.molecular_glut_window._ELMO_ROOT_CANDIDATES picogl.examples.utils.molecular_glut_window._ELMO_ROOT picogl.examples.utils.molecular_glut_window._ELMO_GLSL picogl.examples.utils.molecular_glut_window._ATOM_POINT_SIZE picogl.examples.utils.molecular_glut_window._MOLECULAR_GLSL_DIR Classes ------- .. autoapisummary:: picogl.examples.utils.molecular_glut_window.MolecularViewer picogl.examples.utils.molecular_glut_window.MolecularRenderWindow Functions --------- .. autoapisummary:: picogl.examples.utils.molecular_glut_window._molecular_shader_directory picogl.examples.utils.molecular_glut_window._mesh_vertex_count picogl.examples.utils.molecular_glut_window._build_mesh_vao picogl.examples.utils.molecular_glut_window._enable_blending Module Contents --------------- .. py:data:: _EXAMPLES_DIR .. py:data:: _PICOGL_ROOT .. py:data:: _ELMO_ROOT_CANDIDATES .. py:data:: _ELMO_ROOT .. py:data:: _ELMO_GLSL .. py:data:: _ATOM_POINT_SIZE :value: 6.0 .. py:data:: _MOLECULAR_GLSL_DIR .. py:function:: _molecular_shader_directory() -> pathlib.Path Prefer ElMo molecular GLSL tree when present; else PicoGL shader src. .. py:class:: MolecularViewer(pdb_path: str) Load a PDB and expose PicoGL meshes + optional molecular shaders. .. py:attribute:: pdb_path .. py:attribute:: pdb_loader :value: None .. py:attribute:: atom_data :value: None .. py:attribute:: bond_data :value: None .. py:attribute:: _center .. py:attribute:: _extent :value: 50.0 .. py:attribute:: shader_registry .. py:attribute:: _shaders_loaded :value: False .. py:method:: ensure_shaders_loaded() -> None Compile shaders once an OpenGL context exists. .. py:method:: _load_structure() -> None .. py:method:: _load_shaders() -> None .. py:method:: create_atom_mesh() -> picogl.renderer.MeshData .. py:method:: create_bond_mesh() -> picogl.renderer.MeshData .. py:method:: export_molviewspec(output_path: str) -> None .. py:function:: _mesh_vertex_count(mesh: picogl.renderer.MeshData) -> int .. py:function:: _build_mesh_vao(mesh: picogl.renderer.MeshData) -> picogl.backend.modern.core.vertex.array.object.VertexArrayObject Upload positions + colours for non-indexed glDrawArrays. .. py:function:: _enable_blending() -> None Soft circular points need blending for the smoothstep rim. .. py:class:: MolecularRenderWindow(molecular_viewer: MolecularViewer, **kwargs) Bases: :py:obj:`picogl.ui.backend.glut.window.object.RenderWindow` GLUT window that draws atoms as points and bonds as lines. .. py:attribute:: molecular_viewer .. py:attribute:: atom_mesh .. py:attribute:: bond_mesh .. py:attribute:: atom_vao :type: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None :value: None .. py:attribute:: bond_vao :type: picogl.backend.modern.core.vertex.array.object.VertexArrayObject | None :value: None .. py:attribute:: atom_point_shader :type: picogl.backend.modern.core.shader.program.ShaderProgram | None :value: None .. py:attribute:: _gl_ready :value: False .. py:attribute:: zoom_distance .. py:attribute:: distance_threshold .. py:method:: initializeGL() -> None Load bond shaders only; do not upload atom mesh for triangle drawing. .. py:method:: initialize() -> None .. py:method:: run() -> None run .. py:method:: _load_atom_point_shader() -> None Circular point sprites (gl_PointCoord discard + soft edge). .. py:method:: _setup_molecular_rendering() -> None .. py:method:: paintGL() -> None Clear, then bonds (lines) and atoms (points) — never triangles. .. py:method:: _bond_shader() Prefer ObjectRenderer tu01; fall back to ElMo bonds if needed. .. py:method:: _bind_uniforms(shader, kind: str | None) -> None .. py:method:: _render_atoms() -> None Draw atoms as smooth circular GL_POINTS. .. py:method:: _render_bonds() -> None