public void GeometryEditStart(DF3DFeatureClass fcInfo, IRenderGeometry renderGeo, gviGeoEditType editType) { if (this._app == null || this._app.Current3DMapControl == null) { return; } if (this._geoEditor.IsEditing) { this.StopEdit(true); } this.curGeoField = fcInfo.GetFeatureLayer().GeometryFieldName; this._renderGeometry = renderGeo; this._FeatureClass = fcInfo; Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = fcInfo.GetFeatureClass(); this._row = featureClass.CreateRowBuffer(); int num = this._row.FieldIndex(this.curGeoField); if (num != -1 && this._renderGeometry != null) { this._row.SetValue(num, this._renderGeometry.GetFdeGeometry()); } this._geoEditType = editType; this._InteractaMode = this._app.Current3DMapControl.InteractMode; this._app.Current3DMapControl.InteractMode = gviInteractMode.gviInteractEdit; if (!this._geoEditor.StartEditRenderGeometry(renderGeo, editType)) { this._app.Current3DMapControl.InteractMode = this._InteractaMode; XtraMessageBox.Show("暂不支持该类型的编辑"); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); }
private void RoateGeometry() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } double num = double.Parse(this.spinEditX.EditValue.ToString()); double num2 = double.Parse(this.spinEditY.EditValue.ToString()); double num3 = double.Parse(this.spinEditZ.EditValue.ToString()); if (num == 0.0 && num2 == 0.0 && num3 == 0.0) { return; } num = 3.14 * num / 180.0; num2 = 3.14 * num2 / 180.0; num3 = 3.14 * num3 / 180.0; if (this._connInfo == null || this._oid == -1) { return; } Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = null; try { featureClass = this._connInfo.GetFeatureClass(); IFeatureLayer featureLayer = this._connInfo.GetFeatureLayer(); Gvitech.CityMaker.FdeCore.IRowBuffer row = featureClass.GetRow(this._oid); int num4 = row.FieldIndex(featureLayer.GeometryFieldName); if (num4 != -1) { IGeometry geometry = row.GetValue(num4) as IGeometry; if (geometry != null) { IVector3 vector = new Vector3Class(); vector.Set(1.0, 0.0, 0.0); app.Current3DMapControl.ObjectEditor.Rotate(vector, geometry.Envelope.Center, num); vector.Set(0.0, 1.0, 0.0); app.Current3DMapControl.ObjectEditor.Rotate(vector, geometry.Envelope.Center, num2); vector.Set(0.0, 0.0, 1.0); app.Current3DMapControl.ObjectEditor.Rotate(vector, geometry.Envelope.Center, num3); } } } catch (System.Exception) { } finally { //if (featureClass != null) //{ // System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); // featureClass = null; //} } }
public void GeometryEditStart(DF3DFeatureClass fcInfo, Gvitech.CityMaker.FdeCore.IRowBuffer row, gviGeoEditType editType) { if (this._app == null || this._app.Current3DMapControl == null) { return; } if (this._geoEditor.IsEditing) { this.StopEdit(true); } this.curGeoField = fcInfo.GetFeatureLayer().GeometryFieldName; this._FeatureClass = fcInfo; this._row = row; this._geoEditType = editType; this._InteractaMode = this._app.Current3DMapControl.InteractMode; this._app.Current3DMapControl.InteractMode = gviInteractMode.gviInteractEdit; if (!this._geoEditor.StartEditFeatureGeometry(row, fcInfo.GetFeatureLayer(), editType)) { this._app.Current3DMapControl.InteractMode = this._InteractaMode; XtraMessageBox.Show("暂不支持该类型的编辑"); } }
public void StopEdit(bool bSave) { if (this._app == null || this._app.Current3DMapControl == null) { return; } try { if (this._isSpatialQuery) { if (!bSave) { this._geoEditor.CancelEdit(); } else { this._geoEditor.FinishEdit(); } if (this.spatialQueryEditStopEvent != null) { this.spatialQueryEditStopEvent(bSave); } this._isSpatialQuery = false; this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._FeatureClass != null && this._row != null) { if (!bSave) { this._geoEditor.CancelEdit(); if (this._renderGeometry != null) { this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._geoEditor.IsEditing && bSave) { this._geoEditor.FinishEdit(); } Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = this._FeatureClass.GetFeatureClass(); int position = this._row.FieldIndex(this._FeatureClass.GetFeatureLayer().GeometryFieldName); IGeometry geometry = this._row.GetValue(position) as IGeometry; if (this._geoEditType == gviGeoEditType.gviGeoEditCreator) { ITopologicalOperator2D topologicalOperator2D = geometry as ITopologicalOperator2D; if (topologicalOperator2D == null || !topologicalOperator2D.IsSimple2D()) { XtraMessageBox.Show("创建的对象无效!"); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } else { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); rowBufferCollection.Add(this._row); CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(this._FeatureClass, rowBufferCollection, true, true); this._app.Current3DMapControl.FeatureManager.CreateFeature(featureClass, this._row); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); this._app.Workbench.UpdateMenu(); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); CommonUtils.Instance().FdeUndoRedoManager.UpdateFeature(featureClass, this._row); CommandManagerServices.Instance().CallCommand(cmd); this._app.Workbench.UpdateMenu(); } if (this._row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(this._row); this._row = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } }
private void RoateSelection() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } double num = double.Parse(this.spinEditX.EditValue.ToString()); double num2 = double.Parse(this.spinEditY.EditValue.ToString()); double num3 = double.Parse(this.spinEditZ.EditValue.ToString()); if (num == 0.0 && num2 == 0.0 && num3 == 0.0) { return; } num = 3.14 * num / 180.0; num2 = 3.14 * num2 / 180.0; num3 = 3.14 * num3 / 180.0; System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> rowBuffers = this.GetRowBuffers(); if (rowBuffers.Count < 1) { return; } IEnvelope selectEnvelope = SelectCollection.Instance().GetSelectEnvelope(SelectCollection.Instance().FcRowBuffersMap); double centerX = 0.0; double centerY = 0.0; double centerZ = 0.0; if (selectEnvelope != null) { centerX = (selectEnvelope.MinX + selectEnvelope.MaxX) / 2.0; centerY = (selectEnvelope.MinY + selectEnvelope.MaxY) / 2.0; centerZ = (selectEnvelope.MinZ + selectEnvelope.MaxZ) / 2.0; } foreach (DF3DFeatureClass current in rowBuffers.Keys) { Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = current.GetFeatureClass(); IFeatureLayer featureLayer = current.GetFeatureLayer(); IRowBufferCollection rowBufferCollection = rowBuffers[current]; for (int i = 0; i < rowBufferCollection.Count; i++) { Gvitech.CityMaker.FdeCore.IRowBuffer rowBuffer = rowBufferCollection.Get(i); int position = rowBuffer.FieldIndex(featureLayer.GeometryFieldName); IGeometry geometry = rowBuffer.GetValue(position) as IGeometry; ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (this._editType == RenderEditorType.RotateCenterType) { IEnvelope envelope = geometry.Envelope; centerX = (envelope.MinX + envelope.MaxX) / 2.0; centerY = (envelope.MinY + envelope.MaxY) / 2.0; centerZ = (envelope.MinZ + envelope.MaxZ) / 2.0; } if (geometry.HasZ()) { transform.Rotate3D(1.0, 0.0, 0.0, centerX, centerY, centerZ, num); transform.Rotate3D(0.0, 1.0, 0.0, centerX, centerY, centerZ, num2); transform.Rotate3D(0.0, 0.0, 1.0, centerX, centerY, centerZ, num3); } else { transform.Rotate2D(centerX, centerY, num3); } rowBuffer.SetValue(position, transform); } } app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap); this.UpdateDatabase(rowBuffers); }