/// <summary> /// Gets the features from the selection that are from a given ft class /// </summary> /// <param name="ftClassName">ft class name</param> /// <returns>List of IFeature</returns> public List <ESRI.ArcGIS.Geodatabase.IFeature> GetSelectedFeatures(IFeatureLayer layer) { List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>(); if (layer == null) { return(result); } ESRI.ArcGIS.Carto.IFeatureSelection ftSelection = layer as ESRI.ArcGIS.Carto.IFeatureSelection; if (null != ftSelection && null != ftSelection.SelectionSet) { ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = ftSelection.SelectionSet; ESRI.ArcGIS.Geodatabase.ICursor cursor = null; try { selectionSet.Search(null, false, out cursor); ESRI.ArcGIS.Geodatabase.IRow ft = cursor.NextRow(); while (null != ft) { result.Add((ESRI.ArcGIS.Geodatabase.IFeature)ft); ft = cursor.NextRow(); } } finally { ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(cursor); } } return(result); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { m_command.OnClick(); m_hookHelper.ActiveView.Refresh(); IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint); IFeatureLayer featureLayer = GIS.Common.DataEditCommon.copypasteLayer; if (featureLayer == null) { return; } IFeatureSelection m_featureSelection = featureLayer as IFeatureSelection; ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = m_featureSelection.SelectionSet; if (m_selectionSet.Count == 0) { return; } IFeatureClass pFeatureClass = featureLayer.FeatureClass; ICursor pCursor = null; m_selectionSet.Search(null, false, out pCursor); IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor; IFeature m_pFeature = pFeatureCursor.NextFeature(); double dx = 0; double dy = 0; if (m_pFeature == null) { return; } DataEditCommon.InitEditEnvironment(); DataEditCommon.CheckEditState(); while (m_pFeature != null) { ITransform2D pTrans2D = m_pFeature.ShapeCopy as ITransform2D; if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry0Dimension) { IPoint pt = m_pFeature.Shape as IPoint; if (dx == 0) { dx = pPoint.X - pt.X; } if (dy == 0) { dy = pPoint.Y - pt.Y; } pTrans2D.Move(dx, dy); m_pFeature.Shape = pTrans2D as IGeometry; m_pFeature.Store(); } else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry1Dimension) { IPolyline lPolyline = m_pFeature.Shape as IPolyline; if (dx == 0) { dx = pPoint.X - lPolyline.FromPoint.X; } if (dy == 0) { dy = pPoint.Y - lPolyline.FromPoint.Y; } pTrans2D.Move(dx, dy); m_pFeature.Shape = pTrans2D as IGeometry; m_pFeature.Store(); } else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry2Dimension) { if (m_pFeature.FeatureType == esriFeatureType.esriFTAnnotation) { IAnnotationFeature annoFeature = m_pFeature as IAnnotationFeature; IElement element = (IElement)annoFeature.Annotation; ITextElement textElement = new TextElementClass(); IPoint mPoint = element.Geometry as IPoint; pTrans2D = mPoint as ITransform2D; if (dx == 0) { dx = pPoint.X - mPoint.X; } if (dy == 0) { dy = pPoint.Y - mPoint.Y; } pTrans2D.Move(dx, dy); element.Geometry = pTrans2D as IGeometry; annoFeature.Annotation = element; m_pFeature.Store(); } else { IPolygon lPolyline = m_pFeature.Shape as IPolygon; if (dx == 0) { dx = pPoint.X - lPolyline.FromPoint.X; } if (dy == 0) { dy = pPoint.Y - lPolyline.FromPoint.Y; } pTrans2D.Move(dx, dy); m_pFeature.Shape = pTrans2D as IGeometry; m_pFeature.Store(); } } else { } m_pFeature = pFeatureCursor.NextFeature(); } DataEditCommon.g_engineEditor.StopOperation("editpaste"); GIS.Common.DataEditCommon.copypaste = 0; DataEditCommon.copypasteLayer = null; m_hookHelper.ActiveView.Refresh(); //IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint); //IFeatureLayer featureLayer = DataEditCommon.g_pLayer as IFeatureLayer; //if (featureLayer == null) return; //if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == featureLayer.FeatureClass.ShapeType && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType == featureLayer.FeatureClass.FeatureType) //{ // ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = DataEditCommon.MyCopy.m_selectionSet; // for (int i = 0; i < m_selectionSet.Count; i++) // { // } //} //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && featureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation) //{ //} //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType!=esriFeatureType.esriFTAnnotation&& featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) //{ //} //DataEditCommon.InitEditEnvironment(); //DataEditCommon.CheckEditState(); }
private void button_Import_Click(object sender, System.EventArgs e) { // point to the first selected feature: ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass(); // Set properties for AGImportPathOptions AGImportPathOptionsCls.BasicMap = (ESRI.ArcGIS.Carto.IBasicMap)globe; // Explicit Cast AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast AGImportPathOptionsCls.AnimationType = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass(); AGImportPathOptionsCls.AnimatedObject = globe.GlobeDisplay.ActiveViewer.Camera; if (this.radioButton_flyby.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget; AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative); AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0); } else if (this.radioButton_currentTarget.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver; } else if (this.radioButton_currentObserver.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget; } double pAzimuth, pInclination, pRollVal; AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal); AGImportPathOptionsCls.LookaheadFactor = this.trackBarSimplificationFactor.Value / 100; AGImportPathOptionsCls.TrackName = this.textBox_TrackName.Text; AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState); AGImportPathOptionsCls.VerticalOffset = Convert.ToDouble(this.textBox_VertOffset.Text); AGImportPathOptionsCls.ReversePath = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState); // get the layer selected in the combo box if (this.comboBoxLayers.SelectedIndex == -1) { MessageBox.Show("Please select a layer before you proceed"); } else { //set the layer based on the item selected in the combo box ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex); // Explicit Cast // Get the line feature selected in the layer ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)layer; // Explicit Cast ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer; // Explicit Cast ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = featureSelection.SelectionSet; ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass; string shapeField = featureClass.ShapeFieldName; ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); IScene scene = globe.GlobeDisplay.Scene; ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference; spatialFilterCls.GeometryField = shapeField; spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference); ESRI.ArcGIS.Geodatabase.ICursor cursor; selectionSet.Search(spatialFilterCls, true, out cursor); ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor; // Explicit Cast ESRI.ArcGIS.Geodatabase.IFeature lineFeature; lineFeature = featureCursor.NextFeature(); if (lineFeature == null) { MessageBox.Show("Please select a feature in the feature layer selected"); } else { CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls); } } this.Close(); }