예제 #1
0
        public void Initialize(DrawArgs drawArgs)
        {
            // Initialize fonts
            if (m_drawingFont == null)
            {
                System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
                m_drawingFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

                System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
                m_wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

                System.Drawing.Font worldwinddings = new System.Drawing.Font("World Wind dings", 12.0f);
                m_worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
            }

            // Initialize icon if any
            if (m_imageName.Trim() != string.Empty)
            {
                object key = null;

                // Icon image from file
                m_iconTexture = (JHU_IconTexture)m_textures[m_imageName];
                if (m_iconTexture == null)
                {
                    key           = m_imageName;
                    m_iconTexture = new JHU_IconTexture(drawArgs.device, JHU_Globals.getInstance().BasePath + @"\Data\Icons\Interface\" + m_imageName);
                }

                if (m_iconTexture != null)
                {
                    m_iconTexture.ReferenceCount++;

                    if (key != null)
                    {
                        // New texture, cache it
                        m_textures.Add(key, m_iconTexture);
                    }

                    if (m_size.Width == 0)
                    {
                        m_size.Width = m_iconTexture.Width;
                    }

                    if (m_size.Height == 0)
                    {
                        m_size.Height = m_iconTexture.Height;
                    }

                    this.XScale = (float)m_size.Width / m_iconTexture.Width;
                    this.YScale = (float)m_size.Height / m_iconTexture.Height;
                }

                if (m_sprite == null)
                {
                    m_sprite = new Sprite(drawArgs.device);
                }
            }

            m_isInitialized = true;
        }
예제 #2
0
        public bool PerformRMBAction(MouseEventArgs e)
        {
            int      closestIconDistanceSquared = int.MaxValue;
            JHU_Icon closestIcon = null;
            DrawArgs drawArgs    = JHU_Globals.getInstance().WorldWindow.DrawArgs;

            foreach (RenderableObject ro in m_children)
            {
                // If renderable object can handle the selection
                if (!ro.IsOn)
                {
                    continue;
                }
                if (!ro.isSelectable)
                {
                    continue;
                }

                JHU_Icon icon = ro as JHU_Icon;

                // if its a JHU_Icon check to see if we're on top
                if (icon != null)
                {
                    // don't check if we aren't even in view
                    if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position))
                    {
                        // check if inside current icon's selection rectangle
                        Vector3 projectedPoint = drawArgs.WorldCamera.Project(icon.Position);

                        int dx = e.X - (int)projectedPoint.X;
                        int dy = e.Y - (int)projectedPoint.Y;

                        if (icon.SelectionRectangle.Contains(dx, dy))
                        {
                            // Mouse is over, check whether this icon is closest
                            int distanceSquared = dx * dx + dy * dy;
                            if (distanceSquared < closestIconDistanceSquared)
                            {
                                closestIconDistanceSquared = distanceSquared;
                                closestIcon = icon;
                            }
                        }
                    }
                }
            }

            // if no other object has handled the selection let the closest icon try
            if (closestIcon != null)
            {
                if (closestIcon.PerformRMBAction(e))
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Default Constructor
        /// </summary>
        public JHU_CompassWidget()
        {
            m_textures = JHU_Globals.getInstance().Textures;

            m_location.X    = 5;
            m_location.Y    = 100;
            m_size.Height   = 79;
            m_size.Width    = 79;
            m_isInitialized = false;
        }
예제 #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public JHU_ButtonWidget()
        {
            m_textures = JHU_Globals.getInstance().Textures;

            m_location.X    = 90;
            m_location.Y    = 100;
            m_size.Height   = 32;
            m_size.Width    = 32;
            m_isInitialized = false;
        }
예제 #5
0
        public JHU_TreeNodeWidget()
        {
            m_textures = JHU_Globals.getInstance().Textures;

            m_location.X    = 0;
            m_location.Y    = 0;
            m_size.Height   = NODE_HEIGHT;
            m_size.Width    = 100;
            m_ConsumedSize  = m_size;
            m_isInitialized = false;
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.Icon"/> class
        /// </summary>
        /// <param name="name">Name of the icon</param>
        /// <param name="latitude">Latitude in decimal degrees.</param>
        /// <param name="longitude">Longitude in decimal degrees.</param>
        public JHU_Icon(string name,
                        double latitude,
                        double longitude) : base(name)

        {
            m_latitude  = (float)latitude;
            m_longitude = (float)longitude;

            m_globals  = JHU_Globals.getInstance();
            m_textures = m_globals.Textures;
        }
예제 #7
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public JHU_ControlWidget()
        {
            m_textures = JHU_Globals.getInstance().Textures;

            m_location.X    = 10;
            m_location.Y    = 5;
            m_size.Height   = 90;
            m_size.Width    = 180;
            m_isInitialized = false;

            LeftClickAction = new MouseClickAction(this.PerformLMBAction);
        }
예제 #8
0
        public static void PerformReset(System.Windows.Forms.MouseEventArgs e)
        {
            DrawArgs drawArgs = JHU_Globals.getInstance().WorldWindow.DrawArgs;

            double lat = drawArgs.WorldCamera.Latitude.Degrees;
            double lon = drawArgs.WorldCamera.Longitude.Degrees;
            double alt = drawArgs.WorldCamera.Altitude;
            double fov = drawArgs.WorldCamera.ViewRange.Degrees;

            JHU_Globals.getInstance().WorldWindow.GotoLatLon(lat, lon, 0, alt, fov, 0);

            JHU_Log.Write(1, "NAV", drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, drawArgs.WorldCamera.Altitude, "", "Reset Button Pressed");
        }
예제 #9
0
        public static void PerformZoomIn(System.Windows.Forms.MouseEventArgs e)
        {
            DrawArgs drawArgs = JHU_Globals.getInstance().WorldWindow.DrawArgs;

            double alt = System.Math.Round(drawArgs.WorldCamera.Altitude);

            alt = alt * 0.8;
            if (alt <= 0)
            {
                return;
            }
            drawArgs.WorldCamera.Altitude = alt;

            JHU_Log.Write(1, "NAV", drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, alt, "", "Zoom In Button Pressed");
        }
예제 #10
0
        /// <summary>
        /// Initializes the button by loading the texture, creating the sprite and figure out the scaling.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Initialize(DrawArgs drawArgs)
        {
            object key = null;

            // Icon image from file
            m_iconTexture = (JHU_IconTexture)m_textures[m_imageName];
            if (m_iconTexture == null)
            {
                key           = m_imageName;
                m_iconTexture = new JHU_IconTexture(drawArgs.device, JHU_Globals.getInstance().BasePath + @"\Data\Icons\Interface\" + m_imageName);
            }

            if (m_iconTexture != null)
            {
                m_iconTexture.ReferenceCount++;

                if (key != null)
                {
                    // New texture, cache it
                    m_textures.Add(key, m_iconTexture);
                }

                if (m_size.Width == 0)
                {
                    m_size.Width = m_iconTexture.Width;
                }

                if (m_size.Height == 0)
                {
                    m_size.Height = m_iconTexture.Height;
                }

                this.XScale = (float)m_size.Width / m_iconTexture.Width;
                this.YScale = (float)m_size.Height / m_iconTexture.Height;
            }

            if (m_sprite == null)
            {
                m_sprite = new Sprite(drawArgs.device);
            }

            if (m_crossHairs == null)
            {
                m_crossHairs = new Line(drawArgs.device);
            }

            m_isInitialized = true;
        }
예제 #11
0
        public override void Dispose()
        {
            if (isInitialized)
            {
                m_sprite.Dispose();
                m_sprite = null;

                JHU_Globals.getInstance().WorldWindow.MouseUp -= new MouseEventHandler(OnMouseUp);

                isInitialized        = false;
                m_needToInitChildren = true;
                m_childrenToInit.Clear();
            }

            // base dispose calls dispose of all children
            base.Dispose();
        }
예제 #12
0
        /// <summary>
        /// Default implementation of left click.
        /// </summary>
        /// <param name="e">Mouse event parameters</param>
        public void PerformLMBAction(System.Windows.Forms.MouseEventArgs e)
        {
            double lon = (e.X - this.AbsoluteLocation.X) * 2 - 180;
            double lat = (e.Y - this.AbsoluteLocation.Y) * 2 - 90;

            if (lat > 0)
            {
                lat = -lat;
            }
            else
            {
                lat = System.Math.Abs(lat);
            }

            JHU_Globals.getInstance().WorldWindow.GotoLatLon(lat, lon);

            JHU_Log.Write(1, "NAV", lat, lon, 0, this.Name, "Control Widget Goto Point Called.");
        }
예제 #13
0
        public override void Initialize(DrawArgs drawArgs)
        {
            if (!isOn)
            {
                return;
            }

            if (!isInitialized)
            {
                JHU_Globals.getInstance().WorldWindow.MouseUp += new MouseEventHandler(OnMouseUp);
                m_sprite = new Sprite(drawArgs.device);

                // force the init of all children
                m_needToInitChildren = true;
                m_childrenToInit.Clear();
            }

            InitializeChildren(drawArgs);

            isInitialized = true;
        }
예제 #14
0
        public static void PerformBuildingZoom(System.Windows.Forms.MouseEventArgs e)
        {
            JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Altitude = 1000;

            JHU_Log.Write(1, "NAV", JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Latitude.Degrees, JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Longitude.Degrees, JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Altitude, "", "Building Zoom Button Pressed");
        }