示例#1
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="id"></param>
        /// <param name="cameraPos"></param>
        /// <param name="tableSize"></param>
        public LaserInfo(int id, Vector3d cameraPos, SizeF tableSize)
        {
            Id = id;
            Vector3d loc      = new Vector3d();
            Settings settings = Settings.Get <Settings>();

            loc.X        = settings.Read(Settings.LASER(Id), Settings.X, 9.5f);
            loc.Y        = settings.Read(Settings.LASER(Id), Settings.Y, 27.0f);
            loc.Z        = settings.Read(Settings.LASER(Id), Settings.Z, 7.0f);
            DefaultColor = settings.Read(Settings.LASER(Id), Settings.DEFAULTCOLOR, LaserInfo.GetDefaultColor(Id));


            Location = loc;

            Mapper = new LocationMapper(Location, cameraPos, tableSize);

            Correction = new LaserCorrection();
            Correction.LoadFromSettings(Id);
        }
示例#2
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="id"></param>
        /// <param name="cameraPos"></param>
        /// <param name="tableSize"></param>
        public LaserInfo(int id, Vector3d cameraPos, SizeF tableSize)
        {
            Id = id;
            Vector3d loc = new Vector3d();
            Settings settings = Settings.Get<Settings>();
            loc.X = settings.Read(Settings.LASER(Id), Settings.X, 9.5f);
            loc.Y = settings.Read(Settings.LASER(Id), Settings.Y, 27.0f);
            loc.Z = settings.Read(Settings.LASER(Id), Settings.Z, 7.0f);
            DefaultColor = settings.Read(Settings.LASER(Id), Settings.DEFAULTCOLOR, LaserInfo.GetDefaultColor(Id));


            Location = loc;

            Mapper = new LocationMapper(Location, cameraPos, tableSize);

            Correction = new LaserCorrection();
            Correction.LoadFromSettings(Id);

        }
示例#3
0
		void ClearCorrection(int index)
		{
			LaserCorrection cor = new LaserCorrection();
			cor.SaveToSettings(index);
		}
示例#4
0
		void CommitCorrection()
		{
			if(CurrentLaserIndex>=0)
			{
				LaserCorrection cor = new LaserCorrection();
				cor.LoadFromSettings(CurrentLaserIndex);
				cor.Apply(Drag);
				cor.SaveToSettings(CurrentLaserIndex);
				Drag.Init();
			}
		}
示例#5
0
		protected void DrawScanLine(Graphics g, PointF translation, double scale, ScanLine line, LaserCorrection corr,bool selected)
		{
			List<PointF> points = new List<PointF>(line.Count);
			Matrix4d m = corr.GetMatrix();
			int laserid = line.LaserID;
            int count = line.Count;
            Color baseCol = GetLaserColor(laserid);
            Color col = Color.FromArgb(selected ? 128 / NumClass : 64 / NumClass, baseCol);
            for (int i = 0; i < line.Count; i++)
			{
				Point3D p = line[i];
				Vector3d v = Vector3d.Transform(p.Position, m);
                PointF pt = new PointF((float)(v.X * scale), (float)(v.Z * scale));
				pt.X += translation.X;
				pt.Y += translation.Y;
				points.Add(pt);
            }
            using (SolidBrush b = new SolidBrush(col))
                g.FillPolygon(b, points.ToArray());
            using (Pen b = new Pen(Color.FromArgb(selected ? 128 : 64 , baseCol)))
                g.DrawPolygon(b, points.ToArray());
        }
示例#6
0
		private void PreviewPanel_Paint(object sender, PaintEventArgs e)
		{
			//Graphics g = e.Graphics;
			using (Bitmap bmp = new Bitmap(PreviewPanel.Width, PreviewPanel.Height))
			{
				using (Graphics g = Graphics.FromImage(bmp))
				{
					g.Clip = new Region();
					using (SolidBrush b = new SolidBrush(PreviewPanel.BackColor))
						g.FillRectangle(b, 0, 0, PreviewPanel.Width, PreviewPanel.Height);

					if (ScanInfo != null)
					{
						try
						{
							ScanLine line=null;
							LaserCorrection corr = null;
							double size = ScanInfo.Size() * 1.2f;
							double factor = Math.Min(PreviewPanel.Width, PreviewPanel.Height) / size;
							Matrix4d baseMatrix = Matrix4d.Scale(factor);
							PointF center = new PointF(PreviewPanel.Width / 2, PreviewPanel.Height / 2);
                            DrawGrid(g, center, (float)factor);
							int currentLaser = CurrentLaserIndex;
							List<ScanLine> selectedLaserLine = new List<ScanLine>();
							for (int i = 0; i < ScanInfo.Count; i++)
							{
								line = ScanInfo[i];

								corr = new LaserCorrection();
								corr.LoadFromSettings(line.LaserID);
								bool selected = currentLaser == line.LaserID;
                                if (!selected)
                                {
                                    DrawScanLine(g, center, factor, line, corr, false);
                                }
                                else
                                    selectedLaserLine.Add(line);
							}

                            corr = new LaserCorrection();
                            corr.LoadFromSettings(selectedLaserLine[Math.Max(0,currentLaser)].LaserID);
                            corr.Apply(Drag);
                            for (int i = 0; i < selectedLaserLine.Count; i++)
							{
                                DrawScanLine(g, center, factor,selectedLaserLine[i], corr, true);
							}

						}
						catch
						{
						}
					}
				}
				e.Graphics.Clip = new Region();
				e.Graphics.DrawImageUnscaled(bmp, new Point(0, 0));
			}
		}