Outdated version of the documentation. Find the latest one here.

` `

QGIS Commander

Processing include un instrument practic care vă permite să rulați algoritmi, fără a fi nevoie să utilizați bara de instrumente, doar prin tastarea numelui algoritmului pe care doriți să îl rulați.

Instrumentul este cunoscut ca și QGIS commander, și constă doar într-o simplă casetă de text cu autocompletare, unde veți tasta comanda pe care doriți să o rulați.

../../../_images/commander1.png

QGIS Commander

The Commander is started from the Processing menu or, more practically, by pressing Shift + Ctrl + M (you can change that default keyboard shortcut in the QGIS configuration if you prefer a different one). To close it, just press ESC. Apart from executing Processing algorithms, the Commander gives you access to most of the functionality in QGIS, which means that it gives you a practical and efficient way of running QGIS tasks and allows you to control QGIS with reduced usage of buttons and menus.

Moreover, the Commander is configurable, so you can add your custom commands and have them just a few keystrokes away, making it a powerful tool to help you become more productive in your daily work with QGIS.

Comenzi disponibile

Comenzile disponibile în Commander se încadrează în următoarele categorii:

  • Algoritmi de procesare. Aceștia sunt afișați ca Algoritmi de procesare: <name of the algorithm>.

  • Menu items. These are shown as Menu item: <menu entry text>. All menus items available from the QGIS interface are available, even if they are included in a submenu.
  • Funcții Python. Puteți crea funcții scurte Python care vor fi incluse în lista de comenzi disponibile. Acestea sunt afișate ca Funcția: <function name>.

Pentru a rula oricare dintre categorii, este suficient să începeți să tastați, apoi să selectați elementul corespunzător din lista de comenzi disponibile, care apare după filtrarea întregii liste de comenzi, generată de textul introdus.

In the case of calling a Python function, you can select the entry in the list, which is prefixed by Function: (for instance, Function: removeall), or just directly type the function name (removeall in the previous example). There is no need to add brackets after the function name.

Crearea funcțiilor personalizate

Custom functions are added by entering the corresponding Python code in the commands.py file that is found in the .qgis2/processing/commander directory in your user folder. It is just a simple Python file where you can add the functions that you need.

The file is created with a few example functions the first time you open the Commander. If you haven’t launched the Commander yet, you can create the file yourself. To edit the commands file, use your favourite text editor. You can also use a built-in editor by calling the edit command from the Commander. It will open the editor with the commands file, and you can edit it directly and then save your changes.

De exemplu, puteți adăuga următoarea funcție, care elimină toate straturile:

from qgis.gui import *

def removeall():
    mapreg = QgsMapLayerRegistry.instance()
    mapreg.removeAllMapLayers()

După ce ați adăugat funcția, ea va fi disponibilă în Commander, putând-o invoca prin tastarea removeall. Nu este nevoie să faceți nimic în afară de scrierea funcției în sine.

Functions can receive parameters. Add *args to your function definition to receive arguments. When calling the function from the Commander, parameters have to be passed separated by spaces.

Aici este un exemplu al unei funcții care încarcă un strat, și care primește ca parametru numele de fișier a stratului care se va încărca.

import processing

def load(*args):
  processing.load(args[0])

If you want to load the layer in ;file:/home/myuser/points.shp, type in the Commander text box:

load /home/myuser/points.shp