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(); }
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(); }