public bool KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { switch (e.KeyCode) { case Keys.C: //center if (Earth3d.MainWindow.StudyImageset == null) { return(false); } Tile root = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.StudyImageset, null); if (root != null) { root.CleanUpGeometryRecursive(); } Earth3d.MainWindow.StudyImageset.CenterX = Earth3d.MainWindow.RA * 15; Earth3d.MainWindow.StudyImageset.CenterY = Earth3d.MainWindow.Dec; return(true); case Keys.S: //scale to view return(true); } return(false); }
public static void ShowHistogram(IImageSet imageset, bool toggle, Point pnt) { if (imageset.WcsImage is FitsImage) { if (singleton == null) { singleton = new Histogram(); singleton.Owner = Earth3d.MainWindow; } else { if (toggle) { HideHistogram(); return; } else { singleton.Hide(); } } singleton.Top = pnt.Y - singleton.Height; singleton.Left = pnt.X; singleton.Show(); singleton.Top = pnt.Y - singleton.Height; singleton.Left = pnt.X; singleton.Image = (FitsImage)imageset.WcsImage; singleton.Tile = (SkyImageTile)TileCache.GetTile(0, 0, 0, imageset, null); } }
private static void CleanUpImageSets() { if (Earth3d.MainWindow != null && Earth3d.MainWindow.videoOverlay != null) { Tile tile = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.videoOverlay, null); tile.CleanUp(false); Earth3d.MainWindow.videoOverlay = null; } }
private void HistogramView_MouseMove(object sender, MouseEventArgs e) { switch (dragType) { case DragType.Low: lowPosition = Math.Min(255, Math.Max(0, e.X)); break; case DragType.High: highPosition = Math.Min(255, Math.Max(0, e.X)); break; case DragType.Range: lowPosition = downPosition; highPosition = Math.Min(255, Math.Max(0, e.X)); break; case DragType.Center: int hWidth = Math.Abs(highPosition - lowPosition) / 2; int adCenter = Math.Min(255 - hWidth, Math.Max(hWidth, e.X)); int moved = center - adCenter; lowPosition -= moved; highPosition -= moved; break; case DragType.None: return; default: break; } center = (lowPosition + highPosition) / 2; HistogramView.Refresh(); double factor = (image.MaxVal - image.MinVal) / 256.0; double low = image.MinVal + (lowPosition * factor); double hi = image.MinVal + (highPosition * factor); this.Tile = (SkyImageTile)TileCache.GetTile(Tile.Level, Tile.X, Tile.Y, Tile.Dataset, null); updateTimer.Enabled = false; updateTimer.Enabled = true; image.lastMax = highPosition; image.lastMin = lowPosition; }
private static void CaptureThreadFunction() { int frameNumber = 0; while (Earth3d.MainWindow != null) { Thread.Sleep(msPerFrame); if (capturing && Earth3d.MainWindow != null) { frameNumber++; Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)); g.Dispose(); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ScreenImage = ms.ToArray(); ms.Dispose(); ms = null; string url = string.Format(String.Format("http://{0}:5050/images/{1}/screenshot.png", MyWebServer.IpAddress.ToString(), frameNumber.ToString())); NetControl.SendCommand(String.Format("SCREEN,{4},{0},{1},{2},http://{3}:5050/images/{5}/screenshot.png", Properties.Settings.Default.ScreenOverlayAlt, Properties.Settings.Default.ScreenOverlayAz, Properties.Settings.Default.ScreenOverlayScale, MyWebServer.IpAddress.ToString(), Earth3d.MainWindow.Config.ClusterID.ToString(), frameNumber.ToString())); if (Properties.Settings.Default.ScreenOverlayShowLocal) { if (Earth3d.MainWindow.videoOverlay == null) { Earth3d.MainWindow.videoOverlay = new ImageSetHelper("video", url, ImageSetType.Sky, BandPass.Visible, ProjectionType.SkyImage, Math.Abs(url.GetHashCode32()), 0, 0, 256, Properties.Settings.Default.ScreenOverlayScale / 1000, ".tif", false, "", Properties.Settings.Default.ScreenOverlayAz, Properties.Settings.Default.ScreenOverlayAlt, 0, false, "", false, false, 2, 960, 600, "", "", "", "", 0, ""); } Earth3d.MainWindow.videoOverlay.CenterX = Properties.Settings.Default.ScreenOverlayAz; Earth3d.MainWindow.videoOverlay.CenterY = Properties.Settings.Default.ScreenOverlayAlt; Earth3d.MainWindow.videoOverlay.BaseTileDegrees = Properties.Settings.Default.ScreenOverlayScale / 1000; Tile tile = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.videoOverlay, null); if (Dirty) { tile.CleanUpGeometryOnly(); Dirty = false; } tile.ReadyToRender = false; tile.TextureReady = false; tile.Volitile = true; } else if (Earth3d.MainWindow.videoOverlay != null) { CleanUpImageSets(); } } else { CleanUpImageSets(); } } }
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 bool MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (Earth3d.MainWindow.StudyImageset == null) { return(false); } if (dragging) { Tile root = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.StudyImageset, null); root.CleanUpGeometryRecursive(); bool twoRoots = false; if (Earth3d.MainWindow.StudyImageset.Projection == ProjectionType.Tangent && Earth3d.MainWindow.StudyImageset.WidthFactor == 1) { twoRoots = true; } if (anchored) { if (root is SkyImageTile) { SkyImageTile tile = (SkyImageTile)root; Coordinates point2 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y); WcsFitter fitter = new WcsFitter(tile.Width, tile.Height); fitter.AddPoint(anchoredPoint1, anchorPoint1); fitter.AddPoint(point2, anchorPoint2); fitter.Solve(); Earth3d.MainWindow.StudyImageset.BaseTileDegrees = fitter.Solution.Scale; Earth3d.MainWindow.StudyImageset.Rotation = (fitter.Solution.Rotation); Earth3d.MainWindow.StudyImageset.CenterX = (fitter.Solution.CenterX * 15); Earth3d.MainWindow.StudyImageset.CenterY = fitter.Solution.CenterY; Earth3d.MainWindow.StudyImageset.OffsetX = fitter.Solution.OffsetX; Earth3d.MainWindow.StudyImageset.OffsetY = fitter.Solution.OfsetY; } else { Coordinates downPoint = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y); double len = anchoredPoint1.Distance(downPoint); double angle = anchoredPoint1.Angle(downPoint) / RC; Earth3d.MainWindow.Text = String.Format("Angle = {0}", angle); Earth3d.MainWindow.StudyImageset.BaseTileDegrees = startScale * (len / startLength); Earth3d.MainWindow.StudyImageset.Rotation = startRotation - (angle - startAngle); } } else { double factor = 1.0; if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { factor = .01; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { double rotation = (pntDown.X - e.Location.X) / 50.0; rotation *= factor; Earth3d.MainWindow.StudyImageset.Rotation += rotation; Earth3d.MainWindow.StudyImageset.Rotation = Earth3d.MainWindow.StudyImageset.Rotation % 360; } else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { double scale = 1.0 + (((pntDown.X - e.Location.X) / 500.0) * factor); Earth3d.MainWindow.StudyImageset.BaseTileDegrees *= scale; if (Earth3d.MainWindow.StudyImageset.BaseTileDegrees > 180) { Earth3d.MainWindow.StudyImageset.BaseTileDegrees = 180; } } else { double moveX = (pntDown.X - e.Location.X) * Earth3d.MainWindow.GetPixelScaleX(true); double moveY = (pntDown.Y - e.Location.Y) * Earth3d.MainWindow.GetPixelScaleY(); Earth3d.MainWindow.StudyImageset.CenterX += moveX; Earth3d.MainWindow.StudyImageset.CenterY += moveY; } pntDown = e.Location; } if (twoRoots) { Tile root2 = TileCache.GetTile(0, 1, 0, Earth3d.MainWindow.StudyImageset, null); root2.CleanUpGeometryRecursive(); } } return(false); }