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

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

Bases: PySide2.QtWidgets.QGraphicsView

Super class for Design and Graph QGraphicsViews.

parent

Parent widget

Type:QWidget
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
enterEvent(self, event)[source]

Overridden method. Do not show the stupid open hand mouse cursor.

Parameters:event (QEvent) – event
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.

wheelEvent(self, event)[source]

Zoom 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 (QGraphicsScene) – a new scene
_update_zoom_limits(self, rect)[source]

Updates the minimum zoom limit and the zoom level with which the entire scene fits the view.

Parameters:rect (QRectF) – the scene’s rect
scaling_time(self, pos)[source]

Called when animation value for smooth zoom changes. Perform zoom.

anim_finished(self)[source]

Called when animation for smooth zoom finishes. Clean up.

zoom_in(self)[source]

Perform a zoom in with a fixed scaling.

zoom_out(self)[source]

Perform a zoom out with a fixed scaling.

reset_zoom(self)[source]

Reset zoom to the default factor.

gentle_zoom(self, factor, zoom_focus)[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
class widgets.custom_qgraphicsviews.DesignQGraphicsView(parent)[source]

Bases: widgets.custom_qgraphicsviews.CustomQGraphicsView

QGraphicsView for the Design View.

parent

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

Type:QWidget
mousePressEvent(self, event)[source]

Manage drawing of links. Handle the case where a link is being drawn and the user doesn’t hit a connector button.

Parameters:event (QGraphicsSceneMouseEvent) – Mouse event
mouseMoveEvent(self, event)[source]

Update line end position.

Parameters:event (QGraphicsSceneMouseEvent) – Mouse event
set_ui(self, toolbox)[source]

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

init_scene(self, empty=False)[source]

Resize scene and add a link drawer on scene. The scene must be cleared before calling this.

Parameters:empty (boolean) – True when creating a new project
set_project_item_model(self, model)[source]

Set project item model.

set_connection_model(self, model)[source]

Set connection model and connect signals.

Draws link between source and sink items on scene and appends connection model. Refreshes View references if needed.

Parameters:
  • src_connector (ConnectorButton) – Source connector button
  • dst_connector (ConnectorButton) – Destination connector button
  • index (QModelIndex) – Index in connection model

Removes link between source and sink items on scene and updates connection model. Refreshes View references if needed.

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

Iterates connection model and draws links for each valid entry. Should be called only when a project is loaded from a save file.

connection_rows_removed(self, index, first, last)[source]

Update view when connection model changes.

connection_columns_removed(self, index, first, last)[source]

Update view when connection model changes.

Draw links when slot button is clicked.

Parameters:connector (ConnectorButton) – Connector button that triggered the drawing
emit_connection_information_message(self)[source]

Inform user about what connections are implemented and how they work.

class widgets.custom_qgraphicsviews.GraphQGraphicsView(parent)[source]

Bases: widgets.custom_qgraphicsviews.CustomQGraphicsView

QGraphicsView for the Graph View.

item_dropped[source]
dragLeaveEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not DragListView.

dragEnterEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not DragListView.

dragMoveEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not DragListView.

dropEvent(self, event)[source]

Only accept drops when the source is an instance of DragListView. Capture text from event’s mimedata and emit signal.

contextMenuEvent(self, e)[source]

Show context menu.

Parameters:e (QContextMenuEvent) – Context menu event