eric4.E4Canvas.E4CanvasView

Module implementing a canvas view class.

Classes

E4CanvasView Class implementing a canvas view.

Functions

None


E4CanvasView

Class implementing a canvas view.

Derived from

QScrollArea

Methods

E4CanvasView Constructor
__getDiagram Private method to retrieve the diagram from the canvas fitting it in the minimum rectangle.
_getDiagramRect Protected method to calculate the minimum rectangle fitting the diagram.
canvas Public method to get a reference to the canvas object.
clear Public method to clear the canvas view.
collisions Public method to filter a list of collisions.
mouseMoveEvent Overriden method to handle mouse moves.
mousePressEvent Overriden method to handle mouse button presses.
mouseReleaseEvent Overriden method to handle mouse button releases.
printDiagram Public method to print the diagram.
resizeCanvas Public method to resize the drawing canvas.
saveImage Public method to save the canvas to a file.
selectItem Public method to select an item.
selectItems Public method to select the given items.
setCanvas Public method to set the canvas object.
setCanvasSize Public method to set the canvas size.
setZoom Public method to set the zoom factor.
unselectItems Public method to unselect all items.
zoom Public method to get the current zoom factor.
zoomIn Public method to zoom in.
zoomOut Public method to zoom out.
zoomReset Public method to handle the reset zoom context menu entry.

E4CanvasView (Constructor)

E4CanvasView(parent, canvas = None)

Constructor

parent
parent widget (QWidget)
canvas
reference to the canvas to be shown (E4Canvas)

E4CanvasView.__getDiagram

__getDiagram(rect)

Private method to retrieve the diagram from the canvas fitting it in the minimum rectangle.

rect
minimum rectangle fitting the diagram (QRect)
Returns:
diagram pixmap to receive the diagram (QPixmap)

E4CanvasView._getDiagramRect

_getDiagramRect(border = 0)

Protected method to calculate the minimum rectangle fitting the diagram.

border
border width to include in the calculation (integer)
Returns:
the minimum rectangle (QRect)

E4CanvasView.canvas

canvas()

Public method to get a reference to the canvas object.

Returns:
canvas object (E4Canvas)

E4CanvasView.clear

clear()

Public method to clear the canvas view.

E4CanvasView.collisions

collisions(items)

Public method to filter a list of collisions.

items
list of collision items as reported by the canvas object (E4CanvasItem)
Returns:
list of interesting collision items (E4CanvasItem)

E4CanvasView.mouseMoveEvent

mouseMoveEvent(evt)

Overriden method to handle mouse moves.

This method moves the widget according to the mouse movements.

evt
mouse event (QMouseEvent)

E4CanvasView.mousePressEvent

mousePressEvent(evt)

Overriden method to handle mouse button presses.

This method determines the item over which the button press occurred.

evt
mouse event (QMouseEvent)

E4CanvasView.mouseReleaseEvent

mouseReleaseEvent(evt)

Overriden method to handle mouse button releases.

This method simply resets the tracked widget.

evt
mouse event (QMouseEvent)

E4CanvasView.printDiagram

printDiagram(printer, diagramName = "")

Public method to print the diagram.

printer
reference to a ready configured printer object (QPrinter)
diagramName
name of the diagram (string or QString)

E4CanvasView.resizeCanvas

resizeCanvas(amount, isWidth = True)

Public method to resize the drawing canvas.

isWidth
flag indicating width is to be resized (boolean)
amount
size increment (integer)

E4CanvasView.saveImage

saveImage(filename, format = "PNG")

Public method to save the canvas to a file.

filename
name of the file to write the image to (string or QString)
format
for the image file (string or QString)
Returns:
flag indicating success (boolean)

E4CanvasView.selectItem

selectItem(item)

Public method to select an item.

item
item to be selected (E4CanvasItem)

E4CanvasView.selectItems

selectItems(items)

Public method to select the given items.

items
list of items to be selected (list of E4CanvasItem)

E4CanvasView.setCanvas

setCanvas(canvas)

Public method to set the canvas object.

reference
to the canvas object (E4Canvas)

E4CanvasView.setCanvasSize

setCanvasSize(width, height)

Public method to set the canvas size.

width
width for the canvas (integer)
height
height for the canvas (integer)

E4CanvasView.setZoom

setZoom(zoomFactor)

Public method to set the zoom factor.

zoomFactor
new zoom factor (float)

E4CanvasView.unselectItems

unselectItems()

Public method to unselect all items.

E4CanvasView.zoom

zoom()

Public method to get the current zoom factor.

Returns:
current zoom factor (float)

E4CanvasView.zoomIn

zoomIn()

Public method to zoom in.

E4CanvasView.zoomOut

zoomOut()

Public method to zoom out.

E4CanvasView.zoomReset

zoomReset()

Public method to handle the reset zoom context menu entry.

Up