private void AddDeploymentButton_Click(object sender, EventArgs e) { if (!allowUpdates) { return; } if (this.addingNewStation) { MessageBox.Show(this, "Can only add deployments after the Station entry has been inserted into database.", "Add a New Station.", MessageBoxButtons.OK); return; } PicesSipperDeployment deployment = new PicesSipperDeployment(station.CruiseName, station.StationName); deployment.Latitude = station.Latitude; deployment.Longitude = station.Longitude; if (Deployments.Nodes.Count < 1) { deployment.DeploymentNum = "A"; } DeploymentDialog dd = new DeploymentDialog(deployment, true, false); dd.ShowDialog(this); LoadDeploymentDetails(); }
private void LoadDeployments() { deployment = null; PicesSipperDeploymentList deployments = mainWinConn.SipperDeploymentLoad(cruiseName, stationName); if (deployments == null) { return; } DeploymentField.Items.Clear(); deployment = null; foreach (PicesSipperDeployment d in deployments) { DeploymentField.Items.Add(d); if (d.DeploymentNum.Equals(deploymentNum, StringComparison.InvariantCultureIgnoreCase)) { deployment = d; } } if (deployment == null) { deploymentNum = ""; } else { DeploymentField.SelectedItem = deployment; } }
} /* PopulateDeploymentFromScreen*/ private void ValidateDeploymentNum() { errorProvider1.SetError(DeploymentNum, null); if (!addingNewDeployment) { return; } String s = DeploymentNum.Text.Trim(); if (String.IsNullOrEmpty(s)) { errorProvider1.SetError(DeploymentNum, "Can not leave 'DeploymentNum' blank."); validationErrorsFound = true; return; } String invalidCharacters = ""; for (int x = 0; x < s.Length; x++) { char ch = char.ToUpper(s[x]); bool validChar = ((ch >= '0') && (ch <= '9')) || ((ch >= 'A') && (ch <= 'Z')); if (!validChar) { if (invalidCharacters.Length > 0) { invalidCharacters += ", "; } invalidCharacters += s[x].ToString(); } } if (invalidCharacters.Length > 0) { errorProvider1.SetError(DeploymentNum, "Invalid characters[" + invalidCharacters + "]"); validationErrorsFound = true; return; } if (s.Length > 4) { errorProvider1.SetError(DeploymentNum, "DeploymentNum[" + s + "] is to long; maximum of 4 characters allowed."); validationErrorsFound = true; return; } if ((addingNewDeployment) || (s != deployment.DeploymentNum)) { PicesSipperDeployment existingDeployment = DbConn().SipperDeploymentLoad(CruiseName.Text, StationName.Text, s); if (existingDeployment != null) { errorProvider1.SetError(DeploymentNum, "DeploymentNum[" + s + "] is already been used for Cruise[" + CruiseName.Text + "], Station[" + StationName.Text + "]."); validationErrorsFound = true; return; } } DeploymentNum.Text = s; } /* ValidateDeploymentNum */
public PlotRequest(PicesSipperDeployment _deployment, Color _color ) { deployment = _deployment; color = _color; }
public DataSeriesToPlot(PicesSipperDeployment _deployment, PicesGPSDataPointList _data ) { deployment = _deployment; data = _data; }
private void AddDeploymentToSeries(PicesSipperDeployment deployment, Color color ) { PicesGPSDataPointList gpsData = threadConn.InstrumentDataRetrieveGPSInfo(deployment.CruiseName, deployment.StationName, deployment.DeploymentNum, (int)TimeInterval.Value); if ((gpsData == null) || cancelRequested) { return; } PicesGPSDataPointList fliteredGPSData = gpsData.FilterOutNoise(); if (fliteredGPSData == null) { return; } if (fliteredGPSData.Count > 1) { DataSeriesToPlot seriesToPlot = new DataSeriesToPlot(deployment, fliteredGPSData); seriesToPlot.LocateGPSBounds(); goalie.StartBlock(); series.Add(seriesToPlot); goalie.EndBlock(); } } /* AddDeploymentToSeries */
public DataSeriesToPlot(PicesSipperDeployment _deployment, String _legend, float[] _density, float[] _countsByDepth, float[] _depthVolumeProfile ) { deployment = _deployment; legend = _legend; density = _density; countsByDepth = _countsByDepth; depthVolumeProfile = _depthVolumeProfile; }
public DeploymentDialog(PicesSipperDeployment _deployment, bool _addingNewDeployment, bool _deletingDeployment ) { allowUpdates = PicesSipperVariables.AllowUpdates(); deployment = _deployment; addingNewDeployment = _addingNewDeployment; deletingDeployment = _deletingDeployment; runLog = new PicesRunLog(); InitializeComponent(); }
private void ValidateDeployment() { errorProvider1.SetError(DeploymentField, ""); if (DeploymentField.SelectedItem == null) { errorProvider1.SetError(DeploymentField, "No Deployment Selected."); validationErrorFound = true; } else { deployment = (PicesSipperDeployment)DeploymentField.SelectedItem; deploymentNum = deployment.DeploymentNum; } }
private void DeploymentsToPlot_Format(object sender, ListControlConvertEventArgs e) { if (e.ListItem == null) { return; } PicesSipperDeployment d = (PicesSipperDeployment)e.ListItem; String m = d.StationName; if (!String.IsNullOrEmpty(d.DeploymentNum)) { m += "-" + d.DeploymentNum + " " + d.Description; } e.Value = m; }
} /* CountsByDepth */ private float[] GetDepthVolumeProfile(PicesSipperDeployment deployment) { String msg = "Retrieving Depth-Volume profile Station[" + deployment.CruiseName + "] Station[" + deployment.StationName + "] Deployment[" + deployment.DeploymentNum + "]."; msgQueue.AddMsg(msg); statusMsgs.AddMsg(msg); PicesVolumeSampledStatList volStats = threadConn.InstrumentDataGetVolumePerMeterDepth(deployment.CruiseName, deployment.StationName, deployment.DeploymentNum, depthIncrement); if (volStats == null) { return(null); } return(volStats.ToArray()); }
private void DeploymentField_Format(object sender, ListControlConvertEventArgs e) { if (e.ListItem == null) { return; } PicesSipperDeployment d = (PicesSipperDeployment)e.ListItem; String m = d.DeploymentNum; if (!String.IsNullOrEmpty(m)) { m += " - "; } m += d.DateTimeStart.ToString("yyyy-MM-dd"); e.Value = m; }
private void HighLightClosestPoint(int closestPointSeriesIndex, int closestPointPointIndex, PicesGPSDataPoint closestPoint, PicesSipperDeployment closestDeployment ) { TimeSpan adjGpsToAct = new TimeSpan(0, 0, 0); if (closestDeployment != null) { adjGpsToAct = closestDeployment.SyncTimeStampActual - closestDeployment.SyncTimeStampGPS; } DateTime adjDateTime = closestPoint.GpsUtcTime.Add(adjGpsToAct); if ((lastClosestSeriesIndex >= 0) && (lastClosestSeriesIndex < ProfileChart.Series.Count)) { if ((lastClosestPointIndex >= 0) && (lastClosestPointIndex < ProfileChart.Series[lastClosestSeriesIndex].Points.Count)) { Series s = ProfileChart.Series[lastClosestSeriesIndex]; DataPoint dp = s.Points[lastClosestPointIndex]; dp.Label = ""; dp.MarkerSize = s.MarkerSize; dp.MarkerStyle = s.MarkerStyle; } } lastClosestPoint = null; lastClosestSeriesIndex = -1; lastClosestPointIndex = -1; if ((closestPointSeriesIndex >= 0) && (closestPointSeriesIndex < ProfileChart.Series.Count)) { if ((closestPointPointIndex >= 0) && (closestPointPointIndex < ProfileChart.Series[closestPointSeriesIndex].Points.Count)) { Series s = ProfileChart.Series[closestPointSeriesIndex]; DataPoint dp = s.Points[closestPointPointIndex]; dp.Label = adjDateTime.ToString("HH:mm"); dp.MarkerStyle = MarkerStyle.Diamond; dp.MarkerSize = s.MarkerSize * 3; lastClosestPoint = closestPoint; lastClosestSeriesIndex = closestPointSeriesIndex; lastClosestPointIndex = closestPointPointIndex; } } } /* HighLightClosestPoint */
private void DeploymentsToPlot_Format(object sender, ListControlConvertEventArgs e) { if (e.ListItem == null) { return; } PicesSipperDeployment d = (PicesSipperDeployment)e.ListItem; String m = d.CruiseName + "-" + d.StationName; if (!String.IsNullOrEmpty(d.DeploymentNum)) { m += "-" + d.DeploymentNum; } m += " (" + d.DateTimeStart.ToString("yyyy-MMM-dd HH:mm") + ")"; e.Value = m; }
public TreeNodeDeployment(PicesDataBase _dbConn, PicesSipperDeployment _deployment ) { allowUpdates = PicesSipperVariables.AllowUpdates(); dbConn = _dbConn; deployment = _deployment; Text = ToString(); ContextMenuStrip cms = new ContextMenuStrip(); cms.Items.Add("Edit Deployment Parameters", null, EditDeploymentParameters); if ((this.Nodes.Count < 1) && allowUpdates) { cms.Items.Add("Delete Deployment", null, DeleteDeployment); } this.ContextMenuStrip = cms; LoadSipperFileDetails(); }
private void AddDeploymentToSeries(PicesSipperDeployment deployment) { float[] counts = CountsByDepth(deployment, classToPlot); if ((counts == null) || cancelRequested) { return; } float[] depthVolumeProfile = GetDepthVolumeProfile(deployment); if (depthVolumeProfile == null) { return; } float[] density = new float[counts.Length]; for (int idx = 0; idx < counts.Length; ++idx) { float vol = 0; if (idx < depthVolumeProfile.Length) { vol = depthVolumeProfile[idx]; } if (vol == 0.0f) { density[idx] = 0.0f; } else { density[idx] = counts[idx] / vol; } } String legend = deployment.CruiseName + "-" + deployment.StationName; if (!String.IsNullOrEmpty(deployment.DeploymentNum)) { legend += ("-" + deployment.DeploymentNum); } goalie.StartBlock(); series.Add(new DataSeriesToPlot(deployment, legend, density, counts, depthVolumeProfile)); goalie.EndBlock(); } /* AddDeploymentToSeries */
private void DeleteDeployment(Object sender, EventArgs e) { if (!allowUpdates) { return; } DeploymentDialog sdd = new DeploymentDialog(deployment, false, true); sdd.ShowDialog(); if (sdd.DeploymentDeleted) { if (this.Parent != null) { Parent.Nodes.Remove(this); return; } this.ContextMenuStrip = null; Text = "Deployment[" + deployment.DeploymentNum + "] ***Deleted***"; deployment = null; } } /* DeleteDeployment */
private void WriteTabDelToStream(TextWriter tw) { DateTime curTime = DateTime.Now; tw.WriteLine("ChartGPSByStation"); tw.WriteLine("DateTime" + "\t" + curTime.ToString("yyyy/MM/dd HH:mm:ss")); tw.WriteLine(); foreach (DataSeriesToPlot dstp in series) { PicesGPSDataPointList gpsData = dstp.data; PicesSipperDeployment deployment = dstp.deployment; tw.WriteLine(); tw.WriteLine("Cruise" + "\t" + deployment.CruiseName); tw.WriteLine("Station" + "\t" + deployment.StationName); tw.WriteLine("DeploymentNum" + "\t" + deployment.DeploymentNum); tw.WriteLine("SyncTimeStampActual" + "\t" + deployment.SyncTimeStampActual.ToString("yyyy-MM-dd HH:mm:ss")); tw.WriteLine("SyncTimeStampCTD" + "\t" + deployment.SyncTimeStampCTD.ToString("yyyy-MM-dd HH:mm:ss")); tw.WriteLine("SyncTimeStampGPS" + "\t" + deployment.SyncTimeStampGPS.ToString("yyyy-MM-dd HH:mm:ss")); tw.WriteLine("GpsUtcTime" + "\t" + "Latitude" + "\t" + "Longitude" + "\t" + "Latitude(hh:mm)" + "\t" + "Longitude(HH:MM)" + "\t" + "COG" + "\t" + "SOG(kts)"); foreach (PicesGPSDataPoint dp in gpsData) { tw.WriteLine(dp.GpsUtcTime.ToString("yyyy/MM/dd HH:mm:ss") + "\t" + dp.Latitude.ToString("##0.00000000") + "\t" + dp.Longitude.ToString("##0.00000000") + "\t" + PicesMethods.LongitudeToString(dp.Longitude, 3) + "\t" + PicesMethods.LatitudeToString(dp.Latitude, 3) + "\t" + dp.CourseOverGround.ToString("##0.0") + "\t" + dp.SpeedOverGround.ToString("##0.0") ); } tw.WriteLine("----EndOfDeoploymemt----"); tw.WriteLine(); } tw.WriteLine("End of ChartGPSByStation"); }
} /* DeleteStation */ private void AddANewDeployment(Object sender, EventArgs e) { if (!PicesSipperVariables.AllowUpdates()) { return; } if (station == null) { return; } PicesSipperDeployment deployment = new PicesSipperDeployment(station.CruiseName, station.StationName); deployment.Latitude = station.Latitude; deployment.Longitude = station.Longitude; deployment.DeploymentNum = nextDeploymentNum; DeploymentDialog dd = new DeploymentDialog(deployment, true, false); dd.ShowDialog(); LoadDeploymentDetails(); this.Text = this.ToString(); }
} /* AddStationsToChart */ private void UpdateChartAreas() { goalie.StartBlock(); double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; DateTime minGpsDateTime = DateTime.MaxValue; DateTime maxGpsDateTime = DateTime.MinValue; timeInterval = (int)TimeInterval.Value; //String plotAction = PlotAction.SelectedText; PicesSipperDeploymentList selectedDeployments = CurrentlySelectedDeployments(); String titleLine = "Station: " + stationName; titleLine += " Time-Interval: " + timeInterval; ProfileChart.Titles.Clear(); ProfileChart.Titles.Add(new Title(titleLine, Docking.Top, titleFont, Color.Black)); if (series.Count < 1) { ProfileChart.Series.Clear(); goalie.EndBlock(); return; } ChartArea ca = ProfileChart.ChartAreas[0]; ca.AxisX.TitleFont = axisTitleFont; ca.AxisY.TitleFont = axisTitleFont; ProfileChart.Series.Clear(); // First we will plot cruise level series; that is series that are not ties to a specific deployment. foreach (DataSeriesToPlot dstp in series) { if (dstp.deployment == null) { AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime); } } PicesSipperStationList stationsToPlot = new PicesSipperStationList(); Dictionary <String, PicesSipperStation> stationsPlotted = new Dictionary <string, PicesSipperStation> (); // Second we plot series that is specific to a deployment. foreach (DataSeriesToPlot dstp in series) { PicesSipperDeployment d = dstp.deployment; AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime); if (!stationsPlotted.ContainsKey(d.StationName)) { PicesSipperStation stationToPlot = mainWinConn.SipperStationLoad(d.CruiseName, d.StationName); stationsPlotted.Add(d.StationName, stationToPlot); stationsToPlot.Add(stationToPlot); } } // Third we add stations that were not in one of the specified deployments but awe in the area of the deployments. // Find other stations in plot area. // Degrees/Kilo-Meter = 1/111 There are 111 Km/Degree of latitude double paddingKms = (double)PaddingKms.Value; double latPadding = paddingKms * (1.0 / 111.0); // Will add 5km's of padding to latitude. double degreesToRads = Math.PI / 180.0; double kmsPerDegLong = 111.6 * Math.Cos((minY + maxY) / 2.0 * degreesToRads); double longPadding = paddingKms * (1.0 / (kmsPerDegLong)); // PicesSipperStationList stationsInRange = mainWinConn.SipperStationsLoadByGpsRange(minY - latPadding, maxY + latPadding, minX - longPadding, maxX + longPadding); if (stationsInRange != null) { foreach (PicesSipperStation stationToPlot in stationsInRange) { if (!stationsPlotted.ContainsKey(stationToPlot.StationName)) { stationsPlotted.Add(stationToPlot.StationName, stationToPlot); stationsToPlot.Add(stationToPlot); } } } // Forth We add the stations to the Plot. AddStationsToChart(stationsToPlot, ref minX, ref maxX, ref minY, ref maxY); double latitudeMid = (maxY + minY) / 2.0; float plotAreaHeight = ProfileChart.ChartAreas[0].InnerPlotPosition.Height; float plotAreaWidth = ProfileChart.ChartAreas[0].InnerPlotPosition.Width; double yRangeDegs = maxY - minY; double xRangeDegs = maxX - minX; double yRangeKms = yRangeDegs * 111.0; double longKmsPerDeg = 111.6 * Math.Cos(latitudeMid * degToRad); double xRangeKms = xRangeDegs * longKmsPerDeg; double yDensity = yRangeKms / plotAreaHeight; double xDenisty = xRangeKms / plotAreaWidth; if (xDenisty > yDensity) { double newYRangeKms = xDenisty * plotAreaHeight; double newYRageDegs = newYRangeKms / 111.0; double deltaYRange = newYRageDegs - yRangeDegs; minY = minY - deltaYRange / 2.0; maxY = maxY + deltaYRange / 2.0; } else { double newXRangeKms = yDensity * plotAreaWidth; double newXRangeDegs = newXRangeKms / longKmsPerDeg; double deltaXRange = newXRangeDegs - xRangeDegs; minX = minX - (deltaXRange / 2.0); maxX = maxX + (deltaXRange / 2.0); } { // X Axis Custom Labels ca.AxisX.CustomLabels.Clear(); double delta = (maxX - minX) / 5.0; char d = (char)176; string dStr = d.ToString(); double fromPos = minX; for (int xx = 0; xx < 5; ++xx) { double toPos = fromPos + delta; double midPos = (toPos + fromPos) / 2.0; double midPosAbs = Math.Abs(midPos); double degs = Math.Floor(midPosAbs); double mins = (midPosAbs - degs) * 60.0; string s = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "W" : "E"); CustomLabel cl = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline); ca.AxisX.CustomLabels.Add(cl); fromPos = toPos; } ca.AxisX.LabelStyle.Font = axisLabelFont; } { // Y Axis Custom Labels ca.AxisY.CustomLabels.Clear(); double delta = (maxY - minY) / 5.0; char d = (char)176; string dStr = d.ToString(); double fromPos = minY; for (int xx = 0; xx < 5; ++xx) { double toPos = fromPos + delta; double midPos = (toPos + fromPos) / 2.0; double midPosAbs = Math.Abs(midPos); double degs = Math.Floor(midPosAbs); double mins = (midPosAbs - degs) * 60.0; string s = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "S" : "N"); CustomLabel cl = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline); ca.AxisY.CustomLabels.Add(cl); fromPos = toPos; } ca.AxisY.LabelStyle.Font = axisLabelFont; } ca.AxisX.Minimum = minX; ca.AxisX.Maximum = maxX; ca.AxisY.Minimum = minY; ca.AxisY.Maximum = maxY; ProfileChart.ChartAreas[0].RecalculateAxesScale(); goalie.EndBlock(); } /* UpdateChartAreas */
} /* StartTheBackGroundProcedure */ private void BackGroundProcess() { backGroundRunning = true; PicesDataBase.ThreadInit(); OSservices.CreateDirectoryPath(reportFileDir); DateTime n = DateTime.Now; String logFileName = OSservices.AddSlash(PicesSipperVariables.TempDirectory()) + "InstrumentDataByDeployment_Log_" + n.Year.ToString("0000") + "-" + n.Month.ToString("00") + "-" + n.Day.ToString("00") + "_" + n.Hour.ToString("00") + "-" + n.Minute.ToString("00") + "-" + n.Hour.ToString("00") + ".txt"; backGroundLog = new PicesRunLog(logFileName); PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(backGroundLog); RunLogAddMsg("Cruise [" + cruiseName + "]" + "\n"); RunLogAddMsg("Station [" + stationName + "]" + "\n"); RunLogAddMsg("Deployment [" + deploymentNum + "]" + "\n"); RunLogAddMsg("Start Date/Time [" + DateTime.Now.ToString("yyyy-MMM-dd HH:mm:ss") + "]" + "\n"); RunLogAddMsg("Active DataBase [" + threadConn.Server.Description + "]" + "\n"); PicesSipperDeploymentList deployments = null; if (!String.IsNullOrEmpty(deploymentNum)) { PicesSipperDeployment d = threadConn.SipperDeploymentLoad(cruiseName, stationName, deploymentNum); if (d != null) { deployments = new PicesSipperDeploymentList(); deployments.Add(d); } } else { deployments = threadConn.SipperDeploymentLoad(cruiseName, stationName); } if (deployments == null) { RunLogAddMsg("\n\nNo Deployments for Specified Criteria!\n\n"); return; } int reportNum = 0; foreach (PicesSipperDeployment d in deployments) { if (cancelBackGround) { break; } reportNum++; RunLogAddMsg("Generating Report " + reportNum.ToString() + " of " + deployments.Count.ToString()); SummarizeInstrumentDataForADeployment(threadConn, d.CruiseName, d.StationName, d.DeploymentNum); } threadConn.Close(); threadConn = null; GC.Collect(); PicesDataBase.ThreadEnd(); backGroundRunning = false; } /* BackGroundProcess */
private void AddSeriesToChart(DataSeriesToPlot dataSeries, ref double minX, ref double maxX, ref double minY, ref double maxY, ref DateTime minGpsDateTime, ref DateTime maxGpsDateTime ) { PicesGPSDataPointList gpsData = dataSeries.data; PicesSipperDeployment deployment = dataSeries.deployment; if (gpsData.Count < 2) { return; } TimeSpan adjGpsToActTime = deployment.SyncTimeStampActual - deployment.SyncTimeStampGPS; TimeSpan adjGpsToCTDTime = deployment.SyncTimeStampCTD - deployment.SyncTimeStampGPS; DateTime startTimeGps = new DateTime(1, 1, 1, 1, 1, 1); DateTime endTimeGps = new DateTime(1, 1, 1, 1, 1, 1); if (gpsData.Count > 0) { startTimeGps = gpsData[0].GpsUtcTime; if (startTimeGps.CompareTo(minGpsDateTime) < 0) { minGpsDateTime = startTimeGps; } } if (gpsData.Count > 1) { endTimeGps = gpsData[gpsData.Count - 1].GpsUtcTime; if (endTimeGps.CompareTo(maxGpsDateTime) > 0) { maxGpsDateTime = endTimeGps; } } DateTime startTimeAct = startTimeGps.Add(adjGpsToActTime); DateTime endTimeAct = endTimeGps.Add(adjGpsToActTime); String startTimeStr = startTimeAct.Hour.ToString("00") + ":" + startTimeAct.Minute.ToString("00"); String endTimeStr = endTimeAct.Hour.ToString("00") + ":" + endTimeAct.Minute.ToString("00"); String legend = ""; Series s = null; legend = deployment.CruiseName + "-" + deployment.StationName; if (!String.IsNullOrEmpty(deployment.DeploymentNum)) { legend += "-" + deployment.DeploymentNum; } legend += " (" + startTimeAct.ToString("MMM/dd HH:mm") + ")"; s = new Series(legend); s.BorderWidth = 2; s.ChartType = SeriesChartType.Point; s.ChartArea = "ChartArea1"; s.Name = legend; s.XAxisType = AxisType.Primary; s.MarkerStyle = MarkerStyle.Circle; s.Points.Clear(); if (dataSeries.latitudeMin < minY) { minY = dataSeries.latitudeMin; } if (dataSeries.latitudeMax > maxY) { maxY = dataSeries.latitudeMax; } if (dataSeries.longitudeMin < minX) { minX = dataSeries.longitudeMin; } if (dataSeries.longitudeMax > maxX) { maxX = dataSeries.longitudeMax; } foreach (PicesGPSDataPoint dp in gpsData) { DataPoint dataPoint = new DataPoint(dp.Longitude, dp.Latitude); s.Points.Add(dataPoint); } if (s.Points.Count > 0) { s.Points[0].Label = startTimeStr; } int count = s.Points.Count; if (count > 10) { s.Points[count - 1].Label = endTimeStr; int middle = count / 2; String middleLable = deployment.CruiseName + "(" + startTimeAct.ToString("yyyy-MM-dd") + ")"; s.Points[middle].Label = middleLable; s.Points[middle].Font = new Font(FontFamily.GenericSerif, 9.0f); } dataSeries.chartSeriesIndex = ProfileChart.Series.Count; ProfileChart.Series.Add(s); } /* AddSeriesToChart */
} /* HighLightClosestPoint */ private void ProfileChart_MouseClick(object sender, MouseEventArgs e) { Point p = e.Location; //MouseClickLocation.Text = p.X.ToString () + "," + p.Y.ToString (); ChartArea ca = ProfileChart.ChartAreas[0]; double longitude = ca.AxisX.PixelPositionToValue((double)p.X); double latitude = ca.AxisY.PixelPositionToValue((double)p.Y); // Determine Threshold. int thInPixels = 25; double x = ca.AxisX.PixelPositionToValue((double)(p.X + thInPixels)); double degLongPerPixel = Math.Abs(x - longitude) / thInPixels; double y = ca.AxisY.PixelPositionToValue((double)(p.Y + thInPixels)); double degLatPerPixel = Math.Abs(y - latitude) / thInPixels; double longTH = degLongPerPixel * thInPixels; double latTH = degLatPerPixel * thInPixels; PicesGPSDataPoint closestPoint = null; int closestPointIndex = -1; int closestPointSeriesIndex = -1; double closestPointDistSquare = double.MaxValue; PicesSipperDeployment closestDeployment = null; foreach (DataSeriesToPlot dstp in series) { if (dstp.WithInThreshold(longitude, longTH, latitude, latTH)) { double distSquare = double.MaxValue; int closestPointInSeriesIndex = -1; PicesGPSDataPoint closestPointInSeries = dstp.ClosestPoint(longitude, longTH, latitude, latTH, ref closestPointInSeriesIndex, ref distSquare); if (closestPointInSeries != null) { if (distSquare < closestPointDistSquare) { closestPointIndex = closestPointInSeriesIndex; closestPointSeriesIndex = dstp.chartSeriesIndex; closestPointDistSquare = distSquare; closestPoint = closestPointInSeries; closestDeployment = dstp.deployment; } } } } if (closestPoint != null) { HighLightClosestPoint(closestPointSeriesIndex, closestPointIndex, closestPoint, closestDeployment); String gpsStr = PicesMethods.LatitudeLongitudeToString(closestPoint.Latitude, closestPoint.Longitude); CurGPSLocation.Text = gpsStr; COGField.Text = closestPoint.CourseOverGround.ToString("##0.0") + " deg's"; SOGField.Text = closestPoint.SpeedOverGround.ToString("#0.0") + " kts"; if (closestDeployment != null) { DeploymentHighlighted.Text = closestDeployment.ShortDescription + "(" + closestDeployment.DateTimeStart.ToString("yyyy-MM-dd") + ")"; } else { DeploymentHighlighted.Text = "Cruise"; } } }
public ImageViewer(PicesRaster _raster, PicesDataBaseImage _image, PicesClassList _classes ) { runLog = new PicesRunLog(); raster = _raster; classes = _classes; dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); image = _image; sizeCoordinates = image.SizeCoordinates; if (raster == null) { raster = PicesRaster.GetOrigSipperImage(image.SipperFileName, image.ByteOffset, image.TopLeftRow, image.TopLeftCol, image.Height, image.Width, image.ConnectedPixelDist, runLog ); } if (raster == null) { MessageBox.Show("Could not locate source image or SipperFile[" + image.SipperFileName + "]"); return; } { uint scanLine = image.TopLeftRow; scanLine = 4096 * (uint)(scanLine / 4096); instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow); sipperFile = dbConn.SipperFileRecLoad(image.SipperFileName); } double pixelsPerScanLine = pixelsPerScanLineDefault; if (instrumentData != null) { if (instrumentData.ActiveColumns > 0) { pixelsPerScanLine = instrumentData.ActiveColumns; } if (instrumentData.FlowRate1 > 0.0) { flowRate1 = instrumentData.FlowRate1; } } if (sipperFile != null) { if (sipperFile.ScanRate > 0.0) { scanRate = sipperFile.ScanRate; } deployment = dbConn.SipperDeploymentLoad(sipperFile.CruiseName, sipperFile.StationName, sipperFile.DeploymentNum); if (deployment != null) { chamberWidth = deployment.ChamberWidth; } } if ((dataFieldAssignments == null) || (DataLabels == null)) { ConfigurationLoad(); } InitializeComponent(); if (image != null) { extractionLogEntry = dbConn.LogEntriesSelect(image.ExtractionLogEntryId); classLogEntry = dbConn.LogEntriesSelect(image.ClassLogEntryId); } mmPerPixelAccrossChamber = chamberWidth * mmPerMeter / pixelsPerScanLine; mmPerPixelWithFlow = mmPerMeter * flowRate1 / scanRate; DataLabels = new Label[4]; DataLabels[0] = DataLabel0; DataLabels[1] = DataLabel1; DataLabels[2] = DataLabel2; DataLabels[3] = DataLabel3; displayDataFields = new TextBox[4]; displayDataFields[0] = DataField0; displayDataFields[1] = DataField1; displayDataFields[2] = DataField2; displayDataFields[3] = DataField3; UpdateDataFields(); ImageFileName.Text = image.ImageFileName; }
private float[] CountsByDepth(PicesSipperDeployment deployment, PicesClass c ) { String msg = "Extracting Counts for \"" + deployment.CruiseName + "-" + deployment.StationName + "-" + deployment.DeploymentNum + "\""; statusMsgs.AddMsg(msg); msgQueue.AddMsg(msg); uint[] counts = null; PicesSipperFileList sipperFiles = threadConn.SipperFileLoad(deployment.CruiseName, deployment.StationName, deployment.DeploymentNum); foreach (PicesSipperFile sf in sipperFiles) { if (cancelRequested) { break; } statusMsgs.AddMsg("Retrieving counts for Class[" + c.Name + "] SipperFile[" + sf.SipperFileName + "]"); uint[] countsThisSipperFile = threadConn.ImageGetDepthStatistics(null, // PicesDataBaseImageGroup^ imageGroup, sf.SipperFileName, depthIncrement, // depthIncrements, c, // mlClass, classKeyToUse, // classKeyToUse, probMin, probMax, sizeMin, sizeMax ); counts = MergeTwoLists(counts, countsThisSipperFile); } if (cancelRequested) { return(null); } if (counts == null) { counts = new uint[1]; counts[0] = 0; } float[] countsFloat = new float[counts.Length]; for (int idx = 0; idx < counts.Length; ++idx) { countsFloat[idx] = counts[idx]; } if (!includeSubClasses) { return(countsFloat); } List <PicesClass> children = c.Children; if (children != null) { foreach (PicesClass pc in children) { if (cancelRequested) { break; } float[] countsForChild = CountsByDepth(deployment, pc); if (countsForChild != null) { countsFloat = MergeTwoLists(countsFloat, countsForChild); } } } return(countsFloat); } /* CountsByDepth */
public PlotRequest(PicesSipperDeployment _deployment) { deployment = _deployment; }