"Fossies" - the Fresh Open Source Software Archive

Member "gamgi0.17.5x/src/gtk/gamgi_gtk_measure.c" (23 Feb 2022, 44846 Bytes) of package /linux/misc/gamgi-all-0.17.5x.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /******************************************
    2  *
    3  * $GAMGI/src/gtk/gamgi_gtk_measure.c
    4  *
    5  * Copyright (C) 2004 Carlos Pereira
    6  *
    7  * Distributed under the terms of the GNU
    8  * General Public License: $GAMGI/LICENSE
    9  *
   10  */
   11 
   12 #include "gamgi_engine.h"
   13 #include "gamgi_gtk.h"
   14 #include "gamgi_mesa.h"
   15 #include "gamgi_math.h"
   16 #include "gamgi_chem.h"
   17 #include "gamgi_phys.h"
   18 #include "gamgi_io.h"
   19 #include "gamgi_global.h"
   20 
   21 #include "gamgi_engine_create.h"
   22 #include "gamgi_engine_start.h"
   23 #include "gamgi_engine_link.h"
   24 #include "gamgi_engine_list.h"
   25 #include "gamgi_engine_remove.h"
   26 #include "gamgi_gtk_dialog.h"
   27 #include "gamgi_gtk_object.h"
   28 #include "gamgi_gtk_history.h"
   29 #include "gamgi_mesa_start.h"
   30 #include "gamgi_chem_geometry.h"
   31 #include "gamgi_chem_symmetry.h"
   32 #include "gamgi_phys_reciprocal.h"
   33 #include "gamgi_phys_voronoi.h"
   34 #include "gamgi_phys_cell.h"
   35 #include "gamgi_math_vector.h"
   36 #include "gamgi_math_matrix.h"
   37 #include "gamgi_io_token.h"
   38 
   39 static void static_reciprocal_bravais (GtkWidget *widget, void *data)
   40 {
   41 gamgi_window *window = GAMGI_CAST_WINDOW data;
   42 GtkWidget *dialog = window->dialog0;
   43 GtkWidget *entry;
   44 char token[GAMGI_ENGINE_TOKEN];
   45 
   46 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_entry_constant");
   47 
   48 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE)
   49   {
   50   gtk_entry_set_text (GTK_ENTRY (entry), "");
   51   gtk_widget_set_sensitive (entry, FALSE);
   52   }
   53 else
   54   {
   55   gtk_widget_set_sensitive (entry, TRUE);
   56   sprintf (token, "%.*f", gamgi->gamgi->length, GAMGI_PHYS_RECIPROCAL_DEFAULT);
   57   gtk_entry_set_text (GTK_ENTRY (entry), token);
   58   }
   59 }
   60 
   61 static void static_reciprocal_start (gamgi_layer *layer_old, 
   62 gamgi_layer *layer)
   63 {
   64 /*************************
   65  * give non-default name *
   66  *************************/
   67 
   68 strcpy (layer->object.name, "Analysis");
   69 
   70 /****************************************
   71  * copy projection,modelview parameters *
   72  ****************************************/
   73 
   74 layer->perspective = layer_old->perspective;
   75 layer->top = layer_old->top;
   76 layer->near = layer_old->near;
   77 layer->far = layer_old->far;
   78 
   79 gamgi_math_vector_copy (layer_old->eye, layer->eye);
   80 gamgi_math_vector_copy (layer_old->center, layer->center);
   81 gamgi_math_vector_copy (layer_old->up, layer->up);
   82 
   83 gamgi_math_matrix_copy (layer_old->referential, layer->referential);
   84  
   85 /************************
   86  * copy view parameters *
   87  ************************/
   88 
   89 layer->visibility_in = layer_old->visibility_in;
   90 layer->visibility_out = layer_old->visibility_out;
   91 
   92 layer->axes = layer_old->axes;
   93 
   94 layer->color[0] = layer_old->color[0];
   95 layer->color[1] = layer_old->color[1];
   96 layer->color[2] = layer_old->color[2];
   97 
   98 layer->object.scale = layer_old->object.scale;
   99 }
  100 
  101 static gamgi_layer *static_reciprocal_create (gamgi_layer *layer_old, 
  102 gamgi_window *window)
  103 {
  104 gamgi_layer *layer;
  105 
  106 /********************
  107  * create new layer *
  108  ********************/
  109 
  110 layer = gamgi_engine_create_layer ();
  111 gamgi_engine_start_layer (layer);
  112 static_reciprocal_start (layer_old, layer);
  113 
  114 /**********************************
  115  * start undo and save mechanisms *
  116  **********************************/
  117 
  118 gamgi_gtk_history_start (layer);
  119 
  120 return layer;
  121 }
  122 
  123 static void static_voronoi_color (GtkWidget *widget, void *data)
  124 {
  125 gamgi_window *window = GAMGI_CAST_WINDOW data;
  126 GtkWidget *dialog = window->dialog0;
  127 GtkWidget *entry_red, *entry_green, *entry_blue;
  128 GtkWidget *label_red, *label_green, *label_blue;
  129 char token[GAMGI_ENGINE_TOKEN];
  130 
  131 entry_red = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_red");
  132 entry_green = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_green");
  133 entry_blue = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_blue");
  134 label_red = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_label_red");
  135 label_green = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_label_green");
  136 label_blue = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_label_blue");
  137 
  138 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE)
  139   {
  140   gtk_widget_set_sensitive (entry_red, TRUE);
  141   gtk_widget_set_sensitive (entry_green, TRUE);
  142   gtk_widget_set_sensitive (entry_blue, TRUE);
  143   gtk_widget_set_sensitive (label_red, TRUE);
  144   gtk_widget_set_sensitive (label_green, TRUE);
  145   gtk_widget_set_sensitive (label_blue, TRUE);
  146   sprintf (token, "%.*f", GAMGI_MATH_DECIMAL_COLOR, GAMGI_MESA_CLUSTER_R);
  147   gtk_entry_set_text (GTK_ENTRY (entry_red), token);
  148   sprintf (token, "%.*f", GAMGI_MATH_DECIMAL_COLOR, GAMGI_MESA_CLUSTER_G);
  149   gtk_entry_set_text (GTK_ENTRY (entry_green), token);
  150   sprintf (token, "%.*f", GAMGI_MATH_DECIMAL_COLOR, GAMGI_MESA_CLUSTER_B);
  151   gtk_entry_set_text (GTK_ENTRY (entry_blue), token);
  152   }
  153 else
  154   {
  155   gtk_widget_set_sensitive (entry_red, FALSE);
  156   gtk_widget_set_sensitive (entry_green, FALSE);
  157   gtk_widget_set_sensitive (entry_blue, FALSE);
  158   gtk_widget_set_sensitive (label_red, FALSE);
  159   gtk_widget_set_sensitive (label_green, FALSE);
  160   gtk_widget_set_sensitive (label_blue, FALSE);
  161   gtk_entry_set_text (GTK_ENTRY (entry_red), "");
  162   gtk_entry_set_text (GTK_ENTRY (entry_green), "");
  163   gtk_entry_set_text (GTK_ENTRY (entry_blue), "");
  164   }
  165 }
  166 
  167 static void static_voronoi_faces (GtkWidget *widget, void *data)
  168 {
  169 gamgi_window *window = GAMGI_CAST_WINDOW data;
  170 GtkWidget *dialog = window->dialog0;
  171 GtkWidget *combo;
  172 GtkWidget *button;
  173 gamgi_bool *sensitive;
  174 int row;
  175 
  176 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_color");
  177 
  178 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE)
  179   {
  180   /**********************************************************************
  181    * in solid mode, color can be automatic (default) or set by the user *
  182    **********************************************************************/
  183 
  184   gtk_widget_set_sensitive (button, TRUE);
  185   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
  186   }
  187 else
  188   {
  189   /************************************************
  190    * in wired mode, color must be set by the user *
  191    ************************************************/
  192   
  193   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  194   gtk_widget_set_sensitive (button, FALSE);
  195   }
  196 
  197 /*************************
  198  * get borders combo box *
  199  *************************/
  200 
  201 combo = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_combo_borders");
  202 row = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
  203 sensitive = (gamgi_bool *) g_object_get_data (G_OBJECT (dialog), "voronoi_sensitive_borders");
  204 
  205 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE)
  206   {
  207   /*********************************************
  208    * in solid mode, disable ALL borders option *
  209    *********************************************/
  210 
  211   if (row == GAMGI_PHYS_ALL - 1)
  212     gtk_combo_box_set_active (GTK_COMBO_BOX (combo), GAMGI_PHYS_FACES - 1);
  213   sensitive[GAMGI_PHYS_ALL - 1] = FALSE;
  214   }
  215 else
  216   {
  217   sensitive[GAMGI_PHYS_ALL - 1] = TRUE;
  218   }
  219 
  220 static_voronoi_color (button, window);
  221 }
  222 
  223 static void static_voronoi_layer (gamgi_cluster *cluster, gamgi_window *window)
  224 {
  225 gamgi_layer *layer;
  226 
  227 /********************
  228  * create new layer *
  229  ********************/
  230 
  231 layer = gamgi_engine_create_layer ();
  232 gamgi_engine_start_layer (layer);
  233 gamgi_mesa_start_layer (layer, gamgi->layer);
  234 layer->visibility_out = GAMGI_GTK_NONE;
  235 strcpy (layer->object.name, "Analysis");
  236 
  237 /**********************************
  238  * start undo and save mechanisms *
  239  **********************************/
  240 
  241 gamgi_gtk_history_start (layer);
  242 
  243 /****************************************
  244  * add Voronoi tesselation to new layer *
  245  ****************************************/
  246 
  247 gamgi_engine_link_cluster_layer (cluster, layer);
  248 
  249 /****************************************************
  250  * set up layer as current layer and current object *
  251  ****************************************************/
  252 
  253 gamgi_engine_link_layer_window (layer, window);
  254 gamgi_gtk_object_layer_local (layer, window);
  255 gamgi_gtk_object_focus_local (GAMGI_CAST_OBJECT layer, window);
  256 
  257 /******************************************
  258  * redraw image: show Voronoi tesselation *
  259  ******************************************/
  260 
  261 gtk_widget_queue_draw (window->area);
  262 }
  263 
  264 void gamgi_gtk_measure_geometry_ok (gamgi_object *object, gamgi_window *window)
  265 {
  266 GtkWidget *dialog;
  267 GtkWidget *text;
  268 gamgi_enum action;
  269 
  270 /**************************************
  271  * create and initialize text widget, *
  272  * to show the Geometry report        *
  273  **************************************/
  274 
  275 text = gamgi_gtk_dialog_text_create ();
  276 
  277 /***************************
  278  * apply voronoi algorithm *
  279  ***************************/
  280 
  281 if (gamgi_chem_geometry (object, text, window->layer) == FALSE)
  282   {
  283   gamgi_gtk_dialog_message_create ("Error", "Invalid object data", window);
  284   gtk_widget_destroy (text);
  285   return;
  286   }
  287 
  288 /*************************************************************
  289  * create and initialize text dialog showing Geometry report *
  290  *************************************************************/
  291 
  292 action = FALSE;
  293 if (window->action == GAMGI_GTK_GROUP_MEASURE)
  294   action = GAMGI_GTK_GROUP_MEASURE_GEOMETRY;
  295 if (window->action == GAMGI_GTK_MOLECULE_MEASURE)
  296   action = GAMGI_GTK_MOLECULE_MEASURE_GEOMETRY;
  297 if (window->action == GAMGI_GTK_CLUSTER_MEASURE)
  298   action = GAMGI_GTK_CLUSTER_MEASURE_GEOMETRY;
  299 if (window->action == GAMGI_GTK_CELL_MEASURE)
  300   action = GAMGI_GTK_CELL_MEASURE_GEOMETRY;
  301 
  302 dialog = gamgi_gtk_dialog_report_create (text, 
  303 "Measure Geometry", action, window);
  304 
  305 gtk_widget_show (dialog);
  306 }
  307 
  308 void gamgi_gtk_measure_symmetry_ok (gamgi_object *object, gamgi_window *window)
  309 {
  310 GtkWidget *dialog = window->dialog0;
  311 GtkWidget *text;
  312 GtkWidget *entry;
  313 GtkWidget *button;
  314 const char *name;
  315 float initial, final;
  316 gamgi_bool periodic;
  317 gamgi_enum action;
  318 
  319 /***********************************************
  320  * chemical or crystallographic point symmetry *
  321  ***********************************************/
  322 
  323 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_button_yes");
  324 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  325   periodic = TRUE;
  326 else
  327   periodic = FALSE;
  328 
  329 /********************************
  330  * Get initial,final tolerances *
  331  ********************************/
  332 
  333 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_entry_initial");
  334 name = gtk_entry_get_text (GTK_ENTRY (entry));
  335 if (gamgi_io_token_float_scan (name, &initial, 0.0, 1.0) == FALSE)
  336   {
  337   gamgi_gtk_dialog_message_create ("Error", "Invalid tolerance data", window);
  338   return;
  339   }
  340 
  341 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_entry_final");
  342 name = gtk_entry_get_text (GTK_ENTRY (entry));
  343 if (gamgi_io_token_float_scan (name, &final, 0.0, initial) == FALSE)
  344   {
  345   gamgi_gtk_dialog_message_create ("Error", "Invalid tolerance data", window);
  346   return;
  347   }
  348 
  349 /**************************************
  350  * create and initialize text widget, * 
  351  * to show the point symmetry report  *
  352  **************************************/
  353 
  354 text = gamgi_gtk_dialog_text_create ();
  355 
  356 /**********************************
  357  * determine symmetry information *
  358  **********************************/
  359 
  360 if (gamgi_chem_symmetry (object, 
  361 periodic, initial, final, text) == FALSE)
  362   {
  363   gamgi_gtk_dialog_message_create ("Error", "Invalid object data", window);
  364   gtk_widget_destroy (text);
  365   return;
  366   }
  367 
  368 /*************************************************************
  369  * create and initialize text dialog showing Symmetry report *
  370  *************************************************************/
  371 
  372 action = FALSE;
  373 if (window->action == GAMGI_GTK_GROUP_MEASURE)
  374   action = GAMGI_GTK_GROUP_MEASURE_SYMMETRY;
  375 if (window->action == GAMGI_GTK_MOLECULE_MEASURE)
  376   action = GAMGI_GTK_MOLECULE_MEASURE_SYMMETRY;
  377 if (window->action == GAMGI_GTK_CLUSTER_MEASURE)
  378   action = GAMGI_GTK_CLUSTER_MEASURE_SYMMETRY;
  379 
  380 dialog = gamgi_gtk_dialog_report_create (text, 
  381 "Measure Symmetry", action, window);
  382 
  383 gtk_widget_show (dialog);
  384 }
  385 
  386 void gamgi_gtk_measure_symmetry_init (gamgi_window *window)
  387 {
  388 GtkWidget *dialog = window->dialog0;
  389 GtkWidget *entry;
  390 GtkWidget *button;
  391 char token[GAMGI_ENGINE_TOKEN];
  392 
  393 /*****************************
  394  * no periodicity by default *
  395  *****************************/
  396 
  397 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_button_no");
  398 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  399 
  400 /*****************************************
  401  * initialise lower,upper length factors *
  402  *****************************************/
  403 
  404 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_entry_initial");
  405 sprintf (token, "%f", GAMGI_CHEM_SYMMETRY_TOLERANCE_INITIAL);
  406 gtk_entry_set_text (GTK_ENTRY (entry), token);
  407 
  408 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "symmetry_entry_final");
  409 sprintf (token, "%f", GAMGI_CHEM_SYMMETRY_TOLERANCE_FINAL);
  410 gtk_entry_set_text (GTK_ENTRY (entry), token);
  411 }
  412 
  413 void gamgi_gtk_measure_symmetry (GtkWidget *notebook, gamgi_window *window)
  414 {
  415 GtkWidget *dialog = window->dialog0;
  416 GtkWidget *button;
  417 GtkWidget *label;
  418 GtkWidget *entry;
  419 GtkWidget *hbox_center, *hbox_left;
  420 GtkWidget *vbox_page, *vbox_center, *vbox_top;
  421 
  422 /*****************
  423  * Symmetry page *
  424  *****************/
  425 
  426 vbox_page = gtk_vbox_new (FALSE, 5);
  427 label = gtk_label_new ("Symmetry");
  428 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);
  429 gtk_container_set_border_width (GTK_CONTAINER (vbox_page), 10);
  430 g_object_set_data (G_OBJECT (dialog), "symmetry_vbox_page", vbox_page);
  431 gtk_widget_show (vbox_page);
  432 
  433 vbox_center = gtk_vbox_new (TRUE, 0);
  434 gtk_box_pack_start (GTK_BOX (vbox_page), vbox_center, TRUE, TRUE, 0);
  435 gtk_widget_show (vbox_center);
  436 
  437 vbox_top = gtk_vbox_new (FALSE, 15);
  438 gtk_box_pack_start (GTK_BOX (vbox_center), vbox_top, FALSE, FALSE, 0);
  439 gtk_widget_show (vbox_top);
  440 
  441 /************
  442  * Symmetry *
  443  ************/
  444 
  445 hbox_center = gtk_hbox_new (TRUE, 0);
  446 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
  447 gtk_widget_show (hbox_center);
  448 
  449 hbox_left = gtk_hbox_new (FALSE, 5);
  450 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
  451 gtk_widget_show (hbox_left);
  452 
  453 /***********************************************
  454  * chemical or crystallographic point symmetry *
  455  ***********************************************/
  456 
  457 label = gtk_label_new ("Periodicity");
  458 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
  459 gtk_widget_show (label);
  460 
  461 button = gtk_radio_button_new_with_label (NULL, "Yes");
  462 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
  463 g_object_set_data (G_OBJECT (dialog), "symmetry_button_yes", button);
  464 gtk_widget_show (button);
  465 
  466 button = gtk_radio_button_new_with_label (
  467 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), "No");
  468 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
  469 g_object_set_data (G_OBJECT (dialog), "symmetry_button_no", button);
  470 gtk_widget_show (button);
  471 
  472 /*************
  473  * tolerance *
  474  *************/
  475 
  476 hbox_center = gtk_hbox_new (TRUE, 0);
  477 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
  478 gtk_widget_show (hbox_center);
  479 
  480 hbox_left = gtk_hbox_new (FALSE, 5);
  481 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
  482 gtk_widget_show (hbox_left);
  483 
  484 label = gtk_label_new ("Tolerance");
  485 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
  486 gtk_widget_show (label);
  487 
  488 entry = gtk_entry_new ();
  489 gtk_box_pack_start (GTK_BOX (hbox_left), entry, FALSE, FALSE, 0);
  490 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  491 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  492 g_object_set_data (G_OBJECT (dialog), "symmetry_entry_initial", entry);
  493 gtk_widget_show (entry);
  494 
  495 label = gtk_label_new ("Initial");
  496 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
  497 gtk_widget_show (label);
  498 
  499 entry = gtk_entry_new ();
  500 gtk_box_pack_start (GTK_BOX (hbox_left), entry, FALSE, FALSE, 0);
  501 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  502 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  503 g_object_set_data (G_OBJECT (dialog), "symmetry_entry_final", entry);
  504 gtk_widget_show (entry);
  505 
  506 label = gtk_label_new ("Final");
  507 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
  508 gtk_widget_show (label);
  509 }
  510 
  511 void gamgi_gtk_measure_reciprocal_ok (gamgi_object *object, gamgi_window *window)
  512 {
  513 gamgi_layer *layer_new;
  514 GtkWidget *dialog = window->dialog0;
  515 gamgi_cell *cell, *cell_new;
  516 GtkWidget *entry;
  517 GtkWidget *button;
  518 const char *name;
  519 double factor;
  520 gamgi_bool primitive, planes;
  521 
  522 cell = GAMGI_CAST_CELL object;
  523 
  524 /************************************
  525  * Add primitive lattice and planes *
  526  ************************************/
  527 
  528 primitive = FALSE;
  529 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_lattice");
  530 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  531   {
  532   /************************************************
  533    * adding the reciprocal of the primitive       *
  534    * lattice is useful only for centered lattices *
  535    ************************************************/
  536 
  537   if (cell->model != GAMGI_PHYS_CONVENTIONAL ||
  538   gamgi_phys_cell_primitive (cell->lattice) == cell->lattice)
  539     {
  540     gamgi_gtk_dialog_message_create ("Error", 
  541     "Redundant primitive lattice for non centered lattice", window);
  542     return;
  543     }
  544   primitive = TRUE;
  545   }
  546 
  547 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_planes");
  548 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  549   planes = TRUE;
  550 else
  551   planes = FALSE;
  552 
  553 /******************************************
  554  * Get reciprocal lattice constant factor *
  555  ******************************************/
  556 
  557 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_bravais");
  558 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_entry_constant");
  559 name = gtk_entry_get_text (GTK_ENTRY (entry));
  560 
  561 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  562   {
  563   /*****************************************************
  564    * determine reciprocal lattice constant according   *
  565    * to Bravais polar lattice method, so direct and    *
  566    * reciprocal lattices have the same volume per node *
  567    *****************************************************/
  568 
  569   factor = gamgi_math_vector_mix (cell->p1, cell->p2, cell->p3);
  570   factor = pow (factor, 2.0/3.0);
  571   }
  572 else if (gamgi_io_token_double_scan (name, &factor,
  573 GAMGI_PHYS_RECIPROCAL_MIN, DBL_MAX) == FALSE)
  574   {
  575   gamgi_gtk_dialog_message_create ("Error", "Invalid Factor Data", window);
  576   return;
  577   }
  578 
  579 /*******************************************************
  580  * Create new layer to contain the reciprocal lattice. *
  581  *                                                     *
  582  * Create new cell to contain the reciprocal lattice.  *
  583  * For centered lattices, the corresponding primitive  *
  584  * lattice can also be transformed in its reciprocal   *
  585  * lattice, thus requiring a second cell. This option  *
  586  * should be available only for conventional cells.    *
  587  *                                                     *
  588  * The real lattice uses a subset of the lines used by *
  589  * the primitive lattice, so it should be added in the *
  590  * end, to be rendered after the primitive lattice, to *
  591  * overwrite the primitive, so both cells are visible. *
  592  *                                                     *
  593  * If required, create plane objects for all nodes     *
  594  * (except 000) of the new reciprocal lattice volume.  *
  595  *******************************************************/
  596 
  597 layer_new = static_reciprocal_create (window->layer, window);
  598 
  599 if (primitive == TRUE)
  600   {
  601   cell_new = gamgi_phys_reciprocal_primitive (cell, factor, window);
  602   gamgi_engine_link_cell_layer (cell_new, layer_new);
  603   }
  604 
  605 cell_new = gamgi_phys_reciprocal (cell, factor, planes, window);
  606 gamgi_engine_link_cell_layer (cell_new, layer_new);
  607 
  608 /****************************************************
  609  * set up layer as current layer and current object *
  610  ****************************************************/
  611 
  612 gamgi_engine_link_layer_window (layer_new, window);
  613 gamgi_gtk_object_layer_local (layer_new, window);
  614 gamgi_gtk_object_focus_local (GAMGI_CAST_OBJECT layer_new, window);
  615 
  616 gamgi_gtk_dialog_task0_remove (NULL, window);
  617 
  618 /*****************************************
  619  * redraw image: show reciprocal lattice *
  620  *****************************************/
  621 
  622 gtk_widget_queue_draw (window->area);
  623 }
  624 
  625 void gamgi_gtk_measure_reciprocal_init (gamgi_window *window)
  626 {
  627 GtkWidget *dialog = window->dialog0;
  628 GtkWidget *notebook;
  629 GtkWidget *button;
  630 
  631 /****************
  632  * set notebook *
  633  ****************/
  634 
  635 notebook = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "notebook");
  636 gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
  637 
  638 /*******************
  639  * initialize view *
  640  *******************/
  641 
  642 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_lattice");
  643 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
  644 
  645 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_planes");
  646 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
  647 
  648 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "reciprocal_button_bravais");
  649 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  650   {
  651   if (GAMGI_PHYS_RECIPROCAL_BRAVAIS == FALSE)
  652     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
  653   }
  654 else
  655   {
  656   if (GAMGI_PHYS_RECIPROCAL_BRAVAIS == TRUE)
  657     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  658   }
  659 
  660 static_reciprocal_bravais (button, window);
  661 }
  662 
  663 void gamgi_gtk_measure_reciprocal (GtkWidget *notebook, gamgi_window *window)
  664 {
  665 GtkWidget *dialog = window->dialog0;
  666 GtkWidget *button;
  667 GtkWidget *label;
  668 GtkWidget *entry;
  669 GtkWidget *hbox_center, *hbox_left, *hbox_left_left;
  670 GtkWidget *vbox_page, *vbox_center, *vbox_top;
  671 
  672 /*******************
  673  * Reciprocal page *
  674  *******************/
  675 
  676 vbox_page = gtk_vbox_new (FALSE, 5);
  677 label = gtk_label_new ("Reciprocal");
  678 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);
  679 gtk_container_set_border_width (GTK_CONTAINER (vbox_page), 10);
  680 g_object_set_data (G_OBJECT (dialog), "reciprocal_vbox_page", vbox_page);
  681 gtk_widget_show (vbox_page);
  682 
  683 vbox_center = gtk_vbox_new (TRUE, 0);
  684 gtk_box_pack_start (GTK_BOX (vbox_page), vbox_center, TRUE, TRUE, 0);
  685 gtk_widget_show (vbox_center);
  686 
  687 vbox_top = gtk_vbox_new (FALSE, 15);
  688 gtk_box_pack_start (GTK_BOX (vbox_center), vbox_top, FALSE, FALSE, 0);
  689 gtk_widget_show (vbox_top);
  690 
  691 /******************************************
  692  * primitive lattice; conventional planes *
  693  ******************************************/
  694 
  695 hbox_center = gtk_hbox_new (TRUE, 0);
  696 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
  697 gtk_widget_show (hbox_center);
  698 
  699 hbox_left = gtk_hbox_new (FALSE, 10);
  700 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
  701 gtk_widget_show (hbox_left);
  702 
  703 hbox_left_left = gtk_hbox_new (FALSE, 5);
  704 gtk_box_pack_start (GTK_BOX (hbox_left), hbox_left_left, FALSE, FALSE, 0);
  705 gtk_widget_show (hbox_left_left);
  706 
  707 label = gtk_label_new ("Primitive");
  708 gtk_box_pack_start (GTK_BOX (hbox_left_left), label, FALSE, FALSE, 0);
  709 gtk_widget_show (label);
  710 
  711 button = gtk_toggle_button_new_with_label ("Lattice");
  712 gtk_box_pack_start (GTK_BOX (hbox_left_left), button, FALSE, FALSE, 0);
  713 g_object_set_data (G_OBJECT (dialog), "reciprocal_button_lattice", button);
  714 gtk_widget_show (button);
  715 
  716 hbox_left_left = gtk_hbox_new (FALSE, 5);
  717 gtk_box_pack_start (GTK_BOX (hbox_left), hbox_left_left, FALSE, FALSE, 0);
  718 gtk_widget_show (hbox_left_left);
  719 
  720 label = gtk_label_new ("Conventional");
  721 gtk_box_pack_start (GTK_BOX (hbox_left_left), label, FALSE, FALSE, 0);
  722 gtk_widget_show (label);
  723 
  724 button = gtk_toggle_button_new_with_label ("Planes");
  725 gtk_box_pack_start (GTK_BOX (hbox_left_left), button, FALSE, FALSE, 0);
  726 g_object_set_data (G_OBJECT (dialog), "reciprocal_button_planes", button);
  727 gtk_widget_show (button);
  728 
  729 /******************************************************
  730  * reciprocal lattice constant, Bravais polar lattice *
  731  ******************************************************/
  732 
  733 hbox_center = gtk_hbox_new (TRUE, 0);
  734 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
  735 gtk_widget_show (hbox_center);
  736 
  737 hbox_left = gtk_hbox_new (FALSE, 5);
  738 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
  739 gtk_widget_show (hbox_left);
  740 
  741 label = gtk_label_new ("Constant");
  742 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
  743 gtk_widget_show (label);
  744 
  745 entry = gtk_entry_new ();
  746 gtk_box_pack_start (GTK_BOX (hbox_left), entry, FALSE, FALSE, 0);
  747 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  748 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
  749 g_object_set_data (G_OBJECT (dialog), "reciprocal_entry_constant", entry);
  750 gtk_widget_show (entry);
  751 
  752 button = gtk_toggle_button_new_with_label ("Bravais");
  753 gtk_box_pack_end (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
  754 g_signal_connect (button, "clicked",
  755 G_CALLBACK (static_reciprocal_bravais), window);
  756 g_object_set_data (G_OBJECT (dialog), "reciprocal_button_bravais", button);
  757 gtk_widget_show (button);
  758 }
  759 
  760 void gamgi_gtk_measure_voronoi_ok (gamgi_object *object, gamgi_window *window)
  761 {
  762 gamgi_cluster *cluster;
  763 GtkWidget *dialog = window->dialog0;
  764 GtkWidget *text;
  765 GtkWidget *entry;
  766 GtkWidget *button;
  767 GtkWidget *combo;
  768 const char *name;
  769 gamgi_bool periodic;
  770 gamgi_enum borders;
  771 double offset, variancy;
  772 double apex, area, vertex;
  773 float rgb[3];
  774 float *color;
  775 gamgi_enum action;
  776 
  777 /**************************************
  778  * boundary section: periodic, offset *
  779  **************************************/
  780 
  781 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_periodic");
  782 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  783   periodic = TRUE;
  784 else
  785   periodic = FALSE;
  786 
  787 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_offset");
  788 name = gtk_entry_get_text (GTK_ENTRY (entry));
  789 if (gamgi_io_token_double_scan (name, &offset, 0.0, DBL_MAX) == FALSE
  790 || (periodic == FALSE && offset < GAMGI_MATH_TOLERANCE_LENGTH))
  791   {
  792   gamgi_gtk_dialog_message_create ("Error", "Invalid Boundary Data", window);
  793   return;
  794   }
  795 
  796 /***********************************************
  797  *           polyhedra weight variancy         *
  798  * 0.0: normal tesselation                     *
  799  * 1.0: radical tesselation with atomic radius *
  800  ***********************************************/
  801 
  802 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_variancy");
  803 name = gtk_entry_get_text (GTK_ENTRY (entry));
  804 if (gamgi_io_token_double_scan (name, &variancy, 
  805 0.0, GAMGI_PHYS_VORONOI_VARIANCY) == FALSE)
  806   {
  807   gamgi_gtk_dialog_message_create ("Error", "Invalid Variancy Data", window);
  808   return;
  809   }
  810 
  811 /*****************************************
  812  * tolerance section: apex, area, vertex *
  813  *****************************************/
  814 
  815 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_apex");
  816 name = gtk_entry_get_text (GTK_ENTRY (entry));
  817 if (gamgi_io_token_double_scan (name, &apex, 
  818 0.0, GAMGI_PHYS_VORONOI_TOLERANCE) == FALSE)
  819   {
  820   gamgi_gtk_dialog_message_create ("Error", "Invalid Tolerance Data", window);
  821   return;
  822   }
  823 
  824 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_area");
  825 name = gtk_entry_get_text (GTK_ENTRY (entry));
  826 if (gamgi_io_token_double_scan (name, &area, 
  827 0.0, GAMGI_PHYS_VORONOI_TOLERANCE) == FALSE)
  828   {
  829   gamgi_gtk_dialog_message_create ("Error", "Invalid Tolerance Data", window);
  830   return;
  831   }
  832 
  833 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_vertex");
  834 name = gtk_entry_get_text (GTK_ENTRY (entry));
  835 if (gamgi_io_token_double_scan (name, &vertex, 
  836 0.0, GAMGI_PHYS_VORONOI_TOLERANCE) == FALSE)
  837   {
  838   gamgi_gtk_dialog_message_create ("Error", "Invalid Tolerance Data", window);
  839   return;
  840   }
  841 
  842 /***************************************
  843  * view section: color, red,green,blue *
  844  ***************************************/
  845 
  846 color = NULL;
  847 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_color");
  848 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  849   color = rgb;
  850 
  851 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_red");
  852 name = gtk_entry_get_text (GTK_ENTRY (entry));
  853 if (color != NULL &&
  854 gamgi_io_token_float_scan (name, &color[0], 0.0, 1.0) == FALSE)
  855   {
  856   gamgi_gtk_dialog_message_create ("Error", "Invalid Color Data", window);
  857   return;
  858   }
  859 
  860 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_green");
  861 name = gtk_entry_get_text (GTK_ENTRY (entry));
  862 if (color != NULL &&
  863 gamgi_io_token_float_scan (name, &color[1], 0.0, 1.0) == FALSE)
  864   {
  865   gamgi_gtk_dialog_message_create ("Error", "Invalid Color Data", window);
  866   return;
  867   }
  868 
  869 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_blue");
  870 name = gtk_entry_get_text (GTK_ENTRY (entry));
  871 if (color != NULL &&
  872 gamgi_io_token_float_scan (name, &color[2], 0.0, 1.0) == FALSE)
  873   {
  874   gamgi_gtk_dialog_message_create ("Error", "Invalid Color Data", window);
  875   return;
  876   }
  877 
  878 /*****************************************************
  879  * create cluster to contain the Voronoi tesselation *
  880  *****************************************************/
  881 
  882 cluster = gamgi_engine_create_cluster ();
  883 gamgi_engine_start_cluster (cluster);
  884 strcpy (cluster->object.name, "Voronoi");
  885 
  886 /**************************************
  887  * get faces and atoms toggle buttons *
  888  **************************************/
  889 
  890 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_faces");
  891 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  892   cluster->faces = TRUE;
  893 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_atoms");
  894 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) == TRUE)
  895   cluster->atoms = TRUE;
  896 
  897 /********************************
  898  * get borders combo box option *
  899  ********************************/
  900 
  901 combo = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_combo_borders");
  902 borders = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) + 1;
  903 
  904 /******************************************
  905  * create and initialize text widget,     *
  906  * to show the Voronoi tesselation report *
  907  ******************************************/
  908 
  909 text = gamgi_gtk_dialog_text_create ();
  910 
  911 /***************************
  912  * apply voronoi algorithm *
  913  ***************************/
  914 
  915 if (gamgi_phys_voronoi (object, cluster, periodic, 
  916 offset, variancy, apex, area, vertex, color, borders, text) == FALSE)
  917   {
  918   gamgi_gtk_dialog_message_create ("Error", "Invalid object data", window);
  919   gamgi_engine_remove_cluster (cluster);
  920   gtk_widget_destroy (text);
  921   return;
  922   }
  923 
  924 /************************************************************
  925  * create and initialize layer showing Voronoi tesselation  *
  926  *                                                          *
  927  * create and initialize text dialog showing Voronoi report *
  928  ************************************************************/
  929 
  930 static_voronoi_layer (cluster, window);
  931 
  932 action = FALSE;
  933 if (window->action == GAMGI_GTK_GROUP_MEASURE)
  934   action = GAMGI_GTK_GROUP_MEASURE_VORONOI;
  935 if (window->action == GAMGI_GTK_MOLECULE_MEASURE)
  936   action = GAMGI_GTK_MOLECULE_MEASURE_VORONOI;
  937 if (window->action == GAMGI_GTK_CLUSTER_MEASURE)
  938   action = GAMGI_GTK_CLUSTER_MEASURE_VORONOI;
  939 if (window->action == GAMGI_GTK_CELL_MEASURE)
  940   action = GAMGI_GTK_CELL_MEASURE_VORONOI;
  941 
  942 dialog = gamgi_gtk_dialog_report_create (text, 
  943 "Measure Voronoi", action, window);
  944 
  945 gtk_widget_show (dialog);
  946 }
  947 
  948 void gamgi_gtk_measure_voronoi_init (gamgi_window *window)
  949 {
  950 GtkWidget *dialog = window->dialog0;
  951 GtkWidget* entry;
  952 GtkWidget* button;
  953 GtkWidget* combo;
  954 char token[GAMGI_ENGINE_TOKEN];
  955 
  956 /*************************
  957  * initialize boundaries *
  958  *************************/
  959 
  960 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_offset");
  961 sprintf (token, "%.*f", GAMGI_MATH_DECIMAL_LENGTH, GAMGI_PHYS_VORONOI_BORDER);
  962 gtk_entry_set_text (GTK_ENTRY (entry), token);
  963 
  964 /****************************************
  965  * initialize partition weight variancy *
  966  * for normal Voronoi tesselation: 0.0  *
  967  ****************************************/
  968 
  969 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_variancy");
  970 sprintf (token, "%.*f", GAMGI_MATH_DECIMAL_LENGTH, 0.0);
  971 gtk_entry_set_text (GTK_ENTRY (entry), token);
  972 
  973 /************************
  974  * initialize tolerance *
  975  ************************/
  976 
  977 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_apex");
  978 sprintf (token, "%.*E", 2, GAMGI_PHYS_VORONOI_APEX);
  979 gtk_entry_set_text (GTK_ENTRY (entry), token);
  980 
  981 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_area");
  982 sprintf (token, "%.*E", 2, GAMGI_PHYS_VORONOI_AREA);
  983 gtk_entry_set_text (GTK_ENTRY (entry), token);
  984 
  985 entry = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_entry_vertex");
  986 sprintf (token, "%.*E", 2, GAMGI_PHYS_VORONOI_VERTEX);
  987 gtk_entry_set_text (GTK_ENTRY (entry), token);
  988 
  989 /*******************
  990  * initialize view *
  991  *******************/
  992 
  993 combo = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_combo_borders");
  994 gtk_combo_box_set_active (GTK_COMBO_BOX (combo), FALSE);
  995 
  996 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_atoms");
  997 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  998 
  999 button = (GtkWidget *) g_object_get_data (G_OBJECT (dialog), "voronoi_button_faces");
 1000 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
 1001 
 1002 static_voronoi_faces (button, window);
 1003 }
 1004 
 1005 void gamgi_gtk_measure_voronoi (GtkWidget *notebook, gamgi_window *window)
 1006 {
 1007 GtkWidget *dialog = window->dialog0;
 1008 GtkWidget *table;
 1009 GtkWidget *button;
 1010 GtkWidget *label;
 1011 GtkWidget *entry;
 1012 GtkWidget *hbox_center, *hbox_left, *hbox_left_left;
 1013 GtkWidget *vbox_page, *vbox_center, *vbox_top;
 1014 GtkWidget *combo;
 1015 GtkListStore *store;
 1016 GtkCellRenderer *renderer;
 1017 GtkTreeIter iter;
 1018 gamgi_bool *sensitive;
 1019 
 1020 /****************
 1021  * Voronoi page *
 1022  ****************/
 1023 
 1024 vbox_page = gtk_vbox_new (FALSE, 5);
 1025 label = gtk_label_new ("Voronoi");
 1026 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);
 1027 gtk_container_set_border_width (GTK_CONTAINER (vbox_page), 10);
 1028 g_object_set_data (G_OBJECT (dialog), "voronoi_vbox_page1", vbox_page);
 1029 gtk_widget_show (vbox_page);
 1030 
 1031 vbox_center = gtk_vbox_new (TRUE, 0);
 1032 gtk_box_pack_start (GTK_BOX (vbox_page), vbox_center, TRUE, TRUE, 0);
 1033 gtk_widget_show (vbox_center);
 1034 
 1035 vbox_top = gtk_vbox_new (FALSE, 15);
 1036 gtk_box_pack_start (GTK_BOX (vbox_center), vbox_top, FALSE, FALSE, 0);
 1037 gtk_widget_show (vbox_top);
 1038 
 1039 /**************
 1040  * boundaries *
 1041  **************/
 1042 
 1043 hbox_center = gtk_hbox_new (TRUE, 0);
 1044 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
 1045 gtk_widget_show (hbox_center);
 1046 
 1047 hbox_left = gtk_hbox_new (FALSE, 10);
 1048 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
 1049 gtk_widget_show (hbox_left);
 1050 
 1051 label = gtk_label_new ("Boundaries");
 1052 gtk_box_pack_start (GTK_BOX (hbox_left), label, FALSE, FALSE, 0);
 1053 gtk_widget_show (label);
 1054 
 1055 button = gtk_radio_button_new_with_label (NULL, "Planar");
 1056 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
 1057 gtk_widget_show (button);
 1058 
 1059 button = gtk_radio_button_new_with_label (
 1060 gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), "Periodic");
 1061 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
 1062 g_object_set_data (G_OBJECT (dialog), "voronoi_button_periodic", button);
 1063 gtk_widget_show (button);
 1064 
 1065 /***********
 1066  * 2nd row *
 1067  ***********/
 1068 
 1069 hbox_center = gtk_hbox_new (TRUE, 0);
 1070 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
 1071 gtk_widget_show (hbox_center);
 1072 
 1073 hbox_left = gtk_hbox_new (FALSE, 10);
 1074 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
 1075 gtk_widget_show (hbox_left);
 1076 
 1077 /**********
 1078  * offset *
 1079  **********/
 1080 
 1081 hbox_left_left = gtk_hbox_new (FALSE, 5);
 1082 gtk_box_pack_start (GTK_BOX (hbox_left), hbox_left_left, FALSE, FALSE, 0);
 1083 gtk_widget_show (hbox_left_left);
 1084 
 1085 label = gtk_label_new ("Offset");
 1086 gtk_box_pack_start (GTK_BOX (hbox_left_left), label, FALSE, FALSE, 0);
 1087 gtk_widget_show (label);
 1088 
 1089 entry = gtk_entry_new ();
 1090 gtk_box_pack_start (GTK_BOX (hbox_left_left), entry, FALSE, FALSE, 0);
 1091 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
 1092 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
 1093 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_offset", entry);
 1094 gtk_widget_show (entry);
 1095 
 1096 /************
 1097  * variancy *
 1098  ************/
 1099 
 1100 hbox_left_left = gtk_hbox_new (FALSE, 5);
 1101 gtk_box_pack_start (GTK_BOX (hbox_left), hbox_left_left, FALSE, FALSE, 0);
 1102 gtk_widget_show (hbox_left_left);
 1103 
 1104 label = gtk_label_new ("Variancy");
 1105 gtk_box_pack_start (GTK_BOX (hbox_left_left), label, FALSE, FALSE, 0);
 1106 gtk_widget_show (label);
 1107 
 1108 entry = gtk_entry_new ();
 1109 gtk_box_pack_start (GTK_BOX (hbox_left_left), entry, FALSE, FALSE, 0);
 1110 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
 1111 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_7);
 1112 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_variancy", entry);
 1113 gtk_widget_show (entry);
 1114 
 1115 /******************
 1116  * Tolerance page *
 1117  ******************/
 1118 
 1119 vbox_page = gtk_vbox_new (FALSE, 5);
 1120 label = gtk_label_new ("Tolerance");
 1121 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);
 1122 gtk_container_set_border_width (GTK_CONTAINER (vbox_page), 10);
 1123 g_object_set_data (G_OBJECT (dialog), "voronoi_vbox_page2", vbox_page);
 1124 gtk_widget_show (vbox_page);
 1125 
 1126 vbox_center = gtk_vbox_new (TRUE, 0);
 1127 gtk_box_pack_start (GTK_BOX (vbox_page), vbox_center, TRUE, TRUE, 0);
 1128 gtk_widget_show (vbox_center);
 1129 
 1130 vbox_top = gtk_vbox_new (FALSE, 5);
 1131 gtk_box_pack_start (GTK_BOX (vbox_center), vbox_top, FALSE, FALSE, 0);
 1132 gtk_widget_show (vbox_top);
 1133 
 1134 /*************
 1135  * tolerance *
 1136  *************/
 1137 
 1138 hbox_center = gtk_hbox_new (TRUE, 0);
 1139 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
 1140 gtk_widget_show (hbox_center);
 1141 
 1142 hbox_left = gtk_hbox_new (FALSE, 5);
 1143 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
 1144 gtk_widget_show (hbox_left);
 1145 
 1146 table = gtk_table_new (2, 3, FALSE);
 1147 gtk_box_pack_start (GTK_BOX (hbox_left), table, FALSE, FALSE, 0);
 1148 gtk_widget_show (table);
 1149 
 1150 label = gtk_label_new ("Apex");
 1151 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND, GTK_FILL, 0, 0);
 1152 gtk_widget_show (label);
 1153 
 1154 label = gtk_label_new ("Area");
 1155 gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_EXPAND, GTK_FILL, 0, 0);
 1156 gtk_widget_show (label);
 1157 
 1158 label = gtk_label_new ("Vertex");
 1159 gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_EXPAND, GTK_FILL, 0, 0);
 1160 gtk_widget_show (label);
 1161 
 1162 entry = gtk_entry_new ();
 1163 gtk_table_attach (GTK_TABLE (table), entry, 0, 1, 1, 2, GTK_EXPAND, GTK_FILL, 5, 5);
 1164 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1165 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1166 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_apex", entry);
 1167 gtk_widget_show (entry);
 1168 
 1169 entry = gtk_entry_new ();
 1170 gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND, GTK_FILL, 5, 5);
 1171 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1172 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1173 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_area", entry);
 1174 gtk_widget_show (entry);
 1175 
 1176 entry = gtk_entry_new ();
 1177 gtk_table_attach (GTK_TABLE (table), entry, 2, 3, 1, 2, GTK_EXPAND, GTK_FILL, 5, 5);
 1178 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1179 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_10);
 1180 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_vertex", entry);
 1181 gtk_widget_show (entry);
 1182 
 1183 /*************
 1184  * View page *
 1185  *************/
 1186 
 1187 vbox_page = gtk_vbox_new (FALSE, 5);
 1188 label = gtk_label_new (" View ");
 1189 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);
 1190 gtk_container_set_border_width (GTK_CONTAINER (vbox_page), 10);
 1191 g_object_set_data (G_OBJECT (dialog), "voronoi_vbox_page3", vbox_page);
 1192 gtk_widget_show (vbox_page);
 1193 
 1194 vbox_center = gtk_vbox_new (TRUE, 0);
 1195 gtk_box_pack_start (GTK_BOX (vbox_page), vbox_center, TRUE, TRUE, 0);
 1196 gtk_widget_show (vbox_center);
 1197 
 1198 vbox_top = gtk_vbox_new (FALSE, 15);
 1199 gtk_box_pack_start (GTK_BOX (vbox_center), vbox_top, FALSE, FALSE, 0);
 1200 gtk_widget_show (vbox_top);
 1201 
 1202 /***********************
 1203  * Seeds,Faces,Borders *
 1204  ***********************/
 1205 
 1206 hbox_center = gtk_hbox_new (TRUE, 0);
 1207 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
 1208 gtk_widget_show (hbox_center);
 1209 
 1210 hbox_left = gtk_hbox_new (FALSE, 20);
 1211 gtk_box_pack_start (GTK_BOX (hbox_center), hbox_left, FALSE, FALSE, 0);
 1212 gtk_widget_show (hbox_left);
 1213 
 1214 /***********
 1215  * borders *
 1216  ***********/
 1217 
 1218 hbox_left_left = gtk_hbox_new (FALSE, 5);
 1219 gtk_box_pack_start (GTK_BOX (hbox_left), hbox_left_left, FALSE, FALSE, 0);
 1220 gtk_widget_show (hbox_left_left);
 1221 
 1222 label = gtk_label_new ("Borders");
 1223 gtk_box_pack_start (GTK_BOX (hbox_left_left), label, FALSE, FALSE, 0);
 1224 gtk_widget_show (label);
 1225 
 1226 combo = gtk_combo_box_new ();
 1227 gtk_box_pack_start (GTK_BOX (hbox_left_left), combo, FALSE, FALSE, 0);
 1228 g_object_set_data (G_OBJECT (dialog), "voronoi_combo_borders", combo);
 1229 gtk_widget_show (combo);
 1230 
 1231 store = gtk_list_store_new (1, G_TYPE_STRING);
 1232 gtk_list_store_append (store, &iter);
 1233 gtk_list_store_set (store, &iter, 0, "All", -1);
 1234 gtk_list_store_append (store, &iter);
 1235 gtk_list_store_set (store, &iter, 0, "Faces", -1);
 1236 gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
 1237 g_object_unref (store);
 1238 
 1239 renderer = gtk_cell_renderer_text_new ();
 1240 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
 1241 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", 0, NULL);
 1242 
 1243 sensitive = gamgi_gtk_dialog_sensitive_create (2);
 1244 g_object_set_data (G_OBJECT (dialog), "voronoi_sensitive_borders", sensitive);
 1245 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
 1246 renderer, gamgi_gtk_dialog_sensitive_scan, sensitive, free);
 1247 
 1248 /*********
 1249  * faces *
 1250  *********/
 1251 
 1252 button = gtk_toggle_button_new_with_label ("Faces");
 1253 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
 1254 g_signal_connect (button, "clicked",
 1255 G_CALLBACK (static_voronoi_faces), window);
 1256 g_object_set_data (G_OBJECT (dialog), "voronoi_button_faces", button);
 1257 gtk_widget_show (button);
 1258 
 1259 /*********
 1260  * atoms *
 1261  *********/
 1262 
 1263 button = gtk_toggle_button_new_with_label ("Atoms");
 1264 gtk_box_pack_start (GTK_BOX (hbox_left), button, FALSE, FALSE, 0);
 1265 g_object_set_data (G_OBJECT (dialog), "voronoi_button_atoms", button);
 1266 gtk_widget_show (button);
 1267 
 1268 /*********************
 1269  * second row: color *
 1270  *********************/
 1271 
 1272 hbox_center = gtk_hbox_new (TRUE, 0);
 1273 gtk_box_pack_start (GTK_BOX (vbox_top), hbox_center, FALSE, FALSE, 0);
 1274 gtk_widget_show (hbox_center);
 1275 
 1276 table = gtk_table_new (1, 7, FALSE);
 1277 gtk_box_pack_start (GTK_BOX (hbox_center), table, FALSE, FALSE, 0);
 1278 gtk_widget_show (table);
 1279 
 1280 button = gtk_toggle_button_new_with_label (" Color ");
 1281 gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1282 g_signal_connect (button, "clicked",
 1283 G_CALLBACK (static_voronoi_color), window);
 1284 g_object_set_data (G_OBJECT (dialog), "voronoi_button_color", button);
 1285 gtk_widget_show (button);
 1286 
 1287 label = gtk_label_new ("R");
 1288 gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1289 g_object_set_data (G_OBJECT (dialog), "voronoi_label_red", label);
 1290 gtk_widget_show (label);
 1291 
 1292 label = gtk_label_new ("G");
 1293 gtk_table_attach (GTK_TABLE (table), label, 4, 5, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1294 g_object_set_data (G_OBJECT (dialog), "voronoi_label_green", label);
 1295 gtk_widget_show (label);
 1296 
 1297 label = gtk_label_new ("B");
 1298 gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1299 g_object_set_data (G_OBJECT (dialog), "voronoi_label_blue", label);
 1300 gtk_widget_show (label);
 1301 
 1302 entry = gtk_entry_new ();
 1303 gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1304 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1305 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1306 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_red", entry);
 1307 gtk_widget_show (entry);
 1308 
 1309 entry = gtk_entry_new ();
 1310 gtk_table_attach (GTK_TABLE (table), entry, 3, 4, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1311 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1312 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1313 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_green", entry);
 1314 gtk_widget_show (entry);
 1315 
 1316 entry = gtk_entry_new ();
 1317 gtk_table_attach (GTK_TABLE (table), entry, 5, 6, 0, 1, GTK_FILL, GTK_FILL, 5, 0);
 1318 gtk_entry_set_width_chars (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1319 gtk_entry_set_max_length (GTK_ENTRY (entry), GAMGI_GTK_CHAR_5);
 1320 g_object_set_data (G_OBJECT (dialog), "voronoi_entry_blue", entry);
 1321 gtk_widget_show (entry);
 1322 }