spinetoolbox.widgets.custom_qgraphicsviews

Classes for custom QGraphicsViews for the Design and Graph views.

Module Contents

Classes

CustomQGraphicsView

Super class for Design and Entity QGraphicsViews.

DesignQGraphicsView

QGraphicsView for the Design View.

Functions

_fake_left_button_event(mouse_event)

Makes a left-click mouse event that is otherwise close of given event.

class spinetoolbox.widgets.custom_qgraphicsviews.CustomQGraphicsView(parent)[source]

Bases: PySide6.QtWidgets.QGraphicsView

Super class for Design and Entity QGraphicsViews.

Parameters

parent (QWidget) – parent widget

abstract property _qsettings[source]
property zoom_factor[source]
DRAG_MIN_DURATION = 150[source]
reset_zoom()[source]

Resets zoom to the default factor.

keyPressEvent(event)[source]

Enables zooming with plus and minus keys (comma resets zoom).

Parameters

event (QKeyEvent) – key press event

mousePressEvent(event)[source]

Sets rubber band selection mode if Control or right mouse button is pressed. Enables resetting the zoom factor from the middle mouse button.

mouseMoveEvent(event)[source]
mouseReleaseEvent(event)[source]

Reestablish scroll hand drag mode.

_scroll_scene_by(dx, dy)[source]
_use_smooth_zoom()[source]
_drag_duration_passed(mouse_event)[source]

Test is drag duration has passed.

Parameters

mouse_event (QMouseEvent) – current mouse event

wheelEvent(event)[source]

Zooms in/out.

Parameters

event (QWheelEvent) – Mouse wheel event

resizeEvent(event)[source]

Updates zoom if needed when the view is resized.

Parameters

event (QResizeEvent) – a resize event

setScene(scene)[source]

Sets a new scene to this view.

Parameters

scene (DesignGraphicsScene) – a new scene

_handle_item_move_finished(item)[source]
_update_zoom_limits()[source]

Updates the minimum zoom limit and the zoom level with which the view fits all the items in the scene.

abstract _compute_max_zoom()[source]
_handle_zoom_time_line_advanced(pos)[source]

Performs zoom whenever the smooth zoom time line advances.

_handle_transformation_time_line_finished()[source]

Cleans up after the smooth transformation time line finishes.

_handle_resize_time_line_finished()[source]

Cleans up after resizing time line finishes.

zoom_in()[source]

Perform a zoom in with a fixed scaling.

zoom_out()[source]

Perform a zoom out with a fixed scaling.

gentle_zoom(factor, zoom_focus=None)[source]

Perform a zoom by a given factor.

Parameters
  • factor (float) – a scaling factor relative to the current scene scaling

  • zoom_focus (QPoint) – focus of the zoom, e.g. mouse pointer position

_zoom(factor)[source]
_get_viewport_scene_rect()[source]

Returns the viewport rect mapped to the scene.

Returns

QRectF

_ensure_item_visible(item)[source]

Resets zoom if item is not visible.

_set_preferred_scene_rect()[source]

Sets the scene rect to the result of uniting the scene viewport rect and the items bounding rect.

disable_context_menu()[source]

Disables the context menu.

enable_context_menu()[source]

Enables the context menu.

class spinetoolbox.widgets.custom_qgraphicsviews.DesignQGraphicsView(parent)[source]

Bases: CustomQGraphicsView

QGraphicsView for the Design View.

Parameters

parent (QWidget) – parent widget

property _qsettings[source]
set_ui(toolbox)[source]

Set a new scene into the Design View when app is started.

reset_zoom()[source]

Resets zoom to the default factor.

_compute_max_zoom()[source]
add_icon(item_name)[source]

Adds project item’s icon to the scene.

Parameters

item_name (str) – project item’s name

remove_icon(item_name)[source]

Removes project item’s icon from scene.

Parameters

item_name (str) – name of the icon to remove

Pushes an AddLinkCommand to the toolbox undo stack.

Parameters

Adds given connection to the Design view.

Parameters

connection (Connection) – the connection to add

Replaces a link on the Design view.

Parameters

updated_connection (Connection) – connection that was updated

Pushes a RemoveConnectionsCommand to the Toolbox undo stack.

Parameters

links (list of Link) – links to remove

Removes a link from the scene.

Parameters

connection (ConnectionBase) – link’s connection

Remove link, then start drawing another one from the same source connector.

add_jump(src_connector, dst_connector)[source]

Pushes an AddJumpCommand to the Toolbox undo stack.

Parameters
do_add_jump(jump)[source]

Adds given jump to the Design view.

Parameters

jump (Jump) – jump to add

do_update_jump(updated_jump)[source]

Replaces a jump link on the Design view.

Parameters

updated_jump (Jump) – jump that was updated

do_remove_jump(jump)[source]

Removes a jump from the scene.

Parameters

jump (Jump) – link’s jump

contextMenuEvent(event)[source]

Shows context menu for the blank view

Parameters

event (QContextMenuEvent) – Event

spinetoolbox.widgets.custom_qgraphicsviews._fake_left_button_event(mouse_event)[source]

Makes a left-click mouse event that is otherwise close of given event.

Parameters

mouse_event (QMouseEvent) – mouse event

Returns

left-click mouse event

Return type

QMouseEvent