[Mono-list] MedSphere Graph
Panoramix
aria.francesco at gmail.com
Fri Jun 13 05:56:07 EDT 2008
I have replaced the Timer object with a Gtk.Timeout and now everything seems
to work.
Why? :confused:
Panoramix wrote:
>
> I'm trying to create a dynamic trend but, having certainly made some
> mistakes, the application crashes after a few cycles.
> Carryover below the code, where I made the mistake?
>
> Thanks to all .
>
> using System;
> using Gtk;
> using Medsphere.Widgets;
> using System.Timers;
>
> public partial class MainWindow: Gtk.Window
> {
> // creo l'oggetto grafico
> public Graph NuovoGraph = new Medsphere.Widgets.Graph2D();
> // creo una struttura tree per immagazzinare i dati
> public TreeStore store = new TreeStore (typeof (double), typeof
> (double));
> public TreeStore storeA = new TreeStore (typeof (double), typeof
> (double));
> public double x=0.0;
> public double y=0.0;
> // dichiaro il timer
> private static System.Timers.Timer ourTimer;
>
> public MainWindow (): base (Gtk.WindowType.Toplevel)
> {
> Build ();
> store.AppendValues(0.0,0.0);
> storeA.AppendValues(0.1,0.0);
>
>
> // aggiungo gli assi al grafico
> NuovoGraph.AppendAxis (new LinearAxis (0, AxisLocation.Bottom));
> NuovoGraph.AppendAxis(new LinearAxis (1, AxisLocation.Left));
> // creo il line plot per disegnare il grafico
> LinePlot plot = new
> LinePlot(store,PlotColor.DarkBrown,PointShape.Diamond);
> LinePlot plotA = new
> LinePlot(storeA,PlotColor.Green,PointShape.Diamond);
>
> plot.Name = "plot";
> plot.SetValueDataColumn (0, 0);
> plot.SetValueDataColumn (1, 1);
>
> plotA.Name = "plot";
> plotA.SetValueDataColumn (0, 0);
> plotA.SetValueDataColumn (1, 1);
>
> // creo un plot range ovvero le bande colorate di range
> ReferenceRangePlot Rng = new ReferenceRangePlot (118.0,150.0,
> 1,PlotColor.Brown);
> // aggiungo al grafico i tracciati creati
> NuovoGraph.AddPlot(plot,NuovoGraph.Axes);
> NuovoGraph.AddPlot(plotA,NuovoGraph.Axes);
> NuovoGraph.AddPlot(Rng,NuovoGraph.Axes);
> this.hbox2.Add(NuovoGraph);
> NuovoGraph.Visible=true;
> NuovoGraph.CanFocus = false;
> //creo il timer
> ourTimer = new System.Timers.Timer();
> // attacco l'evento al timer
> ourTimer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
> // imposto l'intervallo a 5 secondi
> ourTimer.Interval = 1000;
> }
>
> protected void OnDeleteEvent (object sender, DeleteEventArgs a)
> {
> Application.Quit ();
> a.RetVal = true;
> }
>
> protected virtual void StartT (object sender, System.EventArgs e)
> {
> if (ourTimer.Enabled == false)
> {
> ourTimer.Enabled = true ;
> button1.Label ="Started";
> }
> else
> {
> ourTimer.Enabled = false ;
> button1.Label = "Stopped";
> }
>
> }
> private void OnTimerElapsed(object sender, ElapsedEventArgs e)
> {
> Console.WriteLine("-> on plot in");
> y=y + 0.2;
> store.AppendValues(y,(Math.Sin (y)+1)*75);
> LinePlot plot = new LinePlot(store,PlotColor.Green,PointShape.Diamond);
> NuovoGraph.RemovePlot(plot);
> NuovoGraph.AddPlot(plot,NuovoGraph.Axes);
> Console.WriteLine("-> on plot out");
> Console.WriteLine("-> on plotA in");
> x=x + 0.2;
> storeA.AppendValues(x+0.5,(Math.Sin (x)+1)*75);
> LinePlot plotA = new
> LinePlot(store,PlotColor.DarkBrown,PointShape.Diamond);
> NuovoGraph.RemovePlot(plotA);
> NuovoGraph.AddPlot(plotA,NuovoGraph.Axes);
> Console.WriteLine("-> on plotA out");
> }
>
>
> }
>
-----
:working:
-----------------------------------------------------------------------------
http://freeflow.awardspace.com http://freeflow.awardspace.com
-----------------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/MedSphere-Graph-tp17803310p17820071.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list