Shape

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

add_attribute(attr)[source]

Append a passed attribute onto the internal attribute list

Parameters:attr (str) – An attribute enum
anchor_rectangle(event)[source]

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
clear_lines()[source]

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.

clear_unfinished_data()[source]

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

Parameters:
  • 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

Parameters:
  • fig – Figure to draw canvas to
  • fill (bool) – Whether to fill or no fill the shape
get_attributes()[source]

Return attributes list maintained by shape

Return type:list
get_color()[source]

Return the hexdecimal color value

Return type:str
get_coordinates()[source]

Return the list of coordinates internally maintained by shape

Return type:list
get_hdf()[source]

Return the file used

Return type:str
get_id()[source]

Return the database ID of shape

Return type:int
get_itemhandler()[source]

Return the item handler object to the actual backend base

Return type:matplotlib.patches.polygon
get_notes()[source]

Return the notes string internally maintained by shape

Return type:str
get_plot()[source]

Return the plot type

Return type:int
get_saved()[source]

Returns if the shape has been saved or not

get_tag()[source]

Return the program Tag of shape

Return type:str
is_attribute(attr)[source]

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

Parameters:attr (str) –
Return type:bool
is_empty()[source]

Return True if empty, False otherwise

is_selected()[source]

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.

Parameters:
  • 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
paint(color)[source]

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.

Parameters:
  • 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

Parameters:
  • 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
remove()[source]

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

remove_attribute(attr)[source]

Remove an attribute as specified in constants.py from the internal attributes variable

Parameters:attr (str) –
rubberband(event)[source]

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.
save()[source]

Marks the shape as saved

set_attributes(attributes_list)[source]

Set the internal list of attributes to a custom passed list

Parameters:attributes_list (list) –
set_color(color)[source]

Set internal color variable

Parameters:color (str) – Valid hexadecimal color value
set_coordinates(coordinates)[source]

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

Parameters:coordinates (list) –
set_hdf(fl)[source]

Manually set the value of the internal file variable

Parameters:fl – HDF file path
set_highlight(highlight)[source]

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_id(_id)[source]

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

Parameters:_id (int) – Database primary key
set_notes(note)[source]

Pass a string containing new notes to set the shape to

Parameters:note (str) – New note string
set_plot(plot)[source]

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

Parameters:plot (constants.Plot) – Plot value
set_tag(tag)[source]

Set internal tag variable

Parameters:tag (str) –