Cursors

TeeChart Beta versions
Post Reply
history
Newbie
Newbie
Posts: 29
Joined: Tue May 22, 2007 12:00 am

Cursors

Post by history » Mon Apr 13, 2009 5:14 pm

Are there any changes in version 4 to address cursor performance?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 14, 2009 10:10 am

Hi history,

Are you using FastCursor=true?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

history
Newbie
Newbie
Posts: 29
Joined: Tue May 22, 2007 12:00 am

Post by history » Tue Apr 14, 2009 2:14 pm


Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 15, 2009 1:50 pm

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);
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 15, 2009 2:17 pm

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;
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply