public override void OnAdd(object sender, EventArgs e) { SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(DEM, SurveyLibrary.frmImportRaster.Purposes.AssociatedSurface, "Associated Surface", new IntPtr(0)); if (EditTreeItem(frm) == DialogResult.OK) { GCDConsoleLib.Raster rAssoc = frm.ProcessRaster(); AssocSurface assoc = new AssocSurface(frm.txtName.Text, rAssoc.GISFileInfo, DEM, AssocSurface.AssociatedSurfaceTypes.Other); DEM.AssocSurfaces.Add(assoc); ProjectManager.Project.Save(); ProjectManager.AddNewProjectItemToMap(assoc); LoadChildNodes(); // Loop through the child nodes and select the item that was just added foreach (TreeNode childNode in Nodes) { if (childNode is TreeNodeItem) { if (((TreeNodeItem)childNode).Item.Equals(assoc)) { TreeView.SelectedNode = childNode; break; } } } } }
public void AddAssociatedSurface(AssocSurface assocRow) { IGroupLayer pAssocGrpLyr = AddAssociatedSurfaceGroupLayer(assocRow.DEM); short dTransparency = GCDCore.Properties.Settings.Default.TransparencyAssociatedLayers ? GCDCore.Properties.Settings.Default.AutoTransparencyValue : (short)-1; IRasterRenderer rasterRenderer = null; switch (assocRow.AssocSurfaceType) { case AssocSurface.AssociatedSurfaceTypes.InterpolationError: if (!GCDCore.Properties.Settings.Default.ApplyComparativeSymbology) { rasterRenderer = RasterSymbolization.CreateClassifyRenderer(assocRow.Raster, 11, "Slope"); } break; case AssocSurface.AssociatedSurfaceTypes.PointQuality3D: if (!GCDCore.Properties.Settings.Default.ApplyComparativeSymbology) { rasterRenderer = RasterSymbolization.CreateClassifyRenderer(assocRow.Raster, 11, "Precipitation", true); } break; case AssocSurface.AssociatedSurfaceTypes.PointDensity: assocRow.Raster.ComputeStatistics(); decimal rasterMax = assocRow.Raster.GetStatistics()["max"]; if (rasterMax <= 2 & rasterMax > 0.25m) { rasterRenderer = RasterSymbolization.CreateClassifyRenderer(assocRow.Raster, 11, "Green to Blue", 1.1, true); } else { rasterRenderer = RasterSymbolization.CreateClassifyRenderer(assocRow.Raster, 11, "Green to Blue", true); } break; case AssocSurface.AssociatedSurfaceTypes.GrainSizeStatic: rasterRenderer = RasterSymbolization.CreateGrainSizeStatisticColorRamp(assocRow.Raster, ProjectManager.Project.Units.VertUnit); break; case AssocSurface.AssociatedSurfaceTypes.Roughness: rasterRenderer = RasterSymbolization.CreateRoughnessColorRamp(assocRow.Raster); break; case AssocSurface.AssociatedSurfaceTypes.SlopeDegree: rasterRenderer = RasterSymbolization.CreateSlopeDegreesColorRamp(assocRow.Raster); break; case AssocSurface.AssociatedSurfaceTypes.SlopePercent: rasterRenderer = RasterSymbolization.CreateSlopePrecentRiseColorRamp(assocRow.Raster); break; } AddRasterLayer(assocRow.Raster, rasterRenderer, assocRow.Name, pAssocGrpLyr, assocRow.LayerHeader, dTransparency); }
public frmAssociatedSurface(DEMSurvey dem, AssocSurface assoc) { InitializeComponent(); DEM = dem; Assoc = assoc; AssocType = assoc.AssocSurfaceType; }
private void cmdOK_Click(object sender, EventArgs e) { if (!ValidateForm()) { DialogResult = DialogResult.None; return; } try { Cursor = Cursors.WaitCursor; if (Assoc == null) { FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text); fiOutput.Directory.Create(); switch (SelectedAssociatedSurfaceType) { case AssocSurface.AssociatedSurfaceTypes.SlopeDegree: GCDConsoleLib.RasterOperators.SlopeDegrees(DEM.Raster, fiOutput, ProjectManager.OnProgressChange); break; case AssocSurface.AssociatedSurfaceTypes.SlopePercent: GCDConsoleLib.RasterOperators.SlopePercent(DEM.Raster, fiOutput, ProjectManager.OnProgressChange); break; default: // This form is not capable of creating other associated surface types throw new NotImplementedException(string.Format("The associated surface form is not capable of creating {0} rasters", SelectedAssociatedSurfaceType)); } Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, SelectedAssociatedSurfaceType); DEM.AssocSurfaces.Add(Assoc); ProjectManager.AddNewProjectItemToMap(Assoc); } else { Assoc.Name = txtName.Text; Assoc.AssocSurfaceType = SelectedAssociatedSurfaceType; } ProjectManager.Project.Save(); Cursor = Cursors.Default; } catch (Exception ex) { GCDException.HandleException(ex, "Error generating associated surface raster."); DialogResult = DialogResult.None; } }
private void frmAssociatedSurface_Load(object sender, EventArgs e) { cboType.DataSource = AssocSurface.GetAssocatedSurfaceTypes(); SelectedAssociatedSurfaceType = AssocType; if (Assoc == null) { cmdOK.Text = Properties.Resources.CreateButtonText; ucRaster.Visible = false; txtPath.Width = ucRaster.Right - txtPath.Left; cboType.Enabled = false; this.txtName.TextChanged += txtName_TextChanged; switch (AssocType) { case AssocSurface.AssociatedSurfaceTypes.SlopeDegree: txtName.Text = "Slope Degrees"; break; case AssocSurface.AssociatedSurfaceTypes.SlopePercent: txtName.Text = "Slope Percent"; break; case AssocSurface.AssociatedSurfaceTypes.PointDensity: txtName.Text = "Point Density"; break; } ucRasterProperties1.Visible = false; Height -= cmdOK.Top - ucRasterProperties1.Top; FormBorderStyle = FormBorderStyle.FixedDialog; } else { txtName.Text = Assoc.Name; txtPath.Text = ProjectManager.Project.GetRelativePath(Assoc.Raster.GISFileInfo); cmdOK.Text = Properties.Resources.UpdateButtonText; txtPath.Visible = false; ucRaster.Width = ucRaster.Right - txtPath.Left; ucRaster.Left = txtPath.Left; ucRaster.InitializeExisting("Associated Surface", Assoc.Raster); ucRasterProperties1.Initialize(Assoc.Noun, Assoc.Raster); } tTip.SetToolTip(txtName, "The name used to refer to this associated surface within this GCD project. It cannot be empty and must be unique among all associated surfaces for the parent DEM survey."); tTip.SetToolTip(txtPath, "The relative file path where this associated surface raster is stored."); tTip.SetToolTip(cboType, "The type of values represented in this associated surface."); }
private void btnOK_Click(object sender, System.EventArgs e) { try { if (!ValidateForm()) { DialogResult = DialogResult.None; return; } Cursor = Cursors.WaitCursor; FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text); fiOutput.Directory.Create(); RasterOperators.PointDensity(DEM.Raster, ucPointCloud.SelectedItem, fiOutput, KernelShape, valSampleDistance.Value, ProjectManager.OnProgressChange); Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, AssocSurface.AssociatedSurfaceTypes.PointDensity); DEM.AssocSurfaces.Add(Assoc); ProjectManager.Project.Save(); ProjectManager.AddNewProjectItemToMap(Assoc); Cursor = Cursors.Default; } catch (Exception ex) { Cursor = Cursors.Default; DialogResult = DialogResult.None; if (ex.Message.ToLower().Contains("multipart") || ex.Message.ToLower().Contains("multi-part")) { MessageBox.Show("The ShapeFile contains multi-part features and is incompatible with the GCD. Please select a single part point ShapeFile.", "Multi-Part Features Detected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { GCDException.HandleException(ex, "Error generating point density associated surface raster."); } } }
public void OnEdit(object sender, EventArgs e) { TreeNodeItem node = sender as TreeNodeItem; Form frm = null; if (Item is AssocSurface) { AssocSurface assoc = Item as AssocSurface; frm = new SurveyLibrary.frmAssociatedSurface(assoc.DEM, assoc); } else if (Item is ErrorSurface && ((ErrorSurface)Item).Surf is DEMSurvey) { ErrorSurface err = Item as ErrorSurface; if (err.ErrorProperties.Count < 1) { frm = new SurveyLibrary.frmSurfaceProperties(Item as GCDProjectRasterItem, true); } else { if (err.Mask == null) { frm = new SurveyLibrary.ErrorSurfaces.frmSingleMethodError(err); } else { frm = new SurveyLibrary.ErrorSurfaces.frmMultiMethodError(err); } } } else if (Item is GCDCore.Project.ProfileRoutes.ProfileRoute) { GCDCore.Project.ProfileRoutes.ProfileRoute route = Item as GCDCore.Project.ProfileRoutes.ProfileRoute; frm = new UserInterface.ProfileRoutes.frmProfileRouteProperties(route.ProfileRouteType, route); } else if (Item is GCDCore.Project.Masks.DirectionalMask) { frm = new Masks.frmDirectionalMaskProps(Item as GCDCore.Project.Masks.DirectionalMask); } else if (Item is GCDCore.Project.Masks.AOIMask) { frm = new Masks.frmAOIProperties(Item as GCDCore.Project.Masks.AOIMask); } else if (Item is GCDCore.Project.Masks.RegularMask) { frm = new Masks.frmMaskProperties(Item as GCDCore.Project.Masks.RegularMask); } else if (Item is GCDCore.Project.LinearExtraction.LinearExtraction) { frm = new LinearExtraction.frmLinearExtractionProperties(Item as GCDCore.Project.LinearExtraction.LinearExtraction); } else { // Generic raster properties form if (Item is GCDProjectRasterItem) { frm = new SurveyLibrary.frmSurfaceProperties(Item as GCDProjectRasterItem, true); } else { throw new NotImplementedException("Unhandled editing of project type"); } } if (frm is Form) { EditTreeItem(frm); } }