Exemplo n.º 1
0
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[e.Item.Index];

                    // double ra = Convert.ToDouble(row[GetRAColumn().Name]) / 15;
                    // double dec = Convert.ToDouble(row[GetDecColumn().Name]);
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        private void listView1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                try
                {
                    VoRow  row = table.Rows[listView1.SelectedIndices[0]];
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString().ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.GotoTarget(pl, false, false, false);
                }
                catch
                {
                }
            }
        }
        public static void ShowAt(IImageSet imageSet, Point pnt)
        {
            TourPlace tp = new TourPlace(imageSet.Name, 0, 0, Classification.Unidentified, "", imageSet.DataSetType, 360);

            tp.BackgroundImageSet = imageSet;

            ShowAt(tp, pnt);
        }
        public static void ShowNofinder(IImageSet imageSet, Point pnt)
        {
            TourPlace tp = new TourPlace(imageSet.Name, 0, 0, Classification.Unidentified, "", imageSet.DataSetType, 360);

            tp.StudyImageset = imageSet;

            ShowNofinder(tp, pnt);
        }
Exemplo n.º 5
0
        private void PlacesList_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            TourPlace p = (TourPlace)this.PlacesList.SelectedItem;

            if (p != null)
            {
                this.txtName.Text = p.Name;

                this.txtLat.Text      = Coordinates.FormatDMS(p.Lat);
                this.txtLong.Text     = Coordinates.FormatDMS(p.Lng);
                this.txtAltitude.Text = p.Elevation.ToString();
            }
        }
Exemplo n.º 6
0
        //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);
        }
Exemplo n.º 7
0
        public IPlace HoverCheck(Vector3 searchPoint, IPlace defaultPlace, float distance)
        {
            searchPoint = -searchPoint;
            Vector3 dist;

            if (defaultPlace != null)
            {
                Vector3 testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0).Vector311;
                dist     = searchPoint - testPoint;
                distance = dist.Length();
            }

            int closestItem = -1;
            int index       = 0;

            foreach (Vector3 point in positions)
            {
                dist = searchPoint - point;
                if (dist.Length() < distance)
                {
                    distance    = dist.Length();
                    closestItem = index;
                }
                index++;
            }

            lastHoverIndex = closestItem;

            if (closestItem == -1)
            {
                return(defaultPlace);
            }

            Coordinates pnt  = Coordinates.CartesianToSpherical(positions[closestItem]);
            string      name = this.names[closestItem];

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            TourPlace place = new TourPlace(name, pnt.Dec, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            return(place);
        }
Exemplo n.º 8
0
        public void DisplaySearchResults(VoTable table)
        {
            searchResults.Clear();
            int count = 0;

            foreach (VoRow row in table.Rows)
            {
                double ra  = Convert.ToDouble(row["RA"]) / 15;
                double dec = Convert.ToDouble(row["DEC"]);

                TourPlace pl = new TourPlace(row["id"].ToString(), dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                searchResults.Add(pl);
                if (count++ > 200)
                {
                    break;
                }
            }
            UpdateMarkers();
        }
Exemplo n.º 9
0
        private int ParseResults(string data)
        {
            resultslist.Clear();

            XmlDocument doc   = new XmlDocument();
            int         index = 0;

            try
            {
                data = data.Substring(data.IndexOf("<?xml"));

                doc.LoadXml(data);

                XmlNode resources = doc["Response"]["ResourceSets"]["ResourceSet"]["Resources"];

                if (resources != null)
                {
                    foreach (XmlNode node in resources.ChildNodes)
                    {
                        if (node.Name == "Location")
                        {
                            index++;
                            string name = node["Name"].InnerText;
                            double lat  = double.Parse(node["Point"]["Latitude"].InnerText);
                            double lng  = double.Parse(node["Point"]["Longitude"].InnerText);
                            string type = node["EntityType"].InnerText;

                            TourPlace place = new TourPlace(name, lat, lng, Classification.Unidentified, "", ImageSetType.Earth, -1);

                            resultslist.Add((IPlace)place);
                        }
                    }
                }
            }
            catch
            {
            }
            return(index);
        }
Exemplo n.º 10
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[listView1.SelectedIndices[0]];

                    table.SelectedRow = row;
                    layer.CleanUp();
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);

                    if (table.SampId != null)
                    {
                        Earth3d.MainWindow.sampConnection.TableHighlightRow("", table.SampId, listView1.SelectedIndices[0]);
                    }
                }
                catch
                {
                }
            }
        }
 private void figureTree_NodeMouseHover(object sender, TreeNodeMouseHoverEventArgs e)
 {
     if (e.Node != null && e.Node.Tag is Linepoint)
     {
         if (e.Node.Tag is Linepoint)
         {
             Linepoint lp = (Linepoint)e.Node.Tag;
             //((Convert.ToDouble(line.Substring(0, 10)) / 24.0 * 360) - 180)
             TourPlace p = new TourPlace(lp.ToString(), (lp.RA + 180) / 360 * 24, lp.Dec, Classification.Unidentified, "", ImageSetType.Sky, -1);
             p.Distance = 1.0;
             //Earth3d.MainWindow.SetLabelText(lp.ToString(), (lp.RA + 180) / 360 * 24, lp.Dec, 1.0);
             Constellations.SelectedSegment = lp;
         }
     }
     else
     {
         if (e.Node.Checked)
         {
             Earth3d.MainWindow.SetLabelText(null, false);
             Constellations.SelectedSegment = null;
         }
     }
 }
Exemplo n.º 12
0
        internal static TourPlace FromAstroObjectsRow(AstroObjectsDataset.spGetAstroObjectsRow row)
        {
            TourPlace newPlace = new TourPlace();

            string seperator = "";

            string name = "";

            if (!row.IsPopularName1Null() && !String.IsNullOrEmpty(row.PopularName1))
            {
                name      = ProperCaps(row.PopularName1);
                seperator = ";";
            }

            if (!row.IsMessierNameNull() && !String.IsNullOrEmpty(row.MessierName))
            {
                name      = name + seperator + row.MessierName;
                seperator = ";";
            }

            if (!row.IsNGCNameNull() && !String.IsNullOrEmpty(row.NGCName))
            {
                name      = name + seperator + row.NGCName;
                seperator = ";";
            }

            newPlace.name           = name;
            newPlace.Type           = ImageSetType.Sky;
            newPlace.Lat            = row.Dec2000;
            newPlace.Lng            = row.Ra2000 / 15;
            newPlace.constellation  = Constellations.Abbreviation(row.ConstellationName);
            newPlace.Classification = Classification.Galaxy; //(Classification)Enum.Parse(typeof(Classification), place.Attributes["Classification"].Value);
            newPlace.magnitude      = row.IsVisualMagnitudeNull() ? row.VisualMagnitude : 0;
            newPlace.AngularSize    = 0;                     // todo fix this
            newPlace.ZoomLevel      = .00009;
            return(newPlace);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        public IPlace HoverCheck(Vector3 searchPoint, IPlace defaultPlace, float distance)
        {
            searchPoint = -searchPoint;
            Vector3 dist;
            if (defaultPlace != null)
            {
                var testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0).Vector311;
                dist = searchPoint - testPoint;
                distance = dist.Length();
            }

            var closestItem = -1;
            var index = 0;
            foreach (var point in positions)
            {
                dist = searchPoint - point;
                if (dist.Length() < distance)
                {
                    distance = dist.Length();
                    closestItem = index;
                }
                index++;
            }

            lastHoverIndex = closestItem;

            if (closestItem == -1)
            {
                return defaultPlace;
            }

            var pnt = Coordinates.CartesianToSpherical(positions[closestItem]);
            var name = names[closestItem];
            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            var place = new TourPlace(name, pnt.Dec, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);
            return place;
        }
        public static void ShowNofinder(IImageSet imageSet, Point pnt)
        {
            var tp = new TourPlace(imageSet.Name, 0, 0, Classification.Unidentified, "", imageSet.DataSetType, 360);
            tp.StudyImageset = imageSet;

            ShowNofinder(tp, pnt);
        }
Exemplo n.º 16
0
 public TourStop(TourPlace target)
 {
     this.target = target;
     id = Guid.NewGuid().ToString();
 }
Exemplo n.º 17
0
        private void renderWindow_MouseMove(object sender, MouseEventArgs e)
        {



            if (contrastMode)
            {
                contrast = (1 - (e.Y / (float)ClientSize.Height));
                brightness = e.X / (float)ClientSize.Width;
                return;
            }




            if (activeTouch != TouchControls.None)
            {
                if (activeTouch == TouchControls.TrackBall)
                {
                    moveVector = new PointF(touchTrackBallCenter.X - (e.X + Properties.Settings.Default.ScreenHitTestOffsetX), touchTrackBallCenter.Y - (e.Y + Properties.Settings.Default.ScreenHitTestOffsetY));
                }

                if (activeTouch == TouchControls.PanTrack)
                {
                    Vector2d panTrack = TouchToScreen(this.panTracker);


                    Vector2d mv = new Vector2d(panTrack.X - (e.X + Properties.Settings.Default.ScreenHitTestOffsetX), panTrack.Y - (e.Y + Properties.Settings.Default.ScreenHitTestOffsetY));

                    if (mv.Length > 50)
                    {
                        mv.Normalize();
                        mv.Scale(50);
                    }

                    moveVector = new PointF((float)mv.X, (float)mv.Y);


                }

                if (activeTouch == TouchControls.ZoomTrack)
                {
                    Vector2d zoomTrack = TouchToScreen(this.zoomTracker);
                    double zoomDrag = zoomTrack.X - (e.X + Properties.Settings.Default.ScreenHitTestOffsetX);
                    if (Math.Abs(zoomDrag) > 54)
                    {
                        ZoomVector = 54 * Math.Sign(zoomDrag);
                    }
                    else
                    {
                        ZoomVector = (float)zoomDrag;
                    }
                }

                if (activeTouch == TouchControls.OrbitTrack)
                {
                    Vector2d orbitTrack = TouchToScreen(this.orbitTracker);
                    double orbitDrag = orbitTrack.X - (e.X + Properties.Settings.Default.ScreenHitTestOffsetX);
                    if (Math.Abs(orbitDrag) > 70)
                    {
                        OrbitVector = 70 * Math.Sign(orbitDrag);
                    }
                    else
                    {
                        OrbitVector = (float)orbitDrag;
                    }
                }

                return;
            }


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

            moved = true;


            if (lastMousePosition == e.Location)
            {
                return;
            }
            else
            {
                mouseMoved = true;
                lastMouseMove = DateTime.Now;

                if (!CursorVisible && !ProjectorServer)
                {
                    Cursor.Show();
                    CursorVisible = true;
                }

            }

            if (measuringDrag)
            {
                measureEnd = GetCoordinatesForScreenPoint(e.X, e.Y);

                if (measureLines == null)
                {

                    measureLines = new SimpleLineList11();
                    measureLines.DepthBuffered = false;

                }
                measureLines.Clear();
                measureLines.AddLine(Coordinates.RADecTo3d(measureStart.RA + 12, measureStart.Dec, 1), Coordinates.RADecTo3d(measureEnd.RA + 12, measureEnd.Dec, 1));
                double angularSperation = CAAAngularSeparation.Separation(measureStart.RA, measureStart.Dec, measureEnd.RA, measureEnd.Dec);



                TourPlace pl = new TourPlace(Language.GetLocalizedText(977, "Seperation: ") + Coordinates.FormatDMS(angularSperation), measureEnd.Dec, measureEnd.RA, Classification.Star, Constellations.Containment.FindConstellationForPoint(measureEnd.RA, measureEnd.Dec), ImageSetType.Sky, -1);
                SetLabelText(pl, true);

            }
            else if (Space && Settings.Active.GalacticMode)
            {
                if (dragging)
                {
                    Tracking = false;

                    MoveView(-(e.X - this.mouseDownX), (e.Y - this.mouseDownY), true);
                    if (!Properties.Settings.Default.SmoothPan)
                    {
                        az = targetAz;
                        alt = targetAlt;
                        double[] gPoint = Coordinates.GalactictoJ2000(az, alt);
                        TargetLat = ViewLat = gPoint[1];
                        TargetLong = ViewLong = RAtoViewLng(gPoint[0] / 15);
                        NotifyMoveComplete();
                    }
                    this.mouseDownX = e.X;
                    this.mouseDownY = e.Y;
                }
                else if (spinning || angle)
                {

                    CameraRotateTarget = (CameraRotateTarget + (((double)(e.X - this.mouseDownX)) / 1000 * Math.PI));

                    CameraAngleTarget = (CameraAngleTarget + (((double)(e.Y - this.mouseDownY)) / 1000 * Math.PI));

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

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

                    if (!Properties.Settings.Default.SmoothPan)
                    {
                        CameraRotate = CameraRotateTarget;
                        CameraAngle = CameraAngleTarget;
                    }

                    this.mouseDownX = e.X;
                    this.mouseDownY = e.Y;
                }
                else
                {
                    mouseMoved = true;
                    lastMouseMove = DateTime.Now;
                }
            }
            else if (Space && Settings.Active.LocalHorizonMode)
            {
                if (dragging)
                {
                    if (!SolarSystemMode)
                    {
                        Tracking = false;
                    }

                    MoveView(-(e.X - this.mouseDownX), (e.Y - this.mouseDownY), true);
                    if (!Properties.Settings.Default.SmoothPan)
                    {
                        az = targetAz;
                        alt = targetAlt;
                        Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);

                        TargetLat = ViewLat = currentRaDec.Dec;
                        TargetLong = ViewLong = RAtoViewLng(currentRaDec.RA);
                        NotifyMoveComplete();
                    }
                    this.mouseDownX = e.X;
                    this.mouseDownY = e.Y;
                }
                else
                {
                    mouseMoved = true;
                    lastMouseMove = DateTime.Now;
                }
            }
            else
            {
                if (dragging)
                {
                    if (!SolarSystemMode)
                    {
                        Tracking = false;
                    }

                    MoveView(-(e.X - this.mouseDownX), (e.Y - this.mouseDownY), true);
                    if (!Properties.Settings.Default.SmoothPan)
                    {
                        ViewLat = TargetLat;
                        ViewLong = TargetLong;
                        NotifyMoveComplete();
                    }
                    this.mouseDownX = e.X;
                    this.mouseDownY = e.Y;
                }
                else if (spinning || angle)
                {

                    CameraRotateTarget = (CameraRotateTarget + (((double)(e.X - this.mouseDownX)) / 1000 * Math.PI));

                    CameraAngleTarget = (CameraAngleTarget + (((double)(e.Y - this.mouseDownY)) / 1000 * Math.PI));

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

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

                    if (!Properties.Settings.Default.SmoothPan)
                    {
                        CameraRotate = CameraRotateTarget;
                        CameraAngle = CameraAngleTarget;
                    }

                    this.mouseDownX = e.X;
                    this.mouseDownY = e.Y;
                }
                else
                {
                    mouseMoved = true;
                    lastMouseMove = DateTime.Now;

                }
            }

            lastMousePosition = e.Location;
        }
Exemplo n.º 18
0
        public ArrayList GetPlaceList()
        {
            if (dataList == null || CheckExpiration())
            {
                dataList = new System.Collections.ArrayList();
                if (dataSetType == DataSetType.Place)
                {
                    DataSetManager.DownloadFile(url, Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt", false, true);

                    TourPlace place;
                    StreamReader sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt");
                    string line;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        place = new TourPlace(line, sky);
                        dataList.Add(place);
                    }
                    sr.Close();
                }
                else if (dataSetType == DataSetType.Imageset)
                {

                    string filename = Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml";

                    DataSetManager.DownloadFile(url, filename, false, true);

                    XmlDocument doc = new XmlDocument();
                    doc.Load(filename);

                    if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"thumbnails\"))
                    {
                        Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"thumbnails\");
                    }

                    XmlNode imageSets = doc["ImageSets"];
                    if (imageSets == null)
                    {
                        imageSets = doc["Folder"];
                    }

                    foreach (XmlNode imageset in imageSets.ChildNodes)
                    {
                        ImageSetHelper newImageset = ImageSetHelper.FromXMLNode(imageset);
                        if (newImageset != null)
                        {
                            TourPlace newPlace = new TourPlace(newImageset.Name, (newImageset.CenterY), (newImageset.CenterX) / 15, Classification.Unidentified, "Err", ImageSetType.Sky, newImageset.BaseTileDegrees*10);
                            newPlace.StudyImageset = newImageset;

                            newPlace.ThumbNail = UiTools.LoadThumbnailFromWeb(newImageset.ThumbnailUrl);
                            dataList.Add(newPlace);
                            if (!String.IsNullOrEmpty(newImageset.AltUrl) && !Earth3d.ReplacementImageSets.ContainsKey(newImageset.AltUrl))
                            {
                                Earth3d.ReplacementImageSets.Add(newImageset.AltUrl, newImageset);
                            }
                        }

                    }
                }

            }
            return dataList;
        }
Exemplo n.º 19
0
        public override IPlace FindClosest(Coordinates target, float distance, IPlace defaultPlace, bool astronomical)
        {
            Vector3d searchPoint = Coordinates.GeoTo3dDouble(target.Lat, target.Lng);

            //searchPoint = -searchPoint;
            Vector3d dist;

            if (defaultPlace != null)
            {
                Vector3d testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0);
                dist     = searchPoint - testPoint;
                distance = (float)dist.Length();
            }

            int closestItem = -1;
            int index       = 0;

            foreach (Vector3 point in positions)
            {
                dist = searchPoint - new Vector3d(point);
                if (dist.Length() < distance)
                {
                    distance    = (float)dist.Length();
                    closestItem = index;
                }
                index++;
            }


            if (closestItem == -1)
            {
                return(defaultPlace);
            }

            Coordinates pnt = Coordinates.CartesianToSpherical2(positions[closestItem]);

            string name = table.Rows[closestItem].ColumnData[this.nameColumn].ToString();

            if (nameColumn == startDateColumn || nameColumn == endDateColumn)
            {
                name = SpreadSheetLayer.ParseDate(name).ToString("u");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            TourPlace place = new TourPlace(name, pnt.Lat, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            Dictionary <String, String> rowData = new Dictionary <string, string>();

            for (int i = 0; i < table.Columns.Count; i++)
            {
                string colValue = table.Rows[closestItem][i].ToString();
                if (i == startDateColumn || i == endDateColumn)
                {
                    colValue = SpreadSheetLayer.ParseDate(colValue).ToString("u");
                }

                if (!rowData.ContainsKey(table.Column[i].Name) && !string.IsNullOrEmpty(table.Column[i].Name))
                {
                    rowData.Add(table.Column[i].Name, colValue);
                }
                else
                {
                    rowData.Add("Column" + i.ToString(), colValue);
                }
            }
            place.Tag = rowData;
            if (Viewer != null)
            {
                Viewer.LabelClicked(closestItem);
            }
            return(place);
        }
Exemplo n.º 20
0
        public bool MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (Earth3d.MainWindow.StudyImageset == null)
            {
                mouseDown = false;
                return(false);
            }
            Tile root = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.StudyImageset, null);

            if (root == null)
            {
                mouseDown = false;
                return(false);
            }
            if (e.Button == MouseButtons.Right && (root is SkyImageTile))
            {
                anchored = !anchored;
                popup.SetPivotMode(anchored);
                if (anchored)
                {
                    anchoredPoint1 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                    TourPlace place = new TourPlace("", anchoredPoint1.Dec, anchoredPoint1.RA, Classification.Unidentified, "UMA", ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(place, false);
                    if (root is TangentTile)
                    {
                        TangentTile tile   = (TangentTile)root;
                        Vector3d    vector = tile.TransformPoint(12, 12);
                        vector = Coordinates.GeoTo3dDouble(anchoredPoint1.Lat, anchoredPoint1.Lng);
                        double x;
                        double y;
                        tile.UnTransformPoint(vector, out x, out y);
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchorPoint1 = tile.GetImagePixel(anchoredPoint1);
                    }
                }
                mouseDown = true;
                return(true);
            }
            else if (e.Button == MouseButtons.Left)
            {
                dragging = true;
                pntDown  = e.Location;
                if (anchored)
                {
                    if (root is TangentTile)
                    {
                        startRotation = Earth3d.MainWindow.StudyImageset.Rotation;
                        startCenterX  = Earth3d.MainWindow.StudyImageset.OffsetX;
                        startCenterY  = Earth3d.MainWindow.StudyImageset.OffsetY;
                        startScale    = Earth3d.MainWindow.StudyImageset.BaseTileDegrees;
                        Coordinates downPoint = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        startLength = anchoredPoint1.Distance(downPoint);
                        startAngle  = anchoredPoint1.Angle(downPoint) / RC;
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchoredPoint2 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        anchorPoint2   = tile.GetImagePixel(anchoredPoint2);
                    }
                }
                mouseDown = true;
                return(true);
            }
            else
            {
                mouseDown = false;
                return(false);
            }
        }
Exemplo n.º 21
0
        public ArrayList GetPlaceList()
        {
            if (dataList == null || CheckExpiration())
            {
                dataList = new System.Collections.ArrayList();
                if (dataSetType == DataSetType.Place)
                {
                    DataSetManager.DownloadFile(url, Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt", false, true);


                    TourPlace    place;
                    StreamReader sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt");
                    string       line;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        place = new TourPlace(line, sky);
                        dataList.Add(place);
                    }
                    sr.Close();
                }
                else if (dataSetType == DataSetType.Imageset)
                {
                    string filename = Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml";

                    DataSetManager.DownloadFile(url, filename, false, true);



                    XmlDocument doc = new XmlDocument();
                    doc.Load(filename);

                    if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"thumbnails\"))
                    {
                        Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"thumbnails\");
                    }

                    XmlNode imageSets = doc["ImageSets"];
                    if (imageSets == null)
                    {
                        imageSets = doc["Folder"];
                    }

                    foreach (XmlNode imageset in imageSets.ChildNodes)
                    {
                        ImageSetHelper newImageset = ImageSetHelper.FromXMLNode(imageset);
                        if (newImageset != null)
                        {
                            TourPlace newPlace = new TourPlace(newImageset.Name, (newImageset.CenterY), (newImageset.CenterX) / 15, Classification.Unidentified, "Err", ImageSetType.Sky, newImageset.BaseTileDegrees * 10);
                            newPlace.StudyImageset = newImageset;

                            newPlace.ThumbNail = UiTools.LoadThumbnailFromWeb(newImageset.ThumbnailUrl);
                            dataList.Add(newPlace);
                            if (!String.IsNullOrEmpty(newImageset.AltUrl) && !Earth3d.ReplacementImageSets.ContainsKey(newImageset.AltUrl))
                            {
                                Earth3d.ReplacementImageSets.Add(newImageset.AltUrl, newImageset);
                            }
                        }
                    }
                }
            }
            return(dataList);
        }
        private void figureTree_NodeMouseHover(object sender, TreeNodeMouseHoverEventArgs e)
        {
            if (e.Node != null && e.Node.Tag is Linepoint)
            {
                if (e.Node.Tag is Linepoint)
                {
                    var lp = (Linepoint)e.Node.Tag;
                    //((Convert.ToDouble(line.Substring(0, 10)) / 24.0 * 360) - 180)
                    var p = new TourPlace(lp.ToString(), (lp.RA + 180) / 360 * 24, lp.Dec, Classification.Unidentified, "", ImageSetType.Sky, -1);
                    p.Distance = 1.0;
                    //Earth3d.MainWindow.SetLabelText(lp.ToString(), (lp.RA + 180) / 360 * 24, lp.Dec, 1.0);
                    Constellations.SelectedSegment = lp;

                }
            }
            else
            {
                if (e.Node.Checked)
                {
                    Earth3d.MainWindow.SetLabelText(null, false);
                    Constellations.SelectedSegment = null;
                }
            }
        }
Exemplo n.º 23
0
        internal static TourPlace FromXml(XmlNode place)
        {
            TourPlace newPlace = new TourPlace();

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

            newPlace.constellation = place.Attributes["Constellation"].Value;
            newPlace.Classification = (Classification)Enum.Parse(typeof(Classification), place.Attributes["Classification"].Value);
            newPlace.magnitude = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            if (place.Attributes["Magnitude"] != null)
            {
                newPlace.magnitude = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            }
            newPlace.AngularSize = Convert.ToDouble(place.Attributes["AngularSize"].Value);
            newPlace.ZoomLevel = Convert.ToDouble(place.Attributes["ZoomLevel"].Value);
            newPlace.camParams.Rotation = Convert.ToDouble(place.Attributes["Rotation"].Value);
            newPlace.camParams.Angle = Convert.ToDouble(place.Attributes["Angle"].Value);
            if (place.Attributes["Opacity"] != null)
            {
                newPlace.camParams.Opacity = Convert.ToSingle(place.Attributes["Opacity"].Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

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

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

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

            if (place.Attributes["DomeAlt"] != null)
            {
                newPlace.camParams.DomeAlt = Convert.ToDouble(place.Attributes["DomeAlt"].Value);
            }

            if (place.Attributes["DomeAz"] != null)
            {
                newPlace.camParams.DomeAz = Convert.ToDouble(place.Attributes["DomeAz"].Value);
            }

            XmlNode descriptionNode = place["Description"];
            if (descriptionNode != null)
            {
                newPlace.HtmlDescription = descriptionNode.Value;
            }

            XmlNode backgroundImageSet = place["BackgroundImageSet"];
            if (backgroundImageSet != null)
            {
                XmlNode imageSet = backgroundImageSet["ImageSet"];

                ImageSetHelper ish = ImageSetHelper.FromXMLNode(imageSet);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.backgroundImageSet = Earth3d.ReplacementImageSets[ish.Url];
                }
                else
                {
                    newPlace.backgroundImageSet = ish;
                }
            }

            XmlNode study = place["ImageSet"];
            if (study != null)
            {
                ImageSetHelper ish = ImageSetHelper.FromXMLNode(study);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.studyImageset = Earth3d.ReplacementImageSets[ish.Url];

                }
                else
                {
                    newPlace.studyImageset = ish;
                }
            }
            return newPlace;
        }
Exemplo n.º 24
0
        internal static TourPlace FromAstroObjectsRow(AstroObjectsDataset.spGetAstroObjectsRow row)
        {
            TourPlace newPlace = new TourPlace();

            string seperator = "";

            string name = "";

            if (!row.IsPopularName1Null() && !String.IsNullOrEmpty(row.PopularName1) )
            {
                name = ProperCaps(row.PopularName1);
                seperator = ";";
            }

            if (!row.IsMessierNameNull() && !String.IsNullOrEmpty(row.MessierName))
            {
                name = name + seperator + row.MessierName;
                seperator = ";";
            }

            if (!row.IsNGCNameNull() && !String.IsNullOrEmpty(row.NGCName))
            {
                name = name + seperator + row.NGCName;
                seperator = ";";
            }

            newPlace.name = name;
            newPlace.Type = ImageSetType.Sky;
            newPlace.Lat = row.Dec2000;
            newPlace.Lng = row.Ra2000/15;
            newPlace.constellation = Constellations.Abbreviation(row.ConstellationName);
            newPlace.Classification = Classification.Galaxy; //(Classification)Enum.Parse(typeof(Classification), place.Attributes["Classification"].Value);
            newPlace.magnitude = row.IsVisualMagnitudeNull() ? row.VisualMagnitude : 0;
            newPlace.AngularSize = 0; // todo fix this
            newPlace.ZoomLevel = .00009;
            return newPlace;
        }
Exemplo n.º 25
0
        public void AddClidrenToStack(Folder folder, bool showFirstAsBackground)
        {

            foreach (object o in folder.Children)
            {
                if (o is Folder)
                {
                    AddClidrenToStack((Folder)o, false);
                }
                else
                {
                    if (o is Place)
                    {
                        if (showFirstAsBackground && firstImageLoaded)
                        {
                            SetCurrentBackgroundForStack((Place)o);
                        }
                        else
                        {
                            AddPlaceToStack((Place)o, false);
                        }
                    }
                    else if (o is IImageSet)
                    {
                        IImageSet imageSet = (IImageSet)o;
                        TourPlace tp = new TourPlace(imageSet.Name, imageSet.CenterX, imageSet.CenterY, Classification.Unidentified, "", imageSet.DataSetType, 360);
                        if (showFirstAsBackground && firstImageLoaded)
                        {
                            SetCurrentBackgroundForStack(tp);
                        }
                        else
                        {
                            AddPlaceToStack(tp, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
        private void LoadImage(string filename)
        {
            WcsImage wcsImage = WcsImage.FromFile(filename);

            bool hasAvm = wcsImage.ValidWcs;
            {
                Bitmap bmp = wcsImage.GetBitmap();
                wcsImage.AdjustScale(bmp.Width, bmp.Height);

                ImageSetHelper imageSet = null;
                TourPlace place = null;
                if (hasAvm)
                {
                    imageSet = new ImageSetHelper(wcsImage.Description, filename, ImageSetType.Sky, BandPass.Visible, ProjectionType.SkyImage, Math.Abs(filename.GetHashCode32()), 0, 0, 256, wcsImage.ScaleY, ".tif", wcsImage.ScaleX > 0, "", wcsImage.CenterX, wcsImage.CenterY, wcsImage.Rotation, false, "", false, false, 1, wcsImage.ReferenceX, wcsImage.ReferenceY, wcsImage.Copyright, wcsImage.CreditsUrl, "", "", 0, "");
                    place = new TourPlace(UiTools.GetNamesStringFromArray(wcsImage.Keywords.ToArray()), wcsImage.CenterY, wcsImage.CenterX / 15, Classification.Unidentified, constellationCheck.FindConstellationForPoint(wcsImage.CenterX, wcsImage.CenterY), ImageSetType.Sky, -1);
                }
                else
                {

                    imageSet = new ImageSetHelper(wcsImage.Description, filename, ImageSetType.Sky, BandPass.Visible, ProjectionType.SkyImage, Math.Abs(filename.GetHashCode32()), 0, 0, 256, .001, ".tif", false, "", RA * 15, ViewLat, 0, false, "", false, false, 1, bmp.Width / 2, bmp.Height / 2, wcsImage.Copyright, wcsImage.CreditsUrl, "", "", 0, "");
                    place = new TourPlace(UiTools.GetNamesStringFromArray(wcsImage.Keywords.ToArray()), this.ViewLat, RA, Classification.Unidentified, constellationCheck.FindConstellationForPoint(wcsImage.CenterX, wcsImage.CenterY), ImageSetType.Sky, -1);
                }
                imageSet.WcsImage = wcsImage;
                place.StudyImageset = imageSet;
                place.Tag = wcsImage;
                Place pl = Place.FromIPlace(place);

                pl.ThumbNail = UiTools.MakeThumbnail(bmp);
                StudyImageset = pl.StudyImageset;
                GotoTarget(pl, false, false, true);



                explorePane.OpenImages.AddChildPlace(pl);

                bmp.Dispose();
                GC.SuppressFinalize(bmp);
                bmp = null;

                explorePane.ShowOpenImages();

            }
            if (!hasAvm)
            {
                MessageBox.Show(Language.GetLocalizedText(112, "The image file did not contain recognizable WCS or AVM Metadata to position it in the sky"), Language.GetLocalizedText(113, "Load Image"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 27
0
        public void DisplaySearchResults(VoTable table)
        {
            searchResults.Clear();
            var count = 0;
            foreach(var row in table.Rows)
            {
                var ra = Convert.ToDouble(row["RA"])/15;
                var dec = Convert.ToDouble(row["DEC"]);

                var pl = new TourPlace(row["id"].ToString(), dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                searchResults.Add( pl);
                if (count++ > 200)
                {
                    break;
                }
            }
            UpdateMarkers();
        }
Exemplo n.º 28
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);
                        }
                    }
                }
            }
        }
        public bool MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (Earth3d.MainWindow.StudyImageset == null)
            {
                mouseDown = false;
                return false;
            }
            Tile root = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.StudyImageset, null);
            if (root == null)
            {
                mouseDown = false;
                return false;
            }
            if (e.Button == MouseButtons.Right && (root is SkyImageTile))
            {
                anchored = !anchored;
                popup.SetPivotMode(anchored);
                if (anchored)
                {
                    anchoredPoint1 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                    TourPlace place = new TourPlace("", anchoredPoint1.Dec, anchoredPoint1.RA, Classification.Unidentified, "UMA", ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(place, false);
                    if (root is TangentTile)
                    {
                        TangentTile tile = (TangentTile)root;
                        Vector3d vector = tile.TransformPoint(12, 12);
                        vector = Coordinates.GeoTo3dDouble(anchoredPoint1.Lat, anchoredPoint1.Lng);
                        double x;
                        double y;
                        tile.UnTransformPoint(vector, out x, out y);
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchorPoint1 = tile.GetImagePixel(anchoredPoint1);
                    }
                }
                mouseDown = true;
                return true;
            }
            else if (e.Button == MouseButtons.Left)
            {
                dragging = true;
                pntDown = e.Location;
                if (anchored)
                {
                    if (root is TangentTile)
                    {
                        startRotation = Earth3d.MainWindow.StudyImageset.Rotation;
                        startCenterX = Earth3d.MainWindow.StudyImageset.OffsetX;
                        startCenterY = Earth3d.MainWindow.StudyImageset.OffsetY;
                        startScale = Earth3d.MainWindow.StudyImageset.BaseTileDegrees;
                        Coordinates downPoint = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        startLength = anchoredPoint1.Distance(downPoint);
                        startAngle = anchoredPoint1.Angle(downPoint) / RC;
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchoredPoint2 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        anchorPoint2 = tile.GetImagePixel(anchoredPoint2);

                    }
                }
                mouseDown = true;
                return true;
            }
            else
            {
                mouseDown = false;
                return false;
            }
        }
        public static void ShowAt(IImageSet imageSet, Point pnt)
        {
            var tp = new TourPlace(imageSet.Name, 0, 0, Classification.Unidentified, "", imageSet.DataSetType, 360);
            tp.BackgroundImageSet = imageSet;

            ShowAt(tp, pnt);
        }
Exemplo n.º 31
0
        void setEndSkyPosition_Click(object sender, EventArgs e)
        {
            if (tour.CurrentTourStop != null)
            {
                //todo localize
                Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(435, "Set End Camera Position"), tour));

                var newPlace = new TourPlace("End Place", Earth3d.MainWindow.viewCamera, Classification.Unidentified, Earth3d.MainWindow.Constellation, Earth3d.MainWindow.CurrentImageSet.DataSetType, Earth3d.MainWindow.SolarSystemTrack);
                tour.CurrentTourStop.EndTarget = newPlace;
                tour.CurrentTourStop.EndTarget.Constellation = Earth3d.MainWindow.Constellation;
                tour.CurrentTourStop.EndTime = SpaceTimeController.Now;
                tour.CurrentTourStop.SetEndKeyFrames();
                tour.CurrentTourStop.TweenPosition = 1f;
                foreach (var info in tour.CurrentTourStop.Layers.Values)
                {
                    if (LayerManager.LayerList.ContainsKey(info.ID))
                    {
                        info.EndOpacity = LayerManager.LayerList[info.ID].Opacity;
                        info.EndParams = LayerManager.LayerList[info.ID].GetParams();
                    }
                }
                tour.CurrentTourStop.UpdateLayerOpacity();

                tourStopList.Refresh();
                TimeLine.RefreshUi();
                TourEditorUI.ClearSelection();
            }
        }
        public override IPlace FindClosest(Coordinates target, float distance, IPlace closestPlace, bool astronomical)
        {
            var pointFound = false;
            var pointIndex = -1;
            var target3d = Coordinates.GeoTo3dDouble(target.Lat, target.Lng, 1);

            for (var i = 0; i < shapefile.Shapes.Count; i++)
            {
                if (shapefile.Shapes[i] is ComplexShape)
                {
                    var p = (ComplexShape)shapefile.Shapes[i];

                    if (PointInboundingBox(target, p.BoundingBox))
                    {
                        if (p.Attributes != null && p.Attributes.ItemArray.GetLength(0) > 0)
                        {
                            var nameCol = GetNameColumn();
                            if (nameCol == -1)
                            {
                                nameCol = 0;
                            }

                            var place = new TourPlace(p.Attributes.ItemArray[nameCol].ToString(), (p.BoundingBox[1] + p.BoundingBox[3]) / 2, (p.BoundingBox[0] + p.BoundingBox[2]) / 2, Classification.Unidentified, "", ImageSetType.Earth, -1);

                            var rowData = new Dictionary<string, string>();
                            for (var r = 0; r < p.Attributes.ItemArray.GetLength(0); r++)
                            {

                                rowData.Add(p.Attributes.Table.Columns[r].ColumnName, p.Attributes.ItemArray[r].ToString());

                            }
                            place.Tag = rowData;
                            return place;
                        }
                        return closestPlace;

                    }
                }

                else if (shapefile.Shapes[i].GetType() == typeof(Point))
                {
                    var p = (Point)shapefile.Shapes[i];

                    var point = Coordinates.GeoTo3dDouble(p.Y, p.X, 1);
                    var dist = target3d - point;

                    if (dist.Length() < distance)
                    {
                        pointFound = true;
                        pointIndex = i;
                        distance = (float)dist.Length();
                    }

                }

            }

            if (pointFound)
            {
                var p = (Point)shapefile.Shapes[pointIndex];
                if (p.Attributes.ItemArray.GetLength(0) > 0)
                {
                    var place = new TourPlace(p.Attributes.ItemArray[0].ToString(), p.Y, p.X, Classification.Unidentified, "", ImageSetType.Earth, -1);

                    var rowData = new Dictionary<string, string>();
                    for (var r = 0; r < p.Attributes.ItemArray.GetLength(0); r++)
                    {

                        rowData.Add(p.Attributes.Table.Columns[r].ColumnName, p.Attributes.ItemArray[r].ToString());

                    }
                    place.Tag = rowData;
                    return place;
                }
            }
            return closestPlace;
        }
Exemplo n.º 33
0
        private void AddSlide(bool insert)
        {
            //todo localize
            Undo.Push(new UndoTourSlidelistChange(Language.GetLocalizedText(426, "Add New Slide"), tour));

            Cursor.Current = Cursors.WaitCursor;
            var placeName = "Current Screen";
            var newPlace = new TourPlace(placeName, Earth3d.MainWindow.viewCamera, Classification.Unidentified, Earth3d.MainWindow.Constellation, Earth3d.MainWindow.CurrentImageSet.DataSetType, Earth3d.MainWindow.SolarSystemTrack);
            newPlace.ThumbNail = null;
            newPlace.StudyImageset = Earth3d.MainWindow.StudyImageset;
            newPlace.BackgroundImageSet = Earth3d.MainWindow.CurrentImageSet.StockImageSet;

            var newTourStop = new TourStop(newPlace);

            if (insert)
            {
                tour.InsertTourStop(newTourStop);
            }
            else
            {
                tour.AddTourStop(newTourStop);
            }

            if (tour.CurrentTourStop != null)
            {
                MusicTrack.Target = tour.CurrentTourStop;
                VoiceTrack.Target = tour.CurrentTourStop;
            }
            else
            {
                MusicTrack.Target = null;
                VoiceTrack.Target = null;

            }
            tour.CurrentTourStop.Layers = LayerManager.GetVisibleLayerList(tour.CurrentTourStop.Layers);

            newTourStop.Thumbnail = newPlace.ThumbNail = Earth3d.MainWindow.GetScreenThumbnail();

            tourStopList.SelectedItem = tourStopList.FindItem(newTourStop);
            tourStopList.Refresh();
            TourEditorUI.ClearSelection();
            Cursor.Current = Cursors.Default;
            TimeLine.RefreshUi();
        }
Exemplo n.º 34
0
        internal static TourPlace FromXml(XmlNode place)
        {
            TourPlace newPlace = new TourPlace();

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

            newPlace.constellation  = place.Attributes["Constellation"].Value;
            newPlace.Classification = (Classification)Enum.Parse(typeof(Classification), place.Attributes["Classification"].Value);
            newPlace.magnitude      = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            if (place.Attributes["Magnitude"] != null)
            {
                newPlace.magnitude = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            }
            newPlace.AngularSize        = Convert.ToDouble(place.Attributes["AngularSize"].Value);
            newPlace.ZoomLevel          = Convert.ToDouble(place.Attributes["ZoomLevel"].Value);
            newPlace.camParams.Rotation = Convert.ToDouble(place.Attributes["Rotation"].Value);
            newPlace.camParams.Angle    = Convert.ToDouble(place.Attributes["Angle"].Value);
            if (place.Attributes["Opacity"] != null)
            {
                newPlace.camParams.Opacity = Convert.ToSingle(place.Attributes["Opacity"].Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

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

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

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

            if (place.Attributes["DomeAlt"] != null)
            {
                newPlace.camParams.DomeAlt = Convert.ToDouble(place.Attributes["DomeAlt"].Value);
            }

            if (place.Attributes["DomeAz"] != null)
            {
                newPlace.camParams.DomeAz = Convert.ToDouble(place.Attributes["DomeAz"].Value);
            }

            XmlNode descriptionNode = place["Description"];

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

            XmlNode backgroundImageSet = place["BackgroundImageSet"];

            if (backgroundImageSet != null)
            {
                XmlNode imageSet = backgroundImageSet["ImageSet"];

                ImageSetHelper ish = ImageSetHelper.FromXMLNode(imageSet);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.backgroundImageSet = Earth3d.ReplacementImageSets[ish.Url];
                }
                else
                {
                    newPlace.backgroundImageSet = ish;
                }
            }

            XmlNode study = place["ImageSet"];

            if (study != null)
            {
                ImageSetHelper ish = ImageSetHelper.FromXMLNode(study);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.studyImageset = Earth3d.ReplacementImageSets[ish.Url];
                }
                else
                {
                    newPlace.studyImageset = ish;
                }
            }
            return(newPlace);
        }
        private int ParseResults(string data)
        {
            resultslist.Clear();

            XmlDocument doc = new XmlDocument();
            int index = 0;
            try
            {
                data = data.Substring(data.IndexOf("<?xml"));

                doc.LoadXml(data);

                XmlNode resources = doc["Response"]["ResourceSets"]["ResourceSet"]["Resources"];

                if (resources != null)
                {
                    foreach (XmlNode node in resources.ChildNodes)
                    {
                        if (node.Name == "Location")
                        {
                            index++;
                            string name = node["Name"].InnerText;
                            double lat = double.Parse(node["Point"]["Latitude"].InnerText);
                            double lng = double.Parse(node["Point"]["Longitude"].InnerText);
                            string type = node["EntityType"].InnerText;

                            TourPlace place = new TourPlace(name, lat, lng,  Classification.Unidentified, "", ImageSetType.Earth, -1);

                            resultslist.Add((IPlace)place);
                        }
                    }
                }

            }
            catch
            {
            }
            return index;
        }
Exemplo n.º 36
0
        public override IPlace FindClosest(Coordinates target, float distance, IPlace defaultPlace, bool astronomical)
        {
            var searchPoint = Coordinates.GeoTo3dDouble(target.Lat, target.Lng);

            //searchPoint = -searchPoint;
            Vector3d dist;
            if (defaultPlace != null)
            {
                var testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0);
                dist = searchPoint - testPoint;
                distance = (float)dist.Length();
            }

            var closestItem = -1;
            var index = 0;
            foreach (var point in positions)
            {
                dist = searchPoint - new Vector3d(point);
                if (dist.Length() < distance)
                {
                    distance = (float)dist.Length();
                    closestItem = index;
                }
                index++;
            }

            if (closestItem == -1)
            {
                return defaultPlace;
            }

            var pnt = Coordinates.CartesianToSpherical2(positions[closestItem]);

            var name = table.Rows[closestItem].ColumnData[nameColumn].ToString();
            if (nameColumn == startDateColumn || nameColumn == endDateColumn)
            {
                name = SpreadSheetLayer.ParseDate(name).ToString("u");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            var place = new TourPlace(name, pnt.Lat, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            var rowData = new Dictionary<string, string>();
            for (var i = 0; i < table.Columns.Count; i++)
            {
                var colValue = table.Rows[closestItem][i].ToString();
                if (i == startDateColumn || i == endDateColumn)
                {
                    colValue = SpreadSheetLayer.ParseDate(colValue).ToString("u");
                }

                if (!rowData.ContainsKey(table.Column[i].Name) && !string.IsNullOrEmpty(table.Column[i].Name))
                {
                    rowData.Add(table.Column[i].Name, colValue);
                }
                else
                {
                    rowData.Add("Column" + i, colValue);
                }
            }
            place.Tag = rowData;
            if (Viewer != null)
            {
                Viewer.LabelClicked(closestItem);
            }
            return place;
        }
Exemplo n.º 37
0
        void ShowPropertiesForPoint(Point pntCenter)
        {
            if (contextPanel != null)
            {
                // TODO fix this for earth, plantes, panoramas
                Coordinates result = GetCoordinatesForScreenPoint(pntCenter.X, pntCenter.Y);
                string constellation = this.constellationCheck.FindConstellationForPoint(result.RA, result.Dec);
                contextPanel.Constellation = Constellations.FullName(constellation);
                IPlace closetPlace = ContextSearch.FindClosestMatch(constellation, result.RA, result.Dec, ZoomFactor / 1300);

                if (closetPlace == null)
                {
                    closetPlace = new TourPlace(Language.GetLocalizedText(90, "No Object"), result.Dec, result.RA, Classification.Unidentified, constellation, ImageSetType.Sky, -1);
                }

                ShowPropertiesMenu(closetPlace, pntCenter);
            }
        }
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                VoRow row = table.Rows[listView1.SelectedIndices[0]];
                double ra = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                string id;

                VoColumn col = table.GetColumnByUcd("meta.id");
                if (col != null)
                {
                    id = row[col.Name].ToString();
                }
                else
                {
                    id = row[0].ToString();
                }

                TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                Earth3d.MainWindow.GotoTarget(pl, false, true, false);
            }
        }
Exemplo n.º 39
0
        private void BrowseList_ItemContextMenu(object sender, object e)
        {
            var thumb = breadcrumbs.Peek();
            var readOnly = true;

            if (thumb is Folder)
            {
                var owner = (Folder)thumb;
                readOnly = owner.ReadOnly;
            }

            thumb = e as IThumbnail;

            if (thumb.IsCloudCommunityItem)
            {
                if (e is Folder)
                {
                    ShowCloudCommunitiesFolderContextMenu(e as Folder);
                }
                else
                {
                    ShowCloudCommunitiesItemContextMenu(e as IThumbnail);
                }

                return;
            }

            var pntClick = Cursor.Position;
            var ta = breadcrumbs.ToArray();
            if (e is IImageSet)
            {
                var imageSet = (IImageSet)e;
                var tp = new TourPlace(imageSet.Name, imageSet.CenterX,imageSet.CenterY, Classification.Unidentified, "", imageSet.DataSetType, 360);
                tp.StudyImageset = imageSet;
                Earth3d.MainWindow.ShowContextMenu(tp, Earth3d.MainWindow.PointToClient(Cursor.Position), true, readOnly);

            }
            else if (e is IPlace)
            {
                if (breadcrumbs.Count > 1 && ta[0].Name == Language.GetLocalizedText(222, "Open Images"))
                {
                    readOnly = false;
                }
                //if (breadcrumbs.Count > 1 && ta[0].Name == Language.GetLocalizedText(222, "Open Images"))
                //{
                //    ShowOpenImageMenu((Place)e);
                //}
                //else
                {
                    Earth3d.MainWindow.ShowContextMenu((IPlace)e, Earth3d.MainWindow.PointToClient(Cursor.Position), true, readOnly);
                }
            }
            else if (e is Folder)
            {
                if (breadcrumbs.Count > 1 && ta[0].Name == Language.GetLocalizedText(223, "Open Collections"))
                {
                    ShowOpenFolderMenu((Folder)e);
                }
                else
                {
                    ShowFolderMenu((Folder)e);
                }
            }
            if (e is Tour)
            {
                // TODO (Diego): fix
                var p = (Tour)e;
                if (p.IsTour)
                    ShowTourMenu(p);
            }
        }
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[e.Item.Index];

                    // double ra = Convert.ToDouble(row[GetRAColumn().Name]) / 15;
                    // double dec = Convert.ToDouble(row[GetDecColumn().Name]);
                    double ra = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);
                }
                catch
                {
                }

            }
        }
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[listView1.SelectedIndices[0]];

                    table.SelectedRow = row;
                    layer.CleanUp();
                    double ra = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);

                    if (table.SampId != null)
                    {
                        Earth3d.MainWindow.sampConnection.TableHighlightRow("", table.SampId, listView1.SelectedIndices[0]);
                    }
                }
                catch
                {
                }

            }
        }
Exemplo n.º 42
0
 //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);
 }
Exemplo n.º 43
0
        public override IPlace FindClosest(Coordinates target, float distance, IPlace closestPlace, bool astronomical)
        {
            bool     pointFound = false;
            int      pointIndex = -1;
            Vector3d target3d   = Coordinates.GeoTo3dDouble(target.Lat, target.Lng, 1);

            for (int i = 0; i < shapefile.Shapes.Count; i++)
            {
                if (shapefile.Shapes[i] is ComplexShape)
                {
                    ComplexShape p = (ComplexShape)shapefile.Shapes[i];

                    if (PointInboundingBox(target, p.BoundingBox))
                    {
                        if (p.Attributes != null && p.Attributes.ItemArray.GetLength(0) > 0)
                        {
                            int nameCol = GetNameColumn();
                            if (nameCol == -1)
                            {
                                nameCol = 0;
                            }

                            TourPlace place = new TourPlace(p.Attributes.ItemArray[nameCol].ToString(), (p.BoundingBox[1] + p.BoundingBox[3]) / 2, (p.BoundingBox[0] + p.BoundingBox[2]) / 2, Classification.Unidentified, "", ImageSetType.Earth, -1);

                            Dictionary <String, String> rowData = new Dictionary <string, string>();
                            for (int r = 0; r < p.Attributes.ItemArray.GetLength(0); r++)
                            {
                                rowData.Add(p.Attributes.Table.Columns[r].ColumnName, p.Attributes.ItemArray[r].ToString());
                            }
                            place.Tag = rowData;
                            return(place);
                        }
                        return(closestPlace);
                    }
                }

                else if (shapefile.Shapes[i].GetType() == typeof(ShapefileTools.Point))
                {
                    ShapefileTools.Point p = (ShapefileTools.Point)shapefile.Shapes[i];

                    Vector3d point = Coordinates.GeoTo3dDouble(p.Y, p.X, 1);
                    Vector3d dist  = target3d - point;

                    if (dist.Length() < distance)
                    {
                        pointFound = true;
                        pointIndex = i;
                        distance   = (float)dist.Length();
                    }
                }
            }

            if (pointFound)
            {
                ShapefileTools.Point p = (ShapefileTools.Point)shapefile.Shapes[pointIndex];
                if (p.Attributes.ItemArray.GetLength(0) > 0)
                {
                    TourPlace place = new TourPlace(p.Attributes.ItemArray[0].ToString(), p.Y, p.X, Classification.Unidentified, "", ImageSetType.Earth, -1);

                    Dictionary <String, String> rowData = new Dictionary <string, string>();
                    for (int r = 0; r < p.Attributes.ItemArray.GetLength(0); r++)
                    {
                        rowData.Add(p.Attributes.Table.Columns[r].ColumnName, p.Attributes.ItemArray[r].ToString());
                    }
                    place.Tag = rowData;
                    return(place);
                }
            }
            return(closestPlace);
        }