.. _addinggrasstools: Adding GRASS Tools ================== GRASS modules can be run from QGIS *GRASS Tools* if QGIS was started from a GRASS shell or if a GRASS mapset was opened from QGIS. The modules work with GRASS data only. It is easy to modify the menu and add new modules because both the menu and the modules are defined in XML configuration files. Below is described how to write new modules and modify menu tree. Module configuration -------------------- Background .......... The options of each module shown in module's_*Options_*tab are created according to combination of definition in QGM (QGIS GRASS module) file and options definition in GRASS module or GRASS script --- GMO (GRASS module options). Because each option in QGM is linked to one (or more) GMO, it is often useful if not necessary to see GMO. GMO are output by GRASS module if it is run with _*--interface-description_* option, the output is in XML format, for example: :: r.to.vect --interface-description Some GRASS modules have too many options which can be confusing for beginners. In QGM it is possible to define only some of them and possibly set some default values and/or hide some options with certain value. That means that more QGIS-GRASS modules can be defined for each GRASS module. For example the module r.to.vect was divided into three QGIS-GRASS modules with predefined "feature" option. The QGM definition is written in XML format file with extension .qgm, one for each QGIS-GRASS module. Configuration files are stored in _*qgis/src/plugins/grass/modules*_ directory and installed in _*share/qgis/grass/modules*_ directory. The name of the file should start with GRASS module name + a word describing the specific task. For example, the module which extracts vector lines from raster is called r.to.vect.line.qgm. Here is an example of a configuration file: :: qgisgrassmodule tag attributes .............................. * *label* --- description used in menu tree * *module* --- name of GRASS module executable or script. Option tags ........... Each qgisgrassmodule tag can contain one or more option tags: * *option* --- corresponds to GMO parameter tag, example: ::