示例#1
0
//------------------------------------------------------------------------------
void SubscriberSetupPanel::SaveControl(const wxString &label)
{
   Integer index = theSubscriber->GetParameterID(label);
   Gmat::ParameterType type = theSubscriber->GetParameterType(index);

   wxControl *theControl = propertyControls[controlMap[label]];
   wxString valueString;

   switch (type)
   {
      case Gmat::BOOLEAN_TYPE:
         {
            bool val = true;
            if (((wxComboBox*)theControl)->GetValue() == wxT("false"))
               val = false;
            theSubscriber->SetBooleanParameter(index, val);
         }
         break;

      case Gmat::REAL_TYPE:
         {
            Real val;
            valueString = ((wxTextCtrl*)theControl)->GetValue();
            CheckReal(val, valueString, label, wxT("Real Number"));
            if (!canClose)
               return;
            theSubscriber->SetRealParameter(index, val);
         }
         break;

      case Gmat::INTEGER_TYPE:
         {
            Integer val;
            valueString = ((wxTextCtrl*)theControl)->GetValue();
            CheckInteger(val, valueString, label, wxT("Integer"));
            if (!canClose)
               return;
            theSubscriber->SetIntegerParameter(index, val);
         }
         break;

      case Gmat::STRING_TYPE:
         valueString = ((wxTextCtrl*)theControl)->GetValue();
         theSubscriber->SetStringParameter(index, valueString.c_str());
         break;

      default:
         break;
   }
}
示例#2
0
//------------------------------------------------------------------------------
// virtual void SaveData()
//------------------------------------------------------------------------------
void ThrusterCoefficientDialog::SaveData()
{
   #ifdef DEBUG_COEF_SAVE
   MessageInterface::ShowMessage
      ("ThrusterCoefficientDialog::SaveData() entered\n");
   #endif
   
   canClose = true;
   
   // Validate input values
   std::string field = "";
   std::string input = "";
   Real cellValue;
   bool cellValueOK = false;
   for (int i = 0; i < coefCount; i++)
   {
      field = coefGrid->GetCellValue(i, 0).c_str();
      input = coefGrid->GetCellValue(i, 1).c_str();
      #ifdef DEBUG_COEF_SAVE
         MessageInterface::ShowMessage("   %s = '%s'\n", field.c_str(), input.c_str());
      #endif
      cellValueOK = CheckReal(cellValue, input, field, "Real Number");
      #ifdef DEBUG_COEF_SAVE
         MessageInterface::ShowMessage("   check real is %s, cellValue = %lf, coefValues[%d] = %lf\n",
               (cellValueOK? "true" : "false"), cellValue, (Integer) i, coefValues.at(i));
      #endif
      if (cellValueOK)
      {
         if (cellValue != coefValues.at(i))  coefsModified = true;
         coefValues.at(i) = cellValue;
      }
      else
      {
         canClose = false;
      }
   }
   
   if (!canClose)
   {
      ResetData();
      return;
   }
   
   #ifdef DEBUG_COEF_SAVE
   MessageInterface::ShowMessage
      ("ThrusterCoefficientDialog::SaveData() exiting\n");
   #endif
}  
示例#3
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void ImpulsiveBurnSetupPanel::SaveData()
{
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage(wxT("ImpulsiveBurnSetupPanel::SaveData() entered\n"));
   #endif
   
   canClose = true;
   wxString str;
   Real isp;
   Integer paramID;
   bool ispChanged = false;
   
   try 
   {
      if (ispTextCtrl->IsModified())
      {
         str = ispTextCtrl->GetValue();      
         CheckReal(isp, str, wxT("Isp"), wxT("Real Number >= 0"), false, true, true, true);
         ispChanged = true;
      }
      
      if (!canClose)
         return;
      
      if (ispChanged)
      {
         paramID = theObject->GetParameterID(wxT("Isp"));
         theObject->SetRealParameter(paramID, isp);
      }
   }
   catch(BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   BurnThrusterPanel::SaveData();
   
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage(wxT("ImpulsiveBurnSetupPanel::SaveData() exiting\n"));
   #endif
}
示例#4
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void ParameterSetupPanel::SaveData()
{
   canClose = true;
   std::string expr;
   
   //-----------------------------------------------------------------
   // check values from text field if variable
   //-----------------------------------------------------------------
   if (mIsValueChanged)
   {
      expr = mValueTextCtrl->GetValue().c_str();
      Real rval;
      if (mParam->GetTypeName() == "Variable")
         CheckReal(rval, expr, "Expression", "Real Number");
   }
   
   if (!canClose)
      return;
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      if (mIsValueChanged)
      {
         mIsValueChanged = false;
         mParam->SetStringParameter("Expression", expr);
      }
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
   }
}
示例#5
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
}
示例#6
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void BurnThrusterPanel::SaveData(GmatBase *theObject)
{
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage("BurnThrusterPanel::SaveData() entered\n");
   #endif
   
   canClose = true;
   std::string str;
   Real elem1, elem2, elem3, gravityAccel;
   bool realDataChanged = false;
   
   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   if (elem1TextCtrl->IsModified() || elem2TextCtrl->IsModified() ||
       elem3TextCtrl->IsModified() || gravityAccelTextCtrl->IsModified())
   {
      str = elem1TextCtrl->GetValue();
      CheckReal(elem1, str, thrustDir1, "Real Number");
      
      str = elem2TextCtrl->GetValue();
      CheckReal(elem2, str, thrustDir2, "Real Number");
      
      str = elem3TextCtrl->GetValue();
      CheckReal(elem3, str, thrustDir3, "Real Number");
      
      str = gravityAccelTextCtrl->GetValue();
      CheckReal(gravityAccel, str, "GravitationalAccel", "Real Number > 0", false,
                true, true);
      
      realDataChanged = true;      
   }
   
   if (!canClose)
      return;
   
   try 
   {
      Integer paramID;
      
      // Coordinate System      
      if (isCoordSysChanged)
      {
         paramID = theObject->GetParameterID("CoordinateSystem");
         theObject->SetStringParameter(paramID, coordSysName);
         isCoordSysChanged = false;
      }
      
      if (coordSysName == "Local")
      {
         // Origin
         paramID = theObject->GetParameterID("Origin");
         theObject->SetStringParameter(paramID, originComboBox->GetValue().WX_TO_STD_STRING);
         
         // Axes
         paramID = theObject->GetParameterID("Axes");
         theObject->SetStringParameter(paramID, axesComboBox->GetValue().WX_TO_STD_STRING);

         std::string axisValue = axesComboBox->GetValue().WX_TO_STD_STRING;
         if ((axisValue == "MJ2000Eq") || (axisValue == "SpacecraftBody"))
         {
            originLabel->Disable();
            originComboBox->Disable();
         }
         else
         {
            originLabel->Enable();
            originComboBox->Enable();
         }
      }
      
      // Save ThrustDirections
      if (realDataChanged)
      {
         paramID = theObject->GetParameterID(thrustDir1);
         theObject->SetRealParameter(paramID, elem1);
         
         paramID = theObject->GetParameterID(thrustDir2);
         theObject->SetRealParameter(paramID, elem2);
         
         paramID = theObject->GetParameterID(thrustDir3);
         theObject->SetRealParameter(paramID, elem3);
         
         paramID = theObject->GetParameterID("GravitationalAccel");
         theObject->SetRealParameter(paramID, gravityAccel);
      }
      
      // Always save DecrementMass
      // @todo If some base code computation involved, have separate flag (LOJ)
      paramID = theObject->GetParameterID("DecrementMass");
      if (decMassCheckBox->IsChecked())
         theObject->SetBooleanParameter(paramID, true);
      else
         theObject->SetBooleanParameter(paramID, false);
      
      // Save Tank
      if (isTankChanged)
      {
         isTankChanged = false;
         paramID = theObject->GetParameterID("Tank");
         
         if (theObject->TakeAction("ClearTanks", ""))
            if (tankName != "")
               theObject->SetStringParameter(paramID, tankName);
      }

      if (theObject->IsOfType(Gmat::THRUSTER))
      {
         if (theObject->IsOfType("ChemicalThruster"))
         {
            // Save C Coefficients
            if (areCCoefsChanged)
            {
               unsigned int coefSize = cCoefs.size();
               for (unsigned int i = 0; i < coefSize; i++)
               {
                  #ifdef DEBUG_BURNPANEL_SAVE_COEFS
                     MessageInterface::ShowMessage("Saving %s with value %lf\n", cCoefNames[i].c_str(), cCoefs[i]);
                  #endif
                  paramID = theObject->GetParameterID(cCoefNames[i]);
                  theObject->SetRealParameter(paramID, cCoefs[i]);
               }
            }

            // Save K Coefficients
            if (areKCoefsChanged)
            {
               unsigned int coefSize = kCoefs.size();
               for (unsigned int i = 0; i < coefSize; i++)
               {
                  #ifdef DEBUG_BURNPANEL_SAVE_COEFS
                     MessageInterface::ShowMessage("Saving %s with value %lf\n", kCoefNames[i].c_str(), kCoefs[i]);
                  #endif
                  paramID = theObject->GetParameterID(kCoefNames[i]);
                  theObject->SetRealParameter(paramID, kCoefs[i]);
               }
            }
         }
         else // ElectricThruster
         {
            // Save T Coefficients
            if (areTCoefsChanged)
            {
               unsigned int coefSize = tCoefs.size();
               for (unsigned int i = 0; i < coefSize; i++)
               {
                  #ifdef DEBUG_BURNPANEL_SAVE_COEFS
                     MessageInterface::ShowMessage("Saving %s with value %lf\n", tCoefNames[i].c_str(), tCoefs[i]);
                  #endif
                  paramID = theObject->GetParameterID(tCoefNames[i]);
                  theObject->SetRealParameter(paramID, tCoefs[i]);
               }
            }

            // Save MF Coefficients
            if (areMFCoefsChanged)
            {
               unsigned int coefSize = mfCoefs.size();
               for (unsigned int i = 0; i < coefSize; i++)
               {
                  #ifdef DEBUG_BURNPANEL_SAVE_COEFS
                     MessageInterface::ShowMessage("Saving %s with value %lf\n", mfCoefNames[i].c_str(), mfCoefs[i]);
                  #endif
                  paramID = theObject->GetParameterID(mfCoefNames[i]);
                  theObject->SetRealParameter(paramID, mfCoefs[i]);
               }
            }
         }
      }
   }
   catch(BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage("BurnThrusterPanel::SaveData() exiting\n");
   #endif
}
示例#7
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;
   }
}
示例#8
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void BurnThrusterPanel::SaveData()
{
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage(wxT("BurnThrusterPanel::SaveData() entered\n"));
   #endif
   
   canClose = true;
   wxString str;
   Real elem1, elem2, elem3, gravityAccel;
   bool realDataChanged = false;
   
   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   if (elem1TextCtrl->IsModified() || elem2TextCtrl->IsModified() ||
       elem3TextCtrl->IsModified() || gravityAccelTextCtrl->IsModified())
   {
      str = elem1TextCtrl->GetValue();
      CheckReal(elem1, str, thrustDir1, wxT("Real Number"));
      
      str = elem2TextCtrl->GetValue();
      CheckReal(elem2, str, thrustDir2, wxT("Real Number"));
      
      str = elem3TextCtrl->GetValue();
      CheckReal(elem3, str, thrustDir3, wxT("Real Number"));
      
      str = gravityAccelTextCtrl->GetValue();
      CheckReal(gravityAccel, str, wxT("GravitationalAccel"), wxT("Real Number > 0"), false,
                true, true);
      
      realDataChanged = true;      
   }
   
   if (!canClose)
      return;
   
   try 
   {
      Integer paramID;
      
      // Coordinate System      
      if (isCoordSysChanged)
      {
         paramID = theObject->GetParameterID(wxT("CoordinateSystem"));
         theObject->SetStringParameter(paramID, coordSysName);
         isCoordSysChanged = false;
      }
      
      if (coordSysName == wxT("Local"))
      {
         // Origin
         paramID = theObject->GetParameterID(wxT("Origin"));
         theObject->SetStringParameter(paramID, originComboBox->GetValue().c_str());
         
         // Axes
         paramID = theObject->GetParameterID(wxT("Axes"));
         theObject->SetStringParameter(paramID, axesComboBox->GetValue().c_str());
      }
      
      // Save ThrustDirections
      if (realDataChanged)
      {
         paramID = theObject->GetParameterID(thrustDir1);
         theObject->SetRealParameter(paramID, elem1);
         
         paramID = theObject->GetParameterID(thrustDir2);
         theObject->SetRealParameter(paramID, elem2);
         
         paramID = theObject->GetParameterID(thrustDir3);
         theObject->SetRealParameter(paramID, elem3);
         
         paramID = theObject->GetParameterID(wxT("GravitationalAccel"));
         theObject->SetRealParameter(paramID, gravityAccel);
      }
      
      // Always save DecrementMass
      // @todo If some base code computation involved, have separate flag (LOJ)
      paramID = theObject->GetParameterID(wxT("DecrementMass"));
      if (decMassCheckBox->IsChecked())
         theObject->SetBooleanParameter(paramID, true);
      else
         theObject->SetBooleanParameter(paramID, false);
      
      // Save Tank
      if (isTankChanged)
      {
         isTankChanged = false;
         paramID = theObject->GetParameterID(wxT("Tank"));
         
         if (theObject->TakeAction(wxT("ClearTanks"), wxT("")))
            if (tankName != wxT(""))
               theObject->SetStringParameter(paramID, tankName.c_str());
      }
   }
   catch(BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   #ifdef DEBUG_BURNPANEL_SAVE
   MessageInterface::ShowMessage(wxT("BurnThrusterPanel::SaveData() exiting\n"));
   #endif
}
示例#9
0
//------------------------------------------------------------------------------
// virtual void SaveData()
//------------------------------------------------------------------------------
void DragInputsDialog::SaveData()
{
   #ifdef DEBUG_DRAG_SAVE
   MessageInterface::ShowMessage(wxT("DragInputsDialog::SaveData() entered\n"));
   #endif
   
   canClose = true;
   Real flux, avgFlux, magIndex;
   
   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   if (isTextModified)
   {
      wxString str;
      
      str = solarFluxTextCtrl->GetValue();
      CheckReal(flux, str, wxT("Solar Flux (F10.7)"), wxT("Real Number >= 0.0"));
      
      str = avgSolarFluxTextCtrl->GetValue();
      CheckReal(avgFlux, str, wxT("Average Solar Flux (F10.7A)"), wxT("Real Number >= 0.0"));
      
      str = geomagneticIndexTextCtrl->GetValue();
      CheckReal(magIndex, str, wxT("Magnetic Index)"), wxT("0.0 <= Real Number <= 9.0"));
      
      if (!canClose)
         return;
      
   }
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      if (useFile)
      {
         wxString fileName = fileNameTextCtrl->GetValue().c_str();
         if (fileName == wxT(""))
         {
            MessageInterface::PopupMessage
               (Gmat::ERROR_, wxT("The flux file name is empty, please enter file name or ")
                wxT("switch to user input"));
            canClose = false;
            return;
         }
         
         inputSourceString = wxT("File");
         theForce->SetStringParameter(inputSourceID, inputSourceString.c_str());
         theForce->SetStringParameter(solarFluxFileID,
                                      fileNameTextCtrl->GetValue().c_str());
         #ifdef DEBUG_DRAG_SAVE
         MessageInterface::ShowMessage
            (wxT("   ==> Saved filename%s\n"), fileNameTextCtrl->GetValue().c_str());
         #endif
      }
      else
      {
         if (isTextModified)
         {
            inputSourceString = wxT("Constant");
            theForce->SetStringParameter(inputSourceID, inputSourceString.c_str());
            
            theForce->SetRealParameter(solarFluxID, flux);
            theForce->SetRealParameter(avgSolarFluxID, avgFlux);
            theForce->SetRealParameter(geomagnecticIndexID, magIndex);
            
            isTextModified = false;
         }
      }
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
   }
   
   #ifdef DEBUG_DRAG_SAVE
   MessageInterface::ShowMessage(wxT("DragInputsDialog::SaveData() leaving\n"));
   #endif
}
示例#10
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void TankConfigPanel::SaveData()
{
   canClose = true;
   
   Real fuelMass, pressure, temp, refTemp, volume, fuelDensity;
   wxString inputString;
   
   //-----------------------------------------------------------------
   // validate user input for non-Real value
   //-----------------------------------------------------------------
   // Fuel Mass 
   inputString = fuelMassTextCtrl->GetValue();
   CheckReal(fuelMass, inputString, wxT("FuelMass"), wxT("Real Number >= 0.0"), false, true, true, true);
   
   // Pressure 
   inputString = pressureTextCtrl->GetValue();
   CheckReal(pressure, inputString, wxT("Pressure"), wxT("Real Number >= 0.0"), false, true, true, true);
   
   // Temperature
   inputString = temperatureTextCtrl->GetValue(); 
   CheckReal(temp, inputString, wxT("Temperature"), wxT("Real Number"));
   
   // Reference Temperature
   inputString = refTemperatureTextCtrl->GetValue();
   CheckReal(refTemp, inputString, wxT("RefTemperature"), wxT("Real Number"));
   
   // Volume
   inputString = volumeTextCtrl->GetValue();
   CheckReal(volume, inputString, wxT("Volume"), wxT("Real Number >= 0.0"), false, true, true, true);
   
   // Fuel Density 
   inputString = fuelDensityTextCtrl->GetValue();
   CheckReal(fuelDensity, inputString, wxT("FuelDensity"), wxT("Real Number > 0.0"), false, true, true, false);
   
   if (!canClose)
      return;
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      // Fuel Mass
      theFuelTank->SetRealParameter(FuelTank::FUEL_MASS, fuelMass);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Allow Negative Fuel Mass
      theFuelTank->SetBooleanParameter(FuelTank::ALLOW_NEGATIVE_FUEL_MASS, allowNegativeFuelMassCheckBox->GetValue());
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Pressure 
       theFuelTank->SetRealParameter(FuelTank::PRESSURE, pressure);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Temperature
       theFuelTank->SetRealParameter(FuelTank::TEMPERATURE, temp);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Reference Temperature
       theFuelTank->SetRealParameter(FuelTank::REFERENCE_TEMPERATURE, refTemp);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Volume 
       theFuelTank->SetRealParameter(FuelTank::VOLUME, volume);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Fuel Density 
       theFuelTank->SetRealParameter(FuelTank::FUEL_DENSITY, fuelDensity);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   try
   {
      // Pressure Model
      wxString modelName = pressureModelComboBox->GetValue().c_str();
      theFuelTank->SetStringParameter(FuelTank::PRESSURE_MODEL, modelName);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   
   EnableUpdate(false);
}
示例#11
0
//------------------------------------------------------------------------------
// void OnHorizonReferenceComboBoxChange()
//------------------------------------------------------------------------------
void GroundStationPanel::OnHorizonReferenceComboBoxChange(wxCommandEvent &event)
{
   std::string horizon       = horizonReferenceComboBox->GetValue().c_str();
   std::string inputString;
   Real        location1, location2, location3;
   if (horizon != currentHorizonReference)
   {
      std::string bodyName = centralBodyComboBox->GetValue().c_str();
      // get a pointer to the celestial body
      CelestialBody *body = ss->GetBody(bodyName);
      if (!body)
      {
         std::string errmsg = "Cannot find body ";
         errmsg += bodyName + " needed for GroundStation panel update.\n";
         throw GmatBaseException(errmsg);
      }
      Real meanRadius = body->GetRealParameter(body->GetParameterID("EquatorialRadius"));
      Real flattening = body->GetRealParameter(body->GetParameterID("Flattening"));
      // Convert location values to the appropriate values
      // Location 1 (Latitude)
      inputString = location1TextCtrl->GetValue();
      CheckReal(location1, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_1), "Real Number");

      // Location 2 (Longitude)
      inputString = location2TextCtrl->GetValue();
      if (currentStateType != "Cartesian")
         CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number >= 0.0", false, true, true, true);
      else
         CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number");

      // Location 3 (Altitude)
      inputString = location3TextCtrl->GetValue();
      CheckReal(location3, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_3), "Real Number");

      Rvector3 locInCurrent(location1, location2, location3);
      if (currentStateType == "Spherical") // latitude and longitude need to be passed in as radians
      {
         locInCurrent[0] *= GmatMathConstants::RAD_PER_DEG;
         locInCurrent[1] *= GmatMathConstants::RAD_PER_DEG;
      }
      //MessageInterface::ShowMessage(" ... Spherical to new horizon ... loc = %12.10f  %12.10f  %12.10f\n",
      //      locInCurrent[0], locInCurrent[1], locInCurrent[2]); // *************************
      Rvector3 locInNew = BodyFixedStateConverterUtil::Convert(locInCurrent, currentStateType,
                          currentHorizonReference, currentStateType, horizon,
                          flattening, meanRadius);
      //MessageInterface::ShowMessage(" ... result =  %12.10f  %12.10f  %12.10f\n",
      //      locInNew[0], locInNew[1], locInNew[2]); // *************************
      location1 = locInNew[0];
      location2 = locInNew[1];
      location3 = locInNew[2];
      if (currentStateType == "Spherical") // need to display DEGREES for latitude and longitude
      {
         location1 *= GmatMathConstants::DEG_PER_RAD;
         location2 *= GmatMathConstants::DEG_PER_RAD;
      }
      localGroundStation->SetStringParameter(BodyFixedPoint::HORIZON_REFERENCE, horizon);
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_1, location1);
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_2, location2);
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_3, location3);
      location1TextCtrl->SetValue(ToWxString(location1));
      location2TextCtrl->SetValue(ToWxString(location2));
      location3TextCtrl->SetValue(ToWxString(location3));
      currentHorizonReference = horizon;
   }
   UpdateControls();
   EnableUpdate(true);
}    
示例#12
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void GroundStationPanel::SaveData()
{
   canClose = true;
   
   std::string inputString;
   std::string text;
   
   //-----------------------------------------------------------------
   // validate user input for locations if state type is not cartesian
   //   X,Y,Z May be any real
   //   Latitude is -90 to 90, Longitude 0 to 360, Altitude is any Real
   // NOTE - we are just checking for Real or non-negative real here;
   //        base code checks for actual ranges on SetrealParameter call
   //-----------------------------------------------------------------
   try
   {
      // State Type
      text = stateTypeComboBox->GetValue().c_str();
      localGroundStation->SetStringParameter(BodyFixedPoint::STATE_TYPE, text);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }

   // Location 1 (X or Latitude)
   inputString = location1TextCtrl->GetValue();
   CheckReal(location1, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_1), "Real Number");
   
   // Location 2 (Y or Longitude)
   inputString = location2TextCtrl->GetValue();
   if (text != "Cartesian")
      CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number >= 0.0", false, true, true, true);
   else
      CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number");
   
   // Location 3 (Z or Altitude)
   inputString = location3TextCtrl->GetValue();
   CheckReal(location3, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_3), "Real Number");

   if (!canClose)
      return;
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   try
   {
      // Station ID
      text = stationIDTextCtrl->GetValue().c_str();
      // Since Groundstation is now in plugin, this no longer works:
//      localGroundStation->SetStringParameter(GroundStation::STATION_ID, text);
      localGroundStation->SetStringParameter(localGroundStation->GetParameterID("Id"), text);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // Central Body
      text = centralBodyComboBox->GetValue().c_str();
      localGroundStation->SetStringParameter(BodyFixedPoint::CENTRAL_BODY, text);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // Horizon Reference
      text = horizonReferenceComboBox->GetValue().c_str();
      localGroundStation->SetStringParameter(BodyFixedPoint::HORIZON_REFERENCE, text);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // location 1
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_1, location1);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // location 2
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_2, location2);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // location 3
      localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_3, location3);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }
   try
   {
      // Hardware
//      text = hardwareTextCtrl->GetValue().c_str();
      //localGroundStation->SetStringParameter(GroundStation::HARDWARE, text);
   }
   catch (BaseException &ex)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, ex.GetFullMessage());
      canClose = false;
   }

   if (!canClose)
      return;
   // copy the current info into the ground station
   theGroundStation->Copy(localGroundStation);
   EnableUpdate(false);
}
示例#13
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void SQPSetupPanel::SaveData()
{
   canClose = true;
   Real tolFun, tolCon, tolX, diffMinChange, diffMaxChange;
   Integer maxIter, maxFunEvals;
   std::string tolFunStr, tolConStr, tolXStr, maxIterStr, maxFunEvalsStr;
   std::string diffMinChangeStr, diffMaxChangeStr;
   std::string str;

   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   if (isTextModified)
   {
      str = tolFunTextCtrl->GetValue();
      CheckReal(tolFun, str, "TolFun", "Real Number > 0");
      tolFunStr = str;

      str = tolConTextCtrl->GetValue();
      CheckReal(tolCon, str, "TolCon", "Real Number > 0");
      tolConStr = str;

      str = tolXTextCtrl->GetValue();
      CheckReal(tolX, str, "TolX", "Real Number > 0");
      tolXStr = str;

      str = maxIterTextCtrl->GetValue();
      CheckInteger(maxIter, str, "MaximumIterations", "Integer Number > 0");
      maxIterStr = str;

      str = maxFunEvalsTextCtrl->GetValue();
      CheckInteger(maxFunEvals, str, "MaxFunEvals", "Integer Number > 0");
      maxFunEvalsStr = str;

      str = diffMinChangeTextCtrl->GetValue();
      CheckReal(diffMinChange, str, "DiffMinChange", "Real Number > 0");
      diffMinChangeStr = str;

      str = diffMaxChangeTextCtrl->GetValue();
      CheckReal(diffMaxChange, str, "DiffMaxChange", "Real Number > 0");
      diffMaxChangeStr = str;
   }

   if (!canClose)
      return;

   try
   {

      // Note: It will catch one error at a time
      // Is this acceptable?

      if (isTextModified)
      {
         theSolver->SetStringParameter("TolFun", tolFunStr);
         theSolver->SetStringParameter("TolCon", tolConStr);
         theSolver->SetStringParameter("TolX", tolXStr);
         theSolver->SetIntegerParameter(theSolver->GetParameterID("MaximumIterations"), maxIter);
         theSolver->SetStringParameter("MaxFunEvals", maxFunEvalsStr);
         theSolver->SetStringParameter("DiffMinChange", diffMinChangeStr);
         theSolver->SetStringParameter("DiffMaxChange", diffMaxChangeStr);
         isTextModified = false;
      }

// GradObj, GradConstr, DerivativeCheck, Diagnostics, and Display parameters are no loner been used:
//      if (gradObjCB->IsChecked())
//         theSolver->SetStringParameter("GradObj", "On");
//      else
//         theSolver->SetStringParameter("GradObj", "Off");
//
//      if (gradConstrCB->IsChecked())
//         theSolver->SetStringParameter("GradConstr", "On");
//      else
//         theSolver->SetStringParameter("GradConstr", "Off");
//
//      if (derivativeCheckCB->IsChecked())
//         theSolver->SetStringParameter("DerivativeCheck", "On");
//      else
//         theSolver->SetStringParameter("DerivativeCheck", "Off");
//
//      if (diagnosticsCB->IsChecked())
//         theSolver->SetStringParameter("Diagnostics", "On");
//      else
//         theSolver->SetStringParameter("Diagnostics", "Off");
//
//      theSolver->SetStringParameter("Display", displayComboBox->GetValue().c_str());

	  Integer id;
      id = theSolver->GetParameterID("ShowProgress");
      theSolver->SetBooleanParameter(id, showProgressCheckBox->GetValue());

	  id = theSolver->GetParameterID("ReportStyle");
	  theSolver->SetStringParameter(id, styleComboBox->GetValue().c_str());

      id = theSolver->GetParameterID("ReportFile");
      theSolver->SetStringParameter(id, reportfileTextCtrl->GetValue().c_str());
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
      canClose = false;
      return;
   }
}