Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  1. Decide which GMAT Command base class will be the parent of your new class. Most Commands derive from the GmatCommand class located in src/base/command.
  2. Create the new class by making NewCommand.cpp and NewCommand.hpp files for the class, where NewCommand is the name of the command (usually identical to the command name used in GMAT scripts).
  3. Add additional data or methods to the new class as needed.
  4. Implement the pure virtual methods of the parent class, and other public methods whose base/default implementation are not correct or sufficient for your new class. The only pure virtual method required for Command Commands is the Execute() and method, which must be implemented. For exampleIn addition, you may need to add some validation to the Initialize() method, so you would include new code in your override the Initialize() method and include new code there, and (almost certainly) call the parent Initialize() method as well.
  5. If your class is a leaf class, implement the Clone() and Copy() methods. Implement the RenameRefobjects() method to handle renaming Resource names from the GUI. If your command does not reference any objects, add the macro "DEFAULT_TO_NO_REFOBJECTS" in the public part of your header file. This macro is replaced by a RenameRefobjects() returning implementation, set to return true, during compilation time.
  6. If your class has cloned objects, implement the cloning of objects in the copy constructor and the assignment operator appropriatelyas needed. The assignment operator should delete owned cloned objects first before creating new owned cloned objects. If your class does not own any cloned objects, add the macro "DEFAULT_TO_NO_CLONES" in the public part of your header file. This macro is replaced by an implementation of HasLocalClones() returning that returns false.
  7. Update /src/base/factory/CommandFactory.cpp to add your new Command type. Add a new Command type to the data member "creatables" list in the CommandFactory constructor so that the new Command type is recognized from in the Interpreter. Update the CreateCommand() method to return an instance of a your new Command type when a new Command instance with the new type name is requested.
  8. Add your new class(es) to the /src/base/MakeBase.eclipse file to make sure it is compiled using GCC.
  9. Add new Command class to Microsoft Visual C++ 2010 Express libGmatBase project if you prefer to build the new command into GMAT builds created using MS Visual Studio.

GUI Code modifications:

  1. If you want to show a customized icon for a the new Command from the Mission tree, insert :
    1.  insert your new Command type
    1. in the MissionIconType enumeration in /src/gui/app/
    1. GmatTreeItemData.hpp. The new Command type must to be inserted between the MISSION_ICON_OPENFOLDER and MISSION_ICON_DEFAULT entries.
    2. Add a statement to load the new Command icon file at the same ordered position
    1. as the location that the new Type was inserted to MissionIconType
    in MissionTree.cpp in
    1. by adding the line to the MissionTree::AddIcons() method in /src/gui/mission/MissionTree
    ::AddIcons() since bitmaps index should match with the position in MissionIconType
    1. .cpp.  Pay careful attention to the ordering here, because the bitmap indices must match the ordering in the MissionIconType enumeration.
  2. If you want to specially handle provide a specialized handler for the new Command type , -- for example, by creating different a new popup menu , -- add your new type in to the ItemType enumeration in /src/gui/app/GuiTreeItemGmatTreeItemData.hpp and implement appropriately the corresponding code in MissionTree.cpp.
  3. Check CreateNewCommand() in /src/gui/app/GmatMainFrame.cpp to see if you need to add or modify the list (i.e. look at the list in the switch statement) , to match the your modifications to the GmatTreeItemData code.
  4. Decide whether you can use the GmatCommandPanel which is (a generic panel for a Command, GMAT Commands) or if you will need a custom GUI panel for your new Command. See "How to Create GMAT panels" for further instructions on creating a new GUI panel.
  5. Add your new class(es) to the /src/gui/MakeGui.eclipse file to make sure it is compiled using GCC.
  6. Add your new Command class(es) to Microsoft Visual C++ 2010 Express GMAT_wxGui project if you prefer to build the new GUI elements into GMAT builds created using MS Visual Studio.

System Test Readiness Criteria

Once you have completed your code modifications and additions, there are several criteria that must be met before the GMAT team will allow the code to be included into the GMAT base code. Note that meeting these criteria does not guarantee that your commands will be added to GMAT.

  1. Update your code base with the latest configured GMAT code, merging the configured code into your code base when necessary.
  2. Build with the GCC compiler to make sure that it the code builds on other platforms. If you prefer, non-Windows platforms, and build with Visual Studio C++ Compilerto ensure that the code builds for Windows.

Then, for those with code modification and system test privileges:

  1. Run SmokeTests and the applicable Command and/or command system test folder(s) successfully
  2. Inform testers of changes to GUI components, when applicable

Or, for those For contributors without code modification and system test privileges: