spinetoolbox.widgets.custom_qgraphicsviews

Classes for custom QGraphicsViews for the Design and Graph views.

authors
  1. Savolainen (VTT), M. Marin (KTH)

date

6.2.2018

Module Contents

Classes

CustomQGraphicsView

Super class for Design and Entity QGraphicsViews.

DesignQGraphicsView

QGraphicsView for the Design View.

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

Bases: PySide2.QtWidgets.QGraphicsView

Super class for Design and Entity QGraphicsViews.

parent

Parent widget

Type

QWidget

Init CustomQGraphicsView.

property zoom_factor(self)[source]
reset_zoom(self)[source]

Resets zoom to the default factor.

keyPressEvent(self, event)[source]

Overridden method. Enable zooming with plus and minus keys (comma resets zoom). Send event downstream to QGraphicsItems if pressed key is not handled here.

Parameters

event (QKeyEvent) – Pressed key

mousePressEvent(self, event)[source]

Set rubber band selection mode if Control pressed. Enable resetting the zoom factor from the middle mouse button.

mouseReleaseEvent(self, event)[source]

Reestablish scroll hand drag mode.

_use_smooth_zoom(self)[source]
wheelEvent(self, event)[source]

Zooms in/out.

Parameters

event (QWheelEvent) – Mouse wheel event

resizeEvent(self, event)[source]

Updates zoom if needed when the view is resized.

Parameters

event (QResizeEvent) – a resize event

setScene(self, scene)[source]

Sets a new scene to this view.

Parameters

scene (ShrinkingScene) – a new scene

_handle_item_move_finished(self, item)[source]
_update_zoom_limits(self)[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(self)[source]
_handle_zoom_time_line_advanced(self, pos)[source]

Performs zoom whenever the smooth zoom time line advances.

_handle_transformation_time_line_finished(self)[source]

Cleans up after the smooth transformation time line finishes.

_handle_resize_time_line_finished(self)[source]

Cleans up after resizing time line finishes.

zoom_in(self)[source]

Perform a zoom in with a fixed scaling.

zoom_out(self)[source]

Perform a zoom out with a fixed scaling.

gentle_zoom(self, 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(self, factor)[source]
_get_viewport_scene_rect(self)[source]

Returns the viewport rect mapped to the scene.

Returns

QRectF

_ensure_item_visible(self, item)[source]

Resets zoom if item is not visible.

_set_preferred_scene_rect(self)[source]

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

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

Bases: CustomQGraphicsView

QGraphicsView for the Design View.

Parameters

parent (QWidget) – Graph View Form’s (QMainWindow) central widget (self.centralwidget)

set_ui(self, toolbox)[source]

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

reset_zoom(self)[source]

Resets zoom to the default factor.

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

Adds project item’s icon to the scene.

Parameters

item_name (str) – project item’s name

remove_icon(self, item_name)[source]

Removes project item’s icon from scene.

Parameters

item_name (str) – name of the icon to remove

Returns all Links in the scene.

Returns

scene’s links

Return type

list of Link

Pushes an AddLinkCommand to the toolbox undo stack.

Parameters

Constructs a Link between given connectors.

Parameters
  • src_connector (ConnectorButton) – Source connector button

  • dst_connector (ConnectorButton) – Destination connector button

  • connection (Connection, optional) – Underlying connection

Returns

new link

Return type

Link

Adds given connection to the Design view.

Parameters

connection (Connection) – the connection to add

Replaces a link on the Design view.

Parameters
  • original_connection (Connection) – connection that was replaced

  • new_connection (Connection) – replacing connection

Pushes a RemoveConnectionsCommand to the Toolbox undo stack.

Parameters

links (list of Link) – links to remove

Removes a link from the scene.

Parameters

connection (Connection) – link’s connection

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

contextMenuEvent(self, event)[source]

Shows context menu for the blank view

Parameters

event (QContextMenuEvent) – Event