Update diagrams are tools docs

This commit is contained in:
Arjan Molenaar 2020-12-07 21:46:40 +01:00
parent f538e45500
commit f013f61617
11 changed files with 1357 additions and 58 deletions

View File

@ -1,4 +1,6 @@
Decorators
==========
...
.. autoclass:: gaphas.decorators.g_async
.. autofunction:: gaphas.decorators.nonrecursive

View File

@ -3,10 +3,26 @@ Class diagram
This class diagram describes the basic layout of Gaphas.
.. image:: gaphas-canvas.png
:width: 700
The central class is ``GtkView``. It takes a model.
A default implementation is provided by `gaphas.Canvas`.
A view is rendered by ``Painter``s. Interaction is handled
by ``Tool``s.
A view is rendered by Painters. Interaction is handled
by Tools.
.. image:: images/view.png
:align: center
Painting is done by painters. Each painter will paint a layer of the canvas.
.. image:: images/painter.png
:align: center
Besides the view, there is constraint based connection management.
Constraints can be used within an item, and to connect different items.
.. image:: images/connections.png
:align: center
A default model and item implementations, a line and an element.
.. image:: images/canvas.png
:align: center

File diff suppressed because it is too large Load Diff

View File

@ -2,3 +2,5 @@ Guides
######
Guides are a tool to align elements with one another.
TODO: screen shot, usage example

BIN
docs/images/canvas.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
docs/images/connections.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/images/painter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/images/view.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -4,3 +4,5 @@ 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.
To use this behavior, import the ``gaphas.segment`` module and add ``LineSegmentPainter`` to the list of painters for the view.
TODO: screen shot, usage example

View File

@ -79,12 +79,5 @@ The advantage is that more complex behaviour can be composed. Since the
decision on what should happen is done in the tool, the aspect which is then
used to work on the item ensures a certain behaviour is performed.
The diagram above shows the relation between tools and their aspects. Note that
tools that delegate their behaviour to aspects have more than one aspects. The
reason is that there are different concerns involved in defining what the tools
should do. Typically ``ItemTool`` will be selecting the actual item and takes
care of moving it around as well. ``HandleTool`` does similar things for
handles.
.. [#] as opposed to versions < 0.5, where tools could be shared among multiple views.
.. [#] not the AOP term. The term aspect is coming from a paper by Dirk Riehe: The Tools and Materials metaphore https://wiki.c2.com/?ToolsAndMaterialsMetaphor..>.

View File

@ -165,37 +165,3 @@ def nonrecursive(func):
m.release()
return wrapper
class recursive:
"""This decorator limits the recursion for a specific function.
>>> class A(object):
... def __init__(self): self.r = 0
... @recursive(10)
... def a(self, x=0):
... self.r += 1
... self.a()
>>> a = A()
>>> a.a()
>>> a.r
10
"""
def __init__(self, limit=10000):
self.limit = limit
def __call__(self, func):
def wrapper(*args, **kwargs):
try:
func._recursion_level += 1
except AttributeError:
# _recursion_level not present
func._recursion_level = 0
if func._recursion_level < self.limit:
try:
return func(*args, **kwargs)
finally:
func._recursion_level -= 1
return wrapper