Conversation
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
…ion state, Moved things into new struct Dataset which represents one active dataset. The goal here is to transition into supporting many active datasets open at once.
|
@copilot I did not like how you put the frame cache inside of loader. I removed that. The loader should conceptually just focus on providing appropriate loaders for file formats. I also made substantian changes to the ApplicationState structure where I moved many portions of the state into a new struct called Dataset which is supposed to represent Dataset specific states. The idea is to transition into supporting multiple open datasets, which are exposed as tabs within the main view of the application where the user can swap between these tabs. The default behaviour when loading a new system (either by dropping a file on the application or by going through the menu) is to open this dataset in a new tab. Notice that some state data is not dataset specific and lives above it. I want you to make sure this runs. For now its sufficient that anything that lives outside of the scope of the dataset is only applied to the first loaded dataset. Representations are going to be dataset specific for example, and when the tab changes to study another dataset, the representations defined for that dataset should be shown in the representation window. Same for ramachandran and other things for now. Godspeed Ai agent, you're going to need it! |
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Addressed in 391bcd9. I updated the stale ApplicationState accesses to use |
|
@copilot Workspaces can be put aside for the moment, but it should default to only storing / loading the first dataset. This issue with this refactor is that alot of the supporting procedures where designed when there was only a single dataset supported. Therefore most of these procedures (which deals with loading and unloading of data, systems, trajectories) need to be redesigned. The logical workflow is this: Make a full pass over main.cpp, viamd.h and viamd.cpp and try to make sure that the loading and unloading of datasets work. |
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Addressed in 9180ef1. Here's a summary of what was fixed: Compile errors fixed
Dataset loading/unloading redesigned
Bitfield memory safety fixed
Stale |
|
@copilot I have not looked over this yet, but can you go over the procedures in viamd.h/cpp and main.cpp and ensure that they operate on the correct level state vs dataset. Many of them were targeting state but after this refactor should target a specific dataset instead. For example to clear all representations, this should target a dataset and not the complete system state. |
…natures Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Done in 6a88a97. Every procedure was audited and updated: Pure dataset-level (now take
Mixed (now take both
Legitimately state-level (unchanged): All call sites in |
|
@copilot I'm posting some new design directions for VIAMD, try to to incorporate as fully as possible: VIAMD Multi-Dataset Architecture (Agent Summary)This document describes the core architecture principles for supporting multiple datasets and views in VIAMD. It is intended for implementation agents and should be treated as the canonical conceptual model. The goal is to support multiple datasets, multiple views, and view-scoped analysis without duplicating large simulation data. Core Principles
Core ObjectsWorkspaceRoot container for the application session. Responsibilities:
Conceptual structure: Workspace SystemRepresents a single molecular dataset. Contains: System Systems are pure data containers and must not store visualization state. TopologyStatic molecular structure. Examples of contents:
TrajectoryTime-dependent coordinates. Contains:
Trajectories may be very large and must be handled efficiently. ViewA visual and analytical context. Defines:
Views reference systems but do not own them. Conceptual structure: View Views should be cheap to create and duplicate. TimelineControls the current frame displayed in a view. Typical fields:
Timeline may be:
RepresentationDefines how a subset of a system is rendered. Structure: Representation Examples of styles:
Representations belong to views because rendering may differ between views. SelectionDefines a subset of atoms within a system. Selections are defined by expressions such as: protein Selections are always evaluated relative to a specific system. AnalysisRepresents a computed property. Examples:
Structure: Analysis Analyses run on all systems visible in the scoped view. ResultsStores computed outputs from analyses. Results are typically stored per system. Example: Results Possible result types:
PlotVisualization of analysis results. Plots must not compute data themselves. Instead they reference analyses and visualize their results. Structure: Plot Ownership RulesWorkspace owns:
Views reference:
Representations reference:
Analyses reference:
Large data structures (trajectories, topology) must never be duplicated. Analysis Scope RuleThe analysis scope is defined by the view. When an analysis runs:
Hidden systems must not be included in calculations. Naming GuidelinesUse domain-level names, not UI names. Correct examples: Workspace Avoid: Window The UI layer should map onto these domain concepts separately. Canonical ModelWorkspace The key rule: Views define analysis scope. This keeps visualization and computation aligned with the user’s mental model. |
… from view context Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
... Incorporated in bf8fc34. Here's what was implemented from the architecture document:
~330 call sites in The full Workspace/View/Analysis/Plot decoupling as described in the document is a longer-term effort — this commit establishes the foundational |
This change removes viamd's use of
md_frame_cache, updates the surrounding trajectory/state plumbing to match the newDataset-owned application state layout, fixes the initialization, deinitialization, and loading lifecycle for datasets, enforces explicit dataset ownership across all supporting procedures, and introduces the foundationalSystemstruct from the new multi-dataset architecture.Trajectory cache refactor
md_frame_cacheusage.loader.cpp.Loader cleanup
Dataset-owned state integration
main.cpp,viamd.cpp, and dataset-related components to usecurrent_dataset(state)for dataset-specific data.workspace_path,Dataset::sys_path, andDataset::traj_path.Dataset loading/unloading lifecycle
load_dataset_from_fileso that loading a new topology into an already-populated dataset creates a newDataset(tab) and switchescurrent_idxto it. Loading into an empty slot reuses it. Trajectory-only loading requires topology to already be present in the current dataset.create_new_datasetwhich was erroneously initialising per-dataset bitfields (selection_mask,highlight_mask,visibility_mask) oncurrent_dataset()instead of the newly created slot.free_molecule_datato re-initialise per-dataset bitfields aftermd_arena_allocator_resetvia a newinit_dataset_bitfieldshelper, preventing use-after-reset memory issues.query.mask,grow.mask) are now initialised with the persistent allocator on first creation only.State vs dataset API boundary enforcement
viamd.h/cppandmain.cppto ensure they operate at the correct level.Dataset&directly instead ofApplicationState*:recompute_atom_visibility_mask,flag_all_representations_as_dirty,remove_all_selections,remove_selection,remove_representation,remove_all_representations,update_representation_info.ApplicationState*and an explicitDataset&:create_representation,clone_representation,create_selection,create_default_representations,update_representation,update_all_representations,reset_view.ApplicationState*-only:init_molecule_data,init_trajectory_data,interrupt_async_tasks,load_dataset_from_file,load_workspace,save_workspace.System architecture introduction
struct Systemas a pure data container aligned with the "Systems must not store visualization state" principle from the multi-dataset architecture.Systemholds all molecular data: topology (md_system_t), trajectory (md_trajectory_i*), GPU representation (md_gl_mol_t), file paths,FrameCache, recenter target, bounding box, precomputed trajectory data, and interpolated properties.Datasetnow contains aSystem systemmember. Molecular data is accessed viadataset.system.X; visualization context (camera, animation, selection, representation, visuals, operations, dirty flags) stays at thedatasetlevel.current_system(state)helper alongsidecurrent_dataset(state)for ergonomicSystem&access.viamd.cpp,main.cpp,dataset.cpp,ramachandran.cpp, andshapespace.cppupdated to use the new access pattern.Datasetis documented as a transitional combined System+View container; the long-term goal is to separate these into independentSystem[]andView[]arrays inApplicationState(the Workspace), with Views referencing Systems by ID.Compile error fixes
load_workspaceused the stale variable namedatathroughout its body; all references corrected toapp_state.staticforward declaration ofreset_viewfrommain.cpp(the function is non-static) and added default arguments to itsviamd.hdeclaration.data->view.param.*references in the#if EXPERIMENTAL_GFX_APIblock and a#if 0debug draw block inmain.cppto usecurrent_dataset(*data).view.param.*.Application state alignment
ApplicationStatewhere it still belongs, such as workspace path, window visibility flags, and shared shader handles.Source cleanup
md_frame_cache-based code paths and corrected outdated assumptions that still referenced the old top-levelApplicationStatelayout.dirty_system_statefield fromDataset.Example of the updated ownership/access pattern:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.