Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ option(VIAMD_IMGUI_ENABLE_DOCKSPACE "Enable ImGui Dockspace in main window" OFF)
option(VIAMD_CREATE_MACOSX_BUNDLE "Build a macosx bundle instead of just an executable" OFF)
option(VIAMD_LINK_STDLIB_STATIC "Link against stdlib statically" ON)
option(VIAMD_ENABLE_VELOXCHEM "Enable Veloxchem Module" OFF)
set(VIAMD_FRAME_CACHE_SIZE_MB "2048" CACHE STRING "Reserved frame cache size in Megabytes")
set(VIAMD_NUM_WORKER_THREADS "8" CACHE STRING "Number of worker threads (Decrease if you run out of memory during evaluation)")

# MDLIB OPTIONS
Expand Down Expand Up @@ -203,7 +202,6 @@ endif()
target_compile_definitions(viamd PRIVATE
${VIAMD_DEFINES}
VIAMD_NUM_WORKER_THREADS=${VIAMD_NUM_WORKER_THREADS}
VIAMD_FRAME_CACHE_SIZE=${VIAMD_FRAME_CACHE_SIZE_MB}
VIAMD_IMGUI_ENABLE_VIEWPORTS=$<BOOL:${VIAMD_IMGUI_ENABLE_VIEWPORTS}>
VIAMD_IMGUI_ENABLE_DOCKSPACE=$<BOOL:${VIAMD_IMGUI_ENABLE_DOCKSPACE}>
${MD_DEFINES}
Expand Down
2 changes: 1 addition & 1 deletion ext/mdlib
160 changes: 80 additions & 80 deletions src/components/dataset/dataset.cpp

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/components/ramachandran/ramachandran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ struct Ramachandran : viamd::EventHandler {
md_array_shrink(rama_type_indices[2], 0);
md_array_shrink(rama_type_indices[3], 0);

for (uint32_t i = 0; i < (uint32_t)md_array_size(state.mold.sys.protein_backbone.segment.rama_type); ++i) {
switch (state.mold.sys.protein_backbone.segment.rama_type[i]) {
for (uint32_t i = 0; i < (uint32_t)md_array_size(current_dataset(state).system.sys.protein_backbone.segment.rama_type); ++i) {
switch (current_dataset(state).system.sys.protein_backbone.segment.rama_type[i]) {
case MD_RAMACHANDRAN_TYPE_GENERAL: md_array_push(rama_type_indices[0], i, arena); break;
case MD_RAMACHANDRAN_TYPE_GLYCINE: md_array_push(rama_type_indices[1], i, arena); break;
case MD_RAMACHANDRAN_TYPE_PROLINE: md_array_push(rama_type_indices[2], i, arena); break;
Expand All @@ -650,18 +650,18 @@ struct Ramachandran : viamd::EventHandler {
}

void update(ApplicationState& state) {
if (show_window && state.mold.sys.protein_backbone.segment.count > 0) {
const size_t num_frames = md_trajectory_num_frames(state.mold.traj);
if (show_window && current_dataset(state).system.sys.protein_backbone.segment.count > 0) {
const size_t num_frames = md_trajectory_num_frames(current_dataset(state).system.traj);
if (num_frames > 0) {
if (full_fingerprint != state.trajectory_data.backbone_angles.fingerprint) {
if (full_fingerprint != current_dataset(state).system.trajectory_data.backbone_angles.fingerprint) {
if (!task_system::task_is_running(compute_density_full)) {
full_fingerprint = state.trajectory_data.backbone_angles.fingerprint;
full_fingerprint = current_dataset(state).system.trajectory_data.backbone_angles.fingerprint;

const uint32_t frame_beg = 0;
const uint32_t frame_end = (uint32_t)num_frames;
const uint32_t frame_stride = (uint32_t)state.trajectory_data.backbone_angles.stride;
const uint32_t frame_stride = (uint32_t)current_dataset(state).system.trajectory_data.backbone_angles.stride;

compute_density_full = rama_rep_compute_density(&rama_data.full, state.trajectory_data.backbone_angles.data, frame_beg, frame_end, frame_stride);
compute_density_full = rama_rep_compute_density(&rama_data.full, current_dataset(state).system.trajectory_data.backbone_angles.data, frame_beg, frame_end, frame_stride);
} else {
task_system::task_interrupt(compute_density_full);
}
Expand All @@ -673,9 +673,9 @@ struct Ramachandran : viamd::EventHandler {

const uint32_t frame_beg = MIN((uint32_t)state.timeline.filter.beg_frame, (uint32_t)num_frames - 1);
const uint32_t frame_end = MIN((uint32_t)state.timeline.filter.end_frame + 1, (uint32_t)num_frames);
const uint32_t frame_stride = (uint32_t)state.trajectory_data.backbone_angles.stride;
const uint32_t frame_stride = (uint32_t)current_dataset(state).system.trajectory_data.backbone_angles.stride;

compute_density_filt = rama_rep_compute_density(&rama_data.filt, state.trajectory_data.backbone_angles.data, frame_beg, frame_end, frame_stride);
compute_density_filt = rama_rep_compute_density(&rama_data.filt, current_dataset(state).system.trajectory_data.backbone_angles.data, frame_beg, frame_end, frame_stride);
}
else {
task_system::task_interrupt(compute_density_filt);
Expand Down Expand Up @@ -762,9 +762,9 @@ struct Ramachandran : viamd::EventHandler {
ImGui::EndMenuBar();
}

const auto& sys = state.mold.sys;
md_bitfield_t* selection_mask = &state.selection.selection_mask;
md_bitfield_t* highlight_mask = &state.selection.highlight_mask;
const auto& sys = current_dataset(state).system.sys;
md_bitfield_t* selection_mask = &current_dataset(state).selection.selection_mask;
md_bitfield_t* highlight_mask = &current_dataset(state).selection.highlight_mask;

const int plot_offset = MAX(0, layout_mode - 1);
const int plot_cols = (layout_mode == 0) ? 2 : 1;
Expand Down Expand Up @@ -919,7 +919,7 @@ struct Ramachandran : viamd::EventHandler {
}

if (is_selecting[plot_idx]) {
grow_mask_by_selection_granularity(highlight_mask, state.selection.granularity, sys);
grow_mask_by_selection_granularity(highlight_mask, current_dataset(state).selection.granularity, sys);
}

if (mouse_hover_idx != -1) {
Expand All @@ -928,7 +928,7 @@ struct Ramachandran : viamd::EventHandler {
md_urange_t range = md_component_atom_range(&sys.component, comp_idx);
if (range.beg != range.end) {
modify_field(highlight_mask, range, SelectionOperator::Or);
grow_mask_by_selection_granularity(highlight_mask, state.selection.granularity, sys);
grow_mask_by_selection_granularity(highlight_mask, current_dataset(state).selection.granularity, sys);
}
str_t lbl = md_component_name(&sys.component, comp_idx);
md_sequence_id_t seq_id = md_component_seq_id(&sys.component, comp_idx);
Expand Down
24 changes: 12 additions & 12 deletions src/components/shapespace/shapespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct Shapespace : viamd::EventHandler {
ImGui::PopItemWidth();
if (ImGui::IsItemHovered()) {
if (input_valid) {
md_bitfield_copy(&app_state->selection.highlight_mask, &joined_bitfield);
md_bitfield_copy(&current_dataset(*app_state).selection.highlight_mask, &joined_bitfield);
} else if (error[0] != '\0') {
ImGui::SetTooltip("%s", error);
}
Expand Down Expand Up @@ -291,7 +291,7 @@ struct Shapespace : viamd::EventHandler {
ImPlot::PopStyleVar(2);

if (ImPlot::IsPlotHovered()) {
md_bitfield_clear(&app_state->selection.highlight_mask);
md_bitfield_clear(&current_dataset(*app_state).selection.highlight_mask);
}

// Redraw hovered index
Expand All @@ -308,7 +308,7 @@ struct Shapespace : viamd::EventHandler {
vec2_t* coordinates = coords + offset;
ImPlot::PlotScatterG("##hovered structure", getter, coordinates, count);
if (hovered_structure_idx < (int)md_array_size(bitfields)) {
md_bitfield_copy(&app_state->selection.highlight_mask, &bitfields[hovered_structure_idx]);
md_bitfield_copy(&current_dataset(*app_state).selection.highlight_mask, &bitfields[hovered_structure_idx]);
}
}
if (hovered_point_idx != -1) {
Expand All @@ -326,11 +326,11 @@ struct Shapespace : viamd::EventHandler {
ImGui::SetTooltip("%s", buf);

if (structure_idx < (int)md_array_size(bitfields)) {
md_bitfield_copy(&app_state->selection.highlight_mask, &bitfields[structure_idx]);
md_bitfield_copy(&current_dataset(*app_state).selection.highlight_mask, &bitfields[structure_idx]);
}

if (ImGui::IsWindowFocused() && ImPlot::IsPlotHovered() && ImGui::GetIO().MouseClicked[0]) {
app_state->animation.frame = frame_idx;
current_dataset(*app_state).animation.frame = frame_idx;
}
}
ImPlot::PopStyleColor();
Expand All @@ -356,11 +356,11 @@ struct Shapespace : viamd::EventHandler {
joined_bitfield = {0};
md_bitfield_init(&joined_bitfield, arena);

md_trajectory_i* traj = load::traj::get_raw_trajectory(app_state->mold.traj);
md_trajectory_i* traj = current_dataset(*app_state).system.traj;

input_valid = false;
MEMSET(error, 0, sizeof(error));
if (md_filter_evaluate(&bitfields, str_from_cstr(input), &app_state->mold.sys, app_state->mold.sys.atom.x, app_state->mold.sys.atom.y, app_state->mold.sys.atom.z, app_state->script.ir, NULL, error, sizeof(error), arena)) {
if (md_filter_evaluate(&bitfields, str_from_cstr(input), &current_dataset(*app_state).system.sys, current_dataset(*app_state).system.sys.atom.x, current_dataset(*app_state).system.sys.atom.y, current_dataset(*app_state).system.sys.atom.z, app_state->script.ir, NULL, error, sizeof(error), arena)) {
eval_hash = hash;

input_valid = true;
Expand All @@ -385,7 +385,7 @@ struct Shapespace : viamd::EventHandler {
evaluate_task = task_system::create_pool_task(STR_LIT("Eval Shape Space"), (uint32_t)num_frames, [shapespace = this, traj](uint32_t range_beg, uint32_t range_end, uint32_t thread_num) {
(void)thread_num;
ApplicationState* app_state = shapespace->app_state;
const size_t stride = ALIGN_TO(app_state->mold.sys.atom.count, 8);
const size_t stride = ALIGN_TO(current_dataset(*app_state).system.sys.atom.count, 8);
const size_t bytes = stride * 3 * sizeof(float);
md_allocator_i* alloc = md_arena_allocator_create(md_get_heap_allocator(), MEGABYTES(1));
defer { md_arena_allocator_destroy(alloc); };
Expand All @@ -397,7 +397,7 @@ struct Shapespace : viamd::EventHandler {
float* w = 0;
if (shapespace->use_mass) {
w = (float*)md_arena_allocator_push(alloc, stride * sizeof(float));
md_atom_extract_masses(w, 0, app_state->mold.sys.atom.count, &app_state->mold.sys.atom);
md_atom_extract_masses(w, 0, current_dataset(*app_state).system.sys.atom.count, &current_dataset(*app_state).system.sys.atom);
}

const vec2_t p[3] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {0.5f, 0.86602540378f}};
Expand All @@ -419,8 +419,8 @@ struct Shapespace : viamd::EventHandler {
xyzw[dst_idx++] = vec4_set(x[src_idx], y[src_idx], z[src_idx], w ? w[src_idx] : 1.0f);
}

vec3_t com = md_util_com_compute_vec4(xyzw, 0, count, &app_state->mold.sys.unitcell);
md_util_deperiodize_vec4(xyzw, count, com, &app_state->mold.sys.unitcell);
vec3_t com = md_util_com_compute_vec4(xyzw, 0, count, &current_dataset(*app_state).system.sys.unitcell);
md_util_deperiodize_vec4(xyzw, count, com, &current_dataset(*app_state).system.sys.unitcell);

const mat3_t M = mat3_covariance_matrix_vec4(xyzw, 0, count, com);
const vec3_t weights = md_util_shape_weights(&M);
Expand Down Expand Up @@ -449,7 +449,7 @@ struct Shapespace : viamd::EventHandler {
defer { md_arena_allocator_destroy(temp_arena); };

// @TODO: add unit to time (if available)
md_unit_t time_unit = md_trajectory_time_unit(app_state->mold.traj);
md_unit_t time_unit = md_trajectory_time_unit(current_dataset(*app_state).system.traj);

str_t x_label = STR_LIT("Frame");
if (!md_unit_empty(time_unit)) {
Expand Down
Loading