public TourPlace(string name, CameraParameters camParams, Classification classification, string constellation, ImageSetType type, SolarSystemObjects target)
 {
     this.constellation = constellation;
     this.name = name;
     Classification = classification;
     this.camParams = camParams;
     Type = type;
     Target = target;
 }
Esempio n. 2
0
        public static CameraParameters Interpolate(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove)
        {
            CameraParameters result   = new CameraParameters();
            double           alpha    = EaseCurve(alphaIn, type);
            double           alphaBIn = Math.Min(1.0, alphaIn * 2);
            double           alphaB   = EaseCurve(alphaBIn, type);

            result.Angle    = to.Angle * alpha + from.Angle * (1.0 - alpha);
            result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha);
            if (fastDirectionMove)
            {
                result.Lat = to.Lat * alphaB + from.Lat * (1.0 - alphaB);
                result.Lng = to.Lng * alphaB + from.Lng * (1.0 - alphaB);
            }
            else
            {
                result.Lat = to.Lat * alpha + from.Lat * (1.0 - alpha);
                result.Lng = to.Lng * alpha + from.Lng * (1.0 - alpha);
            }
            result.Zoom       = Math.Pow(2, Math.Log(to.Zoom, 2) * alpha + Math.Log(from.Zoom, 2) * (1.0 - alpha));
            result.Opacity    = (float)(to.Opacity * alpha + from.Opacity * (1.0 - alpha));
            result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha);

            result.DomeAlt = to.DomeAlt * alpha + from.DomeAlt * (1.0 - alpha);
            result.DomeAz  = to.DomeAz * alpha + from.DomeAz * (1.0 - alpha);


            result.TargetReferenceFrame = to.TargetReferenceFrame;
            if (to.Target == from.Target)
            {
                result.Target = to.Target;
            }
            else
            {
                result.Target = SolarSystemObjects.Custom;
            }
            return(result);
        }
Esempio n. 3
0
        private TimeSpan CalculateRunTime()
        {
            double totalTime = 0.0;

            for (int i = 0; i < tourStops.Count; i++)
            {
                totalTime += (double)(tourStops[i].Duration.TotalMilliseconds / 1000);
                if (i > 0)
                {
                    switch (tourStops[i].Transition)
                    {
                    case TransitionType.Slew:
                        if (tourStops[i].Target.BackgroundImageSet == null || (tourStops[i - 1].Target.BackgroundImageSet.DataSetType == tourStops[i].Target.BackgroundImageSet.DataSetType &&
                                                                               ((tourStops[i - 1].Target.BackgroundImageSet.DataSetType != ImageSetType.SolarSystem) || (tourStops[i - 1].Target.Target == tourStops[i].Target.Target))))
                        {
                            CameraParameters start = tourStops[i - 1].EndTarget == null ? tourStops[i - 1].Target.CamParams : tourStops[i - 1].EndTarget.CamParams;
                            ViewMoverSlew    slew  = new ViewMoverSlew(start, tourStops[i].Target.CamParams);
                            totalTime += slew.MoveTime;
                        }
                        break;

                    case TransitionType.CrossCut:
                        break;

                    case TransitionType.CrossFade:
                        break;

                    case TransitionType.FadeOut:
                        break;

                    default:
                        break;
                    }
                }
            }
            return(TimeSpan.FromSeconds(totalTime));
        }
Esempio n. 4
0
        void IScriptable.InvokeAction(string name, string value)
        {
            MethodInvoker updatePlace = delegate
            {
                if (string.IsNullOrEmpty(name))
                {
                    return;
                }
                try
                {
                    NavigationActions action = (NavigationActions)Enum.Parse(typeof(NavigationActions), name, true);

                    switch (action)
                    {
                        case NavigationActions.ResetRiftView:
                            if (rift)
                            {
                                ResetRift();
                            }
                            break;
                        case NavigationActions.AllStop:
                            TouchAllStop();
                            break;
                        case NavigationActions.MoveUp:
                            if (!string.IsNullOrEmpty(value))
                            {
                                MoveView(0, double.Parse(value) * 10, false);
                            }
                            else
                            {
                                MoveUp();
                            }
                            break;
                        case NavigationActions.MoveDown:
                            if (!string.IsNullOrEmpty(value))
                            {
                                MoveView(0, -double.Parse(value) * 10, false);
                            }
                            else
                            {
                                MoveDown();
                            }

                            break;
                        case NavigationActions.MoveRight:
                            if (!string.IsNullOrEmpty(value))
                            {
                                MoveView(double.Parse(value) * 10, 0, false);
                            }
                            else
                            {
                                MoveRight();
                            }
                            break;
                        case NavigationActions.MoveLeft:
                            if (!string.IsNullOrEmpty(value))
                            {
                                MoveView(-double.Parse(value) * 10, 0, false);
                            }
                            else
                            {
                                MoveLeft();
                            }
                            break;
                        case NavigationActions.ZoomIn:
                            if (!string.IsNullOrEmpty(value))
                            {
                                ZoomIn(double.Parse(value));
                            }
                            else
                            {
                                ZoomIn();
                            }
                            break;
                        case NavigationActions.ZoomOut:
                            if (!string.IsNullOrEmpty(value))
                            {
                                ZoomOut(double.Parse(value));
                             }
                            else
                            {
                                ZoomOut();
                            }
                            break;
                        case NavigationActions.RotateLeft:
                            if (!string.IsNullOrEmpty(value))
                            {
                                RotateLeft(double.Parse(value));
                            }
                            else
                            {
                                RotateLeft(1);
                            }
                            break;
                        case NavigationActions.RotateRight:
                            if (!string.IsNullOrEmpty(value))
                            {
                                RotateRight(double.Parse(value));
                            }
                            else
                            {
                                RotateRight(1);
                            }
                            break;
                        case NavigationActions.DomeLeft:
                            if (!string.IsNullOrEmpty(value))
                            {
                                DomeLeft(double.Parse(value));
                            }
                            else
                            {
                                DomeLeft(1);
                            }
                            break;

                        case NavigationActions.DomeRight:
                            if (!string.IsNullOrEmpty(value))
                            {
                                DomeRight(double.Parse(value));
                            }
                            else
                            {
                                DomeRight(1);
                            }
                            break;

                        case NavigationActions.DomeUp:
                            if (!string.IsNullOrEmpty(value))
                            {
                                DomeUp(double.Parse(value));
                            }
                            else
                            {
                                DomeUp(1);
                            }
                            break;

                        case NavigationActions.DomeDown:
                            if (!string.IsNullOrEmpty(value))
                            {
                                DomeUp(double.Parse(value));
                            }
                            else
                            {
                                DomeUp(1);
                            }
                            break;


                        case NavigationActions.TiltUp:
                            if (!string.IsNullOrEmpty(value))
                            {
                                TiltUp(double.Parse(value));
                            }
                            else
                            {
                                TiltUp(1);
                            }
                            break;
                        case NavigationActions.TiltDown:
                            if (!string.IsNullOrEmpty(value))
                            {
                                TiltDown(double.Parse(value));
                            }
                            else
                            {
                                TiltDown(1);
                            }
                            break;
                        case NavigationActions.ResetCamera:
                            ResetCamera();
                            break;
                        case NavigationActions.NextItem:
                            explorePane.MoveNext();
                            break;
                        case NavigationActions.LastItem:
                            explorePane.MovePrevious();
                            break;
                        case NavigationActions.Select:
                            explorePane.SelectItem();
                            break;
                        case NavigationActions.Back:
                            explorePane.Back();
                            break;
                        case NavigationActions.ShowNextContext:
                            contextPanel.ShowNextObject();
                            break;
                        case NavigationActions.ShowPreviousContext:
                            contextPanel.ShowPreviousObject();
                            break;
                        case NavigationActions.ShowNextExplore:
                            explorePane.MoveNext();
                            explorePane.ShowCurrent();
                            break;
                        case NavigationActions.ShowPreviousExplore:
                            explorePane.MovePrevious();
                            explorePane.ShowCurrent();
                            break;
                        case NavigationActions.SetForeground:
                            explorePane.SelectForeground();
                            break;
                        case NavigationActions.SetBackground:
                            explorePane.SelectBackground();
                            break;
                        case NavigationActions.PreviousMode:
                            PreviousMode();
                            break;
                        case NavigationActions.NextMode:
                            NextMode();
                            break;
                        case NavigationActions.SolarSystemMode:
                            {
                                ImageSetType lookAt = ImageSetType.SolarSystem;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.SkyMode:
                            {
                                ImageSetType lookAt = ImageSetType.Sky;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.EarthMode:
                            {
                                ImageSetType lookAt = ImageSetType.Earth;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.PlanetMode:
                            {
                                ImageSetType lookAt = ImageSetType.Planet;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.PanoramaMode:
                            {
                                ImageSetType lookAt = ImageSetType.Panorama;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.SandboxMode:
                            {
                                ImageSetType lookAt = ImageSetType.Sandbox;
                                contextPanel.SetLookAtTarget(lookAt);
                            }
                            break;
                        case NavigationActions.PlayTour:
                            {
                                if (tourEdit != null)
                                {
                                    tourEdit.PlayNow(false);
                                }
                            }
                            break;
                        case NavigationActions.PauseTour:
                            {
                                if (tourEdit != null)
                                {
                                    tourEdit.PauseTour();
                                }
                            }
                            break;
                        case NavigationActions.StopTour:
                            {
                                if (tourEdit != null)
                                {
                                    tourEdit.PauseTour();
                                    CloseTour(false);
                                }
                            }
                            break;
                        case NavigationActions.NextSlide:
                            {
                                if (TourPlayer.Playing)
                                {
                                    TourPlayer player = uiController as TourPlayer;
                                    if (player != null)
                                    {
                                        player.MoveNextSlide();
                                    }

                                }
                            }
                            break;
                        case NavigationActions.GotoSlide:
                            if (!string.IsNullOrEmpty(value))
                            {
                                int slideID = -1;
                                int.TryParse(value, out slideID);

                                if (TourPlayer.Playing && slideID > -1)
                                {
                                    TourPlayer player = uiController as TourPlayer;
                                    if (player != null)
                                    {
                                        player.MoveToSlide(slideID);
                                    }

                                }
                            }
                            break;
                        case NavigationActions.PreviousSlide:
                            {
                                if (TourPlayer.Playing)
                                {
                                    TourPlayer player = uiController as TourPlayer;
                                    if (player != null)
                                    {
                                        player.MovePreviousSlide();
                                    }

                                }
                            }
                            break;
                        case NavigationActions.MoveToEndSlide:
                            {
                                if (TourPlayer.Playing)
                                {
                                    TourPlayer player = uiController as TourPlayer;
                                    if (player != null)
                                    {
                                        player.MoveToEndSlide();
                                    }

                                }
                            }
                            break;
                        case NavigationActions.MoveToFirstSlide:
                            {
                                if (TourPlayer.Playing)
                                {
                                    TourPlayer player = uiController as TourPlayer;
                                    if (player != null)
                                    {
                                        player.MoveToEndSlide();
                                    }

                                }
                            }
                            break;
                        case NavigationActions.GotoSun:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Sun");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoMercury:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Mercury");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoVenus:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Venus");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoEarth:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Earth");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoMars:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Mars");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoJupiter:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Jupiter");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoSaturn:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Saturn");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoUranus:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Uranus");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoNeptune:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Neptune");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.GotoPluto:
                            {
                                IPlace place = Search.FindCatalogObjectExact("Pluto");
                                GotoTarget(place, false, false, true);

                            }
                            break;
                        case NavigationActions.SolarSystemOverview:
                            {
                                CameraParameters cameraParams = new CameraParameters(45, 45, 300, 0, 0, 100);

                                Earth3d.MainWindow.GotoTarget(cameraParams, false, false);

                            }
                            break;
                        case NavigationActions.GotoMilkyWay:
                            {
                                CameraParameters cameraParams = new CameraParameters(45, 45, 10000000000, 0, 0, 100);

                                Earth3d.MainWindow.GotoTarget(cameraParams, false, false);

                            }
                            break;
                        case NavigationActions.GotoSDSSGalaxies:
                            {
                                CameraParameters cameraParams = new CameraParameters(45, 45, 300000000000000, 0, 0, 100);

                                Earth3d.MainWindow.GotoTarget(cameraParams, false, false);

                            }
                            break;

                        default:
                            break;

                    }
                }
                catch
                {
                }
            };
            try
            {
                Invoke(updatePlace);
            }
            catch
            {
            }
        }
        public override void ProcessRequest(string request, ref Socket socket, bool authenticated, string body)
        {
            QueryString query = new QueryString(request);

            String sMimeType = "text/xml";
            string data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
            if (!authenticated)
            {
                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - IP Not Authorized by Client</Status></LayerApi>";
                SendHeaderAndData(data, ref socket, sMimeType);
                return;
            }

            string cmd = query["cmd"].ToLower();

            Guid layerID = Guid.Empty;

            if (!string.IsNullOrEmpty(query["id"]))
            {
                layerID = new Guid(query["id"]);
            }

            int color = Color.White.ToArgb();
            if (!string.IsNullOrEmpty(query["color"]))
            {
                color = int.Parse(query["color"],System.Globalization.NumberStyles.HexNumber);
            }

            int currentVersion = 0;
            if (!string.IsNullOrEmpty(query["version"]))
            {
                currentVersion = int.Parse(query["version"]);
            }

            string notifyType = "None";
            if (!string.IsNullOrEmpty(query["notifytype"]))
            {
                notifyType = query["notifytype"];
            }

            int notifyTimeout = 30000;
            if (!string.IsNullOrEmpty(query["notifytimeout"]))
            {
                notifyTimeout = Math.Min(120000,int.Parse(query["notifytimeout"]));
            }

            int notifyRate = 100;
            if (!string.IsNullOrEmpty(query["notifyrate"]))
            {
                notifyRate = Math.Min(10000,int.Parse(query["notifyrate"]));
            }

            DateTime dateTime = DateTime.Now;
            if (!string.IsNullOrEmpty(query["datetime"]))
            {
                dateTime = Convert.ToDateTime(query["datetime"]);
                SpaceTimeController.Now = dateTime;
            }

            DateTime beginDate = DateTime.MinValue;
            if (!string.IsNullOrEmpty(query["startdate"]))
            {
                beginDate = Convert.ToDateTime(query["startdate"]);
            }

            DateTime endDate = DateTime.MaxValue;
            if (!string.IsNullOrEmpty(query["enddate"]))
            {
                endDate = Convert.ToDateTime(query["enddate"]);
            }

            double timeRate = 1.0;
            if (!string.IsNullOrEmpty(query["timerate"]))
            {
                timeRate = Convert.ToDouble(query["timerate"]);
                SpaceTimeController.TimeRate = timeRate;
            }

            string name = "New Layer";
            if (!string.IsNullOrEmpty(query["name"]))
            {
                name = query["name"];
            }

            string propName = "";
            if (!string.IsNullOrEmpty(query["propname"]))
            {
                propName = query["propname"];
            }

            string propValue = "";
            if (!string.IsNullOrEmpty(query["propvalue"]))
            {
                propValue = query["propvalue"];
            }

            string filename = "";
            if (!string.IsNullOrEmpty(query["filename"]))
            {
                filename = query["filename"];
            }

            string referenceFrame = "";
            if (!string.IsNullOrEmpty(query["frame"]))
            {
                referenceFrame = query["frame"];
            }

            string parent = "";
            if (!string.IsNullOrEmpty(query["parent"]))
            {
                parent = query["parent"];
            }

            string move = "";
            if (!string.IsNullOrEmpty(query["move"]))
            {
                move = query["move"];
            }
            FadeType fadeType = FadeType.None;
            if (!string.IsNullOrEmpty(query["fadetype"]))
            {
                fadeType = (FadeType)Enum.Parse(typeof(FadeType), query["fadetype"]);
            }

            double fadeRange = 0.0;
            if (!string.IsNullOrEmpty(query["faderange"]))
            {
                fadeRange = Convert.ToDouble(query["faderange"]);
            }

            bool showLayer = true;
            if (!string.IsNullOrEmpty(query["show"]))
            {
                showLayer = Convert.ToBoolean(query["show"]);
            }

            string flyTo = null;
            if (!string.IsNullOrEmpty(query["flyto"]))
            {
                flyTo = query["flyto"];
            }

            string lookat = null;
            if (!string.IsNullOrEmpty(query["lookat"]))
            {
                lookat = query["lookat"];
            }

            bool instant = false;
            if (!string.IsNullOrEmpty(query["instant"]))
            {
                instant = Convert.ToBoolean(query["instant"]);
            }

            bool noPurge = false;
            if (!string.IsNullOrEmpty(query["nopurge"]))
            {
                noPurge = Convert.ToBoolean(query["nopurge"]);
            }

            bool fromClipboard = false;
            if (!string.IsNullOrEmpty(query["fromclipboard"]))
            {
                fromClipboard = Convert.ToBoolean(query["fromclipboard"]);
            }

            bool purgeAll = false;
            if (!string.IsNullOrEmpty(query["purgeall"]))
            {
                purgeAll = Convert.ToBoolean(query["purgeall"]);
            }

            if (!string.IsNullOrEmpty(query["autoloop"]))
            {
                LayerManager.SetAutoloop(Convert.ToBoolean(query["autoloop"]));
            }

            bool layersOnly = false;
            if (!string.IsNullOrEmpty(query["layersonly"]))
            {
                layersOnly = Convert.ToBoolean(query["layersonly"]);
            }

            bool hasheader = false;
            if (!string.IsNullOrEmpty(query["hasheader"]))
            {
                hasheader = Convert.ToBoolean(query["hasheader"]);
            }

            string coordinates = "";
            if (!string.IsNullOrEmpty(query["coordinates"]))
            {
                coordinates = query["coordinates"];
            }

            string cmdtarget = "";
            if (!string.IsNullOrEmpty(query["cmdtarget"]))
            {
                cmdtarget = query["cmdtarget"];
            }

            string cmdtype = "";
            if (!string.IsNullOrEmpty(query["cmdtype"]))
            {
                cmdtype = query["cmdtype"];
            }
            // Update the time and rate
            if (layerID != Guid.Empty || !string.IsNullOrEmpty(referenceFrame) || cmd == "getprojectorconfig" || cmd == "setprojectorconfig" || cmd == "loadtour" || cmd == "layerlist" || cmd == "move" || cmd == "version" || cmd == "uisettings" || cmd == "new" || cmd == "load" || cmd == "group" || cmd == "state" || cmd == "mode" || cmd == "showlayermanager" || cmd == "hidelayermanager" || cmd == "getelevation" || cmd == "notify" || cmd == "dispatch")
            {
                switch (cmd)
                {
                    case "dispatch":
                        {
                            if (DispatchCommand(cmdtarget, cmdtype, propName, propValue))
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }
                        break;
                    case "notify":
                        switch (notifyType.ToLower())
                        {
                            case "none":
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid Notify Type</Status></LayerApi>";
                                break;
                            case "layer":
                                if (layerID == Guid.Empty)
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                                }
                                else
                                {
                                    DateTime start = DateTime.Now;
                                    //default text
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Timeout</Status></LayerApi>";
                                    while ((DateTime.Now - start).TotalMilliseconds < notifyTimeout)
                                    {
                                        Thread.Sleep(notifyRate);
                                        if (!LayerManager.LayerList.ContainsKey(layerID))
                                        {
                                            data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                                            break;
                                        }

                                        Layer target = LayerManager.LayerList[layerID];
                                        if (target == null)
                                        {
                                            data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                                            break;
                                        }

                                        else
                                        {
                                            if (target.Version != currentVersion)
                                            {
                                                data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><Layer {0}=\"{1}\" Version=\"{2}\"></Layer></LayerApi>", "ID", target.ID, target.Version);
                                                break;
                                            }
                                        }
                                    }

                                }
                                break;
                            case "layerlist":
                                {
                                    DateTime start = DateTime.Now;
                                    //default text
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Timeout</Status></LayerApi>";
                                    while ((DateTime.Now - start).TotalMilliseconds < notifyTimeout)
                                    {
                                        Thread.Sleep(notifyRate);

                                        if (LayerManager.Version != currentVersion)
                                        {
                                            data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><LayerList Version=\"{0}\"></LayerList></LayerApi>",  LayerManager.Version);
                                            break;
                                        }
                                    }

                                }
                                break;
                        }

                        break;
                    case "version":
                        {
                            data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Version>{0}</Version></LayerApi>", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

                        }
                        break;
                    case "group":
                        {
                            if (LayerManager.CreateLayerGroup(name, referenceFrame))
                            {

                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }
                        break;
                    case "load":
                        {
                            Guid id = LayerManager.LoadLayer(name, referenceFrame, filename, color, beginDate, endDate, fadeType, fadeRange);
                            if (id != Guid.Empty)
                            {
                                data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><NewLayerID>{0}</NewLayerID></LayerApi>", id.ToString());
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Could not Load Layer</Status></LayerApi>";
                            }

                        }
                        break;
                    case "loadtour":
                        {
                            MethodInvoker doIt = delegate
                            {
                                Earth3d.MainWindow.NoShowTourEndPage = true;
                                Earth3d.MainWindow.LoadTourFromFile(filename, false, "");
                            };

                            if (Earth3d.MainWindow.InvokeRequired)
                            {
                                try
                                {
                                    Earth3d.MainWindow.Invoke(doIt);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                doIt();
                            }

                            if (File.Exists(filename))
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Could not Load Tour</Status></LayerApi>";
                            }

                        }
                        break;

                    case "newframe":
                        {
                            if (LayerManager.CreateReferenceFrame(referenceFrame, parent, body))
                            {
                                 data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid Parameter</Status></LayerApi>";
                            }
                        }
                        break;

                    case "new":
                        {
                            Guid id = LayerManager.CreateLayerFromString(body, name, referenceFrame, false, color, beginDate, endDate, fadeType, fadeRange);
                            data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><NewLayerID>{0}</NewLayerID></LayerApi>", id.ToString());
                        }
                        break;
                    case "get":
                        {
                            data = LayerManager.GetLayerDataID(layerID);
                            if (string.IsNullOrEmpty(data))
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }
                        break;
                    case "update":
                        {
                            if (name == "New Layer")
                            {
                                name = null;
                            }

                            if (LayerManager.UpdateLayer(layerID, body, showLayer, name, noPurge, purgeAll, hasheader))
                            {

                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }

                        break;
                    case "layerlist":
                        {
                            data = LayerManager.GetLayerList(layersOnly);
                            if (data == null)
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }
                        break;
                    case "activate":
                        {
                            if (LayerManager.ActivateLayer(layerID))
                            {

                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                            }
                        }
                        break;
                    case "setprop":
                        {
                            if (layerID != Guid.Empty)
                            {
                                if (LayerManager.SetLayerPropByID(layerID, propName, propValue))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                            }
                            else
                            {
                                if (LayerManager.SetFramePropByName(referenceFrame, propName, propValue))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                               }
                        }
                        break;
                    case "setprops":
                        {
                            if (layerID != Guid.Empty)
                            {
                                if (LayerManager.SetLayerPropsByID(layerID, body))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                            }
                            else
                            {
                                if (LayerManager.SetFramePropsByName(referenceFrame, body))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                            }
                        }
                        break;
                    case "setprojectorconfig":
                        {
                            //if (layerID != Guid.Empty)
                            //{
                            //    if (LayerManager.SetLayerPropsByID(layerID, body))
                            //    {

                            //        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            //    }
                            //    else
                            //    {
                            //        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                            //    }
                            //}
                            //else
                            //{
                            //    if (LayerManager.SetFramePropsByName(referenceFrame, body))
                            //    {

                            //        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            //    }
                            //    else
                            //    {
                            //        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                            //    }
                            //}
                        }
                        break;

                    case "getprojectorconfig":
                        {
                            data = ClientNodes.GetXML(NetControl.NodeList);
                        }
                        break;

                    case "getprop":
                        {
                            if (layerID != Guid.Empty)
                            {
                                Layer layer = null;
                                string val = LayerManager.GetLayerPropByID(layerID, propName, out layer);
                                if (!string.IsNullOrEmpty(val))
                                {

                                    data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><Layer {0}=\"{1}\" Version=\"{2}\"></Layer></LayerApi>", propName, val, layer.Version);
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                            }
                            else
                            {
                                ReferenceFrame frame = null;
                                string val = LayerManager.GetFramePropByName(referenceFrame, propName, out frame);
                                if (!string.IsNullOrEmpty(val))
                                {
                                    data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><Frame {0}=\"{1}\"></Frame></LayerApi>", propName, val);
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                }
                            }
                        }
                        break;
                    case "getprops":
                        {
                            if (layerID != Guid.Empty)
                            {
                                data = LayerManager.GetLayerPropsByID(layerID);
                                if (string.IsNullOrEmpty(data))
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                                }
                            }
                            else
                            {
                                data = LayerManager.GetFramePropsByName(referenceFrame);
                                if (string.IsNullOrEmpty(data))
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid Frame Name</Status></LayerApi>";
                                }
                            }

                        }
                        break;
                    case "delete":
                        {
                            if (layerID != Guid.Empty)
                            {
                                if (LayerManager.DeleteLayerByID(layerID, true, true))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid layer ID</Status></LayerApi>";
                                }
                            }
                            else
                            {
                                if (LayerManager.DeleteFrameByName(referenceFrame))
                                {

                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                                }
                                else
                                {
                                    data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid Frame Name</Status></LayerApi>";
                                }
                            }
                        }
                        break;
                    case "state":
                        {
                            CameraParameters cam = Earth3d.MainWindow.viewCamera;
                            if (Earth3d.MainWindow.Space)
                            {
                                data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><ViewState lookat=\"{7}\" ra=\"{0}\" dec=\"{1}\" zoom=\"{2}\" rotation=\"{4}\" time=\"{5}\" timerate=\"{6}\" ReferenceFrame=\"Sky\" ViewToken=\"SD8834DFA\" ZoomText=\"{8}\"></ViewState></LayerApi>",
                                    cam.RA, cam.Dec, cam.Zoom, cam.Angle, cam.Rotation, SpaceTimeController.Now.ToString(), SpaceTimeController.TimeRate.ToString(), Earth3d.MainWindow.CurrentImageSet.DataSetType.ToString(), Earth3d.MainWindow.contextPanel.ViewLabelText);
                            }
                            else
                            {
                                data = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><ViewState lookat=\"{7}\" lat=\"{0}\" lng=\"{1}\" zoom=\"{2}\" angle=\"{3}\" rotation=\"{4}\" time=\"{5}\" timerate=\"{6}\" ReferenceFrame=\"{8}\" ViewToken=\"{10}\" ZoomText=\"{9}\"></ViewState></LayerApi>",
                                    cam.Lat, cam.Lng, cam.Zoom, cam.Angle, cam.Rotation, SpaceTimeController.Now.ToString(), SpaceTimeController.TimeRate.ToString(), Earth3d.MainWindow.CurrentImageSet.DataSetType.ToString(), Earth3d.MainWindow.FocusReferenceFrame(), Earth3d.MainWindow.contextPanel.ViewLabelText, Earth3d.MainWindow.viewCamera.ToToken());
                            }
                        }
                        break;
                    case "mode":
                        {
                            ImageSetType lookAt = (ImageSetType)Enum.Parse(typeof(ImageSetType), lookat);
                            Earth3d.MainWindow.contextPanel.SetLookAtTarget(lookAt);

                            data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";

                        }
                        break;
                    case "uisettings":
                        {
                            if (String.IsNullOrEmpty(propName) || SetSetting(propName, propValue, false))
                            {

                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            }
                            else
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                            }
                        }
                        break;
                    case "showlayermanager":
                        {
                            MethodInvoker doIt = delegate
                            {
                                Earth3d.MainWindow.ShowLayersWindows = true;
                            };

                            if (Earth3d.MainWindow.InvokeRequired)
                            {
                                try
                                {
                                    Earth3d.MainWindow.Invoke(doIt);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                doIt();
                            }

                        }
                        break;
                    case "hidelayermanager":
                        {
                            MethodInvoker doIt = delegate
                              {
                                  Earth3d.MainWindow.ShowLayersWindows = false;
                              };

                            if (Earth3d.MainWindow.InvokeRequired)
                            {
                                try
                                {
                                    Earth3d.MainWindow.Invoke(doIt);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                doIt();
                            }

                        }

                        break;
                    case "move":
                        {
                            data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status></LayerApi>";
                            if (move.ToLower().StartsWith("reticle"))
                            {
                                string[] parts = move.Split(new char[] { ':' });
                                if (parts.Length > 1)
                                {
                                    int id = int.Parse(parts[1]);
                                    Coordinates result = Earth3d.MainWindow.GetCoordinatesForReticle(id);

                                    if (Earth3d.MainWindow.SolarSystemMode)
                                    {
                                        Earth3d.MainWindow.GotoReticlePoint(id);
                                    }
                                    else
                                    {
                                        CameraParameters cameraParams;
                                        double lat = result.Lat;
                                        double lng = result.Lng;
                                        double zoom = Convert.ToDouble(Earth3d.MainWindow.ZoomFactor);
                                        double rotation = Convert.ToDouble(Earth3d.MainWindow.CameraRotate);
                                        double angle = Convert.ToDouble(Earth3d.MainWindow.CameraAngle);
                                        cameraParams = new CameraParameters(lat, lng, zoom, rotation, angle, 100);
                                        if (Earth3d.MainWindow.Space)
                                        {
                                            cameraParams.RA = result.RA;
                                        }

                                        MethodInvoker doIt = delegate
                                        {
                                            Earth3d.MainWindow.GotoTarget(cameraParams, false, instant);
                                        };

                                        if (Earth3d.MainWindow.InvokeRequired)
                                        {
                                            try
                                            {
                                                Earth3d.MainWindow.Invoke(doIt);
                                            }
                                            catch
                                            {
                                            }
                                        }
                                        else
                                        {
                                            doIt();
                                        }
                                    }
                                }
                            }

                            else
                            {
                                switch (move)
                                {
                                    case "ZoomIn":
                                        Earth3d.MainWindow.ZoomIn();
                                        break;
                                    case "ZoomOut":
                                        Earth3d.MainWindow.ZoomOut();
                                        break;
                                    case "Up":
                                        Earth3d.MainWindow.MoveUp();
                                        break;
                                    case "Down":
                                        Earth3d.MainWindow.MoveDown();
                                        break;
                                    case "Left":
                                        Earth3d.MainWindow.MoveLeft();
                                        break;
                                    case "Right":
                                        Earth3d.MainWindow.MoveRight();
                                        break;
                                    case "Clockwise":
                                        Earth3d.MainWindow.RotateView(0, .2);
                                        break;
                                    case "CounterClockwise":
                                        Earth3d.MainWindow.RotateView(0, -.2);
                                        break;
                                    case "TiltUp":
                                        Earth3d.MainWindow.RotateView(-.2, 0);
                                        break;
                                    case "TiltDown":
                                        Earth3d.MainWindow.RotateView(.2, 0);
                                        break;
                                    case "Finder":
                                        break;
                                    case "Play":
                                        ((IScriptable)Earth3d.MainWindow).InvokeAction("PlayTour", "");
                                        break;
                                    case "Pause":
                                        ((IScriptable)Earth3d.MainWindow).InvokeAction("PauseTour", "");
                                        break;
                                    case "PreviousSlide":
                                        ((IScriptable)Earth3d.MainWindow).InvokeAction("PreviousSlide", "");
                                        break;
                                    case "NextSlide":
                                        ((IScriptable)Earth3d.MainWindow).InvokeAction("NextSlide", "");
                                        break;
                                    default:
                                        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                                        break;
                                }
                            }
                        }
                        break;
                    case "getelevation":
                        {
                            string[] parts = coordinates.Split(new char[] { ',' });
                            StringBuilder sb = new StringBuilder();
                            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Success</Status><Elevations>");
                            try
                            {
                                foreach (string part in parts)
                                {
                                    string[] latLng = part.Split(new char[] { ' ' });
                                    if (latLng.Length > 1)
                                    {

                                        double lat = double.Parse(latLng[0]);
                                        double lng = double.Parse(latLng[1]);
                                        double alt = Earth3d.MainWindow.GetAltitudeForLatLong(lat, lng) - EGM96Geoid.Height(lat, lng);
                                        sb.Append(string.Format("<Coordinates Lat=\"{0}\" Lng=\"{1}\" Altitude=\"{2}\" />", lat, lng, alt));

                                    }
                                }
                                sb.Append("</Elevations></LayerApi>");

                                data = sb.ToString();
                            }
                            catch
                            {
                                data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - Invalid parameter</Status></LayerApi>";
                            }
                        }
                        break;
                    default:
                        data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Status>Error - No Command</Status></LayerApi>";
                        break;
                }
            }

            if (!string.IsNullOrEmpty(flyTo))
            {
                string[] lines = flyTo.Split(new char[] { ',' });
                if (lines.Length == 1)
                {
                    MethodInvoker doIt = delegate
                    {
                        Earth3d.MainWindow.SetBackgroundByName(lines[0]);
                    };
                    if (Earth3d.MainWindow.InvokeRequired)
                    {
                        try
                        {
                            Earth3d.MainWindow.Invoke(doIt);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        doIt();
                    }
                }

                if (lines.Length == 5 )
                {
                    CameraParameters cameraParams;
                    double lat = Convert.ToDouble(lines[0]);
                    double lng = Convert.ToDouble(lines[1]);
                    double zoom = Convert.ToDouble(lines[2]);
                    double rotation = Convert.ToDouble(lines[3]);
                    double angle = Convert.ToDouble(lines[4]);
                    cameraParams = new CameraParameters(lat, lng, zoom, rotation, angle, 100);
                    if (Earth3d.MainWindow.Space)
                    {
                        cameraParams.RA = Convert.ToDouble(lines[1]);
                    }

                    MethodInvoker doIt = delegate
                    {
                        Earth3d.MainWindow.GotoTarget(cameraParams, false, instant);
                    };

                    if (Earth3d.MainWindow.InvokeRequired)
                    {
                        try
                        {
                            Earth3d.MainWindow.Invoke(doIt);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        doIt();
                    }
                }

                if (lines.Length > 5)
                {
                    CameraParameters cameraParams;
                    double lat = Convert.ToDouble(lines[0]);
                    double lng = Convert.ToDouble(lines[1]);
                    double zoom = Convert.ToDouble(lines[2]);
                    double rotation = Convert.ToDouble(lines[3]);
                    double angle = Convert.ToDouble(lines[4]);
                    string frame = lines[5];
                    string token = "";
                    cameraParams = new CameraParameters(lat, lng, zoom, rotation, angle, 100);
                    bool done = false;
                    if (frame == "Sky")
                    {
                        cameraParams.RA = Convert.ToDouble(lines[1]);
                    }
                    else
                    {
                        if (Earth3d.MainWindow.CurrentImageSet.DataSetType == ImageSetType.Planet)
                        {
                            if (!Earth3d.MainWindow.CurrentImageSet.Name.ToLower().Contains(frame.ToLower()))
                            {
                                MethodInvoker doIt3 = delegate
                                {
                                    Earth3d.MainWindow.SetBackgroundByName(frame);
                                };
                                if (Earth3d.MainWindow.InvokeRequired)
                                {
                                    try
                                    {
                                        Earth3d.MainWindow.Invoke(doIt3);
                                    }
                                    catch
                                    {
                                    }
                                }
                                else
                                {
                                    doIt3();
                                }
                            }
                            MethodInvoker doIt2 = delegate
                            {
                                Earth3d.MainWindow.GotoTarget(cameraParams, false, instant);
                            };

                            if (Earth3d.MainWindow.InvokeRequired)
                            {
                                try
                                {
                                    Earth3d.MainWindow.Invoke(doIt2);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                doIt2();
                            }
                            done = true;

                        }
                        else
                        {
                            try
                            {
                                cameraParams.Target = (SolarSystemObjects)Enum.Parse(typeof(SolarSystemObjects), frame, true);
                            }
                            catch
                            {
                                cameraParams.Target = SolarSystemObjects.Custom;
                                //cameraParams.ViewTarget =  */Stuff here */
                                //todo get custom location and insert
                            }
                        }
                    }
                    if (!done)
                    {
                        TourPlace pl = new TourPlace(frame, 0, 0, Classification.SolarSystem, "UMA", Earth3d.MainWindow.CurrentImageSet.DataSetType == ImageSetType.SolarSystem ? ImageSetType.Sky : Earth3d.MainWindow.CurrentImageSet.DataSetType, zoom);
                        if (lines.Length > 6)
                        {
                            token = lines[6];
                            if (!string.IsNullOrEmpty(token))
                            {
                                cameraParams = CameraParameters.FromToken(token);
                            }
                        }
                        pl.CamParams = cameraParams;

                        MethodInvoker doIt = delegate
                        {
                            Earth3d.MainWindow.GotoTarget(pl, false, false, true);
                        };

                        if (Earth3d.MainWindow.InvokeRequired)
                        {
                            try
                            {
                                Earth3d.MainWindow.Invoke(doIt);
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            doIt();
                        }
                    }
                }
            }

            SendHeaderAndData(data, ref socket, sMimeType);
        }
Esempio n. 6
0
        public void Render(Earth3d window)
        {
            window.SetupMatricesOverlays();
            window.RenderContext11.DepthStencilMode = DepthStencilMode.Off;


            if (tour == null || tour.CurrentTourStop == null)
            {
                return;
            }

            if (ProjectorServer)
            {
                overlayBlend.State = true;
            }

            if (!onTarget && !ProjectorServer)
            {
                slideStartTime = SpaceTimeController.MetaNow;
                if (Earth3d.MainWindow.OnTarget(Tour.CurrentTourStop.Target))
                {
                    onTarget                 = true;
                    overlayBlend.State       = !Tour.CurrentTourStop.FadeInOverlays;
                    overlayBlend.TargetState = true;

                    if (!PreRoll)
                    {
                        if (tour.CurrentTourStop.MusicTrack != null)
                        {
                            tour.CurrentTourStop.MusicTrack.Play();
                        }

                        if (tour.CurrentTourStop.VoiceTrack != null)
                        {
                            tour.CurrentTourStop.VoiceTrack.Play();
                        }

                        foreach (Overlay overlay in tour.CurrentTourStop.Overlays)
                        {
                            overlay.Play();
                        }
                    }

                    LayerManager.SetVisibleLayerList(tour.CurrentTourStop.Layers);


                    if (tour.CurrentTourStop.KeyFramed)
                    {
                        tour.CurrentTourStop.KeyFrameMover.CurrentDateTime = tour.CurrentTourStop.StartTime;
                        tour.CurrentTourStop.KeyFrameMover.CurrentPosition = tour.CurrentTourStop.Target.CamParams;
                        tour.CurrentTourStop.KeyFrameMover.MoveTime        = (double)(tour.CurrentTourStop.Duration.TotalMilliseconds / 1000.0);
                        Earth3d.MainWindow.Mover = tour.CurrentTourStop.KeyFrameMover;
                    }
                    else if (tour.CurrentTourStop.EndTarget != null && tour.CurrentTourStop.EndTarget.ZoomLevel != -1)
                    {
                        if (tour.CurrentTourStop.Target.Type == ImageSetType.SolarSystem)
                        {
                            tour.CurrentTourStop.Target.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.StartTime));
                            tour.CurrentTourStop.EndTarget.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.EndTime));
                        }


                        Earth3d.MainWindow.Mover = new ViewMoverKenBurnsStyle(tour.CurrentTourStop.Target.CamParams, tour.CurrentTourStop.EndTarget.CamParams, tour.CurrentTourStop.Duration.TotalMilliseconds / 1000.0, tour.CurrentTourStop.StartTime, tour.CurrentTourStop.EndTime, tour.CurrentTourStop.InterpolationType);
                    }

                    Settings.TourSettings           = tour.CurrentTourStop;
                    SpaceTimeController.Now         = tour.CurrentTourStop.StartTime;
                    SpaceTimeController.SyncToClock = false;
                }
            }

            if (currentMasterSlide != null)
            {
                foreach (Overlay overlay in currentMasterSlide.Overlays)
                {
                    overlay.TweenFactor = 1f;

                    overlay.Draw3D(window.RenderContext11, 1.0f, false);
                }
            }



            if (onTarget || ProjectorServer)
            {
                foreach (Overlay overlay in tour.CurrentTourStop.Overlays)
                {
                    if (!Tour.CurrentTourStop.KeyFramed || (overlay.Animate && overlay.AnimationTarget == null))
                    {
                        overlay.TweenFactor = (float)CameraParameters.EaseCurve(tour.CurrentTourStop.TweenPosition, overlay.InterpolationType == InterpolationType.Default ? tour.CurrentTourStop.InterpolationType : overlay.InterpolationType);
                    }
                    overlay.Draw3D(window.RenderContext11, overlayBlend.Opacity, false);
                }
            }
        }
 public ViewMoverSlew(CameraParameters from, CameraParameters to, double upDowFactor)
 {
     upTimeFactor = downTimeFactor = upDowFactor;
     Init(from, to);
 }
        public ViewMoverKenBurnsStyle(CameraParameters from, CameraParameters to, double time, DateTime fromDateTime, DateTime toDateTime, InterpolationType type)
        {
            InterpolationType = type;
            if (Math.Abs(from.Lng - to.Lng) > 180)
            {
                if (from.Lng > to.Lng)
                {
                    from.Lng -= 360;
                }
                else
                {
                    from.Lng += 360;
                }
            }

            this.fromDateTime = fromDateTime;
            this.toDateTime = toDateTime;

            dateTimeSpan = toDateTime - fromDateTime;

            this.from = from;
            this.to = to;
            fromTime = SpaceTimeController.MetaNowTickCount;
            toTargetTime = time;
        }
        public static CameraParameters InterpolateGreatCircle(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type)
        {
            CameraParameters result = new CameraParameters();
            double alpha = EaseCurve(alphaIn, type);
            double alphaBIn = Math.Min(1.0, alphaIn * 2);
            double alphaB = EaseCurve(alphaBIn, type);
            result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha);
            result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha);

            Vector3d left = Coordinates.GeoTo3dDouble(from.Lat, from.Lng);
            Vector3d right = Coordinates.GeoTo3dDouble(to.Lat, to.Lng);

            Vector3d mid = Vector3d.Slerp(left, right, alpha);

            Vector2d midV2 = Coordinates.CartesianToLatLng(mid);

            result.Lat = midV2.Y;
            result.Lng = midV2.X;

            result.Zoom = Math.Pow(2, Math.Log(to.Zoom, 2) * alpha + Math.Log(from.Zoom, 2) * (1.0 - alpha));
            result.Opacity = (float)(to.Opacity * alpha + from.Opacity * (1.0 - alpha));
            result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha);

            result.DomeAlt = to.DomeAlt * alpha + from.DomeAlt * (1.0 - alpha);
            result.DomeAz = to.DomeAz * alpha + from.DomeAz * (1.0 - alpha);

            result.TargetReferenceFrame = to.TargetReferenceFrame;
            if (to.Target == from.Target)
            {
                result.Target = to.Target;
            }
            else
            {
                result.Target = SolarSystemObjects.Custom;
            }
            return result;
        }
        public static CameraParameters FromToken(string token)
        {
            CameraParameters cam = new CameraParameters();

            token = token.Replace("G", "00000000");
            token = token.Replace("H", "0000000");
            token = token.Replace("I","000000" );
            token = token.Replace("J", "00000");
            token = token.Replace("K", "0000");
            token = token.Replace("L", "000");
            token = token.Replace("M", "00");

            try
            {
                byte[] data = new byte[token.Length / 2];
                for (int i = 0; i < token.Length; i += 2)
                {
                    data[i/2] = byte.Parse(token.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
                }
                MemoryStream ms = new MemoryStream(data);
                BinaryReader br = new BinaryReader(ms);
                cam.Lat = br.ReadDouble();
                cam.Lng = br.ReadDouble();
                cam.Zoom = br.ReadDouble();
                cam.Rotation = br.ReadDouble();
                cam.Angle = br.ReadDouble();
                cam.RaDec = br.ReadBoolean();
                cam.Opacity = br.ReadSingle();
                cam.ViewTarget.X = br.ReadDouble();
                cam.ViewTarget.Y = br.ReadDouble();
                cam.ViewTarget.Z = br.ReadDouble();
                cam.Target = (SolarSystemObjects)br.ReadInt32();
                try
                {
                    cam.DomeAlt = br.ReadSingle();
                    cam.DomeAz = br.ReadSingle();
                }
                catch
                {
                }
                br.Close();

            }
            catch
            {
            }
            return cam;
        }
Esempio n. 11
0
        public void GotoTarget(IPlace place, bool noZoom, bool instant, bool trackObject)
        {
            if (place == null)
            {
                return;
            }
            if ((trackObject && SolarSystemMode) )
            {
                if ((place.Classification == Classification.SolarSystem && place.Type != ImageSetType.SolarSystem) || (place.Classification == Classification.Star) || (place.Classification == Classification.Galaxy) && place.Distance > 0)
                {
                    SolarSystemObjects target = SolarSystemObjects.Undefined;

                    if (place.Classification == Classification.Star || place.Classification == Classification.Galaxy)
                    {
                        target = SolarSystemObjects.Custom;
                    }
                    else
                    {
                        try
                        {
                            if (place.Target != SolarSystemObjects.Undefined)
                            {
                                target = place.Target;
                            }
                            else
                            {
                                target = (SolarSystemObjects)Enum.Parse(typeof(SolarSystemObjects), place.Name, true);
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (target != SolarSystemObjects.Undefined)
                    {
                        trackingObject = place;
                        double jumpTime = 4;

                        if (target == SolarSystemObjects.Custom)
                        {
                            jumpTime = 17;
                        }
                        else
                        {
                            jumpTime += 13 * (101 - Settings.Active.SolarSystemScale) / 100;
                        }

                        if (instant)
                        {
                            jumpTime = 1;
                        }

                        CameraParameters camTo = viewCamera;
                        camTo.TargetReferenceFrame = "";
                        camTo.Target = target;
                        double zoom = 10;
                        if (target == SolarSystemObjects.Custom)
                        {
                            if (place.Classification == Classification.Galaxy)
                            {
                                zoom = 1404946007758;
                            }
                            else
                            {
                                zoom = 63239.6717 * 100;
                            }
                            // Star or something outside of SS
                            Vector3d vect = Coordinates.RADecTo3d(place.RA, place.Dec, place.Distance);
                            double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;

                            vect.RotateX(ecliptic);
                            camTo.ViewTarget = -vect;
                        }
                        else
                        {
                            camTo.ViewTarget = Planets.GetPlanet3dLocation(target, SpaceTimeController.GetJNowForFutureTime(jumpTime));
                            switch (target)
                            {
                                case SolarSystemObjects.Sun:
                                    zoom = .6;
                                    break;
                                case SolarSystemObjects.Mercury:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Venus:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Mars:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Jupiter:
                                    zoom = .007;
                                    break;
                                case SolarSystemObjects.Saturn:
                                    zoom = .007;
                                    break;
                                case SolarSystemObjects.Uranus:
                                    zoom = .004;
                                    break;
                                case SolarSystemObjects.Neptune:
                                    zoom = .004;
                                    break;
                                case SolarSystemObjects.Pluto:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Moon:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Io:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Europa:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Ganymede:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Callisto:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Earth:
                                    zoom = .0004;
                                    break;
                                case SolarSystemObjects.Custom:
                                    zoom = 10;
                                    break;

                                default:
                                    break;
                            }

                            zoom = zoom * Settings.Active.SolarSystemScale;

                        }

                        CameraParameters fromParams = viewCamera;
                        if (SolarSystemTrack == SolarSystemObjects.Custom && !string.IsNullOrEmpty(TrackingFrame))
                        {
                            fromParams = CustomTrackingParams;
                            TrackingFrame = "";
                        }
                        camTo.Zoom = zoom;
                        Vector3d toVector = camTo.ViewTarget;
                        toVector.Subtract(fromParams.ViewTarget);

  
                        if (place.Classification == Classification.Star)
                        {
                            toVector = -toVector;
                        }

                        if (toVector.Length() != 0)
                        {

                            Vector2d raDec = toVector.ToRaDec();

                            if (target == SolarSystemObjects.Custom)
                            {
                                camTo.Lat = -raDec.Y;
                            }
                            else
                            {
                                camTo.Lat = raDec.Y;
                            }
                            camTo.Lng = raDec.X * 15 - 90;
                        }
                        else
                        {
                            camTo.Lat = viewCamera.Lat;
                            camTo.Lng = viewCamera.Lng;
                        }

                        if (target != SolarSystemObjects.Custom)
                        {
                            // replace with planet surface
                            camTo.ViewTarget = Planets.GetPlanetTargetPoint(target, camTo.Lat, camTo.Lng, SpaceTimeController.GetJNowForFutureTime(jumpTime));

                        }



                        ViewMoverKenBurnsStyle solarMover = new ViewMoverKenBurnsStyle(fromParams, camTo, jumpTime, SpaceTimeController.Now, SpaceTimeController.GetTimeForFutureTime(jumpTime), InterpolationType.EaseInOut);
                        solarMover.FastDirectionMove = true;
                        mover = solarMover;

                        return;
                    }
                }
            }


            Tracking = false;
            trackingObject = null;
            CameraParameters camParams = place.CamParams;



            if (place.Type != CurrentImageSet.DataSetType)
            {
                ZoomFactor = TargetZoom = ZoomMax;
                CameraRotateTarget = CameraRotate = 0;
                CameraAngleTarget = CameraAngle = 0;
                viewCamera = place.CamParams;
                if (place.BackgroundImageSet != null)
                {
                    FadeInImageSet(GetRealImagesetFromGeneric(place.BackgroundImageSet));
                }
                else
                {
                    CurrentImageSet = GetDefaultImageset(place.Type, BandPass.Visible);
                }
                instant = true;
            }
            else if (SolarSystemMode && place.Target != SolarSystemTrack)
            {
                ZoomFactor = TargetZoom = ZoomMax;
                CameraRotateTarget = CameraRotate = 0;
                CameraAngleTarget = CameraAngle = 0;
                viewCamera = targetViewCamera = place.CamParams;
                SolarSystemTrack = place.Target;
                instant = true;
            }


            if (place.Classification == Classification.Constellation)
            {
                camParams.Zoom = ZoomMax;
                GotoTarget(false, instant, camParams, null, null);
            }
            else
            {
                SolarSystemTrack = place.Target;
                GotoTarget(noZoom, instant, camParams, place.StudyImageset, place.BackgroundImageSet);
 
                if (trackObject)
                {
                    Tracking = true;
                    TrackingObject = place;
                }
            }

        }
Esempio n. 12
0
        private void MainWndow_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {


            if (uiController != null)
            {
                if (uiController.KeyDown(sender, e))
                {
                    return;
                }
            }
            if (Control.ModifierKeys == Keys.Alt)
            {
                switch (e.KeyCode)
                {
                    case Keys.OemMinus:
                    case Keys.PageUp:
                    case Keys.Subtract:
                        zoomSpeed = (ZoomSpeeds)Properties.Settings.Default.ZoomSpeed;
                        ZoomOut();
                        break;
                    case Keys.PageDown:
                    case Keys.Oemplus:
                    case Keys.Add:
                        zoomSpeed = (ZoomSpeeds)Properties.Settings.Default.ZoomSpeed;
                        ZoomIn();
                        break;
                    case Keys.F1:
                        LaunchHelp();
                        break;
                    case Keys.F5:
                        TileCache.ClearCache();
                        Tile.fastLoad = true;
                        Tile.iTileBuildCount = 0;
                        break;
                    case Keys.Left:
                        RotateView(0, -.05);
                        break;
                    case Keys.Right:
                        RotateView(0, .05);
                        break;
                    case Keys.Up:
                        RotateView(-.01, 0);
                        break;
                    case Keys.Down:
                        RotateView(.01, 0);
                        break;

                }
            }
            else if (Control.ModifierKeys == Keys.Control)
            {
                switch (e.KeyCode)
                {
                    case Keys.F9:
                        config = new Config();
                        break;
                    case Keys.A:
                        useAsymetricProj = !useAsymetricProj;
                        break;
                    case Keys.F5:
                        Tile.PurgeRefresh = true;
                        Render();
                        Tile.PurgeRefresh = false;
                        TileCache.ClearCache();
                        break;
                    case Keys.E:
                        if (uiController == null)
                        {
                            // We can't really tell where this image came from so dirty everything.
                            FolderBrowser.AllDirty = true;
                            uiController = new ImageAlignmentUI();
                            Earth3d.MainWindow.StudyOpacity = 50;

                        }
                        else
                        {
                            if (uiController != null && uiController is ImageAlignmentUI)
                            {
                                ((ImageAlignmentUI)uiController).Close();
                            }
                            uiController = null;
                        }
                        break;

                    case Keys.L:
                        Logging = !Logging;

                        break;
                    case Keys.T:
                        targetViewCamera = viewCamera = CustomTrackingParams;
                        break;
                }
            }
            else
            {
                switch (e.KeyCode)
                {
                    case Keys.Z:
                        riftFov *= .99f;
                        this.Text = riftFov.ToString();
                        break;
                    case Keys.X:
                        riftFov *= 1.01f;
                        this.Text = riftFov.ToString();
                        break;
                    case Keys.C:
                        iod *= .99f;
                        break;
                    case Keys.V:
                        iod *= 1.01f;
                        break;
                    case Keys.F:
                        SpaceTimeController.Faster();
                        break;
                    case Keys.S:
                        SpaceTimeController.Slower();
                        break;
                    case Keys.H:
                        // turn friction on and off
                        Friction = !Friction;
                        break;
                    case Keys.P:
                        SpaceTimeController.PauseTime();
                        break;
                    case Keys.N:
                        SpaceTimeController.SetRealtimeNow();
                        break;
                    case Keys.B:
                        blink = !blink;
                        break;
                    case Keys.L:
                        RenderContext11.SetLatency(3);
                        break;
                    case Keys.K:
                        RenderContext11.SetLatency(1);
                        break;
                    case Keys.F5:
                        TileCache.ClearCache();
                        Tile.iTileBuildCount = 0;
                        break;
                    case Keys.F11:
                        ShowFullScreen(!fullScreen);
                        break;
                    case Keys.OemMinus:
                    case Keys.PageUp:
                    case Keys.Subtract:
                        zoomSpeed = (ZoomSpeeds)Properties.Settings.Default.ZoomSpeed;
                        ZoomOut();
                        break;
                    case Keys.Oemplus:
                    case Keys.PageDown:
                    case Keys.Add:
                        zoomSpeed = (ZoomSpeeds)Properties.Settings.Default.ZoomSpeed;
                        ZoomIn();
                        break;
                    case Keys.F3:

                        break;
                    case Keys.F1:
                        LaunchHelp();
                        break;
                    case Keys.F2:
                        showWireFrame = !showWireFrame;
                        break;
                    case Keys.Left:
                        Control c = UiTools.GetFocusControl();
                        MoveLeft();
                        break;
                    case Keys.Right:
                        MoveRight();
                        break;
                    case Keys.Up:
                        MoveUp();
                        break;
                    case Keys.Down:
                        MoveDown();
                        break;
                    case Keys.Space:
                    case Keys.Play:
                        if (TourEdit != null)
                        {
                            TourEdit.PlayNow(false);
                        }
                        break;
                    case Keys.Escape:
                        if (fullScreen)
                        {
                            ShowFullScreen(false);
                        }
                        break;
                }
            }
        }
Esempio n. 13
0
        public void Init(CameraParameters from, CameraParameters to)
        {
            if (Math.Abs(from.Lng - to.Lng) > 180)
            {
                if (from.Lng > to.Lng)
                {
                    from.Lng -= 360;
                }
                else
                {
                    from.Lng += 360;
                }
            }

            if (to.Zoom <= 0)
            {
                to.Zoom = 360;
            }
            if (from.Zoom <= 0)
            {
                from.Zoom = 360;
            }
            this.from = from;
            this.to   = to;
            fromTime  = SpaceTimeController.MetaNowTickCount;
            double zoomUpTarget = 360.0;
            double travelTime;

            double lngDist  = Math.Abs(from.Lng - to.Lng);
            double latDist  = Math.Abs(from.Lat - to.Lat);
            double distance = Math.Sqrt(latDist * latDist + lngDist * lngDist);

            if (Earth3d.MainWindow.Space)
            {
                zoomUpTarget = (distance / 3) * 20;
            }
            else
            {
                zoomUpTarget = (distance / 3) * 3;
            }

            if (zoomUpTarget > 360.0)
            {
                zoomUpTarget = 360.0;
            }

            if (zoomUpTarget < from.Zoom)
            {
                zoomUpTarget = from.Zoom;
            }

            if (Earth3d.MainWindow.Space)
            {
                travelTime = (distance / 180.0) * (360 / zoomUpTarget) * travelTimeFactor;
            }
            else
            {
                travelTime = (distance / 180.0) * (75 / zoomUpTarget) * travelTimeFactor;
            }
            double rotateTime = Math.Max(Math.Abs(from.Angle - to.Angle), Math.Abs(from.Rotation - to.Rotation));


            double logDistUp = Math.Max(Math.Abs(Math.Log(zoomUpTarget, 2) - Math.Log(from.Zoom, 2)), rotateTime);

            upTargetTime   = upTimeFactor * logDistUp;
            downTargetTime = upTargetTime + travelTime;
            double logDistDown = Math.Abs(Math.Log(zoomUpTarget, 2) - Math.Log(to.Zoom, 2));

            toTargetTime = downTargetTime + Math.Max((downTimeFactor * logDistDown), rotateTime);

            fromTop          = from;
            fromTop.Zoom     = zoomUpTarget;
            fromTop.Angle    = (from.Angle + to.Angle) / 2.0; //todo make short wrap arounds..
            fromTop.Rotation = (from.Rotation + to.Rotation) / 2.0;
            fromTop.DomeAlt  = (from.DomeAlt + to.DomeAlt) / 2.0;
            fromTop.DomeAz   = (from.DomeAz + to.DomeAz) / 2.0;

            toTop          = to;
            toTop.Zoom     = fromTop.Zoom;
            toTop.Angle    = fromTop.Angle;
            toTop.Rotation = fromTop.Rotation;
            toTop.DomeAlt  = fromTop.DomeAlt;
            toTop.DomeAz   = fromTop.DomeAz;
        }
Esempio n. 14
0
 public ViewMoverSlew(CameraParameters from, CameraParameters to, double upDowFactor)
 {
     upTimeFactor = downTimeFactor = upDowFactor;
     Init(from, to);
 }
Esempio n. 15
0
 public ViewMoverSlew(CameraParameters from, CameraParameters to)
 {
     Init(from, to);
 }
Esempio n. 16
0
        public void UpdateXInputState()
        {

            if (Properties.Settings.Default.XboxCustomMapping)
            {
                ProcessCustomXboxMapping();
                return;
            }

            // lastFrameTime gives us fraction of seconds for update of motion factor for zooms
            double factor = lastFrameTime / (1.0 / 60.0);
            JoyInMotion = false;
            XInputState state;
            try
            {
                if (!XInputMethods.GetState(0, out state))
                {
                    return;
                }
            }
            catch
            {
                return;
            }
            double trigger = 0;

            if (state.Gamepad.RightTrigger > 0)
            {
                trigger = -state.Gamepad.RightTrigger;
            }
            else
            {
                trigger = +state.Gamepad.LeftTrigger;
            }

            if (Math.Abs(trigger) > 4)
            {
                ZoomFactor = TargetZoom = ZoomFactor * (1 + (trigger / 16000) * factor);

                if (ZoomFactor > ZoomMax)
                {
                    ZoomFactor = TargetZoom = ZoomMax;
                }

                if (ZoomFactor < ZoomMin)
                {
                    ZoomFactor = TargetZoom = ZoomMin;
                }
                JoyInMotion = true;
            }

            if (state.Gamepad.IsDPadRightButtonDown)
            {
                if (SpaceTimeController.TimeRate > .9)
                {
                    SpaceTimeController.TimeRate *= 1.1;
                }
                else if (SpaceTimeController.TimeRate < -1)
                {
                    SpaceTimeController.TimeRate /= 1.1;
                }
                else
                {
                    SpaceTimeController.TimeRate = 1.0;
                }

                if (SpaceTimeController.TimeRate > 1000000000)
                {
                    SpaceTimeController.TimeRate = 1000000000;
                }
                JoyInMotion = true;
            }

            if (state.Gamepad.IsDPadLeftButtonDown)
            {
                if (SpaceTimeController.TimeRate < -.9)
                {
                    SpaceTimeController.TimeRate *= 1.1;
                }
                else if (SpaceTimeController.TimeRate > 1)
                {
                    SpaceTimeController.TimeRate /= 1.1;
                }
                else
                {
                    SpaceTimeController.TimeRate = -1.0;
                }

                if (SpaceTimeController.TimeRate < -1000000000)
                {
                    SpaceTimeController.TimeRate = -1000000000;
                }
            }

            if ((state.Gamepad.Buttons & XInputButtons.LeftThumb) == XInputButtons.LeftThumb)
            {
                if (!leftThumbDown)
                {
                    leftThumbDown = true;
                    CameraParameters camParams = new CameraParameters(0, 0, 360, 0, 0, 100);
                    GotoTarget(camParams, false, false);

                }
            }
            else
            {
                leftThumbDown = false;
            }



            if ((state.Gamepad.Buttons & XInputButtons.RightThumb) == XInputButtons.RightThumb)
            {
                if (!rightThumbDown)
                {
                    rightThumbDown = true;
                    reticleControl = !reticleControl;

                    if (reticleControl)
                    {
                        Reticle.Show(retId, false);
                    }
                    else
                    {
                        Reticle.Hide(retId, false);
                    }

                    Properties.Settings.Default.ShowReticle.TargetState = reticleControl;
                }
            }
            else
            {
                rightThumbDown = false;
            }



            if (state.Gamepad.IsStartButtonDown)
            {
                if (!startDown)
                {
                    NextMode();
                    startDown = true;

                }
            }
            else
            {
                startDown = false;
            }

            if (state.Gamepad.IsBackButtonDown)
            {
                if (!backDown)
                {
                    PreviousMode();
                    backDown = true;

                }
            }
            else
            {
                backDown = false;
            }

            if (state.Gamepad.IsDPadUpButtonDown)
            {
                SpaceTimeController.TimeRate = 0;
            }

            if (state.Gamepad.IsDPadDownButtonDown)
            {
                SpaceTimeController.TimeRate = 1;
                SpaceTimeController.SyncTime();
                SpaceTimeController.SyncToClock = true;
            }

            double zoomRate = slowRates ? 16000 : 8000;
            double moveRate = slowRates ? 8000 : 2000;

            if (!reticleControl)
            {
                if (Math.Abs((double)state.Gamepad.RightThumbX) > 8000)
                {
                    CameraRotateTarget = (CameraRotateTarget + ((((double)state.Gamepad.RightThumbX / (zoomRate * 100)) * factor)));
                }

                if (Math.Abs((double)state.Gamepad.RightThumbY) > 8000)
                {
                    CameraAngleTarget = (CameraAngleTarget + ((((double)state.Gamepad.RightThumbY / (zoomRate * 100)) * factor)));
                }
            }
            else
            {
                if (!Reticle.Reticles.ContainsKey(retId))
                {
                    Reticle.Set(retId, 0, 0, Color.Red);
                }


                if (Math.Abs((double)state.Gamepad.RightThumbX) > 7000)
                {
                    Reticle reticle = Reticle.Reticles[retId];
                    reticle.Az = (reticle.Az - ((((double)state.Gamepad.RightThumbX / (zoomRate * 3)) * factor)) / Math.Cos(reticle.Alt * Math.PI / 180));
                }

                if (Math.Abs((double)state.Gamepad.RightThumbY) > 7000)
                {
                    Reticle reticle = Reticle.Reticles[retId];
                    reticle.Alt = (reticle.Alt + ((((double)state.Gamepad.RightThumbY / (zoomRate * 3)) * factor)));
                }
            }



            if (CameraAngleTarget < TiltMin)
            {
                CameraAngleTarget = TiltMin;
            }

            if (CameraAngleTarget > 0)
            {
                CameraAngleTarget = 0;
            }

            if (Math.Abs((double)state.Gamepad.LeftThumbX) > 8000 || Math.Abs((double)state.Gamepad.LeftThumbY) > 8000)
            {
                MoveView(((double)state.Gamepad.LeftThumbX / moveRate) * factor, ((double)state.Gamepad.LeftThumbY / moveRate) * factor, false);
                JoyInMotion = true;
            }

            if (state.Gamepad.IsRightShoulderButtonDown)
            {
                // Edge trigger
                if (!rSholderDown)
                {
                    contextPanel.ShowNextObject();
                    rSholderDown = true;
                }
            }
            else
            {
                rSholderDown = false;
            }

            if (state.Gamepad.IsLeftShoulderButtonDown)
            {
                // Edge trigger
                if (!lSholderDown)
                {
                    contextPanel.ShowPreviousObject();
                    lSholderDown = true;
                }
            }
            else
            {
                lSholderDown = false;
            }

            if (state.Gamepad.IsXButtonDown)
            {
                if (!xDown)
                {
                    xDown = true;
                    switch (CurrentImageSet.DataSetType)
                    {
                        case ImageSetType.Earth:
                            Properties.Settings.Default.ShowClouds.TargetState = !Properties.Settings.Default.ShowClouds.TargetState;
                            break;
                        case ImageSetType.Planet:
                            break;
                        case ImageSetType.Sky:
                            Properties.Settings.Default.ShowEcliptic.TargetState = !Properties.Settings.Default.ShowEcliptic.TargetState;
                            break;
                        case ImageSetType.Panorama:
                            break;
                        case ImageSetType.SolarSystem:
                            {
                                if (Properties.Settings.Default.SolarSystemOrbits.TargetState)
                                {
                                    if (Properties.Settings.Default.SolarSystemMinorOrbits.TargetState)
                                    {
                                        Properties.Settings.Default.SolarSystemOrbits.TargetState = false;
                                        Properties.Settings.Default.SolarSystemMinorOrbits.TargetState = false;
                                    }
                                    else
                                    {
                                        Properties.Settings.Default.SolarSystemMinorOrbits.TargetState = true;
                                    }
                                }
                                else
                                {
                                    Properties.Settings.Default.SolarSystemOrbits.TargetState = true;
                                    Properties.Settings.Default.SolarSystemMinorOrbits.TargetState = false;
                                }

                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                xDown = false;
            }

            if (state.Gamepad.IsYButtonDown)
            {
                if (!yDown)
                {
                    yDown = true;
                    switch (CurrentImageSet.DataSetType)
                    {
                        case ImageSetType.Earth:
                            Properties.Settings.Default.ShowClouds.TargetState = !Properties.Settings.Default.ShowClouds.TargetState;
                            break;
                        case ImageSetType.Planet:
                            break;
                        case ImageSetType.Sky:
                            Properties.Settings.Default.ShowConstellationFigures.TargetState = !Properties.Settings.Default.ShowConstellationFigures.TargetState;
                            break;
                        case ImageSetType.Panorama:
                            break;
                        case ImageSetType.SolarSystem:
                            Properties.Settings.Default.SolarSystemStars.TargetState = !Properties.Settings.Default.SolarSystemStars.TargetState;
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                yDown = false;
            }


            if (state.Gamepad.IsAButtonDown)
            {
                if (!aDown)
                {
                    aDown = true;
                    switch (CurrentImageSet.DataSetType)
                    {
                        case ImageSetType.Earth:
                            break;
                        case ImageSetType.Planet:
                            break;
                        case ImageSetType.Sky:
                            Properties.Settings.Default.ShowGrid.TargetState = !Properties.Settings.Default.ShowGrid.TargetState;
                            break;
                        case ImageSetType.Panorama:
                            break;
                        case ImageSetType.SolarSystem:
                            Properties.Settings.Default.SolarSystemMinorPlanets.TargetState = !Properties.Settings.Default.SolarSystemMinorPlanets.TargetState;
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                aDown = false;
            }

            if (state.Gamepad.IsBButtonDown)
            {
                if (!bDown)
                {
                    bDown = true;
                    switch (CurrentImageSet.DataSetType)
                    {
                        case ImageSetType.Earth:
                            break;
                        case ImageSetType.Planet:
                            break;
                        case ImageSetType.Sky:
                            Properties.Settings.Default.ShowConstellationBoundries.TargetState = !Properties.Settings.Default.ShowConstellationBoundries.TargetState;
                            Properties.Settings.Default.ShowConstellationSelection.TargetState = false;
                            break;
                        case ImageSetType.Panorama:
                            break;
                        case ImageSetType.SolarSystem:
                            Properties.Settings.Default.SolarSystemMilkyWay.TargetState = !Properties.Settings.Default.SolarSystemMilkyWay.TargetState;
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                bDown = false;
            }

            return;

        }
Esempio n. 17
0
        public void UpdateMover(IViewMover mover)
        {
            CameraParameters newCam = mover.CurrentPosition;

            if (viewCamera.Opacity != newCam.Opacity)
            {
                if (contextPanel != null)
                {
                    contextPanel.studyOpacity.Value = (int)newCam.Opacity;
                }

            }
            viewCamera = targetViewCamera = newCam;



            if (Space && Settings.Active.GalacticMode)
            {
                double[] gPoint = Coordinates.J2000toGalactic(newCam.RA * 15, newCam.Dec);

                targetAlt = alt = gPoint[1];
                targetAz = az = gPoint[0];
            }
            else if (Space && Settings.Active.LocalHorizonMode)
            {
                Coordinates currentAltAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(newCam.RA, newCam.Dec), SpaceTimeController.Location, SpaceTimeController.Now);

                targetAlt = alt = currentAltAz.Alt;
                targetAz = az = currentAltAz.Az;
            }

            if (mover.Complete)
            {
                targetViewCamera = viewCamera = newCam;
                Earth3d.MainWindow.Mover = null;
                //Todo Notify interested parties that move is complete

                NotifyMoveComplete();
            }
        }
Esempio n. 18
0
        public void GotoTarget(CameraParameters camParams, bool noZoom, bool instant)
        {
            tracking = false;
            trackingObject = null;
            GotoTarget(noZoom, instant, camParams, this.studyImageset, this.CurrentImageSet);

        }
        public static CameraParameters Interpolate(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove)
        {
            CameraParameters result = new CameraParameters();
            double alpha = EaseCurve(alphaIn, type);
            double alphaBIn = Math.Min(1.0, alphaIn * 2);
            double alphaB = EaseCurve(alphaBIn, type);
            result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha);
            result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha);
            if (fastDirectionMove)
            {
                result.Lat = to.Lat * alphaB + from.Lat * (1.0 - alphaB);
                result.Lng = to.Lng * alphaB + from.Lng * (1.0 - alphaB);
            }
            else
            {
                result.Lat = to.Lat * alpha + from.Lat * (1.0 - alpha);
                result.Lng = to.Lng * alpha + from.Lng * (1.0 - alpha);
            }
            result.Zoom = Math.Pow(2, Math.Log(to.Zoom,2) * alpha + Math.Log(from.Zoom,2) * (1.0 - alpha));
            result.Opacity = (float)(to.Opacity * alpha + from.Opacity * (1.0 - alpha));
            result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha);

            result.DomeAlt = to.DomeAlt * alpha + from.DomeAlt * (1.0 - alpha);
            result.DomeAz = to.DomeAz * alpha + from.DomeAz * (1.0 - alpha);

            result.TargetReferenceFrame = to.TargetReferenceFrame;
            if (to.Target == from.Target)
            {
                result.Target = to.Target;
            }
            else
            {
                result.Target = SolarSystemObjects.Custom;
            }
            return result;
        }
Esempio n. 20
0
        public void GotoTarget(bool noZoom, bool instant, CameraParameters cameraParams, IImageSet studyImageSet, IImageSet backgroundImageSet)
        {
            tracking = false;
            trackingObject = null;
            targetStudyImageset = studyImageSet;
            targetBackgroundImageset = backgroundImageSet;


            if (noZoom)
            {
                cameraParams.Zoom = viewCamera.Zoom;
                cameraParams.Angle = viewCamera.Angle;
                cameraParams.Rotation = viewCamera.Rotation;
            }
            else
            {
                if (cameraParams.Zoom == -1)
                {
                    if (Space)
                    {
                        cameraParams.Zoom = 1.40625;
                    }
                    else
                    {
                        cameraParams.Zoom = 0.09F;
                    }
                }
            }

            if (instant || (Math.Abs(ViewLat - cameraParams.Lat) < .000000000001 && Math.Abs(ViewLong - cameraParams.Lng) < .000000000001 && Math.Abs(ZoomFactor - cameraParams.Zoom) < .000000000001))
            {
                mover = null;
                viewCamera = targetViewCamera = cameraParams;

                if (Space && Settings.Active.GalacticMode)
                {
                    double[] gPoint = Coordinates.J2000toGalactic(viewCamera.RA * 15, viewCamera.Dec);
                    targetAlt = alt = gPoint[1];
                    targetAz = az = gPoint[0];
                }
                else if (Space && Settings.Active.LocalHorizonMode)
                {
                    Coordinates currentAltAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(viewCamera.RA, viewCamera.Dec), SpaceTimeController.Location, SpaceTimeController.Now);

                    targetAlt = alt = currentAltAz.Alt;
                    targetAz = az = currentAltAz.Az;
                }
                mover_Midpoint(this, new EventArgs());
            }
            else
            {
                if (TourPlayer.Playing)
                {
                    mover = new ViewMoverSlew(this.viewCamera, cameraParams);
                }
                else
                {
                    mover = new ViewMoverSlew(this.viewCamera, cameraParams, 1.2);
                }
                mover.Midpoint += new EventHandler(mover_Midpoint);
            }
        }
        public double[] GetParams()
        {
            currentCamera = Earth3d.MainWindow.viewCamera;
            jDate = SpaceTimeController.JNow;
            double[] paramList = new double[13];
            paramList[0] = jDate;
            paramList[1] = currentCamera.Lat;
            paramList[2] = currentCamera.Lng;
            paramList[3] = currentCamera.Zoom;
            paramList[4] = currentCamera.Rotation;
            paramList[5] = currentCamera.Angle;
            paramList[6] = currentCamera.Opacity;
            paramList[7] = currentCamera.ViewTarget.X;
            paramList[8] = currentCamera.ViewTarget.Y;
            paramList[9] = currentCamera.ViewTarget.Z;
            paramList[10] = (int)currentCamera.Target;
            paramList[11] = currentCamera.DomeAlt;
            paramList[12] = currentCamera.DomeAz;

            return paramList;
        }
Esempio n. 22
0
 private void ResetCamera()
 {
     CameraParameters camParams = new CameraParameters(0, 0, 360, 0, 0, 100);
     GotoTarget(camParams, false, true);
 }
 public ViewMoverSlew(CameraParameters from, CameraParameters to)
 {
     Init(from, to);
 }
Esempio n. 24
0
        void myMouse_ButtonEvent(object sender, SpaceNavigator._3DxMouse.ButtonEventArgs e)
        {
            CameraParameters cameraParams;
            if ((e.ButtonMask.Pressed & 1) == 1)
            {
                CameraRotateTarget = 0;
            }
            if ((e.ButtonMask.Pressed & 2) == 2)
            {
                cameraParams = new CameraParameters(0, 0, 360, 0, 0, 100);
                this.GotoTarget(cameraParams, false, false);

            }
        }
        public void Init(CameraParameters from, CameraParameters to)
        {
            if (Math.Abs(from.Lng - to.Lng) > 180)
            {
                if (from.Lng > to.Lng)
                {
                    from.Lng -= 360;
                }
                else
                {
                    from.Lng += 360;
                }
            }

            if (to.Zoom <= 0)
            {
                to.Zoom = 360;
            }
            if (from.Zoom <= 0)
            {
                from.Zoom = 360;
            }
            this.from = from;
            this.to = to;
            fromTime = SpaceTimeController.MetaNowTickCount;
            double zoomUpTarget = 360.0;
            double travelTime;

            double lngDist = Math.Abs(from.Lng - to.Lng);
            double latDist = Math.Abs(from.Lat - to.Lat);
            double distance = Math.Sqrt(latDist * latDist + lngDist * lngDist);

            if (Earth3d.MainWindow.Space)
            {
                zoomUpTarget = (distance / 3) * 20;
            }
            else
            {
                zoomUpTarget = (distance / 3)*3;
            }

            if (zoomUpTarget > 360.0)
            {
                zoomUpTarget = 360.0;
            }

            if (zoomUpTarget < from.Zoom)
            {
                zoomUpTarget = from.Zoom;
            }

            if (Earth3d.MainWindow.Space)
            {
                travelTime = (distance / 180.0) * (360 / zoomUpTarget) * travelTimeFactor;
            }
            else
            {
                travelTime = (distance / 180.0) * (75 / zoomUpTarget) * travelTimeFactor;
            }
            double rotateTime = Math.Max(Math.Abs(from.Angle - to.Angle), Math.Abs(from.Rotation - to.Rotation)) ;

            double logDistUp = Math.Max(Math.Abs(Math.Log(zoomUpTarget, 2) - Math.Log(from.Zoom, 2)), rotateTime);
            upTargetTime = upTimeFactor * logDistUp;
            downTargetTime = upTargetTime + travelTime;
            double logDistDown = Math.Abs(Math.Log(zoomUpTarget, 2) - Math.Log(to.Zoom, 2));
            toTargetTime = downTargetTime + Math.Max((downTimeFactor * logDistDown),rotateTime);

            fromTop = from;
            fromTop.Zoom = zoomUpTarget;
            fromTop.Angle = (from.Angle + to.Angle) / 2.0; //todo make short wrap arounds..
            fromTop.Rotation = (from.Rotation + to.Rotation) / 2.0;
            fromTop.DomeAlt = (from.DomeAlt + to.DomeAlt) / 2.0;
            fromTop.DomeAz = (from.DomeAz + to.DomeAz) / 2.0;

            toTop = to;
            toTop.Zoom = fromTop.Zoom;
            toTop.Angle = fromTop.Angle;
            toTop.Rotation = fromTop.Rotation;
            toTop.DomeAlt = fromTop.DomeAlt;
            toTop.DomeAz = fromTop.DomeAz;
        }
Esempio n. 26
0
        private void renderWindow_MouseUp(object sender, MouseEventArgs e)
        {
            if (contrastMode)
            {
                contrastMode = false;
                return;
            }


            if (activeTouch != TouchControls.None)
            {
                if (activeTouch == TouchControls.Finder)
                {
                    if (kioskControl)
                    {
                        if (ObjectProperties.Active)
                        {
                            ObjectProperties.HideProperties();
                        }
                        else
                        {
                            ShowFinder();
                        }
                    }
                    else
                    {
                        Friction = !Friction;
                    }
                }
                if (activeTouch == TouchControls.Home)
                {
                    if (kioskControl)
                    {
                        if (TouchKiosk)
                        {
                            Properties.Settings.Default.SolarSystemScale = 1;
                            FadeInImageSet(GetDefaultImageset(ImageSetType.SolarSystem, BandPass.Visible));
                            CameraParameters camParams = new CameraParameters(45, 0, 360, 0, 0, 100);
                            GotoTarget(camParams, false, true);
                        }
                        else
                        {
                            CameraParameters camParams = new CameraParameters(0, 0, 360, 0, 0, 100);
                            GotoTarget(camParams, false, true);
                        }
                    }
                    else
                    {
                        TouchAllStop();
                    }
                }

                activeTouch = TouchControls.None;

                return;
            }


            if (uiController != null)
            {
                if (uiController.MouseUp(sender, new MouseEventArgs(e.Button, e.Clicks, e.X + Properties.Settings.Default.ScreenHitTestOffsetX, e.Y + Properties.Settings.Default.ScreenHitTestOffsetY, e.Delta)))
                {
                    return;
                }
            }

            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle)
            {
                dragging = false;
                spinning = false;
                measuringDrag = false;
                measuring = false;
                angle = false;
                if (!moved && ShowKmlMarkers && Space)
                {

                    Point cursor = renderWindow.PointToClient(Cursor.Position);

                    Coordinates result = GetCoordinatesForScreenPoint(cursor.X, cursor.Y);

                    if (CurrentImageSet.DataSetType == ImageSetType.Sky)
                    {
                        if (!ProjectorServer)
                        {
                            if (constellationCheck != null)
                            {
                                if (ShowKmlMarkers && KmlMarkers != null)
                                {
                                    KmlMarkers.ItemClick(Coordinates.RADecTo3dDouble(result, 1.0).Vector311, (float)(ZoomFactor / 900.0));
                                }
                            }
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if ((CurrentImageSet.DataSetType == ImageSetType.Sky || CurrentImageSet.DataSetType == ImageSetType.SolarSystem /*|| CurrentImageSet.DataSetType == ImageSetType.Planet || CurrentImageSet.DataSetType == ImageSetType.Earth*/ ) && !TourPlayer.Playing)
                {


                    if (figureEditor != null)
                    {
                        // TODO fix this for earth, plantes, panoramas
                        Coordinates result = GetCoordinatesForScreenPoint(e.X, e.Y);
                        string constellation = this.constellationCheck.FindConstellationForPoint(result.RA, result.Dec);
                        contextPanel.Constellation = Constellations.FullName(constellation);
                        IPlace closetPlace = ContextSearch.FindClosestMatch(constellation, result.RA, result.Dec, Earth3d.MainWindow.DegreesPerPixel * 80);
                        if (closetPlace == null)
                        {
                            closetPlace = new TourPlace(Language.GetLocalizedText(90, "No Object"), result.Dec, result.RA, Classification.Unidentified, constellation, ImageSetType.Sky, -1);
                        }
                        figureEditor.AddFigurePoint(closetPlace);
                    }
                    else
                    {
                        Point pntShow = new Point(e.X, e.Y);

                        if (SolarSystemMode)
                        {
                            ObjectProperties.ShowAt(renderWindow.PointToScreen(pntShow));

                        }
                        else
                        {
                            ShowPropertiesForPoint(pntShow);
                        }
                    }
                }
            }
        }
 //todo this stuff below is too tightly coupled to implementtion for winforms
 public static void GotoLookAt(KmlFeature feature)
 {
     //todo add sky support
     CameraParameters camera = new CameraParameters();
     camera.Lat = feature.LookAt.latitude;
     camera.Lng = feature.LookAt.longitude;
     camera.Rotation = feature.LookAt.heading / 180 * Math.PI;
     camera.Angle = -feature.LookAt.tilt / 180 * Math.PI;
     camera.Zoom = UiTools.MetersToZoom(feature.LookAt.range);
     TourPlace p = new TourPlace(feature.Name, camera, Classification.Unidentified, "", ImageSetType.Earth, SolarSystemObjects.Earth);
     Earth3d.MainWindow.GotoTarget(p, false, false, true);
 }
Esempio n. 28
0
 void keyboard_KeyDown(int keyCode)
 {
     CameraParameters cameraParams;
     switch (keyCode)
     {
         case 1:
             CameraRotateTarget = 0;
             break;
         case 2:
             cameraParams = new CameraParameters(0, 0, 360, 0, 0, 100);
             this.GotoTarget(cameraParams, false, false);
             break;
     }
 }