A GRASS modulok a QGIS GRASS eszközök közül futtathatók. Ha a QGIS-t a a GRASS burokból indította vagy ha egy GRASS térképhalmazt megnyitott a a QGIS-ből.
A menüt egyszerűen lehet módosítani és új modulokat hozzáadni, mivel a menüket és a modulokat XML konfigurációs fájlokban definiálhatjuk. Lentebb leírjuk hogyan írjunk új modulokat és módosítsuk a menü fát.
A különböző modulok paraméterei (melyeket a _*Beállítások_*fülön találunk) automatikusan generálódnak az előre definiált QGM (QGIS GRASS module) fájl és magának a GRASS modul vagy a GRASS script –GMO (GRASS module options) beállításainak függvényében. Mivel minden paraméter a QGM fájlban kapcsolódik a megfelelő (vagy több) GMO-hoz, ezért ajánlatos (illetve inkább szükséges) a GMO-k böngészése is. A GMO nem más, mint a GRASS modul kimenete, az _*–interface-description_* kapcsolóval, XML formátumban. Pl.:
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.
Itt van egy példa konfiguráció fájl:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
<qgisgrassmodule label="Generate aspect map from DEM" module="r.slope.aspect">
<option key="elevation" />
<option key="aspect" />
</qgisgrassmodule>
címke — a menü fában használt leírás
modul — végrehajtható GRASS modul vagy szkript.
key — name of module option in GMO.
answer — default value (overwrites GMO default value); value „on” will switch on a flag.
hidden — the option will not appear in the dialog, but module will be run with this option (hidden=”yes”).
label — option label
advanced — „yes” or „no”, default is „no”. If set to „yes”, the option/flag is add to initially hidden advanced options panel and „Show advanced options >>” button is shown under simple (basic,standard) options
version_min — minimum GRASS version for which this option/flag is valid
version_max — maximum GRASS version for which this option/flag is valid
typeoption — this option can be used with vector layer to define the name of vector input type option, when module is run, the type of selected vector layer will be used for that option. For example (v.overlay.or.qgm):
<option key="ainput" typeoption="atype" layeroption="alayer" typemask="area,line" />
It means that if a layer is selected from combobox of this option the _*atype*_ option is automaticaly set to the layer’s type, and thus _*atype*_ does not have to be added at all.
layeroption — equivalent of typeoption for layer.
typmask — for vector input option defines allowed types. Only the layers of one of defined type are displayed in input. See v.overlay.or.qgm for example.
layer — the key attribute of the option which defines the vector this field should depend on
type — defines types of attribute fields which should be added to the field combobox, for example
<field key="column" layer="map" type="integer,double" label="Attribute field" />
It means that only the attribute fields of type in integer and double precision will appear in combobox. See v.what.vect for example (2 different vectors).
The idea QGIS-GRASS modules implementation is to use maximum information from GMO and only simplify the interface. Here are described some rules how information from GMO are used and in which order if not all of them are defined in GMO.
label — if label attribute is defined in QGM it is used as option label, if it is not defined GMO option label tag is used and if it is not defined GMO option description tag is used
tooltip — (appeares on mouseover the option) if label is defined (either in QGM or GMO) and description is defined in GMO (thus label and description differ) the GMO description tag is used for tooltip
multiple values label — if an option is type multiple with defined list of possible values (like upload option of v.distance) and description tag is defined for value tag in GMO then it is used as checkbox label
Each module must be represented also by a picture/icon which symbolizes the modules functionality. The pictures are also stored in plugins/grass/modules as SVG (.svg) or PNG (.png) files.
Currently there are supported 3 schemas for the picture:
1 picture
2 pictures — QGIS will create icon: 1 -> 2
3 pictures — QGIS will create icon: 1 + 2 -> 3
The name of the picture starts with QGIS-GRASS module name to which is appended picture number, for example: v.overlay.and.1.svg, v.overlay.and.2.svg, v.overlay.and.3.svg. It is possible to combine SVG and PNG pictures.
SVG and PNG pictures can be generated from QGIS using Map Composer. The size of PNG images should be larger than the expected icon size, because it is expected to be later used in automatically generated documentation, where pictures will be used in larger size.
Because it can take long time until a new script is added to stable GRASS release and because some scripts can be useful only for QGIS GUI interface it is possible to add a «GRASS» script to QGIS. The scripts should follow general requirements for GRASS scripts and they are located in qgis/src/plugins/grass/scripts.
A GRASS eszközök elsősorban a kezdő felhasználóknak készültek és nem a nagyon tapasztaltaknak. Az alapszabályok a következők:
Each module should have 3 or less options; if it seems to be necessary to add more options, it should be discussed beforehand
Module definition should be robust so that it doesn’t allow a user to run a module with wrong option. If there is not yet support for certain type of option the module should not be added to menu
Kerülje a 3. személyt az igéknél, pl. „Export raster” az „Exports raster” helyett
Kerülje a szükségtelen „map”, „layer” és „file” szavakat, pl. „Export raster” az „Export raster map layer” helyett
Kerülje a szükségtelen „GRASS”-t, pl. „Export raster” az „Export GRASS raster” helyett
Kerülje az „a” vagy „an”-t, pl. „Export raster” az „Exports a raster” helyett
Kerülje a kitöltő szavakat, pl. „Export raster” az „Allows the export of a raster” helyett
Kerülje a „Convert” szót: használja az „Export” vagy „Import” szavakat helyette. A konvertálást a a GRASS-on belüli konverziókra kellene használni (pl. raszterből vektorba)
A mozaik szavakat írja nagybetűvel, pl. ASCII az ascii helyett
Kétségek esetén ellenőrizze a már létező, hasonló modult a következetesség fentartásáért
Technically, any option can be used. Some kinds of options however are not yet well supported, for example those which depend on other option. Here is a list (probably incomplete) of options which are not yet well supported and so should not be used at present:
OGR input dsn/réteg (v.in.ogr)
A modulok többségét hozzáadtuk. Ha továbbiakra van szüksége írjon a QGIS fejlesztői levelező listára és sorolja fel az ön szerint legfontosabb hozzáadandó modulokat.
You should post the name of a new QGIS-GRASS module, the name of the GRASS module and the options which you want to use. For example:
r.to.vect.area: r.to.vect input output feature=area
See also here for discussion on GRASS-QGIS relevant module list.
List hereafter the modules who should be removed, with a rationale for this suggestion (e.g.: some modules related to projections are difficult to understand, and of no general use). Please note: some modules have not been thoroughly tested. Please test them, and if you find any issue report it to the redmine (better still: fix it yourself and send the patch).