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);
}
Exemple #2
0
void cb_space_image_spinner(GtkWidget *w, gpointer data)
{
gint i;
struct model_pak *model;

model = sysenv.active_model;
if (!model)
  return;

/* alter the spinner value */
i = GPOINTER_TO_INT(data);
g_assert(i >= 0);
g_assert(i < 6);
model->image_limit[i] = SPIN_FVAL(GTK_SPIN_BUTTON(w));

/* update only if this is a genuine call for perioidic image creation */
if (image_update)
  {
  space_make_images(CREATE, model);
  coords_init(CENT_COORDS, model);
  redraw_canvas(SINGLE);
  }
}
Exemple #3
0
void gui_relation_set_value(GtkWidget *w, struct model_pak *model)
{
gpointer value;
GSList *list;
struct relation_pak *relation;

g_assert(w != NULL);

/* if no model supplied, use active model */
if (!model)
  model = sysenv.active_model;

/* find appropriate relation (direct -> widget, else model) */
list = gui_relation_list;
while (list)
  {
  relation = list->data;
  list = g_slist_next(list);

  if (relation->widget != w)
    continue;

  if (relation->direct)
    value = relation->variable;
  else
    {
    g_assert(model != NULL);
    value = (gpointer) model + relation->offset;
    }

/* update variable associated with the widget */
  switch (relation->type)
    {
    case AUTO_CHECK:
#if DEBUG_RELATION
printf("model %p : relation %p : setting variable to %d\n", 
       model, relation, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)));
#endif
      if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
        *((gint *) value) = TRUE;
      else
        *((gint *) value) = FALSE;
      break;

    case AUTO_SPIN:
#if DEBUG_RELATION
printf("model %p : relation %p : setting variable to %f\n", 
       model, relation, SPIN_FVAL(GTK_SPIN_BUTTON(w)));
#endif
      *((gdouble *) value) = SPIN_FVAL(GTK_SPIN_BUTTON(w));
      break;

    case AUTO_RANGE:
      *((gint *) value) = gtk_range_get_value(GTK_RANGE(w));
      break;

    case AUTO_TEXT_ENTRY:
/* CURRENT */
      g_free(*((gchar **) value));
      *((gchar **) value) = g_strdup(gtk_entry_get_text(GTK_ENTRY(w)));
      break;

    }
  }
}
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);
}