internal ucCalibrationPanel(AstrometryController astrometryController, VideoController videoController, IPlateCalibrationTool configTool) { InitializeComponent(); m_AstrometryController = astrometryController; m_VideoController = videoController; m_CalibrationTool = configTool; m_CalibrationTool.AreaChanged += m_CalibrationTool_AreaChanged; pnlDebugFits.Visible = false; m_AstrometryController.RegisterCalibrationRunner(this); rbIdentify3Stars.Checked = true; UpdateEnabledStateOfScrollControls(); m_InitialPixelmap = m_VideoController.GetCurrentAstroImage(false).Pixelmap; m_VideoController.ApplyDisplayModeAdjustments(m_InitialPixelmap.DisplayBitmap, false, m_InitialPixelmap); m_CalibrationTool.ActivateOsdAreaSizing(); rbInclusion.Checked = TangraConfig.Settings.PlateSolve.SelectedScopeRecorderConfig.IsInclusionArea; }
/// <summary> /// This method displays the currently selected pixels. If there are any filters /// to be applied they should have been already applied /// </summary> private void PlotSingleTargetPixels() { Bitmap bmp = picTarget1Pixels.Image as Bitmap; if (bmp != null && m_ProcessingPixels != null) { byte peak = 0; for (int x = 0; x < 17; x++) { for (int y = 0; y < 17; y++) { if (peak < m_DisplayPixels[x, y]) { peak = m_DisplayPixels[x, y]; } } } // This copes the pixels to a new array of pixels for displaying. This new array may have slightly different // dimentions (LP) and pixel intensities may be normalized (LPD) for (int x = 0; x < 17; x++) { for (int y = 0; y < 17; y++) { byte pixelValue = m_DisplayPixels[x, y]; Color pixelcolor = SystemColors.Control; if (pixelValue < TangraConfig.Settings.Photometry.Saturation.Saturation8Bit) { if (SelectedFilter == TangraConfig.PreProcessingFilter.LowPassDifferenceFilter) { pixelcolor = Color.FromArgb(150 * pixelValue / peak, 150 * pixelValue / peak, 150 * pixelValue / peak); } else if (SelectedFilter == TangraConfig.PreProcessingFilter.LowPassFilter) { if (x >= 1 && x < 16 && y >= 1 && y < 16) { pixelcolor = Color.FromArgb(pixelValue, pixelValue, pixelValue); } } else { pixelcolor = Color.FromArgb(pixelValue, pixelValue, pixelValue); } } else { pixelcolor = TangraConfig.Settings.Color.Saturation; } for (int dx = 0; dx < 7; dx++) { for (int dy = 0; dy < 7; dy++) { bmp.SetPixel(7 * x + dx, 7 * y + dy, pixelcolor); } } } } m_VideoController.ApplyDisplayModeAdjustments(bmp); using (Graphics g = Graphics.FromImage(bmp)) { float radius = (float)m_Aperture * 7; float x0 = m_X0 + dx + 0.5f; float y0 = m_Y0 + dy + 0.5f; g.DrawEllipse( m_Pen, (float)(7 * (x0) - radius), (float)(7 * (y0) - radius), 2 * radius, 2 * radius); if (SelectedObjectType == TrackingType.GuidingStar && !pnlUDLR.Visible) { float halfMatrixSize = (int)nudFitMatrixSize.Value / 2.0f; g.DrawRectangle(m_Pen, 7 * (x0 - halfMatrixSize), 7 * (y0 - halfMatrixSize), 14 * halfMatrixSize, 14 * halfMatrixSize); } else if (SelectedObjectType == TrackingType.OccultedStar) { radius = (float)(m_Aperture + (float)nudPositionTolerance.Value) * 7; g.DrawEllipse( m_Pen, (float)(7 * (x0) - radius), (float)(7 * (y0) - radius), 2 * radius, 2 * radius); } g.Save(); } picTarget1Pixels.Refresh(); } }
internal void ApplyDisplayModeAdjustments(Bitmap displayBitmap) { m_VideoController.ApplyDisplayModeAdjustments(displayBitmap); }
/// <summary> /// This method displays the currently selected pixels. If there are any filters /// to be applied they should have been already applied /// </summary> private void PlotPixelArea() { Bitmap bmp = picTarget1Pixels.Image as Bitmap; if (bmp != null && m_ProcessingPixels != null) { byte peak = 0; for (int x = 0; x < AREA_SIDE; x++) { for (int y = 0; y < AREA_SIDE; y++) { if (peak < m_DisplayPixels[x, y]) { peak = m_DisplayPixels[x, y]; } } } // This copes the pixels to a new array of pixels for displaying. This new array may have slightly different // dimentions (LP) and pixel intensities may be normalized (LPD) for (int x = 0; x < AREA_SIDE; x++) { for (int y = 0; y < AREA_SIDE; y++) { byte pixelValue = m_DisplayPixels[x, y]; Color pixelcolor = SystemColors.Control; if (pixelValue < TangraConfig.Settings.Photometry.Saturation.Saturation8Bit) { pixelcolor = Color.FromArgb(pixelValue, pixelValue, pixelValue); } else { pixelcolor = TangraConfig.Settings.Color.Saturation; } for (int dx = 0; dx < MAGN_FACTOR; dx++) { for (int dy = 0; dy < MAGN_FACTOR; dy++) { bmp.SetPixel(MAGN_FACTOR * x + dx, MAGN_FACTOR * y + dy, pixelcolor); } } } } m_VideoController.ApplyDisplayModeAdjustments(bmp); using (Graphics g = Graphics.FromImage(bmp)) { if (m_UserPeakMode) { if (FirstObjectPeakDefined()) { g.DrawLine(Pens.Coral, MAGN_FACTOR * m_X1Start, MAGN_FACTOR * (m_Y1Start - 3), MAGN_FACTOR * m_X1Start, MAGN_FACTOR * (m_Y1Start + 3)); g.DrawLine(Pens.Coral, MAGN_FACTOR * (m_X1Start - 3), MAGN_FACTOR * m_Y1Start, MAGN_FACTOR * (m_X1Start + 3), MAGN_FACTOR * m_Y1Start); } if (SecondObjectPeakDefined()) { g.DrawLine(Pens.Coral, MAGN_FACTOR * m_X2Start, MAGN_FACTOR * (m_Y2Start - 3), MAGN_FACTOR * m_X2Start, MAGN_FACTOR * (m_Y2Start + 3)); g.DrawLine(Pens.Coral, MAGN_FACTOR * (m_X2Start - 3), MAGN_FACTOR * m_Y2Start, MAGN_FACTOR * (m_X2Start + 3), MAGN_FACTOR * m_Y2Start); } } else { float?[] apertures = new float?[] { m_Aperture, m_Aperture1, m_Aperture2 }; float[] xPos = new float[] { m_X0, m_X1, m_X2 }; float[] yPos = new float[] { m_Y0, m_Y1, m_Y2 }; Pen[] pens = new Pen[] { m_Pen, m_Pen, m_Pen2 }; for (int i = 0; i < 3; i++) { if (apertures[i] != null) { float radius = (float)apertures[i] * MAGN_FACTOR; float x0 = xPos[i] + 0.5f; float y0 = yPos[i] + 0.5f; g.DrawEllipse( pens[i], (float)(MAGN_FACTOR * (x0) - radius), (float)(MAGN_FACTOR * (y0) - radius), 2 * radius, 2 * radius); } } } g.Save(); } picTarget1Pixels.Refresh(); } }