CCIMXDesktop
 
Loading...
Searching...
No Matches
SimpleDrawingScene Class Reference

A QGraphicsScene subclass that provides simple drawing capabilities. More...

#include <SimpleDrawingScene.h>

Inheritance diagram for SimpleDrawingScene:

Public Types

enum class  DrawingMode { DrawingMode , EditMode }
 Defines the interaction modes for the scene. More...
 
enum class  SupportItemItem { Line , Rect , Ellipse , FreeHand }
 The types of drawable shapes supported by the scene. More...
 

Public Slots

void undo ()
 Undoes the last drawing operation.
 
void redo ()
 Redoes the last undone operation.
 

Public Member Functions

 SimpleDrawingScene (QObject *parent=nullptr)
 Constructs a SimpleDrawingScene.
 
void setColor (const QColor &color)
 Sets the current drawing color.
 
QColor getColor () const
 Gets the current drawing color.
 
void setPenWidth (const short penWidth)
 Sets the pen width for drawing.
 
short getPenWidth () const
 Gets the current pen width.
 
void setItemType (const SupportItemItem i)
 Sets the current drawing item type.
 
void setMode (const DrawingMode m)
 Sets the interaction mode.
 
QImage exportImage ()
 Exports the current scene as an image.
 

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse press events for drawing.
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse move events for drawing.
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse release events for drawing.
 

Detailed Description

A QGraphicsScene subclass that provides simple drawing capabilities.

This class implements a drawing canvas with multiple shape types, undo/redo functionality, and different interaction modes.

Member Enumeration Documentation

◆ DrawingMode

Defines the interaction modes for the scene.

Enumerator
DrawingMode 

Default mode for creating new items.

EditMode 

Mode for selecting and modifying existing items.

◆ SupportItemItem

The types of drawable shapes supported by the scene.

Enumerator
Line 

Straight line between two points.

Rect 

Rectangle shape.

Ellipse 

Ellipse or circle shape.

FreeHand 

Free-form drawing with mouse movement.

Constructor & Destructor Documentation

◆ SimpleDrawingScene()

SimpleDrawingScene::SimpleDrawingScene ( QObject *  parent = nullptr)
explicit

Constructs a SimpleDrawingScene.

Parameters
parentThe parent QObject (optional)

Member Function Documentation

◆ exportImage()

QImage SimpleDrawingScene::exportImage ( )

Exports the current scene as an image.

Returns
QImage containing the rendered scene

◆ getColor()

QColor SimpleDrawingScene::getColor ( ) const
inline

Gets the current drawing color.

Returns
The current drawing color

◆ getPenWidth()

short SimpleDrawingScene::getPenWidth ( ) const
inline

Gets the current pen width.

Returns
The current pen width in pixels

◆ setColor()

void SimpleDrawingScene::setColor ( const QColor &  color)
inline

Sets the current drawing color.

Parameters
colorThe color to use for new drawings

◆ setItemType()

void SimpleDrawingScene::setItemType ( const SupportItemItem  i)
inline

Sets the current drawing item type.

Parameters
iThe shape type to create (from SupportItemItem enum)

◆ setMode()

void SimpleDrawingScene::setMode ( const DrawingMode  m)

Sets the interaction mode.

Parameters
mThe mode to set (from DrawingMode enum)

◆ setPenWidth()

void SimpleDrawingScene::setPenWidth ( const short  penWidth)
inline

Sets the pen width for drawing.

Parameters
penWidthThe width in pixels for new drawings

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