Beispiel #1
0
//------------------------------------------------------------------------------
AboutDialog::AboutDialog(wxWindow *parent, wxWindowID id, const wxString& title,
                         const wxPoint& pos, const wxSize& size, long style)
   : wxDialog(parent, id, title, pos, size, style, title)
{
   #ifdef DEBUG_ICONFILE
   MessageInterface::ShowMessage("AboutDialog::AboutDialog() entered\n");
   #endif
   wxBitmap bitmap;
   wxBitmapButton *aboutButton;
   
   // if icon file available, use it
   FileManager *fm = FileManager::Instance();
   std::string iconFile = (fm->GetFullPathname("ICON_PATH") + "GMATAboutIcon.png");
   #ifdef DEBUG_ICONFILE
   MessageInterface::ShowMessage("   About iconFile='%s'\n", iconFile.c_str());
   #endif
   if (fm->DoesFileExist(iconFile))
   {
      //bitmap.LoadFile(iconFile.c_str(), wxBITMAP_TYPE_JPEG);
      bitmap.LoadFile(iconFile.c_str(), wxBITMAP_TYPE_PNG);
      wxImage image = bitmap.ConvertToImage();
      #ifdef DEBUG_ICONFILE
      MessageInterface::ShowMessage("   Scaling and creating bitmap button\n");
      #endif
      bitmap = wxBitmap(image.Scale(100, 100), wxIMAGE_QUALITY_HIGH);
      aboutButton = new wxBitmapButton(this, -1, bitmap, wxDefaultPosition,
                                       wxSize(100, 100), wxBORDER_NONE);
   }
   else
   {
      MessageInterface::ShowMessage
         ("About GMAT icon file '%s' does not exist.\n", iconFile.c_str());
      aboutButton = new wxBitmapButton(this, -1, NULL, wxDefaultPosition,
                                       wxSize(100, 100));
   }
   
   #ifdef DEBUG_ICONFILE
   MessageInterface::ShowMessage("   Bitmap button created\n");
   #endif
   
   wxColourDatabase cdb;
   wxColour gmatColor = cdb.Find("NAVY");
      
   wxStaticLine *line1 = new wxStaticLine(this);
   wxStaticLine *line2 = new wxStaticLine(this);
   
   // title, build date   
   wxStaticText *gmatText =
      new wxStaticText(this, -1, "General Mission Analysis Tool");
   wxFont font1 = wxFont();
   
   #ifdef __WXMAC__
   font1.SetPointSize(20);
   #else
   font1.SetPointSize(11);
   #endif
   
   font1.SetWeight(wxFONTWEIGHT_BOLD);
   gmatText->SetOwnFont(font1);
   gmatText->SetOwnForegroundColour(gmatColor);
   
   wxString buildDate;
   buildDate.Printf("Build Date: %s %s\n", __DATE__, __TIME__);
   
   wxStaticText *buildText = new wxStaticText(this, -1, buildDate);
   
   #ifdef __WXMAC__
   font1.SetPointSize(12);
   #else
   font1.SetPointSize(8);
   #endif
   
   font1.SetWeight(wxFONTWEIGHT_LIGHT);
   buildText->SetFont(font1);
   
   // website and contact email
   wxStaticText *webText = new wxStaticText(this, -1, "Website: ");
   wxString gmatUrl = "http://gmat.gsfc.nasa.gov";
   wxHyperlinkCtrl *webLink = new wxHyperlinkCtrl(this, -1, gmatUrl, gmatUrl);
   wxStaticText *contactText = new wxStaticText(this, -1, "Contact: ");
   wxStaticText *emailText = new wxStaticText(this, -1, "*****@*****.**");
   
   wxFlexGridSizer *contactSizer = new wxFlexGridSizer(2);
   contactSizer->Add(webText, 0, wxALIGN_RIGHT|wxALL, 2);
   contactSizer->Add(webLink, 0, wxALIGN_LEFT|wxALL, 2);
   contactSizer->Add(contactText, 0, wxALIGN_RIGHT|wxALL, 2);
   contactSizer->Add(emailText, 0, wxALIGN_LEFT|wxALL, 2);
   
   wxBoxSizer *gmatSizer = new wxBoxSizer(wxVERTICAL);
   gmatSizer->Add(gmatText, 0, wxALIGN_CENTRE|wxALL, 4);
   gmatSizer->Add(buildText, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT, 4);
   gmatSizer->Add(3, 3);
   gmatSizer->Add(contactSizer, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT, 4);
   
   wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);
   topSizer->Add(aboutButton, 0, wxALIGN_CENTRE|wxALL, 4);
   topSizer->Add(gmatSizer, 0, wxALIGN_CENTRE|wxALL, 4);
   
   // licence and thrid party
   wxStaticText *licenceText = new wxStaticText(this, -1, " - Licensed under");
   //wxString agreement = "NASA Open Source Agreement";
   wxString agreement = "Apache License, Version 2.0";
   theLicenseLink =
      new wxHyperlinkCtrl(this, ID_HYPERLINK, agreement, "");
   wxBoxSizer *licenceSizer = new wxBoxSizer(wxHORIZONTAL);
   licenceSizer->Add(licenceText, 0, wxALIGN_CENTRE|wxALL, 1);
   licenceSizer->Add(theLicenseLink, 0, wxALIGN_CENTRE|wxALL, 1);
   
   wxString use;
   use = use + " - Uses " + wxVERSION_STRING + "\n";
   use = use + " - Uses TSPlot\n";
   //use = use + " - Uses Perl Compatible Regular Expressions\n";
   use = use + " - Uses JPL SPICE Library\n";
   use = use + " - Uses IAU SOFA Library\n";
   use = use + " - Planetary images courtesy of JPL/Caltech/USGS, Celestia \n";
   use = use + "   Motherlode, Bjorn Jonsson, and NASA World Wind";
   wxStaticText *useText = new wxStaticText(this, -1, use);
   
   wxBoxSizer *useSizer = new wxBoxSizer(wxVERTICAL);
   useSizer->Add(licenceSizer, 0, wxALIGN_LEFT|wxALL, 2);
   useSizer->Add(useText, 0, wxALIGN_CENTRE|wxALL, 4);
   
   // OK button
   theOkButton = new wxButton(this, ID_BUTTON_OK, "OK");
   
   // Add to page sizer and set sizer to this dialog
   wxBoxSizer *pageSizer = new wxBoxSizer(wxVERTICAL);
   pageSizer->Add(topSizer, 0, wxALIGN_CENTRE|wxALL, 4);
   pageSizer->Add(10, 10);
   pageSizer->Add(line1, 0, wxGROW|wxALIGN_CENTRE|wxLEFT|wxRIGHT, 20);
   pageSizer->Add(useSizer, 0, wxALIGN_CENTRE|wxALL, 4);
   pageSizer->Add(line2, 0, wxGROW|wxALIGN_CENTRE|wxLEFT|wxRIGHT, 20);
   pageSizer->Add(10, 10);
   pageSizer->Add(theOkButton, 0, wxALIGN_CENTRE|wxALL, 5);
   
   SetAutoLayout(TRUE);
   SetSizer(pageSizer);
   pageSizer->Fit(this);
   pageSizer->SetSizeHints(this);
   
   // Set icon if icon file is in the start up file
   try
   {
      wxString iconfile = fm->GetFullPathname("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.GetMessage());
   }
   
   CenterOnScreen(wxBOTH);
   
   #ifdef DEBUG_ICONFILE
   MessageInterface::ShowMessage("AboutDialog::AboutDialog() leaving\n");
   #endif
}
Beispiel #2
0
//------------------------------------------------------------------------------
bool SolarFluxReader::LoadFluxData(const std::string &obsFile, const std::string &predictFile)
{
   std::string theLine;

   if (!obsFile.empty())
      obsFileName = obsFile;
   if (!predictFile.empty())
      predictFileName = predictFile;

   obsFluxData.clear();
   predictFluxData.clear();

   FileManager *fm = FileManager::Instance();

   if (obsFileName != "")
   {
      std::string weatherfile = obsFileName;
      if (fm->DoesFileExist(weatherfile) == false)
         weatherfile = fm->GetAbsPathname("ATMOSPHERE_PATH") + weatherfile;
      if (fm->DoesFileExist(weatherfile) == false)
         throw SolarSystemException("Cannot open the historic space weather file " +
               obsFileName + ", nor the file at the location " + weatherfile);

      obsFileName = weatherfile;
   }

   if (predictFileName != "")
   {
      std::string weatherfile = predictFileName;
      if (fm->DoesFileExist(weatherfile) == false)
         weatherfile = fm->GetAbsPathname("ATMOSPHERE_PATH") + weatherfile;
      if (fm->DoesFileExist(weatherfile) == false)
         throw SolarSystemException("Cannot open the predicted space weather file " +
               predictFileName + ", nor the file at the location " + weatherfile);

      predictFileName = weatherfile;
   }

   // Open the files to load
   Open();
   
   if (obsFileName != "")
   {
      if (inObs.is_open())
      {
         inObs.seekg(0, std::ios_base::beg);

         while (!inObs.eof())
         {
            GmatFileUtil::GetLine(&inObs, theLine);

            if (theLine.find(beg_ObsTag) != std::string::npos)
            {
               begObs = inObs.tellg();
            }
            else if (theLine.find(end_ObsTag) != std::string::npos)
            {
               endObs = inObs.tellg();
               endObs = endObs - theLine.length() - 2;
               break;
            }
         }
         LoadObsData();
      }
      else
      {
         //throw an exception
         throw SolarSystemException("SolarFluxReader: Historic/Observed File " +
               obsFileName + " could not be opened.\n");
      }
   }

   if (predictFileName != "")
   {
      if (inPredict.is_open())
      {
         inPredict.seekg(0, std::ios_base::beg);
         while (!inPredict.eof())
         {
            GmatFileUtil::GetLine(&inPredict, theLine);

            if ((theLine.find("NOMINAL TIMING") != std::string::npos) &&
                (theLine.find("EARLY TIMING") != std::string::npos))
            {
               GmatFileUtil::GetLine(&inPredict, theLine);
               break;
            }
         }
         LoadPredictData();
      }
      else
      {
         //throw an exception
         throw SolarSystemException("SolarFluxReader: The Schatten predict "
               "file " + predictFileName + " could not be opened.\n");
      }
   }

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("Spans: [%lf %lf], [%lf %lf]\n",
            historicStart, historicEnd, predictStart, predictEnd);
   #endif

   return(Close());
}