The modular design of pySimiam allows the use of any graphics engine. Even an HTML implementation should be possible. However, the creation of a new interface is a complicated task, as it has to support the rendering of the robots, and the control of supervisor parameters.
At the moment, only a Qt interface is implemented. It can be used as a source of inspiration, but a new UI does not have to follow exactly the same design. The only requirement is a correct processing of the simulator messages.
Todo
Specify the message types and possible responses.
Todo
Describe the Renderer interface
The Renderer class is an abstract class describing a generalized drawing engine. It has to be subclassed to implement the drawing in a way specific to the UI that the program is using.
The base class does not impose any restrictions on the type of the canvas parameter. It is up to a specific implementation to interpret this parameter correctly.
Add a pose transformation to the current transformation
Clears the canvas and draws the grid if necessary
To be implemented in subclasses.
Draw an arrow from (x1, y1) to (x2, y2). You can also specify the arrowhead angle (in radians), the ratio between arrowhead and arrow length and the triangular (close=True) or linear (close=False) arrowhead shape.
Draws an ellipse with current pen and fills it with current brush.
The center of the ellipse is at (cx, cy), the half-axes are ra and rb. In the case rb is not specified, the method draws a circle of radius ra.
Draw a line using the current pen from (x1,y1) to (x2, y2)
Draw a single point using the current pen at (x,y)
Draw a set of points, given as [(x,y)], using the current pen
Draws a polygon with current pen and fills it with current brush
Expects a list of points as a list of tuples or as a numpy array.
Draws a rectangle with current pen and fills it with current brush
The bottom-left corner of the rectangle is at (x, y), if the width and height are positive.
Restore the last saved state from the stack
The state includes default pose, pen and brush.
To be implemented in subclasses.
Store the current state on the stack.
Current state includes default pose, pen and brush.
To be implemented in subclasses.
Change canvas size
On canvas rescale the zoom factor will be recalculated: If the view rect was set, the view will be rescaled to fit the rect. If the view rect was not set, the zoom factor and default pose will be kept.
Resets the renderer to default pose and zoom level
Rotate canvas by angle (in radians)
To be implemented in subclasses.
Scale all drawing operations by factor
To be implemented in subclasses.
Zoom up the drawing by an additional factor
Equivalent to set_zoom_level(zoom_level*factor)
The zoom center is at the last set screen pose. This method will clear the canvas.
Sets the fill color.
The color is an integer, interpreted as 0xAARRGGBB. In the case AA == 0 the color is considered fully opaque.
Use None to unset a brush.
Tell the renderer to draw on canvas.
The type of canvas is implementation-dependent
Sets the line color anf thickness.
Color is interpreted as 0xAARRGGBB. In case AA == 0 the color is considered fully opaque.
Use None to unset a pen.
Set a coordinate transformation based on pose
Set the pose of center of the canvas
The zoom center will switch to canvas center.
Parameters: | pose (Pose) – The new pose of the lower-left corner. |
---|
Set the pose of the lower-left corner of the canvas.
The zoom center will switch to that corner.
Parameters: | pose (Pose) – The new pose of the lower-left corner. |
---|
Zoom on the rectangle to fit it into the view
Zoom up the drawing by a factor of zoom_level
The zoom center is at the last set screen pose.
This method will clear the canvas.
Draw the grid on the canvas background by default.
The grid is adaptive, with minimum interline distance of 40 px, and a maximum of 80 px. In the case the interline distance has to be smaller or larger, it is scaled. The interval is divided either in half, in five parts or in ten parts, to keep the grid decimal.
This method will clear the canvas
Translate canvas by dx, dy
To be implemented in subclasses.