コード例 #1
0
//------------------------------------------------------------------------------
const wxString& EndTarget::GetGeneratingString(Gmat::WriteMode mode,
                                                  const wxString &prefix,
                                                  const wxString &useName)
{
   if (mode == Gmat::NO_COMMENTS)
   {
      generatingString = wxT("EndTarget;");
      return generatingString;
   }
   
   // Build the local string
   generatingString = prefix + wxT("EndTarget;");
   if ((next) && (next->GetTypeName() == wxT("Target")))
   {
      // To avoid keep appending, check for empty inline comment
      if (GetInlineComment() == wxT(""))
      {
         generatingString += wxT("  % For targeter ");
         generatingString += next->GetRefObjectName(Gmat::SOLVER);
      }
   }
   
   // Then call the base class method for preface and inline comments
   // We want preface comment to be indented
   return GmatCommand::GetGeneratingString(mode, prefix + wxT("   "), useName);
}
コード例 #2
0
ファイル: EndOptimize.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
// GetGeneratingString
//------------------------------------------------------------------------------
const std::string& EndOptimize::GetGeneratingString(Gmat::WriteMode mode,
                                                    const std::string &prefix,
                                                    const std::string &useName)
{
   generatingString = prefix + "EndOptimize;";
   if (mode == Gmat::NO_COMMENTS)
   {
	  InsertCommandName(generatingString);
      return generatingString;
   }
   
   if ((next) && (next->GetTypeName() == "Optimize"))
   {
      if (showInlineComment)
      {
         // To avoid keep appending, check for empty inline comment
         if (GetInlineComment() == "")
         {
            generatingString += "  % For optimizer ";
            generatingString += next->GetRefObjectName(Gmat::SOLVER);
         }
      }
   }
   return GmatCommand::GetGeneratingString(mode, prefix, useName);
}
コード例 #3
0
//------------------------------------------------------------------------------
std::string Array::GetInitialValueString(const std::string &prefix)
{
   #ifdef DEBUG_INITIAL_VALUE
   MessageInterface::ShowMessage
      ("Array::GetInitialValueString() '%s' entered\n", GetName().c_str());
   #endif
   
   std::stringstream data;
   bool writeGmatKeyword = GmatGlobal::Instance()->IsWritingGmatKeyword();
   
   Integer row = GetIntegerParameter("NumRows");
   Integer col = GetIntegerParameter("NumCols");
   
   for (Integer i = 0; i < row; ++i)
   {
      //loj: Do not write if value is zero since default is zero(03/27/07)
      for (Integer j = 0; j < col; ++j)
      {
         Real realVal = GetRealParameter(SINGLE_VALUE, i, j);
         #ifdef DEBUG_INITIAL_VALUE
         MessageInterface::ShowMessage("   value = %f\n", realVal);
         #endif
         
         if (realVal != 0.0)
         {
            //========================================================
            #ifndef __WRITE_INITIAL_VALUE_STRING__
            //========================================================
            
            // This writes out actual value
            // We now write out GMAT prefix on option from the startup file (see GMT-3233)
            if (writeGmatKeyword)
               data << "GMAT " << instanceName << "(" << i+1 << ", " << j+1 <<
                  ") = " <<  GmatStringUtil::ToString(realVal, 16, false, 1) << ";";
            else
               data << instanceName << "(" << i+1 << ", " << j+1 <<
                  ") = " <<  GmatStringUtil::ToString(realVal, 16, false, 1) << ";";
            data << GetInlineComment() + "\n";
            
            //========================================================
            #else
            //========================================================
            
            // This writes out initial value string (LOJ: 2010.09.21)
            std::string mapstr = GmatStringUtil::ToString(i+1, 1) + "," +
               GmatStringUtil::ToString(j+1, 1);
            
            #ifdef DEBUG_INITIAL_VALUE
            MessageInterface::ShowMessage
               ("Array::GetInitialValueString() mapstr='%s'\n", mapstr.c_str());
            #endif
            
            std::string initialVal = "No Initial Value";
            bool writeData = false;
            
            if (initialValueMap.find(mapstr) != initialValueMap.end())
               initialVal = initialValueMap[mapstr];
            
            #ifdef DEBUG_INITIAL_VALUE
            MessageInterface::ShowMessage("   initialVal='%s'\n", initialVal.c_str());
            #endif
            
            if (GmatStringUtil::IsNumber(initialVal))
               if (mInitialValueType == 1)
                  writeData = true;
               else
                  writeData = false;
            else
               if (mInitialValueType == 1)
                  writeData = false;
               else
                  writeData = true;
            
            if (writeData)
            {
               // We now write out GMAT prefix on option from the startup file (see GMT-3233)
               if (writeGmatKeyword)
                  data << prefix << "GMAT " << instanceName << "(" << i+1 << ", " << j+1 << ") = " << initialVal;
               else
                  data << prefix << instanceName << "(" << i+1 << ", " << j+1 << ") = " << initialVal;
               data << GetInlineComment() + "\n";
            }
            
            //========================================================
            #endif
            //========================================================
         }
      }
   }
   
   return data.str();
}
コード例 #4
0
//------------------------------------------------------------------------------
const wxString& BeginScript::GetGeneratingString(Gmat::WriteMode mode,
                                                    const wxString &prefix,
                                                    const wxString &useName)
{
   //Note: This method is called only once from the ScriptInterpreter::WriteScript()
   // So all nested ScriptEvent generating string should be handled here
   
   wxString gen;
   wxString indent;
   wxString commentLine = GetCommentLine();
   wxString inlineComment = GetInlineComment();
   wxString beginPrefix = prefix;

   if (mode != Gmat::GUI_EDITOR)
   {
      if (mode == Gmat::NO_COMMENTS)
      {
         gen << prefix << wxT("BeginScript") << wxT("\n");
      }
      else
      {
         IndentComment(gen, commentLine, prefix);
         gen << prefix << wxT("BeginScript");   
         
         if (inlineComment != wxT(""))
            gen << inlineComment << wxT("\n");
         else
            gen << wxT("\n");
      }
   }
   
   #if DBGLVL_GEN_STRING
   MessageInterface::ShowMessage
      (wxT("BeginScript::GetGeneratingString() this=(%p)%s, mode=%d, prefix='%s', ")
       wxT("useName='%s'\n"), this, this->GetTypeName().c_str(), mode, prefix.c_str(),
       useName.c_str());
   #endif
   
   if (mode == Gmat::GUI_EDITOR)
      indent = wxT("");
   else
      indent = wxT("   ");
   
   GmatCommand *current = next;
   while (current != NULL)
   {      
      #if DBGLVL_GEN_STRING > 1
      MessageInterface::ShowMessage
         (wxT("BeginScript::GetGeneratingString() current=(%p)%s\n"), current,
          current->GetTypeName().c_str());
      #endif
      
      if (current->GetTypeName() != wxT("EndScript"))
      {
         // Indent whole block within Begin/EndScript
         IndentChildString(gen, current, indent, mode, prefix, useName, false);
         
         // Get command after EndScript
         current = GmatCommandUtil::GetNextCommand(current);
         
         if (current == NULL)
            IndentChildString(gen, current, indent, mode, beginPrefix, useName, true);
      }
      else
      {
         if (mode != Gmat::GUI_EDITOR)
         {
            // Indent whole block within Begin/EndScript
            IndentChildString(gen, current, indent, mode, beginPrefix, useName, true);
         }
         current = NULL;
      }
   }
   
   generatingString = gen;
   
   #if DBGLVL_GEN_STRING
   MessageInterface::ShowMessage
      (wxT("BeginScript::GetGeneratingString() returnning generatingString\n"));
   MessageInterface::ShowMessage(wxT("<<<\n%s>>>\n\n"), generatingString.c_str());
   #endif
   
   return generatingString;
}
コード例 #5
0
//------------------------------------------------------------------------------
const std::string& BeginScript::GetGeneratingString(Gmat::WriteMode mode,
                                                    const std::string &prefix,
                                                    const std::string &useName)
{
   //Note: This method is called only once from the ScriptInterpreter::WriteScript(),
   // so all nested ScriptEvent generating strings should be handled here.
   
   std::stringstream gen;
   std::string indent;
   std::string commentLine = GetCommentLine();
   std::string inlineComment = GetInlineComment();
   std::string beginPrefix = prefix;

   if (mode != Gmat::GUI_EDITOR)
   {
      if (mode == Gmat::NO_COMMENTS)
      {
         gen << prefix << "BeginScript" << "\n";
      }
      else
      {
         IndentComment(gen, commentLine, prefix);
         
         // Insert command name (Fix for GMT-2612, LOJ: 2012.10.22)
         //gen << prefix << "BeginScript";
         std::string tempString = prefix + "BeginScript";
         
         InsertCommandName(tempString);
         gen << tempString;
         
         if (inlineComment != "")
            gen << inlineComment << "\n";
         else
            gen << "\n";
      }
   }
   
   #if DBGLVL_GEN_STRING
   MessageInterface::ShowMessage
      ("BeginScript::GetGeneratingString() this=(%p)%s, mode=%d, prefix='%s', "
       "useName='%s'\n", this, this->GetTypeName().c_str(), mode, prefix.c_str(),
       useName.c_str());
   #endif
   
   if (mode == Gmat::GUI_EDITOR)
      indent = "";
   else
      indent = "   ";
   
   GmatCommand *current = next;
   while (current != NULL)
   {      
      #if DBGLVL_GEN_STRING > 1
      MessageInterface::ShowMessage
         ("BeginScript::GetGeneratingString() current=(%p)%s\n", current,
          current->GetTypeName().c_str());
      #endif
      
      if (current->GetTypeName() != "EndScript")
      {
         // Indent whole block within Begin/EndScript
         IndentChildString(gen, current, indent, mode, prefix, useName, false);
         
         // Get command after EndScript
         current = GmatCommandUtil::GetNextCommand(current);
         
         if (current == NULL)
            IndentChildString(gen, current, indent, mode, beginPrefix, useName, true);
      }
      else
      {
         if (mode != Gmat::GUI_EDITOR)
         {
            // Indent whole block within Begin/EndScript
            IndentChildString(gen, current, indent, mode, beginPrefix, useName, true);
         }
         else
         {
            std::string comment = current->GetCommentLine();
            #if DBGLVL_GEN_STRING
            MessageInterface::ShowMessage("   EndScript comment = '%s'\n", comment.c_str());
            #endif
            // Only indent inline comment of EndScript (LOJ: 2013.03.27)
            gen << indent << comment;
         }
         current = NULL;
      }
   }
   
   generatingString = gen.str();
   
   #if DBGLVL_GEN_STRING
   MessageInterface::ShowMessage
      ("BeginScript::GetGeneratingString() returnning generatingString\n");
   MessageInterface::ShowMessage("<<<\n%s>>>\n\n", generatingString.c_str());
   #endif
   
   return generatingString;
}