View¶
View is the central class in Gaphas. It shows your diagram and allows you to interact with it.
-
class
gaphas.view.
GtkView
(*args: Any, **kwargs: Any)[source]¶ GTK+ widget for rendering a gaphas.view.model.Model to a screen. The view uses Tools to handle events and Painters to draw. Both are configurable.
The widget already contains adjustment objects (hadjustment, vadjustment) to be used for scrollbars.
This view registers itself on the model, so it will receive update events.
-
property
matrix
¶ Model root to view transformation matrix.
-
get_matrix_i2v
(item: gaphas.item.Item) → gaphas.matrix.Matrix[source]¶ Get Item to View matrix for
item
.
-
get_matrix_v2i
(item: gaphas.item.Item) → gaphas.matrix.Matrix[source]¶ Get View to Item matrix for
item
.
-
property
model
¶ The model.
-
property
painter
¶ Painter for drawing the view.
-
property
bounding_box_painter
¶ Special painter for calculating item bounding boxes.
-
property
selection
¶ Selected, focused and hovered items.
-
property
bounding_box
¶ The bounding box of the complete view, relative to the view port.
-
property
hadjustment
¶ Gtk adjustment object for use with a scrollbar.
-
property
vadjustment
¶ Gtk adjustment object for use with a scrollbar.
-
add_controller
(*controllers: gi.repository.Gtk.EventController) → None[source]¶ Add a controller.
A convenience method, so you have a place to store the event controllers. Events controllers are linked to a widget (in GTK3) on creation time, so calling this method is not necessary.
-
remove_controller
(controller: gi.repository.Gtk.EventController) → bool[source]¶ Remove a controller.
The event controller’s propagation phase is set to Gtk.PropagationPhase.NONE to ensure it’s not invoked anymore.
- NB. The controller is only really removed from the widget when it’s destroyed!
This is a Gtk3 limitation.
-
get_items_in_rectangle
(rect: Tuple[float, float, float, float], contain: bool = False) → Iterable[gaphas.item.Item][source]¶ Return the items in the rectangle ‘rect’.
Items are automatically sorted in model’s processing order.
-
get_item_bounding_box
(item: gaphas.item.Item) → gaphas.geometry.Rectangle[source]¶ Get the bounding box for the item, in view coordinates.
-
request_update
(items: Iterable[gaphas.item.Item], removed_items: Iterable[gaphas.item.Item] = ()) → None[source]¶ Request update for items.
-
all_dirty_items
() → Set[gaphas.item.Item][source]¶ Return all dirty items, clearing the marked items.
-
update_bounding_box
(items: Collection[gaphas.item.Item]) → None[source]¶ Update the bounding boxes of the model items for this view, in model coordinates.
-
property