Пример #1
0
        public void GotoTargetFull(bool noZoom, bool instant, CameraParameters cameraParams, Imageset studyImageSet, Imageset backgroundImageSet)
        {
            RenderNeeded = true;
            //if (cameraParams == this.viewCamera)
            //{
            //    instant = true;
            //}
            tracking = false;
            trackingObject = null;
            targetStudyImageset = studyImageSet;
            targetBackgroundImageset = backgroundImageSet;

            if (noZoom)
            {
                cameraParams.Zoom = RenderContext.ViewCamera.Zoom;
                cameraParams.Angle = RenderContext.ViewCamera.Angle;
                cameraParams.Rotation = RenderContext.ViewCamera.Rotation;
            }
            else
            {
                if (cameraParams.Zoom == -1 || cameraParams.Zoom == 0)
                {
                    if (RenderContext.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))
            if (instant || (Math.Abs(RenderContext.ViewCamera.Lat - cameraParams.Lat) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Lng - cameraParams.Lng) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Zoom - cameraParams.Zoom) < .000000000001))
            {
                Mover = null;
                RenderContext.TargetCamera = cameraParams.Copy();
                RenderContext.ViewCamera = RenderContext.TargetCamera.Copy();

                //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();
                moving = true;
            }
            else
            {

                Mover = ViewMoverSlew.Create(RenderContext.ViewCamera, cameraParams);
                RenderNeeded = true;
                Mover.Midpoint = mover_Midpoint;
            }
        }
Пример #2
0
        //public double GetPixelScaleX(bool mouseRelative)
        //{
        //    double lat = RenderContext.ViewCamera.Lat;
        //    if (mouseRelative)
        //    {
        //        //if (Space && Settings.Active.LocalHorizonMode)
        //        //{
        //        //    Point cursor = renderWindow.PointToClient(Cursor.Position);
        //        //    Coordinates result = GetCoordinatesForScreenPoint(cursor.X, cursor.Y);
        //        //    Coordinates currentAltAz = Coordinates.EquitorialToHorizon(GetCoordinatesForScreenPoint(cursor.X, cursor.Y), SpaceTimeController.Location, SpaceTimeController.Now);
        //        //    lat = currentAltAz.Alt;
        //        //}
        //        //else
        //        {
        //            Point cursor = renderWindow.PointToClient(Cursor.Position);
        //            Coordinates result = GetCoordinatesForScreenPoint(cursor.X, cursor.Y);
        //            lat = result.Lat;
        //        }
        //    }
        //    if (CurrentImageSet != null && (CurrentImageSet.DataSetType == ImageSetType.Sky || CurrentImageSet.DataSetType == ImageSetType.Panorama || SolarSystemMode || CurrentImageSet.DataSetType == ImageSetType.Earth || CurrentImageSet.DataSetType == ImageSetType.Planet))
        //    {
        //        double cosLat = 1;
        //        if (ViewLat > 89.9999)
        //        {
        //            cosLat = Math.Cos(89.9999 * RC);
        //        }
        //        else
        //        {
        //            cosLat = Math.Cos(lat * RC);
        //        }
        //        double zz = (90 - ZoomFactor / 6);
        //        double zcos = Math.Cos(zz * RC);
        //        return GetPixelScaleY() / Math.Max(zcos, cosLat);
        //    }
        //    else
        //    {
        //        return (((baseTileDegrees / ((double)Math.Pow(2, viewTileLevel))) / tileSizeX) / 5) / Math.Max(.2, Math.Cos(targetLat));
        //    }
        //}
        //public double GetPixelScaleY()
        //{
        //    if (SolarSystemMode)
        //    {
        //        if ((int)SolarSystemTrack < (int)SolarSystemObjects.Custom)
        //        {
        //            return Math.Min(.06, 545000 * Math.Tan(Math.PI / 4) * ZoomFactor / renderWindow.ClientRectangle.Height);
        //        }
        //        else
        //        {
        //            return .06;
        //        }
        //    }
        //    else if (CurrentImageSet != null && (CurrentImageSet.DataSetType == ImageSetType.Sky || CurrentImageSet.DataSetType == ImageSetType.Panorama))
        //    {
        //        double val = fovAngle / renderWindow.ClientRectangle.Height;
        //        //if (Properties.Settings.Default.DomeView)
        //        //{
        //        //    val = val / 10;
        //        //}
        //        return val;
        //    }
        //    else
        //    {
        //        return ((baseTileDegrees / ((double)Math.Pow(2, viewTileLevel))) / (double)tileSizeY) / 5;
        //    }
        //}
        //public void MoveView(double amountX, double amountY, bool mouseDrag)
        //{
        //    if (CurrentImageSet == null)
        //    {
        //        return;
        //    }
        //    Tracking = false;
        //    double angle = Math.Atan2(amountY, amountX);
        //    double distance = Math.Sqrt(amountY * amountY + amountX * amountX);
        //    if (SolarSystemMode)
        //    {
        //        amountX = Math.Cos(angle - CameraRotate) * distance;
        //        amountY = Math.Sin(angle - CameraRotate) * distance;
        //    }
        //    else if (!PlanetLike)
        //    {
        //        amountX = Math.Cos(angle + CameraRotate) * distance;
        //        amountY = Math.Sin(angle + CameraRotate) * distance;
        //    }
        //    else
        //    {
        //        amountX = Math.Cos(angle - CameraRotate) * distance;
        //        amountY = Math.Sin(angle - CameraRotate) * distance;
        //    }
        //    MoveViewNative(amountX, amountY, mouseDrag);
        //}
        ///// <summary>
        ///// Move the view relative to screen coordinates without account for the view rotation
        ///// </summary>
        ///// <param name="amountX"></param>
        ///// <param name="amountY"></param>
        //public void MoveViewNative(double amountX, double amountY, bool mouseDrag)
        //{
        //    double scaleY = GetPixelScaleY();
        //    double scaleX = GetPixelScaleX(mouseDrag);
        //    //if (CurrentImageSet.DataSetType == ImageSetType.SolarSystem)
        //    //{
        //    //    if (Settings.Active.ActualPlanetScale)
        //    //    {
        //    //        if (ZoomFactor < .0003)
        //    //        {
        //    //            scaleX *= 1210 / 300;
        //    //            scaleY *= 800 / 300;
        //    //        }
        //    //        else
        //    //        {
        //    //            scaleX = .06;
        //    //            scaleY = .06;
        //    //        }
        //    //    }
        //    //    else
        //    //    {
        //    //        if (ZoomFactor < .05)
        //    //        {
        //    //            scaleX *= 1210;
        //    //            scaleY *= 800;
        //    //        }
        //    //        else
        //    //        {
        //    //            scaleX = .06;
        //    //            scaleY = .06;
        //    //        }
        //    //    }
        //    //}
        //    if (CurrentImageSet.DataSetType == ImageSetType.SolarSystem)
        //    {
        //        if (scaleY > .05999)
        //        {
        //            scaleX = scaleY;
        //        }
        //    }
        //    if (Space && Settings.Active.LocalHorizonMode)
        //    {
        //        targetAlt += (amountY) * scaleY;
        //        if (targetAlt > Properties.Settings.Default.MaxLatLimit)
        //        {
        //            targetAlt = Properties.Settings.Default.MaxLatLimit;
        //        }
        //        if (targetAlt < -Properties.Settings.Default.MaxLatLimit)
        //        {
        //            targetAlt = -Properties.Settings.Default.MaxLatLimit;
        //        }
        //    }
        //    else
        //    {
        //        TargetLat += (amountY) * scaleY;
        //        if (TargetLat > Properties.Settings.Default.MaxLatLimit)
        //        {
        //            TargetLat = Properties.Settings.Default.MaxLatLimit;
        //        }
        //        if (TargetLat < -Properties.Settings.Default.MaxLatLimit)
        //        {
        //            TargetLat = -Properties.Settings.Default.MaxLatLimit;
        //        }
        //    }
        //    if (Space && Settings.Active.LocalHorizonMode)
        //    {
        //        targetAz = ((targetAz + amountX * scaleX) + 720) % 360;
        //    }
        //    else
        //    {
        //        TargetLong += (amountX) * scaleX;
        //        TargetLong = ((TargetLong + 900.0) % 360.0) - 180.0;
        //    }
        //}
        public void Move(double x, double y)
        {
            double scaleY = RenderContext.FovScale / (3600.0);

            if (RenderContext.BackgroundImageset.DataSetType == ImageSetType.SolarSystem)
            {
                scaleY = .06;
            }

            double scaleX = scaleY / Math.Max(.2, Math.Cos(RenderContext.ViewCamera.Lat / 180.0 * Math.PI));

            if (RenderContext.BackgroundImageset.DataSetType == ImageSetType.Earth || RenderContext.BackgroundImageset.DataSetType == ImageSetType.Planet || RenderContext.BackgroundImageset.DataSetType == ImageSetType.SolarSystem)
            {
                scaleX = scaleX * 6.3;
                scaleY = scaleY * 6.3;
            }

            if (RenderContext.Space && (Settings.Active.GalacticMode || Settings.Active.LocalHorizonMode))
            {
                x = Settings.Active.LocalHorizonMode ? -x : x;
                RenderContext.targetAz += x * scaleX;
                RenderContext.targetAz = ((RenderContext.targetAz + 720) % 360);
                RenderContext.targetAlt += y * scaleY;

                if (RenderContext.targetAlt > 90)
                {
                    RenderContext.targetAlt = 90;
                }

                if (RenderContext.targetAlt < -90)
                {
                    RenderContext.targetAlt = -90;
                }
            }
            else
            {
                RenderContext.TargetCamera.Lng -= x * scaleX;

                RenderContext.TargetCamera.Lng = ((RenderContext.TargetCamera.Lng + 720) % 360);

                RenderContext.TargetCamera.Lat += y * scaleY;

                if (RenderContext.TargetCamera.Lat > 90)
                {
                    RenderContext.TargetCamera.Lat = 90;
                }

                if (RenderContext.TargetCamera.Lat < -90)
                {
                    RenderContext.TargetCamera.Lat = -90;
                }
            }

            if (!Settings.GlobalSettings.SmoothPan)
            {
                RenderContext.ViewCamera = RenderContext.TargetCamera.Copy();
            }

            if (x != 0 && y != 0)
            {
                tracking = false;
                trackingObject = null;
            }
        }
Пример #3
0
        public void GotoTarget(Place 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)Planets.GetPlanetIDFromName(place.Name);
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (target != SolarSystemObjects.Undefined)
                    {
                        trackingObject = place;
                        if (target == SolarSystemTrack && !(place.Classification == Classification.Star || place.Classification == Classification.Galaxy))
                        {
                            GotoTarget3(place.CamParams, noZoom, instant);
                            return;
                        }
                        double jumpTime = 4;

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

                        if (instant)
                        {
                            jumpTime = 1;
                        }

                        //SolarSystemTrack = target;
                        CameraParameters camTo = RenderContext.ViewCamera.Copy();
                        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.RADecTo3dAu(place.RA, place.Dec, place.Distance);
                            double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;

                            vect.RotateX(ecliptic);
                            camTo.ViewTarget = Vector3d.Negate(camTo.ViewTarget);
                        }
                        else
                        {
                            camTo.ViewTarget = Planets.GetPlanet3dLocationJD(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 = RenderContext.ViewCamera.Copy();
                        if (SolarSystemTrack == SolarSystemObjects.Custom && !string.IsNullOrEmpty(RenderContext.TrackingFrame))
                        {
                            fromParams =  RenderContext.CustomTrackingParams;
                            RenderContext.TrackingFrame = "";
                        }
                        camTo.Zoom = zoom;
                        Vector3d toVector = camTo.ViewTarget;
                        toVector.Subtract(fromParams.ViewTarget);

                        //Vector3d toVector = camTo.ViewTarget;
                        //toVector.Subtract(new Vector3d(cameraPosition));

                        if (place.Classification == Classification.Star)
                        {
                            toVector = Vector3d.Negate(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 = RenderContext.ViewCamera.Lat;
                            camTo.Lng = RenderContext.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.Copy();

            // (gonzalo) backgroundimageset could be null... protect onself!
            if (RenderContext.BackgroundImageset != null && place.Type != RenderContext.BackgroundImageset.DataSetType)
            {
                RenderContext.TargetCamera = place.CamParams.Copy();
                RenderContext.ViewCamera = RenderContext.TargetCamera.Copy();
                RenderContext.BackgroundImageset = GetDefaultImageset(place.Type, BandPass.Visible);
                instant = true;
            }
            else if (SolarSystemMode && place.Target != SolarSystemTrack)
            {
                RenderContext.TargetCamera = place.CamParams.Copy();
                RenderContext.ViewCamera = RenderContext.TargetCamera.Copy();
                SolarSystemTrack = place.Target;
                instant = true;
            }

            if (place.Classification == Classification.Constellation)
            {
                camParams.Zoom = ZoomMax;
                GotoTargetFull(false, instant, camParams, null, null);
            }
            else
            {
                SolarSystemTrack = place.Target;
                GotoTargetFull(noZoom, instant, camParams, place.StudyImageset, place.BackgroundImageset);
                //if (place.Classification == Classification.SolarSystem)
                if (trackObject)
                {
                    tracking = true;
                    trackingObject = place;
                }
            }
        }
Пример #4
0
 public void GotoTarget3(CameraParameters camParams, bool noZoom, bool instant)
 {
     tracking = false;
     trackingObject = null;
     GotoTargetFull(noZoom, instant, camParams, RenderContext.ForegroundImageset, RenderContext.BackgroundImageset);
 }
Пример #5
0
 public virtual Place FindClosest(Coordinates target, float distance, Place closestPlace, bool astronomical)
 {
     return(closestPlace);
 }
Пример #6
0
        public void GotoRADecZoom(double ra, double dec, double zoom, bool instant)
        {
            ra = DoubleUtilities.Clamp(ra, 0, 24);
            dec = DoubleUtilities.Clamp(dec, -90, 90);
            zoom = DoubleUtilities.Clamp(zoom, ZoomMin, ZoomMax);

            tracking = false;
            trackingObject = null;
            GotoTargetFull(false, instant, CameraParameters.Create(dec, WWTControl.Singleton.RenderContext.RAtoViewLng(ra), zoom, WWTControl.Singleton.RenderContext.ViewCamera.Rotation, WWTControl.Singleton.RenderContext.ViewCamera.Angle, (float)WWTControl.Singleton.RenderContext.ViewCamera.Opacity), WWTControl.Singleton.RenderContext.ForegroundImageset, WWTControl.Singleton.RenderContext.BackgroundImageset);
        }
Пример #7
0
 public void AddChildPlace(Place child)
 {
     places.Add(child);
     dirty = true;
 }
Пример #8
0
        public static Place CreateCameraParams(string name, CameraParameters camParams, Classification classification, string constellation, ImageSetType type, SolarSystemObjects target)
        {
            Place temp = new Place();

            temp.constellation = constellation;
            temp.name = name;
            temp.Classification = classification;
            temp.camParams = camParams;
            temp.Type = type;
            temp.Target = target;

            return temp;
        }
Пример #9
0
 public void RemoveChildPlace(Place child)
 {
     places.Remove(child);
     dirty = true;
 }
Пример #10
0
        //internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName)
        //{
        //    xmlWriter.WriteStartElement(elementName);
        //    xmlWriter.WriteAttributeString("Name", name);
        //    xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString());
        //    if (this.Type == ImageSetType.Sky)
        //    {
        //        xmlWriter.WriteAttributeString("RA", camParams.RA.ToString());
        //        xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString());
        //    }
        //    else
        //    {
        //        xmlWriter.WriteAttributeString("Lat", Lat.ToString());
        //        xmlWriter.WriteAttributeString("Lng", Lng.ToString());
        //    }
        //    xmlWriter.WriteAttributeString("Constellation", constellation);
        //    xmlWriter.WriteAttributeString("Classification", Classification.ToString());
        //    xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString());
        //    xmlWriter.WriteAttributeString("Distance", distnace.ToString());
        //    xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString());
        //    xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString());
        //    xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString());
        //    xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString());
        //    xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString());
        //    xmlWriter.WriteAttributeString("Target", Target.ToString());
        //    xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString());
        //    xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame);
        //    xmlWriter.WriteStartElement("Description");
        //    xmlWriter.WriteCData(HtmlDescription);
        //    xmlWriter.WriteEndElement();
        //    if (backgroundImageSet != null)
        //    {
        //        xmlWriter.WriteStartElement("BackgroundImageSet");
        //        ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, "");
        //        xmlWriter.WriteEndElement();
        //    }
        //    if (studyImageset != null)
        //    {
        //        ImageSetHelper.SaveToXml(xmlWriter, studyImageset, "");
        //    }
        //    xmlWriter.WriteEndElement();
        //}
        internal static Place FromXml(XmlNode place)
        {
            Place newPlace = new Place();

            newPlace.name = place.Attributes.GetNamedItem("Name").Value;

            if (place.Attributes.GetNamedItem("DataSetType") != null)
            {
                switch (place.Attributes.GetNamedItem("DataSetType").Value.ToLowerCase())
                {
                    case "earth":
                        newPlace.type = ImageSetType.Earth;
                        break;
                    case "planet":
                        newPlace.type = ImageSetType.Planet;
                        break;
                    case "sky":
                        newPlace.type = ImageSetType.Sky;
                        break;
                    case "panorama":
                        newPlace.type = ImageSetType.Panorama;
                        break;
                    case "solarsystem":
                        newPlace.type = ImageSetType.SolarSystem;
                        break;
                }
            }

            if (newPlace.Type == ImageSetType.Sky)
            {
                newPlace.camParams.RA = double.Parse(place.Attributes.GetNamedItem("RA").Value);
                newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value);
            }
            else
            {
                newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value);
                newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value);
            }

            if (place.Attributes.GetNamedItem("Constellation") != null)
            {
                newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value;
            }
            //todo change to switch/case
            if (place.Attributes.GetNamedItem("Classification") != null)
            {
                switch (place.Attributes.GetNamedItem("Classification").Value)
                {

                    case "Star":
                        newPlace.classification = Classification.Star;
                        break;
                    case "Supernova":
                        newPlace.classification = Classification.Supernova;
                        break;
                    case "BlackHole":
                        newPlace.classification = Classification.BlackHole;
                        break;
                    case "NeutronStar":
                        newPlace.classification = Classification.NeutronStar;
                        break;
                    case "DoubleStar":
                        newPlace.classification = Classification.DoubleStar;
                        break;
                    case "MultipleStars":
                        newPlace.classification = Classification.MultipleStars;
                        break;
                    case "Asterism":
                        newPlace.classification = Classification.Asterism;
                        break;
                    case "Constellation":
                        newPlace.classification = Classification.Constellation;
                        break;
                    case "OpenCluster":
                        newPlace.classification = Classification.OpenCluster;
                        break;
                    case "GlobularCluster":
                        newPlace.classification = Classification.GlobularCluster;
                        break;
                    case "NebulousCluster":
                        newPlace.classification = Classification.NebulousCluster;
                        break;
                    case "Nebula":
                        newPlace.classification = Classification.Nebula;
                        break;
                    case "EmissionNebula":
                        newPlace.classification = Classification.EmissionNebula;
                        break;
                    case "PlanetaryNebula":
                        newPlace.classification = Classification.PlanetaryNebula;
                        break;
                    case "ReflectionNebula":
                        newPlace.classification = Classification.ReflectionNebula;
                        break;
                    case "DarkNebula":
                        newPlace.classification = Classification.DarkNebula;
                        break;
                    case "GiantMolecularCloud":
                        newPlace.classification = Classification.GiantMolecularCloud;
                        break;
                    case "SupernovaRemnant":
                        newPlace.classification = Classification.SupernovaRemnant;
                        break;
                    case "InterstellarDust":
                        newPlace.classification = Classification.InterstellarDust;
                        break;
                    case "Quasar":
                        newPlace.classification = Classification.Quasar;
                        break;
                    case "Galaxy":
                        newPlace.classification = Classification.Galaxy;
                        break;
                    case "SpiralGalaxy":
                        newPlace.classification = Classification.SpiralGalaxy;
                        break;
                    case "IrregularGalaxy":
                        newPlace.classification = Classification.IrregularGalaxy;
                        break;
                    case "EllipticalGalaxy":
                        newPlace.classification = Classification.EllipticalGalaxy;
                        break;
                    case "Knot":
                        newPlace.classification = Classification.Knot;
                        break;
                    case "PlateDefect":
                        newPlace.classification = Classification.PlateDefect;
                        break;
                    case "ClusterOfGalaxies":
                        newPlace.classification = Classification.ClusterOfGalaxies;
                        break;
                    case "OtherNGC":
                        newPlace.classification = Classification.OtherNGC;
                        break;
                    case "Unidentified":
                        newPlace.classification = Classification.Unidentified;
                        break;
                    case "SolarSystem":
                        newPlace.classification = Classification.SolarSystem;
                        break;
                    case "Unfiltered":
                        newPlace.classification = Classification.Unfiltered;
                        break;
                    case "Stellar":
                        newPlace.classification = Classification.Stellar;
                        break;
                    case "StellarGroupings":
                        newPlace.classification = Classification.StellarGroupings;
                        break;
                    case "Nebulae":
                        newPlace.classification = Classification.Nebulae;
                        break;
                    case "Galactic":
                        newPlace.classification = Classification.Galactic;
                        break;
                    case "Other":
                        newPlace.classification = Classification.Other;
                        break;

                    default:
                        break;
                }
            }

            if (place.Attributes.GetNamedItem("Magnitude") != null)
            {
                newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value);
            }

            if (place.Attributes.GetNamedItem("AngularSize") != null)
            {
                newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value);
            }

            if (place.Attributes.GetNamedItem("ZoomLevel") != null)
            {

                newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value);
            }

            if (place.Attributes.GetNamedItem("Rotation") != null)
            {
                newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value);
            }

            if (place.Attributes.GetNamedItem("Angle") != null)
            {
                newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value);
            }

            if (place.Attributes.GetNamedItem("Opacity") != null)
            {
                newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

            newPlace.Target = SolarSystemObjects.Undefined;

            if (place.Attributes.GetNamedItem("Target") != null)
            {

                switch (place.Attributes.GetNamedItem("Target").Value)
                {
                    case "Sun":
                        newPlace.Target = SolarSystemObjects.Sun;
                        break;
                    case "Mercury":
                        newPlace.Target = SolarSystemObjects.Mercury;
                        break;
                    case "Venus":
                        newPlace.Target = SolarSystemObjects.Venus;
                        break;
                    case "Mars":
                        newPlace.Target = SolarSystemObjects.Mars;
                        break;
                    case "Jupiter":
                        newPlace.Target = SolarSystemObjects.Jupiter;
                        break;
                    case "Saturn":
                        newPlace.Target = SolarSystemObjects.Saturn;
                        break;
                    case "Uranus":
                        newPlace.Target = SolarSystemObjects.Uranus;
                        break;
                    case "Neptune":
                        newPlace.Target = SolarSystemObjects.Neptune;
                        break;
                    case "Pluto":
                        newPlace.Target = SolarSystemObjects.Pluto;
                        break;
                    case "Moon":
                        newPlace.Target = SolarSystemObjects.Moon;
                        break;
                    case "Io":
                        newPlace.Target = SolarSystemObjects.Io;
                        break;
                    case "Europa":
                        newPlace.Target = SolarSystemObjects.Europa;
                        break;
                    case "Ganymede":
                        newPlace.Target = SolarSystemObjects.Ganymede;
                        break;
                    case "Callisto":
                        newPlace.Target = SolarSystemObjects.Callisto;
                        break;
                    case "IoShadow":
                        newPlace.Target = SolarSystemObjects.IoShadow;
                        break;
                    case "EuropaShadow":
                        newPlace.Target = SolarSystemObjects.EuropaShadow;
                        break;
                    case "GanymedeShadow":
                        newPlace.Target = SolarSystemObjects.GanymedeShadow;
                        break;
                    case "CallistoShadow":
                        newPlace.Target = SolarSystemObjects.CallistoShadow;
                        break;
                    case "SunEclipsed":
                        newPlace.Target = SolarSystemObjects.SunEclipsed;
                        break;
                    case "Earth":
                        newPlace.Target = SolarSystemObjects.Earth;
                        break;
                    case "Custom":
                        newPlace.Target = SolarSystemObjects.Custom;
                        break;
                    case "Undefined":
                        newPlace.Target = SolarSystemObjects.Undefined;
                        break;

                    default:

                        break;
                }
            }

            if (place.Attributes.GetNamedItem("ViewTarget") != null)
            {
                newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value);
            }

            //if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null)
            //{
            //    newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value;
            //}

            XmlNode descriptionNode = Util.SelectSingleNode(place, "Description");
            if (descriptionNode != null)
            {
                newPlace.HtmlDescription = descriptionNode.Value;
            }

            XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet");
            if (backgroundImageSet != null)
            {
                XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet, "ImageSet");

                newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet);

            }
            XmlNode study = Util.SelectSingleNode(place, "ForegroundImageSet");
            if (study != null)
            {
                XmlNode imageSet = Util.SelectSingleNode(study, "ImageSet");

                newPlace.studyImageset = Imageset.FromXMLNode(imageSet);

            }
            study = Util.SelectSingleNode(place, "ImageSet");
            if (study != null)
            {

                newPlace.studyImageset = Imageset.FromXMLNode(study);

            }
            return newPlace;
        }
Пример #11
0
 public void AddChildPlace(Place child)
 {
     places.Add(child);
     dirty = true;
 }
Пример #12
0
        //public static Folder LoadFromXML(XmlNode node)
        //{
        //    Folder temp = new Folder();

        //    temp.ParseXML(node);

        //    return temp;
        //}

        private void ParseXML(XmlNode node)
        {
            if (node.Attributes.GetNamedItem("Name") != null)
            {
                nameField = node.Attributes.GetNamedItem("Name").Value;
            }
            else
            {
                nameField = "";
            }
            if (node.Attributes.GetNamedItem("Url") != null)
            {
                urlField = node.Attributes.GetNamedItem("Url").Value;
            }

            if (node.Attributes.GetNamedItem("Thumbnail") != null)
            {
                thumbnailUrlField = node.Attributes.GetNamedItem("Thumbnail").Value;
            }

            // load Children

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "Folder":
                    Folder temp = new Folder();
                    temp.Parent = this;
                    //if (Parent != null && IsProxy)
                    //{
                    //    temp.Parent = Parent.Parent;
                    //}
                    temp.ParseXML(child);
                    folders.Add(temp);
                    break;

                case "Place":
                    places.Add(Place.FromXml(child));
                    break;

                case "ImageSet":
                    Imagesets.Add(Imageset.FromXMLNode(child));
                    break;

                case "Tour":
                    Tours.Add(Tour.FromXml(child));
                    break;
                }
            }


            //bool Browseable { get; set; }
            //System.Collections.Generic.List<Folder> Folders { get; set; }
            //FolderGroup Group { get; set; }
            //System.Collections.Generic.List<Imageset> Imagesets { get; set; }
            //long MSRCommunityId { get; set; }
            //long MSRComponentId { get; set; }
            //string Name { get; set; }
            //long Permission { get; set; }
            //System.Collections.Generic.List<Place> Places { get; set; }
            //bool ReadOnly { get; set; }
            //string RefreshInterval { get; set; }
            //FolderRefreshType RefreshType { get; set; }
            //bool RefreshTypeSpecified { get; set; }
            //bool Searchable { get; set; }
            //string SubType { get; set; }
            //string ThumbnailUrl { get; set; }
            //System.Collections.Generic.List<Tour> Tours { get; set; }
            //FolderType Type { get; set; }
            //string Url { get; set; }
        }
Пример #13
0
        internal static Place FromXml(XmlNode place)
        {
            Place newPlace = new Place();

            newPlace.name = place.Attributes.GetNamedItem("Name").Value;

            if (place.Attributes.GetNamedItem("MSRComponentId") != null && place.Attributes.GetNamedItem("Permission") != null && place.Attributes.GetNamedItem("Url") != null)
            {
                //communities item
                newPlace.Url          = place.Attributes.GetNamedItem("Url").Value;
                newPlace.ThumbnailUrl = place.Attributes.GetNamedItem("Thumbnail").Value;
                return(newPlace);
            }

            if (place.Attributes.GetNamedItem("DataSetType") != null)
            {
                newPlace.type = (ImageSetType)Enums.Parse("ImageSetType", place.Attributes.GetNamedItem("DataSetType").Value);
            }

            if (newPlace.Type == ImageSetType.Sky)
            {
                newPlace.camParams.RA  = double.Parse(place.Attributes.GetNamedItem("RA").Value);
                newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value);
            }
            else
            {
                newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value);
                newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value);
            }

            if (place.Attributes.GetNamedItem("Constellation") != null)
            {
                newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value;
            }

            if (place.Attributes.GetNamedItem("Classification") != null)
            {
                newPlace.classification = (Classification)Enums.Parse("Classification", place.Attributes.GetNamedItem("Classification").Value);
            }

            if (place.Attributes.GetNamedItem("Magnitude") != null)
            {
                newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value);
            }

            if (place.Attributes.GetNamedItem("AngularSize") != null)
            {
                newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value);
            }

            if (place.Attributes.GetNamedItem("ZoomLevel") != null)
            {
                newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value);
            }

            if (place.Attributes.GetNamedItem("Rotation") != null)
            {
                newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value);
            }

            if (place.Attributes.GetNamedItem("Angle") != null)
            {
                newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value);
            }

            if (place.Attributes.GetNamedItem("Opacity") != null)
            {
                newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

            newPlace.Target = SolarSystemObjects.Undefined;

            if (place.Attributes.GetNamedItem("Target") != null)
            {
                newPlace.Target = (SolarSystemObjects)Enums.Parse("SolarSystemObjects", place.Attributes.GetNamedItem("Target").Value);
            }

            if (place.Attributes.GetNamedItem("ViewTarget") != null)
            {
                newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value);
            }

            //if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null)
            //{
            //    newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value;
            //}

            XmlNode descriptionNode = Util.SelectSingleNode(place, "Description");

            if (descriptionNode != null)
            {
                newPlace.HtmlDescription = descriptionNode.Value;
            }

            XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet");

            if (backgroundImageSet != null)
            {
                XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet, "ImageSet");

                newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet);
            }
            XmlNode study = Util.SelectSingleNode(place, "ForegroundImageSet");

            if (study != null)
            {
                XmlNode imageSet = Util.SelectSingleNode(study, "ImageSet");

                newPlace.studyImageset = Imageset.FromXMLNode(imageSet);
            }
            study = Util.SelectSingleNode(place, "ImageSet");
            if (study != null)
            {
                newPlace.studyImageset = Imageset.FromXMLNode(study);
            }
            return(newPlace);
        }
Пример #14
0
 public virtual Place FindClosest(Coordinates target, float distance, Place closestPlace, bool astronomical)
 {
     return closestPlace;
 }
Пример #15
0
 public void RemoveChildPlace(Place child)
 {
     places.Remove(child);
     dirty = true;
 }
Пример #16
0
        //public Place(string name, double lat, double lng)
        //{
        //    this.name = name;
        //    Lat = lat;
        //    Lng = lng;
        //    Type = DataSetType.Geo;
        //    ZoomLevel = -1;
        //}
        public static Place create(string name, double lat, double lng, Classification classification, string constellation, ImageSetType type, double zoomFactor)
        {
            Place temp = new Place();
            temp.ZoomLevel = zoomFactor;
            temp.constellation = constellation;
            temp.name = name;
            if (type == ImageSetType.Sky || type == ImageSetType.SolarSystem)
            {
                temp.camParams.RA = lng;
            }
            else
            {
                temp.Lng = lng;
            }
            temp.Lat = lat;
            temp.Classification = classification;
            temp.Type = type;

            return temp;
        }
Пример #17
0
        private void UpdateViewParameters()
        {
            if (RenderContext.Space && tracking && trackingObject != null)
            {
                if (Settings.Active.GalacticMode && RenderContext.Space)
                {
                    double[] gPoint = Coordinates.J2000toGalactic(trackingObject.RA * 15, trackingObject.Dec);

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

                    RenderContext.targetAlt = currentAltAz.Alt;
                    RenderContext.targetAz = currentAltAz.Az;
                }
                else
                {
                    RenderContext.ViewCamera.Lng = RenderContext.TargetCamera.Lng = this.RAtoViewLng(trackingObject.RA);
                    RenderContext.ViewCamera.Lat = RenderContext.TargetCamera.Lat = trackingObject.Dec;
                }
            }
            else if (!SolarSystemMode)
            {
                tracking = false;
                trackingObject = null;
            }

            double oneMinusDragCoefficient = 1 - DragCoefficient;
            double dc = DragCoefficient;

            //if (!Settings.Current.SmoothPan)
            //{
            //    oneMinusDragCoefficient = 1;
            //    dc = 0;
            //}
            if (!tracking)
            {
                double minDelta = (RenderContext.ViewCamera.Zoom / 4000.0);
                if (RenderContext.ViewCamera.Zoom > 360)
                {
                    minDelta = (360.0 / 40000.0);
                }
                //if (RenderContext.Space && Settings.Active.LocalHorizonMode)
                //{
                //    //if (!Settings.Current.SmoothPan)
                //    //{
                //    //    this.alt = targetAlt;
                //    //    this.az = targetAz;
                //    //}

                //    if (((Math.Abs(this.TargetAlt - this.alt) >= (minDelta)) |
                //        ((Math.Abs(this.targetAz - this.az) >= (minDelta)))))
                //    {
                //        this.alt += (targetAlt - alt) / 10;

                //        if (Math.Abs(targetAz - az) > 170)
                //        {
                //            if (targetAz > az)
                //            {
                //                this.az += (targetAz - (360 + az)) / 10;
                //            }
                //            else
                //            {
                //                this.az += ((360 + targetAz) - az) / 10;
                //            }
                //        }
                //        else
                //        {
                //            this.az += (targetAz - az) / 10;
                //        }

                //        //this.az = ((az + 540) % 360) - 180;
                //        this.az = ((az + 720) % 360);

                //    }
                //}
                //else

                    //if (!Settings.Current.SmoothPan)
                    //{
                    //    this.viewCamera.Lat = this.targetCamera.Lat;
                    //    this.viewCamera.Lng = this.targetCamera.Lng;
                    //}
                if (RenderContext.Space && (Settings.Active.LocalHorizonMode || Settings.Active.GalacticMode))
                {
                    if (((Math.Abs(RenderContext.targetAlt - RenderContext.alt) >= (minDelta)) |
                        ((Math.Abs(RenderContext.targetAz - RenderContext.az) >= (minDelta)))))
                    {
                        RenderContext.alt += (RenderContext.targetAlt - RenderContext.alt) / 10;

                        if (Math.Abs(RenderContext.targetAz - RenderContext.az) > 170)
                        {
                            if (RenderContext.targetAz > RenderContext.az)
                            {
                                RenderContext.az += (RenderContext.targetAz - (360 + RenderContext.az)) / 10;
                            }
                            else
                            {
                                RenderContext.az += ((360 + RenderContext.targetAz) - RenderContext.az) / 10;
                            }
                        }
                        else
                        {
                            RenderContext.az += (RenderContext.targetAz - RenderContext.az) / 10;
                        }
                        RenderContext.az = ((RenderContext.az + 720) % 360);
                    }
                }
                else
                {
                    if (((Math.Abs(RenderContext.TargetCamera.Lat - RenderContext.ViewCamera.Lat) >= (minDelta)) |
                        ((Math.Abs(RenderContext.TargetCamera.Lng - RenderContext.ViewCamera.Lng) >= (minDelta)))))
                    {
                        RenderContext.ViewCamera.Lat += (RenderContext.TargetCamera.Lat - RenderContext.ViewCamera.Lat) / 10;

                        if (Math.Abs(RenderContext.TargetCamera.Lng - RenderContext.ViewCamera.Lng) > 170)
                        {
                            if (RenderContext.TargetCamera.Lng > RenderContext.ViewCamera.Lng)
                            {
                                RenderContext.ViewCamera.Lng += (RenderContext.TargetCamera.Lng - (360 + RenderContext.ViewCamera.Lng)) / 10;
                            }
                            else
                            {
                                RenderContext.ViewCamera.Lng += ((360 + RenderContext.TargetCamera.Lng) - RenderContext.ViewCamera.Lng) / 10;
                            }
                        }
                        else
                        {
                            RenderContext.ViewCamera.Lng += (RenderContext.TargetCamera.Lng - RenderContext.ViewCamera.Lng) / 10;
                        }

                        RenderContext.ViewCamera.Lng = ((RenderContext.ViewCamera.Lng + 720) % 360);
                    }
                    else
                    {
                        if (RenderContext.ViewCamera.Lat != RenderContext.TargetCamera.Lat || RenderContext.ViewCamera.Lng != RenderContext.TargetCamera.Lng)
                        {
                            RenderContext.ViewCamera.Lat = RenderContext.TargetCamera.Lat;
                            RenderContext.ViewCamera.Lng = RenderContext.TargetCamera.Lng;
                        }
                    }
                }
            }

            //if (!tracking)
            //{
            //    this.viewCamera.Lng = dc * this.viewCamera.Lng + oneMinusDragCoefficient * this.targetCamera.Lng;
            //    this.viewCamera.Lat = dc * this.viewCamera.Lat + oneMinusDragCoefficient * this.targetCamera.Lat;
            //}
            RenderContext.ViewCamera.Zoom = dc * RenderContext.ViewCamera.Zoom + oneMinusDragCoefficient * RenderContext.TargetCamera.Zoom;
            RenderContext.ViewCamera.Rotation = dc * RenderContext.ViewCamera.Rotation + oneMinusDragCoefficient * RenderContext.TargetCamera.Rotation;
            RenderContext.ViewCamera.Angle = dc * RenderContext.ViewCamera.Angle + oneMinusDragCoefficient * RenderContext.TargetCamera.Angle;
        }
Пример #18
0
        //internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName)
        //{
        //    xmlWriter.WriteStartElement(elementName);
        //    xmlWriter.WriteAttributeString("Name", name);
        //    xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString());
        //    if (this.Type == ImageSetType.Sky)
        //    {
        //        xmlWriter.WriteAttributeString("RA", camParams.RA.ToString());
        //        xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString());
        //    }
        //    else
        //    {
        //        xmlWriter.WriteAttributeString("Lat", Lat.ToString());
        //        xmlWriter.WriteAttributeString("Lng", Lng.ToString());
        //    }
        //    xmlWriter.WriteAttributeString("Constellation", constellation);
        //    xmlWriter.WriteAttributeString("Classification", Classification.ToString());
        //    xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString());
        //    xmlWriter.WriteAttributeString("Distance", distnace.ToString());
        //    xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString());
        //    xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString());
        //    xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString());
        //    xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString());
        //    xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString());
        //    xmlWriter.WriteAttributeString("Target", Target.ToString());
        //    xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString());
        //    xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame);
        //    xmlWriter.WriteStartElement("Description");
        //    xmlWriter.WriteCData(HtmlDescription);
        //    xmlWriter.WriteEndElement();
        //    if (backgroundImageSet != null)
        //    {
        //        xmlWriter.WriteStartElement("BackgroundImageSet");
        //        ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, "");
        //        xmlWriter.WriteEndElement();
        //    }
        //    if (studyImageset != null)
        //    {
        //        ImageSetHelper.SaveToXml(xmlWriter, studyImageset, "");
        //    }
        //    xmlWriter.WriteEndElement();
        //}
        internal static Place FromXml(XmlNode place)
        {
            Place newPlace = new Place();

            newPlace.name = place.Attributes.GetNamedItem("Name").Value;
            newPlace.Type = (ImageSetType)Enum.Parse(typeof(ImageSetType), place.Attributes.GetNamedItem("DataSetType").Value);
            if (newPlace.Type == ImageSetType.Sky)
            {
                newPlace.camParams.RA = double.Parse(place.Attributes.GetNamedItem("RA").Value);
                newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value);
            }
            else
            {
                newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value);
                newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value);
            }

            newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value;

            //todo change to switch/case
            newPlace.Classification = (Classification)Enum.Parse(typeof(Classification), place.Attributes.GetNamedItem("Classification").Value);

            newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value);
            if (place.Attributes.GetNamedItem("Magnitude") != null)
            {
                newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value);
            }
            newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value);
            newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value);
            newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value);
            newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value);
            if (place.Attributes.GetNamedItem("Opacity") != null)
            {
                newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

            if (place.Attributes.GetNamedItem("Target") != null)
            {
                newPlace.Target = (SolarSystemObjects)Enum.Parse(typeof(SolarSystemObjects), place.Attributes.GetNamedItem("Target").Value);
            }

            if (place.Attributes.GetNamedItem("ViewTarget") != null)
            {
                newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value);
            }

            //if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null)
            //{
            //    newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value;
            //}

            XmlNode descriptionNode = Util.SelectSingleNode(place,"Description");
            if (descriptionNode != null)
            {
                newPlace.HtmlDescription = descriptionNode.Value;
            }

            XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet");
            if (backgroundImageSet != null)
            {
                XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet,"ImageSet");

                newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet);

            }

            XmlNode study = Util.SelectSingleNode(place,"ImageSet");
            if (study != null)
            {
                newPlace.studyImageset = Imageset.FromXMLNode(study);

            }
            return newPlace;
        }
Пример #19
0
 public bool OnTarget(Place place)
 {
     return (
             (
                 Math.Abs(ViewCamera.Lat - TargetCamera.Lat) < .000000000001
                 && Math.Abs(ViewCamera.Lng - TargetCamera.Lng) < .000000000001
                 && Math.Abs(ViewCamera.Zoom - TargetCamera.Zoom) < .000000000001
             )
             && ViewMover == null
         );
 }