Canvas Tool

Association of Axes widget of MATLAB with a natural behavior for drawing graphic primitives in an arbitrary way
99 Downloads
Updated 12 Jun 2020

View License

Canvas Tool - Association of Axes widget of MATLAB with a natural behavior for drawing graphic primitives in an arbitrary way

Developed by:
Pedro Cortez Lopes (pedrocortez@id.uff.br) - Universidade Federal Fluminense (UFF - www.uff.br)
Rafael Lopez Rangel (rafaelrangel@tecgraf.puc-rio.br) - Pontificia Universidade Catolica do Rio de Janeiro (PUC-Rio - www.puc-rio.br)
Luiz Fernando Martha (lfm@tecgraf.puc-rio.br) - Pontificia Universidade Catolica do Rio de Janeiro (PUC-Rio - www.puc-rio.br)

In:
Tecgraf/PUC-Rio - The Tecgraf Institute of Technical-Scientific Software Development of PUC-Rio (www.tecgraf.puc-rio.br)

GitLab repository:
https://gitlab.com/cortezpedro/canvas

Overview:
The Canvas Tool consists of two object-oriented abstract superclasses: Canvas and Emouse.

* Canvas class
The purpose of the Canvas class is to associate the Axes widget of MATLAB with a natural behavior for drawing graphic primitives in an arbitrary way. It was designed to be used interchangeably by any program developed in MATLAB that needs a widget for an arbitrary drawing of graphic primitives.
The Axes widget was not originally designed to draw arbitrary graphic primitives (lines, curves, polygons, meshes, etc.) as a generic drawing area, although this is possible. This brings some disadvantages regarding the use of the Axes widget when the objective is to have a canvas for a generic design of geometric models, as is the case of a structural model. For example, the Axes widget has the natural behavior of updating the drawing scale when its dimensions are changed. This is not a natural behavior when the goal is to draw graphic primitives on a generic canvas. The desired behavior for a generic canvas can be achieved using the Axes widget, but some specific procedures must be performed. It should be noted that there is no other alternative in the MATLAB environment: the widget closest to a generic canvas is the Axes.
The Canvas class is an abstract superclass whose intrinsic property is an Axes widget. The Canvas superclass encapsulates all the procedures necessary to associate the behavior of a generic canvas to the Axes widget. This superclass declares abstract methods that associate callback functions to basic canvas actions: resizing, repaint, etc. A client subclass must be inherited from the Canvas class for implementing the abstract methods according to the necessities of the client application.
Besides the abstract Canvas superclass, this package provides two subclasses, one for dealing with 2D models (Canvas_2D) and another for dealing with 3D models (Canvas_3D).
The Canvas superclass and the provided 2D and 3D subclasses come in two versions: one for GUIDE applications and other for App Designer applications.

* Emouse class
The purpose of the Emouse class is to manage mouse actions on a MATLAB canvas (Axes widget) in a generic way.
Usually, the processes of modeling and camera control on a GUI application are aided by mouse interactions with the canvas. These interactions are carried out through mouse events, such as click, hoover, drag, and scroll, to perform the desired tasks of modeling (insert and pick objects, for example) and camera manipulation (panning, zooming, and rotating).
The Emouse superclass declares abstract methods that associate callback functions to basic mouse actions: pressing a mouse button, releasing a mouse button, moving the cursor, etc. Similar to the use of the Canvas class, a client subclass must be inherited from the Emouse class for implementing the abstract methods according to the necessities of the client application. Most of the complexity of handling mouse events on canvas is dealt with by concrete methods of the Emouse class. The client subclass only needs to address what is specific to its application. An Emouse object recognizes that a mouse event has occurred on the canvas and calls an abstract method, implemented by the client subclass, who calls auxiliary functions to do tasks according to the conditions of the event.
The Emouse class was originally developed by Emersson Duvan Torres Sánchez (emersson80@hotmail.com) in his MSc Dissertation: "Development of a class in the context of OOP for generic management of mouse events in a canvas in the MATLAB environment". Department of Civil and Environmental Engineering - PUC-Rio, Set. 2017: http://www.tecgraf.puc-rio.br/~lfm/teses/EmerssonTorres-Mestrado-2017.pdf

Instructions and License:
README: https://gitlab.com/cortezpedro/canvas/-/blob/master/README.md
LICENSE: https://gitlab.com/cortezpedro/canvas/-/blob/master/LICENSE

Cite As

Luiz Fernando Martha (2024). Canvas Tool (https://www.mathworks.com/matlabcentral/fileexchange/76872-canvas-tool), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2019a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

mouse_events_app

mouse_events_app/canvas

mouse_events_app/draw

mouse_events_app/gui

mouse_events_app/mouse

source/AppDesigner

source/GUIDE_Figs

tests

tests/canvas

tests/utils

Version Published Release Notes
1.0.1

Changed icon and download file.

1.0.0