Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string      path   = textBox5.Text;
            string      s1     = textBox1.Text;
            string      s2     = textBox2.Text;
            string      s3     = textBox3.Text;
            string      s4     = textBox4.Text;
            string      mes    = String.Empty;
            IPosition61 dztpos = null;

            TECoClass      = new TerraExplorerClass();
            ITerraExplorer = (ITerraExplorer5)TECoClass;
            IInfoTree      = (IInformationTree5)TECoClass;
            IObjectManager = (IObjectManager5)TECoClass;
            try
            {
                double           dxcoord  = double.Parse(s1);
                double           dycoord  = double.Parse(s2);
                double           altitude = double.Parse(s3);
                AltitudeTypeCode ealit    = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                dztpos = MainForm.sgworld.Creator.CreatePosition(dxcoord, dycoord, altitude, ealit, 0, 90, 100.0, 1000);
                dzt    = MainForm.sgworld.Creator.CreateModel(dztpos, path, 1, ModelTypeCode.MT_NORMAL, 0, s4);
            }
            catch (Exception ex)
            {
                mes = String.Format("CreateLabelButton_Click Exception :{0}", ex.Message);
                Log4NetHelper.WriteLog(typeof(AddgeologicbodyForm), ex);
                MessageBox.Show(mes);
            }
        }
Пример #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            asc.controllInitializeSize(this);
            sgworld.OnLoadFinished += new
                                      _ISGWorld61Events_OnLoadFinishedEventHandler(OnProjectLoadFinished);
            //string flyFile = "http://www.skylineglobe.com/SkylineGlobe/WebClient/PresentationLayer/WebClient/SkyglobeLB.fly";
            string flyFile = Application.StartupPath + "\\elta.fly";

            //ITE.LoadEx(Application.StartupPath + @"\elta.fly", "", "", 0);
            sgworld.Project.Open(flyFile, true, null, null);
            CoTE                     = new TerraExplorerClass();
            ITE                      = (TerraExplorerX.ITerraExplorer5)CoTE;
            IInfoTree                = (TerraExplorerX.IInformationTree5)CoTE;
            IRender                  = (IRender5)CoTE;
            IObjectManager           = (IObjectManager5)CoTE;
            this.CoTE.OnLButtonDown += new _ITerraExplorerEvents5_OnLButtonDownEventHandler(OnLButtonDown);

            numObjs  = 0;
            currObj  = 0;
            objArray = new object[2000];
            sx       = new double[2000];
            sy       = new double[2000];
            xx       = new double[2000];
            yy       = new double[2000];
            InitArray();
        }
Пример #3
0
 public AddbuildingForm()
 {
     InitializeComponent();
     TECoClass      = new TerraExplorerClass();
     ITerraExplorer = (ITerraExplorer5)TECoClass;
     IInfoTree      = (IInformationTree5)TECoClass;
     IObjectManager = (IObjectManager5)TECoClass;
 }
Пример #4
0
 public MainForm()
 {
     InitializeComponent();
     asc.controllInitializeSize(this);
     this.CoTE      = new TerraExplorerClass();
     this.ITE       = (ITerraExplorer51)CoTE;
     this.IInfoTree = (IInformationTree5)CoTE;
     this.IPlane    = (IPlane5)CoTE;
     this.Ita       = (ITerrain5)CoTE;
     sgworld        = new SGWorld61();
     CoTE.OnFrame  += new _ITerraExplorerEvents5_OnFrameEventHandler(TE_OnFrame);
 }
Пример #5
0
        static Program()
        {
            TE = new TerraExplorerClass();
            sgworld = new SGWorld61Class();

            Program.ITE = Program.TE as ITerraExplorer5;
            Program.IInfoTree = (IInformationTree5)Program.TE;
            Program.pRender = (IRender5)Program.TE;
            Program.pPlane5 = (IPlane5)Program.TE;
            Program.Terrain5 = (ITerrain5)Program.TE;
            Program.pNavigate6 = (INavigate61)Program.sgworld.Navigate;
            Program.pIobject = (IObjectManager51)Program.TE;
            Program.pCreator6 = (ICreator61)Program.sgworld.Creator;
            Program.pDateTime = (IDateTime61)Program.sgworld.DateTime;
            Program.pCoordServices6 = (ICoordServices61)Program.sgworld.CoordServices;
            Program.CoordSys = (ICoordSys3)Program.TE;
        }
Пример #6
0
        /// <summary>
        /// 加载shape文件添加模型
        /// 模型数据要与shape在同一路径下
        /// 2012-09-21 张航宇
        /// 添加Z修正 -56
        /// </summary>
        /// <param name="FileName"></param>
        ///
        public void LoadShapeAdd3model(ISGWorld61 sgworld, ITerraExplorer te, string FileName)
        {
            IInformationTree5 infoTree5 = te as IInformationTree5;

            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }
            if (File.Exists(FileName))
            {
                bool   PathType     = true;
                string PathFileName = "";
                string GroupName    = "模型组群" + System.Guid.NewGuid().ToString().Substring(0, 6);
                infoTree5.CreateGroup(GroupName, 0);
                int    GroupID         = sgworld.ProjectTree.FindItem(GroupName);
                string ModelFilename   = "";
                string UNModelFilename = "";
                string _XMLLayerInfo   = "<PlugData>" +

                                         "<PlugType>shape</PlugType>" +

                                         "<LayerName>" + FileName + "</LayerName>" +

                                         "<Server></Server>" +

                                         "<user></user>" +

                                         "<password></password>" +

                                         "<TableName></TableName>" +

                                         "<AttributesToLoad>*</AttributesToLoad >" +

                                         "<Feature>1</Feature >" +

                                         "<Annotation>1</Annotation>" +

                                         "<SaveItems>0</SaveItems>" +

                                         "<GroupKey>LAT-LONG</GroupKey>" +

                                         "<SysKey>LAT-LONG</SysKey>" +

                                         "<DatumKey>WGS84</DatumKey>" +

                                         "<UnitKey>METERS</UnitKey>" +

                                         "<UseZValue>0</UseZValue>" +

                                         "<AltitudeUnit>Meters</AltitudeUnit>" +

                                         "<Reproject>1</Reproject>" +

                                         "<StreamedLayer>0</StreamedLayer></PlugData >";
                ILayer5 iLyr = infoTree5.CreateLayer("3DModleGoto", _XMLLayerInfo, GroupID);//在根目录下装载shp数据
                iLyr.Load();
                IFeature61 sqfeature61 = null;
                int        itemid      = sgworld.ProjectTree.FindItem("" + GroupName + "\\3DModleGoto");

                ILayer61 m_layer61 = sgworld.ProjectTree.GetLayer(itemid);
                m_layer61.Streaming = false;

                IFeatureGroups61 pFeatureGroups61 = m_layer61.FeatureGroups;

                IFeatureGroup61 pFeatureGroup61 = pFeatureGroups61.Point as IFeatureGroup61;
                if (pFeatureGroup61 == null)
                {
                    MessageBox.Show("当前操作要求是正确的点图层");
                    return;
                }
                else
                {
                    if (pFeatureGroup61.Count == 0)
                    {
                        MessageBox.Show("图层为空!");
                        return;
                    }
                    else
                    {
                        sqfeature61 = pFeatureGroup61[0] as IFeature61;
                        IFeatureAttributes61 m_FeatureAttributes = sqfeature61.FeatureAttributes;
                        int      AttributesCount = m_FeatureAttributes.Count;
                        string[] FiledArry       = new string[AttributesCount];
                        for (int f = 0; f < AttributesCount; f++)
                        {
                            IFeatureAttribute61 m_FeatureAttribute = m_FeatureAttributes[f] as IFeatureAttribute61;
                            FiledArry[f] = m_FeatureAttribute.Name;
                        }
                        Skyline.Core.UI.FrmAddModelShape pFrmAddModelShape = new Skyline.Core.UI.FrmAddModelShape();
                        pFrmAddModelShape.GetFiledName = FiledArry;
                        pFrmAddModelShape.ShowDialog();
                        PathFileName = pFrmAddModelShape.Filed;
                        PathType     = pFrmAddModelShape.PathType;
                        pFrmAddModelShape.Dispose();

                        int m_FeatureCount     = pFeatureGroup61.Count;
                        int ImportFeatureCount = pFeatureGroup61.Count;
                        for (int i = 0; i < m_FeatureCount; i++)
                        {
                            sqfeature61 = pFeatureGroup61[i] as IFeature61;
                            IFeatureAttributes61     _FeatureAttributes = sqfeature61.FeatureAttributes;
                            TerraExplorerX.IGeometry _Geometry          = sqfeature61.GeometryZ;
                            TerraExplorerX.IPoint    pPoint             = _Geometry as TerraExplorerX.IPoint;
                            //IPosition61 TPosition61 = sgworld.Window.PixelToWorld(pPoint.X, pPoint.Y, WorldPointType.WPT_ALL).Position;
                            IPosition61         TPosition61       = sgworld.Creator.CreatePosition(pPoint.X, pPoint.Y, -56, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0);
                            IFeatureAttribute61 _FeatureAttribute = _FeatureAttributes.GetFeatureAttribute(PathFileName);
                            UNModelFilename = _FeatureAttribute.Value.ToString();
                            if (PathType)
                            {
                                ModelFilename = System.IO.Path.GetDirectoryName(FileName) + "\\" + UNModelFilename;
                            }
                            else
                            {
                                ModelFilename = UNModelFilename;
                            }

                            try
                            {
                                sgworld.Creator.CreateModel(TPosition61, ModelFilename, 1, ModelTypeCode.MT_NORMAL, GroupID, UNModelFilename);
                            }
                            catch
                            {
                                ImportFeatureCount--;
                                continue;
                            }
                        }
                        MessageBox.Show(ImportFeatureCount + "个模型加载成功," + (m_FeatureCount - ImportFeatureCount) + "个模型加载失败!");

                        /****20130227杨漾(添加文件有效性判断,分步判断图层有效性,增加加载统计情况提示)****/
                    }
                }
            }
        }