Beispiel #1
0
//------------------------------------------------------------------------------
bool UserInputValidator::CheckIntegerRange(Integer &ivalue, const std::string &str, 
                                           const std::string &field, Integer lower,
                                           Integer upper, bool checkLower, bool checkUpper,
                                           bool includeLower, bool includeUpper)
{
   Integer ival;
   if (GmatStringUtil::ToInteger(str, &ival, false, false))
   {
      Real rval = (Real)ival;
      
      bool retval = CheckRealRange(str, rval, field, lower, upper, checkLower,
                                   checkUpper, includeLower, includeUpper, true);
      if (retval)
         ivalue = ival;
      
      return retval;
   }
   
   std::string expRange = "Integer";
   MessageInterface::PopupMessage
      (Gmat::ERROR_, mMsgFormat.c_str(), str.c_str(), field.c_str(), "",
       expRange.c_str());
   
   SetErrorFlag();
   return false;
}
Beispiel #2
0
//------------------------------------------------------------------------------
// virtual void SaveData()
//------------------------------------------------------------------------------
void DragInputsDialog::SaveData()
{
   #ifdef DEBUG_DRAG_SAVE
   MessageInterface::ShowMessage("DragInputsDialog::SaveData() entered\n");
   #endif
   
   canClose = true;
   Real flux, avgFlux, magIndex;
   
   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   if (isTextModified)
   {
      std::string str;
      
      str = solarFluxTextCtrl->GetValue();
      CheckReal(flux, str, "Solar Flux (F10.7)", "Real Number >= 0.0", false, true, true , true);
      
      str = avgSolarFluxTextCtrl->GetValue();
      CheckReal(avgFlux, str, "Average Solar Flux (F10.7A)", "Real Number >= 0.0", false, true, true, true);
      
      str = geomagneticIndexTextCtrl->GetValue();
      bool isValid = CheckReal(magIndex, str, "Geomagnetic Index (Kp)", "0.0 <= Real Number <= 9.0");
      if (isValid)
         isValid = CheckRealRange(str, magIndex, "Geomagnetic Index", 0.0, 9.0, true, true, true, true);

      if (!isValid)
         canClose = false;

      std::string fileToCheck;

      // Check the flux files
      if (historicFileComboBox->GetStringSelection().WX_TO_C_STRING != "ConstantFluxAndGeoMag")
      {
         fileToCheck = cssiFileTextCtrl->GetValue().WX_TO_C_STRING;

         if (theDragForce->CheckFluxFile(fileToCheck, true) == "")
         {
            MessageInterface::PopupMessage
               (Gmat::ERROR_, "The flux file %s does not contain valid historic data",
                     fileToCheck.c_str());
            canClose = false;
         }
      }
      
      if (predictedFileComboBox->GetStringSelection().WX_TO_C_STRING != "ConstantFluxAndGeoMag")
      {
         if (predictedFileComboBox->GetStringSelection().WX_TO_C_STRING == "CSSISpaceWeatherFile")
         {
            MessageInterface::PopupMessage
               (Gmat::ERROR_, "CSSI predict data is not supported in GMAT");
            canClose = false;

//            fileToCheck = cssiFileTextCtrl->GetValue().WX_TO_C_STRING;
//            if (theDragForce->CheckFluxFile(fileToCheck, false) == "")
//            {
//               MessageInterface::PopupMessage
//                  (Gmat::ERROR_, "The flux file %s does not contain valid predict data",
//                        fileToCheck.c_str());
//               canClose = false;
//            }
         }
         else
         {
            fileToCheck = schattenFileTextCtrl->GetValue().WX_TO_C_STRING;
            if (theDragForce->CheckFluxFile(fileToCheck, false) == "")
            {
               MessageInterface::PopupMessage
                  (Gmat::ERROR_, "The flux file %s does not contain valid predict data",
                        fileToCheck.c_str());
               canClose = false;
            }
         }
      }

      if (!canClose)
         return;
   }
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      std::string cssifileName = cssiFileTextCtrl->GetValue().WX_TO_C_STRING;
      std::string schattenfileName = schattenFileTextCtrl->GetValue().WX_TO_C_STRING;
      std::string schattenError = schattenErrorComboBox->GetValue().WX_TO_C_STRING;
      std::string schattenTiming = schattenTimingComboBox->GetValue().WX_TO_C_STRING;
      (*theForceStringArray)[0] = predictedFileComboBox->GetStringSelection().WX_TO_C_STRING;
      (*theForceStringArray)[1] = historicFileComboBox->GetStringSelection().WX_TO_C_STRING;
      
     if (cssifileName == "")
     {
        MessageInterface::PopupMessage
           (Gmat::ERROR_, "The CSSI flux file name is empty, please enter file name");
        canClose = false;
        return;
     }

     // save off the data
     (*theForceStringArray)[2] = cssifileName;

     if (schattenfileName=="")
     {
          MessageInterface::PopupMessage
             (Gmat::ERROR_, "The Schatten flux file name is empty, please enter file name");
          canClose = false;
          return;
     }

     // save the data
     (*theForceStringArray)[3] = schattenfileName;
     (*theForceStringArray)[4] = schattenError; 
     (*theForceStringArray)[5] = schattenTiming;

    #ifdef DEBUG_DRAG_SAVE
       MessageInterface::ShowMessage
      ("theForcesStringArray has size %d:\n", theForceStringArray->size());

      for (UnsignedInt q = 0; q < theForceStringArray->size(); ++q)
         MessageInterface::ShowMessage("   %d:  %s\n", q, theForceStringArray->at(q).c_str());
    #endif


    #ifdef DEBUG_DRAG_SAVE
       MessageInterface::ShowMessage
          ("   ==> Saved filename%s\n", fileNameTextCtrl->GetValue().c_str());
    #endif

    if (isTextModified)
    {
       theForceData[0] = flux;
       theForceData[1] = avgFlux;
       theForceData[2] = magIndex;
        
        isTextModified = false;
     }
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
   }
  

   #ifdef DEBUG_DRAG_SAVE
   MessageInterface::ShowMessage("DragInputsDialog::SaveData() leaving\n");
   #endif
}
Beispiel #3
0
//------------------------------------------------------------------------------
void CoordSystemConfigPanel::SaveData()
{
   canClose = true;
   std::string originName = originComboBox->GetValue().Trim().c_str();
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      //-------------------------------------------------------
      // check/set new epoch
      //-------------------------------------------------------
      if (mEpochChanged)
      {
         std::string savedEpoch = (mCoordPanel->epochValue).c_str();
         Real epoch;
         std::string str = mCoordPanel->GetEpochTextCtrl()->GetValue().c_str();
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage("Epoch data has been changed!!!!\n");
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() epoch value = %s\n",
             str.c_str());
         #endif
         bool isValid = CheckReal(epoch, str, "Epoch", "Real Number >= 0");
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() isValid = %s, and epoch real value = %12.10f\n",
             (isValid? "true" : "false"), epoch);
         #endif

         // check range here too
         if (isValid)
            isValid = CheckRealRange(str, epoch, "Epoch", DateUtil::EARLIEST_VALID_MJD_VALUE, DateUtil::LATEST_VALID_MJD_VALUE, true, true, true, true);
         if (!isValid)
         {
            canClose = false;
         }
      }

      if (!canClose)
         return;

      //-------------------------------------------------------
      // set new axis system
      //-------------------------------------------------------
      if (mObjRefChanged)
      {
         AxisSystem *oldAxis = (AxisSystem*) theCoordSys->GetRefObject(Gmat::AXIS_SYSTEM, "");
         AxisSystem *axis = mCoordPanel->CreateAxis();
         #ifdef DEBUG_COORD_PANEL_XYZ
            MessageInterface::ShowMessage("CoordSystemConfigPanel:: CreateAxis returned %s\n",
                  (axis? "not NULL" : "NULL"));
         #endif
         
         if (axis != NULL)
         {
            #ifdef DEBUG_COORD_PANEL_XYZ
               MessageInterface::ShowMessage("CoordSystemConfigPanel:: executing axis not equal to NULL part ...\n");
            #endif
            canClose = mCoordPanel->SaveData(theCoordSys->GetName(), axis, mEpochFormat);
            
            if (canClose)
            {
               try
               {
                  // only set these if there was no error creating or initializing the coordinate system
                  theCoordSys->SetRefObject(axis, Gmat::AXIS_SYSTEM, "");
                  theCoordSys->Initialize();
               }
               catch (BaseException &be)
               {
                  // reset the CS to have the axis system it started with
                  theCoordSys->SetRefObject(oldAxis, Gmat::AXIS_SYSTEM, "");
                  theCoordSys->Initialize();
                  throw;
               }
            }
         }
         else
         {
            #ifdef DEBUG_COORD_PANEL_XYZ
               MessageInterface::ShowMessage("CoordSystemConfigPanel:: executing axis EQUAL to NULL part ...\n");
            #endif
            MessageInterface::ShowMessage
               ("CoordSystemConfigPanel::SaveData() Cannot create AxisSystem.\n");
            canClose = false;
         }
      }

      //-------------------------------------------------------
      // set new origin - needs to be done after setting of the axis system
      //-------------------------------------------------------
      if (mOriginChanged)
      {
         #if DEBUG_COORD_PANEL_SAVE
         MessageInterface::ShowMessage
            ("CoordSystemConfigPanel::SaveData() originName = %s\n",
             originName.c_str());
         #endif

         // set coordinate system origin
         SpacePoint *origin =
            (SpacePoint*)theGuiInterpreter->GetConfiguredObject(originName);
         theCoordSys->SetStringParameter("Origin", originName);
         theCoordSys->SetOrigin(origin);

         mOriginChanged = false;

         // set Earth as J000Body if NULL
         if (origin->GetJ2000Body() == NULL)
         {
            SpacePoint *j2000body =
               (SpacePoint*)theGuiInterpreter->GetConfiguredObject("Earth");
            origin->SetJ2000Body(j2000body);
         }
      }
      ResetFlags();

   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
   }
}