Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

void plot_area_zoom_rectangle_draw ( Plot plot,
gint  x,
gint  y 
)

On motion events, draw a rectangle between the zoom starting point and the current cursor location in order to delimit the zoom region.

Parameters:
plot The Plot.
x The x coordinate (pixels) of the pointer.
y The y coordinate (pixels) of the pointer.

Definition at line 591 of file plot_area.c.

References _Plot::pixmap, _Plot::plot_area, _Plot::zoom_x_start, and _Plot::zoom_y_start.

Referenced by plot_area_motion_notify_event().

{
  GdkPixmap* pixmap;
  gint x_start;
  gint y_start;
  gint width;
  gint height;

  x_start = MIN(plot->zoom_x_start, x);
  y_start = MIN(plot->zoom_y_start, y);

  width = abs(plot->zoom_x_start - x);
  height = abs(plot->zoom_y_start - y);

  /*
   * Create a pixmap of appropriate size.
   */
  pixmap = gdk_pixmap_new(plot->plot_area->window, width+1, height+1, -1);

  /*
   * Draw the current plot area contents onto the pixmap as a background.
   */
  gdk_draw_pixmap
    (pixmap, plot->plot_area->style->fg_gc[GTK_WIDGET_STATE(plot->plot_area)],
     plot->pixmap, x_start, y_start, 0, 0, width, height);

  /*
   * Draw the zoom rectangle.
   */
  gdk_draw_rectangle(pixmap, plot->plot_area->style->black_gc, FALSE,
                     0, 0, width, height);

  /*
   * Re-draw the plot area window to erase any previous zoom actions.
   */
  gdk_draw_pixmap
    (plot->plot_area->window,
     plot->plot_area->style->fg_gc[GTK_WIDGET_STATE(plot->plot_area)],
     plot->pixmap, 0, 0, 0, 0, -1, -1);

  /*
   * Copy the zoom pixmap onto the main plot area pixmap.
   */
  gdk_draw_pixmap
    (plot->plot_area->window,
     plot->plot_area->style->fg_gc[GTK_WIDGET_STATE(plot->plot_area)],
     pixmap, 0, 0, x_start, y_start, -1, -1);

  /* 
   * Get rid of the zoom pixmap since we don't need it any more.
   */
  if (pixmap != NULL)
    gdk_pixmap_unref(pixmap);
}


Generated by  Doxygen 1.6.0   Back to index