private static void AddAllMaps(Dictionary <string, LayerMap> maps, String parent) { foreach (String key in maps.Keys) { LayerMap map = maps[key]; map.Frame.Parent = parent; AllMaps[map.Name] = map; AddAllMaps(map.ChildMaps, map.Name); } }
private List <ReferenceFrame> GetReferenceFrameList() { List <ReferenceFrame> list = new List <ReferenceFrame>(); foreach (string key in LayerManager.AllMaps.Keys) { LayerMap lm = LayerManager.AllMaps[key]; if ((lm.Frame.Reference == ReferenceFrames.Custom || lm.Frame.Reference == ReferenceFrames.Identity) && !list.Contains(lm.Frame) && lm.Frame.SystemGenerated == false) { list.Add(lm.Frame); } } return(list); }
public static void ConnectAllChildren() { foreach (String key in AllMaps.Keys) { LayerMap map = AllMaps[key]; if (String.IsNullOrEmpty(map.Frame.Parent) && !LayerMaps.ContainsKey(map.Frame.Name)) { LayerMaps[map.Name] = map; } else if (!String.IsNullOrEmpty(map.Frame.Parent) && AllMaps.ContainsKey(map.Frame.Parent)) { if (!AllMaps[map.Frame.Parent].ChildMaps.ContainsKey(map.Frame.Name)) { AllMaps[map.Frame.Parent].ChildMaps[map.Frame.Name] = map; } } } }
private static void AddMoons(string file) { string[] data = file.Split("\r\n"); bool first = true; foreach (string line in data) { if (first) { first = false; continue; } string[] parts = line.Split("\t"); string planet = parts[0]; LayerMap frame = new LayerMap(parts[2], ReferenceFrames.Custom); frame.Frame.SystemGenerated = true; frame.Frame.Epoch = double.Parse(parts[1]); frame.Frame.SemiMajorAxis = double.Parse(parts[3]) * 1000; frame.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital; frame.Frame.Inclination = double.Parse(parts[7]); frame.Frame.LongitudeOfAscendingNode = double.Parse(parts[8]); frame.Frame.Eccentricity = double.Parse(parts[4]); frame.Frame.MeanAnomolyAtEpoch = double.Parse(parts[6]); frame.Frame.MeanDailyMotion = double.Parse(parts[9]); frame.Frame.ArgumentOfPeriapsis = double.Parse(parts[5]); frame.Frame.Scale = 1; frame.Frame.SemiMajorAxisUnits = AltUnits.Meters; frame.Frame.MeanRadius = double.Parse(parts[16]) * 1000; frame.Frame.RotationalPeriod = double.Parse(parts[17]); frame.Frame.ShowAsPoint = false; frame.Frame.ShowOrbitPath = true; frame.Frame.RepresentativeColor = Color.FromArgb(255, 144, 238, 144); frame.Frame.Oblateness = 0; LayerMaps["Sun"].ChildMaps[planet] = frame; AllMaps.Clear(); AddAllMaps(LayerMaps, null); } }
internal static void CloseAllTourLoadedLayers() { List <Guid> purgeTargets = new List <Guid>(); foreach (Guid key in LayerList.Keys) { Layer layer = LayerList[key]; if (layer.LoadedFromTour) { purgeTargets.Add(layer.ID); } } foreach (Guid guid in purgeTargets) { DeleteLayerByID(guid, true, false); } List <string> purgeMapsNames = new List <string>(); foreach (String key in AllMaps.Keys) { LayerMap map = AllMaps[key]; if (map.LoadedFromTour && map.Layers.Count == 0) { purgeMapsNames.Add(map.Name); } } foreach (string name in purgeMapsNames) { PurgeLayerMapDeep(AllMaps[name], true); } Version++; LoadTree(); }
public static void PurgeLayerMapDeep(LayerMap target, bool topLevel) { foreach (Layer layer in target.Layers) { LayerManager.DeleteLayerByID(layer.ID, false, false); } target.Layers.Clear(); foreach (string key in target.ChildMaps.Keys) { LayerMap map = target.ChildMaps[key]; PurgeLayerMapDeep(map, false); } target.ChildMaps.Clear(); if (topLevel) { if (!String.IsNullOrEmpty(target.Frame.Parent)) { if (AllMaps.ContainsKey(target.Frame.Parent)) { AllMaps[target.Frame.Parent].ChildMaps.Remove(target.Name); } } else { if (LayerMaps.ContainsKey(target.Name)) { LayerMaps.Remove(target.Name); } } } AllMaps.Remove(target.Name); version++; }
// Merged layers from Tour Player Alternate universe into the real layer manager layers list public static void MergeToursLayers() { tourLayers = false; bool OverWrite = false; bool CollisionChecked = false; foreach (String key in allMapsTours.Keys) { LayerMap map = allMapsTours[key]; if (!allMaps.ContainsKey(map.Name)) { LayerMap newMap = new LayerMap(map.Name, ReferenceFrames.Custom); newMap.Frame = map.Frame; newMap.LoadedFromTour = true; LayerManager.AllMaps[newMap.Name] = newMap; } } ConnectAllChildren(); foreach (Guid key in layerListTours.Keys) { Layer layer = layerListTours[key]; if (LayerList.ContainsKey(layer.ID)) { if (!CollisionChecked) { //todo add UI in the future if (true) // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { OverWrite = true; } else { OverWrite = false; } CollisionChecked = true; } if (OverWrite) { LayerManager.DeleteLayerByID(layer.ID, true, false); } } if (!LayerList.ContainsKey(layer.ID)) { if (AllMaps.ContainsKey(layer.ReferenceFrame)) { LayerList[layer.ID] = layer; AllMaps[layer.ReferenceFrame].Layers.Add(layer); } } else { layer.CleanUp(); } } layerListTours.Clear(); allMapsTours.Clear(); layerMapsTours.Clear(); LoadTree(); }
public static void InitLayers() { ClearLayers(); //LayerMap iss = null; //if (!TourLayers) //{ // string[] isstle = new string[0]; // try // { // //This is downloaded now on startup // string url = "http://www.worldwidetelescope.org/wwtweb/isstle.aspx"; // string filename = string.Format(@"{0}data\isstle.txt", Properties.Settings.Default.CahceDirectory); // DataSetManager.DownloadFile(url, filename, false, false); // isstle = File.ReadAllLines(filename); // } // catch // { // } // iss = new LayerMap("ISS", ReferenceFrames.Custom); // iss.Frame.Epoch = SpaceTimeController.TwoLineDateToJulian("10184.51609218"); // iss.Frame.SemiMajorAxis = 6728829.41; // iss.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital; // iss.Frame.Inclination = 51.6442; // iss.Frame.LongitudeOfAscendingNode = 147.0262; // iss.Frame.Eccentricity = .0009909; // iss.Frame.MeanAnomolyAtEpoch = 325.5563; // iss.Frame.MeanDailyMotion = 360 * 15.72172655; // iss.Frame.ArgumentOfPeriapsis = 286.4623; // iss.Frame.Scale = 1; // iss.Frame.SemiMajorAxisUnits = AltUnits.Meters; // iss.Frame.MeanRadius = 130; // iss.Frame.Oblateness = 0; // iss.Frame.ShowOrbitPath = true; // if (isstle.Length > 1) // { // iss.Frame.FromTLE(isstle[0], isstle[1], 398600441800000); // } //} LayerMaps["Sun"] = new LayerMap("Sun", ReferenceFrames.Sun); LayerMaps["Sun"].ChildMaps["Mercury"] = new LayerMap("Mercury", ReferenceFrames.Mercury); LayerMaps["Sun"].ChildMaps["Venus"] = new LayerMap("Venus", ReferenceFrames.Venus); LayerMaps["Sun"].ChildMaps["Earth"] = new LayerMap("Earth", ReferenceFrames.Earth); LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps["Moon"] = new LayerMap("Moon", ReferenceFrames.Moon); //if (!TourLayers) //{ // LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps.Add("ISS", iss); //} LayerMaps["Sun"].ChildMaps["Mars"] = new LayerMap("Mars", ReferenceFrames.Mars); LayerMaps["Sun"].ChildMaps["Jupiter"] = new LayerMap("Jupiter", ReferenceFrames.Jupiter); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Io"] = new LayerMap("Io", ReferenceFrames.Io); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Europa"] = new LayerMap("Europa", ReferenceFrames.Europa); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Ganymede"] = new LayerMap("Ganymede", ReferenceFrames.Ganymede); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Callisto"] = new LayerMap("Callisto", ReferenceFrames.Callisto); LayerMaps["Sun"].ChildMaps["Saturn"] = new LayerMap("Saturn", ReferenceFrames.Saturn); LayerMaps["Sun"].ChildMaps["Uranus"] = new LayerMap("Uranus", ReferenceFrames.Uranus); LayerMaps["Sun"].ChildMaps["Neptune"] = new LayerMap("Neptune", ReferenceFrames.Neptune); LayerMaps["Sun"].ChildMaps["Pluto"] = new LayerMap("Pluto", ReferenceFrames.Pluto); // AddMoons(); LayerMaps["Sky"] = new LayerMap("Sky", ReferenceFrames.Sky); LayerMaps["Sun"].Open = true; AllMaps.Clear(); AddAllMaps(LayerMaps, null); version++; LoadTree(); }
public void FromXml(XmlDocument doc) { XmlNode root = Util.SelectSingleNode(doc, "Tour"); id = root.Attributes.GetNamedItem("ID").Value.ToString(); Title = root.Attributes.GetNamedItem("Title").Value.ToString(); Author = root.Attributes.GetNamedItem("Author").Value.ToString(); if (root.Attributes.GetNamedItem("Descirption") != null) { Description = root.Attributes.GetNamedItem("Descirption").Value; } if (root.Attributes.GetNamedItem("AuthorEmail") != null) { authorEmail = root.Attributes.GetNamedItem("AuthorEmail").Value; } if (root.Attributes.GetNamedItem("Keywords") != null) { Keywords = root.Attributes.GetNamedItem("Keywords").Value; } if (root.Attributes.GetNamedItem("OrganizationName") != null) { OrgName = root.Attributes.GetNamedItem("OrganizationName").Value; } organizationUrl = root.Attributes.GetNamedItem("OrganizationUrl").Value.ToString(); switch (root.Attributes.GetNamedItem("UserLevel").Value) { case "Beginner": level = UserLevel.Beginner; break; case "Intermediate": level = UserLevel.Intermediate; break; case "Advanced": level = UserLevel.Advanced; break; case "Educator": level = UserLevel.Educator; break; case "Professional": level = UserLevel.Professional; break; default: break; } switch (root.Attributes.GetNamedItem("Classification").Value) { case "Star": type = Classification.Star; break; case "Supernova": type = Classification.Supernova; break; case "BlackHole": type = Classification.BlackHole; break; case "NeutronStar": type = Classification.NeutronStar; break; case "DoubleStar": type = Classification.DoubleStar; break; case "MultipleStars": type = Classification.MultipleStars; break; case "Asterism": type = Classification.Asterism; break; case "Constellation": type = Classification.Constellation; break; case "OpenCluster": type = Classification.OpenCluster; break; case "GlobularCluster": type = Classification.GlobularCluster; break; case "NebulousCluster": type = Classification.NebulousCluster; break; case "Nebula": type = Classification.Nebula; break; case "EmissionNebula": type = Classification.EmissionNebula; break; case "PlanetaryNebula": type = Classification.PlanetaryNebula; break; case "ReflectionNebula": type = Classification.ReflectionNebula; break; case "DarkNebula": type = Classification.DarkNebula; break; case "GiantMolecularCloud": type = Classification.GiantMolecularCloud; break; case "SupernovaRemnant": type = Classification.SupernovaRemnant; break; case "InterstellarDust": type = Classification.InterstellarDust; break; case "Quasar": type = Classification.Quasar; break; case "Galaxy": type = Classification.Galaxy; break; case "SpiralGalaxy": type = Classification.SpiralGalaxy; break; case "IrregularGalaxy": type = Classification.IrregularGalaxy; break; case "EllipticalGalaxy": type = Classification.EllipticalGalaxy; break; case "Knot": type = Classification.Knot; break; case "PlateDefect": type = Classification.PlateDefect; break; case "ClusterOfGalaxies": type = Classification.ClusterOfGalaxies; break; case "OtherNGC": type = Classification.OtherNGC; break; case "Unidentified": type = Classification.Unidentified; break; case "SolarSystem": type = Classification.SolarSystem; break; case "Unfiltered": type = Classification.Unfiltered; break; case "Stellar": type = Classification.Stellar; break; case "StellarGroupings": type = Classification.StellarGroupings; break; case "Nebulae": type = Classification.Nebulae; break; case "Galactic": type = Classification.Galactic; break; case "Other": type = Classification.Other; break; default: break; } taxonomy = root.Attributes.GetNamedItem("Taxonomy").Value.ToString(); XmlNode TourStops = Util.SelectSingleNode(root, "TourStops"); foreach (XmlNode tourStop in TourStops.ChildNodes) { if (tourStop.Name == "TourStop") { AddTourStop(TourStop.FromXml(this, tourStop)); } } XmlNode Frames = Util.SelectSingleNode(root, "ReferenceFrames"); if (Frames != null) { foreach (XmlNode frame in Frames.ChildNodes) { if (frame.Name == "ReferenceFrame") { ReferenceFrame newFrame = new ReferenceFrame(); newFrame.InitializeFromXml(frame); if (!LayerManager.AllMaps.ContainsKey(newFrame.Name)) { LayerMap map = new LayerMap(newFrame.Name, ReferenceFrames.Custom); map.Frame = newFrame; map.LoadedFromTour = true; LayerManager.AllMaps[newFrame.Name] = map; } } } LayerManager.ConnectAllChildren(); LayerManager.LoadTree(); } XmlNode Layers = Util.SelectSingleNode(root, "Layers"); if (Layers != null) { foreach (XmlNode layer in Layers.ChildNodes) { if (layer.Name == "Layer") { Layer newLayer = new Layer().FromXml(layer, true);//.Layer.FromXml(layer, true); if (newLayer != null) { string fileName = string.Format("{0}.txt", newLayer.ID.ToString()); if (LayerManager.LayerList.ContainsKey(newLayer.ID)) // && newLayer.ID != ISSLayer.ISSGuid) { //if (!CollisionChecked) //{ // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) // { // OverWrite = true; // } // else // { // OverWrite = false; // } // CollisionChecked = true; //} //if (OverWrite) //{ LayerManager.DeleteLayerByID(newLayer.ID, true, false); //} } try { newLayer.LoadedFromTour = true; newLayer.LoadData(GetFileStream(fileName)); LayerManager.Add(newLayer, false); } catch { } } } } LayerManager.LoadTree(); } //todo author //if (File.Exists(WorkingDirectory + "Author.png")) //{ // authorImage = UiTools.LoadBitmap(WorkingDirectory + "Author.png"); //} tourDirty = 0; }
public void FromXml(XmlDocument doc) { XmlNode root = Util.SelectSingleNode(doc, "Tour"); id = root.Attributes.GetNamedItem("ID").Value.ToString(); Title = root.Attributes.GetNamedItem("Title").Value.ToString(); Author = root.Attributes.GetNamedItem("Author").Value.ToString(); if (root.Attributes.GetNamedItem("Descirption") != null) { Description = root.Attributes.GetNamedItem("Descirption").Value; } if (root.Attributes.GetNamedItem("AuthorEmail") != null) { authorEmail = root.Attributes.GetNamedItem("AuthorEmail").Value; } if (root.Attributes.GetNamedItem("Keywords") != null) { Keywords = root.Attributes.GetNamedItem("Keywords").Value; } if (root.Attributes.GetNamedItem("OrganizationName") != null) { OrgName = root.Attributes.GetNamedItem("OrganizationName").Value; } organizationUrl = root.Attributes.GetNamedItem("OrganizationUrl").Value; switch (root.Attributes.GetNamedItem("UserLevel").Value) { case "Beginner": level = UserLevel.Beginner; break; case "Intermediate": level = UserLevel.Intermediate; break; case "Advanced": level = UserLevel.Advanced; break; case "Educator": level = UserLevel.Educator; break; case "Professional": level = UserLevel.Professional; break; default: break; } switch (root.Attributes.GetNamedItem("Classification").Value) { case "Star": type = Classification.Star; break; case "Supernova": type = Classification.Supernova; break; case "BlackHole": type = Classification.BlackHole; break; case "NeutronStar": type = Classification.NeutronStar; break; case "DoubleStar": type = Classification.DoubleStar; break; case "MultipleStars": type = Classification.MultipleStars; break; case "Asterism": type = Classification.Asterism; break; case "Constellation": type = Classification.Constellation; break; case "OpenCluster": type = Classification.OpenCluster; break; case "GlobularCluster": type = Classification.GlobularCluster; break; case "NebulousCluster": type = Classification.NebulousCluster; break; case "Nebula": type = Classification.Nebula; break; case "EmissionNebula": type = Classification.EmissionNebula; break; case "PlanetaryNebula": type = Classification.PlanetaryNebula; break; case "ReflectionNebula": type = Classification.ReflectionNebula; break; case "DarkNebula": type = Classification.DarkNebula; break; case "GiantMolecularCloud": type = Classification.GiantMolecularCloud; break; case "SupernovaRemnant": type = Classification.SupernovaRemnant; break; case "InterstellarDust": type = Classification.InterstellarDust; break; case "Quasar": type = Classification.Quasar; break; case "Galaxy": type = Classification.Galaxy; break; case "SpiralGalaxy": type = Classification.SpiralGalaxy; break; case "IrregularGalaxy": type = Classification.IrregularGalaxy; break; case "EllipticalGalaxy": type = Classification.EllipticalGalaxy; break; case "Knot": type = Classification.Knot; break; case "PlateDefect": type = Classification.PlateDefect; break; case "ClusterOfGalaxies": type = Classification.ClusterOfGalaxies; break; case "OtherNGC": type = Classification.OtherNGC; break; case "Unidentified": type = Classification.Unidentified; break; case "SolarSystem": type = Classification.SolarSystem; break; case "Unfiltered": type = Classification.Unfiltered; break; case "Stellar": type = Classification.Stellar; break; case "StellarGroupings": type = Classification.StellarGroupings; break; case "Nebulae": type = Classification.Nebulae; break; case "Galactic": type = Classification.Galactic; break; case "Other": type = Classification.Other; break; default: break; } taxonomy = root.Attributes.GetNamedItem("Taxonomy").Value.ToString(); XmlNode TourStops = Util.SelectSingleNode(root, "TourStops"); foreach (XmlNode tourStop in TourStops.ChildNodes) { if (tourStop.Name == "TourStop") { AddTourStop(TourStop.FromXml(this, tourStop)); } } XmlNode Frames = Util.SelectSingleNode(root, "ReferenceFrames"); if (Frames != null) { foreach (XmlNode frame in Frames.ChildNodes) { if (frame.Name == "ReferenceFrame") { ReferenceFrame newFrame = new ReferenceFrame(); newFrame.InitializeFromXml(frame); if (!LayerManager.AllMaps.ContainsKey(newFrame.Name)) { LayerMap map = new LayerMap(newFrame.Name, ReferenceFrames.Custom); map.Frame = newFrame; map.LoadedFromTour = true; LayerManager.AllMaps[newFrame.Name] = map; } } } LayerManager.ConnectAllChildren(); LayerManager.LoadTree(); } XmlNode Layers = Util.SelectSingleNode(root, "Layers"); if (Layers != null) { foreach (XmlNode layer in Layers.ChildNodes) { if (layer.Name == "Layer") { Layer newLayer = new Layer().FromXml(layer,true);//.Layer.FromXml(layer, true); if (newLayer != null) { string fileName = string.Format("{0}.txt", newLayer.ID.ToString()); if (LayerManager.LayerList.ContainsKey(newLayer.ID)) // && newLayer.ID != ISSLayer.ISSGuid) { //if (!CollisionChecked) //{ // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) // { // OverWrite = true; // } // else // { // OverWrite = false; // } // CollisionChecked = true; //} //if (OverWrite) //{ LayerManager.DeleteLayerByID(newLayer.ID, true, false); //} } try { newLayer.LoadedFromTour = true; newLayer.LoadData(GetFileStream(fileName)); LayerManager.Add(newLayer, false); } catch { } } } } LayerManager.LoadTree(); } //todo author //if (File.Exists(WorkingDirectory + "Author.png")) //{ // authorImage = UiTools.LoadBitmap(WorkingDirectory + "Author.png"); //} tourDirty = 0; }
//todo remove the stuff from draw that is redundant once predraw has run internal static void PreDraw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested) { if (!AllMaps.ContainsKey(referenceFrame)) { return; } LayerMap thisMap = AllMaps[referenceFrame]; if (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0) { return; } if (TourPlayer.Playing) { TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController as TourPlayer; if (player != null) { TourDocument tour = player.Tour; if (tour.CurrentTourStop != null) { player.UpdateTweenPosition(-1); tour.CurrentTourStop.UpdateLayerOpacity(); foreach (Guid key in tour.CurrentTourStop.Layers.Keys) { LayerInfo info = tour.CurrentTourStop.Layers[key]; if (LayerList.ContainsKey(info.ID)) { LayerList[info.ID].Opacity = info.FrameOpacity; LayerList[info.ID].SetParams(info.FrameParams); } } } } } Matrix3d matOld = renderContext.World; Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating; double oldNominalRadius = renderContext.NominalRadius; if (thisMap.Frame.Reference == ReferenceFrames.Custom) { thisMap.ComputeFrame(renderContext); if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital) //if (true) { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World); } else { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); } renderContext.NominalRadius = thisMap.Frame.MeanRadius; } for (int pass = 0; pass < 2; pass++) { foreach (Layer layer in AllMaps[referenceFrame].Layers) { if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer))) { if (layer.Enabled) // && astronomical == layer.Astronomical) { double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime); double layerEnd = SpaceTimeController.UtcToJulian(layer.EndTime); double fadeIn = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); double fadeOut = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut) { float fadeOpacity = 1; if (SpaceTimeController.JNow < layerStart) { fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000)); } if (SpaceTimeController.JNow > layerEnd) { fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000)); } if (thisMap.Frame.Reference == ReferenceFrames.Sky) { layer.Astronomical = true; } layer.PreDraw(renderContext, opacity * fadeOpacity); } } } } } if (nested) { foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys) { LayerMap map = AllMaps[referenceFrame].ChildMaps[key]; if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity)) { PreDraw(renderContext, opacity, astronomical, map.Name, nested); } } } renderContext.NominalRadius = oldNominalRadius; renderContext.World = matOld; renderContext.WorldBaseNonRotating = matOldNonRotating; }
internal static void Draw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested, bool cosmos) { if (!AllMaps.ContainsKey(referenceFrame)) { return; } LayerMap thisMap = AllMaps[referenceFrame]; if (!thisMap.Enabled || (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0 && !(thisMap.Frame.ShowAsPoint || thisMap.Frame.ShowOrbitPath))) { return; } if (TourPlayer.Playing) { TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController; if (player != null) { TourDocument tour = player.Tour; if (tour.CurrentTourStop != null) { player.UpdateTweenPosition(-1); tour.CurrentTourStop.UpdateLayerOpacity(); foreach (Guid key in tour.CurrentTourStop.Layers.Keys) { LayerInfo info = tour.CurrentTourStop.Layers[key]; if (LayerList.ContainsKey(info.ID)) { LayerList[info.ID].Opacity = info.FrameOpacity; LayerList[info.ID].SetParams(info.FrameParams); } } } } } Matrix3d matOld = renderContext.World; Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating; double oldNominalRadius = renderContext.NominalRadius; if (thisMap.Frame.Reference == ReferenceFrames.Custom) { thisMap.ComputeFrame(renderContext); if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital && thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Trajectory) //if (true) { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World); } else { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); } renderContext.NominalRadius = thisMap.Frame.MeanRadius; } if (thisMap.Frame.ShowAsPoint) { // todo Draw point planet... // Planets.DrawPointPlanet(renderContext.Device, new Vector3d(0, 0, 0), (float).2, thisMap.Frame.RepresentativeColor, true); } for (int pass = 0; pass < 2; pass++) { foreach (Layer layer in AllMaps[referenceFrame].Layers) { if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer))) { if (layer.Enabled) // && astronomical == layer.Astronomical) { double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime); double layerEnd = SpaceTimeController.UtcToJulian(layer.EndTime); double fadeIn = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); double fadeOut = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut) { float fadeOpacity = 1; if (SpaceTimeController.JNow < layerStart) { fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000)); } if (SpaceTimeController.JNow > layerEnd) { fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000)); } layer.Astronomical = astronomical; //if (thisMap.Frame.Reference == ReferenceFrames.Sky) //{ // layer.Astronomical = true; //} layer.Draw(renderContext, opacity * fadeOpacity, cosmos); } } } } } if (nested) { foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys) { LayerMap map = AllMaps[referenceFrame].ChildMaps[key]; if (map.Frame.ShowOrbitPath && Settings.Active.SolarSystemOrbits) { if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Orbital) { if (map.Frame.Orbit == null) { map.Frame.Orbit = new Orbit(map.Frame.Elements, 360, map.Frame.RepresentativeColor, 1, (float)renderContext.NominalRadius); } Matrix3d matSaved = renderContext.World; renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); map.Frame.Orbit.Draw3D(renderContext, 1f * .25f, Vector3d.Create(0, 0, 0)); renderContext.World = matSaved; } else if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Trajectory) { //todo add trajectories back //if (map.Frame.trajectoryLines == null) //{ // map.Frame.trajectoryLines = new LineList(renderContext.Device); // map.Frame.trajectoryLines.ShowFarSide = true; // map.Frame.trajectoryLines.UseNonRotatingFrame = true; // int count = map.Frame.Trajectory.Count - 1; // for (int i = 0; i < count; i++) // { // Vector3d pos1 = map.Frame.Trajectory[i].Position; // Vector3d pos2 = map.Frame.Trajectory[i + 1].Position; // pos1.Multiply(1 / renderContext.NominalRadius); // pos2.Multiply(1 / renderContext.NominalRadius); // map.Frame.trajectoryLines.AddLine(pos1, pos2, map.Frame.RepresentativeColor, new Dates()); // } //} //Matrix3D matSaved = renderContext.World; //renderContext.World = thisMap.Frame.WorldMatrix * renderContext.WorldBaseNonRotating; //map.Frame.trajectoryLines.DrawLines(renderContext, Earth3d.MainWindow.showMinorOrbits.Opacity * .25f); //renderContext.World = matSaved; } } if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity)) { Draw(renderContext, opacity, astronomical, map.Name, nested, cosmos); } } } renderContext.NominalRadius = oldNominalRadius; renderContext.World = matOld; renderContext.WorldBaseNonRotating = matOldNonRotating; }
static public void InitLayers() { ClearLayers(); //LayerMap iss = null; //if (!TourLayers) //{ // string[] isstle = new string[0]; // try // { // //This is downloaded now on startup // string url = "http://www.worldwidetelescope.org/wwtweb/isstle.aspx"; // string filename = string.Format(@"{0}data\isstle.txt", Properties.Settings.Default.CahceDirectory); // DataSetManager.DownloadFile(url, filename, false, false); // isstle = File.ReadAllLines(filename); // } // catch // { // } // iss = new LayerMap("ISS", ReferenceFrames.Custom); // iss.Frame.Epoch = SpaceTimeController.TwoLineDateToJulian("10184.51609218"); // iss.Frame.SemiMajorAxis = 6728829.41; // iss.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital; // iss.Frame.Inclination = 51.6442; // iss.Frame.LongitudeOfAscendingNode = 147.0262; // iss.Frame.Eccentricity = .0009909; // iss.Frame.MeanAnomolyAtEpoch = 325.5563; // iss.Frame.MeanDailyMotion = 360 * 15.72172655; // iss.Frame.ArgumentOfPeriapsis = 286.4623; // iss.Frame.Scale = 1; // iss.Frame.SemiMajorAxisUnits = AltUnits.Meters; // iss.Frame.MeanRadius = 130; // iss.Frame.Oblateness = 0; // iss.Frame.ShowOrbitPath = true; // if (isstle.Length > 1) // { // iss.Frame.FromTLE(isstle[0], isstle[1], 398600441800000); // } //} LayerMaps["Sun"] = new LayerMap("Sun", ReferenceFrames.Sun); LayerMaps["Sun"].ChildMaps["Mercury"] = new LayerMap("Mercury", ReferenceFrames.Mercury); LayerMaps["Sun"].ChildMaps["Venus"] = new LayerMap("Venus", ReferenceFrames.Venus); LayerMaps["Sun"].ChildMaps["Earth"] = new LayerMap("Earth", ReferenceFrames.Earth); LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps["Moon"] = new LayerMap("Moon", ReferenceFrames.Moon); //if (!TourLayers) //{ // LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps.Add("ISS", iss); //} LayerMaps["Sun"].ChildMaps["Mars"] = new LayerMap("Mars", ReferenceFrames.Mars); LayerMaps["Sun"].ChildMaps["Jupiter"] = new LayerMap("Jupiter", ReferenceFrames.Jupiter); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Io"] = new LayerMap("Io", ReferenceFrames.Io); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Europa"] = new LayerMap("Europa", ReferenceFrames.Europa); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Ganymede"] = new LayerMap("Ganymede", ReferenceFrames.Ganymede); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Callisto"] = new LayerMap("Callisto", ReferenceFrames.Callisto); LayerMaps["Sun"].ChildMaps["Saturn"] = new LayerMap("Saturn", ReferenceFrames.Saturn); LayerMaps["Sun"].ChildMaps["Uranus"] = new LayerMap("Uranus", ReferenceFrames.Uranus); LayerMaps["Sun"].ChildMaps["Neptune"] = new LayerMap("Neptune", ReferenceFrames.Neptune); LayerMaps["Sun"].ChildMaps["Pluto"] = new LayerMap("Pluto", ReferenceFrames.Pluto); // AddMoons(); LayerMaps["Sky"] = new LayerMap("Sky", ReferenceFrames.Sky); LayerMaps["Sun"].Open = true; AllMaps.Clear(); AddAllMaps(LayerMaps, null); version++; LoadTree(); }
//public static TourDocument FromUrl(string url, Action callMe) //{ // TourDocument temp = new TourDocument(); // temp.Url = url; // temp.callMe = callMe; // temp.webFile = new WebFile(Util.GetTourComponent(url, "master")); // temp.webFile.OnStateChange = temp.LoadXmlDocument; // temp.webFile.Send(); // return temp; //} //private void LoadXmlDocument() //{ // if (webFile.State == StateType.Error) // { // Script.Literal("alert({0})", webFile.Message); // } // else if (webFile.State == StateType.Received) // { // FromXml(webFile.GetXml()); // callMe(); // } //} public void FromXml(XmlDocument doc) { XmlNode root = Util.SelectSingleNode(doc, "Tour"); id = root.Attributes.GetNamedItem("ID").Value.ToString(); Title = root.Attributes.GetNamedItem("Title").Value.ToString(); Author = root.Attributes.GetNamedItem("Author").Value.ToString(); if (root.Attributes.GetNamedItem("Descirption") != null) { Description = root.Attributes.GetNamedItem("Descirption").Value; } if (root.Attributes.GetNamedItem("AuthorEmail") != null) { authorEmail = root.Attributes.GetNamedItem("AuthorEmail").Value; } if (root.Attributes.GetNamedItem("Keywords") != null) { Keywords = root.Attributes.GetNamedItem("Keywords").Value; } if (root.Attributes.GetNamedItem("OrganizationName") != null) { OrgName = root.Attributes.GetNamedItem("OrganizationName").Value; } organizationUrl = root.Attributes.GetNamedItem("OrganizationUrl").Value; level = (UserLevel)Enums.Parse("UserLevel", root.Attributes.GetNamedItem("UserLevel").Value); type = (Classification)Enums.Parse("Classification", root.Attributes.GetNamedItem("Classification").Value); taxonomy = root.Attributes.GetNamedItem("Taxonomy").Value.ToString(); XmlNode TourStops = Util.SelectSingleNode(root, "TourStops"); foreach (XmlNode tourStop in TourStops.ChildNodes) { if (tourStop.Name == "TourStop") { AddTourStop(TourStop.FromXml(this, tourStop)); } } XmlNode Frames = Util.SelectSingleNode(root, "ReferenceFrames"); if (Frames != null) { foreach (XmlNode frame in Frames.ChildNodes) { if (frame.Name == "ReferenceFrame") { ReferenceFrame newFrame = new ReferenceFrame(); newFrame.InitializeFromXml(frame); if (!LayerManager.AllMaps.ContainsKey(newFrame.Name)) { LayerMap map = new LayerMap(newFrame.Name, ReferenceFrames.Custom); map.Frame = newFrame; map.LoadedFromTour = true; LayerManager.AllMaps[newFrame.Name] = map; } } } LayerManager.ConnectAllChildren(); LayerManager.LoadTree(); } XmlNode Layers = Util.SelectSingleNode(root, "Layers"); if (Layers != null) { foreach (XmlNode layer in Layers.ChildNodes) { if (layer.Name == "Layer") { Layer newLayer = Layer.FromXml(layer, true);//.Layer.FromXml(layer, true); if (newLayer != null) { string fileName = string.Format("{0}.txt", newLayer.ID.ToString()); if (LayerManager.LayerList.ContainsKey(newLayer.ID)) // && newLayer.ID != ISSLayer.ISSGuid) { //if (!CollisionChecked) //{ // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) // { // OverWrite = true; // } // else // { // OverWrite = false; // } // CollisionChecked = true; //} //if (OverWrite) //{ LayerManager.DeleteLayerByID(newLayer.ID, true, false); //} } try { newLayer.LoadedFromTour = true; newLayer.LoadData(this, fileName); LayerManager.Add(newLayer, false); } catch { } } } } LayerManager.LoadTree(); } //todo author //if (File.Exists(WorkingDirectory + "Author.png")) //{ // authorImage = UiTools.LoadBitmap(WorkingDirectory + "Author.png"); //} tourDirty = 0; }