grid_renderer.*¶
Provides
- func:
painter_save: Context manager saving and restoring painter state
- func:
painter_zoom: Context manager scaling and restoring the painter
- func:
painter_rotate: Context manager rotating and restoring the painter
GridCellNavigator
: Find neighbors of a cell
EdgeBorders
: Dataclass for edge properties
CellEdgeRenderer
: Paints cell edges
QColorCache
: QColor cache
CellRenderer
: Paints cells
- class grid_renderer.BorderColorBottomCache(grid, *args, **kwargs)[source]¶
Bases:
BorderWidthBottomCache
BorderColorBottomCache cache
- class grid_renderer.BorderColorRightCache(grid, *args, **kwargs)[source]¶
Bases:
BorderWidthBottomCache
BorderColorBottomCache cache
- class grid_renderer.BorderWidthBottomCache(grid, *args, **kwargs)[source]¶
Bases:
dict
BorderWidthBottom cache
- class grid_renderer.BorderWidthRightCache(grid, *args, **kwargs)[source]¶
Bases:
BorderWidthBottomCache
BorderWidthRight cache
- class grid_renderer.CellEdgeRenderer(painter, center, borders, rect, clip_path, zoom)[source]¶
Bases:
object
Paints cell edges
Borders are provided by EdgeBorders in order: left, right, top, bottom
- Parameters:
painter (
QPainter
) – Painter with which edge is drawncenter (
QPointF
) – Edge centerborders (
EdgeBorders
) – Border widths and colorsrect (
QRectF
) – Rect of the clip_pathclip_path (
QPainterPath
) – Clip rectangle that is required for QtSVG clippingzoom (
float
) – Current zoom level
- intersection_cache = {}¶
- class grid_renderer.CellRenderer(grid, painter, option, index)[source]¶
Bases:
object
Paints cells
Cell rendering governs the area of a cell inside its borders. It is done in a vector oriented way. Therefore, the following conventions shall apply:
Cell borders of width 1 shall be painted so that they appear only in the bottom and right edge of the cell.
Cell borders of all widths have the same center line.
Cell borders that are thicker than 1 are painted on all borders.
- At the edges, borders are painted in the following order:
Thin borders are painted first
If border width is equal, lighter colors are painted first
- Parameters:
grid (
QTableView
) – The main grid widgetpainter (
QPainter
) – Painter with which borders are drawnoption (
QStyleOptionViewItem
) – Style option for renderingindex (
QModelIndex
) – Index of cell to be rendered
- _draw_line(point1, point2, width, color, clip_path)[source]¶
Draws line
Uses drawLine for screen painting and QPainterPathStroker for svg painting.
- static _get_border_pen(width, zoom)[source]¶
Gets zoomed border pen, white, fully transparent
- Parameters:
width – Unzoomed line width
zoom – Current zoom level of grid
- inner_rect(rect)[source]¶
Returns inner rect that is shrunk by border widths
For merged cells, minimum top/left border widths are taken into account
- Parameters:
rect (
QRectF
) – Cell rect to be shrunk- Return type:
QRectF
- paint_above_borders(rect, clip_path)[source]¶
Paint lower borders of all above cells
- Parameters:
rect (
QRectF
) – Cell rect of below cell, in which the borders are paintedclip_path (
QPainterPath
) – Clip rectangle that is requuired for QtSVG clipping
- paint_bottom_border(rect, clip_path)[source]¶
Paint bottom border of cell
- Parameters:
rect (
QRectF
) – Cell rect of the cell to be paintedclip_path (
QPainterPath
) – Clip rectangle that is required for QtSVG clipping
- paint_bottom_left_edge(rect, clip_path)[source]¶
Paints bottom left edge of the cell
- Parameters:
rect (
QRectF
) – Cell rect of cell, for which the edge is paintedclip_path (
QPainterPath
) –Clip rectangle that is requuired for QtSVG clipping
top
L | C
- left ———— right
- BL | B
bottom
- paint_bottom_right_edge(rect, clip_path)[source]¶
Paints bottom right edge of the cell
- Parameters:
rect (
QRectF
) – Cell rect of cell, for which the edge is paintedclip_path (
QPainterPath
) –Clip rectangle that is requuired for QtSVG clipping
top
C | R
- left ———– right
- B | BR
bottom
- paint_left_borders(rect, clip_path)[source]¶
Paint right borders of all left cells
- Parameters:
rect (
QRectF
) – Cell rect of right cell, in which the borders are paintedclip_path (
QPainterPath
) – Clip rectangle that is requuired for QtSVG clipping
- paint_right_border(rect, clip_path)[source]¶
Paint right border of cell
- Parameters:
rect (
QRectF
) – Cell rect of the cell to be paintedclip_path (
QPainterPath
) – Clip rectangle that is requuired for QtSVG clipping
- class grid_renderer.EdgeBorders(left_width, right_width, top_width, bottom_width, left_color, right_color, top_color, bottom_color, left_x, right_x, top_y, bottom_y)[source]¶
Bases:
object
Holds border data for an edge and provides effective edge properties
- property _border_colors: Tuple[QColor, QColor, QColor, QColor]¶
Tuple of border colors in order left, right, top, bottom
- property _border_widths: Tuple[float, float, float, float]¶
Tuple of border widths in order left, right, top, bottom
- _color_cache = None¶
Bases:
object
Find neighbors of a cell
- Parameters:
Color of bottom border line
Color of right border line
Width of bottom border line
Width of right border line
Merge area of the key cell
Merging cell if cell is merged else cell key
- class grid_renderer.QColorCache(grid, *args, **kwargs)[source]¶
Bases:
dict
QColor cache that returns default color for None
- grid_renderer.painter_rotate(painter, rect, angle=0)[source]¶
Context manager rotating and restoring the painter
- Parameters:
painter (
QPainter
) – Painter, which is rotatedrect (
QRectF
) – Rect to be painted inangle (
int
) – Rotataion angle must be in (0, 90, 180, 270)
- Return type:
QRectF
- grid_renderer.painter_save(painter)[source]¶
Context manager saving and restoring painter state
- Parameters:
painter (
QPainter
) – Painter, for which the state is preserved
- grid_renderer.painter_zoom(painter, zoom, rect)[source]¶
Context manager scaling and restoring the painter
(rect.x(), rect.y()) is invariant
- Parameters:
painter (
QPainter
) – Painter, for which the state is preservedzoom (
float
) – Zoom factorrect (
QRectF
) – Rect for setting zoom invariant point (rect.x(), rect.y())
- Return type:
QRectF