コード例 #1
0
 /// <summary>
 /// 从子图层列表中移除一个图层
 /// Removes a layer from the child layer list
 /// </summary>
 /// <param name="objectName">被移除的图层对象的名称Name of object to remove</param>
 public virtual void Remove(string objectName)
 {
     lock (this.m_children.SyncRoot)
     {
         for (int i = 0; i < this.m_children.Count; i++)
         {
             RenderableObject ro = (RenderableObject)this.m_children[i];
             if (ro.Name.Equals(objectName))
             {
                 ro.ParentList = null;
                 ro.Dispose();
                 this.m_children.RemoveAt(i);
                 break;
             }
         }
     }
 }
コード例 #2
0
 public SurfaceImage(
     string imageFilePath,
     double north,
     double south,
     double west,
     double east,
     Texture texture,
     RenderableObject parentRenderable)
 {
     m_ParentRenderable = parentRenderable;
     m_ImageFilePath    = imageFilePath;
     m_North            = north;
     m_South            = south;
     m_West             = west;
     m_East             = east;
     m_Texture          = texture;
 }
コード例 #3
0
        /// <summary>
        /// 通过优先级对子节点进行排序
        /// Sorts the children list according to priority
        /// TODO: Redesign the render tree to perhaps a list, to enable proper sorting
        /// </summary>
        public virtual void SortChildren()
        {
            int index = 0;

            while (index + 1 < m_children.Count)
            {
                RenderableObject a = (RenderableObject)m_children[index];
                RenderableObject b = (RenderableObject)m_children[index + 1];
                if (a.RenderPriority > b.RenderPriority)
                {
                    // Swap
                    m_children[index]     = b;
                    m_children[index + 1] = a;
                    index = 0;
                    continue;
                }
                index++;
            }
        }
コード例 #4
0
        private int getIRenderableIndexFromParent(RenderableObject renderable)
        {
            if (renderable.ParentList == null)
            {
                return(-1);
            }
            else
            {
                for (int index = 0; index < renderable.ParentList.ChildObjects.Count; index++)
                {
                    if (renderable == renderable.ParentList.ChildObjects[index])
                    {
                        return(index);
                    }
                }
            }

            return(-1);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="oldRenderable"></param>
        /// <param name="newRenderable"></param>
        private void updateRenderable(RenderableObject oldRenderable, RenderableObject newRenderable)
        {
            if (oldRenderable is Icon && newRenderable is Icon)
            {
                Icon oldIcon = (Icon)oldRenderable;
                Icon newIcon = (Icon)newRenderable;

                oldIcon.SetPosition((float)newIcon.Latitude, (float)newIcon.Longitude, (float)newIcon.Altitude);
            }
            else if (oldRenderable is GCP && newRenderable is GCP)
            {
                GCP oldGCP = (GCP)oldRenderable;
                GCP newGCP = (GCP)newRenderable;

                oldGCP.SetPosition((float)newGCP.Latitude, (float)newGCP.Longitude, (float)newGCP.Altitude);
            }
            else if (oldRenderable is RenderableObjectList && newRenderable is RenderableObjectList)
            {
                RenderableObjectList oldList = (RenderableObjectList)oldRenderable;
                RenderableObjectList newList = (RenderableObjectList)newRenderable;

                compareRefreshLists(newList, oldList);
            }
        }
コード例 #6
0
 ///<summary>
 /// 使照相机ZOOM到图层的位置。
 /// </summary>
 protected virtual void OnGotoClick(object sender, EventArgs e)
 {
     lock (this.ParentList.ChildObjects.SyncRoot)
     {
         for (int i = 0; i < this.ParentList.ChildObjects.Count; i++)
         {
             RenderableObject ro = (RenderableObject)this.ParentList.ChildObjects[i];
             if (ro.Name.Equals(name))
             {
                 if (ro is QuadTileSet)
                 {//瓦片集
                     QuadTileSet qts = (QuadTileSet)ro;
                     //设置摄像机位置
                     DrawArgs.Camera.SetPosition((qts.North + qts.South) / 2, (qts.East + qts.West) / 2);
                     //垂直视域范围
                     double perpendicularViewRange = (qts.North - qts.South > qts.East - qts.West ? qts.North - qts.South : qts.East - qts.West);
                     //高度,海拔
                     DrawArgs.Camera.Altitude = qts.LayerRadius * Math.Sin(MathEngine.DegreesToRadians(perpendicularViewRange * 0.5));
                     break;
                 }
                 else if (ro is Icon)
                 {//图标
                     Icon ico = (Icon)ro;
                     DrawArgs.Camera.SetPosition(ico.Latitude, ico.Longitude);
                     if (ico.Altitude != 0)
                     {
                         DrawArgs.Camera.Altitude = ico.Altitude;
                     }
                     else
                     {
                         DrawArgs.Camera.Altitude = ico.MaximumDisplayDistance - 100000;
                     }
                     break;
                 }
                 else if (ro is Icons)
                 {
                     double lat = 0, lon = 0;
                     Icons  icons = ro as Icons;
                     foreach (Icon icon in icons.ChildObjects)
                     {
                         lat += icon.Latitude;
                         lon += icon.Longitude;
                     }
                     lat /= ((Icons)ro).ChildObjects.Count;
                     lon /= ((Icons)ro).ChildObjects.Count;
                     DrawArgs.Camera.SetPosition(lat, lon);
                     if (icons.MaximumDisplayDistance > 16521634)
                     {
                         icons.MaximumDisplayDistance = 16521634;
                     }
                     DrawArgs.Camera.Altitude = icons.MaximumDisplayDistance - 100000;
                     break;
                 }
                 else if (ro is GCP)
                 {
                     GCP gcp = (GCP)ro;
                     DrawArgs.Camera.SetPosition(gcp.Latitude, gcp.Longitude);
                     break;
                 }
                 else if (ro is GCPs)
                 {
                     double lat = 0, lon = 0;
                     foreach (GCP gcp in ((GCPs)ro).ChildObjects)
                     {
                         lat += gcp.Latitude;
                         lon += gcp.Longitude;
                     }
                     lat /= ((GCPs)ro).ChildObjects.Count;
                     lon /= ((GCPs)ro).ChildObjects.Count;
                     DrawArgs.Camera.SetPosition(lat, lon);
                     break;
                 }
                 else
                 {
                     DrawArgs.Camera.SetPosition((ro.Extension.North + ro.Extension.South) / 2, (ro.Extension.West + ro.Extension.East) / 2);
                     //垂直视域范围
                     double perpendicularViewRange = (ro.Extension.North - ro.Extension.South > ro.Extension.East - ro.Extension.West ? ro.Extension.North - ro.Extension.South : ro.Extension.East - ro.Extension.West);
                     //高度,海拔
                     double alt = (float)(ro.World.EquatorialRadius) * Math.Sin(MathEngine.DegreesToRadians(perpendicularViewRange * 1.1));
                     if (alt > ro.MaximumDisplayDistance - 100000)
                     {
                         alt = ro.MaximumDisplayDistance - 100000;
                     }
                     DrawArgs.Camera.Altitude = alt;
                 }
             }
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// 刷新图标集合图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void refreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (isUpdating)
            {
                return;
            }
            isUpdating = true;
            try
            {
                for (int i = 0; i < this.ChildObjects.Count; i++)
                {
                    RenderableObject ro = (RenderableObject)this.ChildObjects[i];
                    if (ro != null && ro.IsOn && ro is Icon)
                    {
                        Icon icon = (Icon)ro;

                        if (icon.RefreshInterval == TimeSpan.MaxValue || icon.LastRefresh > System.DateTime.Now - icon.RefreshInterval)
                        {
                            continue;
                        }

                        object      key         = null;
                        IconTexture iconTexture = null;

                        if (icon.TextureFileName != null && icon.TextureFileName.Length > 0)
                        {
                            if (icon.TextureFileName.ToLower().StartsWith("http://") && icon.SaveFilePath != null)
                            {
                                //download it
                                WebDownload webDownload = new WebDownload(icon.TextureFileName);
                                webDownload.DownloadType = DownloadType.Unspecified;

                                System.IO.FileInfo saveFile = new System.IO.FileInfo(icon.SaveFilePath);
                                if (!saveFile.Directory.Exists)
                                {
                                    saveFile.Directory.Create();
                                }

                                webDownload.DownloadFile(saveFile.FullName);

                                iconTexture = (IconTexture)m_textures[icon.SaveFilePath];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.Device, icon.SaveFilePath);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.Device, icon.SaveFilePath);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                            else
                            {
                                // Icon image from file
                                iconTexture = (IconTexture)m_textures[icon.TextureFileName];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.Device, icon.TextureFileName);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.Device, icon.TextureFileName);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                        }
                        else
                        {
                            // Icon image from bitmap
                            if (icon.Image != null)
                            {
                                iconTexture = (IconTexture)m_textures[icon.Image];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.Device, icon.Image);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.Device, icon.Image);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                        }

                        icon.LastRefresh = System.DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                isUpdating = false;
            }
        }
コード例 #8
0
 /// <summary>
 /// 添加一个Icon对象.
 /// </summary>
 public override void Add(RenderableObject ro)
 {
     m_children.Add(ro);
     IsInitialized = false;
 }
コード例 #9
0
ファイル: GCP.cs プロジェクト: AlvaIce/GFJT-2020
        /// <summary>
        /// 刷新控制点集合图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void refreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (isUpdating)
            {
                return;
            }
            isUpdating = true;
            try
            {
                for (int i = 0; i < this.ChildObjects.Count; i++)
                {
                    RenderableObject ro = (RenderableObject)this.ChildObjects[i];
                    if (ro != null && ro.IsOn && ro is GCP)
                    {
                        GCP GCP = (GCP)ro;

                        if (GCP.RefreshInterval == TimeSpan.MaxValue || GCP.LastRefresh > System.DateTime.Now - GCP.RefreshInterval)
                        {
                            continue;
                        }

                        object     key        = null;
                        GCPTexture GCPTexture = null;

                        if (GCP.TextureFileName != null && GCP.TextureFileName.Length > 0)
                        {
                            // GCP image from file
                            GCPTexture = (GCPTexture)m_textures[GCP.TextureFileName];
                            if (GCPTexture != null)
                            {
                                GCPTexture tempTexture = GCPTexture;
                                m_textures[GCP.SaveFilePath] = new GCPTexture(DrawArgs.Device, GCP.TextureFileName);
                                tempTexture.Dispose();
                            }
                            else
                            {
                                key        = GCP.SaveFilePath;
                                GCPTexture = new GCPTexture(DrawArgs.Device, GCP.TextureFileName);

                                // New texture, cache it
                                m_textures.Add(key, GCPTexture);

                                // Use default dimensions if not set
                                if (GCP.Width == 0)
                                {
                                    GCP.Width = GCPTexture.Width;
                                }
                                if (GCP.Height == 0)
                                {
                                    GCP.Height = GCPTexture.Height;
                                }
                            }
                        }
                        else
                        {
                            // GCP image from bitmap
                            if (GCP.Image != null)
                            {
                                GCPTexture = (GCPTexture)m_textures[GCP.Image];
                                if (GCPTexture != null)
                                {
                                    GCPTexture tempTexture = GCPTexture;
                                    m_textures[GCP.SaveFilePath] = new GCPTexture(DrawArgs.Device, GCP.Image);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key        = GCP.SaveFilePath;
                                    GCPTexture = new GCPTexture(DrawArgs.Device, GCP.Image);

                                    // New texture, cache it
                                    m_textures.Add(key, GCPTexture);

                                    // Use default dimensions if not set
                                    if (GCP.Width == 0)
                                    {
                                        GCP.Width = GCPTexture.Width;
                                    }
                                    if (GCP.Height == 0)
                                    {
                                        GCP.Height = GCPTexture.Height;
                                    }
                                }
                            }
                        }

                        GCP.LastRefresh = System.DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                isUpdating = false;
            }
        }