示例#1
0
 public override void Initialize(DrawArgs drawArgs)
 {
     if (!base.IsOn)
     {
         return;
     }
     foreach (RenderableObject ro in base.m_children)
     {
         MyChart c = ro as MyChart;
         // if c is not in current view frustum
         if (!this.IsInViewFrustum(drawArgs.WorldCamera, c))
         {
             continue;
         }
         // is c is not initialized , initialize c.
         if (!c.Initialized)
         {
             //double layerLatitudeRange = this.east - this.west;
             //double chartLatitudeRange = layerLatitudeRange*c.Diameter/MyCharts.WindowWidth;
             //Angle chartAngle = World.ApproxAngularDistance(
             //   Angle.FromDegrees(c.Latitude),
             //   Angle.FromDegrees(c.Longitude),
             //   Angle.FromDegrees(c.Latitude + chartLatitudeRange),
             //   Angle.FromDegrees(c.Longitude)
             //   );
             //double chartDiameter = chartAngle.Radians*
             //                       (drawArgs.WorldCamera.WorldRadius
             //                        + c.DistanceAboveSurface);
             //c.Scale = (float) (chartDiameter/2.0);
             c.Initialize(drawArgs);
         }
     }
     base.RenderPriority = RenderPriority.Custom;
     base.Inited         = true;
 }
示例#2
0
 public override void Update(DrawArgs drawArgs)
 {
     if (!base.IsOn)
     {
         return;
     }
     // donot do update if not initialized
     if (!base.Initialized)
     {
         this.Initialize(drawArgs);
     }
     foreach (RenderableObject ro in base.m_children)
     {
         MyChart c = ro as MyChart;
         //if (c == null) {
         //   ro.Dispose();
         //   base.Remove(ro.Name);
         //   continue;
         //}
         if (!this.IsInViewFrustum(drawArgs.WorldCamera, c))
         {
             continue;
         }
         c.Update(drawArgs);
     }
 }
示例#3
0
 public override void Render(DrawArgs drawArgs)
 {
     if (!base.IsOn)
     {
         return;
     }
     // if not initialized, initialize and return, wait for next
     // render
     if (!base.Initialized)
     {
         //this.Initialize(drawArgs);
         return;
     }
     foreach (RenderableObject ro in base.m_children)
     {
         MyChart c = ro as MyChart;
         if (c == null)
         {
             continue;
         }
         if (c.Scale == 0)
         {
             base.Inited = false;
             return;
         }
         if (!this.IsInViewFrustum(drawArgs.WorldCamera, c))
         {
             continue;
         }
         c.Render(drawArgs);
         this.OnRendered(c);
     }
 }
示例#4
0
 private bool IsInViewFrustum(CameraBase camera, MyChart c)
 {
     if (c.Position
         == Vector3.Empty)
     {
         c.Position = MathEngine.SphericalToCartesian(c.Latitude, c.Longitude, camera.WorldRadius);
     }
     return(camera.ViewFrustum.ContainsPoint(c.Position));
 }
示例#5
0
        /// <summary>
        /// HighLight a chart in this layer.
        /// </summary>
        /// <param name="itemName">
        /// name of the chart to operate
        /// </param>
        /// <param name="highLight">
        /// indicates whether highlight the chart.
        /// </param>
        public override void Highlight(string itemName, bool highLight)
        {
            MyChart chart = base.GetObject(itemName) as MyChart;

            if (chart != null)
            {
                chart.HighLight = highLight;
            }
        }
示例#6
0
        /// <summary>
        /// if ro is chart, then add it to list.
        /// </summary>
        /// <param name="ro"></param>
        public override void Add(RenderableObject ro)
        {
            MyChart c = ro as MyChart;

            if (c == null)
            {
                ro.Dispose();
                return;
            }
            c.ParentWorld = this.ParentWorld;
            base.m_children.Add(ro);
            // the first chart added to this layer
            if (base.Count == 1)
            {
                this.east  = c.Longitude;
                this.west  = c.Longitude;
                this.south = c.Latitude;
                this.north = c.Latitude;
            }
            else
            {
                if (this.east
                    < c.Longitude)
                {
                    this.east = c.Longitude;
                }
                if (this.west
                    > c.Longitude)
                {
                    this.west = c.Longitude;
                }
                if (this.north
                    < c.Latitude)
                {
                    this.north = c.Latitude;
                }
                if (this.south
                    > c.Latitude)
                {
                    this.south = c.Latitude;
                }
            }
            base.Inited = false;
        }
示例#7
0
        protected virtual void OnRendered(MyChart c)
        {
            string localLayerName = base.Name.Substring(base.Name.IndexOf("_") + 1);

            if (c.IsMouseOverCaption ||
                c.IsMouseOverChart)
            {
                if (c.MouseEntered == false)
                {
                    this.OnMouseEnterItem(localLayerName, c.Name);
                    c.MouseEntered = true;
                }
            }
            else
            {
                if (c.MouseEntered == true)
                {
                    this.OnMouseLeaveItem(localLayerName, c.Name);
                    c.MouseEntered = false;
                }
            }
        }
示例#8
0
 private bool IsInViewFrustum(CameraBase camera, MyChart c)
 {
     if (c.Position
         == Vector3.Empty) {
         c.Position = MathEngine.SphericalToCartesian(c.Latitude, c.Longitude, camera.WorldRadius);
     }
     return camera.ViewFrustum.ContainsPoint(c.Position);
 }
示例#9
0
 protected virtual void OnRendered(MyChart c)
 {
     string localLayerName = base.Name.Substring(base.Name.IndexOf("_") + 1);
     if (c.IsMouseOverCaption
         || c.IsMouseOverChart) {
         if (c.MouseEntered == false) {
             this.OnMouseEnterItem(localLayerName, c.Name);
             c.MouseEntered = true;
         }
     }
     else {
         if (c.MouseEntered == true) {
             this.OnMouseLeaveItem(localLayerName, c.Name);
             c.MouseEntered = false;
         }
     }
 }
示例#10
0
        private static void AddMyChart(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
        {
            if (iter.Count > 0) {
                while (iter.MoveNext()) {
                    string isOnStr = iter.Current.GetAttribute("ShowAtStartup", "");
                    string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
                    string latStr = getInnerTextFromFirstChild(iter.Current.Select("Latitude/Value"));
                    string lonStr = getInnerTextFromFirstChild(iter.Current.Select("Longitude/Value"));
                    string distStr = getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface"));
                    string diaStr = getInnerTextFromFirstChild(iter.Current.Select("Diameter"));
                    string heightStr = getInnerTextFromFirstChild(iter.Current.Select("Height"));
                    Color chartColor = getColor(iter.Current.Select("ChartColor"));
                    string scaleStr = getInnerTextFromFirstChild(iter.Current.Select("Scale"));
                    string typeStr = getInnerTextFromFirstChild(iter.Current.Select("ChartType"));
                    string capTxt = getInnerTextFromFirstChild(iter.Current.Select("Caption/CaptionText"));
                    FontDescription capFontDesc = getDisplayFont(iter.Current.Select("Caption/DisplayFont"));
                    Color capColor = getColor(iter.Current.Select("CaptionColor"));
                    string clkUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
                    string minViewRng = getInnerTextFromFirstChild(iter.Current.Select("MinViewRange"));
                    string maxViewRng = getInnerTextFromFirstChild(iter.Current.Select("MaxViewRange"));

                    MyChart c = new MyChart(name, (float) ParseDouble(latStr), (float) ParseDouble(lonStr), (float) ParseDouble(distStr));
                    c.Diameter = (float) ParseDouble(diaStr);
                    c.Height = (float) ParseDouble(heightStr);
                    c.ChartColor = chartColor;
                    c.ChartType = typeStr;
                    c.Caption = capTxt;
                    c.CaptionFont = new Font(capFontDesc.FaceName, 9.0F);
                    c.CaptionColor = capColor;
                    c.ClickableUrl = clkUrl;
                    c.MinViewRange = (float) ParseDouble(minViewRng);
                    c.MaxViewRange = (float) ParseDouble(maxViewRng);
                    MyCharts.WindowWidth = 1024;
                    MyCharts myCharts = parentRenderable as MyCharts;
                    myCharts.Add(c);

                    c.ParentWorld = parentWorld;
                    c.ParentList = myCharts;
                    c.Scale = (float) ParseDouble(scaleStr);
                }
            }
        }