# eric7.EricGraphics.EricGraphicsView

Module implementing a canvas view class.

### Global Attributes

None

### Classes

EricGraphicsView | Class implementing a graphics view.

### Functions

None

## EricGraphicsView

Class implementing a graphics view.

### Signals

zoomValueChanged(int)
  emitted to signal a change of the zoom value

### Derived from

QGraphicsView

### Class Attributes

ZoomLevelDefault
ZoomLevels

### Class Methods

None

### Methods

EricGraphicsView | Constructor
__getDiagram | Private method to retrieve the diagram from the scene fitting it in the minimum rectangle.
__levelForZoom | Private method determining the zoom level index given a zoom factor.
_getDiagramRect | Protected method to calculate the minimum rectangle fitting the diagram.
_getDiagramSize | Protected method to calculate the minimum size fitting the diagram.
autoAdjustSceneSize | Public method to adjust the scene size to the diagram size.
filteredItems | Public method to filter a list of items.
getBackgroundColor | Public method to get the configured background color.
getDrawingColors | Public method to get the configured drawing colors.
getForegroundColor | Public method to get the configured foreground color.
printDiagram | Public method to print the diagram.
resizeScene | Public method to resize the scene.
saveImage | Public method to save the scene to a file.
setSceneSize | Public method to set the scene size.
setZoom | Public method to set the zoom value in percent.
zoom | Public method to get the current zoom factor in percent.
zoomIn | Public method to zoom in.
zoomOut | Public method to zoom out.
zoomReset | Public method to handle the reset the zoom value.

### Static Methods

None

#### EricGraphicsView (Constructor)

EricGraphicsView(scene, parent=None)

Constructor

scene
  reference to the scene object (QGraphicsScene)
parent
  parent widget (QWidget)

#### EricGraphicsView.__getDiagram

__getDiagram(rect, imageFormat="PNG", filename=None)

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

rect (QRectF)
  minimum rectangle fitting the diagram
imageFormat (str)
  format for the image file
filename
  name of the file for non pixmaps str

Return:
  paint device containing the diagram

Return Type:
  QPixmap or QSvgGenerator

#### EricGraphicsView.__levelForZoom

__levelForZoom(zoom)

Private method determining the zoom level index given a zoom factor.

zoom
  zoom factor (integer)

Return:
  index of zoom factor (integer)

#### EricGraphicsView._getDiagramRect

_getDiagramRect(border=0)

Protected method to calculate the minimum rectangle fitting the diagram.

border
  border width to include in the calculation (integer)

Return:
  the minimum rectangle (QRectF)

#### EricGraphicsView._getDiagramSize

_getDiagramSize(border=0)

Protected method to calculate the minimum size fitting the diagram.

border
  border width to include in the calculation (integer)

Return:
  the minimum size (QSizeF)

#### EricGraphicsView.autoAdjustSceneSize

autoAdjustSceneSize(limit=False)

Public method to adjust the scene size to the diagram size.

limit
  flag indicating to limit the scene to the initial size (boolean)

#### EricGraphicsView.filteredItems

filteredItems(items)

Public method to filter a list of items.

items
  list of items as returned by the scene object (QGraphicsItem)

Return:
  list of interesting collision items (QGraphicsItem)

#### EricGraphicsView.getBackgroundColor

getBackgroundColor()

Public method to get the configured background color.

Return:
  background color

Return Type:
  QColor

#### EricGraphicsView.getDrawingColors

getDrawingColors()

Public method to get the configured drawing colors.

Return:
  tuple containing the foreground and background colors

Return Type:
  tuple of (QColor, QColor)

#### EricGraphicsView.getForegroundColor

getForegroundColor()

Public method to get the configured foreground color.

Return:
  foreground color

Return Type:
  QColor

#### EricGraphicsView.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)

#### EricGraphicsView.resizeScene

resizeScene(amount, isWidth=True)

Public method to resize the scene.

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

#### EricGraphicsView.saveImage

saveImage(filename, imageFormat="PNG")

Public method to save the scene to a file.

filename
  name of the file to write the image to (string)
imageFormat
  format for the image file (string)

Return:
  flag indicating success (boolean)

#### EricGraphicsView.setSceneSize

setSceneSize(width, height)

Public method to set the scene size.

width
  width for the scene (real)
height
  height for the scene (real)

#### EricGraphicsView.setZoom

setZoom(value)

Public method to set the zoom value in percent.

value
  zoom value in percent (integer)

#### EricGraphicsView.zoom

zoom()

Public method to get the current zoom factor in percent.

Return:
  current zoom factor in percent (integer)

#### EricGraphicsView.zoomIn

zoomIn()

Public method to zoom in.

#### EricGraphicsView.zoomOut

zoomOut()

Public method to zoom out.

#### EricGraphicsView.zoomReset

zoomReset()

Public method to handle the reset the zoom value.

Up