public double GetScaledAltitudeForLatLong(double viewLat, double viewLong) { Imageset layer = BackgroundImageset; if (layer == null) { return(0); } int maxX = GetTilesXForLevel(layer, layer.BaseLevel); int maxY = GetTilesYForLevel(layer, layer.BaseLevel); for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null); if (tile != null) { if (tile.IsPointInTile(viewLat, viewLong)) { return(tile.GetSurfacePointAltitude(viewLat, viewLong, false)); } } } } return(0); }
private Tile GetTileAtLatLong(double viewLat, double viewLong) { Imageset layer = BackgroundImageset; if (layer == null) { return(null); } int maxX = GetTilesXForLevel(layer, layer.BaseLevel); int maxY = GetTilesYForLevel(layer, layer.BaseLevel); for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null); if (tile != null) { if (tile.IsPointInTile(viewLat, viewLong)) { return(tile); } } } } return(null); }
public void Show(Vector2d position) { tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, layer.ImageSet, null); DivElement picker = Document.GetElementById <DivElement>("histogram"); DivElement closeBtn = Document.GetElementById <DivElement>("histogramClose"); /////////////picker.ClassName = "histogram"; picker.Style.Display = "block"; picker.Style.Left = position.X.ToString() + "px"; picker.Style.Top = position.Y.ToString() + "px"; SelectedCurveStyle = (int)image.lastScale; dropDown = Document.GetElementById <SelectElement>("ScaleTypePicker"); dropDown.AddEventListener("change", CurveStyleSelected, false); dropDown.AddEventListener("click", IgnoreMe, true); CanvasElement canvas = Document.GetElementById <CanvasElement>("graph"); canvas.AddEventListener("mousedown", MouseDown, false); canvas.AddEventListener("mousemove", mousemove, false); canvas.AddEventListener("mouseup", mouseup, false); closeBtn.AddEventListener("click", Close, true); Draw(); }
public double GetAltitudeForLatLongForPlanet(int planetID, double viewLat, double viewLong) { Imageset layer = WWTControl.Singleton.GetImagesetByName(Planets.GetNameFrom3dId(planetID)); if (layer == null) { return(0); } int maxX = GetTilesXForLevel(layer, layer.BaseLevel); int maxY = GetTilesYForLevel(layer, layer.BaseLevel); for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null); if (tile != null) { if (tile.IsPointInTile(viewLat, viewLong)) { return(tile.GetSurfacePointAltitude(viewLat, viewLong, true)); } } } } return(0); }
private void TryGetAllDataInView(Imageset imageset, bool limit, CatalogSpreadSheetLayer catalogSpreadSheetLayer, Action <InViewReturnMessage> onComplete, int i) { int maxX = GetTilesXForLevel(imageset, imageset.BaseLevel); int maxY = GetTilesYForLevel(imageset, imageset.BaseLevel); bool anyTileStillDownloading = false; for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null); if (tile != null) { bool tileAndChildrenReady = ((HealpixTile)tile).GetDataInView(this, limit, catalogSpreadSheetLayer); anyTileStillDownloading = anyTileStillDownloading || !tileAndChildrenReady; } else { anyTileStillDownloading = true; } } } if (anyTileStillDownloading) { int count = catalogSpreadSheetLayer.Table.Rows.Count; if ((count > 10000 || i > 100 * 60 * 5) && limit) // ~5 minutes { Script.Literal("console.log('Too Many results - Aborting')"); Script.Literal("console.log(count)"); InViewReturnMessage returnMessage = new InViewReturnMessage(); returnMessage.aborted = true; returnMessage.table = catalogSpreadSheetLayer.GetTableDataInView(); onComplete.Invoke(returnMessage); catalogSpreadSheetLayer.CleanUp(); } else { Script.SetTimeout(delegate() { TryGetAllDataInView(imageset, limit, catalogSpreadSheetLayer, onComplete, i); }, 10); if (i % 200 == 0) { Script.Literal("console.log('Waiting for more tiles to load')"); Script.Literal("console.log(count)"); } i++; } } else { int count = catalogSpreadSheetLayer.Table.Rows.Count; Script.Literal("console.log('Done!')"); Script.Literal("console.log(count)"); InViewReturnMessage returnMessage = new InViewReturnMessage(); returnMessage.aborted = false; returnMessage.table = catalogSpreadSheetLayer.GetTableDataInView(); onComplete.Invoke(returnMessage); catalogSpreadSheetLayer.CleanUp(); } }
public static void UpdateScale(ImageSetLayer isl, ScaleTypes scale, double low, double hi) { FitsImage image = isl.ImageSet.WcsImage as FitsImage; SkyImageTile Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, isl.ImageSet, null); int z = image.lastBitmapZ; string colorMapperName = image.lastBitmapColorMapperName; Tile.texture2d = image.GetScaledBitmap(low, hi, scale, z, colorMapperName).GetTexture(); }
public static void UpdateImage(ImageSetLayer isl, double z) { FitsImage image = isl.ImageSet.WcsImage as FitsImage; SkyImageTile Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, isl.ImageSet, null); double low = image.lastBitmapMin; double hi = image.lastBitmapMax; Tile.texture2d = image.GetScaledBitmap(low, hi, image.lastScale, Math.Floor(z * (image.Depth - 1)), null).GetTexture(); }
public static void UpdateImage(ImageSetLayer isl, double z) { if (!RenderContext.UseGlVersion2) { FitsImageJs image = isl.ImageSet.WcsImage as FitsImageJs; SkyImageTile Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, isl.ImageSet, null); Tile.texture2d = image.GetBitmap().GetTexture(); } }
public static void UpdateColorMapper(ImageSetLayer isl, string colorMapperName) { isl.ImageSet.FitsProperties.ColorMapName = colorMapperName; if (!RenderContext.UseGlVersion2) { FitsImageJs image = isl.ImageSet.WcsImage as FitsImageJs; SkyImageTile Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, isl.ImageSet, null); Tile.texture2d = image.GetBitmap().GetTexture(); } }
public static void UpdateScale(ImageSetLayer isl, ScaleTypes scale, double low, double hi) { isl.ImageSet.FitsProperties.ScaleType = scale; isl.ImageSet.FitsProperties.LowerCut = low; isl.ImageSet.FitsProperties.UpperCut = hi; if (!RenderContext.UseGlVersion2) { FitsImageJs image = isl.ImageSet.WcsImage as FitsImageJs; SkyImageTile Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, isl.ImageSet, null); Tile.texture2d = image.GetBitmap().GetTexture(); } }
public bool GetDataInView(RenderContext renderContext, bool limit, CatalogSpreadSheetLayer catalogSpreadSheetLayer) { if (!ReadyToRender) { if (!errored) { RequestImage(); if (limit) { return(false); } } else if (Level >= 3) //Level 0-2 sometimes deleted in favor of allsky.jpg/tsv { return(true); } } bool allChildrenReady = true; bool anyChildInFrustum = false; int childIndex = 0; for (int y1 = 0; y1 < 2; y1++) { for (int x1 = 0; x1 < 2; x1++) { if (Level < dataset.Levels) { if (children[childIndex] == null) { children[childIndex] = TileCache.GetTile(Level + 1, x1, y1, dataset, this); } if (children[childIndex].IsTileInFrustum(renderContext.Frustum)) { anyChildInFrustum = true; allChildrenReady = allChildrenReady && ((HealpixTile)children[childIndex]).GetDataInView(renderContext, limit, catalogSpreadSheetLayer); } } childIndex++; } } if (anyChildInFrustum) { catalogSpreadSheetLayer.AddTileRows(Key, catalogRows); } return(allChildrenReady && !Downloading); }
public void DrawImageSet(Imageset imageset, double opacity) { int maxX = GetTilesXForLevel(imageset, imageset.BaseLevel); int maxY = GetTilesYForLevel(imageset, imageset.BaseLevel); for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null); if (tile != null) { tile.Draw3D(this, opacity); } } } }
public virtual bool Draw3D(RenderContext renderContext, double opacity) { // CanvasContext2D device = renderContext.Device; RenderedGeneration = CurrentRenderGeneration; TilesTouched++; AccessCount = TileCache.AccessID++; if (errored) { return(false); } int xMax = 2; InViewFrustum = true; if (!ReadyToRender) { TileCache.AddTileToQueue(this); //RequestImage(); return(false); } bool transitioning = false; int childIndex = 0; int yOffset = 0; if (dataset.Mercator || dataset.BottomsUp) { yOffset = 1; } int xOffset = 0; // try { bool anythingToRender = false; bool childRendered = false; for (int y1 = 0; y1 < 2; y1++) { for (int x1 = 0; x1 < xMax; x1++) { // if (level < (demEnabled ? 12 : dataset.Levels)) if (Level < dataset.Levels) { // make children if (children[childIndex] == null) { children[childIndex] = TileCache.GetTile(Level + 1, tileX * 2 + ((x1 + xOffset) % 2), tileY * 2 + ((y1 + yOffset) % 2), dataset, this); } if (children[childIndex].IsTileInFrustum(renderContext.Frustum)) { InViewFrustum = true; if (children[childIndex].IsTileBigEnough(renderContext)) { renderChildPart[childIndex].TargetState = !children[childIndex].Draw3D(renderContext, opacity); if (renderChildPart[childIndex].TargetState) { childRendered = true; } } else { renderChildPart[childIndex].TargetState = true; } } else { renderChildPart[childIndex].TargetState = renderChildPart[childIndex].State = false; } //if (renderChildPart[childIndex].TargetState == true || !blendMode) //{ // renderChildPart[childIndex].State = renderChildPart[childIndex].TargetState; //} if (renderChildPart[childIndex].TargetState != renderChildPart[childIndex].State) { transitioning = true; } } else { renderChildPart[childIndex].State = true; } if (renderChildPart[childIndex].State == true) { anythingToRender = true; } childIndex++; } } if (childRendered || anythingToRender) { RenderedAtOrBelowGeneration = CurrentRenderGeneration; if (Parent != null) { Parent.RenderedAtOrBelowGeneration = RenderedAtOrBelowGeneration; } } if (!anythingToRender) { return(true); } if (!CreateGeometry(renderContext)) { return(false); } TilesInView++; accomidation = ComputeAccomidation(); for (int i = 0; i < 4; i++) { if (renderChildPart[i].TargetState) { RenderPart(renderContext, i, (opacity / 100), false); } } } // catch { } return(true); }
public void DrawCatalogTile(RenderContext renderContext, double opacity) { RenderedGeneration = CurrentRenderGeneration; TilesTouched++; InViewFrustum = true; bool onlyDrawChildren = false; if (!ReadyToRender) { if (!errored) { TileCache.AddTileToQueue(this); return; } if (errored && Level < 3) //Level 0-2 sometimes deleted in favor of allsky.jpg/tsv { onlyDrawChildren = true; } else { return; } } bool anyChildInFrustum = false; int childIndex = 0; for (int y1 = 0; y1 < 2; y1++) { for (int x1 = 0; x1 < 2; x1++) { if (Level < dataset.Levels) { if (children[childIndex] == null) { children[childIndex] = TileCache.GetTile(Level + 1, x1, y1, dataset, this); } if (children[childIndex].IsTileInFrustum(renderContext.Frustum)) { InViewFrustum = true; anyChildInFrustum = true; if (children[childIndex].IsTileBigEnough(renderContext) || onlyDrawChildren) { ((HealpixTile)children[childIndex]).DrawCatalogTile(renderContext, opacity); } else { ((HealpixTile)children[childIndex]).RemoveCatalogTile(); } } else { ((HealpixTile)children[childIndex]).RemoveCatalogTile(); } } childIndex++; } } if (Level == 0 && !anyChildInFrustum && !onlyDrawChildren) { RemoveCatalogTile(); } else if (anyChildInFrustum) { TilesInView++; AddCatalogTile(); } }
public override bool Draw3D(RenderContext renderContext, double opacity) { if (IsCatalogTile) { DrawCatalogTile(renderContext, opacity); return(true); } RenderedGeneration = CurrentRenderGeneration; TilesTouched++; InViewFrustum = true; bool onlyDrawChildren = false; if (!ReadyToRender) { if (!errored) { TileCache.AddTileToQueue(this); return(false); } if (errored && Level < 3) //Level 0-2 sometimes deleted in favor of allsky.jpg/tsv { onlyDrawChildren = true; } else { return(false); } } //if (!CreateGeometry(renderContext)) //{ // if (Level > 2) // { // return false; // } //} int partCount = this.TriangleCount; TrianglesRendered += partCount; bool anythingToRender = false; bool childRendered = false; int childIndex = 0; for (int y1 = 0; y1 < 2; y1++) { for (int x1 = 0; x1 < 2; x1++) { if (Level < dataset.Levels) { // make children if (children[childIndex] == null) { children[childIndex] = TileCache.GetTile(Level + 1, x1, y1, dataset, this); } if (children[childIndex].IsTileInFrustum(renderContext.Frustum)) { InViewFrustum = true; if (children[childIndex].IsTileBigEnough(renderContext) || onlyDrawChildren) { //renderChildPart[childIndex].TargetState = true; renderChildPart[childIndex].TargetState = !children[childIndex].Draw3D(renderContext, opacity); if (renderChildPart[childIndex].TargetState) { childRendered = true; } } else { renderChildPart[childIndex].TargetState = true; } } else { renderChildPart[childIndex].TargetState = renderChildPart[childIndex].State = false; } } else { renderChildPart[childIndex].State = true; } ////if(childIndex != 0) ////{ //// renderChildPart[childIndex].TargetState = true; //// anythingToRender = true; ////} if (renderChildPart[childIndex].State == true) { anythingToRender = true; } childIndex++; } } if (childRendered || anythingToRender) { RenderedAtOrBelowGeneration = CurrentRenderGeneration; if (Parent != null) { Parent.RenderedAtOrBelowGeneration = RenderedAtOrBelowGeneration; } } if (!anythingToRender) { return(true); } if (!CreateGeometry(renderContext)) { return(false); } if (onlyDrawChildren) { return(true); } TilesInView++; for (int i = 0; i < 4; i++) { if (renderChildPart[i].TargetState) { RenderPart(renderContext, i, opacity / 100, false); } } return(true); }
private void InitializeGrids() { vertexList = new List <PositionTexture>(); childTriangleList = new List <Triangle> [4]; childTriangleList[0] = new List <Triangle>(); childTriangleList[1] = new List <Triangle>(); childTriangleList[2] = new List <Triangle>(); childTriangleList[3] = new List <Triangle>(); bounds = new PositionTexture[9]; if (Level > 0) { // Set in constuctor now //ToastTile parent = (ToastTile)TileCache.GetTile(level - 1, x / 2, y / 2, dataset, null); if (Parent == null) { Parent = TileCache.GetTile(Level - 1, tileX / 2, tileY / 2, dataset, null); } ToastTile parent = (ToastTile)Parent; int xIndex = tileX % 2; int yIndex = tileY % 2; if (Level > 1) { backslash = parent.backslash; } else { backslash = xIndex == 1 ^ yIndex == 1; } bounds[0 + 3 * 0] = parent.bounds[xIndex + 3 * yIndex].Copy(); bounds[1 + 3 * 0] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * yIndex]); bounds[2 + 3 * 0] = parent.bounds[xIndex + 1 + 3 * yIndex].Copy(); bounds[0 + 3 * 1] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 3 * (yIndex + 1)]); if (backslash) { bounds[1 + 3 * 1] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]); } else { bounds[1 + 3 * 1] = Midpoint(parent.bounds[xIndex + 1 + 3 * yIndex], parent.bounds[xIndex + 3 * (yIndex + 1)]); } bounds[2 + 3 * 1] = Midpoint(parent.bounds[xIndex + 1 + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]); bounds[0 + 3 * 2] = parent.bounds[xIndex + 3 * (yIndex + 1)].Copy(); bounds[1 + 3 * 2] = Midpoint(parent.bounds[xIndex + 3 * (yIndex + 1)], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]); bounds[2 + 3 * 2] = parent.bounds[xIndex + 1 + 3 * (yIndex + 1)].Copy(); bounds[0 + 3 * 0].Tu = 0 * uvMultiple; bounds[0 + 3 * 0].Tv = 0 * uvMultiple; bounds[1 + 3 * 0].Tu = .5f * uvMultiple; bounds[1 + 3 * 0].Tv = 0 * uvMultiple; bounds[2 + 3 * 0].Tu = 1 * uvMultiple; bounds[2 + 3 * 0].Tv = 0 * uvMultiple; bounds[0 + 3 * 1].Tu = 0 * uvMultiple; bounds[0 + 3 * 1].Tv = .5f * uvMultiple; bounds[1 + 3 * 1].Tu = .5f * uvMultiple; bounds[1 + 3 * 1].Tv = .5f * uvMultiple; bounds[2 + 3 * 1].Tu = 1 * uvMultiple; bounds[2 + 3 * 1].Tv = .5f * uvMultiple; bounds[0 + 3 * 2].Tu = 0 * uvMultiple; bounds[0 + 3 * 2].Tv = 1 * uvMultiple; bounds[1 + 3 * 2].Tu = .5f * uvMultiple; bounds[1 + 3 * 2].Tv = 1 * uvMultiple; bounds[2 + 3 * 2].Tu = 1 * uvMultiple; bounds[2 + 3 * 2].Tv = 1 * uvMultiple; vertexList.Add(bounds[0 + 3 * 0]); vertexList.Add(bounds[1 + 3 * 0]); vertexList.Add(bounds[2 + 3 * 0]); vertexList.Add(bounds[0 + 3 * 1]); vertexList.Add(bounds[1 + 3 * 1]); vertexList.Add(bounds[2 + 3 * 1]); vertexList.Add(bounds[0 + 3 * 2]); vertexList.Add(bounds[1 + 3 * 2]); vertexList.Add(bounds[2 + 3 * 2]); if (backslash) { childTriangleList[0].Add(Triangle.Create(4, 1, 0)); childTriangleList[0].Add(Triangle.Create(3, 4, 0)); childTriangleList[1].Add(Triangle.Create(5, 2, 1)); childTriangleList[1].Add(Triangle.Create(4, 5, 1)); childTriangleList[2].Add(Triangle.Create(7, 4, 3)); childTriangleList[2].Add(Triangle.Create(6, 7, 3)); childTriangleList[3].Add(Triangle.Create(8, 5, 4)); childTriangleList[3].Add(Triangle.Create(7, 8, 4)); } else { childTriangleList[0].Add(Triangle.Create(3, 1, 0)); childTriangleList[0].Add(Triangle.Create(4, 1, 3)); childTriangleList[1].Add(Triangle.Create(4, 2, 1)); childTriangleList[1].Add(Triangle.Create(5, 2, 4)); childTriangleList[2].Add(Triangle.Create(6, 4, 3)); childTriangleList[2].Add(Triangle.Create(7, 4, 6)); childTriangleList[3].Add(Triangle.Create(7, 5, 4)); childTriangleList[3].Add(Triangle.Create(8, 5, 7)); } } else { bounds[0 + 3 * 0] = PositionTexture.Create(0, -1, 0, 0, 0); bounds[1 + 3 * 0] = PositionTexture.Create(0, 0, 1, .5f, 0); bounds[2 + 3 * 0] = PositionTexture.Create(0, -1, 0, 1, 0); bounds[0 + 3 * 1] = PositionTexture.Create(-1, 0, 0, 0, .5f); bounds[1 + 3 * 1] = PositionTexture.Create(0, 1, 0, .5f, .5f); bounds[2 + 3 * 1] = PositionTexture.Create(1, 0, 0, 1, .5f); bounds[0 + 3 * 2] = PositionTexture.Create(0, -1, 0, 0, 1); bounds[1 + 3 * 2] = PositionTexture.Create(0, 0, -1, .5f, 1); bounds[2 + 3 * 2] = PositionTexture.Create(0, -1, 0, 1, 1); vertexList.Add(bounds[0 + 3 * 0]); vertexList.Add(bounds[1 + 3 * 0]); vertexList.Add(bounds[2 + 3 * 0]); vertexList.Add(bounds[0 + 3 * 1]); vertexList.Add(bounds[1 + 3 * 1]); vertexList.Add(bounds[2 + 3 * 1]); vertexList.Add(bounds[0 + 3 * 2]); vertexList.Add(bounds[1 + 3 * 2]); vertexList.Add(bounds[2 + 3 * 2]); childTriangleList[0].Add(Triangle.Create(3, 1, 0)); childTriangleList[0].Add(Triangle.Create(4, 1, 3)); childTriangleList[1].Add(Triangle.Create(5, 2, 1)); childTriangleList[1].Add(Triangle.Create(4, 5, 1)); childTriangleList[2].Add(Triangle.Create(7, 4, 3)); childTriangleList[2].Add(Triangle.Create(6, 7, 3)); childTriangleList[3].Add(Triangle.Create(7, 5, 4)); childTriangleList[3].Add(Triangle.Create(8, 5, 7)); // Setup default matrix of points. } }