Пример #1
0
        //
        // Removes the panel from the scene manager
        //
        public void Remove()
        {
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;
            IAgStkGraphicsScreenOverlayCollectionBase collectionBase = (IAgStkGraphicsScreenOverlayCollectionBase)manager.ScreenOverlays.Overlays;

            collectionBase.Remove((IAgStkGraphicsScreenOverlay)m_Panel);
        }
Пример #2
0
        //
        // When the mouse pressed
        //
        public void Control3D_MouseDown(object sender, AxAGI.STKX.IAgUiAxVOCntrlEvents_MouseDownEvent e)
        {
            IAgStkGraphicsScreenOverlayPickResultCollection picked = null;
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;

            if (manager.Scenes.Count > 0)
            {
                picked = manager.Scenes[0].PickScreenOverlays(e.x, e.y);
            }

            OverlayButton button = FindButton(picked);

            IAgStkGraphicsOverlay overlay = (IAgStkGraphicsOverlay)m_Panel;

            if (button == null && OverlayPanelPicked(picked))
            {
                m_MouseDown           = true;
                m_Control3D.MouseMode = AGI.STKX.AgEMouseMode.eMouseModeManual;
                m_AnchorPoint         = new Point(e.x, e.y);

                overlay.Translucency       = m_PanelTranslucencyClicked;
                overlay.BorderTranslucency = m_PanelBorderTranslucencyClicked;

                if (manager.Scenes.Count > 0)
                {
                    manager.Scenes[0].Render();
                }
            }

            if (button != null)
            {
                m_MouseDown       = true;
                m_MouseOverButton = button;
                m_MouseDownButton = button;
                m_MouseOverButton.MouseDown();

                if (button == m_RotateButton)
                {
                    m_Tranforming         = true;
                    m_Control3D.MouseMode = AGI.STKX.AgEMouseMode.eMouseModeManual;
                    m_RotatePoint         = new Point(e.x, e.y);
                    EnableButtons(m_RotateButton, false);
                }
                if (button == m_ScaleButton)
                {
                    m_Tranforming         = true;
                    m_Control3D.MouseMode = AGI.STKX.AgEMouseMode.eMouseModeManual;
                    m_ScalePoint          = new Point(e.x, e.y);
                    m_StartScale          = overlay.Scale;
                    m_ScaleOffset         = overlay.TranslationX;
                    object[] bounds = (object[])overlay.ControlBounds;
                    m_ScaleBounds = new Rectangle((int)bounds.GetValue(0), (int)bounds.GetValue(1), (int)bounds.GetValue(2), (int)bounds.GetValue(3));
                    EnableButtons(m_ScaleButton, false);
                }
            }

            m_LastMouseClick = new Point(e.x, e.y);
        }
Пример #3
0
        public void MoonAction()
        {
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;
            IAgCrdnAxes moonAxes = ((IAgCrdnSystemAssembled)m_Root.CentralBodies["Moon"].Vgt.Systems["ICRF"]).ReferenceAxes.GetAxes();

            if (manager.Scenes.Count > 0)
            {
                manager.Scenes[0].Camera.ViewCentralBody("Moon", moonAxes);
            }
            m_Panning = false;
        }
Пример #4
0
        //
        // When the mouse is unpressed
        //
        public void Control3D_MouseUp(object sender, AxAGI.STKX.IAgUiAxVOCntrlEvents_MouseUpEvent e)
        {
            if (m_MouseDown)
            {
                IAgStkGraphicsScreenOverlayPickResultCollection picked = null;
                IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;
                if (manager.Scenes.Count > 0)
                {
                    picked = manager.Scenes[0].PickScreenOverlays(e.x, e.y);
                }

                OverlayButton button = FindButton(picked);

                IAgStkGraphicsOverlay overlay = (IAgStkGraphicsOverlay)m_Panel;

                if (button == null && OverlayPanelPicked(picked))
                {
                    overlay.Translucency       = m_PanelTranslucencyPicked;
                    overlay.BorderTranslucency = m_PanelBorderTranslucencyPicked;
                    if (!m_Animating)
                    {
                        if (manager.Scenes.Count > 0)
                        {
                            manager.Scenes[0].Render();
                        }
                    }
                }

                if (button != null)
                {
                    m_MouseOverButton = button;
                    m_MouseOverButton.MouseUp();

                    // Check if this button was under the mouse during both the mouse down and mouse up event
                    // (i.e. the button was clicked)
                    if (m_MouseOverButton == m_MouseDownButton)
                    {
                        m_MouseOverButton.MouseClick();
                    }
                }

                m_AnchorPoint = Point.Empty;
                m_RotatePoint = Point.Empty;
                m_ScalePoint  = Point.Empty;

                EnableButtons(null, true);
                m_BaseAnchorPoint = new Point((int)overlay.TranslationX, (int)overlay.TranslationY);

                m_Tranforming         = false;
                m_Control3D.MouseMode = AGI.STKX.AgEMouseMode.eMouseModeAutomatic;
                m_MouseDown           = false;
            }
        }
Пример #5
0
        public void OnMouseClick(IAgUiPlugin3DMouseEventArgs eventArgs, IAgUiPlugin3DNotifyContext context)
        {
            Array       position = new object[] { eventArgs.X, eventArgs.Y };
            IAgScenario scenario = (IAgScenario)CommonData.StkRoot.CurrentScenario;
            IAgStkGraphicsSceneManager sceneManager = scenario.SceneManager;
            IAgStkGraphicsScene        scene        = scenario.SceneManager.Scenes[eventArgs.SceneID - 1];

            //object[] cartographic = (object[])scene.Camera.WindowToCartographic("Earth", ref position);
            //string latitudeString = cartographic.GetValue(0).ToString();
            //string longitudeString = cartographic.GetValue(1).ToString();
            //double altitude = double.Parse(cartographic.GetValue(1).ToString());

            //NOTE:
            //If the angle unit is set to HMS or DMS, latitude and longitude string might not be directly converted to doubles.
        }
Пример #6
0
        //
        // When the mouse is double clicked
        //
        public void Control3D_MouseDoubleClick(object sender, EventArgs e)
        {
            IAgStkGraphicsScreenOverlayPickResultCollection picked = null;
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;

            if (manager.Scenes.Count > 0)
            {
                picked = manager.Scenes[0].PickScreenOverlays(m_LastMouseClick.X, m_LastMouseClick.Y);
            }

            OverlayButton button = FindButton(picked);

            IAgStkGraphicsOverlay overlay = (IAgStkGraphicsOverlay)m_Panel;

            if (button == null && OverlayPanelPicked(picked))
            {
                overlay.TranslationX = 0;
                overlay.TranslationY = 0;

                overlay.RotationAngle = 0;
                overlay.Scale         = 1;
                OrientButtons();
            }
        }
Пример #7
0
        //
        // Event handlers
        //

        //
        // When the mouse is moved
        //
        public void Control3D_MouseMove(object sender, AxAGI.STKX.IAgUiAxVOCntrlEvents_MouseMoveEvent e)
        {
            IAgStkGraphicsScreenOverlayPickResultCollection picked = null;
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;

            if (manager.Scenes.Count > 0)
            {
                picked = manager.Scenes[0].PickScreenOverlays(e.x, e.y);
            }

            OverlayButton button = FindButton(picked);

            IAgStkGraphicsOverlay overlay = (IAgStkGraphicsOverlay)m_Panel;

            if (!m_Tranforming)
            {
                if (OverlayPanelPicked(picked) && !m_PanelCurrentlyPicked)
                {
                    overlay.BorderTranslucency = m_PanelBorderTranslucencyPicked;
                    overlay.Translucency       = m_PanelTranslucencyPicked;
                    m_PanelCurrentlyPicked     = true;
                    m_PanelTranslucencyChanged = true;
                }
                else if (!OverlayPanelPicked(picked) && m_PanelCurrentlyPicked)
                {
                    overlay.BorderTranslucency = m_PanelBorderTranslucencyRegular;
                    overlay.Translucency       = m_PanelTranslucencyRegular;
                    m_PanelCurrentlyPicked     = false;
                    m_PanelTranslucencyChanged = true;
                }
                if (m_PanelTranslucencyChanged)
                {
                    m_PanelTranslucencyChanged = false;
                    if (!m_Animating)
                    {
                        if (manager.Scenes.Count > 0)
                        {
                            manager.Scenes[0].Render();
                        }
                    }
                }
            }

            if (button != null)
            {
                if (m_MouseOverButton != null && m_MouseOverButton != button)
                {
                    m_MouseOverButton.MouseLeave();
                }
                m_MouseOverButton = button;
                m_MouseOverButton.MouseEnter();
            }
            else
            {
                if (m_AnchorPoint != Point.Empty)
                {
                    int offsetX = (e.x - m_AnchorPoint.X);
                    int offsetY = (m_AnchorPoint.Y - e.y);

                    // This fixes the bug with the ScreenOverlayOrigin being different.
                    // Before, if you dragged left with +x to the left, the panel would
                    // have gone right.
                    if (overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginBottomRight ||
                        overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginCenterRight ||
                        overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginTopRight)
                    {
                        overlay.TranslationX = m_BaseAnchorPoint.X - offsetX;
                    }
                    else
                    {
                        overlay.TranslationX = m_BaseAnchorPoint.X + offsetX;
                    }

                    // check that translations in the x direction are inside the window
                    double dist = (m_Control3D.Width - m_PanelWidth) / 2;
                    double minX = -dist;
                    double maxX = dist;
                    if (overlay.TranslationX < minX)
                    {
                        overlay.TranslationX = minX;
                    }
                    else if (overlay.TranslationX > maxX)
                    {
                        overlay.TranslationX = maxX;
                    }

                    if (overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginTopRight ||
                        overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginTopCenter ||
                        overlay.Origin == AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginTopLeft)
                    {
                        overlay.TranslationY = m_BaseAnchorPoint.Y - offsetY;

                        // check that translations in the y direction are inside the window
                        double maxYBorder = m_Control3D.Height;
                        double minYBorder = overlay.Height;
                        if (overlay.TranslationY < minYBorder)
                        {
                            overlay.TranslationY = minYBorder;
                        }
                        else if (overlay.TranslationY > maxYBorder)
                        {
                            overlay.TranslationY = maxYBorder;
                        }
                    }
                    else
                    {
                        overlay.TranslationY = m_BaseAnchorPoint.Y + offsetY;

                        // check that translations in the y direction are inside the window
                        double yBorderDist = m_Control3D.Height - overlay.Height;
                        if (overlay.TranslationY < 0)
                        {
                            overlay.TranslationY = 0;
                        }
                        else if (overlay.TranslationY > yBorderDist)
                        {
                            overlay.TranslationY = yBorderDist;
                        }
                    }

                    if (!m_Animating)
                    {
                        if (manager.Scenes.Count > 0)
                        {
                            manager.Scenes[0].Render();
                        }
                    }
                }
                else if (m_RotatePoint != Point.Empty)
                {
                    Point current = new Point(e.x, e.y);
                    current.Offset(m_RotatePoint);
                    object[] bounds   = (object[])overlay.ControlBounds;
                    double   centerX  = ((double)overlay.ControlPosition.GetValue(0)) + ((int)bounds.GetValue(2)) / 2;
                    double   centerY  = ((double)overlay.ControlPosition.GetValue(1)) + ((int)bounds.GetValue(3)) / 2;
                    double   adjacent = (e.x - centerX);
                    double   opposite = ((m_Control3D.Bounds.Height - e.y) - centerY);

                    if (adjacent >= 0)
                    {
                        overlay.RotationAngle = Math.Atan(opposite / adjacent);
                    }
                    else
                    {
                        overlay.RotationAngle = Math.PI + Math.Atan(opposite / adjacent);
                    }

                    OrientButtons();

                    if (!m_Animating)
                    {
                        if (manager.Scenes.Count > 0)
                        {
                            manager.Scenes[0].Render();
                        }
                    }
                }
                else if (m_ScalePoint != Point.Empty)
                {
                    // Complete rework of scaling..
                    double scale = 1;

                    // Get the cos,sin and tan to make this easier to understand.
                    double cos = Math.Cos(overlay.RotationAngle);
                    double sin = Math.Sin(overlay.RotationAngle);
                    double tan = Math.Tan(overlay.RotationAngle);

                    double xVector = (e.x - m_ScalePoint.X);
                    double yVector = (m_ScalePoint.Y - e.y);

                    // Get the projection of e.X and e.Y in the direction
                    // of the toolbar's horizontal.
                    double x = ((xVector * cos + yVector * sin) * cos);
                    double y = ((xVector * cos + yVector * sin) * sin);

                    // Figure out if we are shrinking or growing the toolbar
                    // (This is dependant on the quadrant we are in)
                    double magnitude = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
                    if (sin >= 0 && cos >= 0 && tan >= 0)
                    {
                        magnitude = (x < 0 | y < 0) ? -magnitude : magnitude;
                    }
                    else if (sin >= 0)
                    {
                        magnitude = (x > 0 | y < 0) ? -magnitude : magnitude;
                    }
                    else if (tan >= 0)
                    {
                        magnitude = (x > 0 | y > 0) ? -magnitude : magnitude;
                    }
                    else if (cos >= 0)
                    {
                        magnitude = (x < 0 | y > 0) ? -magnitude : magnitude;
                    }

                    scale = ((magnitude + m_ScaleBounds.Width) / m_ScaleBounds.Width);

                    if (scale < 0)
                    {
                        scale = 0;
                    }


                    overlay.Scale = Math.Min(Math.Max(m_StartScale * scale, 0.5), 10);
                    double width      = m_PanelWidth * overlay.Scale;
                    double startWidth = m_PanelWidth * m_StartScale;

                    // Translate the toolbar in order to account for the
                    // fact that rotation does not affect the location
                    // of the toolbar, but just rotates the texture.
                    // (This causes the toolbar, if +/-90 degrees to scale
                    // off the screen if not fixed).
                    overlay.TranslationX = m_ScaleOffset - (((width / 2) - (startWidth / 2)) * Math.Abs(Math.Sin(overlay.RotationAngle)));

                    if (!m_Animating)
                    {
                        if (manager.Scenes.Count > 0)
                        {
                            manager.Scenes[0].Render();
                        }
                    }
                }
                else if (m_MouseOverButton != null)
                {
                    m_MouseOverButton.MouseLeave();
                    m_MouseOverButton = null;
                }
            }
        }
Пример #8
0
        //
        // Constructor
        //
        public OverlayToolbar(AgStkObjectRoot root, AGI.STKX.Controls.AxAgUiAxVOCntrl control)
        {
            m_Root      = root;
            m_Control3D = control;
            IAgStkGraphicsSceneManager manager = ((IAgScenario)m_Root.CurrentScenario).SceneManager;

            m_ButtonHolders = new List <OverlayButton>();
            IAgStkGraphicsScreenOverlayManager ScreenOverlayManager = manager.ScreenOverlays;

            //
            // Panel
            //
            m_Panel = manager.Initializers.TextureScreenOverlay.InitializeWithXYWidthHeight(0, 0, m_PanelWidth, OverlayButton.ButtonSize);
            IAgStkGraphicsOverlay overlay = (IAgStkGraphicsOverlay)m_Panel;

            overlay.Origin             = AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginBottomLeft;
            overlay.BorderSize         = 2;
            overlay.Color              = Color.Transparent;
            overlay.BorderColor        = Color.Transparent;
            overlay.Translucency       = m_PanelTranslucencyRegular;
            overlay.BorderTranslucency = m_PanelBorderTranslucencyRegular;

            IAgStkGraphicsScreenOverlayCollectionBase managerOverlays = (IAgStkGraphicsScreenOverlayCollectionBase)manager.ScreenOverlays.Overlays;

            managerOverlays.Add((IAgStkGraphicsScreenOverlay)m_Panel);

            //
            // Buttons
            //
            string         enabledImage, disabledImage;
            ActionDelegate action;

            //
            // ShowHide button
            //
            enabledImage  = Path.Combine(Application.StartupPath, "ToolbarImages\\visible.png");
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\invisible.png");
            action        = new ActionDelegate(ShowHideAction);
            AddButton(enabledImage, disabledImage, action);

            //
            // Reset button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\reset.png");
            action        = new ActionDelegate(ResetAction);
            AddButton(disabledImage, action);

            // DecreaseDelta button
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\decreasedelta.png");
            action        = new ActionDelegate(DecreaseDeltaAction);
            AddButton(disabledImage, action);

            //
            // StepBack button
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\stepreverse.png");
            action        = new ActionDelegate(StepReverseAction);
            AddButton(disabledImage, action);
            m_StepReverseButton = m_ButtonHolders[m_ButtonHolders.Count - 1];

            //
            // PlayBack button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\playreverse.png");
            action        = new ActionDelegate(PlayReverseAction);
            AddButton(disabledImage, action);

            //
            // Pause button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\pause.png");
            action        = new ActionDelegate(PauseAction);
            AddButton(disabledImage, action);

            //
            // Play button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\playforward.png");
            action        = new ActionDelegate(PlayForwardAction);
            AddButton(disabledImage, action);

            //
            // StepForward button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\stepforward.png");
            action        = new ActionDelegate(StepForwardAction);
            AddButton(disabledImage, action);
            m_StepForwardButton = m_ButtonHolders[m_ButtonHolders.Count - 1];

            //
            // IncreaseDelta button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\increasedelta.png");
            action        = new ActionDelegate(IncreaseDeltaAction);
            AddButton(disabledImage, action);

            //
            // Zoom button
            //
            enabledImage  = Path.Combine(Application.StartupPath, "ToolbarImages\\zoompressed.png");
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\zoom.png");
            action        = new ActionDelegate(ZoomAction);
            AddButton(enabledImage, disabledImage, action);
            m_ZoomButton = m_ButtonHolders[m_ButtonHolders.Count - 1];

            //
            // Pan button
            //
            enabledImage  = Path.Combine(Application.StartupPath, "ToolbarImages\\panpressed.png");
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\pan.png");
            action        = new ActionDelegate(PanAction);
            AddButton(enabledImage, disabledImage, action);

            //
            // Home button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\home.png");
            action        = new ActionDelegate(HomeAction);
            AddButton(disabledImage, action);

            //
            // Moon Button
            //
            disabledImage = Path.Combine(Application.StartupPath, "ToolbarImages\\moon.png");
            action        = new ActionDelegate(MoonAction);
            AddButton(disabledImage, action);

            IAgStkGraphicsScreenOverlayCollectionBase collectionBase = (IAgStkGraphicsScreenOverlayCollectionBase)overlay.Overlays;

            //
            // Scale button
            //
            m_ScaleButton = new OverlayButton(
                new ActionDelegate(ScaleAction),
                Path.Combine(Application.StartupPath, "ToolbarImages\\scale.png"),
                0, m_PanelWidth, 0.5, 0, m_Root);
            IAgStkGraphicsOverlay scaleOverlay = (IAgStkGraphicsOverlay)m_ScaleButton.Overlay;

            scaleOverlay.Origin = AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginTopRight;
            collectionBase.Add(m_ScaleButton.Overlay);
            m_ButtonHolders.Add(m_ScaleButton);

            //
            // Rotate button
            //
            m_RotateButton = new OverlayButton(
                new ActionDelegate(RotateAction),
                Path.Combine(Application.StartupPath, "ToolbarImages\\rotate.png"),
                0, m_PanelWidth, 0.5, 0, m_Root);
            IAgStkGraphicsOverlay rotateOverlay = (IAgStkGraphicsOverlay)m_RotateButton.Overlay;

            rotateOverlay.Origin = AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginBottomRight;
            collectionBase.Add(m_RotateButton.Overlay);
            m_ButtonHolders.Add(m_RotateButton);
            DockBottom();
        }