Exemplo n.º 1
0
        private void RotatingModel(double AxisX, double AxisY, double AxisZ, double Angle)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            this.bFinished          = false;
            this.modifyRowbufferMap = SelectCollection.Instance().Clone(this.beginRowbufferMap);
            if (this.modifyRowbufferMap != null)
            {
                foreach (DF3DFeatureClass featureClassInfo in this.modifyRowbufferMap.Keys)
                {
                    IFeatureClass        featureClass        = featureClassInfo.GetFeatureClass();
                    string               facName             = featureClassInfo.GetFacilityClassName();
                    IRowBufferCollection rowBufferCollection = this.modifyRowbufferMap[featureClassInfo] as IRowBufferCollection;
                    for (int i = 0; i < rowBufferCollection.Count; i++)
                    {
                        IRowBuffer rowBuffer = rowBufferCollection.Get(i);
                        if (rowBuffer != null)
                        {
                            int num = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName);
                            if (num != -1)
                            {
                                IGeometry geometry = rowBuffer.GetValue(num) as IGeometry;
                                if (geometry != null)
                                {
                                    ITransform transform = geometry as ITransform;
                                    if (geometry.HasZ())
                                    {
                                        transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle);
                                    }
                                    else
                                    {
                                        if (!geometry.HasZ() && AxisZ > 0.0)
                                        {
                                            transform.Rotate2D(this.centerX, this.centerY, Angle);
                                        }
                                    }
                                    rowBuffer.SetValue(num, transform);
                                }
                            }
                            #region 管线设施
                            if (facName == "PipeLine" || facName == "PipeNode" || facName == "PipeBuild" || facName == "PipeBuild1")
                            {
                                int num3 = rowBuffer.FieldIndex("Shape");
                                if (num3 != -1)
                                {
                                    IGeometry geometry = rowBuffer.GetValue(num3) as IGeometry;
                                    if (geometry != null)
                                    {
                                        ITransform transform = geometry as ITransform;
                                        if (geometry != null && transform != null)
                                        {
                                            if (geometry.HasZ())
                                            {
                                                transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle);
                                            }
                                            else
                                            {
                                                transform.Rotate2D(this.centerX, this.centerY, Angle);
                                            }
                                            rowBuffer.SetValue(num3, transform);
                                        }
                                    }
                                }
                                int num4 = rowBuffer.FieldIndex("FootPrint");
                                if (num4 != -1)
                                {
                                    IGeometry geometry = rowBuffer.GetValue(num4) as IGeometry;
                                    if (geometry != null)
                                    {
                                        ITransform transform = geometry as ITransform;
                                        if (geometry != null && transform != null)
                                        {
                                            if (geometry.HasZ())
                                            {
                                                transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle);
                                            }
                                            else
                                            {
                                                transform.Rotate2D(this.centerX, this.centerY, Angle);
                                            }
                                            rowBuffer.SetValue(num4, transform);
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection);
                    //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                }
            }
        }
Exemplo n.º 2
0
        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);
        }