Example #1
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();
        }
Example #2
0
        private void usingKarousHjeltToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var nodes =
                (from TreeNode node in treeViewMain.Nodes["NodeTilt"].Nodes select(TreeNode) node.Clone()).ToList();
            var form2 = new TreeInput(nodes);
            var dlg   = form2.ShowDialog();

            if (dlg != DialogResult.OK)
            {
                return;
            }

            var nodeName = "Untitled";

            if (InputPrompt.InputStringBox("2D Surface", "Enter a name.", ref nodeName) != DialogResult.OK)
            {
                return;
            }

            // Collect all tiltdata from treeview
            IList <TiltData> gather =
                (from TreeNode node in form2.treeView1.Nodes where node.Checked select node.Tag as TiltData).ToList();

            //Build using Fraser filter
            var surf2D = new Surface2D(gather, Surface2D.FilterType.KarousHjelt)
            {
                Title      = nodeName,
                XAxisTitle = "Easting",
                YAxisTitle = "Northing",
                XUnit      = "m",
                YUnit      = "m"
            };

            nodeName = FindUniqeName(nodeName, treeViewMain.Nodes["Node2DSurface"]);
            StartGriddingWorker(surf2D);
            AddNode(nodeName, treeViewMain.Nodes["Node2DSurface"], surf2D);
        }
Example #3
0
        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();
        }