Re: Gtk-plot Zoom

"Adrian E. Feiguin" <[email protected]> Fri, 03 Oct 2008 16:21:50 -0700
Newsgroups gmane.comp.scigraphica.gtkextra
Message-ID <[email protected]>
Hi Arne,

Nice!
What you have to do is the following:

connect the select_region signal as:

  gtk_signal_connect(GTK_OBJECT(canvas), "select_region",
                     GTK_SIGNAL_FUNC(tool_select_region), NULL);


static gint
tool_select_region(GtkPlotCanvas *canvas,
                   gdouble x1, gdouble y1,
                   gdouble x2, gdouble y2,
                   gpointer data)
{
...
      GtkPlotCanvasChild *child = gtk_plot_canvas_get_active_item(canvas);
      GtkPlot *real_plot = GTK_PLOT_CANVAS_PLOT(child);

      gtk_plot_canvas_unselect(canvas);

      gtk_plot_canvas_get_pixel(canvas, xmin, ymin, &px1, &py1);
      gtk_plot_canvas_get_pixel(canvas, xmax, ymax, &px2, &py2);
      gtk_plot_get_point(real_plot, px1, py1, &xmin, &ymax);
      gtk_plot_get_point(real_plot, px2, py2, &xmax, &ymin);

      gtk_plot_set_range(real_plot, xmin, xmax, ymin, ymax);
      gtk_plot_canvas_paint(canvas);
      gtk_widget_queue_draw(GTK_WIDGET(canvas));

...
}

Tell me how it goes. Thank you for using gtkplot!
Best,
<ADRIAN>


arne wrote:
> Hello,
>
> I am writing a small application which uses gtkplot to display some recorded data,
> it is a kind of software oscilloscope,
>
> you can see a screenshot here:
>
> http://www.pagelnet.de/scope.png
>
>
> At the moment I want to add a zoom-function with mouse support,
> that means, that I want to mark a rectangle(like gimp etc.) with the mouse and then zoom into the plot.
>
> The biggest problem for me is drawing a rectangle with the mouse in the gtkplot and getting the 
> positions of the rectangle.
>
> What is the best way to do this?
>
> Must I get the pointer-position and then always use gtk_plot_draw_line() to mark a rectangle?
>
>
> When I have the start and end-position of the marked rectangle related to my plot the zoom function 
> itself should be no problem.
>
> Best regards
>    Arne
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Scigraphica-gtkextra mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scigraphica-gtkextra
>
>   


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/