Пример #1
0
 public void SetSite(IAgUiPluginEmbeddedControlSite Site)
 {
     m_pEmbeddedControlSite = Site;
     m_uiplugin             = m_pEmbeddedControlSite.Plugin as UIPlugin;
     m_root = m_uiplugin.STKRoot;
     wpfLogin1.InitProjnFile(Site);
 }
Пример #2
0
        public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor)
        {
            _root   = root;
            _sensor = (IAgSensor)selectedSensor;

            _pluginInstallDir = Path.Combine(@CommonData.InstallDir, "Plugin Files\\SensorBoresightPlugin");
        }
Пример #3
0
        public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor)
        {
            _root   = root;
            _sensor = (IAgSensor)selectedSensor;

            _pluginInstallDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        }
Пример #4
0
 public void SetSite(IAgUiPluginEmbeddedControlSite Site)
 {
     m_pEmbeddedControlSite = Site;
     m_uiPlugin             = m_pEmbeddedControlSite.Plugin as MoveMtoTime;
     m_root = m_uiPlugin.STKRoot;
     DisplayUI();
 }
Пример #5
0
        public void OnDisplayMenu(string MenuTitle, AgEUiPluginMenuBarKind MenuBarKind, IAgUiPluginMenuBuilder2 MenuBuilder)
        {
            if (MenuTitle.Contains("FigureOfMerit"))
            {
                //Insert a Menu Item
                MenuBuilder.InsertMenuItem(1, "ReportGridStats", "Generate Grid Stats Report", "Generate Grid Stats Report", null);
                MenuBuilder.InsertMenuItem(1, "UpdateStaticContours", "Auto Update Static Contours", "FOM Graphics Auto Update", null);
                MenuBuilder.InsertMenuItem(1, "UpdateAnimationContours", "Auto Update Animation Contours", "FOM Graphics Auto Update", null);
            }

            if (MenuBarKind == AgEUiPluginMenuBarKind.eUiPluginMenuBarContextMenu)
            {
                //the STK Object Root
                AgStkObjectRoot root = (AgStkObjectRoot)m_pSite.Application.Personality2;
                //the current Selected Object
                IAgStkObject oSelectedObject = root.GetObjectFromPath(m_pSite.Selection[0].Path);

                //Only show menu items for the Scenario or Satellite object
                if (oSelectedObject.ClassName.Equals("FigureOfMerit"))
                {
                    MenuBuilder.InsertMenuItem(5, "ReportGridStats", "Report Grid Stats", "Report Grid Stats", null);
                    MenuBuilder.InsertMenuItem(5, "UpdateStaticContours", "Auto Update Static Contours", "FOM Graphics Auto Update", null);
                    MenuBuilder.InsertMenuItem(5, "UpdateAnimationContours", "Auto Update Animation Contours", "FOM Graphics Auto Update", null);
                }
            }
        }
Пример #6
0
        //#####################################################################
        /// <summary>
        /// 初始化STK 10 桌面程序
        /// <para>1 启动STK桌面程序(若已有场景,则关联当前场景)</para>
        /// <para>2 为uiApp,stkRoot赋值</para>
        /// </summary>
        public static void InitialSTK10Desktop()
        {
            try
            {
                try
                {
                    //  关联已打开的STK桌面程序
                    uiApp = Marshal.GetActiveObject("STK10.Application") as AgUiApplication;
                }
                catch
                {
                    //  创建新的STK桌面程序
                    uiApp = new AgUiApplication();
                    uiApp.LoadPersonality("STK");
                    uiApp.Visible     = true;
                    uiApp.UserControl = true;
                }

                // Retrieve the root of the StkEngine Automation Object Model.
                _stkRoot = uiApp.Personality2 as AGI.STKObjects.AgStkObjectRoot;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "初始化STK 10出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #7
0
        private void ButtonConnect_Click(object sender, EventArgs e)
        {
            try
            {
                // Connect to open STK
                AgUiApplication app = System.Runtime.InteropServices.Marshal.GetActiveObject("STK12.Application") as AgUiApplication;
                m_root = app.Personality2 as AgStkObjectRoot;

                if (m_root.Children.Count == 0)
                {
                    throw new Exception("No scenario open.");
                }

                PopulateComboBoxes();

                //IMPORTANT - set default units to epoch seconds
                m_root.UnitPreferences.SetCurrentUnit("DateFormat", "EpSec");

                // Add event handlers to update combo boxes when object is added/removed/modified
                m_root.OnStkObjectAdded   += new IAgStkObjectRootEvents_OnStkObjectAddedEventHandler(Root_OnStkObjectAdded);
                m_root.OnStkObjectDeleted += new IAgStkObjectRootEvents_OnStkObjectDeletedEventHandler(Root_OnStkObjectDeleted);
                m_root.OnStkObjectChanged += new IAgStkObjectRootEvents_OnStkObjectChangedEventHandler(Root_OnStkObjectChanged);

                buttonConnect.Enabled    = false;
                radioButtonOpen.Enabled  = true;
                radioButtonClose.Enabled = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error connecting to STK: " + exception.Message, "Error");
            }
        }
        //populates some form values, gets scenario timeframe
        private void InitConnection()
        {
            if (!_stkconnected)
            {
                // Get reference to running STK instance
                _uiApp = System.Runtime.InteropServices.Marshal.GetActiveObject("STK11.Application") as AgUiApplication;

                // Get our IAgStkObjectRoot interface
                _stkRoot      = _uiApp.Personality2 as AgStkObjectRoot;
                _zscen        = _stkRoot.CurrentScenario as IAgScenario;
                _stkconnected = true;

                dtp_start.Value = DateTime.ParseExact(_zscen.StartTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
                dtp_end.Value   = DateTime.ParseExact(_zscen.StopTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);

                //btn_refresh.BackColor = Color.LimeGreen;
            }
            else
            {
                //refresh scenario times
                dtp_start.Value = DateTime.ParseExact(_zscen.StartTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
                dtp_end.Value   = DateTime.ParseExact(_zscen.StopTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
            }


            if (string.IsNullOrEmpty(_workingUserDirectory))
            {
                //get user directory for working purposes
                IAgExecCmdResult conRes = _stkRoot.ExecuteCommand(@"GetDirectory / UserData");
                _workingUserDirectory = conRes[0];
            }

            SafelyUpdateLabel("Connected and using: " + Environment.NewLine + _workingUserDirectory);
        }
Пример #9
0
        public void OnDisplayMenu(string MenuTitle, AgEUiPluginMenuBarKind MenuBarKind, IAgUiPluginMenuBuilder2 MenuBuilder)
        {
            string enabled = "Enable";

            //Insert a Menu Item
            if (m_updater != null)
            {
                enabled = "Disable";
            }
            if (MenuTitle.Contains("Scenario"))
            {
                MenuBuilder.InsertMenuItem(1, "Enable Model Size Update", enabled + " Model Size Update", enabled + " Model Size Update", null);
            }

            if (MenuBarKind == AgEUiPluginMenuBarKind.eUiPluginMenuBarContextMenu)
            {
                //the STK Object Root
                AgStkObjectRoot root = (AgStkObjectRoot)m_pSite.Application.Personality2;
                //the current Selected Object
                IAgStkObject oSelectedObject = root.GetObjectFromPath(m_pSite.Selection[0].Path);

                //Only show menu items for the Scenario or Satellite object
                if (oSelectedObject.ClassName.Equals("Scenario"))
                {
                    MenuBuilder.InsertMenuItem(5, "Enable Model Size Update", enabled + " Model Size Update", enabled + " Model Size Update", null);
                }
            }
        }
        public static void Initialize()
        {
            if (!DefaultsSet)
            {
                SetInitialConditions();
            }

            _stkApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("STK11.Application");
            _root           = _stkApplication.GetType().InvokeMember("Personality2", System.Reflection.BindingFlags.GetProperty, null, _stkApplication, null) as AgStkObjectRoot;

            if (!_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eAircraft).Contains(AircraftName))
            {
                _root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, AircraftName);
            }

            _root.ExecuteCommand("SetUnits / EPOCHSEC");//   %sets date format to epochsec
            _root.ExecuteCommand($"Realtime */Aircraft/{AircraftName} SetProp");
            _root.ExecuteCommand($"SetAttitude */Aircraft/{AircraftName} RealTime Extrapolate 100 200");

            try
            {
                _root.ExecuteCommand($"SetAttitude */Aircraft/{AircraftName} DATAREFERENCE Fixed QUAT 0 0 0 1 \"Aircraft/{AircraftName} FlightPath\"");
                _root.ExecuteCommand($"VO */Aircraft/{AircraftName} Model File \"C:\\Program Files\\AGI\\STK 11\\STKData\\VO\\Models\\Air\\rq-1a_predator.mdl\"");
            }
            catch
            {
            }

            _scen       = (IAgScenario)_root.CurrentScenario;
            _scen.Epoch = "Today";
            _root.PlayForward();
        }
Пример #11
0
        //#####################################################################
        /// <summary>
        /// 初始化STK 11 桌面程序
        /// <para>1 启动STK桌面程序(若已有场景,则关联当前场景)</para>
        /// <para>2 为uiApp,stkRoot赋值</para>
        /// </summary>
        public static void InitialSTK11Desktop()
        {
            try
            {
                try
                {
                    //  关联已打开的STK桌面程序
                    uiApp = Marshal.GetActiveObject("STK11.Application") as AgUiApplication;
                }
                catch
                {
                    //  创建新的STK桌面程序
                    //Guid clsID = typeof(AgUiApplicationClass).GUID;
                    //Type t = Type.GetTypeFromCLSID(clsID);
                    //uiApp = Activator.CreateInstance(t) as AGI.Ui.Application.AgUiApplication;
                    uiApp = new AgUiApplication();
                    uiApp.LoadPersonality("STK");
                    uiApp.Visible     = true;
                    uiApp.UserControl = true;
                }

                // Retrieve the root of the StkEngine Automation Object Model.
                _stkRoot = uiApp.Personality2 as AGI.STKObjects.AgStkObjectRoot;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "初始化STK 11出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #12
0
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            site = PluginSite;
            IAgUiApplication AgUiApp = site.Application;

            root = AgUiApp.Personality2 as AgStkObjectRoot;
        }
Пример #13
0
 public void SetSite(IAgUiPluginEmbeddedControlSite Site)
 {
     m_pEmbeddedControlSite = Site;
     m_uiplugin             = m_pEmbeddedControlSite.Plugin as UIPlugin;
     m_root = m_uiplugin.STKRoot;
     this.mainWindow1.InitProjnFile(Site);
     //this.mainWindow1.loadAll(Site);
 }
Пример #14
0
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            // Setup and attach to STK
            m_psite = PluginSite;
            IAgUiApplication AgUiApp = m_psite.Application;

            m_root = AgUiApp.Personality2 as AgStkObjectRoot;
        }
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            m_pSite = PluginSite;
            //Get the AgStkObjectRoot
            IAgUiApplication AgUiApp = m_pSite.Application;

            m_root = AgUiApp.Personality2 as AgStkObjectRoot;
        }
Пример #16
0
        public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor)
        {
            m_root = root;
            sensor = (IAgSensor)selectedSensor;
            IAgExecCmdResult result = m_root.ExecuteCommand("GetDirectory / STKHome");

            installDir       = result[0];
            pluginInstallDir = installDir + @"Plugins\SensorBoresightView";
        }
Пример #17
0
        public void OnDisplayMenu(string MenuTitle, AgEUiPluginMenuBarKind MenuBarKind,
                                  IAgUiPluginMenuBuilder2 MenuBuilder)
        {
            if (MenuTitle.Contains("Insert"))
            {
                //Add a Menu Item to the Insert menu
                stdole.IPictureDisp picture1;
                picture1 = (stdole.IPictureDisp)Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture(Agi.Ui.GreatArc.Stk12.Properties.Resources.acRoute64);
                MenuBuilder.InsertMenuItem(4,
                                           "RasterSearch.LaunchInterface",
                                           "Aircraft from Search Pattern...",
                                           "Define an Aircraft based on search criteria",
                                           picture1);
            }

            if (MenuBarKind == AgEUiPluginMenuBarKind.eUiPluginMenuBarContextMenu)
            {
                //the STK Object Root
                AgStkObjectRoot root = (AgStkObjectRoot)m_pSite.Application.Personality2;
                //the current Selected Object
                IAgStkObject oSelectedObject = root.GetObjectFromPath(m_pSite.Selection[0].Path);

                //Only show menu items for the Scenario or Satellite object
                if (oSelectedObject.ClassName.Equals("Aircraft") ||
                    oSelectedObject.ClassName.Equals("GroundVehicle") ||
                    oSelectedObject.ClassName.Equals("Ship"))
                {
                    MenuBuilder.InsertMenuItem(3, "UpdateVelocity", "Update Velocity", "Update Velocity", null);
                    MenuBuilder.InsertMenuItem(4, "UpdateAltitude", "Update Altitude", "Update Altitude", null);
                    MenuBuilder.InsertMenuItem(5, "UpdateTurnRadius", "Update Turn Radius", "Update Turn Radius", null);
                    MenuBuilder.InsertMenuItem(6, "EnterEditMode", "Enter 3D Edit Mode", "Enter 3D Edit Mode", null);
                    MenuBuilder.InsertSeparator(6);
                    MenuBuilder.InsertSeparator(3);
                }
                else if (oSelectedObject.ClassName.Equals("Place") ||
                         oSelectedObject.ClassName.Equals("Facility") ||
                         oSelectedObject.ClassName.Equals("Target") ||
                         oSelectedObject.ClassName.Equals("AreaTarget") ||
                         oSelectedObject.ClassName.Equals("LineTarget"))
                {
                    MenuBuilder.InsertMenuItem(3, "EnterEditMode", "Enter 3D Edit Mode", "Enter 3D Edit Mode", null);
                    MenuBuilder.InsertSeparator(3);
                }
            }

            if (MenuTitle.Contains("Ship") ||
                MenuTitle.Contains("GroundVehicle") ||
                MenuTitle.Contains("Aircraft"))
            {
                MenuBuilder.InsertMenuItem(0, "UpdateVelocity", "Update Velocity", "Update Velocity", null);
                MenuBuilder.InsertMenuItem(1, "UpdateAltitude", "Update Altitude", "Update Altitude", null);
                MenuBuilder.InsertMenuItem(2, "UpdateTurnRadius", "Update Turn Radius", "Update Turn Radius", null);
                MenuBuilder.InsertMenuItem(3, "ShiftLatitude", "Shift in Latitude", "Shift in Latitude", null);
                MenuBuilder.InsertMenuItem(4, "ShiftLongitude", "Shift in Longitude", "Shift in Longitude", null);
                MenuBuilder.InsertSeparator(5);
            }
        }
Пример #18
0
        public DirectionsUI(AgStkObjectRoot stkRoot)
        {
            InitializeComponent();
            m_root = stkRoot;

            terrainCheckBox.Enabled = Licensing("Professional");
            populateDropdowns();
            routeBuilder = new Directions(m_root);
        }
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            m_pSite = PluginSite;
            IAgUiApplication AgUiApp = m_pSite.Application;

            m_root = AgUiApp.Personality2 as AgStkObjectRoot;
            m_root.Isolate();
            m_root.UnitPreferences.ResetUnits();
        }
Пример #20
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (m_root != null)
     {
         System.Runtime.InteropServices.Marshal.ReleaseComObject(m_root);
         m_root = null;
         projInfoFile.write2file();
         //System.Windows.Application.Current.Shutdown();
         Environment.Exit(0);
     }
 }
Пример #21
0
 public RasterUI(AgStkObjectRoot m_root)
 {
     InitializeComponent();
     root         = m_root;
     routeBuilder = new RasterSearch(root);
     PopulateListViews();
     RadioChanged();
     setupGridView();
     setupUnitsComboBoxes();
     checkBox_UseEndurance_CheckedChanged(null, null);
 }
        public void SetSite(IAgUiPluginEmbeddedControlSite Site)
        {
            m_pEmbeddedControlSite = Site;
            m_uiPlugin             = m_pEmbeddedControlSite.Plugin as CSharpPlugin;
            m_root = m_uiPlugin.STKRoot;

            m_uiPlugin.customUI = this;



            InitGUI();
        }
        public bool Init(IAgUtPluginSite Site)
        {
            m_UtPluginSite = (AgStkPluginSite)Site;

            if (m_UtPluginSite != null)
            {
                // Get a pointer to the STK Object Model root object
                m_StkRootObject = (AgStkObjectRoot)m_UtPluginSite.StkRootObject;
                m_StkScenario   = m_StkRootObject.CurrentScenario;
            }
            return(true);
        }
Пример #24
0
        public void Free()
        {
            Debug.WriteLine(m_DisplayName + ".Free()", "Entered:");

            m_Site                  = null;
            m_StkRootObject         = null;
            m_CalcToolProvider      = null;
            m_VectorToolProvider    = null;
            m_objectConfiguredPoint = null;

            Debug.WriteLine(m_DisplayName + ".Free()", "Exited:");
        }
Пример #25
0
        private void createScenarioTleDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            STK.CreateScenarioFromTle(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, currentTle);
            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Пример #26
0
        private void createScenarioSatcatDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            string satelliteID = this.dgvSatList.SelectedRows[0].Cells[1].Value.ToString();

            currentTle = STK.CreateScenarioFromSatcat(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, satelliteID);

            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Пример #27
0
        public bool Init(IAgUtPluginSite Site)
        {
            Debug.WriteLine(m_DisplayName + ".Init()", "Entered:");

            m_Site = (AgStkPluginSite)Site;

            if (m_Site != null)
            {
                // Get a pointer to the STK Object Model root object
                m_StkRootObject = (AgStkObjectRoot)m_Site.StkRootObject;
            }

            Debug.WriteLine(m_DisplayName + ".Init()", "Exited:");

            return(true);
        }
Пример #28
0
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            m_pSite = PluginSite;
            //Get the AgStkObjectRoot
            IAgUiApplication AgUiApp = m_pSite.Application;

            m_root = AgUiApp.Personality2 as AgStkObjectRoot;
            m_root.Isolate();
            m_root.UnitPreferences.ResetUnits();
            m_root.OnStkObjectAdded      += new IAgStkObjectRootEvents_OnStkObjectAddedEventHandler(UpdateListAdded);
            m_root.OnStkObjectChanged    += new IAgStkObjectRootEvents_OnStkObjectChangedEventHandler(UpdateListChanged);
            m_root.OnStkObjectRenamed    += new IAgStkObjectRootEvents_OnStkObjectRenamedEventHandler(UpdateListRenamed);
            m_root.OnStkObjectDeleted    += new IAgStkObjectRootEvents_OnStkObjectDeletedEventHandler(UpdateListDeleted);
            m_root.OnScenarioBeforeClose += new IAgStkObjectRootEvents_OnScenarioBeforeCloseEventHandler(ScenarioCloseEvent);

            STKHelper.StkRoot = m_root;
        }
        public void SetSite(IAgUiPluginEmbeddedControlSite Site)
        {
            m_pEmbeddedControlSite = Site;
            m_uiPlugin             = m_pEmbeddedControlSite.Plugin as Setup;
            m_root = m_uiPlugin.STKRoot;
            m_stkObjectsLibrary = new StkObjectsLibrary((IAgStkObjectRoot)m_root);

            //EXAMPLE: Hooking to STK Exents
            //m_root.OnStkObjectAdded += new IAgStkObjectRootEvents_OnStkObjectAddedEventHandler(m_root_OnStkObjectAdded);
            //m_root.OnStkObjectDeleted += new IAgStkObjectRootEvents_OnStkObjectDeletedEventHandler(m_root_OnStkObjectDeleted);

            //EXAMPLE: Using preference value
            //m_uiPlugin.DoubleValue;

            //EXAMPLE: Populate combo box with STK Objects
            //PopulateComboBox();
        }
Пример #30
0
        private void ConnectToSTK()
        {
            // Try to connect to existing STK instance, otherwise open a new one
            try
            {
                m_stkApplication = Marshal.GetActiveObject("STK12.Application") as AgUiApplication;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                m_stkApplication = new AgUiApplication();

                m_stkApplication.LoadPersonality("STK");
                m_stkApplication.Visible = true;
            }

            m_stkRoot = (AgStkObjectRoot)m_stkApplication.Personality2;
        }