Пример #1
0
//------------------------------------------------------------------------------
void GmatFunction::BuildUnusedGlobalObjectList()
{
   #ifdef DEBUG_UNUSED_GOL
   MessageInterface::ShowMessage
      (wxT("BuildUnusedGlobalObjectList() entered. There are %d global objects\n"),
       globalObjectStore->size());
   #endif
   
   if (unusedGlobalObjectList != NULL)
      delete unusedGlobalObjectList;
   
   unusedGlobalObjectList = new StringArray;
   
   // Check global object store
   wxString cmdUsed;
   std::map<wxString, GmatBase *>::iterator omi;
   for (omi = globalObjectStore->begin(); omi != globalObjectStore->end(); ++omi)
   {
      GmatBase *obj = omi->second;
      if (!GmatCommandUtil::FindObject(fcs, (omi->second)->GetType(), omi->first,
                                       cmdUsed))
      {
         // Add unused global CoordinateSystem with Spacecraft origin,  primary,
         // or secondary, since Spacecraft is not an automatic global object and
         // we don't want to throw an exception for unexisting Spacecraft in the GOS.
         if (obj->IsOfType(Gmat::COORDINATE_SYSTEM))
         {
            GmatBase *origin = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFOrigin_"));
            GmatBase *primary = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFPrimary_"));
            GmatBase *secondary = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFSecondary_"));
            
            if ((origin != NULL && origin->IsOfType(Gmat::SPACECRAFT)) ||
                (primary != NULL && primary->IsOfType(Gmat::SPACECRAFT)) ||
                (secondary != NULL && secondary->IsOfType(Gmat::SPACECRAFT)))
            {
               #ifdef DEBUG_UNUSED_GOL
               MessageInterface::ShowMessage
                  (wxT("==> Adding '%s' to unusedGOL\n"), (omi->first).c_str());
               #endif
               unusedGlobalObjectList->push_back(omi->first);
            }
         }
      }
   }
   #ifdef DEBUG_UNUSED_GOL
   MessageInterface::ShowMessage
      (wxT("BuildUnusedGlobalObjectList() leaving, There are %d unused global objects\n"),
       unusedGlobalObjectList->size());
   #endif
}
Пример #2
0
//------------------------------------------------------------------------------
bool EndFiniteBurn::Initialize()
{
   bool retval = GmatCommand::Initialize();
   GmatBase *mapObj;
   
   if (retval)
   {
      // Look up the maneuver object
      if ((mapObj = FindObject(burnName)) == NULL) 
         throw CommandException("EndFiniteBurn: Unknown finite burn \"" +
               burnName + "\"");
      if (mapObj->IsOfType("FiniteBurn") == false)
         throw CommandException("EndFiniteBurn: " + (burnName) + " is not a "
               "FiniteBurn");
      maneuver = (FiniteBurn*)mapObj;
      
      // Find all of the spacecraft
      StringArray::iterator scName;
      Spacecraft *sc;
      sats.clear();
      for (scName = satNames.begin(); scName != satNames.end(); ++scName)
      {
         if ((mapObj = FindObject(*scName)) == NULL) 
            throw CommandException("EndFiniteBurn: Unknown SpaceObject \"" +
                  (*scName) + "\"");
         
         if (mapObj->IsOfType(Gmat::SPACECRAFT) == false)
            throw CommandException("EndFiniteBurn: " + (*scName) +
                  " is not a Spacecraft");
         sc = (Spacecraft*)mapObj;
         sats.push_back(sc);
      }
   }
   
   thrustName = burnName + "_FiniteThrust";
   #ifdef DEBUG_END_MANEUVER
      MessageInterface::ShowMessage
         ("EndFiniteBurn initialized with thrust force named \"%s\"\n", 
          thrustName.c_str());
   #endif
   
   return isInitialized;
}
Пример #3
0
//------------------------------------------------------------------------------
PropSetup *GetFirstPropagator(GmatCommand *cmd)
{
   static PropSetup *retval = NULL;
   GmatCommand *current = cmd;

   #ifdef DEBUG_ODE_SEARCH
      extraMsg = "Commands checked:\n";
   #endif
   while (current != NULL)
   {
      #ifdef DEBUG_ODE_SEARCH
            extraMsg += "   '" + current->GetTypeName() + "'\n";
      #endif
      if (current->GetTypeName() == "Propagate")
      {
         try
         {
            // Set all of the internal connections
//               current->TakeAction("PrepareToPropagate");
            current->Execute();
         }
         catch (BaseException &ex)
         {
            lastMsg = ex.GetFullMessage();
         }
         #ifdef DEBUG_ODE_SEARCH
            extraMsg += "      Checking in this command\n";
         #endif
         GmatBase *obj = current->GetRefObject(Gmat::PROP_SETUP, "", 0);

         #ifdef DEBUG_ODE_SEARCH
            if (obj != NULL)
               extraMsg += "      Found an object of type PROPSETUP\n";
            else
               extraMsg += "      Propagate command returns NULL PROPSETUP\n";
         #endif

         if (obj->IsOfType("PropSetup"))
         {
            retval = (PropSetup*)(obj);
            break;
         }
      }

      current = current->GetNext();
   }

   return retval;
}
Пример #4
0
//------------------------------------------------------------------------------
bool Set::Initialize()
{
   bool retval = GmatCommand::Initialize();
   
   target = FindObject(targetName);
   if (target == NULL)
      throw CommandException("The Set command could not find the target "
            "object \"" + targetName + "\" needed to initialize");

   GmatBase *obj = FindObject(interfaceName);
   if (obj == NULL)
      throw CommandException("The Set command could not find the interface "
            "object \"" + interfaceName + "\" needed to initialize");

   if (obj->IsOfType("DataInterface"))
      theInterface = (DataInterface*)obj;
   else
      throw CommandException("The object \"" + interfaceName +
               "\" is not a FileInterface object."); 


   // If specific data elements are requested, warn if not in the reader
   if (!loadAll)
   {
      StringArray allKeywords = 
         theInterface->GetStringArrayParameter("SupportedFields");
      for (UnsignedInt i = 0; i < selections.size(); ++i)
         if (find(allKeywords.begin(), allKeywords.end(), selections[i]) ==
               allKeywords.end())
            MessageInterface::ShowMessage("*** Warning ***: The data keyword "
                  "\"%s\" is not a recognized keyword in the data reader "
                  "\"tvhf\" on the line:\n%s\n", selections[i].c_str(), 
                  generatingString.c_str());
   }
   
   return retval;
}
Пример #5
0
//------------------------------------------------------------------------------
void TopocentricAxes::CalculateRotationMatrix(const A1Mjd &atEpoch,
                                              bool forceComputation) 
{   
   // Check to make sure that the central body is a celestial body
   itsBodyName       = bfPoint->GetStringParameter("CentralBody");
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("Origin's central body is %s\n",
            itsBodyName.c_str());
   #endif
   GmatBase *bodyPtr = bfPoint->GetRefObject(Gmat::CELESTIAL_BODY, itsBodyName);
   if (!bodyPtr)
   {
      std::string errMsg = "Central Body for a BodyFixedPoint used in a ";
      errMsg += " Topocentric Coordinate System is NULL";
      throw CoordinateSystemException(errMsg);
   }
   if (!(bodyPtr->IsOfType("CelestialBody")))
   {
      std::string errMsg = "Central Body for a BodyFixedPoint used in a ";
      errMsg += " Topocentric Coordinate System must be a Celestial Body";
      throw CoordinateSystemException(errMsg);
   }
   centralBody      = (CelestialBody*) bodyPtr;
   flattening       = centralBody->GetFlattening();
   radius           = centralBody->GetEquatorialRadius();
   bfcs             = bfPoint->GetBodyFixedCoordinateSystem();
   horizonReference = bfPoint->GetStringParameter("HorizonReference");
   if ((horizonReference != "Sphere") && (horizonReference != "Ellipsoid"))
   {
      std::string errMsg = "Unexpected horizon reference \"";
      errMsg += horizonReference + "\" received from BodyFixedPoint \"";
      errMsg += bfPoint->GetName() + "\"";
      throw CoordinateSystemException(errMsg);
   }

   // compute rotMatrix and rotDotMatrix
   // First, calculate the Rft matrix, if the position has changed
   Rvector3 newLoc  = bfPoint->GetBodyFixedLocation(atEpoch);
   
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("horizon reference is %s:\n",
            horizonReference.c_str());
      MessageInterface::ShowMessage("flattening of %s is %12.17f:\n",
            itsBodyName.c_str(), flattening);
      MessageInterface::ShowMessage("equatorial radius of %s is %12.17f:\n\n",
            itsBodyName.c_str(), radius);
      MessageInterface::ShowMessage("bfPoint's old location is:\n");
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[0]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[1]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[2]);
      MessageInterface::ShowMessage("bfPoint's new location is:\n");
      MessageInterface::ShowMessage("%12.17f\n", newLoc[0]);
      MessageInterface::ShowMessage("%12.17f\n", newLoc[1]);
      MessageInterface::ShowMessage("%12.17f\n", newLoc[2]);
   #endif
   if (newLoc != bfLocation)
      CalculateRFT(atEpoch, newLoc);
   // save the location
   bfLocation  = newLoc;
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("Now bfLocation is set to:\n");
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[0]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[1]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[2]);
   #endif
   // Determine rotation matrix from body-fixed to inertial
   Rvector bogusIn(6,7000.0,1000.0,6000.0, 0.0, 0.0, 0.0);
   Rvector bogusOut = bfcs->ToBaseSystem(atEpoch, bogusIn); // @todo - need ToMJ2000Eq here?
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("bogusIn:\n");
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[0]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[1]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[2]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[3]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[4]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[5]);
      MessageInterface::ShowMessage("bogusOut:\n");
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[0]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[1]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[2]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[3]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[4]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[5]);
   #endif
   Rmatrix33 RIF    = bfcs->GetLastRotationMatrix();
   Rmatrix33 RIFDot = bfcs->GetLastRotationDotMatrix();
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("last Rotation Matrix (RIF):\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(0,0), RIF(0,1), RIF(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(1,0), RIF(1,1), RIF(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(2,0), RIF(2,1), RIF(2,2));
      MessageInterface::ShowMessage("last Rotation Dot Matrix (RIFDot):\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(0,0), RIFDot(0,1), RIFDot(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(1,0), RIFDot(1,1), RIFDot(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(2,0), RIFDot(2,1), RIFDot(2,2));
   #endif
   
   rotMatrix        = RIF    * RFT;
   rotDotMatrix     = RIFDot * RFT;

   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("rotMatrix:\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(0,0), rotMatrix(0,1), rotMatrix(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(1,0), rotMatrix(1,1), rotMatrix(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(2,0), rotMatrix(2,1), rotMatrix(2,2));
      MessageInterface::ShowMessage("rotDotMatrix:\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(0,0), rotDotMatrix(0,1), rotDotMatrix(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(1,0), rotDotMatrix(1,1), rotDotMatrix(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(2,0), rotDotMatrix(2,1), rotDotMatrix(2,2));
   #endif
}
Пример #6
0
//------------------------------------------------------------------------------
bool RunSimulator::Initialize()
{
   bool retval = false;

   // First set the simulator object
   if (solverName == wxT(""))
      throw CommandException(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("simulator name is not specified."));

   // Clear the old clone if it was set
   if (theSimulator != NULL)
      delete theSimulator;

   GmatBase *simObj = FindObject(solverName);
   if (simObj == NULL)
      throw CommandException(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("simulator named ") + solverName + wxT(" cannot be found."));

   if (!simObj->IsOfType(wxT("Simulator")))
      throw CommandException(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("object named ") + solverName + wxT(" is not a simulator."));

   theSimulator = (Simulator*)(simObj->Clone());

   // Set the streams for the measurement manager
   MeasurementManager *measman = theSimulator->GetMeasurementManager();
   StringArray streamList = measman->GetStreamList();
   for (UnsignedInt ms = 0; ms < streamList.size(); ++ms)
   {
      GmatBase *obj = FindObject(streamList[ms]);
      if (obj != NULL)
      {
         if (obj->IsOfType(Gmat::DATASTREAM))
         {
            Datafile *df = (Datafile*)obj;
            measman->SetStreamObject(df);
         }
      }
      else
         throw CommandException(wxT("Did not find the object named ") +
               streamList[ms]);
   }

   // Next comes the propagator
   PropSetup *obj = theSimulator->GetPropagator();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage(wxT("Propagator at address %p "), obj);
      if (obj != NULL)
         MessageInterface::ShowMessage(wxT("is named %s\n"),
               obj->GetName().c_str());
      else
         MessageInterface::ShowMessage(wxT("is not yet set\n"));
   #endif

   if (obj != NULL)
   {
      if (obj->IsOfType(Gmat::PROP_SETUP))
      {
         PropSetup *ps = (PropSetup*)obj->Clone();

         // RunSimulator only manages one PropSetup.  If that changes, so
         // does this code
         if (propagators.size() > 0)
         {
            for (std::vector<PropSetup*>::iterator pp = propagators.begin();
                  pp != propagators.end(); ++pp)
            {
               delete (*pp);
            }
            propagators.clear();
            p.clear();
            fm.clear();
         }
         propagators.push_back(ps);
         p.push_back(ps->GetPropagator());
         fm.push_back(ps->GetODEModel());
         retval = true;
      }
   }
   else
      throw CommandException(wxT("Cannot initialize RunSimulator command; the ")
            wxT("propagator pointer in the Simulator ") +
            theSimulator->GetName() + wxT(" is NULL."));

   // Now set the participant list
   MeasurementManager *mm = theSimulator->GetMeasurementManager();
   StringArray participants = mm->GetParticipantList();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage(wxT("RunSimulator command found %d ")
            wxT("participants\n"), participants.size());
   #endif

   propObjectNames.clear();
   propObjectNames.push_back(participants);

   // Now we can initialize the propagation subsystem by calling up the
   // inheritance tree.
   retval = RunSolver::Initialize();

   #ifdef DEBUG_INITIALIZATION
      if (retval == false)
         MessageInterface::ShowMessage(wxT("RunSimulator command failed to ")
               wxT("initialize; RunSolver::Initialize() call failed.\n"));
   #endif

   return retval;
}
Пример #7
0
//------------------------------------------------------------------------------
bool RunSimulator::Initialize()
{
   bool retval = false;

   // First set the simulator object
   if (solverName == "")
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "simulator name is not specified.");

   // Clear the old clone if it was set
   if (theSimulator != NULL)
      delete theSimulator;

   GmatBase *simObj = FindObject(solverName);
   if (simObj == NULL)
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "simulator named " + solverName + " cannot be found.");

   if (!simObj->IsOfType("Simulator"))
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "object named " + solverName + " is not a simulator.");

   theSimulator = (Simulator*)(simObj->Clone());

   // Set the streams for the measurement manager
   MeasurementManager *measman = theSimulator->GetMeasurementManager();
   StringArray streamList = measman->GetStreamList();
   for (UnsignedInt ms = 0; ms < streamList.size(); ++ms)
   {
      GmatBase *obj = FindObject(streamList[ms]);
      if (obj != NULL)
      {
         if (obj->IsOfType(Gmat::DATASTREAM))
         {
            DataFile *df = (DataFile*)obj;
            measman->SetStreamObject(df);
         }
      }
      else
         throw CommandException("Did not find the object named " +
               streamList[ms]);
   }

   // Find the event manager and store its pointer
   if (triggerManagers == NULL)
      throw CommandException("The Event Manager pointer was not set on the "
            "RunSimulator command");

   for (UnsignedInt i = 0; i < triggerManagers->size(); ++i)
   {
      #ifdef DEBUG_INITIALIZATION
         MessageInterface::ShowMessage("RunSimulator has an TriggerManager of "
               "type %s, id %d\n",
               (*triggerManagers)[i]->GetTriggerTypeString().c_str(),
               (*triggerManagers)[i]->GetTriggerType());
      #endif
      if ((*triggerManagers)[i]->GetTriggerType() == Gmat::EVENT)
      {
         eventMan = (EventManager*)(*triggerManagers)[i];
         #ifdef DEBUG_INITIALIZATION
            MessageInterface::ShowMessage("RunSimulator has an EventManager of "
                  "type %s\n", eventMan->GetTriggerTypeString().c_str());
         #endif
      }
   }
   if (eventMan == NULL)
      throw CommandException("The EventManager pointer was not set on the "
            "RunSimulator command");

   // Next comes the propagator
   PropSetup *obj = theSimulator->GetPropagator();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("Propagator at address %p ", obj);
      if (obj != NULL)
         MessageInterface::ShowMessage("is named %s\n",
               obj->GetName().c_str());
      else
         MessageInterface::ShowMessage("is not yet set\n");
   #endif

   if (obj != NULL)
   {
      if (obj->IsOfType(Gmat::PROP_SETUP))
      {
         PropSetup *ps = (PropSetup*)obj->Clone();

         // RunSimulator only manages one PropSetup.  If that changes, so
         // does this code
         if (propagators.size() > 0)
         {
            for (std::vector<PropSetup*>::iterator pp = propagators.begin();
                  pp != propagators.end(); ++pp)
            {
               delete (*pp);
            }
            propagators.clear();
            p.clear();
            fm.clear();
         }
         propagators.push_back(ps);
         p.push_back(ps->GetPropagator());
         fm.push_back(ps->GetODEModel());
         eventMan->SetObject(ps);  // todo <-- Check this -- added 6/28

//         PropagationStateManager *psm = ps->GetPropStateManager();
//         StringArray propObjects = ps->GetStringArrayParameter("");

         retval = true;
      }
   }
   else
      throw CommandException("Cannot initialize RunSimulator command; the "
            "propagator pointer in the Simulator " +
            theSimulator->GetName() + " is NULL.");

   // Now set the participant list
   MeasurementManager *mm = theSimulator->GetMeasurementManager();
   StringArray participants = mm->GetParticipantList();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("RunSimulator command found %d "
            "participants\n", participants.size());
   #endif

   propObjectNames.clear();
   propObjectNames.push_back(participants);

   // Now we can initialize the propagation subsystem by calling up the
   // inheritance tree.
   if (retval)
      retval = RunSolver::Initialize();

   #ifdef DEBUG_INITIALIZATION
      if (retval == false)
         MessageInterface::ShowMessage("RunSimulator command failed to "
               "initialize; RunSolver::Initialize() call failed.\n");
   #endif

   return retval;
}
Пример #8
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   if (IsIconized())
      return;
   
   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
      // Since GmatMainFrame::GetActualClientSize() subtracts one, add one here (LOJ: 2012.07.23)
      screenWidth++;
      screenHeight++;
   #endif

   bool isMinimized = IsIconized(), isMaximized = IsMaximized();
   if (isMinimized)	
	  Iconize(false);
   else if (isMaximized)
	  Maximize(false);

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   if (isMinimized)	
	  Iconize();
   else if (isMaximized)
	  Maximize();


   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage("*** Size of SCREEN %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, screenWidth, screenHeight);
   MessageInterface::ShowMessage("Position of View plot %s is: x = %d, y = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpX, tmpY);
   MessageInterface::ShowMessage("Size of View plot %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpW, tmpH);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  ||
       (mItemType == GmatTree::OUTPUT_CCSDS_OEM_FILE ) ||
       (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) ||
       (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj = theGuiInterpreter->GetConfiguredObject(mChildName.c_str());
      
      #ifdef DEBUG_FUNCTION
      // Check if child name is the configured object name
      MessageInterface::ShowMessage
         ("GmatMdiChildFrame::SaveChildPositionAndSize() the child '%s' %s a "
          "configured object, obj = <%p>[%s]'%s'\n", mChildName.WX_TO_C_STRING,
          obj ? "is" : "is not", obj, obj ? obj->GetTypeName().c_str() : "NULL",
          obj ? obj->GetName().c_str() : "NULL");
      #endif
      
      if (!obj)
      {
         // Just return if child is not a configured subscriber,ie,
         // plotting from GMAT function (LOJ: 2015.06.26)
         #ifdef DEBUG_FUNCTION
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "will not save position and size for unconfigured subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         return;
      }
      else if (!obj->IsOfType("Subscriber"))
      {
         #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "cannot not save position and size for non-subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         SubscriberException se;
         se.SetDetails("Cannot set position and size for non-subscriber '%s'");
         throw se;
      }
      
      Subscriber *sub = (Subscriber*) obj;
      
      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID("UpperLeft"), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID("Size"), childSize);
      sub->SetIntegerParameter(sub->GetParameterID("RelativeZOrder"), relativeZOrder);
      sub->SetBooleanParameter(sub->GetParameterID("Maximized"), isMaximized);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/MissionTree/UpperLeft", location.str().c_str());
      pConfig->Write("/MissionTree/Size", size.str().c_str());
      pConfig->Write("/MissionTree/IsMaximized", isMaximized);
      pConfig->Write("/MissionTree/IsMinimized", isMinimized);
   }
   else if (mItemType == GmatTree::SCRIPT_FILE)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/ScriptEditor/UpperLeft", location.str().c_str());
      pConfig->Write("/ScriptEditor/Size", size.str().c_str());
      pConfig->Write("/ScriptEditor/IsMaximized", isMaximized);
      pConfig->Write("/ScriptEditor/IsMinimized", isMinimized);
   }
}
Пример #9
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      //theParent->GetClientSize(&screenWidth, &screenHeight);
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
   #endif

//   #ifdef DEBUG_PERSISTENCE
//   wxRect      wxR         = GetScreenRect();
//   wxPoint     wxP         = wxR.GetPosition();
//   wxSize      wxS         = wxR.GetSize();
//   Integer     x           = (Integer) wxP.x;
//   Integer     y           = (Integer) wxP.y;
//   Integer     w           = (Integer) wxS.GetWidth();
//   Integer     h           = (Integer) wxS.GetHeight();
//   MessageInterface::ShowMessage
//      (wxT("wxP.x = %d, wxP.y = %d, wxS.w = %d, wxS.h = %d\n"), x, y, w, h);
//   #endif

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage(wxT("*** Size of SCREEN %s is: width = %d, height = %d\n"), mPlotName.c_str(), screenWidth, screenHeight);
   MessageInterface::ShowMessage(wxT("Position of View plot %s is: x = %d, y = %d\n"), mPlotName.c_str(), tmpX, tmpY);
   MessageInterface::ShowMessage(wxT("Size of View plot %s is: width = %d, height = %d\n"), mPlotName.c_str(), tmpW, tmpH);
//   MessageInterface::ShowMessage(wxT("Position of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpX, (Integer) tmpY);
//   MessageInterface::ShowMessage(wxT("Size of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpW, (Integer) tmpH);
//   wxPoint tmpPt = ScreenToClient(wxP);
//   MessageInterface::ShowMessage(wxT("--- Position of View plot %s in client coords is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpPt.x, (Integer) tmpPt.y);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  || (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) || (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj =
         (Subscriber*)theGuiInterpreter->GetConfiguredObject(mPlotName.c_str());
         
      if (!obj || !obj->IsOfType(wxT("Subscriber")))
      {
         wxString errmsg = wxT("Cannot find subscriber ");
         errmsg += mPlotName + wxT("\n");
         throw SubscriberException(errmsg);
      }
      Subscriber *sub = (Subscriber*) obj;

      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID(wxT("UpperLeft")), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID(wxT("Size")), childSize);
      sub->SetIntegerParameter(sub->GetParameterID(wxT("RelativeZOrder")), relativeZOrder);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      wxString location;
      location << upperLeft[0] << wxT(" ") << upperLeft[1];
      wxString size;
      size << childSize[0] << wxT(" ") << childSize[1];
      pConfig->Write(wxT("/MissionTree/UpperLeft"), location.c_str());
      pConfig->Write(wxT("/MissionTree/Size"), size.c_str());
   }
}
Пример #10
0
//------------------------------------------------------------------------------
bool BeginFiniteBurn::Initialize()
{
   bool retval = GmatCommand::Initialize();
   
   #ifdef DEBUG_BEGIN_MANEUVER
      MessageInterface::ShowMessage
         ("BeginFiniteBurn::Initialize() entered. burnName=%s\n", burnName.c_str());
   #endif
   
   GmatBase *mapObj = NULL;
   if (retval)
   {
      // Look up the maneuver object
      if ((mapObj = FindObject(burnName)) == NULL) 
         throw CommandException("Unknown finite burn \"" + burnName + "\"\n");
      if (mapObj->IsOfType("FiniteBurn") == false)
         throw CommandException(burnName + " is not a FiniteBurn\n");

      maneuver = (FiniteBurn*)mapObj;

      #ifdef DEBUG_BEGIN_MANEUVER
         MessageInterface::ShowMessage(
            "BeginFiniteBurn::Initialize() found %s with type %s\n", 
            maneuver->GetName().c_str(), maneuver->GetTypeName().c_str());
      #endif      

      // find all of the spacecraft
      StringArray::iterator scName;
      Spacecraft *sc;
      sats.clear();
      for (scName = satNames.begin(); scName != satNames.end(); ++scName)
      {
         if ((mapObj = FindObject(*scName)) == NULL) 
            throw CommandException("Unknown SpaceObject \"" + (*scName) + "\"");

         if (mapObj->IsOfType(Gmat::SPACECRAFT) == false)
            throw CommandException((*scName) + " is not a Spacecraft");
         sc = (Spacecraft*)mapObj;

         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() found %s with type %s\n", 
               scName->c_str(), sc->GetTypeName().c_str());
         #endif
         
         sats.push_back(sc);
      }
      
      // Delete old burnForce
      if (burnForce != NULL)
      {
         #ifdef DEBUG_MEMORY
         MemoryTracker::Instance()->Remove
            (burnForce, burnForce->GetName(), "BeginFiniteBurn::Initialize()",
             "deleting burn force");
         #endif
         if (transientForces != NULL)
         {
            std::vector<PhysicalModel *>::iterator transient = find(
               transientForces->begin(), transientForces->end(), burnForce);
            if (transient != transientForces->end())
            {
               #ifdef DEBUG_TRANSIENTFORCE_MANAGEMENT
                  MessageInterface::ShowMessage("Removing burn force <%p> from "
                        "the transient force list\n", burnForce);
               #endif
               transientForces->erase(transient);
            }
         }
         delete burnForce;
         burnForce = NULL;
      }
      
      // If all is okay, create the FiniteThrust object and configure it.
      std::string thrustName = burnName + "_FiniteThrust";
      burnForce = new FiniteThrust(thrustName);
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Add
         (burnForce, thrustName, "BeginFiniteBurn::Initialize()",
          "burnForce = new FiniteThrust()");
      #endif
      
      burnForce->SetRefObject(maneuver, maneuver->GetType(),
                              maneuver->GetName());

      Gmat::ObjectType type = Gmat::SPACECRAFT;
      StringArray::iterator iter;
      
      // load up the spacecraft name list
      for (iter = satNames.begin(); iter != satNames.end(); ++iter)
      {
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() setting %s on %s\n", 
               iter->c_str(), thrustName.c_str());
         #endif
         burnForce->SetRefObjectName(type, *iter);
      }
   }
   
   #ifdef DEBUG_BEGIN_MANEUVER
   MessageInterface::ShowMessage
      ("BeginFiniteBurn::Initialize() returning %d\n", isInitialized);
   #endif
   
   return isInitialized;
}
Пример #11
0
//------------------------------------------------------------------------------
PropSetup *GetPropagator(GmatCommand **cmd)
{
   PropSetup *retval = NULL;
   static Integer setupIndex = 0;

   if ((*cmd) != NULL)
   {
      bool findNextPropagate = false;
      std::string currentType = (*cmd)->GetTypeName();

      if ((currentType == "Propagate") && (setupIndex > 0))
      {
         try
         {
            if ((*cmd)->GetRefObject(Gmat::PROP_SETUP, "", setupIndex) == NULL)
            {
               findNextPropagate = true;
               (*cmd) = (*cmd)->GetNext();
               setupIndex = 0;
            }
         }
         catch (BaseException &)
         {
            findNextPropagate = true;
            (*cmd) = (*cmd)->GetNext();
         }
      }
      else
         findNextPropagate = true;

      if (findNextPropagate)
      {
         // Find the next propagate command
         setupIndex = 0;
         if ((*cmd) != NULL)
         {
            while ((*cmd)->GetTypeName() != "Propagate")
            {
               (*cmd) = (*cmd)->GetNext();
               if ((*cmd) == NULL)
                  break;
            }
         }
      }

      if ((*cmd) != NULL)
      {
         #ifdef DEBUG_INTERFACE_FROM_MATLAB
            fprintf(fp, "Current <%p>: %s; SetupIndex %d\n", (*cmd),
                  (*cmd)->GetGeneratingString(Gmat::NO_COMMENTS).c_str(),
                  setupIndex);
         #endif
         GmatBase *obj = NULL;
         try
         {
            if (setupIndex == 0)
            {
               try
               {
                  // Set all of the internal connections
      //               current->TakeAction("PrepareToPropagate");
                  (*cmd)->Execute();
               }
               catch (BaseException &ex)
               {
                  lastMsg = ex.GetFullMessage();
               }
            }

            obj = (*cmd)->GetRefObject(Gmat::PROP_SETUP, "", setupIndex);
         }
         catch (BaseException *)
         {
            obj = NULL;
         }

         if (obj == NULL)
         {
            (*cmd) = (*cmd)->GetNext();
            #ifdef DEBUG_INTERFACE_FROM_MATLAB
               fprintf(fp, "obj was NULL; new command is <%p>: %s\n", (*cmd),
                     (*cmd)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
            #endif
            setupIndex = 0;
         }
         else
         {
            if (obj->IsOfType(Gmat::PROP_SETUP))
               retval = (PropSetup*)obj;
            ++setupIndex;
         }
      }
   }

   return retval;
}