Re: Movable line via mouse
| From: | Brian Stumm | Date: | Wed, 07 Dec 2005 18:44:24 +0000 |
| Subject: | Re: Movable line via mouse | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6369@lists.php.net to get a copy of this message | ||
should mention too that my graph data is collected once a second and stored in
array so the moveable bars relate to the time element for zooming purposes and
the data is stored ie $array[time][x] and $array[time][y]
Also should have mentioned I use gdk::draw_line() to create the graph/plot
Brian Stumm wrote:
> I'm doing something similar in an app where I monitor time/temp profiling
> (graphing) in real time and ability to recall graphs. Users can select to
> "zoom" to a portion of the graph and it can display up to 6 channels of
> temperature data. I probably didn't get all code related in here but
> should get you going... email me if you need more info.
>
> I'm using a drawing area:
>
> $drawingarea = &new GtkDrawingArea();
> //$drawingarea->size(560, 330);
> $drawingarea->size(1800, 330);
> $drawingarea->set_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
>
> $newstyle = &new GtkStyle();
> $newstyle->bg[GTK_STATE_NORMAL] = gdk::color_parse('gray');
> $drawingarea->set_style($newstyle);
> $pbox->put($drawingarea, 20, 0);
> $drawingarea->realize();
> $style = $drawingarea->style;
> $mydrawable = $drawingarea->window;
>
> I use buttons for movable/draggable bars
>
> $moveable_bar1 = &new GtkButton('');
> $moveable_bar1->set_usize(4,300);
> $pbox->put($moveable_bar1, 249, 30);
>
> $drawingarea->connect('drag-data-received', 'dragDataReceived');
>
> and I have functions to deal with changing things when bars are moved:
>
> /***** DRAGDATAGET() *****/
> function dragDataGet($bar, $context, $selection_data, $info, $time, $name)
>
> {
> global $pwindow, $pbox, $button, $vbar1, $vbar2, $moveable_bar1,
> $moveable_bar2;
> $location = $pwindow->get_pointer();
> if($name == 1) {
> $vbar1 = $location[0] - 30;
> }
> if($name == 2) {
> $vbar2 = $location[0] - 30;
> }
> ClearGraph(0);
> RedrawIt();
> $pbox->move($moveable_bar1, ($vbar1 + 19), 30);
> $pbox->move($moveable_bar2, ($vbar2 + 19), 30);
> $pwindow->set_focus($button);
> }
>
> function DragAids() {
> global $drag_state, $moveable_bar1, $moveable_bar2;
> if($drag_state == 1) {
> $moveable_bar1->hide();
> $moveable_bar2->hide();
> $drag_state = 0;
> } else {
> $moveable_bar1->show();
> $moveable_bar2->show();
> $drag_state = 1;
> }
> return 1;
> }
>
> Tabber Watts wrote:
>
> > I in now way need/require anyone to completely solve this issue but
> > need ideas on how this might be accomplished.
> >
> > Situation:
> > I have data on six different sites, and each collect data period has a
> > +/- 30 minute skew for each site. I need to allow users to see these
> > data collection periods for a given day and select when they want to
> > look at data for all six sites.
> >
> > I can solve this problem without using graphics and just displaying
> > text times and having the user enter in the times manually but I would
> > like todo it with graphics.
> >
> > My idea:
> > Generate a timeline in a window, with the sites listed on the left
> > side of the window. Then there will be two vertical lines that a user
> > could click on and drag to the appropriate times they want to start
> > and stop looking at the data.
> >
> > What I know I can do:
> > Generation of the window with the full timeline and placement of data
> > lines for each site in a GtkLayout.
> >
> > What I don't know how to do:
> > Clicking and dragging of the line. The closest thing I could find to
> > this functionally is the colorselector.php demo using
> > GtkColorSelectionDialog.
> >
> > Any help or pointing in the right direction would be helpfull.
> >
> > Mahalo,
> > Tabber Watts
>
> --
> Brian Stumm
> ETS - Energy Technology Systems, Inc
> bstumm@energytechnologysystems.com
> http://energytechnologysystems.com
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Brian Stumm
ETS - Energy Technology Systems, Inc
bstumm@energytechnologysystems.com
http://energytechnologysystems.com