public static Bitmap MakeBlendMap(ProjectorEntry pe, int blur, int blurIterations, float gamma)
        {
            BlendPoint pnt      = new BlendPoint();
            Bitmap     bmpBlend = new Bitmap(512, 512);

            double   xFactor = 512.0 / pe.Width;
            double   yFactor = 512.0 / pe.Height;
            Graphics g       = Graphics.FromImage(bmpBlend);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.PixelOffsetMode = PixelOffsetMode.HighQuality;

            List <PointF> points = new List <PointF>();

            foreach (BlendPoint bp in pe.BlendPolygon)
            {
                points.Add(new PointF((float)(bp.X * xFactor), (float)(bp.Y * yFactor)));
            }

            Brush brush = new SolidBrush(Color.FromArgb(255, Gamma(pe.WhiteBalance.Red, gamma), Gamma(pe.WhiteBalance.Green, gamma), Gamma(pe.WhiteBalance.Blue, gamma)));

            if (points.Count < 3)
            {
                g.Clear(Color.White);
            }
            else
            {
                g.Clear(Color.Black);

                g.FillPolygon(brush, points.ToArray());
            }
            g.Flush();
            g.Dispose();
            g = null;
            brush.Dispose();

            for (int i = 0; i < blurIterations; i++)
            {
                BlurBitmap(bmpBlend, blur);
            }

            bmpBlend = GammaBmp(bmpBlend, gamma);

            return(bmpBlend);
        }
        public static Bitmap MakeWarpMap(ProjectorEntry pe, double domeSize, bool radialDistortion, List<GroundTruthPoint> gtPointList, ScreenTypes screenType)
        {
            List<Vector2d> PointTo = new List<Vector2d>();
            List<Vector2d> PointFrom = new List<Vector2d>();

            double xFactor = pe.Width / 512.0;
            double yFactor = pe.Height / 512.0;

            Bitmap bmp = new Bitmap(512, 512);
            FastBitmap fastBmp = new FastBitmap(bmp);

            SolveProjector spProjector = new SolveProjector(pe, domeSize, ProjectionType.Projector, screenType, SolveParameters.Default);
            spProjector.RadialDistorion = radialDistortion;

            SolveProjector spView = new SolveProjector(pe, domeSize, ProjectionType.View, ScreenTypes.Spherical, SolveParameters.Default);
            spView.RadialDistorion = false;

            foreach (GroundTruthPoint gt in gtPointList)
            {
                PointFrom.Add(new Vector2d((double)gt.X / (double)pe.Width * 512, (double)gt.Y / (double)pe.Height * 512));

                Vector2d pntOutTarget = spView.ProjectPoint(new Vector2d(gt.Az, gt.Alt));
                Vector2d AltAzMapped = spProjector.GetCoordinatesForScreenPoint(gt.X,gt.Y);
                Vector2d pntOutMapped = spView.ProjectPoint(new Vector2d(AltAzMapped.X, AltAzMapped.Y));

                pntOutTarget.X = pntOutTarget.X *(512 / 2.0) + (512 / 2.0);
                pntOutTarget.Y = pntOutTarget.Y *(-512 / 2.0) + (512 / 2.0);
                pntOutMapped.X = pntOutMapped.X *(512 / 2.0) + (512 / 2.0);
                pntOutMapped.Y =  pntOutMapped.Y *(-512 / 2.0) + (512 / 2.0);

                PointTo.Add(new Vector2d(pntOutTarget.X - pntOutMapped.X, pntOutTarget.Y - pntOutMapped.Y));

            }

            //Matrix3d projMat = spView.GetCameraMatrix();
            unsafe
            {
                fastBmp.LockBitmap();
                for (int y = 0; y < 512; y++)
                {

                    for (int x = 0; x < 512; x++)
                    {
                        Vector2d pnt = spProjector.GetCoordinatesForScreenPoint(x * xFactor, y * yFactor);

                        Vector2d pntOut = spView.ProjectPoint(pnt);

                        // Map
                        pntOut.X = pntOut.X * (512 / 2.0) + (512 / 2.0);
                        pntOut.Y = pntOut.Y * (-512 / 2.0) + (512 / 2.0);

                        pntOut = MapPoint(new Vector2d(x,y), pntOut, PointTo, PointFrom);

                        pntOut.X = (pntOut.X - (512 / 2.0)) / (512 / 2.0);
                        pntOut.Y = (pntOut.Y - (512 / 2.0)) / (-512 / 2.0);
                        // End Map

                        double xo = pntOut.X * (4096 / 2.0) + (4096 / 2.0);
                        double yo = pntOut.Y * (-4096 / 2.0) + (4096 / 2.0);

                        int blue = (int)xo & 255;
                        int green = (int)yo & 255;
                        int red = (((int)yo) >> 4 & 240) + (((int)xo) >> 8 & 15);
                        *fastBmp[x, y] = new PixelData(red, green, blue, 255);

                    }
                }
                fastBmp.UnlockBitmap();

            }
            return bmp;
        }
        public static Bitmap MakeBlendMap(ProjectorEntry pe, int blur, int blurIterations, float gamma)
        {
            BlendPoint pnt = new BlendPoint();
            Bitmap bmpBlend = new Bitmap(512, 512);

            double xFactor = 512.0/pe.Width;
            double yFactor = 512.0/pe.Height;
            Graphics g = Graphics.FromImage(bmpBlend);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.PixelOffsetMode = PixelOffsetMode.HighQuality;

            List<PointF> points = new List<PointF>();

            foreach (BlendPoint bp in pe.BlendPolygon)
            {
                points.Add(new PointF((float)(bp.X*xFactor), (float)(bp.Y*yFactor)));
            }

            Brush brush = new SolidBrush(Color.FromArgb(255, Gamma(pe.WhiteBalance.Red, gamma), Gamma(pe.WhiteBalance.Green, gamma), Gamma(pe.WhiteBalance.Blue, gamma)));

            if (points.Count < 3)
            {
                g.Clear(Color.White);
            }
            else
            {
                g.Clear(Color.Black);

                g.FillPolygon(brush, points.ToArray());
            }
            g.Flush();
            g.Dispose();
            g = null;
            brush.Dispose();

            for (int i = 0; i < blurIterations; i++)
            {
                BlurBitmap(bmpBlend, blur);
            }

            bmpBlend = GammaBmp(bmpBlend, gamma);

               return bmpBlend;
        }
Exemple #4
0
 private void projectorList_SelectionChanged(object sender, EventArgs e)
 {
     UpdateProjectorEntry();
     Projector = (ProjectorEntry)projectorList.SelectedItem;
     SyncProjectorEntry();
 }
 private void projectorList_SelectionChanged(object sender, EventArgs e)
 {
     UpdateProjectorEntry();
     Projector = (ProjectorEntry)projectorList.SelectedItem;
     SyncProjectorEntry();
 }
        public static Bitmap MakeBlendMap(ProjectorEntry pe, int blur, int blurIterations, float gamma)
        {
            var bmpBlend = new Bitmap(512, 512);

            var xFactor = 512.0/pe.Width;
            var yFactor = 512.0/pe.Height;
            var g = Graphics.FromImage(bmpBlend);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.PixelOffsetMode = PixelOffsetMode.HighQuality;

            var points = pe.BlendPolygon.Select(bp => new PointF((float) (bp.X*xFactor), (float) (bp.Y*yFactor))).ToList();

            Brush brush = new SolidBrush(Color.FromArgb(255, Gamma(pe.WhiteBalance.Red, gamma), Gamma(pe.WhiteBalance.Green, gamma), Gamma(pe.WhiteBalance.Blue, gamma)));

            if (points.Count < 3)
            {
                g.Clear(Color.White);
            }
            else
            {
                g.Clear(Color.Black);

                g.FillPolygon(brush, points.ToArray());
            }
            g.Flush();
            g.Dispose();
            brush.Dispose();

            for (var i = 0; i < blurIterations; i++)
            {
                BlurBitmap(bmpBlend, blur);
            }

            bmpBlend = GammaBmp(bmpBlend, gamma);

               return bmpBlend;
        }
        private void Calibration_Load(object sender, EventArgs e)
        {
            leftBrush = new SolidBrush(Color.Red);
            rightBrush = new SolidBrush(Color.Green);

            MakeRegions();

            for (var i = 1; i < 7; i++)
            {
                var pe = new ProjectorEntry {Name = "Projector " + i, ID = i};

                CalibrationInfo.Projectors.Add(pe);
                CalibrationInfo.ProjLookup.Add(pe.ID, pe);
            }

            CalibrationInfo.AddEdge(new Edge(2, 1));
            CalibrationInfo.AddEdge(new Edge(5, 1));
            CalibrationInfo.AddEdge(new Edge(1, 4));
            CalibrationInfo.AddEdge(new Edge(2, 5));
            CalibrationInfo.AddEdge(new Edge(5, 4));
            CalibrationInfo.AddEdge(new Edge(2, 6));
            CalibrationInfo.AddEdge(new Edge(6, 4));
            CalibrationInfo.AddEdge(new Edge(2, 3));
            CalibrationInfo.AddEdge(new Edge(3, 6));
            CalibrationInfo.AddEdge(new Edge(5, 6));
            CalibrationInfo.AddEdge(new Edge(3, 4));

            ReloadListBox();

            if (File.Exists(Properties.Settings.Default.LastDomeConfigFile))
            {
                OpenConfigFile(Properties.Settings.Default.LastDomeConfigFile);
            }

            BlendPanelButtons .Visible = false;
            BlendPanelButtons.Dock = DockStyle.None;
        }
        public static Bitmap MakeWarpMap(ProjectorEntry pe, double domeSize, bool radialDistortion, List <GroundTruthPoint> gtPointList, ScreenTypes screenType)
        {
            List <Vector2d> PointTo   = new List <Vector2d>();
            List <Vector2d> PointFrom = new List <Vector2d>();

            double xFactor = pe.Width / 512.0;
            double yFactor = pe.Height / 512.0;

            Bitmap     bmp     = new Bitmap(512, 512);
            FastBitmap fastBmp = new FastBitmap(bmp);

            SolveProjector spProjector = new SolveProjector(pe, domeSize, ProjectionType.Projector, screenType, SolveParameters.Default);

            spProjector.RadialDistorion = radialDistortion;

            SolveProjector spView = new SolveProjector(pe, domeSize, ProjectionType.View, ScreenTypes.Spherical, SolveParameters.Default);

            spView.RadialDistorion = false;


            foreach (GroundTruthPoint gt in gtPointList)
            {
                PointFrom.Add(new Vector2d((double)gt.X / (double)pe.Width * 512, (double)gt.Y / (double)pe.Height * 512));

                Vector2d pntOutTarget = spView.ProjectPoint(new Vector2d(gt.Az, gt.Alt));
                Vector2d AltAzMapped  = spProjector.GetCoordinatesForScreenPoint(gt.X, gt.Y);
                Vector2d pntOutMapped = spView.ProjectPoint(new Vector2d(AltAzMapped.X, AltAzMapped.Y));

                pntOutTarget.X = pntOutTarget.X * (512 / 2.0) + (512 / 2.0);
                pntOutTarget.Y = pntOutTarget.Y * (-512 / 2.0) + (512 / 2.0);
                pntOutMapped.X = pntOutMapped.X * (512 / 2.0) + (512 / 2.0);
                pntOutMapped.Y = pntOutMapped.Y * (-512 / 2.0) + (512 / 2.0);

                PointTo.Add(new Vector2d(pntOutTarget.X - pntOutMapped.X, pntOutTarget.Y - pntOutMapped.Y));
            }



            //Matrix3d projMat = spView.GetCameraMatrix();
            unsafe
            {
                fastBmp.LockBitmap();
                for (int y = 0; y < 512; y++)
                {
                    for (int x = 0; x < 512; x++)
                    {
                        Vector2d pnt = spProjector.GetCoordinatesForScreenPoint(x * xFactor, y * yFactor);

                        Vector2d pntOut = spView.ProjectPoint(pnt);

                        // Map
                        pntOut.X = pntOut.X * (512 / 2.0) + (512 / 2.0);
                        pntOut.Y = pntOut.Y * (-512 / 2.0) + (512 / 2.0);

                        pntOut = MapPoint(new Vector2d(x, y), pntOut, PointTo, PointFrom);

                        pntOut.X = (pntOut.X - (512 / 2.0)) / (512 / 2.0);
                        pntOut.Y = (pntOut.Y - (512 / 2.0)) / (-512 / 2.0);
                        // End Map


                        double xo = pntOut.X * (4096 / 2.0) + (4096 / 2.0);
                        double yo = pntOut.Y * (-4096 / 2.0) + (4096 / 2.0);

                        int blue          = (int)xo & 255;
                        int green         = (int)yo & 255;
                        int red           = (((int)yo) >> 4 & 240) + (((int)xo) >> 8 & 15);
                        *   fastBmp[x, y] = new PixelData(red, green, blue, 255);
                    }
                }
                fastBmp.UnlockBitmap();
            }
            return(bmp);
        }
        private void TransferEdges(ProjectorEntry pe)
        {
            var pointList = new SortedList<double, BlendPoint>();

            foreach (var edge in CalibrationInfo.Edges)
            {
                var right = false;
                if (edge.Right == pe.ID)
                {
                    right = true;
                }
                else if (edge.Left != pe.ID)
                {
                    continue;
                }

                foreach (var edgePoint in edge.Points)
                {
                    if (!edgePoint.Blend)
                    {
                        continue;
                    }

                    var pnt = right ? edgePoint.Right : edgePoint.Left;

                    var blend = new BlendPoint {X = pnt.X, Y = pnt.Y};
                    var angle = Math.Atan2(pnt.X - (pe.Width / 2.0), pnt.Y - (pe.Height / 2.0));
                    if (!pointList.ContainsKey(angle))
                    {
                        pointList.Add(angle, blend);
                    }
                }
            }

            foreach (var blend in pointList.Values)
            {
                pe.BlendPolygon.Add(blend);
            }
        }
        private void SendBlendPointEditUpdate(ProjectorEntry pe)
        {
            var sb = new StringBuilder();

            var first = true;
            foreach (var bp in pe.BlendPolygon)
            {
                if (!first)
                {
                    sb.Append(";");
                }
                else
                {
                    first = false;
                }
                sb.Append(bp.X.ToString(CultureInfo.InvariantCulture));
                sb.Append(" ");
                sb.Append(bp.Y.ToString(CultureInfo.InvariantCulture));
                sb.Append(" ");
                sb.Append(bp.Softness.ToString(CultureInfo.InvariantCulture));
            }

            var command = "CAL," + Earth3d.MainWindow.Config.ClusterID + "," + pe.ID + ",GEOMETRY," + GeometryStyles.Polygon + "," + pe.SelectedBlendPoint + "," + SavedColor.Save(Color.FromArgb(255, Gamma(pe.WhiteBalance.Red), Gamma(pe.WhiteBalance.Green), Gamma(pe.WhiteBalance.Blue))) + "," + SavedColor.Save(Color.Yellow) + "," + sb;
            NetControl.SendCommand(command);
        }
        private void SendAlignPointEditUpdate(ProjectorEntry pe, bool emptyList)
        {
            var sb = new StringBuilder();
            if (!emptyList)
            {
                var first = true;
                foreach (var gt in pe.Constraints)
                {
                    if (!first)
                    {
                        sb.Append(";");
                    }
                    else
                    {
                        first = false;
                    }
                    sb.Append(gt.X.ToString(CultureInfo.InvariantCulture));
                    sb.Append(" ");
                    sb.Append(gt.Y.ToString(CultureInfo.InvariantCulture));
                }
            }
            var pointColor = Color.Red;

            var command = "CAL," + Earth3d.MainWindow.Config.ClusterID + "," + pe.ID + ",GEOMETRY," + GeometryStyles.Points + "," + pe.SelectedGroundTruth + "," + SavedColor.Save(Color.White) + "," + SavedColor.Save(pointColor) + "," + sb;
            NetControl.SendCommand(command);
        }
        public static void SendViewConfig(int projectorID, ProjectorEntry pe, double domeTilt)
        {
            var command = string.Format("CONFIG,{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                Earth3d.MainWindow.Config.ClusterID,
                pe.ID,
                pe.ViewTransform.Heading,
                pe.ViewTransform.Pitch,
                pe.ViewTransform.Roll,
                pe.ViewProjection.FOV / 2,
                pe.ViewProjection.FOV / 2,
                pe.ViewProjection.Aspect,
                domeTilt);

            NetControl.SendCommand(command);
        }
        private void AddProjector_Click(object sender, EventArgs e)
        {
            int maxID = -1;

            foreach (ProjectorEntry p in CalibrationInfo.Projectors)
            {
                if (p.ID > maxID)
                {
                    maxID = p.ID;
                }
            }
            maxID++;

            ProjectorProperties projProps = new ProjectorProperties();
            ProjectorEntry pe = new ProjectorEntry();
            pe.ID = maxID;
            projProps.Projector = pe;
            projProps.CalibrationInfo = CalibrationInfo;
            projProps.AddMode = true;
            bool allGood = false;

            while (!allGood)
            {
                if (projProps.ShowDialog() == DialogResult.OK)
                {
                    if (!CalibrationInfo.ProjLookup.ContainsKey(pe.ID))
                    {
                        CalibrationInfo.Projectors.Add(pe);
                        CalibrationInfo.ProjLookup.Add(pe.ID, pe);
                        allGood = true;
                    }
                    else
                    {
                        UiTools.ShowMessageBox(Language.GetLocalizedText(696, "That ID currently exists. Please choose a unique ID"));
                        allGood = false;
                    }
                }
                else
                {
                    allGood = true;
                }
            }
            ReloadListBox();
        }
        private void TransferEdges(ProjectorEntry pe)
        {
            SortedList<double, BlendPoint> pointList = new SortedList<double, BlendPoint>();

            foreach (Edge edge in CalibrationInfo.Edges)
            {
                bool right = false;
                if (edge.Right == pe.ID)
                {
                    right = true;
                }
                else if (edge.Left != pe.ID)
                {
                    continue;
                }

                foreach (EdgePoint edgePoint in edge.Points)
                {
                    GroundTruthPoint pnt;
                    if (!edgePoint.Blend)
                    {
                        continue;
                    }

                    if (right)
                    {
                        pnt = edgePoint.Right;
                    }
                    else
                    {
                        pnt = edgePoint.Left;
                    }

                    BlendPoint blend = new BlendPoint();
                    blend.X = pnt.X;
                    blend.Y = pnt.Y;
                    double angle = Math.Atan2(pnt.X - (pe.Width / 2), pnt.Y - (pe.Height / 2));
                    if (!pointList.ContainsKey(angle))
                    {
                        pointList.Add(angle, blend);
                    }
                }
            }

            foreach (BlendPoint blend in pointList.Values)
            {
                pe.BlendPolygon.Add(blend);
            }
        }
        public SolveProjector(ProjectorEntry pe, double radius, ProjectionType type, ScreenTypes tranformType, SolveParameters solveParameters)
        {
            this.projectionType  = type;
            this.screenType      = tranformType;
            this.solveParameters = solveParameters;

            switch (type)
            {
            case ProjectionType.View:
            {
                Fov.Value           = pe.ViewProjection.FOV;
                Aspect.Value        = pe.ViewProjection.Aspect;
                OffsetX.Value       = pe.ViewProjection.XOffset;
                OffsetY.Value       = pe.ViewProjection.YOffset;
                RadialCenterX.Value = pe.ViewProjection.RadialCenterX;
                RadialCenterY.Value = pe.ViewProjection.RadialCenterY;
                RadialAmountX.Value = pe.ViewProjection.RadialAmountX;
                RadialAmountY.Value = pe.ViewProjection.RadialAmountY;

                Pitch.Value   = pe.ViewTransform.Pitch;
                Heading.Value = pe.ViewTransform.Heading;
                Roll.Value    = pe.ViewTransform.Roll;
                X.Value       = -pe.ViewTransform.X;
                Y.Value       = pe.ViewTransform.Y;
                Z.Value       = pe.ViewTransform.Z;
            }
            break;

            case ProjectionType.FishEye:
            case ProjectionType.Projector:
            {
                Fov.Value           = pe.ProjectorProjection.FOV;
                Aspect.Value        = pe.ProjectorProjection.Aspect;
                OffsetX.Value       = pe.ProjectorProjection.XOffset;
                OffsetY.Value       = pe.ProjectorProjection.YOffset;
                RadialCenterX.Value = pe.ProjectorProjection.RadialCenterX;
                RadialCenterY.Value = pe.ProjectorProjection.RadialCenterY;
                RadialAmountX.Value = pe.ProjectorProjection.RadialAmountX;
                RadialAmountY.Value = pe.ProjectorProjection.RadialAmountY;

                Pitch.Value   = pe.ProjectorTransform.Pitch;
                Heading.Value = pe.ProjectorTransform.Heading;
                Roll.Value    = pe.ProjectorTransform.Roll;
                X.Value       = -pe.ProjectorTransform.X;
                Y.Value       = pe.ProjectorTransform.Y;
                Z.Value       = pe.ProjectorTransform.Z;
            }
            break;

            case ProjectionType.Solved:
            {
                Fov.Value           = pe.SolvedProjection.FOV;
                Aspect.Value        = pe.SolvedProjection.Aspect;
                OffsetX.Value       = pe.SolvedProjection.XOffset;
                OffsetY.Value       = pe.SolvedProjection.YOffset;
                RadialCenterX.Value = pe.ProjectorProjection.RadialCenterX;
                RadialCenterY.Value = pe.ProjectorProjection.RadialCenterY;
                RadialAmountX.Value = pe.ProjectorProjection.RadialAmountX;
                RadialAmountY.Value = pe.ProjectorProjection.RadialAmountY;

                Pitch.Value   = pe.SolvedTransform.Pitch;
                Heading.Value = pe.SolvedTransform.Heading;
                Roll.Value    = pe.SolvedTransform.Roll;
                X.Value       = -pe.SolvedTransform.X;
                Y.Value       = pe.SolvedTransform.Y;
                Z.Value       = pe.SolvedTransform.Z;
            }
            break;

            default:
                break;
            }

            useGrid = pe.UseGrid;

            width        = pe.Width;
            height       = pe.Height;
            sphereRadius = radius;

            if (useGrid)
            {
                LoadGrid(pe.Constraints);
            }
        }
        public SolveProjector(ProjectorEntry pe, double radius, ProjectionType type, ScreenTypes tranformType, SolveParameters solveParameters)
        {
            projectionType = type;
            screenType = tranformType;
            this.solveParameters = solveParameters;

            switch (type)
            {
                case ProjectionType.View:
                    {

                        Fov.Value = pe.ViewProjection.FOV;
                        Aspect.Value = pe.ViewProjection.Aspect;
                        OffsetX.Value = pe.ViewProjection.XOffset;
                        OffsetY.Value = pe.ViewProjection.YOffset;
                        RadialCenterX.Value = pe.ViewProjection.RadialCenterX;
                        RadialCenterY.Value = pe.ViewProjection.RadialCenterY;
                        RadialAmountX.Value = pe.ViewProjection.RadialAmountX;
                        RadialAmountY.Value = pe.ViewProjection.RadialAmountY;

                        Pitch.Value = pe.ViewTransform.Pitch;
                        Heading.Value = pe.ViewTransform.Heading;
                        Roll.Value = pe.ViewTransform.Roll;
                        X.Value = -pe.ViewTransform.X;
                        Y.Value = pe.ViewTransform.Y;
                        Z.Value = pe.ViewTransform.Z;
                    }
                    break;
                case ProjectionType.FishEye:
                case ProjectionType.Projector:
                    {
                        Fov.Value = pe.ProjectorProjection.FOV;
                        Aspect.Value = pe.ProjectorProjection.Aspect;
                        OffsetX.Value = pe.ProjectorProjection.XOffset;
                        OffsetY.Value = pe.ProjectorProjection.YOffset;
                        RadialCenterX.Value = pe.ProjectorProjection.RadialCenterX;
                        RadialCenterY.Value = pe.ProjectorProjection.RadialCenterY;
                        RadialAmountX.Value = pe.ProjectorProjection.RadialAmountX;
                        RadialAmountY.Value = pe.ProjectorProjection.RadialAmountY;

                        Pitch.Value = pe.ProjectorTransform.Pitch;
                        Heading.Value = pe.ProjectorTransform.Heading;
                        Roll.Value = pe.ProjectorTransform.Roll;
                        X.Value = -pe.ProjectorTransform.X;
                        Y.Value = pe.ProjectorTransform.Y;
                        Z.Value = pe.ProjectorTransform.Z;
                    }
                    break;
                case ProjectionType.Solved:
                    {
                        Fov.Value = pe.SolvedProjection.FOV;
                        Aspect.Value = pe.SolvedProjection.Aspect;
                        OffsetX.Value = pe.SolvedProjection.XOffset;
                        OffsetY.Value = pe.SolvedProjection.YOffset;
                        RadialCenterX.Value = pe.ProjectorProjection.RadialCenterX;
                        RadialCenterY.Value = pe.ProjectorProjection.RadialCenterY;
                        RadialAmountX.Value = pe.ProjectorProjection.RadialAmountX;
                        RadialAmountY.Value = pe.ProjectorProjection.RadialAmountY;

                        Pitch.Value = pe.SolvedTransform.Pitch;
                        Heading.Value = pe.SolvedTransform.Heading;
                        Roll.Value = pe.SolvedTransform.Roll;
                        X.Value = -pe.SolvedTransform.X;
                        Y.Value = pe.SolvedTransform.Y;
                        Z.Value = pe.SolvedTransform.Z;
                    }
                    break;
            }

            width = pe.Width;
            height = pe.Height;
            sphereRadius = radius;
        }
        private void AddProjector_Click(object sender, EventArgs e)
        {
            var maxID = CalibrationInfo.Projectors.Select(p => p.ID).Concat(new[] {-1}).Max();

            maxID++;

            var projProps = new ProjectorProperties();
            var pe = new ProjectorEntry {ID = maxID};
            projProps.Projector = pe;
            projProps.CalibrationInfo = CalibrationInfo;
            projProps.AddMode = true;
            var allGood = false;

            while (!allGood)
            {
                if (projProps.ShowDialog() == DialogResult.OK)
                {
                    if (!CalibrationInfo.ProjLookup.ContainsKey(pe.ID))
                    {
                        CalibrationInfo.Projectors.Add(pe);
                        CalibrationInfo.ProjLookup.Add(pe.ID, pe);
                        allGood = true;
                    }
                    else
                    {
                        UiTools.ShowMessageBox(Language.GetLocalizedText(696, "That ID currently exists. Please choose a unique ID"));
                    }
                }
                else
                {
                    allGood = true;
                }
            }
            ReloadListBox();
        }