Beispiel #1
0
static void
gtk_plot_surface_draw_private   (GtkPlotData *data)  
{
  GtkPlot *plot;
  GtkPlotSurface *surface;

  g_return_if_fail(GTK_IS_PLOT_SURFACE(data));

  surface = GTK_PLOT_SURFACE(data);
  data = GTK_PLOT_DATA(surface);

  g_return_if_fail(GTK_PLOT_DATA(data)->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(GTK_PLOT_DATA(data)->plot));

  if(data->redraw_pending) gtk_plot_surface_update_range(data);

  plot = GTK_PLOT(data->plot);

  gtk_plot_surface_real_draw(surface);
}
Beispiel #2
0
static void
gtk_plot_surface_real_draw   (GtkPlotSurface *surface)  
{
  GtkWidget *widget;
  GtkPlot *plot = NULL;
  GtkPlotData *dataset;
  GList *list;

  g_return_if_fail(GTK_IS_PLOT_SURFACE(surface));

  dataset = GTK_PLOT_DATA(surface);

  g_return_if_fail(GTK_PLOT_DATA(dataset)->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(GTK_PLOT_DATA(dataset)->plot));

  plot = dataset->plot;
  widget = GTK_WIDGET(plot);

  gtk_plot_pc_gsave(plot->pc);

  if(!GTK_WIDGET_DRAWABLE(widget)) return;
  if(!GTK_WIDGET_VISIBLE(widget)) return;

  gtk_plot_set_line_attributes(plot, surface->mesh_line);

  list = surface->dt->triangles;
  while(list){
    GtkPlotDTtriangle *t;
 
    t = (GtkPlotDTtriangle *)list->data;
    GTK_PLOT_SURFACE_CLASS(GTK_OBJECT(surface)->klass)->draw_triangle(surface, t, -1.); 
    list = list->next;
  }

  gtk_plot_pc_grestore(plot->pc);
}
static void
gtk_plot_bar_draw_legend(GtkPlotData *data, gint x, gint y)
{
  GtkPlotBar *bar;
  GtkPlot *plot = NULL;
  GtkPlotText legend;
  GdkRectangle area;
  gint lascent, ldescent, lheight, lwidth;
  gdouble m;

  bar = GTK_PLOT_BAR(data);

  g_return_if_fail(data->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(data->plot));
  g_return_if_fail(GTK_WIDGET_VISIBLE(data));
  g_return_if_fail(GTK_WIDGET_VISIBLE(data->plot));

  plot = data->plot;
  area.x = GTK_WIDGET(plot)->allocation.x;
  area.y = GTK_WIDGET(plot)->allocation.y;
  area.width = GTK_WIDGET(plot)->allocation.width;
  area.height = GTK_WIDGET(plot)->allocation.height;

  m = plot->magnification;
  legend = plot->legends_attr;

  if(data->legend)
    legend.text = data->legend;
  else
    legend.text = "";

  gtk_plot_text_get_size(legend.text, legend.angle, legend.font,
                         roundint(legend.height * m),
                         &lwidth, &lheight,
                         &lascent, &ldescent);


  legend.x = (gdouble)(area.x + x + roundint((plot->legends_line_width + 4) * m))
             / (gdouble)area.width;
  legend.y = (gdouble)(area.y + y + lascent) / (gdouble)area.height;

  gtk_plot_draw_text(plot, legend);


  if(data->symbol.symbol_style == GTK_PLOT_SYMBOL_OPAQUE){
    gtk_plot_pc_set_color(plot->pc, &plot->background);
    gtk_plot_pc_draw_rectangle(plot->pc, TRUE,
                               x, y,
                               roundint(plot->legends_line_width * m),
                               lascent + ldescent);
  }

  gtk_plot_pc_set_lineattr (plot->pc, data->symbol.border.line_width, 0, 0, 0);
  gtk_plot_pc_set_dash(plot->pc, 0, 0, 0);

  if(data->symbol.symbol_style == GTK_PLOT_SYMBOL_FILLED){
    gtk_plot_pc_set_color(plot->pc, &data->symbol.color);
    gtk_plot_pc_draw_rectangle(plot->pc, TRUE,
                               x, y,
                               roundint(plot->legends_line_width * m),
                               lascent + ldescent);
  }

  gtk_plot_pc_set_color(plot->pc, &data->symbol.border.color);
  gtk_plot_pc_draw_rectangle(plot->pc, FALSE,
                             x, y,
                             roundint(plot->legends_line_width * m),
                             lascent + ldescent);

}
static void
gtk_plot_candle_draw_legend(GtkPlotData *data, gint x, gint y)
{
  GtkPlotCandle *box;
  GtkPlot *plot = NULL;
  GtkPlotText legend;
  GdkRectangle area;
  gint lascent, ldescent, lheight, lwidth;
  gdouble m;

  box = GTK_PLOT_CANDLE(data);

  g_return_if_fail(data->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(data->plot));
  if(!GTK_WIDGET_REALIZED(data->plot)) return;

  plot = data->plot;
  area.x = GTK_WIDGET(plot)->allocation.x;
  area.y = GTK_WIDGET(plot)->allocation.y;
  area.width = GTK_WIDGET(plot)->allocation.width;
  area.height = GTK_WIDGET(plot)->allocation.height;

  m = plot->magnification;
  legend = plot->legends_attr;

  if(data->legend)
    legend.text = data->legend;
  else
    legend.text = "";

  gtk_plot_text_get_size(legend.text, legend.angle, legend.font,
                         roundint(legend.height * m), 
                         &lwidth, &lheight,
                         &lascent, &ldescent);


  legend.x = (gdouble)(area.x + x + roundint((plot->legends_line_width + 4) * m))
             / (gdouble)area.width;
  legend.y = (gdouble)(area.y + y + lascent) / (gdouble)area.height;

  gtk_plot_draw_text(plot, legend);

  gtk_plot_pc_set_lineattr (plot->pc, data->symbol.border.line_width, 0, 0, 0);
  gtk_plot_pc_set_dash (plot->pc, 0, 0, 0);

  gtk_plot_pc_set_color(plot->pc, &data->symbol.color);

  if(data->symbol.symbol_style == GTK_PLOT_SYMBOL_EMPTY){
    gtk_plot_pc_draw_line(plot->pc, 
                          x,  
                          y + (lascent + ldescent) / 2,
                          x + roundint(plot->legends_line_width * m), 
                          y + (lascent + ldescent) / 2); 
  } else {
    gtk_plot_pc_draw_rectangle(plot->pc, TRUE, 
                               x, y,
                               roundint(plot->legends_line_width * m), 
                               lascent + ldescent);
    gtk_plot_pc_set_color(plot->pc, &data->symbol.border.color);
    gtk_plot_pc_draw_rectangle(plot->pc, FALSE, 
                               x, y,
                               roundint(plot->legends_line_width * m), 
                               lascent + ldescent);

  }

}
Beispiel #5
0
static void
gtk_plot_surface_draw_legend(GtkPlotData *data, gint x, gint y)
{
  GtkPlotSurface *surface;
  GtkPlot *plot = NULL;
  GtkPlotText legend;
  GdkRectangle area;
  gint lascent, ldescent, lheight, lwidth;
  gdouble m;

  surface = GTK_PLOT_SURFACE(data);

  g_return_if_fail(data->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(data->plot));

  plot = data->plot;
  area.x = GTK_WIDGET(plot)->allocation.x;
  area.y = GTK_WIDGET(plot)->allocation.y;
  area.width = GTK_WIDGET(plot)->allocation.width;
  area.height = GTK_WIDGET(plot)->allocation.height;

  m = plot->magnification;
  legend = plot->legends_attr;

  if(data->legend)
    legend.text = data->legend;
  else
    legend.text = "";

  gtk_plot_text_get_size(legend.text, legend.angle, legend.font,
                         roundint(legend.height * m), 
                         &lwidth, &lheight,
                         &lascent, &ldescent);


  if(!surface->height_gradient){
    gtk_plot_pc_set_color(plot->pc, &surface->color);

    gtk_plot_pc_draw_rectangle(plot->pc, TRUE, 
                               x, y,
                               roundint(plot->legends_line_width * m), 
                               lascent + ldescent);
  }else{
    gdouble level, step;
    gint lx = x, lstep;
    step = (data->gradient.end - data->gradient.begin) / 10;
    lstep = roundint(plot->legends_line_width * m / 10.);
    for(level = data->gradient.begin; level < data->gradient.end; level += step){
      GdkColor color;
      gtk_plot_data_get_gradient_level(data, level, &color);
      gtk_plot_pc_set_color(plot->pc, &color);

      gtk_plot_pc_draw_rectangle(plot->pc, TRUE, 
                                 lx, y,
                                 lstep, lascent + ldescent);
      lx += lstep;
    }
  }


  legend.x = (gdouble)(area.x + x + roundint((plot->legends_line_width + 4) * m))
             / (gdouble)area.width;
  legend.y = (gdouble)(area.y + y + lascent) / (gdouble)area.height;

  gtk_plot_draw_text(plot, legend);

  y += 2*lheight;
  gtk_plot_data_draw_gradient(data, x, y);
}
Beispiel #6
0
static void
gtk_plot_flux_draw_legend(GtkPlotData *data, gint x, gint y)
{
  GtkPlotFlux *flux;
  GtkPlot *plot = NULL;
  GtkPlotText legend;
  GdkRectangle area;
  gint lascent, ldescent, lheight, lwidth;
  gdouble m;
  gboolean centered;
  GtkAllocation allocation;

  flux = GTK_PLOT_FLUX(data);
  centered = flux->centered;

  g_return_if_fail(data->plot != NULL);
  g_return_if_fail(GTK_IS_PLOT(data->plot));
  g_return_if_fail(gtk_widget_get_visible(GTK_WIDGET(data->plot)));

  plot = data->plot;
  gtk_widget_get_allocation( GTK_WIDGET(plot), &allocation);
  area.x = allocation.x;
  area.y = allocation.y;
  area.width = allocation.width;
  area.height = allocation.height;

  m = plot->magnification;
  legend = plot->legends_attr;

  if(data->legend)
    legend.text = data->legend;
  else
    legend.text = "";

  gtk_plot_text_get_size(legend.text, legend.angle, legend.font,
                         roundint(legend.height * m), 
                         &lwidth, &lheight,
                         &lascent, &ldescent);

  if(data->show_legend){
    legend.x = (gdouble)(area.x + x) / (gdouble)area.width;
    legend.y = (gdouble)(area.y + y + lascent) / (gdouble)area.height;

    gtk_plot_draw_text(plot, legend);
  }
  if(flux->show_scale){
    gchar new_label[100], text_max[100];
 
    flux->centered = FALSE;
     
    gtk_plot_flux_draw_arrow(flux, 
                             area.x + x, 
                             area.y + y + lheight * 3 / 2,
                             area.x + x + roundint(flux->size_max*m),
                             area.y + y + lheight * 3 / 2);
    y += MAX(lheight, roundint(m*flux->arrow_width));  

    gtk_plot_axis_parse_label(data->gradient, flux->scale_max, flux->labels_precision, flux->labels_style, text_max);
    if(flux->labels_prefix){
      gchar aux_text[100];
      g_snprintf(aux_text, 100, "%s%s", flux->labels_prefix, text_max);
      g_snprintf(text_max, 100, "%s", aux_text);
    }
    if(flux->labels_suffix){
      gchar aux_text[100];
      g_snprintf(aux_text, 100, "%s%s", text_max, flux->labels_suffix);
      g_snprintf(text_max, 100, "%s", aux_text);
    }
    g_snprintf(new_label, 100, "%s", text_max);

    legend.x = (gdouble)(area.x + x + m*(flux->size_max + 4)) / (gdouble)area.width;
    legend.y = (gdouble)(area.y + y + lascent) / (gdouble)area.height;
    legend.text = new_label;
    gtk_plot_draw_text(plot, legend);

    flux->centered = centered;
    y += lheight;  

  } else
    y += lheight;  
}