[Quantproject-developers] QuantProject/b5_Presentation/Charting Chart.cs,1.5,1.6
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2005-04-03 00:04:51
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Charting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9721/b5_Presentation/Charting Modified Files: Chart.cs Log Message: Each ChartPlot is now computed just once. In the previous version, it was computed on each OnPaint event. As a consequence, not it is more efficient. Furthermore, now zoom feature is available. Index: Chart.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Charting/Chart.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Chart.cs 29 Mar 2005 15:03:16 -0000 1.5 --- Chart.cs 3 Apr 2005 00:04:41 -0000 1.6 *************** *** 41,44 **** --- 41,48 ---- { this.chartPlots = new ArrayList(); + this.AllowSelection = true; + this.AutoScaleAutoGeneratedAxes = false; + this.RightMenu = NPlot.Windows.PlotSurface2D.DefaultContextMenu; + // this.Paint += new System.Windows.Forms.PaintEventHandler(this.Chart_Paint); } *************** *** 57,60 **** --- 61,65 ---- ChartPlot chartPlot = new ChartPlot( history , Color.Red ); this.chartPlots.Add( chartPlot ); + this.addChartPlot( chartPlot ); } public void Add( History history , Color color ) *************** *** 62,65 **** --- 67,71 ---- ChartPlot chartPlot = new ChartPlot( history , color ); this.chartPlots.Add( chartPlot ); + this.addChartPlot( chartPlot ); } /// <summary> *************** *** 75,81 **** ChartPlot chartPlot = new ChartPlot( history , color , startDateTime , endDateTime ); this.chartPlots.Add( chartPlot ); } ! #region "OnPaint" ! private void onPaint_addLinePlot_ok( ChartPlot chartPlot ) { int npt=chartPlot.History.Count; --- 81,87 ---- ChartPlot chartPlot = new ChartPlot( history , color , startDateTime , endDateTime ); this.chartPlots.Add( chartPlot ); + this.addChartPlot( chartPlot ); } ! private void addChartPlot( ChartPlot chartPlot ) { int npt=chartPlot.History.Count; *************** *** 108,142 **** this.Add(lp); } - private void onPaint_addLinePlot( ChartPlot chartPlot ) - { - int npt=chartPlot.History.Count; - int startIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.StartDateTime ); - int endIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.EndDateTime ); - int plotLength = endIndex - startIndex + 1; - float [] x = new float[ plotLength ]; - float [] y = new float[ plotLength ]; - - float step=1.0F; - for ( int i=startIndex ; i<=endIndex ; i++ ) - { - x[i-startIndex]=i*step; - y[i-startIndex]=(float)chartPlot.History.GetByIndex( i ); - } - - // LinePlot lp=new LinePlot( new ArrayAdapter(x,y) ); commentata per avere compilazione; rimuovi commenti per farlo funzionare con la vecchia scpl - Pen p=new Pen( chartPlot.Color ); - // lp.Pen=p; - - // base.Clear(); - // this.Add(lp); - } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Console.WriteLine( "Chart.OnPaint()" ); ! foreach ( ChartPlot chartPlot in this.chartPlots ) ! onPaint_addLinePlot_ok( chartPlot ); base.OnPaint( e ); } - #endregion } } --- 114,124 ---- this.Add(lp); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Console.WriteLine( "Chart.OnPaint()" ); ! // foreach ( ChartPlot chartPlot in this.chartPlots ) ! // onPaint_addLinePlot_ok( chartPlot ); base.OnPaint( e ); } } } |