Source code for wolfhece.pyvertexvectors._grid

"""GUI-enabled Grid class."""

import numpy as np

from ..PyVertex import wolfvertex
from ._models import GridModel
from ._zones import Zones
from ._zone import zone
from ._vector import vector

[docs] class Grid(Zones, GridModel): """ Grid to draw on the mapviewer. Contains one zone and 3 vectors (gridx, gridy, contour). Each gridx and gridy vector contains vertices forming a continuous line. Contour vector contains 4 vertices forming a closed polyline. Drawing all the elements on the mapviewer allows to draw a grid. Based on spatial extent and resolution. """ def __init__(self, size:float=1000., ox:float=0., oy:float=0., ex:float=1000., ey:float=1000., parent=None): """Initialise a GUI-enabled grid. :param size: Grid cell size in world units. :param ox: X-coordinate of the grid origin (lower-left). :param oy: Y-coordinate of the grid origin (lower-left). :param ex: X-coordinate of the grid extent (upper-right). :param ey: Y-coordinate of the grid extent (upper-right). :param parent: Parent mapviewer or None. """ Zones.__init__(self, ox=ox, oy=oy, parent=parent) mygrid=zone(name='grid',parent=self) self.add_zone(mygrid) gridx=vector(name='gridx') gridy=vector(name='gridy') contour=vector(name='contour') mygrid.add_vector(gridx) mygrid.add_vector(gridy) mygrid.add_vector(contour) self.creategrid(size,ox,oy,ex,ey)