Inheritance diagram of polygon.shape
class Shape(canvas=None, tag='', color='')[source]

Displays the polygon objects onto the canvas by supplying draw methods and maintaining internal information on the shape. Draws to matplotlib backend


Append a passed attribute onto the internal attribute list

Parameters:attr (str) – An attribute enum

Establishes a corner of a rectangle as an anchor for when the user drags the cursor to create a rectangle. Used in ‘Draw Rect’ button

Parameters:event – A matplotlib backend event object

Remove any existing lines and clear the shape data. This is called so the lines don’t remain on the screen if the user unclicks the toggleable button.


In the event the user is plotting points and decides to switch buttons without finishing the free draw polygon, the lines must be cleared and data must be reset. this function will ensure any unfinished data is cleared for future shape drawing.

draw(fig, fl, plot=0, fill=False)[source]

Draw the shape to the canvas, onto the passed figure. Only fill the object if the fill parameter is set to True

  • fig – A SubplotAxes object from the matplotlib backend
  • fl – A string representing the HDF path
  • plotconstants.Plot enum specifying which plot the object belongs to
  • fill (bool) – False for fill, True for outline
fill_rectangle(event, plot, fl, fig, fill=False)[source]

Draws the rectangle and stores the coordinates of the rectangle internally. Used in ‘Draw Rect’ button. Forwards argument parameters to draw

  • fig – Figure to draw canvas to
  • fill (bool) – Whether to fill or no fill the shape

Return attributes list maintained by shape

Return type:list

Return the hexdecimal color value

Return type:str

Return the list of coordinates internally maintained by shape

Return type:list

Return the file used

Return type:str

Return the database ID of shape

Return type:int

Return the item handler object to the actual backend base

Return type:matplotlib.patches.polygon

Return the notes string internally maintained by shape

Return type:str

Return the plot type

Return type:int

Returns if the shape has been saved or not


Return the program Tag of shape

Return type:str

Return True if attr is inside the attributes list, False otherwise.

Parameters:attr (str) –
Return type:bool

Return True if empty, False otherwise


Return a boolean value based on whether the object is currently highlighted in the figure. Uses __selected

Return type:bool
loaded_draw(fig, fill)[source]

Called in the case of panning the plot, since panning the plot invalidates the previous figure, the figures must first be cleared and the shapes are removed. Loaded draw draws the shapes back into view using a new figure.

  • fig – A SubplotAxes object to add the patch to
  • fill (bool) – Boolean value whether to have the shape filled in when drawn to or not

Changes the color of the shape and saves it internally

Parameters:color – the new color of the shape
plot_point(event, plot, fl, fig, fill=False)[source]

Plot a single point to the shape, connect any previous existing points and fill to a shape if the current coordinate intersects the beginning point.

  • event – A matplotlib.backend_bases.MouseEvent passed object
  • plot – an integer indicating which plot it was draw on
  • fl – A string representing the HDF it was drawn on
  • fig – The figure to be drawing the canvas to
  • fill (bool) – Whether the shape will have a solid fill or not
redraw(fig, fl, fill)[source]

Function to draw the shape in the event the shape may or may not already be drawn. Checks if the image already exists, if not draws the image

  • fig – A SubplotAxes object to add the patch to
  • fl – A string representing the HDF file
  • fill (bool) – Boolean value whether to have the shape filled in when drawn or not

Wrapper function to internally call matplotlib backend to remove the shape from the figure


Remove an attribute as specified in from the internal attributes variable

Parameters:attr (str) –

Draws a temporary helper rectangle that outlines the final shape of the rectangle for the user. This draws to screen coordiantes, so backend is not needed here.

Parameters:event – A matplotlib.backend_bases.MouseEvent forwarded object.

Marks the shape as saved


Set the internal list of attributes to a custom passed list

Parameters:attributes_list (list) –

Set internal color variable

Parameters:color (str) – Valid hexadecimal color value

Pass a list of coordinates to set to the shape to.

Parameters:coordinates (list) –

Manually set the value of the internal file variable

Parameters:fl – HDF file path

Set the linewidth and linestyle attributes of a the internal item handler. Highlights if highlight is True, otherwise sets to normal outline.

Parameters:highlight (bool) –

Set the database ID of the shape. unsafe to use outside letting database call this.

Parameters:_id (int) – Database primary key

Pass a string containing new notes to set the shape to

Parameters:note (str) – New note string

Manually set the new value of the internal plot variable. unsafe

Parameters:plot (constants.Plot) – Plot value

Set internal tag variable

Parameters:tag (str) –