private void flipAndReverseToolStripMenuItem_Click(object sender, EventArgs e) { var selectedNode = treeViewMain.SelectedNode; var parent = treeViewMain.Nodes["NodeTilt"]; var original = selectedNode.Tag as TiltData; if (original == null) { return; } var tilt = original.Copy(); var uniqeName = FindUniqeName(selectedNode.Name + "_flippedreversed", treeViewMain.Nodes["NodeTilt"]); if (InputPrompt.InputStringBox("Flip and Reverse", "Enter a name.", ref uniqeName) != DialogResult.OK) { return; } tilt.Rename(uniqeName); tilt.FlipThenReverse(); AddNode(uniqeName, parent, tilt); var form2 = new ChartPlot(tilt.Title, tilt) { MdiParent = this }; form2.Show(); }
private void AddPlot(TreeNode node) { ChartPlot form2; // DO switch based on the root node index switch (node.Parent.Index) { case 0: var data = node.Tag as TiltData; if (data == null) { return; } form2 = new ChartPlot(data.Title, data) { MdiParent = this }; form2.Show(); break; case 1: var fdata = node.Tag as FraserData; if (fdata == null) { return; } form2 = new ChartPlot(fdata.Title, fdata) { MdiParent = this }; form2.Show(); break; case 2: var kh = node.Tag as KarousHjeltData; if (kh != null && kh.RawLength > 150) { MessageBox.Show( @"Due to the limitation of gridding implementation in this version, the filtered result could not be shown. However, you can still export the result into an external file.", @"Data Too Large To Grid", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } StartGriddingWorker(new Surface2D(kh)); break; case 3: var surfdata = node.Tag as Surface2D; StartGriddingWorker(surfdata); break; } }
private void tsAddData_Click(object sender, EventArgs e) { var dlg = importRawDialog.ShowDialog(); if (dlg != DialogResult.OK) { return; } var errcount = 0; foreach (var t in importRawDialog.FileNames) { TiltData input = null; try { input = VLFDataReader.Read(t); } catch (Exception) { errcount++; } finally { if (input != null) { var safename = Path.GetFileNameWithoutExtension(t); var newname = FindUniqeName(safename, treeViewMain.Nodes[0]); AddNode(newname, treeViewMain.Nodes[0], input); var form2 = new ChartPlot(input.Title, input) { MdiParent = this }; form2.Show(); } } } if (errcount > 0) { MessageBox.Show( $"The file(s) you are trying to import encountered an error.{Environment.NewLine}[Failed: {errcount} files, Success: {importRawDialog.FileNames.Length - errcount} files]", @"Import Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void tsbMovAvg_Click(object sender, EventArgs e) { var selectedNode = treeViewMain.SelectedNode; var parent = treeViewMain.Nodes["NodeTilt"]; var order = 3; if (InputPrompt.InputNumberBox("Moving Average Filter", "Filter Order", ref order) != DialogResult.OK) { return; } var data = selectedNode.Tag as TiltData; if (data != null && ((Math.Abs(order)) <= 1 || order > data.Npts)) { MessageBox.Show(@"Invalid filter order.", @"Error"); return; } if (data == null) { return; } var newname = FindUniqeName($"{selectedNode.Name}_MovAvg Order {Convert.ToInt32(order)}", parent); if (InputPrompt.InputStringBox("Moving Average Filter", "Enter a name.", ref newname) != DialogResult.OK) { return; } var smooth = VlfFilter.MovingAverage(data, Convert.ToInt32(order)); smooth.Rename(newname); AddNode(newname, parent, smooth); var form2 = new ChartPlot(newname, smooth) { MdiParent = this }; form2.Show(); }
private void krigingWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { var result = e.Result as Tuple <HeatMapSeries, Surface2D>; if (result == null || e.Cancelled) { return; } var form2 = new ChartPlot(result.Item1, result.Item2) { MdiParent = this }; form2.Show(); tsStatusLabel.Text = string.Empty; krigingProgressBar.Visible = false; krigingProgressBar.Value = 0; }
private void tsFraserFilter_Click(object sender, EventArgs e) { var selectedNode = treeViewMain.SelectedNode; var tiltData = selectedNode.Tag as TiltData; if (tiltData == null) { return; } if (tiltData.Npts < 4) { MessageBox.Show(@"There should be minimum of 4 data for this filter to work."); return; } var uniqeName = FindUniqeName(selectedNode.Name, treeViewMain.Nodes["NodeFraser"]); if (InputPrompt.InputStringBox("Fraser Filter", "Enter a name.", ref uniqeName) != DialogResult.OK) { return; } // Do Fraser Filtering var fraser = VlfFilter.Fraser(tiltData); fraser.Rename(uniqeName); AddNode(uniqeName, treeViewMain.Nodes["NodeFraser"], fraser); // Plot the result var form2 = new ChartPlot(uniqeName, fraser) { MdiParent = this }; form2.Show(); }
private void tsInterpolate_Click(object sender, EventArgs e) { var selectedNode = treeViewMain.SelectedNode; var data = selectedNode.Tag as TiltData; if (data == null) { return; } var spacing = Convert.ToSingle(Math.Floor(data.Spacing)); if (InputPrompt.InputNumberBox("Cubic Spline Interpolation", "Enter the new spacing", ref spacing) != DialogResult.OK) { return; } var npt = Convert.ToInt32(((data.Distances.Max() - data.Distances.Min()) / spacing) + 1); if ( InputPrompt.InputNumberBox("Cubic Spline Interpolation", "Enter the new npts (number of points).", ref npt) != DialogResult.OK) { return; } if ((data.Distances.Min() + ((npt - 1) * spacing) > data.Distances.Max())) { var dlg = MessageBox.Show(@"The new interpolated max distances will exceed the original max distances." + $"{Environment.NewLine}" + $"{Environment.NewLine}Original: {data.Distances.Max()} m, Interpolated: {data.Distances.Min() + ((npt - 1)*spacing)} m." + $"{Environment.NewLine}" + $"{Environment.NewLine}Do you want to continue?", @"Exceed Original Max Distances", MessageBoxButtons.YesNo, MessageBoxIcon.Question); Debug.WriteLine((data.Distances.Min() + (npt * spacing))); if (dlg == DialogResult.No) { return; } } var newname = FindUniqeName($"{selectedNode.Name}_Interpolated", treeViewMain.Nodes["NodeTilt"]); if (InputPrompt.InputStringBox("Cubic Spline Interpolation", "Enter a name.", ref newname) != DialogResult.OK) { return; } var tiltData = VlfInterpolation.CubicSplineNatural(data, Convert.ToSingle(spacing), npt); tiltData.Rename(newname); AddNode(newname, treeViewMain.Nodes["NodeTilt"], tiltData); var form2 = new ChartPlot(newname, tiltData) { MdiParent = this }; form2.Show(); }