Пример #1
0
//------------------------------------------------------------------------------
// void SaveAndBuildScript(wxCommandEvent &event)
//------------------------------------------------------------------------------
void GmatSavePanel::SaveAndBuildScript(wxCommandEvent &event)
{
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::SaveAndBuildScript() entered\n   mFilename = '%s'\n",
       mFilename.c_str());
   #endif
   
   SaveData();
   mScriptDirtyLabel->SetLabel("");
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   SetEditorModified(false);
   gmatAppData->GetMainFrame()->SetActiveChildDirty(false);
   
   // If script is active, build the script 
   if (mIsScriptActive & !mDelayBuild)
   {
      if (gmatAppData->GetMainFrame()->SetScriptFileName(mFilename.c_str()))
         gmatAppData->GetMainFrame()->OnScriptBuildObject(event);
   }
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::SaveAndBuildScript() leaving\n   mFilename = '%s'\n",
       mFilename.c_str());
   #endif
}
Пример #2
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void ScriptPanel::SaveData()
{
   #ifdef DEBUG_SCRIPTPANEL_SAVE
   MessageInterface::ShowMessage
      ("ScriptPanel::SaveData() entered\n   mScriptFilename = '%s'\n   "
       "      mFilename = '%s'\n", mScriptFilename.c_str(), mFilename.c_str());
   #endif
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   
   if (mScriptFilename != mFilename)
   {
      // add new script to tree
      gmatAppData->GetResourceTree()->AddScriptItem(mFilename);
      
      // rename this child window
      gmatAppData->GetMainFrame()->RenameActiveChild(mFilename);
      mScriptFilename = mFilename;
   }
   
   mFileContentsTextCtrl->SaveFile(mScriptFilename);
   gmatAppData->GetMainFrame()->SetActiveChildDirty(false);
   mUserModified = false;
   
   #ifdef DEBUG_SCRIPTPANEL_SAVE
   MessageInterface::ShowMessage
      ("ScriptPanel::SaveData() leaving\n   mScriptFilename = '%s'\n   "
       "      mFilename = '%s'\n", mScriptFilename.c_str(), mFilename.c_str());
   #endif
}
Пример #3
0
//------------------------------------------------------------------------------
// void UpdateResourceTree()
//------------------------------------------------------------------------------
void GuiInterpreter::UpdateResourceTree()
{
#if !defined __CONSOLE_APP__
   //close the open windows first
   GmatAppData *gmatAppData = GmatAppData::Instance();
   gmatAppData->GetMainFrame()->CloseAllChildren();
   gmatAppData->GetResourceTree()->UpdateResource(true);
#endif
}
Пример #4
0
//------------------------------------------------------------------------------
void OutputTree::OnClose(wxCommandEvent &event)
{
   // Get info from selected item
   GmatTreeItemData *item = (GmatTreeItemData *) GetItemData(GetSelection());
   
   // if its open, its activated
   GmatAppData *gmatAppData = GmatAppData::Instance();
   if (gmatAppData->GetMainFrame()->IsChildOpen(item))
      gmatAppData->GetMainFrame()->CloseActiveChild();
   else
      return;
}
Пример #5
0
//------------------------------------------------------------------------------
// GmatMdiChildFrame::GmatMdiChildFrame(...)
//------------------------------------------------------------------------------
GmatMdiChildFrame::GmatMdiChildFrame(wxMDIParentFrame *parent, 
                                     const wxString &name,
                                     const wxString &title, 
                                     const GmatTree::ItemType type,
                                     wxWindowID id, 
                                     const wxPoint &pos, 
                                     const wxSize &size, 
                                     long style)
   : wxMDIChildFrame(parent, id, title, pos, size, style, name)
{
   #ifdef DEBUG_MDI_CHILD_FRAME
   MessageInterface::ShowMessage
      ("GmatMdiChildFrame::GmatMdiChildFrame() entered, type=%d\n    "
       "name='%s'\n   title='%s'\n", type, name.c_str(), title.c_str());
   #endif
   
   relativeZOrder          = maxZOrder++;
   usingSavedConfiguration = false;
   mChildName = name;
   theParent = parent;
   mDirty = false;
   mOverrideDirty = false;
   mCanClose = true;
   mCanSaveLocation = true;
   mIsActiveChild = false;
   mCanBeDeleted = true;
   mItemType = type;
   theScriptTextCtrl = NULL;
   theMenuBar = NULL;
   theAssociatedWin = NULL;
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   theGuiInterpreter = gmatAppData->GetGuiInterpreter();

   #ifdef __USE_STC_EDITOR__
   theEditor = NULL;
   #endif
   
   #ifdef __WXMAC__
   childTitle = title;
   #endif
   
   #ifdef __CREATE_CHILD_MENU_BAR__
      // create a menu bar, pass Window menu if Windows
      #ifdef __WXMSW__
         theMenuBar = new GmatMenuBar(mItemType, parent->GetWindowMenu());
      #else
         theMenuBar = new GmatMenuBar(mItemType, NULL);
      #endif
   
      #ifdef DEBUG_MENUBAR
      MessageInterface::ShowMessage
         ("GmatMdiChildFrame::GmatMdiChildFrame() theMenuBarCreated %p\n", theMenuBar);
      #endif
      
      // Commented out so that Window menu works for MdiChildFrame (loj: 2008.02.08)
      // Double Window menu appears when more than one child is open and cannot
      // delete theMenuBar in the destructor.
      //SetMenuBar(theMenuBar);
   #else
      theMenuBar = (GmatMenuBar*)(parent->GetMenuBar());      
   #endif
   
   // Enable Edit menu and tools if ScriptFile
   #ifdef DEBUG_UPDATE_GUI_ITEM
   MessageInterface::ShowMessage
      ("GmatMdiChildFrame() constructor calling UpdateGuiItem()\n");
   #endif
   UpdateGuiItem(1, 0);
   
   // Set GMAT main icon
   GmatAppData::Instance()->SetIcon(this, "GmatMdiChildFrame");
   
}
Пример #6
0
//------------------------------------------------------------------------------
// GmatMdiChildFrame::GmatMdiChildFrame(...)
//------------------------------------------------------------------------------
GmatMdiChildFrame::GmatMdiChildFrame(wxMDIParentFrame *parent, 
                                     const wxString &name,
                                     const wxString &title, 
                                     const GmatTree::ItemType type,
                                     wxWindowID id, 
                                     const wxPoint &pos, 
                                     const wxSize &size, 
                                     long style)
   : wxMDIChildFrame(parent, id, title, pos, size, style, name)
{
   #ifdef DEBUG_MDI_CHILD_FRAME
   MessageInterface::ShowMessage
      (wxT("GmatMdiChildFrame::GmatMdiChildFrame() entered, type=%d\n    ")
       wxT("name='%s'\n   title='%s'"), type, name.c_str(), title.c_str());
   #endif
   
   relativeZOrder          = maxZOrder++;
   usingSavedConfiguration = false;
   mPlotName = name;
   theParent = parent;
   mDirty = false;
   mOverrideDirty = false;
   mCanClose = true;
   mCanSaveLocation = true;
   mItemType = type;
   theScriptTextCtrl = NULL;
   theMenuBar = NULL;
   theAssociatedWin = NULL;
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   theGuiInterpreter = gmatAppData->GetGuiInterpreter();

   #ifdef __USE_STC_EDITOR__
   theEditor = NULL;
   #endif
   
   #ifdef __WXMAC__
   childTitle = title;
   #endif
   
   #ifdef __CREATE_CHILD_MENU_BAR__
      // create a menu bar, pass Window menu if Windows
      #ifdef __WXMSW__
         theMenuBar = new GmatMenuBar(mItemType, parent->GetWindowMenu());
      #else
         theMenuBar = new GmatMenuBar(mItemType, NULL);
      #endif
   
      #ifdef DEBUG_MENUBAR
      MessageInterface::ShowMessage
         (wxT("GmatMdiChildFrame::GmatMdiChildFrame() theMenuBarCreated %p\n"), theMenuBar);
      #endif
      
      // Commented out so that Window menu works for MdiChildFrame (loj: 2008.02.08)
      // Double Window menu appears when more than one child is open and cannot
      // delete theMenuBar in the destructor.
      //SetMenuBar(theMenuBar);
   #else
      theMenuBar = (GmatMenuBar*)(parent->GetMenuBar());      
   #endif
   
   // Enable Edit menu and tools if ScriptFile
   #ifdef DEBUG_UPDATE_GUI_ITEM
   MessageInterface::ShowMessage
      (wxT("GmatMdiChildFrame() constructor calling UpdateGuiItem()\n"));
   #endif
   UpdateGuiItem(1, 0);
   
   // Set icon if icon file is in the start up file
   FileManager *fm = FileManager::Instance();
   try
   {
      wxString iconfile = fm->GetFullPathname(wxT("MAIN_ICON_FILE")).c_str();
      #if defined __WXMSW__
         SetIcon(wxIcon(iconfile, wxBITMAP_TYPE_ICO));
      #elif defined __WXGTK__
         SetIcon(wxIcon(iconfile, wxBITMAP_TYPE_XPM));
      #elif defined __WXMAC__
         SetIcon(wxIcon(iconfile, wxBITMAP_TYPE_PICT_RESOURCE));
      #endif
   }
   catch (GmatBaseException &e)
   {
      MessageInterface::ShowMessage(e.GetFullMessage());
   }
}
Пример #7
0
//------------------------------------------------------------------------------
// void MakeScriptActive(wxCommandEvent &event, bool isScriptModified)
//------------------------------------------------------------------------------
void GmatSavePanel::MakeScriptActive(wxCommandEvent &event, bool isScriptModified)
{
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage
      ("GmatSavePanel::MakeScriptActive() entered, isScriptModified=%d\n",
       isScriptModified);
   #endif
   
   bool saveScript = true;
   mSyncGui = false;
   mDelayBuild = false;
   GmatAppData *gmatAppData = GmatAppData::Instance();
   
   if (event.GetEventObject() == mSaveSyncButton ||
       event.GetEventObject() == mSaveSyncRunButton)
   {
      #ifdef DEBUG_ACTIVE_SCRIPT
      MessageInterface::ShowMessage("   Event is SaveSyncButton or SaveSyncRunButton\n");
      #endif
      if (gmatAppData->GetMainFrame()->IsAnimationRunning())
      {
         #ifdef DEBUG_ACTIVE_SCRIPT
         MessageInterface::ShowMessage("   Animation is running\n");
         #endif
         // @todo - Figure out why following happens. (LOJ: 2012.07.18)
         // It always runs mission before updating the resource tree.
         // It sometimes crashes when I tried SaveSyncRun again.
         // @note - Prompt user to stop animation first until issue is resolved.
         // Is there a timing issue? wxYield() didn't seem to solve the problem.
         // Use wxTimer?
         //===========================================================
         #if 0
         //===========================================================
         wxString action = "reload the GUI with the saved script?";
         if (event.GetEventObject() == mSaveSyncRunButton)
            action = "reload the GUI with the saved script and run?";
         
         int answer =
            wxMessageBox(wxT("GMAT is running the animation.\n"
                             "Are you sure you want to stop the animation and " + action),
                         wxT("Please confirm"), wxYES_NO);
         
         if (answer == wxYES)
         {
            // Stop animation
            gmatAppData->GetMainFrame()->StopAnimation();
         }
         else
            return;
         
         //===========================================================
         #else
         //===========================================================
        
         wxMessageBox(wxT("GMAT is running the animation.\n"
                          "Please stop the animation first."),
                      wxT("Warning"), wxOK);
         return;
         
         //===========================================================
         #endif
         //===========================================================
      }
      else
      {
         #ifdef DEBUG_ACTIVE_SCRIPT
         MessageInterface::ShowMessage("   Animation is not running\n");
         #endif
      }
      mSyncGui = true;
      mDelayBuild = true;
   }
   
   wxYield();
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage("   mIsScriptActive=%d\n", mIsScriptActive);
   #endif
   
   // If this is not an active script, prompt the user for setting active
   if (!mIsScriptActive)
   {
      #ifdef DEBUG_ACTIVE_SCRIPT
      MessageInterface::ShowMessage("   ==> Showing active script confirm message\n");
      #endif
      wxString makeActiveMsg = "The script file \"" + mFilename + "\" is not the active script.  "
         "Would you like to save, make it the active script, and load it into the GUI";
      if (event.GetEventObject() == mSaveSyncButton)
         makeActiveMsg = makeActiveMsg + "?";
      else if (event.GetEventObject() == mSaveSyncRunButton)
         makeActiveMsg = makeActiveMsg + " and run?";
      
      wxMessageDialog *msgDlg = new wxMessageDialog
         (this, makeActiveMsg, "Save active...", wxYES_NO | wxICON_QUESTION, wxDefaultPosition);
      int result = msgDlg->ShowModal();
      
      if (result == wxID_YES)
      {
         mSyncGui = true;
         saveScript = true;
         // If inactive script is modified, set it dirty so that change can be saved
         // before build (Fix for GMT-2843, LOJ: 2012.08.22)
         if (isScriptModified)
            theGuiManager->SetActiveScriptStatus(2);
      }
      else
      {
         mSyncGui = false;
         saveScript = false;
      }
   }
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage
      ("   mSyncGui=%d, saveScript=%d, mScriptFilename='%s'\n", mSyncGui, saveScript,
       mScriptFilename.c_str());
   #endif
   
   // No action is performed if user said no to sync GUI
   // See GMAT Software Specification, Script Editor section (LOJ: 2012.02.22)
   if (saveScript)
   {
      OnSave(event);
      if (mSaveCanceled)
      {
         #ifdef DEBUG_SAVE
         MessageInterface::ShowMessage
            ("GmatSavePanel::OnSave() leaving, user canceled SaveAs, mFilename='%s'\n", mFilename.c_str());
         #endif
         return;
      }
   }
   
   wxYield();
   
   // If continue building, set script file name and build script
   if (mSyncGui)
   {
      if (event.GetEventObject() == mSaveSyncButton)
      {
         if (gmatAppData->GetMainFrame()->SetScriptFileName(mScriptFilename.c_str()))
         {
            #ifdef DEBUG_ACTIVE_SCRIPT
            MessageInterface::ShowMessage
               ("   ==> Calling GmatMainFrame::OnScriptBuildObject()\n");
            #endif
            gmatAppData->GetMainFrame()->OnScriptBuildObject(event);
         }
      }
      else if (event.GetEventObject() == mSaveSyncRunButton)
      {
         if (gmatAppData->GetMainFrame()->SetScriptFileName(mScriptFilename.c_str()))
         {
            #ifdef DEBUG_ACTIVE_SCRIPT
            MessageInterface::ShowMessage
               ("   ==> Calling GmatMainFrame::OnScriptBuildAndRun()\n");
            #endif
            gmatAppData->GetMainFrame()->OnScriptBuildAndRun(event);
         }
      }
      // Make current script active script (Fix for GMT-206, LOJ: 2012.02.09)
      UpdateScriptActiveStatus(true);
      mSyncGui = false;
   }
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage("GmatSavePanel::MakeScriptActive() leaving\n");
   #endif
}