示例#1
0
Network* new_network(size_t input_layer_size, size_t output_layer_size, size_t hidden_layers_count, ...){
    Network* network = malloc(sizeof(Network));
    HIDDEN_LAYERS_COUNT = hidden_layers_count;
    network->input_layer = new_layer(input_layer_size, 0, 0, NULL, NULL);
    network->hidden_layers = malloc(hidden_layers_count*sizeof(Layer*));
    network->hidden_layers_count = hidden_layers_count;
    va_list args;
    va_start(args, hidden_layers_count);
    size_t count_connections_prev_layer = input_layer_size;
    for (int i = 0; i < hidden_layers_count; i++) {
        size_t hidden_layer_size = va_arg(args, size_t);
        network->hidden_layers[i] = new_layer(hidden_layer_size, count_connections_prev_layer, i+1, NULL, NULL);
        count_connections_prev_layer = hidden_layer_size;
    }
    va_end(args);
    network->output_layer = new_layer(output_layer_size, count_connections_prev_layer, (int)hidden_layers_count+1, NULL, NULL);
    
    if (hidden_layers_count > 0) {
        set_next_layer(network->input_layer, network->hidden_layers[0]);
        set_prev_layer(network->hidden_layers[0], network->input_layer);
        for (int i = 0; i < hidden_layers_count-1; i++) {
            set_next_layer(network->hidden_layers[i], network->hidden_layers[i+1]);
            set_prev_layer(network->hidden_layers[hidden_layers_count-i-1], network->hidden_layers[hidden_layers_count-i-2]);
        }
        set_next_layer(network->hidden_layers[hidden_layers_count-1], network->output_layer);
        set_prev_layer(network->output_layer, network->hidden_layers[hidden_layers_count-1]);
    } else {
        set_next_layer(network->input_layer, network->output_layer);
        set_prev_layer(network->output_layer, network->input_layer);
    }
    
    return network;
}
示例#2
0
static void
edit_layer_add_ok_callback (GtkWidget *w, gpointer client_data)
{
  EditLayerDialog *dialog = (EditLayerDialog *) client_data;
  Diagram *dia = ddisplay_active_diagram();
  Layer *layer;
  int pos = data_layer_get_index (dia->data, dia->data->active_layer) + 1;
  
  layer = new_layer(g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry))), dia->data);
  data_add_layer_at(dia->data, layer, pos);
  data_set_active_layer(dia->data, layer);

  diagram_add_update_all(dia);
  diagram_flush(dia);
  
  undo_layer(dia, layer, TYPE_ADD_LAYER, pos);
  undo_set_transactionpoint(dia->undo);

  /* ugly way of updating the layer widget */
  if (layer_dialog && layer_dialog->diagram == dia) {
    layer_dialog_set_diagram(dia);
  }

  gtk_widget_destroy (dialog->dialog);
  g_free (dialog);
}
示例#3
0
/*!
 * \brief Create a copy of the whole diagram data
 *
 * This is kind of a deep copy, everything not immutable gets duplicated.
 * Still this is supposed to be relatively fast, because the most expensive
 * objects have immutuable properties, namely the pixbufs in DiaImage are
 * only referenced.
 *
 * \memberof _DiagramData
 */
DiagramData *
diagram_data_clone (DiagramData *data)
{
  DiagramData *clone;
  guint i;
  
  clone = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
  
  clone->extents = data->extents;
  clone->bg_color = data->bg_color;
  clone->paper = data->paper; /* so ugly */
  clone->paper.name = g_strdup (data->paper.name);
  clone->is_compressed = data->is_compressed;
  
  layer_destroy(g_ptr_array_index(clone->layers, 0));
  g_ptr_array_remove(clone->layers, clone->active_layer);

  for (i=0; i < data->layers->len; ++i) {
    Layer *src_layer = g_ptr_array_index(data->layers, i);
    Layer *dest_layer = new_layer (layer_get_name (src_layer), clone);
  
    /* copy layer, init the active one */
    dest_layer->extents = src_layer->extents;
    dest_layer->objects = object_copy_list (src_layer->objects);
    dest_layer->visible = src_layer->visible;
    dest_layer->connectable = src_layer->connectable;
    g_ptr_array_add (clone->layers, dest_layer);
    if (src_layer == data->active_layer)
      clone->active_layer = dest_layer;
      
    /* the rest should be initialized by construction */
  }

  return clone;  
}
示例#4
0
/** Initialize a new diagram data object.
 * @param data A diagram data object to initialize.
 */
static void
diagram_data_init(DiagramData *data)
{
  Color* color = persistence_register_color ("new_diagram_bgcolour", &color_white);
  gboolean compress = persistence_register_boolean ("compress_save", TRUE);
  Layer *first_layer;

  data->extents.left = 0.0; 
  data->extents.right = 10.0; 
  data->extents.top = 0.0; 
  data->extents.bottom = 10.0; 
 
  data->bg_color = *color;

  get_paper_info (&data->paper, -1, NULL);

  first_layer = new_layer(g_strdup(_("Background")),data);
  
  data->layers = g_ptr_array_new ();
  g_ptr_array_add (data->layers, first_layer);
  data->active_layer = first_layer;

  data->selected_count_private = 0;
  data->selected = NULL;
  
  data->is_compressed = compress; /* Overridden by doc */

  data->text_edits = NULL;
  data->active_text_edit = NULL;
}
示例#5
0
ActivateLayer*
new_activate_layer(ActivateType activate_type)
{
  ActivateLayer* activate_layer = new_layer(Activation_T);
  activate_layer->activate_type = activate_type;
  return activate_layer;
}
示例#6
0
dia::Layer*
dia::DiagramData::add_layer (const char* name)
{
    int pos = -1; //TODO: make this a parameter
    g_return_val_if_fail (self != NULL, 0);
    ::Layer* layer = new_layer(g_strdup(name),self);
    if (pos != -1)
	data_add_layer_at(self, layer, pos);
    else
	data_add_layer(self, layer);

    dia::Layer* dl = new dia::Layer (layer);
    return dl;
}
示例#7
0
static PyObject *
PyDiaDiagramData_AddLayer(PyDiaDiagramData *self, PyObject *args)
{
    gchar *name;
    int pos = -1;
    Layer *layer;

    if (!PyArg_ParseTuple(args, "s|i:DiagramData.add_layer", &name, &pos))
	return NULL;
    layer = new_layer(g_strdup(name),self->data);
    if (pos != -1)
	data_add_layer_at(self->data, layer, pos);
    else
	data_add_layer(self->data, layer);
    return PyDiaLayer_New(layer);
}
示例#8
0
/* imports the given DRS file, returns TRUE if successful */
gboolean
import_drs (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data) 
{
  GList *item, *items;
  xmlDocPtr doc = xmlParseFile(filename);
  xmlNodePtr root = NULL, node;
  Layer *active_layer = NULL;

  for (node = doc->children; node; node = node->next)
    if (xmlStrcmp (node->name, (const xmlChar *)"drs") == 0)
      root = node;

  if (!root || !(root = find_child_named (root, "diagram"))) {
    dia_context_add_message (ctx, _("Broken file?"));
    return FALSE;
  }

  for (node = root->children; node != NULL; node = node->next) {
    if (xmlStrcmp (node->name, (const xmlChar *)"layer") == 0) {
      xmlChar *str;
      xmlChar *name = xmlGetProp (node, (const xmlChar *)"name");
      Layer *layer = new_layer (g_strdup (name ? (gchar *)name : _("Layer")), dia);

      if (name)
	xmlFree (name);

      str = xmlGetProp (node, (const xmlChar *)"active");
      if (xmlStrcmp (str, (const xmlChar *)"true")) {
	  active_layer = layer;
	xmlFree (str);
      }

      items = read_items (node->children, ctx);
      for (item = items; item != NULL; item = g_list_next (item)) {
        DiaObject *obj = (DiaObject *)item->data;
        layer_add_object(layer, obj);
      }
      g_list_free (items);
      data_add_layer (dia, layer);
    }
  }
  if (active_layer)
    data_set_active_layer (dia, active_layer);
  xmlFreeDoc(doc);
  return TRUE;
}
示例#9
0
static void
layer_dialog_new_callback(GtkWidget *widget, gpointer gdata)
{
  Layer *layer;
  Diagram *dia;
  GtkWidget *selected;
  GList *list = NULL;
  GtkWidget *layer_widget;
  int pos;
  static int next_layer_num = 1;

  dia = layer_dialog->diagram;

  if (dia != NULL) {
    gchar* new_layer_name = g_strdup_printf(_("New layer %d"),
					    next_layer_num++);
    layer = new_layer(new_layer_name, dia->data);

    assert(GTK_LIST(layer_dialog->layer_list)->selection != NULL);
    selected = GTK_LIST(layer_dialog->layer_list)->selection->data;
    pos = gtk_list_child_position(GTK_LIST(layer_dialog->layer_list), selected);

    data_add_layer_at(dia->data, layer, dia->data->layers->len - pos);
    
    diagram_add_update_all(dia);
    diagram_flush(dia);

    layer_widget = dia_layer_widget_new(dia, layer);
    gtk_widget_show(layer_widget);

    list = g_list_prepend(list, layer_widget);
    
    gtk_list_insert_items(GTK_LIST(layer_dialog->layer_list), list, pos);

    gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), pos);

    undo_layer(dia, layer, TYPE_ADD_LAYER, dia->data->layers->len - pos);
    undo_set_transactionpoint(dia->undo);
  }
}
示例#10
0
/* TODO: merge this with other layer code? */
static Layer *
layer_find_by_name(char *layername, DiagramData *dia) 
{
    Layer *matching_layer, *layer;
    guint i;
	
    matching_layer = NULL;
   
    for (i=0; i<dia->layers->len; i++) {
        layer = (Layer *)g_ptr_array_index(dia->layers, i);
        if(strcmp(layer->name, layername) == 0) {
            matching_layer = layer;
            break;
        }
    }

   if( matching_layer == NULL )
     {
	matching_layer = new_layer(g_strdup( layername ), dia);
	data_add_layer(dia, matching_layer);
     }

    return matching_layer;
}
示例#11
0
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *active_plot;
 GdkColor color;
 gint page_width, page_height;
 gfloat scale = 1.;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlot Real Time Demo");
 gtk_widget_set_usize(window1,550,600);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 gtk_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);
 gtk_widget_show(vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);
 gtk_widget_show(scrollw1);

 canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
 GTK_PLOT_CANVAS_UNSET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw1), canvas);

 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_canvas_set_background(GTK_PLOT_CANVAS(canvas), &color);

 gtk_widget_show(canvas);

 active_plot = new_layer(canvas);
 gdk_color_parse("light yellow", &color);
 gdk_color_alloc(gtk_widget_get_colormap(active_plot), &color);
 gtk_plot_set_background(GTK_PLOT(active_plot), &color);

 gdk_color_parse("white", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_legends_set_attributes(GTK_PLOT(active_plot),
                                 NULL, 0,
				 NULL,
                                 &color);
 gtk_plot_set_range(GTK_PLOT(active_plot), 0. ,20., 0., 1.);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), GTK_PLOT_AXIS_X, 2, 1);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), GTK_PLOT_AXIS_Y, .1, 1);

 gtk_plot_axis_set_labels_numbers(GTK_PLOT(active_plot), 2, 0, 0);
 gtk_plot_axis_set_labels_numbers(GTK_PLOT(active_plot), 3, 0, 0);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP, TRUE);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT, TRUE);
 gtk_plot_grids_set_visible(GTK_PLOT(active_plot), TRUE, TRUE, TRUE, TRUE);
 gtk_plot_canvas_add_plot(GTK_PLOT_CANVAS(canvas), GTK_PLOT(active_plot), .15, .15);
 gtk_plot_axis_hide_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP);
 gtk_plot_axis_hide_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT);
 gtk_plot_axis_set_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_LEFT, "Intensity");
 gtk_plot_axis_set_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_BOTTOM, "Point");
 gtk_plot_set_legends_border(GTK_PLOT(active_plot), 2, 3);
 gtk_plot_legends_move(GTK_PLOT(active_plot), .60, .10);
 gtk_widget_show(active_plot);

 gtk_widget_show(window1);

 gtk_plot_canvas_put_text(GTK_PLOT_CANVAS(canvas), .45, .05,  
                          "Times-BoldItalic", 20, 0, NULL, NULL, TRUE,
                          GTK_JUSTIFY_CENTER, 
                          "Iterator Demo");

 dataset = GTK_PLOT_DATA(gtk_plot_data_new_iterator((GtkPlotIterator)iter,
						     20,
						     GTK_PLOT_DATA_X|GTK_PLOT_DATA_Y|GTK_PLOT_DATA_LABELS));
 gtk_plot_data_show_labels(dataset, TRUE);

 gtk_plot_add_data(GTK_PLOT(active_plot), dataset);

 gtk_widget_show(GTK_WIDGET(dataset));

 gdk_color_parse("red", &color);
 gdk_color_alloc(gdk_colormap_get_system(), &color);

 gtk_plot_data_set_legend(dataset, "Iterator");
 gtk_plot_data_set_symbol(dataset,
                             GTK_PLOT_SYMBOL_DIAMOND,
                             GTK_PLOT_SYMBOL_OPAQUE,
                             10, 2, &color, &color);
 gtk_plot_data_set_line_attributes(dataset,
                                      GTK_PLOT_LINE_SOLID,
                                      1, &color);

 gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas));
 gtk_plot_canvas_refresh(GTK_PLOT_CANVAS(canvas));

/*
 gtk_plot_clip_data(GTK_PLOT(active_plot), TRUE);
*/

 gtk_main();

 return(0);
}
示例#12
0
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *canvas;
 GtkWidget *button;
 GtkWidget *surface;
 GtkPlotCanvasChild *child;
 gint page_width, page_height;
 gfloat scale = 1.;
 gint n;
 static gdouble *x, *y, *z;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlot3D Demo");
 gtk_widget_set_usize(window1,550,650);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 gtk_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);
 gtk_widget_show(vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);
 gtk_widget_show(scrollw1);

 canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
 GTK_PLOT_CANVAS_SET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw1), canvas);

/*
 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_canvas_set_background(GTK_PLOT_CANVAS(canvas), &color);
*/

 gtk_widget_show(canvas);

 plot3d = GTK_PLOT3D(new_layer(canvas, GTK_TYPE_PLOT3D));
 child = gtk_plot_canvas_plot_new(GTK_PLOT(plot3d));
 gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, .16, .05, .65, .45);
 gtk_widget_show(GTK_WIDGET(plot3d));

 x = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 y = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 z = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 n = 0;

/*
 for(nx = 0; nx < 40; nx++)
   for(ny = 0; ny < 40; ny++)
   {
     x[n]=0.025*(gdouble)nx;
     y[n]=0.025*(gdouble)ny;
     z[n]=cos(((x[n]-0.5)*(x[n]-0.5) + (y[n]-0.5)*(y[n]-0.5))*24) / 4. + .5;
     n++;
   }

 surface = gtk_plot_csurface_new();
 gtk_plot_surface_set_points(GTK_PLOT_SURFACE(surface), 
                             x, y, z, NULL, NULL, NULL, 40, 40); 
 gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), "cos ((r-r\\s0\\N)\\S2\\N)");
*/
/*
 for(nx = 0; nx < 10; nx++)
   for(ny = 0; ny < 10; ny++)
   {
     x[n]=(gdouble)0.1*(gdouble)nx;
     y[n]=(gdouble)0.1*(gdouble)ny;
     z[n]=(x[n]-0.5)*(x[n]-0.5) + (y[n]-0.5)*(y[n]-0.5);
     z[n]=x[n]*x[n] + y[n]*y[n];
     n++;
   }

 surface = gtk_plot_csurface_new();
 gtk_plot_surface_set_points(GTK_PLOT_SURFACE(surface), 
                             x, y, z, NULL, NULL, NULL, 10, 10); 

*/

 gtk_plot3d_set_minor_ticks(GTK_PLOT3D(plot3d), GTK_PLOT_AXIS_X, 3);
 gtk_plot3d_set_minor_ticks(GTK_PLOT3D(plot3d), GTK_PLOT_AXIS_Y, 3);

 gtk_plot3d_minor_grids_set_visible(GTK_PLOT3D(plot3d), FALSE, FALSE, FALSE);


 surface = gtk_plot_csurface_new_function((GtkPlotFunc3D) function);

 gtk_plot_surface_set_xstep(GTK_PLOT_SURFACE(surface), .05);
 gtk_plot_surface_set_ystep(GTK_PLOT_SURFACE(surface), .05);

 gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), "cos ((r-r\\s0\\N)\\S2\\N)");

 gtk_plot_add_data(GTK_PLOT(plot3d), GTK_PLOT_DATA(surface));
 gtk_widget_show(surface);

 gtk_plot_data_set_gradient(GTK_PLOT_DATA(surface), .2, .8, 6, 0);
/* 
 gtk_plot_surface_set_transparent(GTK_PLOT_SURFACE(surface), TRUE);
*/
 gtk_plot_surface_set_transparent(GTK_PLOT_SURFACE(surface), FALSE);
 gtk_plot_csurface_set_projection(GTK_PLOT_CSURFACE(surface), GTK_PLOT_PROJECT_EMPTY);
 GTK_PLOT_CSURFACE(surface)->levels_line.line_style = GTK_PLOT_LINE_NONE;
 GTK_PLOT_CSURFACE(surface)->sublevels_line.line_style = GTK_PLOT_LINE_NONE;
/*******************/
 active_plot = new_layer(canvas, GTK_TYPE_PLOT);
 child = gtk_plot_canvas_plot_new(GTK_PLOT(active_plot));
 gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, .26, .54, .65, .90);

 gtk_plot_axis_set_minor_ticks(gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_LEFT), 1);
 gtk_plot_axis_set_minor_ticks(gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_BOTTOM), 1);

 surface = gtk_plot_csurface_new_function((GtkPlotFunc3D) function);

 gtk_plot_surface_set_xstep(GTK_PLOT_SURFACE(surface), .050);
 gtk_plot_surface_set_ystep(GTK_PLOT_SURFACE(surface), .050);

 gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), "cos ((r-r\\s0\\N)\\S2\\N)");
 gtk_plot_add_data(GTK_PLOT(active_plot), GTK_PLOT_DATA(surface));
 gtk_widget_show(surface);

 gtk_plot_data_set_gradient(GTK_PLOT_DATA(surface), .2, .8, 3, 0);

 gtk_plot_surface_set_grid_visible(GTK_PLOT_SURFACE(surface), FALSE);
 gtk_plot_surface_set_transparent(GTK_PLOT_SURFACE(surface), TRUE);
 gtk_plot_csurface_set_projection(GTK_PLOT_CSURFACE(surface), GTK_PLOT_PROJECT_FULL);

/*
 gtk_plot_csurface_set_lines_visible(GTK_PLOT_CSURFACE(surface), FALSE);
*/


 button = gtk_button_new_with_label("Rotate X");
 gtk_fixed_put(GTK_FIXED(canvas), button, 80, 0);
 gtk_widget_show(button);

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_x), canvas);

 button = gtk_button_new_with_label("Rotate Y");
 gtk_fixed_put(GTK_FIXED(canvas), button, 160, 0);
 gtk_widget_show(button);

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_y), canvas);

 button = gtk_button_new_with_label("Rotate Z");
 gtk_fixed_put(GTK_FIXED(canvas), button, 240, 0);
 gtk_widget_show(button);

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_z), canvas);

 gtk_signal_connect(GTK_OBJECT(canvas), "select_item",
                    (GtkSignalFunc) select_item, NULL);
                                                                                
 gtk_widget_show(window1);

 gtk_plot_canvas_export_ps(GTK_PLOT_CANVAS(canvas), "democsurface.ps", 0, 0,
                           GTK_PLOT_LETTER);

 gtk_main();

 return(0);
}
示例#13
0
文件: testflux.c 项目: 2tim/gtkextra
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *canvas;
 GtkPlotCanvasChild *child;
 gint page_width, page_height;
 gfloat scale = 1.;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlotFlux Demo");
 gtk_widget_set_size_request(window1,550,650);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 g_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);
 gtk_widget_show(vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);
 gtk_widget_show(scrollw1);

 canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
 GTK_PLOT_CANVAS_SET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw1), canvas);

/*
 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_canvas_set_background(GTK_PLOT_CANVAS(canvas), &color);
*/

 gtk_widget_show(canvas);

 active_plot = new_layer(canvas);
 gtk_plot_set_range(GTK_PLOT(active_plot), -1. ,1., -1., 1.4);
 gtk_plot_legends_move(GTK_PLOT(active_plot), .500, .05);
 gtk_plot_set_legends_border(GTK_PLOT(active_plot), 0, 0);
 gtk_plot_axis_hide_title(gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP));
 gtk_plot_axis_show_ticks(gtk_plot_get_axis(GTK_PLOT(active_plot), 3), 15, 3);
 gtk_plot_axis_set_ticks(gtk_plot_get_axis(GTK_PLOT(active_plot), 0), 1., 1);
 gtk_plot_axis_set_ticks(gtk_plot_get_axis(GTK_PLOT(active_plot), 1), 1., 1);
 gtk_plot_axis_set_visible(gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP), TRUE);
 gtk_plot_axis_set_visible(gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT), TRUE);
 gtk_plot_x0_set_visible(GTK_PLOT(active_plot), TRUE);
 gtk_plot_y0_set_visible(GTK_PLOT(active_plot), TRUE);

 gtk_plot_grids_set_visible(GTK_PLOT(active_plot), TRUE, TRUE, TRUE, TRUE);

 child = gtk_plot_canvas_plot_new(GTK_PLOT(active_plot));
 gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, .15, .06, .65, .31);
 gtk_widget_show(active_plot);
 
 build_example1(active_plot);

 g_signal_connect(GTK_OBJECT(canvas), "select_item",
                    (void *) select_item, NULL);

 gtk_widget_show(window1);

 gtk_plot_canvas_export_ps(GTK_PLOT_CANVAS(canvas), "demoflux.ps", 0, 0, 
                           GTK_PLOT_LETTER);
 
 gtk_main();

 return(0);
}
示例#14
0
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *canvas;
 GtkWidget *button;
 GtkWidget *surface;
 gdouble *x,*y,*z,*a;
 gint cnt= 0;
 gint page_width, page_height;
 gfloat scale = 1.;
 char buffer[1000];
 FILE *f;
 gdouble xmin=1e99;
 gdouble xmax=-1e99;
 gdouble ymin=1e99;
 gdouble ymax=-1e99;
 gdouble zmin=1e99;
 gdouble zmax=-1e99;
 gdouble dx,dy,dz;
 gint n, nx, ny;
 GtkPlotCanvasChild *child;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlot3D Demo");
 gtk_widget_set_usize(window1,550,650);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 gtk_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);

 canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
 GTK_PLOT_CANVAS_SET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw1), canvas);

/*
 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_canvas_set_background(GTK_PLOT_CANVAS(canvas), &color);
*/


 active_plot = new_layer(canvas);

 child = gtk_plot_canvas_plot_new(GTK_PLOT(active_plot));
 gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, .10, .06, .85, .85);


 x = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 y = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 z = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 a = (gdouble *)g_malloc(1600 * sizeof(gdouble));
 n = 0;

 for(nx = 0; nx < 40; nx++)
   for(ny = 0; ny < 40; ny++)
   {
     x[n]=0.025*(gdouble)nx;
     y[n]=0.025*(gdouble)ny;
     z[n]=cos(((x[n]-0.5)*(x[n]-0.5) + (y[n]-0.5)*(y[n]-0.5))*24) / 4. + .5;
     a[n]=(x[n]-0.5)*(x[n]-0.5) + (y[n]-0.5)*(y[n]-0.5);
     n++;
   }

 surface = gtk_plot_surface_new();

 gtk_plot_surface_set_points(GTK_PLOT_SURFACE(surface), 
                             x, y, z, NULL, NULL, NULL, 40, 40); 
 gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), "cos ((r-r\\s0\\N)\\S2\\N)");

 gtk_plot_surface_use_amplitud(GTK_PLOT_SURFACE(surface), TRUE);
 gtk_plot_data_set_a(GTK_PLOT_DATA(surface), a);
 gtk_plot_data_gradient_set_visible(GTK_PLOT_DATA(surface), TRUE);

/*
 for(nx = 0; nx < 10; nx++)
   for(ny = 0; ny < 10; ny++)
   {
     x[n]=(gdouble)0.1*(gdouble)nx;
     y[n]=(gdouble)0.1*(gdouble)ny;
     z[n]=(x[n]-0.5)*(x[n]-0.5) + (y[n]-0.5)*(y[n]-0.5);
     n++;
   }

 surface = gtk_plot_surface_new();

 gtk_plot_surface_set_points(GTK_PLOT_SURFACE(surface), 
                             x, y, z, NULL, NULL, NULL, 10, 10); 
*/

 gtk_plot3d_set_minor_ticks(GTK_PLOT3D(active_plot), GTK_PLOT_AXIS_X, 1);
 gtk_plot3d_set_minor_ticks(GTK_PLOT3D(active_plot), GTK_PLOT_AXIS_Y, 1);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_XY, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_XZ, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_YX, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_YZ, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_ZX, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);
 gtk_plot3d_show_ticks(GTK_PLOT3D(active_plot), 
                            GTK_PLOT_SIDE_ZY, 
                            GTK_PLOT_TICKS_OUT, GTK_PLOT_TICKS_OUT);

 /* if a file was specified on the commandline, try to open and display it: */

 if (argc!=2 || !(f=fopen(argv[1],"r"))) {
/*
   x= y= z= NULL;
   surface = gtk_plot_surface_new_function((GtkPlotFunc3D) function);
   gtk_plot_surface_set_xstep(GTK_PLOT_SURFACE(surface), .025);
   gtk_plot_surface_set_ystep(GTK_PLOT_SURFACE(surface), .025);
   gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), "cos ((r-r\\s0\\N)\\S2\\N)");
*/
   gtk_plot_add_data(GTK_PLOT(active_plot), GTK_PLOT_DATA(surface));
 } else {
   x= g_new(gdouble,MAXNODES);
   y= g_new(gdouble,MAXNODES);
   z= g_new(gdouble,MAXNODES);
   while (fgets(buffer,1000,f) && cnt<MAXNODES) 
     if (sscanf(buffer,"%lf %lf %lf", &x[cnt], &y[cnt], &z[cnt])==3) {
       z[cnt]*=10; /* REMOVE THIS BEFORE FLIGHT */
       if (xmin>x[cnt]) xmin= x[cnt];
       if (xmax<x[cnt]) xmax= x[cnt];
       if (ymin>y[cnt]) ymin= y[cnt];
       if (ymax<y[cnt]) ymax= y[cnt];
       if (zmin>z[cnt]) zmin= z[cnt];
       if (zmax<z[cnt]) zmax= z[cnt];
       cnt++;   
     }
   fclose(f);
   dx= (xmax-xmin)*.02;
   dy= (ymax-ymin)*.02;
   dz= (zmax-zmin)*.02;
   /* start the triangulation */
   fprintf(stderr,"data ranges from (%g,%g) to (%g,%g)\n",
	   xmin,ymin,xmax,ymax);

   /*
   gtk_plot3d_set_xrange(GTK_PLOT3D(active_plot), xmin-dx, xmax+dx);
   gtk_plot3d_set_yrange(GTK_PLOT3D(active_plot), ymin-dy, ymax+dy);
   gtk_plot3d_set_zrange(GTK_PLOT3D(active_plot), zmin-dz, zmax+dz);
   gtk_plot3d_set_ticks(GTK_PLOT3D(active_plot), GTK_PLOT_AXIS_X, (xmax-xmin)/10., 1);
   gtk_plot3d_set_ticks(GTK_PLOT3D(active_plot), GTK_PLOT_AXIS_Y, (ymax-ymin)/10., 1);
   gtk_plot3d_set_ticks(GTK_PLOT3D(active_plot), GTK_PLOT_AXIS_Z, (zmax-zmin)/10., 1);
   */

   surface = gtk_plot_csurface_new();
   gtk_plot_add_data(GTK_PLOT(active_plot), GTK_PLOT_DATA(surface));
   gtk_plot_surface_set_points(GTK_PLOT_SURFACE(surface), 
			       x, y, z, NULL, NULL, NULL, cnt, 1); 
   gtk_plot_data_set_legend(GTK_PLOT_DATA(surface), argv[1]);
   gtk_plot_data_gradient_autoscale_z(GTK_PLOT_DATA(surface));
 }
/*
 gtk_plot_surface_use_height_gradient(GTK_PLOT_SURFACE(surface), TRUE);
 gtk_plot_data_set_gradient(GTK_PLOT_DATA(surface), .2, .8, 6, 0);
*/

/*
 gtk_plot_data_gradient_set_scale(GTK_PLOT_DATA(surface),GTK_PLOT_SCALE_LOG10);
*/

 gtk_plot3d_autoscale(GTK_PLOT3D(active_plot));
// gtk_plot3d_set_xrange(GTK_PLOT3D(active_plot), -0.5,1);
// gtk_plot3d_set_yrange(GTK_PLOT3D(active_plot), -0.2,1);
// gtk_plot3d_set_zrange(GTK_PLOT3D(active_plot), 0.,1);
 gtk_widget_show(surface);


 button = gtk_button_new_with_label("Rotate X");
 gtk_fixed_put(GTK_FIXED(canvas), button, 80, 0);

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_x), canvas);

 button = gtk_button_new_with_label("Rotate Y");
 gtk_fixed_put(GTK_FIXED(canvas), button, 160, 0);

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_y), canvas);

 button = gtk_button_new_with_label("Rotate Z");
 gtk_fixed_put(GTK_FIXED(canvas), button, 240, 0);

/*
 gtk_plot3d_set_xfactor(GTK_PLOT3D(active_plot), 0.5);
*/
/*
 gtk_plot3d_set_xrange(GTK_PLOT3D(active_plot), 0., 2.0);
*/

 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                    GTK_SIGNAL_FUNC(rotate_z), canvas);

 gtk_widget_show_all(window1);

/*
 gtk_plot_canvas_export_ps(GTK_PLOT_CANVAS(canvas), "demo3d.ps", 0, 0,
                           GTK_PLOT_LETTER);
*/

 gtk_plot_canvas_export_ps_with_size(GTK_PLOT_CANVAS(canvas), "demo3d.ps", 
				     0, 0, GTK_PLOT_PSPOINTS,
                            	     GTK_PLOT_LETTER_W, GTK_PLOT_LETTER_H);


 gtk_main();

 return(0);
}
示例#15
0
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *active_plot;
 GtkWidget *canvas;
 gint page_width, page_height;
 gfloat scale = 1.;
 GtkPlotDTnode p;
 GtkPlotDT *dtdata;
 char buffer[1000];
 FILE *f;
 gdouble xmin=1e99;
 gdouble xmax=-1e99;
 gdouble ymin=1e99;
 gdouble ymax=-1e99;
 gdouble dx,dy;
 gint num_triangles = 0;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlotFlux Demo");
 gtk_widget_set_usize(window1,550,650);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 gtk_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);
 gtk_widget_show(vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);
 gtk_widget_show(scrollw1);

 canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
 GTK_PLOT_CANVAS_SET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw1), canvas);

/*
 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(canvas), &color);
 gtk_plot_canvas_set_background(GTK_PLOT_CANVAS(canvas), &color);
*/

 gtk_widget_show(canvas);

 if (argc!=2) {
   fprintf(stderr,"\nUsage:\n\ttestgtkplotdt X-Y-FILE\n");
   exit(-1);
 }
 if (!(f=fopen(argv[1],"r"))) {
   fprintf(stderr,"\ncould not open file '%s' for reading\n",argv[1]);
   exit(-2);
 }
 
 /* init with nodelist size 0 */
 dtdata= GTK_PLOT_DT(gtk_plot_dt_new(0));
 if (!dtdata) exit(-1);
 /* register the progressmeter */
 dtdata->pbar= simpleprogressbar;
 
 /* read X/Y pairs from f: */
 while (fgets(buffer,1000,f)) {
   if (sscanf(buffer,"%lf %lf", &p.x, &p.y)==2) {
     /* add this node */
     gtk_plot_dt_add_node(dtdata,p);
     if (xmin>p.x) xmin= p.x;
     if (xmax<p.x) xmax= p.x;
     if (ymin>p.y) ymin= p.y;
     if (ymax<p.y) ymax= p.y;
   }
 }
 dx= (xmax-xmin)*.02;
 dy= (ymax-ymin)*.02;
 fclose(f);
 /* start the triangulation */
 fprintf(stderr,"data ranges from (%g,%g) to (%g,%g)\n",
	 xmin,ymin,xmax,ymax);
 num_triangles= gtk_plot_dt_triangulate(dtdata);

 active_plot = new_layer(canvas);
 gtk_plot_set_range(GTK_PLOT(active_plot), xmin-dx, xmax+dx, ymin-dy, ymax+dy);
 gtk_plot_legends_move(GTK_PLOT(active_plot), .500, .05);
 gtk_plot_set_legends_border(GTK_PLOT(active_plot), 0, 0);
 gtk_plot_axis_hide_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP);
 gtk_plot_axis_show_ticks(GTK_PLOT(active_plot), 3, 15, 3);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), 0, (xmax-xmin)/10., 1);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), 1, (ymax-ymin)/10., 1);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP, TRUE);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT, TRUE);
 gtk_plot_x0_set_visible(GTK_PLOT(active_plot), TRUE);
 gtk_plot_y0_set_visible(GTK_PLOT(active_plot), TRUE);
 gtk_plot_canvas_add_plot(GTK_PLOT_CANVAS(canvas), GTK_PLOT(active_plot), .15, .06);
 gtk_widget_show(active_plot);

 build_example1(active_plot,dtdata, num_triangles);

 gtk_widget_show(window1);

 gtk_plot_canvas_export_ps(GTK_PLOT_CANVAS(canvas), "demodtflux.ps", 0, 0, 
                           GTK_PLOT_LETTER);
 
 gtk_main();

 return(0);
}
示例#16
0
文件: realdemo.c 项目: sanbee/capps
int main(int argc, char *argv[]){

 GtkWidget *window1;
 GtkWidget *vbox1;
 GtkWidget *scrollw1;
 GtkWidget *active_plot;
 GdkColor color;
 gint page_width, page_height;
 gfloat scale = 1.;
 
 page_width = GTK_PLOT_LETTER_W * scale;
 page_height = GTK_PLOT_LETTER_H * scale;
 
 gtk_init(&argc,&argv);

 window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window1), "GtkPlot Real Time Demo");
 gtk_widget_set_usize(window1,550,600);
 gtk_container_border_width(GTK_CONTAINER(window1),0);

 gtk_signal_connect (GTK_OBJECT (window1), "destroy",
		     GTK_SIGNAL_FUNC (quit), NULL);

 vbox1=gtk_vbox_new(FALSE,0);
 gtk_container_add(GTK_CONTAINER(window1),vbox1);
 gtk_widget_show(vbox1);

 scrollw1=gtk_scrolled_window_new(NULL, NULL);
 gtk_container_border_width(GTK_CONTAINER(scrollw1),0);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw1),
				GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
 gtk_box_pack_start(GTK_BOX(vbox1),scrollw1, TRUE, TRUE,0);
 gtk_widget_show(scrollw1);

 canvas = gtk_plot_canvas_new(page_width, page_height);
 GTK_PLOT_CANVAS_UNSET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS);
 layout = canvas;
 gtk_container_add(GTK_CONTAINER(scrollw1),layout);
 gtk_layout_set_size(GTK_LAYOUT(layout), page_width, page_height);
 GTK_LAYOUT(layout)->hadjustment->step_increment = 5;
 GTK_LAYOUT(layout)->vadjustment->step_increment = 5;

 gdk_color_parse("light blue", &color);
 gdk_color_alloc(gtk_widget_get_colormap(layout), &color);
 gtk_plot_layout_set_background(GTK_PLOT_LAYOUT(layout), color);

 gtk_widget_show(layout);

 active_plot = new_layer(layout);
 gdk_color_parse("light yellow", &color);
 gdk_color_alloc(gtk_widget_get_colormap(active_plot), &color);
 gtk_plot_set_background(GTK_PLOT(active_plot), color);

 gdk_color_parse("white", &color);
 gdk_color_alloc(gtk_widget_get_colormap(layout), &color);
 gtk_plot_legends_set_attributes(GTK_PLOT(active_plot),
                                 NULL, 0,
				 NULL,
                                 &color);
 gtk_plot_set_range(GTK_PLOT(active_plot), 0. ,20., 0., 1.);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), 0, 2, 1);
 gtk_plot_axis_set_ticks(GTK_PLOT(active_plot), 1, .1, .05);
 gtk_plot_axis_labels_set_numbers(GTK_PLOT(active_plot), 2, 0, 0);
 gtk_plot_axis_labels_set_numbers(GTK_PLOT(active_plot), 3, 0, 0);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP, TRUE);
 gtk_plot_axis_set_visible(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT, TRUE);
 gtk_plot_set_grids_visible(GTK_PLOT(active_plot), TRUE, TRUE, TRUE, TRUE);
 gtk_plot_canvas_add_plot(GTK_PLOT_CANVAS(canvas), GTK_PLOT(active_plot), .15, .15);
 gtk_plot_axis_hide_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_TOP);
 gtk_plot_axis_hide_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT);
 gtk_plot_axis_set_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_LEFT, "Intensity");
 gtk_plot_axis_set_title(GTK_PLOT(active_plot), GTK_PLOT_AXIS_BOTTOM, "Time (s)");
 gtk_plot_show_legends_border(GTK_PLOT(active_plot), TRUE, 3);
 gtk_plot_legends_move(GTK_PLOT(active_plot), .60, .10);
 gtk_widget_show(active_plot);

 gtk_widget_show(window1);

 gtk_plot_layout_put_text(GTK_PLOT_LAYOUT(canvas), .45, .05, 0, 
                          "Times-BoldItalic", 20, NULL, NULL,
                          GTK_JUSTIFY_CENTER,
                          "Real Time Demo");

 dataset = gtk_plot_dataset_new(GTK_PLOT(active_plot));
 gtk_plot_add_dataset(GTK_PLOT(active_plot), dataset);

 gdk_color_parse("red", &color);
 gdk_color_alloc(gdk_colormap_get_system(), &color);

 gtk_plot_dataset_set_legend(dataset, "Random pulse");
 gtk_plot_dataset_set_symbol(dataset,
                             GTK_PLOT_SYMBOL_DIAMOND,
                             GTK_PLOT_SYMBOL_OPAQUE,
                             10, 2, color);
 gtk_plot_dataset_set_line_attributes(dataset,
                                      GTK_PLOT_LINE_SOLID,
                                      1, color);

 timer = gtk_timeout_add(1000, update, active_plot);

 gtk_main();

 return(0);
}