/// <summary>
        /// Creates a new instance. Font, Name and LinkScalars properties must be specified.
        /// </summary>
        public LinkBudgetOverlayHelper(Font font)
        {
            m_font = font;

            // GraphicsParameterFormatter is part of Platform.Graphics and
            // optimizes dynamic text generation by only recalculating
            // values as they are needed. For example, if a field is not,
            // time varying, it will never evaluate it more than once.
            m_formatter = new GraphicsParameterFormatter
            {
                // Specify a format string that provides the output we want.
                FormatString = @"Name: {0}
Effective Isotropic Radiated Power: {1:0.000} dBW
Received Isotropic Power: {2:0.000} dBW
Power At Receiver Output: {3:0.000} dBW
Received Power Flux Density: {4:0.000} dBW/m^2
Propagation Loss: {5:0.000} dB
Carrier To Noise Density: {6:0.000} dB*Hz
Carrier To Noise: {7:0.000} dB
Energy Per Bit To Noise Density: {8:0.000} dB
Bit Error Rate: {9:0.###E+000}"
            };

            // Create a screen overlay with a translucent background to make the
            // text easier to read.
            m_overlay = new ScreenOverlay(0.0, 0.0, 1.0, 1.0)
            {
                Color        = Color.Black,
                Translucency = 0.5f,
                Origin       = ScreenOverlayOrigin.TopLeft
            };

            // Create a child overlay for our background to write text on.
            m_textOverlay = new TextureScreenOverlay(0.0, 0.0, 1.0, 1.0)
            {
                Origin = ScreenOverlayOrigin.Center,
                Color  = Color.Yellow
            };
            m_overlay.Overlays.Add(m_textOverlay);

            if (TextureFilter2D.Supported(TextureWrap.ClampToEdge))
            {
                m_textOverlay.TextureFilter = TextureFilter2D.NearestClampToEdge;
            }
        }
Beispiel #2
0
            /// <summary>
            /// Initializes a new instance.
            /// </summary>
            public OverlayButtonHolder(Insight3D insight3D, Action action, string enabledImage, string disabledImage, int xOffset, double panelWidth)
            {
                m_insight3D     = insight3D;
                m_action        = action;
                m_enabled       = true;
                m_enabledImage  = enabledImage;
                m_disabledImage = disabledImage;
                m_xOffset       = xOffset;

                m_overlay = new TextureScreenOverlay
                {
                    X            = xOffset / panelWidth,
                    XUnit        = ScreenOverlayUnit.Fraction,
                    Width        = ButtonSize / panelWidth,
                    WidthUnit    = ScreenOverlayUnit.Fraction,
                    Height       = 1.0,
                    HeightUnit   = ScreenOverlayUnit.Fraction,
                    Translucency = MouseExitTranslucency,
                    Texture      = SceneManager.Textures.FromUri(disabledImage)
                };
            }
        /// <summary>
        /// Update the number of satellites on the text panel
        /// </summary>
        private void SetText(int number)
        {
            if (m_textOverlay != null)
            {
                m_textPanel.Overlays.Remove(m_textOverlay);
                m_textOverlay = null;
            }

            Font     font       = new Font("Arial", 10, FontStyle.Bold);
            string   text       = "Satellites:\n" + number;
            Size     textSize   = Insight3DHelper.MeasureString(text, font);
            Bitmap   textBitmap = new Bitmap(textSize.Width, textSize.Height);
            Graphics gfx        = Graphics.FromImage(textBitmap);

            gfx.DrawString(text, font, Brushes.Black, new PointF(0, 0));
            m_textOverlay = new TextureScreenOverlay(0, 0, textSize.Width, textSize.Height)
            {
                Origin  = ScreenOverlayOrigin.Center,
                Texture = SceneManager.Textures.FromBitmap(textBitmap)
            };
            m_textPanel.Overlays.Add(m_textOverlay);
        }
        private void OnLoad(object sender, EventArgs e)
        {
            // Create overlay toolbar and panels
            m_overlayToolbar = new OverlayToolbar(m_insight3D);
            m_overlayToolbar.Overlay.Origin = ScreenOverlayOrigin.BottomCenter;

            // Add additional toolbar buttons

            // Number of Satellites Button
            m_overlayToolbar.AddButton(GetDataFilePath("Textures/OverlayToolbar/manysatellites.png"),
                                       GetDataFilePath("Textures/OverlayToolbar/fewsatellites.png"),
                                       ToggleNumberOfSatellites);

            // Show/Hide Access Button
            m_overlayToolbar.AddButton(GetDataFilePath("Textures/OverlayToolbar/noshowaccess.png"),
                                       GetDataFilePath("Textures/OverlayToolbar/showaccess.png"),
                                       ToggleComputeAccess);

            // Initialize the text panel
            m_textPanel = new TextureScreenOverlay(0, 0, 80, 35)
            {
                Origin             = ScreenOverlayOrigin.TopRight,
                BorderSize         = 2,
                BorderColor        = Color.Transparent,
                BorderTranslucency = 0.6f,
                Color        = Color.Transparent,
                Translucency = 0.4f
            };
            SceneManager.ScreenOverlays.Add(m_textPanel);

            // Show label for the moon
            Scene scene = m_insight3D.Scene;

            scene.CentralBodies[CentralBodiesFacet.GetFromContext().Moon].ShowLabel = true;

            // Create a marker primitive for the facility at Bells Beach Australia
            EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;

            Cartographic facilityPosition = new Cartographic(Trig.DegreesToRadians(144.2829), Trig.DegreesToRadians(-38.3697), 0.0);

            Texture2D facilityTexture = SceneManager.Textures.FromUri(GetDataFilePath(@"Markers\Facility.png"));

            MarkerBatchPrimitive marker = new MarkerBatchPrimitive(SetHint.Infrequent)
            {
                Texture = facilityTexture
            };

            marker.Set(new[] { earth.Shape.CartographicToCartesian(facilityPosition) });

            SceneManager.Primitives.Add(marker);

            PointCartographic point     = new PointCartographic(earth, facilityPosition);
            Axes           topographic  = new AxesNorthEastDown(earth, point);
            ReferenceFrame facilityTopo = new ReferenceFrame(point, topographic);

            m_fixedToFacilityTopoEvaluator = GeometryTransformer.GetReferenceFrameTransformation(earth.FixedFrame, facilityTopo);
            Axes temeAxes = earth.TrueEquatorMeanEquinoxFrame.Axes;

            m_temeToFixedEvaluator = GeometryTransformer.GetAxesTransformation(temeAxes, earth.FixedFrame.Axes);
            m_showAccess           = true;
            m_satellites           = new Satellites();
            CreateSatellites("stkSatDb");

            // This Render() is needed so that the stars will show.
            scene.Render();
        }
Beispiel #5
0
        /// <summary>
        /// Construct a default instance.
        /// </summary>
        public Main()
        {
            InitializeComponent();

            m_insight3D      = new Insight3D();
            m_insight3D.Dock = DockStyle.Fill;
            m_insight3DPanel.Controls.Add(m_insight3D);

            m_defaultStart = GregorianDate.Now;
            m_defaultEnd   = m_defaultStart.AddDays(1);

            m_animation            = new SimulationAnimation();
            SceneManager.Animation = m_animation;

            m_display = new ServiceProviderDisplay();

            m_forceModelSettings = new ForceModelSettings(s_jplData, GetDataFilePath("EarthGravityFile_EGM2008.grv"));
            m_integratorSettings = new IntegratorSettings();
            m_area.Text          = "20";
            m_mass.Text          = "500";

            // Create overlay toolbar and panels
            m_overlayToolbar = new OverlayToolbar(m_insight3D);
            m_overlayToolbar.Overlay.Origin = ScreenOverlayOrigin.BottomCenter;

            // Initialize the text panel
            TextureScreenOverlay textPanel = new TextureScreenOverlay(0, 0, 220, 35)
            {
                Origin             = ScreenOverlayOrigin.TopRight,
                BorderSize         = 0,
                BorderColor        = Color.Transparent,
                BorderTranslucency = 1.0f,
                Color        = Color.Transparent,
                Translucency = 1.0f
            };

            SceneManager.ScreenOverlays.Add(textPanel);

            m_dateTimeFont = new Font("Courier New", 12, FontStyle.Bold);
            Size textSize = Insight3DHelper.MeasureString(m_defaultStart.ToString(), m_dateTimeFont);

            m_textOverlay = new TextureScreenOverlay(0, 0, textSize.Width, textSize.Height)
            {
                Origin     = ScreenOverlayOrigin.Center,
                BorderSize = 0
            };
            textPanel.Overlays.Add(m_textOverlay);

            // Show label for the moon
            m_insight3D.Scene.CentralBodies[CentralBodiesFacet.GetFromContext().Moon].ShowLabel = true;

            // Set the name for the element that will get propagated
            m_elementID = "Satellite";

            // Subscribe to the time changed event
            SceneManager.TimeChanged += OnTimeChanged;

            // Set the start and stop times
            m_start.CustomFormat = DateFormat;
            m_end.CustomFormat   = DateFormat;

            m_start.Text = m_defaultStart.ToString(DateFormat);
            m_end.Text   = m_defaultEnd.ToString(DateFormat);

            m_animation.Time      = m_defaultStart.ToJulianDate();
            m_animation.StartTime = m_defaultStart.ToJulianDate();
            m_animation.EndTime   = m_defaultEnd.ToJulianDate();

            // Dynamically set the camera's position and direction so that the camera will always be pointed at the daylit portion of the earth.
            EarthCentralBody       earth               = CentralBodiesFacet.GetFromContext().Earth;
            SunCentralBody         sun                 = CentralBodiesFacet.GetFromContext().Sun;
            VectorTrueDisplacement earthToSunVector    = new VectorTrueDisplacement(earth.CenterOfMassPoint, sun.CenterOfMassPoint);
            VectorEvaluator        earthToSunEvaluator = earthToSunVector.GetEvaluator();
            Cartesian     earthToSunCartesian          = earthToSunEvaluator.Evaluate(new JulianDate(m_defaultStart));
            UnitCartesian earthToSunUnitCartesian      = new UnitCartesian(earthToSunCartesian);
            UnitCartesian cameraDirection              = new UnitCartesian(earthToSunUnitCartesian.Invert());
            Cartesian     cameraPosition               = new Cartesian(earthToSunUnitCartesian.X * 50000000, earthToSunUnitCartesian.Y * 50000000, earthToSunUnitCartesian.Z * 50000000);

            m_insight3D.Scene.Camera.Position  = cameraPosition;
            m_insight3D.Scene.Camera.Direction = cameraDirection;
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        public OverlayToolbar(Insight3D insight3D)
        {
            m_insight3D     = insight3D;
            m_buttonHolders = new List <OverlayButtonHolder>();

            insight3D.MouseOptions.ZoomComplete += OnZoomComplete;
            insight3D.MouseDown             += OnMouseDown;
            insight3D.MouseMove             += OnMouseMove;
            insight3D.MouseUp               += OnMouseUp;
            insight3D.MouseClick            += OnMouseClick;
            insight3D.MouseDoubleClick      += OnMouseDoubleClick;
            SceneManager.Animation.Stopped  += OnAnimationStopped;
            SceneManager.Animation.Started  += OnAnimationStarted;
            SceneManager.Animation.Paused   += OnAnimationPaused;
            SceneManager.Animation.HasReset += OnAnimationHasReset;

            m_overlay = new TextureScreenOverlay(0.0, 0.0, DefaultPanelWidth, ButtonSize)
            {
                Origin             = ScreenOverlayOrigin.BottomLeft,
                BorderSize         = 2,
                Color              = Color.Transparent,
                BorderColor        = Color.Transparent,
                Translucency       = PanelTranslucencyRegular,
                BorderTranslucency = PanelBorderTranslucencyRegular
            };
            SceneManager.ScreenOverlays.Add(m_overlay);

            // ShowHide button
            AddButton(GetTexturePath("visible.png"), GetTexturePath("invisible.png"), ShowHide);

            // Reset button
            AddButton(GetTexturePath("reset.png"), Reset);

            // DecreaseDelta button
            m_decreaseDeltaButton = AddButton(GetTexturePath("decreasedelta.png"), DecreaseDelta);

            // StepBack button
            m_stepReverseButton = AddButton(GetTexturePath("stepreverse.png"), StepReverse);

            // PlayBack button
            AddButton(GetTexturePath("playreverse.png"), PlayReverse);

            // Pause button
            AddButton(GetTexturePath("pause.png"), Pause);

            // Play button
            AddButton(GetTexturePath("playforward.png"), PlayForward);

            // StepForward button
            m_stepForwardButton = AddButton(GetTexturePath("stepforward.png"), StepForward);

            // IncreaseDelta button
            m_increaseDeltaButton = AddButton(GetTexturePath("increasedelta.png"), IncreaseDelta);

            // Zoom button
            AddButton(GetTexturePath("zoompressed.png"), GetTexturePath("zoom.png"), Zoom);
            m_zoomButton = m_buttonHolders[m_buttonHolders.Count - 1];

            // Pan button
            AddButton(GetTexturePath("panpressed.png"), GetTexturePath("pan.png"), Pan);

            // Home button
            AddButton(GetTexturePath("home.png"), Home);

            // Moon Button
            AddButton(GetTexturePath("moon.png"), Moon);

            // Scale button
            m_scaleButton = new OverlayButtonHolder(m_insight3D, Scale, GetTexturePath("scale.png"), 0, m_overlay.Width, 0.5, 0.0);
            m_scaleButton.Overlay.Origin = ScreenOverlayOrigin.TopRight;
            m_overlay.Overlays.Add(m_scaleButton.Overlay);
            m_buttonHolders.Add(m_scaleButton);

            // Rotate button
            m_rotateButton = new OverlayButtonHolder(m_insight3D, Rotate, GetTexturePath("rotate.png"), 0, m_overlay.Width, 0.5, 0.0);
            m_rotateButton.Overlay.Origin = ScreenOverlayOrigin.BottomRight;
            m_overlay.Overlays.Add(m_rotateButton.Overlay);
            m_buttonHolders.Add(m_rotateButton);

            DockBottom();
        }