Esempio n. 1
0
 private void OnMouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Delta > 0)
     {
         kx *= 1.1f;
         ky  = kx;
     }
     if (e.Delta < 0)
     {
         kx /= 1.1f;
         ky  = kx;
     }
     GLC.Invalidate();
 }
Esempio n. 2
0
        private void glC_MouseMove(object sender, MouseEventArgs e)
        {
            double x1  = e.X;
            double y1  = e.Y;
            double ex1 = (x1 - GLC.Width / 2.0) / (GLC.Width / 2.0);

            stCoord.Text = string.Format("X={0} Y={1} ex={2}", x1, y1, ex1);

            if (e.Button == MouseButtons.Right)
            {
                x = PointToClient(Cursor.Position).X *(z + 1);
                y = (-PointToClient(Cursor.Position).Y + GLC.Height) * (z + 1);
            }
            GLC.Invalidate();
        }
Esempio n. 3
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                switch (ofd.FilterIndex)
                {
                case 0:
                    Points.Clear();
                    using (TextReader tr = File.OpenText(ofd.FileName))
                    {
                        string line;
                        double px, py, pz, pw;
                        while ((line = tr.ReadLine()) != null)
                        {
                            Console.WriteLine(line);
                            string[] vals = line.Split('\t');
                            double.TryParse(vals[0], out px);
                            double.TryParse(vals[1], out py);
                            double.TryParse(vals[2], out pz);
                            double.TryParse(vals[3], out pw);
                            Points.Add(new Point4D()
                            {
                                X = px, Y = py, Z = pz, W = pw
                            });
                        }
                    }
                    bArtRun.Visible = false;
                    break;

                case 1:
                    Sr.Load(ofd.FileName);
                    pg1.SelectedObject = Sr;
                    bArtRun.Visible    = false;
                    break;
                }
                GLC.Invalidate();
            }
        }
Esempio n. 4
0
        //

        private void btnMakePoints_Click_1(object sender, EventArgs e)
        {
            Point4D       p4d;
            List <double> times = new List <double>();
            double        currentTime = 0;
            double        dt, path, truepath, lastpath, lasttime, firstpath;
            double        Lx, Ly, Lz;
            double        px, py, pz;
            double        dx, dy, dz;
            int           nP;

            double.TryParse(cbTR.Text, out dt);
            GraphPoints.Clear();
            while (!queue.IsEmpty)
            {
                queue.TryDequeue(out p4d);
            }
            Console.WriteLine(string.Format("queue.Count {0}", queue.Count));
            lasttime  = 0;
            firstpath = 0;
            px        = Points[0].X;
            py        = Points[0].Y;
            pz        = Points[0].Z;
            GraphPoints.Add(new Point3D()
            {
                X = px, Y = py, Z = pz
            });
            times.Add(currentTime);
            Console.WriteLine(string.Format("Точка[{0}] {1} {2}", GraphPoints.Count, px, py));
            for (int i = 0; i < Points.Count - 1; i++)
            {
                Console.WriteLine();
                path = getDist(Points[i], Points[i + 1]);
                Lx   = Points[i + 1].X - Points[i].X;
                Ly   = Points[i + 1].Y - Points[i].Y;
                Lz   = Points[i + 1].Z - Points[i].Z;

                dx = Points[i].W * Lx / Math.Sqrt(Lx * Lx + Ly * Ly + Lz * Lz);
                dy = Points[i].W * Ly / Math.Sqrt(Lx * Lx + Ly * Ly + Lz * Lz);
                dz = Points[i].W * Lz / Math.Sqrt(Lx * Lx + Ly * Ly + Lz * Lz);
                Console.WriteLine(string.Format("dx {0} dy {1}", dx, dy));

                if (lasttime > 0)
                {
                    Console.WriteLine(string.Format("Начальное время {0}", dt - lasttime));
                    GraphPoints.RemoveAt(GraphPoints.Count - 1);
                    times.RemoveAt(times.Count - 1);
                    px          += (dt - lasttime) * dx;
                    py          += (dt - lasttime) * dy;
                    pz          += (dt - lasttime) * dz;
                    currentTime += dt - lasttime;
                    GraphPoints.Add(new Point3D()
                    {
                        X = px, Y = py, Z = pz
                    });
                    times.Add(currentTime);
                    Console.WriteLine(string.Format("Точка[{0}] {1} {2}", GraphPoints.Count, px, py));
                    firstpath = Math.Sqrt(Math.Pow((dt - lasttime) * dx, 2) + Math.Pow((dt - lasttime) * dy, 2) + Math.Pow((dt - lasttime) * dz, 2));
                    path     -= firstpath;
                }
                nP       = (int)Math.Floor(path / (Points[i].W * dt));
                truepath = nP * Points[i].W * dt;
                Console.WriteLine(string.Format("Отрезок {0} Длина {1} ЦелаяДлина {2} Точок={3}", i, path, truepath, nP));
                for (int j = 0; j < nP; j++)
                {
                    px          += dt * dx;
                    py          += dt * dy;
                    pz          += dt * dz;
                    currentTime += dt;
                    GraphPoints.Add(new Point3D()
                    {
                        X = px, Y = py, Z = pz
                    });
                    times.Add(currentTime);
                    Console.WriteLine(string.Format("Точка[{0}] {1} {2}", GraphPoints.Count, px, py));
                }
                lastpath = path - truepath;
                lasttime = lastpath / Points[i].W;
                Console.WriteLine(string.Format("ПоследняяДлина {0} ПоследнееВремя={1}", lastpath, lasttime));
                if (lasttime > 0)
                {
                    px          += lasttime * dx;
                    py          += lasttime * dy;
                    pz          += lasttime * dz;
                    currentTime += lasttime;
                    GraphPoints.Add(new Point3D()
                    {
                        X = px, Y = py, Z = pz
                    });
                    times.Add(currentTime);
                    Console.WriteLine(string.Format("Точка[{0}] {1} {2}", GraphPoints.Count, px, py));
                }
            }
            GLC.Invalidate();
            for (int i = 0; i < GraphPoints.Count; i++)
            {
                queue.Enqueue(new Point4D()
                {
                    X = GraphPoints[i].X, Y = GraphPoints[i].Y, Z = GraphPoints[i].Z, W = times[i]
                });
            }
            times = null;
            Console.WriteLine(string.Format("GraphPoints.Count = {0} Queue ={1}", GraphPoints.Count, queue.Count));
            //TestPoint();

            // HACH:

            /*
             * Ray.Hz.Clear();
             * Ray.Hz.AddRange(Sr.Profile.Select(p => (double)p.z).ToArray());
             *
             * Ray.Cz.Clear();
             * Ray.Cz.AddRange(Sr.Profile.Select(p => (double)p.c).ToArray());
             */

            bArtRun.Visible = true;
        }
Esempio n. 5
0
 private void GLC_MouseUp(object sender, MouseEventArgs e)
 {
     lbDown = false;
     //glX += 0.1;
     GLC.Invalidate();
 }