File: segment.rst

package info (click to toggle)
python-gaphas 5.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,560 kB
  • sloc: python: 5,839; makefile: 17; sh: 2
file content (25 lines) | stat: -rw-r--r-- 999 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Line Segments
#############

The line segment functionality is an add-on, that will allow the user to add line segments to a line, and merge them.

.. image:: images/segment.png
   :align: center

To use this behavior, import the ``gaphas.segment`` module and add ``LineSegmentPainter`` to the list of painters for the view.
Splitting and merging of lines is supported by ``item_tool``, however
to actually use it, the ``segment`` module needs to be imported.

    >>> from gaphas.view import GtkView
    >>> from gaphas.painter import PainterChain, ItemPainter, HandlePainter
    >>> from gaphas.tool import item_tool, zoom_tool
    >>> from gaphas.segment import LineSegmentPainter
    >>> view = GtkView()
    >>> view.painter = (
    ...     PainterChain()
    ...     .append(ItemPainter(view.selection))
    ...     .append(HandlePainter(view))
    ...     .append(LineSegmentPainter(view.selection))
    ... )
    >>> view.add_controller(item_tool())
    >>> view.add_controller(zoom_tool())