Example #1
0
        /// <summary>
        /// 获取场景内的卫星及载荷资源
        /// </summary>
        /// <returns></returns>
        public List <CoScheduling.Core.Model.STKObject> GetSTKObject()
        {
            List <CoScheduling.Core.Model.STKObject> stkObjects = new List <CoScheduling.Core.Model.STKObject>();
            //获取场景内的所有对象
            AgExecCmdResult results = (AgExecCmdResult)stkRoot.ExecuteCommand("AllInstanceNames /");
            //取出结果字符串
            string rs = results[0].Substring(1, results[0].Length - 2);

            string[] result = rs.Split(' ');
            for (int num = 0; num < result.Length; num++)
            {
                if (result[num].Contains("Sensor"))
                {
                    int satBSign    = result[num].IndexOf("Satellite/") + 10;
                    int satESign    = result[num].IndexOf("/Sensor/");
                    int sensorBSign = result[num].LastIndexOf('/') + 1;

                    CoScheduling.Core.Model.STKObject stkObject = new CoScheduling.Core.Model.STKObject();
                    stkObject.SAT_STKNAME    = result[num].Substring(satBSign, satESign - satBSign);
                    stkObject.SENSOR_STKNAME = result[num].Substring(sensorBSign);
                    stkObjects.Add(stkObject);
                }
            }
            return(stkObjects);
        }
        public void CreateSensorWindow(int intVertPixels)
        {
            int             windowID   = 9999;
            string          command    = "Window3D * CreateWindow Type Normal Title \"Sensor View\"";
            AgExecCmdResult execResult = (AgExecCmdResult)m_root.ExecuteCommand(command);


            execResult = (AgExecCmdResult)m_root.ExecuteCommand("VO_R * MapID");
            string strResult = execResult[0];

            string[] strWindows = strResult.Split(Environment.NewLine.ToCharArray());

            foreach (string strWindow in strWindows)
            {
                if (strWindow.Contains("Sensor View"))
                {
                    string[] winID = strWindow.Split('-');

                    windowID = Convert.ToInt16(winID[0]);
                }
            }
            strWinID = windowID.ToString();

            m_root.ExecuteCommand("VO * Annotation Time ShowTimeStep Off WindowID " + strWinID);
            m_root.ExecuteCommand("VO * Annotation Time Show Off WindowID " + strWinID);
            m_root.ExecuteCommand("VO * Annotation ViewerPos Show Off WindowID " + strWinID);
            m_root.ExecuteCommand("VO * Annotation Frame Show Off WindowID " + strWinID);

            string[] toolbars = { "3D Window Defaults", "3D Graphics", "3D Camera Control", "3D Object Editing", "3D Aircraft Mission Modeler Editing",
                                  "Animation",          "ArcGIS",      "Globe Manager",     "Microsoft Bingtm Maps" };

            foreach (var item in toolbars)
            {
                try
                {
                    m_root.ExecuteCommand("Window3D * Toolbar Hide \"" + item + "\" WindowID" + strWinID);
                }
                catch
                {
                }
            }


            SetWindowFOV(intVertPixels);
        }
Example #3
0
        private void cbStkObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            string simpleName;
            string className;
            string ext;

            CommonData.totalSectionCount = 0;
            //Change options in articulation box
            StringCollection objectPaths = m_stkObjectsLibrary.GetObjectPathListFromInstanceNamesXml(CommonData.StkRoot.AllInstanceNamesToXML(), "");

            foreach (string path in objectPaths)
            {
                CommonData.objectPaths.Add(path);
            }
            simpleName = cbStkObjects.Text;
            CreatedArtic.Items.Clear();
            MainBody.Items.Clear();
            LinkToAttitude.Checked = false;
            int startnum = CommonData.sectionList.Count;

            for (int i = (startnum - 1); i > -1; i--)
            {
                CommonData.sectionList.RemoveAt(i);
            }
            foreach (string path in objectPaths)
            {
                string objectName = m_stkObjectsLibrary.ObjectName(path);
                className = m_stkObjectsLibrary.ClassNameFromObjectPath(path);
                if (objectName == simpleName && className != "Scenario")
                {
                    className = m_stkObjectsLibrary.ClassNameFromObjectPath(path);
                    CommonData.objectClass = className;
                    CommonData.simpleName  = simpleName;
                    string       objectPath = className + "/" + simpleName;
                    IAgStkObject obj        = CommonData.StkRoot.GetObjectFromPath(objectPath);

                    //Clear possible articulations if another object was previously selected
                    PossibleArtic.Items.Clear();

                    //Add possible articulations to dropdown menu
                    Array names = ArticFunctions.GetArticulations(obj);
                    foreach (var item in names)
                    {
                        if (item.ToString().Contains("Time"))
                        {
                        }
                        else
                        {
                            PossibleArtic.Items.Add(item);
                        }
                    }

                    //Get the right file extension based on object class
                    ext = ArticFunctions.GetExtension(className);
                    AgExecCmdResult directory = (AgExecCmdResult)CommonData.StkRoot.ExecuteCommand("GetDirectory / Scenario");
                    CommonData.directoryStr = m_stkObjectsLibrary.GetScenarioDirectory();
                    CommonData.fileStr      = CommonData.directoryStr + "\\" + simpleName + ext;

                    //If file exists read the file and add current articulations to list of sections
                    if (File.Exists(CommonData.fileStr))
                    {
                        //read in file
                        List <Section> fileSections = ArticFunctions.ReadFile(CommonData.fileStr);
                        //populate created articulation list based on file
                        foreach (Section item in fileSections)
                        {
                            CommonData.sectionList.Add(item);
                            if (!String.IsNullOrWhiteSpace(item.sectionName))
                            {
                                if (item.isLinked)
                                {
                                    CreatedArtic.Items.Add(item.sectionName + "  |  LINKED");
                                }
                                else if (item.linkedToList)
                                {
                                    CreatedArtic.Items.Add(item.sectionName + "  |  LINKED TO INTERVAL LIST");
                                }
                                else
                                {
                                    CreatedArtic.Items.Add(item.sectionName);
                                }
                            }
                            else
                            {
                                if (item.isLinked)
                                {
                                    CreatedArtic.Items.Add(item.objectName + item.articName + " Start Time: " + item.startTimeValue + "sec" + "  |  LINKED");
                                }
                                else if (item.linkedToList)
                                {
                                    CreatedArtic.Items.Add(item.objectName + item.articName + " Start Time: " + item.startTimeValue + "sec" + "  |  LINKED TO INTERVAL LIST");
                                }
                                else
                                {
                                    CreatedArtic.Items.Add(item.objectName + item.articName + " Start Time: " + item.startTimeValue + "sec");
                                }
                            }
                        }
                    }
                }
            }
        }