Example #1
0
void gui_animate_frame_select(GtkWidget *w, gpointer data)
{
gint i;
gdouble f, max;
struct model_pak *model;

/* TODO - if range is not enough to cover the number of values (test below) */
/* then change the range accordingly */

f = gtk_range_get_value(GTK_RANGE(w));

model = tree_model_get();
if (model)
  {
  if (animate_phonons)
    {
    max = model->num_phonons;
    f *= max/100.0;
    model->current_phonon = f;

/* if we're not animating - re-draw eigenvectors */
    if (!model->animating)
      gui_animate_phonon_vectors(model);
    }
  else
    {
    max = g_list_length(model->animate_list);
    f *= max/100.0;
    i = f;
    animate_frame_select(i, model);
    }

  gui_refresh(GUI_CANVAS | GUI_ACTIVE);
  }
}
Example #2
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);
}
Example #3
0
void gui_animate_type_change(GtkWidget *w,  gpointer data)
{
struct model_pak *model;

animate_phonons ^= 1;

model = tree_model_get();

if (animate_phonons)
  {
  if (model)
    model->current_phonon=1;

  gui_animate_phonon_vectors(model);

  gtk_widget_show(box_phonon_options);
  }
else
  {
  if (model)
    model->current_phonon=-1;

  gtk_widget_hide(box_phonon_options);
  }

gui_refresh(GUI_CANVAS);
}
Example #4
0
gint gui_frame_loop(void)
{
gint range[3];
struct model_pak *model;

model = tree_model_get();
if (model)
  {
  if (model->animating)
    {
    gui_animate_range_get(range, model);

/* add step */
    model->animate_current += range[2];

/* enforce minimum */
  if (model->animate_current < range[0])
    model->animate_current = range[0];

/* loop on maximum */
    if (model->animate_current < range[1]+1)
      animate_frame_select(model->animate_current, model);
    else
      animate_frame_select(range[0], model);

    gui_refresh(GUI_CANVAS | GUI_ACTIVE);
    return(TRUE);
    }
  }
return(FALSE);
}
Example #5
0
/* Gekke dingen */
void
plaats_rechthoek(void) {
#if MAP_HEIGHT < 10
#error Map height must be at least 10
#endif
#if MAP_WIDTH < 30
#error Map width must be at least 30
#endif
	int x1 = myrand(10, MAP_WIDTH/2);
	int x2 = myrand(MAP_WIDTH/2 + 5, MAP_WIDTH - 3);
	int y1 = myrand(3, MAP_HEIGHT/2 - 3);
	int y2 = myrand(MAP_HEIGHT/2 + 3, MAP_HEIGHT - 3);
	int x, y;
	for(x = x1; x2 >= x; x++) {
		map[y1][x] = MUUR;
		map[y2][x] = MUUR;
	}
	for(y = y1; y2 >= y; y++) {
		map[y][x1] = MUUR;
		map[y][x2] = MUUR;
	}

	if(map[kareltje.y][kareltje.x] == MUUR) {
		gui_die("You got hit by a wall");
	}
	gui_refresh(map, &kareltje);
}
Example #6
0
// copy-paste uit charles_package
void
creeer_bal(int x, int y) {
    if (x >= 0 && x < MAP_WIDTH && y >= 0 && y < MAP_HEIGHT)
    {
        map[MAP_HEIGHT-y-1][x] = BAL;
        gui_refresh(map, &kareltje);
    }
}
Example #7
0
void
teken_ballenlijn(int s) {
	while(s--) {
		stap_undelayed();
		leg_bal();
	}
	gui_refresh(map, &kareltje);
}
Example #8
0
// copy-paste uit charles_package
void
make_cave()               // toegevoegd in origineel door Peter
{
    resetmap();

    cave_wall (NOORD) ;
    cave_wall (ZUID) ;
	gui_refresh(map, &kareltje);
}
Example #9
0
void
maak_ballenchaos(void) {
	int x, y;
	for(y = MAP_HEIGHT / 2 - 1; 1 < y; y--) {
		for(x = myrand(MAP_WIDTH - 10, MAP_WIDTH - 2); MAP_WIDTH - 1 > x; x++) {
			map[y][x] = BAL;
		}
	}
	gui_refresh(map, &kareltje);
}
Example #10
0
void
maak_ballensnoer(void) {
	int x, y;
	for(x=1; MAP_WIDTH-1>x; x++) {
		map[1][x] = BAL;
		map[MAP_HEIGHT-2][x] = BAL;
	}
	for(y=1; MAP_HEIGHT-1>y; y++) {
		map[y][1] = BAL;
		map[y][MAP_WIDTH-2] = BAL;
	}
	gui_refresh(map, &kareltje);
}
Example #11
0
// copy-paste uit charles_package
void
maak_ballenpad ()			// toegevoegd in origineel door Peter
{
	resetmap();

	for (int ix = 1; ix < MAP_WIDTH-2; ix++)				map[MAP_HEIGHT/2][ix] = BAL;
	for (int iy = MAP_HEIGHT/2; iy < MAP_HEIGHT-3; iy++)	map[iy][MAP_WIDTH-3]  = BAL;
	for (int ix = MAP_WIDTH-3; ix >= MAP_WIDTH / 2; ix--)	map[MAP_HEIGHT-4][ix] = BAL;
	for (int iy = MAP_HEIGHT-4; iy >= 1; iy--)				map[iy][MAP_WIDTH/2]  = BAL;
	for (int ix = MAP_WIDTH / 2; ix >= 2; ix--)		    	map[1][ix]            = BAL;
	for (int iy = 1; iy <= MAP_HEIGHT / 2 - 3; iy++)		map[iy][2]            = BAL;

	gui_refresh(map, &kareltje);
}
Example #12
0
void
rechtsom(void) {
	switch(kareltje.dir) {
		case NOORD:
			kareltje.dir = OOST;
			break;
		case OOST:
			kareltje.dir = ZUID;
			break;
		case ZUID:
			kareltje.dir = WEST;
			break;
		case WEST:
			kareltje.dir = NOORD;
			break;
	}
	gui_refresh(map, &kareltje);
}
Example #13
0
void gui_animate_last(void)
{
gint range[3];
struct model_pak *model;

model = tree_model_get();
if (model)
  {
  if (animate_phonons)
    model->current_phonon = model->num_phonons;
  else
    {
    gui_animate_range_get(range, model);
    animate_frame_select(range[1], model);
    }
  gui_refresh(GUI_CANVAS | GUI_ACTIVE);
  }
}
Example #14
0
// copy-paste uit charles_package
void teken_rechthoek ( int links, int onder, int breedte, int hoogte )
{
	for (int hor = links; hor<=links+breedte; hor++)
	{
		map[MAP_HEIGHT-onder][hor]        = MUUR ;
		map[MAP_HEIGHT-(onder+hoogte)][hor] = MUUR ;
	};

	for (int vert = onder; vert<=onder+hoogte; vert++)
	{
		map[MAP_HEIGHT-vert][links]         = MUUR ;
		map[MAP_HEIGHT-vert][links+breedte] = MUUR ;
	};

	if(map[kareltje.y][kareltje.x] == MUUR) {
		gui_die("You got hit by a wall");
	}
	gui_refresh(map, &kareltje);
}
Example #15
0
/* NB: leave symmetry / pbc structure intact */
void core_delete_all(struct model_pak *model)
{
g_assert(model != NULL);

/* free core reference lists */
free_mol_list(model);
wipe_bonds(model);
g_slist_free(model->unique_atom_list);
model->unique_atom_list = NULL;

/* free cores */
free_slist(model->cores);
model->cores = NULL;

/* redo dependancies */
zone_init(model);
calc_emp(model);
gui_refresh(GUI_MODEL_PROPERTIES);
model->state = 0;
}
Example #16
0
void space_image_widget_setup(GtkWidget *box)
{
gint i;
GtkWidget *table, *label;

/* use table for nice spacing */
table = gtk_table_new(3, 4, FALSE);
gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0);

/* image directions */
label = gtk_label_new ("-");
gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,0,1);
label = gtk_label_new ("+");
gtk_table_attach_defaults(GTK_TABLE(table),label,2,3,0,1);

/* labels and spinners */
for (i=0 ; i<3 ; i++)
  {
/* negative direction */
  image_spin[2*i] = new_spinner(NULL, 0, 10, 1, 
                                cb_space_image_spinner,
                                GINT_TO_POINTER(2*i),
                                NULL);
/* TODO - set these to 1, when fractional periodic images are working */
  gtk_spin_button_set_digits(GTK_SPIN_BUTTON(image_spin[2*i]), 0);
  gtk_table_attach_defaults(GTK_TABLE(table), image_spin[2*i], 1, 2, i+1, i+2);

/* positive direction */
  image_spin[2*i+1] = new_spinner(NULL, 1, 10, 1,
                                  cb_space_image_spinner,
                                  GINT_TO_POINTER(2*i+1),
                                  NULL);
/* TODO - set these to 1, when fractional periodic images are working */
  gtk_spin_button_set_digits(GTK_SPIN_BUTTON(image_spin[2*i+1]), 0);
  gtk_table_attach_defaults(GTK_TABLE(table),
                            image_spin[2*i+1], 2, 3, i+1, i+2);
  }

/* set the spinner values */
gui_refresh(GUI_MODEL_PROPERTIES);
}
Example #17
0
// copy-paste uit charles_package
void maak_muur ( int links, int onder, int aantal, bool horizontaal )
{
    if (horizontaal)
    {
        for (int x = links ; x <= links + aantal ; x++)
        {
            map[MAP_HEIGHT-onder][x] = MUUR ;
        }
    }
    else
    {
        for (int y = onder; y <= onder+aantal ; y++)
        {
            map[MAP_HEIGHT-y][links] = MUUR ;
        }
    }
	if(map[kareltje.y][kareltje.x] == MUUR) {
		gui_die("You got hit by a wall");
	}
	gui_refresh(map, &kareltje);
}
Example #18
0
int
main(int argc, char **argv) {
	kareltje.x = 1;
	kareltje.y = MAP_HEIGHT / 2;
	kareltje.dir = OOST;
#ifdef __FreeBSD__
	srandomdev();
#else
	srandom(time(NULL) ^ getpid());
#endif
	if(argc == 1) {
		printf("Usage: %s <command, [command... ]>\n", argv[0]);
		printf("commands: ");
		for(const command* cmd = commands; cmd->name != NULL;cmd++) {
			printf("%s", cmd->name);
			if ((cmd+1)->name != NULL) printf(", ");
		}
		printf("\n");
		exit(0);
	}
	gui_init();
	resetmap();
	gui_refresh(map, &kareltje);
	while(--argc) {
		++argv;
		const command* cmd = commands;
		while(cmd->name != NULL) {
			if (strcmp(*argv, cmd->name) == 0) {
				cmd->cmd();
				break;
			}
			cmd++;
		}
		if (cmd->name == NULL) {
			gui_die("Onbekende functie");
		}
	}
	gui_end();
	return 0;
}
Example #19
0
void gui_animate_next(void)
{
gint range[3];
struct model_pak *model;

model = tree_model_get();
if (model)
  {
  if (animate_phonons)
    {
    if (model->current_phonon < model->num_phonons)
      {
      model->current_phonon++;
/* if we're not animating - re-draw eigenvectors */
      if (!model->animating)
        gui_animate_phonon_vectors(model);
      }
    }
  else
    {
    gui_animate_range_get(range, model);

/* add step */
    model->animate_current += range[2];

/* enforce minimum */
    if (model->animate_current < range[0])
      model->animate_current = range[0];

/* enforce maximum */
    if (model->animate_current < range[1]+1)
      animate_frame_select(model->animate_current, model);
    else
      animate_frame_select(range[1], model);
    }

  gui_refresh(GUI_CANVAS | GUI_ACTIVE);
  }
}
Example #20
0
void gui_animate_back(void)
{
gint range[3];
struct model_pak *model;

model = tree_model_get();
if (model)
  {
  if (animate_phonons)
    {
    if (model->current_phonon > 1)
      {
      model->current_phonon--;
/* if we're not animating - re-draw eigenvectors */
      if (!model->animating)
        gui_animate_phonon_vectors(model);
      }
    }
  else
    {
    gui_animate_range_get(range, model);

/* subtract step */
    model->animate_current -= range[2];

/* enforce maximum */
    if (model->animate_current > range[1])
      model->animate_current = range[1];

/* enforce minimum */
    if (model->animate_current > range[0]-1)
      animate_frame_select(model->animate_current, model);
    else
      animate_frame_select(range[0], model);
    }

  gui_refresh(GUI_CANVAS | GUI_ACTIVE);
  }
}
Example #21
0
void delete_commit(struct model_pak *data)
{
gint flag1=FALSE, flag2=FALSE;
gpointer m;
GSList *list1, *list2;
struct core_pak *core;
struct shel_pak *shell;
struct bond_pak *bond;

g_assert(data != NULL);

/* delete flaged cores in list */
list1 = data->cores;
while (list1)
  {
  core = list1->data;
  list1 = g_slist_next(list1);

  if (core->status & DELETED)
    {
#if DEBUG_DELETE_COMMIT
printf("Deleting %s core [%p] ...\n", core->label, core);
#endif
    flag1 = TRUE;

/* flag assoc. shell */
    if (core->shell)
      {
      shell = core->shell;
      shell->status |= DELETED;
      }

/* update connectivity */
    connect_atom_clear(core, data);
    list2 = data->ubonds;
    while (list2)
      {
      bond = list2->data;
      list2 = g_slist_next(list2);

      if (bond->atom1 == core || bond->atom2 == core)
        {
        data->ubonds = g_slist_remove(data->ubonds, bond);
        g_free(bond);
        }
      }

/* update selection */
    data->selection = g_slist_remove(data->selection, core);

/* delete any labels that reference the deleted core */
    list2 = data->measure_list;
    while (list2)
      {
      m = list2->data;
      list2 = g_slist_next(list2);
      if (measure_has_core(core, m))
        measure_free(m, data);
      }
/* update main list */
    data->cores = g_slist_remove(data->cores, core);
    g_free(core);
    }
  }

/* delete flaged shells in list */
list1 = data->shels;
while (list1)
  {
  shell = list1->data;
  list1 = g_slist_next(list1);

  if (shell->status & DELETED)
    {
    flag2 = TRUE;
/* update main list */
    data->shels = g_slist_remove(data->shels, shell);
    g_free(shell);
    }
  }

/* refresh totals */
data->num_atoms = g_slist_length(data->cores);
data->num_shells = g_slist_length(data->shels);

/* refresh spatial partitioning */
/* it's probably best to refresh the partitioning here, rather than */
/* incrementally as it's speedups for large models we're targeting */
zone_init(data);

/* cope with deleted bonds - expensive, so only do if required */
if (flag1)
  {
  connect_bonds(data);
  connect_molecules(data);
  }

/* refresh net charge calc */
calc_emp(data);

/* refresh unique atom list */
g_slist_free(data->unique_atom_list);
data->unique_atom_list = find_unique(ELEMENT, data);

/* refresh widgets */
meas_graft_model(data);
gui_refresh(GUI_MODEL_PROPERTIES);

/* reset functions with static pointers to cores */
data->state = 0;
}
Example #22
0
// not really an animate function as such...
void gui_animate_phonon_vectors(struct model_pak *model)
{
gdouble *v, x1[3], x2[3], colour[3];
gpointer spatial, ptr;
GSList *list, *xlist, *ylist, *zlist;
struct core_pak *core, *prim;

if (!model)
  return;

/* create & init the spatial object */
spatial_destroy_by_label("phonons", model);
spatial = spatial_new("phonons", SPATIAL_VECTOR, 2, TRUE, model);

/* get eigenvectors from all atoms */
for (list=model->cores ; list; list=g_slist_next(list))
  {
  core = list->data;
  ARR3SET(x1, core->x);

/* get eigenvector list */
  if (core->primary)
    {
    xlist = core->vibx_list; 
    ylist = core->viby_list; 
    zlist = core->vibz_list; 
    }
  else
    {
    prim = core->primary_core;
    xlist = prim->vibx_list; 
    ylist = prim->viby_list; 
    zlist = prim->vibz_list; 
    }

  if (!xlist || !ylist || !zlist)
    {
    printf("Missing phonon eigenvectors.\n");
    return;
    }

/* vibrational eigenvector */
/* NB: current_phonon starts from 1 */
  ptr = g_slist_nth_data(xlist, model->current_phonon-1);
  if (ptr)
    x2[0] = *((gdouble *) ptr);

  ptr = g_slist_nth_data(ylist, model->current_phonon-1);
  if (ptr)
    x2[1] = *((gdouble *) ptr);

  v = g_slist_nth_data(zlist, model->current_phonon-1);
  if (ptr)
    x2[2] = *v;

/* pulse offset scaling */
  VEC3MUL(x2, sysenv.render.phonon_scaling);
  vecmat(model->ilatmat, x2);

/* TODO - unify with siesta */
/*
  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 */
  ARR3ADD(x2, x1);

/* add to spatial */
  spatial_vertex_add(x2, colour, spatial);
  spatial_vertex_add(x1, colour, spatial);
  }

coords_compute(model);

gui_refresh(GUI_CANVAS);
}
Example #23
0
void
maak_doolhof(void) {
	int kx, ky, kd, bx, by, hmuren, vmuren;
	FILE *fh = fopen("doolhof", "r");
	if(fh == NULL) {
		gui_die("No doolhof file");
	}
	fscanf(fh, "%d %d %d %d %d %d %d\n", &kx, &ky, &kd, &bx, &by, &hmuren, &vmuren);

	if(kx >= MAP_WIDTH || ky >= MAP_HEIGHT || bx >= MAP_WIDTH || by >= MAP_HEIGHT) {
		gui_die("Doolhof doesn't fit");
	}

	resetmap();
	kareltje.x = kx;
	kareltje.y = MAP_HEIGHT - ky;
	switch(kd) {
		case 0:
			kareltje.dir = NOORD;
			break;
		case 1:
			kareltje.dir = WEST;
			break;
		case 2:
			kareltje.dir = ZUID;
			break;
		case 3:
			kareltje.dir = OOST;
			break;
	}
	map[MAP_HEIGHT - by][bx] = BAL;

	while(hmuren--) {
		int mx, my, md;
		fscanf(fh, "%d %d %d\n", &mx, &my, &md);

		if(mx+md >= MAP_WIDTH || my >= MAP_HEIGHT) {
			gui_die("Doolhof doesn't fit");
		}

		while(md--) {
			map[MAP_HEIGHT - my][mx] = MUUR;
			mx++;
		}
	}

	while(vmuren--) {
		int mx, my, md;
		fscanf(fh, "%d %d %d\n", &mx, &my, &md);

		if(mx >= MAP_WIDTH || my+md >= MAP_HEIGHT) {
			gui_die("Doolhof doesn't fit");
		}

		while(md--) {
			map[MAP_HEIGHT - my][mx] = MUUR;
			my++;
		}
	}

	//fclose(fh);
	gui_refresh(map, &kareltje);
}
Example #24
0
void
gui_set_output_language (string lan) {
  set_output_language (lan);
  get_server () -> refresh ();
  gui_refresh ();
}
Example #25
0
void
stap(void) {
	stap_undelayed();
	gui_refresh(map, &kareltje);
}