Process visualization

This folder contains all the functions and class that designate the graphic part of the project, which uses several graphic tools, such as Tkinter, Canvas and other Widgets. We have two types of representations, one which is fixed and the other which is interactive. There also are other aspects of the interface as an example : The GIF generator and other aspects of the representation such as the TABLE button.

Base visualization

process_vis.base_vis.circle(canvas, center, radius, state_circle, background_circle, outline_circle)

This function creates a circle item in the canvas.

Parameters
  • canvas (tkinter.Canvas) – Canvas where the circle will be created

  • center (tuple) – Coordinates of the circle’s center in the Canvas

  • radius (int) – Corresponds to the radius of the circle

  • state_circle (boolean) – Displays the circle’s item if it takes True

  • background_circle (str) – Color of the circle’s background

  • outline_circle (str) – Color of the circle’s line

Returns

Returns the Canvas widget

Return type

tkinter.Canvas

process_vis.base_vis.coord(x, y, a, b)

Gives the coordinates to change the landmark for one point (integer numbers).

Returns

Returns coordinates of one point in the Canvas landmark

Return type

tuple

Example

>>> coord(200,200,40,60)
(260,160)
process_vis.base_vis.angle_tab(radius, graph)

Returns a list of coordinates in the basic landmark which gives the coordinates of each vertex. Vertices are proportionally spaced (t = 2*pi/modulo number).

Parameters
  • radius (int) – Radius of the circle

  • graph (multiplication_table.process_math.Graph.Graph) – Graph object which gives the modulo number

Returns

Returns a list of coordinates of all vertices

Return type

list

process_vis.base_vis.dot(canvas, graph, radius, center, color_graph, color_name)

Adds the number of dots needed on the circle thanks to the angle_tab() function. These points are proportionally spaced. Also, it calls name_vertices() function which associates, for each dot, a number.

Parameters
  • canvas (tkinter.Canvas) – Canvas where the dots items will be created

  • graph (multiplication_table.process_math.Graph.Graph) – Graph object which gives the modulo number

  • radius (int) – Corresponds to the circle’s radius

  • center (int) – Center of the circle in the Canvas

  • color_graph (list) – List of colors to change the dots color

  • color_name (str) – Color of text items which represent the name of dots

Returns

Returns the Canvas widget

Return type

tkinter.Canvas

process_vis.base_vis.name_vertices(cnv, radius, graph, center, color_name)

Adds a name, for each vertex, around the circle.

Parameters
  • cnv (tkinter.Canvas) – Canvas where the name will be added

  • radius (int) – Corresponds to the circle’s radius

  • center (int) – Center of the circle in the canvas

  • color_name (str) – Color of text items

Returns

Returns the Canvas widget

Return type

tkinter.Canvas

Edges visualization

process_vis.edges_vis.all_edges(canvas, graph, radius, center, color_graph, edges_width)

This function reiterates the one_edge() function for each vertex i between 0 and the modulo number minus one.

Parameters
  • canvas (tkinter.Canvas) – Canvas where edges will be created

  • graph (multiplication_table.process_math.Graph.Graph) – Graph object which gives the modulo number

  • radius (int) – Corresponds to the circle’s radius

  • center (int) – Center of the circle in the canvas

  • color_graph (list) – List of colors to change the edges color

  • edges_width (int) – The width of edges in pixels

Returns

Returns the Canvas widget

Return type

tkinter.Canvas

process_vis.edges_vis.one_edge(graph, canvas, i, angle, center, color_graph, edges_width)

This function draws for any i fixed the edge between the vertex i and the vertex j. j is given by the result of the modular multiplication for i.

Parameters
  • graph (multiplication_table.process_math.Graph.Graph) – Graph object which gives the modulo number

  • canvas (tkinter.Canvas) – Canvas where the edge will be created

  • i (int) – Vertex i

  • angle (list) – List of coordinates of all vertices

  • center (int) – Center of the circle in the canvas

  • color_graph (str) – Color of the edge

  • edges_width (int) – Width of edge in pixels

Returns

Returns the Canvas widget

Return type

tkinter.Canvas

Interface

class process_vis.interface.Interface_gestion(speed, state_button, background, state_circle, color_graph, background_circle, outline_circle, color_name, edges_width)

This class contains functions which are used, for the graphical interface and makes the link between the different aspects of the visualization, as well as design and movement.

Parameters
  • speed (float) – Speed of the circle’s movement

  • state_circle (boolean) – Displays the circle’s item if it takes True

  • color_graph (list) – List of colors to change the dots and edges color

  • background_circle (str) – Color of the circle’s background

  • outline_circle (str) – Color of the circle’s line

  • color_name (str) – Color of text items for vertices’s name

  • edges_width (int) – Width of edges in pixels

  • nb_frame (int) – The number of images captured for a gif since the last gif.

  • nb_video (int) – The number of gif already created

  • root (tkinter.Tk) – Interface window

  • canvas (tkinter.Canvas) – Canvas where all items will be created

  • radius (int) – Corresponds to the circle’s radius

  • center (tuple) – Coordinates of the circle’s center in the Canvas

  • N (float) – Corresponds to the multiplication table. This number is rounded to \(10^{-2}\)

  • mod (int) – Corresponds to the modulo number

  • graph (multiplication_table.process_math.Graph.Graph) – Graph object which gives the modulo number

  • peak_cursor (tkinter.Scale) – Slider which changes the modulo value according to the user

  • table_cursor (tkinter.Scale) – Slider which changes the table value according to the user

  • state_button (boolean) – State of the button **Play/Pause

process_vis.interface.Interface_gestion.__init__(self, speed, state_button, background, state_circle, color_graph, background_circle, outline_circle, color_name, edges_width)

This method is a constructor method, that instantiates the speed and all other aspects.

process_vis.interface.Interface_gestion.design_aspect(self, speed, state_circle, color_graph, background_circle, outline_circle, color_name, edges_width)

Initialization of the design aspect parameters.

Parameters
  • speed (float) – Speed of the circle’s movement

  • state_circle (boolean) – Displays the circle’s item if it takes True

  • color_graph (list) – List of colors to change the dots and edges color

  • background_circle (str) – Color of the circle’s background

  • outline_circle (str) – Color of the circle’s line

  • color_name (str) – Color of text items for vertices’s name

  • edges_width (int) – Width of edges in pixels

process_vis.interface.Interface_gestion.window_init(self, background)

This method initializes the interface’s window which refers to a rectangular area. The user can display screen through which he can interact.

Parameters

background (str) – Color of the Canvas’s background

process_vis.interface.Interface_gestion.graph_init(self)

This method initializes the graph by default, as one its radius, its center, its multiplication table and its modulo.

process_vis.interface.Interface_gestion.graph_vis(self)

This method displays its execution’s time in the terminal and also the visualization part of the graph in other words dots, circle and edges.

process_vis.interface.Interface_gestion.table(self, n)

This method sets the value of table thanks to the cursor and calls the function show_update() that will change the Canvas.

Parameters

n (str) – Represent the table number. For example if the cursor is moved to position 40; we have called the table 2.40.

process_vis.interface.Interface_gestion.vertices(self, mod)

This method sets the value of modulo thanks to the cursor and calls the function show_update() that will change the Canvas.

Parameters

mod – Represent the modulo number. For example if the cursor is moved to position 40; we have called the table 42.

process_vis.interface.Interface_gestion.show_update(self)

This method removes all Canvas items and recreates them after all the modifications

process_vis.interface.Interface_gestion.slider(self)

This method generates the two cursors which captures the number of the table and the number of vertices (modulo). The table cursor captures all tables from 2 to 400 with a step of 0.01 and the modulo cursor captures all modulo from 2 to 200 with a step of 1. They are placed horizontally and are 250 pixels long.

process_vis.interface.Interface_gestion.move_value(self)

This method increases the table number with a step of 0.01 automatically and continuously

process_vis.interface.Interface_gestion.save_frame(self)

This method captures the current canvas, converts it to .png format and saves it in the correct directory “/temp/png{number_video}”.

process_vis.interface.Interface_gestion.save_video(self)

This method accesses the folder where the corresponding images are saved. Then it creates the gif from the captured images. This latter is saved in the folder “/gif” in the format: gif{number}.gif

process_vis.interface.Interface_gestion.destroy_root(self)

This method deletes all the folders whose format is “/temp/png{number_video}”. Then, it destroys all the canvas and closes the window.

process_vis.interface.Interface_gestion.create_table_window(self)

This method creates another window which contains all the modular calculations of the current Canvas. This window is managed by a scrollbar.

process_vis.interface.Interface_gestion.create_description(self)

This method creates another window which contains a description of the different graphical performances.

process_vis.interface.Interface_gestion.motion_button(self)

Provides the control buttons, for example, the motion button which actives the animation.