Selecting Lines

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Selecting Lines

Post by lilo » Thu Oct 06, 2011 3:40 am

Is it possible to select multiple lines with the mouse, drawn with the line tool?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Selecting Lines

Post by Sandra » Thu Oct 06, 2011 10:14 am

Hello lilo,

I think you can achieve as you want, using DrawLine and DrawLineItems tools that you allow select more of one DrawLines. I recomend take a look in this thread, where you find an example that can serve you to achieve as you want.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Re: Selecting Lines

Post by lilo » Thu Oct 06, 2011 11:10 am

Next question...if I have the start and end point coordinates for each line, will I be able to add a smoothing function for all the selected lines and draw the result?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Selecting Lines

Post by Sandra » Thu Oct 06, 2011 3:19 pm

Hello lilo,

Would be very greatful if you could explain exactly, step to step or with a graphic example, as you want achieve so we can try to find a good solution for you.

Thanks,
Best Regards,
Sandra Pazos / 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

lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Re: Selecting Lines

Post by lilo » Fri Oct 07, 2011 2:31 am

What I want to do is:

1.Draw some lines on a Teechart programatically

2. Select some of the lines with a mouse

3. Apply smoothing, such as BSpline, so I get a smooth curve.

4. Be ably to apply line thickness, color etc to the final curve

5. Be able to select the curve and/or its line segments with the mouse.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Selecting Lines

Post by Sandra » Fri Oct 07, 2011 9:11 am

Hello lilo,

Ok. In your case I suggest take a look in next example and do something as do in it. How you be able to see in the code is selected more of one series using Control key and mouse and I think will be helpful for you to try to achieve as you want.

Code: Select all

  public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.FastLine series1, series2,series3;
        int HandleSize = 5;
        Color oldBrushColor;
        Color oldPenColor;
        bool oldGradient;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            series1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            series2 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            series3 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            series1.FillSampleValues();
            series2.FillSampleValues();
            series3.FillSampleValues();
            series1.Color= Color.Blue;
            series2.Color = Color.Orange;
            series3.Color = Color.Red;
            tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
        }

        void tChart1_MouseDown(object sender, MouseEventArgs e)
        {
            Steema.TeeChart.ChartClickedPart p;
            Point pp = new Point();
            if (tChart1.Series.Count != 0)
            {
                foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
                {
                    if (s.Clicked(e.X, e.Y) != -1 && ModifierKeys == Keys.Control)
                    {
                        tChart1.AutoRepaint = false;
                        pp.X = e.X;
                        pp.Y = e.Y;
                        tChart1.Chart.CalcClickedPart(pp, out p);
                        if (p.Part == Steema.TeeChart.ChartClickedPartStyle.Series)
                        {
                            DrawSelection(p);

                        }
                    }
                    else
                    {                    
                        tChart1.AutoRepaint = true;
                       
                    }
                }
            }
        }
           private void DrawSelection(Steema.TeeChart.ChartClickedPart Part)
           {
               int t, X, Y;
               int tmpStep, tmpLast, tmpCount;
               Steema.TeeChart.Styles.Series tmpSeries = Part.ASeries;
               Steema.TeeChart.Drawing.Graphics3D g = tChart1.Chart.Graphics3D;
               
         if (Part.ASeries != null)
         {
               tmpCount = tmpSeries.LastVisibleIndex - tmpSeries.FirstVisibleIndex;
               if (tmpCount == 0) tmpCount = Part.ASeries.Count;
               if (tmpCount > 20)
               {
                   tmpStep = tmpCount/ 20;
               }
               else
               {
                   tmpStep = 1;
               }
               t = tmpSeries.FirstVisibleIndex;
               if (t == -1)t = 0;
               tmpLast = tmpSeries.LastVisibleIndex;
               if (tmpLast == -1) tmpLast = Part.ASeries.Count - 1;
               oldBrushColor = g.Brush.Color;
               oldPenColor = g.Pen.Color;
               oldGradient = g.Gradient.Visible;

               g.Gradient.Visible = false;
               g.Brush.Color = Color.Black;
               g.Pen.Color = Color.Black;
               while (t < tmpLast)
               {
                   X = tmpSeries.CalcXPos(t);
                   Y = tmpSeries.CalcYPos(t);
                   g.Rectangle(RectFormPoint1(X, Y), tmpSeries.MiddleZ);
                   t += tmpStep;
               }
               g.Brush.Color = oldBrushColor;
               oldPenColor = g.Pen.Color = oldBrushColor;
               g.Gradient.Visible = oldGradient;
               series1.Color = Color.Blue;
               series2.Color = Color.Orange;
               series3.Color = Color.Red;
         }
         
        }
           private Rectangle RectFormPoint1(int X, int Y)
           {
               //return a rectangle few pixels around XY point }
               return Steema.TeeChart.Utils.FromLTRB(X - HandleSize, Y - HandleSize, X + HandleSize, Y + HandleSize);

           }
Can you tell us if previous code works as you want?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Re: Selecting Lines

Post by lilo » Sun Oct 09, 2011 3:53 am

Thanks Sandra,

This solution should work best for me:

"I think you can achieve as you want, using DrawLine and DrawLineItems tools that you allow select more of one DrawLines. I recomend take a look in this thread, where you find an example that can serve you to achieve as you want. "

lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Re: Selecting Lines

Post by lilo » Sun Oct 09, 2011 4:16 am

Also, if I select more than one line with the mouse, the handles are only displayed for the currently selected item. Is there a property that will allow the handles to remain visible for all selected lines?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Selecting Lines

Post by Sandra » Mon Oct 10, 2011 3:05 pm

Hello lilo,

I would be very helpful if you can send us a simple project, so we can see what you want do and try to find a good solution for you.


Thanks,
Best Regards,
Sandra Pazos / 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