NNFS
Neural network library from scratch
Loading...
Searching...
No Matches
Canvas Class Reference

The Canvas class represents a custom widget for drawing on a canvas. More...

#include <canvas.h>

Inheritance diagram for Canvas:
[legend]

Public Member Functions

 Canvas (QWidget *parent=nullptr)
 Constructs a new Canvas object.
 
void clearImage ()
 Clears the image on the canvas.
 
void restartCanvas ()
 Restarts the canvas by clearing the image and resetting the drawing state.
 
Eigen::MatrixXd getMatrix ()
 Gets the matrix representation of the image on the canvas.
 
bool isDrawing ()
 Checks if the user is currently drawing on the canvas.
 

Protected Member Functions

void mousePressEvent (QMouseEvent *event) override
 Handles the mouse press event.
 
void mouseMoveEvent (QMouseEvent *event) override
 Handles the mouse move event.
 
void mouseReleaseEvent (QMouseEvent *event) override
 Handles the mouse release event.
 

Detailed Description

The Canvas class represents a custom widget for drawing on a canvas.

This class extends QLabel and provides functionality for drawing on a canvas using the mouse.

Constructor & Destructor Documentation

◆ Canvas()

Canvas::Canvas ( QWidget *  parent = nullptr)
explicit

Constructs a new Canvas object.

Parameters
parentThe parent widget.

Member Function Documentation

◆ clearImage()

void Canvas::clearImage ( )

Clears the image on the canvas.

◆ getMatrix()

Eigen::MatrixXd Canvas::getMatrix ( )

Gets the matrix representation of the image on the canvas.

Returns
The matrix representation of the image.

◆ isDrawing()

bool Canvas::isDrawing ( )
inline

Checks if the user is currently drawing on the canvas.

Returns
True if the user is drawing, false otherwise.

◆ mouseMoveEvent()

void Canvas::mouseMoveEvent ( QMouseEvent *  event)
overrideprotected

Handles the mouse move event.

Parameters
eventThe mouse event.

◆ mousePressEvent()

void Canvas::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Handles the mouse press event.

Parameters
eventThe mouse event.

◆ mouseReleaseEvent()

void Canvas::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Handles the mouse release event.

Parameters
eventThe mouse event.

◆ restartCanvas()

void Canvas::restartCanvas ( )

Restarts the canvas by clearing the image and resetting the drawing state.


The documentation for this class was generated from the following files: