Example #1
0
gint read_gmf(gchar *filename, struct model_pak *data)
{
/* checks */
g_assert(data != NULL);
g_assert(filename != NULL);

/* setup model parameters */
data->mode = FREE;
data->id = MORPH;
data->axes_type = OTHER;
data->morph_label = TRUE;

g_free(data->filename);
data->filename = g_strdup(filename);

g_free(data->basename);
data->basename = parse_strip(filename);

/* read from a gmf file */
if (load_planes(filename, data))
  {
  printf("File load failed, check %s.\n", data->filename);
  model_delete(data);
  return(1);
  }

/* construct the hull (convert to H representation) */
data->num_vertices=0;

/* FIXME - signature change */
/*
if (morph_build(data))
  return(3);
*/

#if DEBUG_READ_GMF
printf("-------------------------\n");
printf("       Input planes: %d\n", data->num_planes);
printf("Calculated vertices: %d\n", data->num_vertices);
printf("-------------------------\n");
#endif

/* test success */
if (!g_slist_length(data->planes))
  return(4);

/* vertices are cartesian - so a fudge is needed */
model_prep(data);

/* proper rmax scaling & visibility calc */
coords_init(REDO_COORDS, data);

return(0);
}
Example #2
0
void gtk_refresh_images(GtkWidget *w, gpointer dummy)
{
struct model_pak *model;

model = sysenv.active_model;
g_assert(model != NULL);

/* atom colour/display updates */
space_make_images(CREATE, model);
coords_init(CENT_COORDS, model);
redraw_canvas(SINGLE);
}
Example #3
0
void space_image_widget_reset(void)
{
struct model_pak *model;

/* update model (if exists) */
model = sysenv.active_model;
if (model)
  {
  space_make_images(INITIAL, model);
  coords_init(CENT_COORDS, model);
  }

/* update widget and canvas */
gui_refresh(GUI_MODEL_PROPERTIES);
gui_refresh(GUI_CANVAS);
}
coords* convert_new2old(coords *given, conv_tbl *cvt) {
    coords *oldcoo = coords_init(given->nat, given->boxL);
    for (int i = 0; i < given->nat; i++) {
        oldcoo->at[i]->n = given->at[i]->n;
        strncpy(given->at[i]->esymb, oldcoo->at[i]->esymb, 2);
        int att = cvt_attlookup(cvt, given->at[i]->atn);
        if (att == -1) {
            printf("\n***   convert_new2old: atn=%3d not found in conversion table. Will exit.",given->at[i]->atn);
            exit(EXIT_FAILURE);
        }
        oldcoo->at[i]->atn = att;
        oldcoo->at[i]->pnt.x = given->at[i]->pnt.x;
        oldcoo->at[i]->pnt.y = given->at[i]->pnt.y;
        oldcoo->at[i]->pnt.z = given->at[i]->pnt.z;
    }
    return oldcoo;
}
Example #5
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);
  }
}