displaydrivers.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!-- meta page description: Display drivers -->
  2. <!-- meta page index: display -->
  3. The current command line rendering mechanism is direct rendering into
  4. a file. The driver is selected by setting
  5. the <tt>GRASS_RENDER_IMMEDIATE</tt> variable or by
  6. running <em><a href="d.mon.html">d.mon</a></em> module.
  7. <p>
  8. <b>List of available display drivers:</b>
  9. <ul>
  10. <li><a href="cairodriver.html">Cairo driver</a>
  11. <li><a href="pngdriver.html">PNG driver</a>
  12. <li><a href="psdriver.html">PS driver (Postscript)</a>
  13. <li><a href="htmldriver.html">HTMLMAP driver</a>
  14. </ul>
  15. <h2>NOTES</h2>
  16. <h3>GRASS_RENDER_COMMAND</h3>
  17. If environmental variable GRASS_RENDER_COMMAND is defined,
  18. rendering is redirected by display library to the given external command
  19. defined by this variable. Currently only Python scrips are supported.
  20. <p>
  21. Lets start with simple example of Python script called <i>render.py</i>:
  22. <div class="code"><pre>
  23. #!/usr/bin/evn python
  24. import os
  25. import sys
  26. import grass.script as grass
  27. from grass.script import task as gtask
  28. os.environ['GRASS_RENDER_IMMEDIATE'] = 'default'
  29. os.environ['GRASS_RENDER_FILE'] = 'output.png'
  30. cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1])
  31. grass.run_command('d.text', text="Test of GRASS_RENDER_COMMAND redirection")
  32. os.environ['GRASS_RENDER_FILE_READ'] = 'TRUE'
  33. grass.run_command(cmd, **dcmd)
  34. </pre></div>
  35. After defining GRASS_RENDER_COMMAND variable (example for Bash):
  36. <div class="code"><pre>
  37. export GRASS_RENDER_COMMAND=render.py
  38. </pre></div>
  39. Display GRASS modules like <em><a href="d.rast.html">d.rast</a></em>
  40. or <em><a href="d.vect.html">d.vect</a></em> will be executed
  41. by <i>render.py</i> program.
  42. For example the command
  43. <div class="code"><pre>
  44. d.vect roadsmajor
  45. </pre></div>
  46. produces output PNG file <i>output.png</i> which will contain rendered
  47. features from vector map <i>roadsmajor</i> and sample text <i>&quot;Test of
  48. GRASS_RENDER_COMMAND redirection&quot;</i>.
  49. <h2>SEE ALSO</h2>
  50. <em>
  51. <a href="d.mon.html">d.mon</a>,
  52. <a href="variables.html#list-of-selected-grass-environment-variables-for-rendering">variables</a>
  53. </em>