HMI

The HMI (Human machine interface) is a class for drawing curves and generating vertices. A guide on how to use it can be found here How to HMI.

This class initializes a figure and connects to mouse and keyboard inputs. These are then used to control the drawing and calculation of the new vertices.

A future update might include a way to load images and create curves by manually setting vertices. An automatic way of generating the vertices is included in get_vertices.py but still needs some work.

class curve_shortening_flow.hmi.get_vertices(radius=3.0)[source]

Class for the HMI (Human machine interface).

This class provides an interface for drawing curves. These curves can then be feed into the iterator and animated. The drawing can be restarted by pressing ‘c’ on the keyboard. The density of points can be adjusted by the number keys from 1 to 9. At 1 the maximum amount of points are drawn and at 9 the minimum. In order to close the drawing screen, close the figure or press ‘q’ or ‘escape’. After closing the figure the last and dist point are also connected by a line with maximum amount of points. Drawing is only possible without any tool picked. This helps drawing by zooming or panning the view. The number of points and the scaling factor is updated in the title. The functionality is:

  • Drawing by mouse movement after pressing and holding the left mouse button.
  • Setting single points by pressing and releasing the left mouse button.
  • Pressing ‘b’ or ‘v’ draws a line between the last point and the mouse pointer position.

Initialization with a minimal radius.

Parameters:

radius: double, optional

Minimal radius to the last point to draw the new one. Default is 3.

connect()[source]

Connect to the button events.

disconnect()[source]

Disconnect from the events.

drawing()[source]

Start the drawing process.

interpol(x, y, xl, yl)[source]

Connect two points by a line.

This method creates a line between two points with a minimal distance between points. The distance is controlled by the minimal radius and the scaling factor.

key_pressed(event)[source]

Key event handler.

Options are:

  • ‘escape’ or ‘q’ to close the figure and connect last and first point.
  • ‘b’ or ‘v’ to connect the last point and mouse position with a line.
  • Number keys for setting the scaling of the minimal distance.
  • ‘c’ to clear the drawing and start from the beginning.
on_motion(event)[source]

Draw lines by moving the mouse.

If the left mouse button is pressed and the mouse is moved, vertices are drawn. The minimum distance of points takes is defined by the radius and its scaling factor. Only if the next mouse position if further away then that distance a new vertex is generated. By moving the mouse faster or slower the amounts of points takes is also changed but this is a problem with the figure not with the algorithm. If moved slow enough vertices are generated at the specified rate.

pressed(event)[source]

Act on mouse button pressed.

If no tool is selected create a vertex. The first vertex is a handled different because the plot has to initialized. For every other points the same rules for setting points apply as in the motion method.

release(event)[source]

Save the released state.