NDEVR
API Documentation
QTImageEditorView

A widget that provides a canvas for viewing and editing images with drawing tools. More...

Public Types

enum class  EditMode {
  e_freehand , e_draw_line , e_draw_rect , e_draw_circle ,
  e_erase , e_draw_text , e_crop , e_size
}
 The active drawing or editing tool for the image editor. More...
enum class  ResizeMode { e_center , e_top_left , e_stretch }
 Describes how an image is positioned when resized. More...

Public Member Functions

 QTImageEditorView (QWidget *parent=nullptr)
 Constructs a QTImageEditorView widget.
void checkTextEdit ()
 Checks if the text edit widget needs to be committed or dismissed.
void clearImage ()
 Clears the image to a blank state.
void clearSelection ()
 Clears the current selection or crop region.
void editedSignal ()
 Emitted when the image has been edited.
EditMode editMode () const
 Returns the current edit mode.
void finishText ()
 Finishes and commits the current text editing operation.
QImage image () const
 Returns the current image being edited.
bool isEditing () const
 Returns whether a drawing or text editing operation is currently in progress.
bool isModified () const
 Returns whether the image has been modified since the last save.
void mousePressLocation (QPointF end_point)
 Handles a mouse press at the given image-space location.
void mouseReleaseLocation (QPointF end_point)
 Handles a mouse release at the given image-space location.
QColor penColor () const
 Returns the current pen color.
int penWidth () const
 Returns the current pen width.
void resizeImage (const QSize &new_size, ResizeMode resize_mode, bool lock_aspect_ratio)
 Resizes the image to the given size using the specified mode.
fltp08 scale () const
 Returns the current display scale factor.
void setEditMode (EditMode edit_mode)
 Sets the active editing mode (drawing tool).
void setFillColor (const QColor &color)
 Sets the fill color used for shape drawing operations.
void setFont (const QFont &font)
 Sets the font used for text drawing mode.
void setImage (QImage image)
 Sets the image to be displayed and edited.
void setPenColor (const QColor &color)
 Sets the pen color used for drawing operations.
void setPenWidth (fltp08 width)
 Sets the pen width used for drawing operations.
void setScale (fltp08 scale)
 Sets the display scale factor for the image.
QSize sizeHint () const override
 Returns the recommended size for this widget.
QImage undoImage () const
 Returns the image state before the last edit, for undo purposes.
void updateCursorLocation (QPointF end_point)
 Updates the cursor position during a drag operation.

Protected Member Functions

void drawText ()
 Renders text onto the image from the active text edit widget.
void mouseMoveEvent (QMouseEvent *event) override
 Handles mouse move events for drawing.
void mousePressEvent (QMouseEvent *event) override
 Handles mouse press events for drawing.
void mouseReleaseEvent (QMouseEvent *event) override
 Handles mouse release events for drawing.
void paintEvent (QPaintEvent *event) override
 Paints the editor view including the image and any active drawing overlays.
void resizeEvent (QResizeEvent *event) override
 Handles resize events to update the background image.

Detailed Description

A widget that provides a canvas for viewing and editing images with drawing tools.


Definition at line 24 of file QTImageEditor.h.

Member Enumeration Documentation

◆ EditMode

enum class QTImageEditorView::EditMode
strong

The active drawing or editing tool for the image editor.

Enumerator
e_freehand 

Freehand drawing mode.

e_draw_line 

Draw straight lines.

e_draw_rect 

Draw rectangles.

e_draw_circle 

Draw circles or ellipses.

e_erase 

Eraser mode.

e_draw_text 

Text annotation mode.

e_crop 

Crop the image.

e_size 

Sentinel value representing the number of edit modes.

Definition at line 40 of file QTImageEditor.h.

◆ ResizeMode

enum class QTImageEditorView::ResizeMode
strong

Describes how an image is positioned when resized.

Enumerator
e_center 

Centers the image within the new size.

e_top_left 

Anchors the image to the top-left corner.

e_stretch 

Stretches the image to fill the new size.

Definition at line 31 of file QTImageEditor.h.

Constructor & Destructor Documentation

◆ QTImageEditorView()

QTImageEditorView::QTImageEditorView ( QWidget * parent = nullptr)

Constructs a QTImageEditorView widget.

Parameters
[in]parentThe parent widget.

Member Function Documentation

◆ editMode()

EditMode QTImageEditorView::editMode ( ) const
inline

Returns the current edit mode.

Returns
The active edit mode.

Definition at line 167 of file QTImageEditor.h.

◆ image()

QImage QTImageEditorView::image ( ) const
inline

Returns the current image being edited.

Returns
The current image.

Definition at line 97 of file QTImageEditor.h.

Referenced by resizeEvent(), and setImage().

◆ isEditing()

bool QTImageEditorView::isEditing ( ) const

Returns whether a drawing or text editing operation is currently in progress.

Returns
True if editing is active.

◆ isModified()

bool QTImageEditorView::isModified ( ) const
inline

Returns whether the image has been modified since the last save.

Returns
True if the image has been modified.

Definition at line 77 of file QTImageEditor.h.

◆ mouseMoveEvent()

void QTImageEditorView::mouseMoveEvent ( QMouseEvent * event)
overrideprotected

Handles mouse move events for drawing.

Parameters
[in]eventThe mouse event.

◆ mousePressEvent()

void QTImageEditorView::mousePressEvent ( QMouseEvent * event)
overrideprotected

Handles mouse press events for drawing.

Parameters
[in]eventThe mouse event.

◆ mousePressLocation()

void QTImageEditorView::mousePressLocation ( QPointF end_point)

Handles a mouse press at the given image-space location.

Parameters
[in]end_pointThe press location in image coordinates.

◆ mouseReleaseEvent()

void QTImageEditorView::mouseReleaseEvent ( QMouseEvent * event)
overrideprotected

Handles mouse release events for drawing.

Parameters
[in]eventThe mouse event.

◆ mouseReleaseLocation()

void QTImageEditorView::mouseReleaseLocation ( QPointF end_point)

Handles a mouse release at the given image-space location.

Parameters
[in]end_pointThe release location in image coordinates.

◆ paintEvent()

void QTImageEditorView::paintEvent ( QPaintEvent * event)
overrideprotected

Paints the editor view including the image and any active drawing overlays.

Parameters
[in]eventThe paint event.

◆ penColor()

QColor QTImageEditorView::penColor ( ) const
inline

Returns the current pen color.

Returns
The pen color.

Definition at line 82 of file QTImageEditor.h.

◆ penWidth()

int QTImageEditorView::penWidth ( ) const
inline

Returns the current pen width.

Returns
The pen width in pixels.

Definition at line 87 of file QTImageEditor.h.

◆ resizeEvent()

void QTImageEditorView::resizeEvent ( QResizeEvent * event)
overrideprotected

Handles resize events to update the background image.

Parameters
[in]eventThe resize event.

References image(), and resizeImage().

◆ resizeImage()

void QTImageEditorView::resizeImage ( const QSize & new_size,
ResizeMode resize_mode,
bool lock_aspect_ratio )

Resizes the image to the given size using the specified mode.

Parameters
[in]new_sizeThe new image dimensions.
[in]resize_modeHow to position the image within the new size.
[in]lock_aspect_ratioWhether to preserve the image aspect ratio.

Referenced by resizeEvent().

◆ scale()

fltp08 QTImageEditorView::scale ( ) const
inline

Returns the current display scale factor.

Returns
The scale factor.

Definition at line 119 of file QTImageEditor.h.

Referenced by setScale().

◆ setEditMode()

void QTImageEditorView::setEditMode ( EditMode edit_mode)

Sets the active editing mode (drawing tool).

Parameters
[in]edit_modeThe edit mode to activate.

◆ setFillColor()

void QTImageEditorView::setFillColor ( const QColor & color)
inline

Sets the fill color used for shape drawing operations.

Parameters
[in]colorThe fill color.

Definition at line 72 of file QTImageEditor.h.

◆ setFont()

void QTImageEditorView::setFont ( const QFont & font)

Sets the font used for text drawing mode.

Parameters
[in]fontThe font to use.

◆ setImage()

void QTImageEditorView::setImage ( QImage image)

Sets the image to be displayed and edited.

Parameters
[in]imageThe image to set.

References image().

◆ setPenColor()

void QTImageEditorView::setPenColor ( const QColor & color)

Sets the pen color used for drawing operations.

Parameters
[in]colorThe color to use for the pen.

◆ setPenWidth()

void QTImageEditorView::setPenWidth ( fltp08 width)

Sets the pen width used for drawing operations.

Parameters
[in]widthThe width of the pen in pixels.

◆ setScale()

void QTImageEditorView::setScale ( fltp08 scale)

Sets the display scale factor for the image.

Parameters
[in]scaleThe scale factor.

References scale().

◆ sizeHint()

QSize QTImageEditorView::sizeHint ( ) const
override

Returns the recommended size for this widget.

Returns
The size hint.

◆ undoImage()

QImage QTImageEditorView::undoImage ( ) const
inline

Returns the image state before the last edit, for undo purposes.

Returns
The previous image state.

Definition at line 129 of file QTImageEditor.h.

◆ updateCursorLocation()

void QTImageEditorView::updateCursorLocation ( QPointF end_point)

Updates the cursor position during a drag operation.

Parameters
[in]end_pointThe current cursor location in image coordinates.

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