Page 1 of 1

Cursors

Posted: Mon Apr 13, 2009 5:14 pm
by 13045128
Are there any changes in version 4 to address cursor performance?

Posted: Tue Apr 14, 2009 10:10 am
by narcis
Hi history,

Are you using FastCursor=true?

Posted: Tue Apr 14, 2009 2:14 pm
by 13045128

Posted: Wed Apr 15, 2009 1:50 pm
by narcis
Hi history,

Thanks for the information.
while the regular cursor is choppy in movement when there are a large number of points due to the painting
Nothing else has been done on that field. That's why FastCursor property was implemented.
One of the issues with fastcursor is that you may want to display information on the chart as the cursor is changing. With TeeChart you seem to be only able to paint all the screen and not a portion of the screen.
Yes, this works fine with our current v4 sources and using code below. You can see that only the annotation tool is being repainted if you set FastCursor to false.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private Steema.TeeChart.Tools.Annotation anno;
		private Rectangle r1;

		private void InitializeChart()
		{
			tChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.DoubleBuffer;

			tChart1.Aspect.View3D = false;
			tChart1.Series.Add(typeof(Steema.TeeChart.Styles.Line));
			tChart1[0].FillSampleValues(10000);

			Steema.TeeChart.Tools.CursorTool cursor;
			tChart1.Tools.Add(cursor = new Steema.TeeChart.Tools.CursorTool());
			cursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
			cursor.FollowMouse = true;
			cursor.FastCursor = true; //try false
			cursor.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(cursor_Change);

			tChart1.Tools.Add(anno = new Steema.TeeChart.Tools.Annotation());
			anno.AutoSize = false;
			anno.Top = 10;
			anno.Left = 10;
			anno.Height = 20;
			anno.Width = 110;
			r1 = anno.Shape.ShapeBounds;
			tChart1.AutoRepaint = false;
		}

		void cursor_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
		{
			anno.Text = e.XValue.ToString();
			tChart1.Invalidate(r1);
		}

Posted: Wed Apr 15, 2009 2:17 pm
by narcis
Hi history,

In the example above you may also be interested in implementing cursor's Change event as shown below when FastCursor=false.

Code: Select all

		private Rectangle oldRect;

		void cursor_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
		{
			anno.Text = e.XValue.ToString();
			tChart1.Invalidate(r1);
			
			Rectangle rect = tChart1.Chart.ChartRect;
			Steema.TeeChart.Tools.CursorTool cursor = (Steema.TeeChart.Tools.CursorTool)sender;
			int cursorPos = tChart1.Axes.Bottom.CalcPosValue(e.XValue - cursor.Pen.Width/2);
			Rectangle r2 = new Rectangle(cursorPos, rect.Top, cursor.Pen.Width, rect.Height);

			if (oldRect!=null) tChart1.Invalidate(oldRect);
			tChart1.Invalidate(r2);
			oldRect = r2;
		}