void anim_start(GtkWidget *w, gpointer data) { gint freq; struct model_pak *model; /* don't allow more than one */ model = dialog_model(data); g_assert(model != NULL); if (model->animating) return; /* timeout frequency */ /* NB: we can't refresh any faster than units of 25 (ie the canvas redraw frequency) */ freq = 25 * model->anim_speed; if (!model->transform_list) { model->afp = fopen(model->filename, "r"); if (!model->afp) { gui_text_show(ERROR, "Failed to open animation stream.\n"); return; } } g_timeout_add(freq, (GSourceFunc) &anim_next_frame, model); model->animating = TRUE; }
void gui_siesta_mode_show(GtkWidget *w, gpointer dialog) { gint i, atom, state; gdouble scale, x1[3], x2[3], colour[3]; gpointer button, spin; GSList *list; struct core_pak *core; struct spatial_pak *spatial; struct model_pak *model; g_assert(dialog != NULL); model = dialog_model(dialog); g_assert(model != NULL); button = dialog_child_get(dialog, "phonon_toggle"); g_assert(button != NULL); spatial_destroy_by_label("siesta_phonons", model); state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); if (!state) { redraw_canvas(SINGLE); return; } spin = dialog_child_get(dialog, "phonon_scaling"); scale = SPIN_FVAL(spin); /* create & init the spatial object */ spatial = spatial_new("siesta_phonons", SPATIAL_VECTOR, 2, TRUE, model); atom = 0; /* get eigenvectors from all atoms */ for (list=model->cores ; list; list=g_slist_next(list)) { core = list->data; ARR3SET(x1, core->x); /* get current eigenvector */ i = model->siesta.sorted_eig_values[model->siesta.current_animation]; x2[0] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom, i); x2[1] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+1, i); x2[2] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+2, i); atom++; /* compute coords */ VEC3MUL(x2, scale); vecmat(model->ilatmat, x2); ARR3ADD(x2, x1); /* add to spatial */ spatial_vertex_add(x2, colour, spatial); spatial_vertex_add(x1, colour, spatial); } /* drawing update */ coords_compute(model); redraw_canvas(SINGLE); }
void anim_stop(GtkWidget *w, gpointer data) { struct model_pak *model; model = dialog_model(data); g_assert(model != NULL); model->animating = FALSE; }
void exec_analysis_task(GtkWidget *w, gpointer dialog) { const gchar *type; gpointer gui_menu_calc; struct analysis_pak *analysis; struct model_pak *model; /* duplicate the analysis structure at time of request */ g_assert(dialog != NULL); model = dialog_model(dialog); g_assert(model != NULL); analysis = analysis_dup(model->analysis); /* get the task type requested from the dialog */ gui_menu_calc = dialog_child_get(dialog, "gui_menu_calc"); type = gui_pulldown_text(gui_menu_calc); if (g_ascii_strncasecmp(type, "RDF", 3) == 0) { analysis->rdf_normalize = TRUE; task_new("RDF", &analysis_plot_rdf, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "Pair", 4) == 0) { analysis->rdf_normalize = FALSE; task_new("Pair", &analysis_plot_rdf, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "VACF", 4) == 0) { task_new("VACF", &analysis_plot_vacf, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "Temp", 4) == 0) { task_new("Temp", &analysis_plot_temp, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "Pot", 3) == 0) { task_new("Energy", &analysis_plot_pe, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "Kin", 3) == 0) { task_new("Energy", &analysis_plot_ke, analysis, &analysis_show, model, model); return; } if (g_ascii_strncasecmp(type, "Meas", 4) == 0) { task_new("Measure", &analysis_plot_meas, analysis, &analysis_show, model, model); return; } }
void anim_fastforward(GtkWidget *w, gpointer data) { struct model_pak *model; model = dialog_model(data); g_assert(model != NULL); model->cur_frame = model->num_frames-1; gui_relation_update(model); }
void anim_rewind(GtkWidget *w, gpointer data) { struct model_pak *model; model = dialog_model(data); g_assert(model != NULL); model->cur_frame = 0; gui_relation_update(model); }
void anim_step_forward(GtkWidget *w, gpointer data) { struct model_pak *model; model = dialog_model(data); g_assert(model != NULL); if (model->cur_frame < model->num_frames-1) { model->cur_frame++; gui_relation_update(model); } }
void anim_step_backward(GtkWidget *w, gpointer data) { struct model_pak *model; model = dialog_model(data); g_assert(model != NULL); if (model->cur_frame > 0) { model->cur_frame--; gui_relation_update(model); } }
void siesta_phonon_stop(GtkWidget *w, gpointer dialog) { struct model_pak *model; g_assert(dialog != NULL); model = dialog_model(dialog); g_assert(model != NULL); /* reset */ model->pulse_direction = 0; model->pulse_count = 0; model->phonon_movie = FALSE; }
void gui_siesta_slider_changed(GtkWidget *w, gpointer dialog) { gint m; struct model_pak *model; g_assert(w != NULL); g_assert(dialog != NULL); model = dialog_model(dialog); m = nearest_int(gtk_range_get_value(GTK_RANGE(w))); model->siesta.current_animation = m-1; /* 1..n range -> 0..n-1 */ gui_siesta_frequency_set(dialog); gui_siesta_mode_show(NULL, dialog); }
void siesta_phonon_start(GtkWidget *w, gpointer dialog) { struct model_pak *model; g_assert(dialog != NULL); model = dialog_model(dialog); g_assert(model != NULL); model->pulse_count = 0; model->pulse_direction = 1; #if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 12 gdk_threads_add_timeout(100, (GSourceFunc) siesta_phonon_timer, dialog); #else g_timeout_add(100, (GSourceFunc) siesta_phonon_timer, dialog); #endif }
void siesta_phonon_movie(GtkWidget *w, gpointer dialog) { gpointer entry; struct model_pak *model; model = dialog_model(dialog); g_assert(model != NULL); entry = dialog_child_get(dialog, "phonon_movie_name"); g_assert(entry != NULL); /* FIXME - GULP phonon movie uses the same variable */ g_free(model->phonon_movie_name); model->phonon_movie_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); entry = dialog_child_get(dialog, "phonon_movie_type"); g_assert(entry != NULL); g_free(model->phonon_movie_type); model->phonon_movie_type = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); model->phonon_movie = TRUE; siesta_phonon_start(NULL, dialog); }
void gui_siesta_frequency_set(gpointer dialog) { gint m; gchar *text; gdouble f; gpointer entry; struct model_pak *model; model = dialog_model(dialog); g_assert(model != NULL); entry = dialog_child_get(dialog, "phonon_entry"); g_assert(entry != NULL); m = model->siesta.current_animation; g_assert(m >= 0); g_assert(m < model->siesta.num_animations); f = make_eigvec_freq(mesch_ve_get(model->siesta.eigen_values, model->siesta.sorted_eig_values[m])); text = g_strdup_printf("%f", f); gtk_entry_set_text(GTK_ENTRY(entry), text); g_free(text); }
gint siesta_phonon_timer(gpointer dialog) { static gint count=0; gint atom, mode; gchar *text, *name; gdouble f, x1[3]; gpointer spin; GSList *list; struct core_pak *core; struct model_pak *model; /* checks */ if (!dialog_valid(dialog)) return(FALSE); model = dialog_model(dialog); g_assert(model != NULL); /* stop animation? */ if (!model->pulse_direction) { siesta_phonon_cleanup(model); coords_compute(model); redraw_canvas(SINGLE); return(FALSE); } /* setup animation resolution */ spin = dialog_child_get(dialog, "phonon_resolution"); model->pulse_max = SPIN_FVAL(spin); /* setup scaling for this step */ model->pulse_count += model->pulse_direction; if (model->pulse_count <= -model->pulse_max) { model->pulse_count = -model->pulse_max; model->pulse_direction = 1; } if (model->pulse_count >= model->pulse_max) { model->pulse_count = model->pulse_max; model->pulse_direction = -1; } spin = dialog_child_get(dialog, "phonon_scaling"); f = SPIN_FVAL(spin); f *= (gdouble) model->pulse_count; f /= model->pulse_max; atom = 0; mode = model->siesta.sorted_eig_values[model->siesta.current_animation]; /* get eigenvectors from all atoms */ for (list=model->cores ; list; list=g_slist_next(list)) { core = list->data; ARR3SET(x1, core->x); //get x,y,z for given freq. core->offset[0] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom, mode); core->offset[1] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+1, mode); core->offset[2] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+2, mode); atom++; /* pulse offset scaling */ VEC3MUL(core->offset, f); vecmat(model->ilatmat, core->offset); } /* recalc coords */ coords_compute(model); /* CURRENT - output to povray for movie rendering */ if (model->phonon_movie) { if (!model->pulse_count && model->pulse_direction==1) { model->phonon_movie = FALSE; count=0; text = g_strdup_printf("%s -delay 20 %s_*.tga %s.%s", sysenv.convert_path, model->phonon_movie_name, model->phonon_movie_name, model->phonon_movie_type); system(text); g_free(text); return(FALSE); } else { text = g_strdup_printf("%s_%06d.pov", model->phonon_movie_name, count++); name = g_build_filename(sysenv.cwd, text, NULL); write_povray(name, model); povray_exec(sysenv.cwd, name); g_free(text); g_free(name); } } else redraw_canvas(SINGLE); return(TRUE); }