nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::services::DrawingService Class Reference

Adapter service for graphical output backends. More...

#include <drawingService.h>

Inheritance diagram for nsbaci::services::DrawingService:
Collaboration diagram for nsbaci::services::DrawingService:

Signals

void drawCommandReceived (const nsbaci::types::DrawCommand &command)
 Emitted when a drawing command should be executed.
void clearRequested (const nsbaci::types::Color &backgroundColor)
 Emitted when the canvas should be cleared.
void drawRequested (const nsbaci::types::Drawable &drawable)
 Emitted when a shape should be drawn.
void refreshRequested ()
 Emitted when the canvas should refresh.
void canvasSizeChanged (const nsbaci::types::Size &size)
 Emitted when canvas size changes.

Public Member Functions

 DrawingService (QObject *parent=nullptr)
 DrawingService (const DrawingService &)=delete
DrawingService & operator= (const DrawingService &)=delete
 DrawingService (DrawingService &&)=delete
DrawingService & operator= (DrawingService &&)=delete
void setColor (uint8_t r, uint8_t g, uint8_t b)
 Set the current drawing color using RGB values.
void setColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Set the current drawing color using RGBA values.
void setColor (const nsbaci::types::Color &color)
 Set the current drawing color using a Color struct.
nsbaci::types::Color getCurrentColor () const
 Get the current drawing color.
void setPosition (int32_t x, int32_t y)
 Set the current drawing position.
void setPosition (const nsbaci::types::Point &point)
 Set the current drawing position using a Point.
nsbaci::types::Point getCurrentPosition () const
 Get the current drawing position.
void clear ()
 Clear the canvas with optional background color.
void clear (const nsbaci::types::Color &color)
 Clear the canvas with a specific color.
void fill ()
 Fill the entire canvas with the current color.
void refresh ()
 Request a canvas refresh/redraw.
void setLineWidth (int32_t width)
 Set the line thickness for subsequent drawings.
int32_t getLineWidth () const
 Get the current line width.
void drawCircle (int32_t centerX, int32_t centerY, int32_t radius, bool filled=false)
 Draw a circle at the specified position.
void drawRectangle (int32_t x, int32_t y, int32_t width, int32_t height, bool filled=false)
 Draw a rectangle at the specified position.
void drawTriangle (int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, bool filled=false)
 Draw a triangle with three vertices.
void drawLine (int32_t x1, int32_t y1, int32_t x2, int32_t y2)
 Draw a line between two points.
void drawEllipse (int32_t centerX, int32_t centerY, int32_t radiusX, int32_t radiusY, bool filled=false)
 Draw an ellipse at the specified position.
void drawPixel (int32_t x, int32_t y)
 Draw a single pixel at the specified position.
void drawText (int32_t x, int32_t y, const std::string &text, int32_t fontSize=12)
 Draw text at the specified position.
void drawShape (const nsbaci::types::Shape &shape)
 Draw a generic shape.
nsbaci::types::Size getCanvasSize () const
 Get the canvas size.
void setCanvasSize (int32_t width, int32_t height)
 Set the canvas size.
void reset ()
 Reset the drawing service to initial state.
void processCommand (const nsbaci::types::DrawCommand &command)
 Process a drawing command from the runtime.

Detailed Description

Adapter service for graphical output backends.

The DrawingService manages drawing state and emits signals when drawing operations are requested by the runtime. It follows an SDL-like approach where you set the render color and then draw shapes.

Usage pattern:

  1. setColor(r, g, b) - Set the current drawing color
  2. drawCircle/drawRect/etc - Draw shapes with current color
  3. clear() - Clear the canvas

The service emits signals that can be connected to any drawing backend (Qt widget, OpenGL, etc.)

Member Function Documentation

◆ canvasSizeChanged

void nsbaci::services::DrawingService::canvasSizeChanged ( const nsbaci::types::Size & size)
signal

Emitted when canvas size changes.

Parameters
sizeThe new canvas size.
Here is the caller graph for this function:

◆ clear()

void nsbaci::services::DrawingService::clear ( const nsbaci::types::Color & color)

Clear the canvas with a specific color.

Parameters
colorThe background color.
Here is the call graph for this function:

◆ clearRequested

void nsbaci::services::DrawingService::clearRequested ( const nsbaci::types::Color & backgroundColor)
signal

Emitted when the canvas should be cleared.

Parameters
backgroundColorThe color to clear with.
Here is the caller graph for this function:

◆ drawCircle()

void nsbaci::services::DrawingService::drawCircle ( int32_t centerX,
int32_t centerY,
int32_t radius,
bool filled = false )

Draw a circle at the specified position.

Parameters
centerXCenter X coordinate
centerYCenter Y coordinate
radiusCircle radius
filledWhether to fill the circle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCommandReceived

void nsbaci::services::DrawingService::drawCommandReceived ( const nsbaci::types::DrawCommand & command)
signal

Emitted when a drawing command should be executed.

Parameters
commandThe drawing command to execute.
Here is the caller graph for this function:

◆ drawEllipse()

void nsbaci::services::DrawingService::drawEllipse ( int32_t centerX,
int32_t centerY,
int32_t radiusX,
int32_t radiusY,
bool filled = false )

Draw an ellipse at the specified position.

Parameters
centerXCenter X coordinate
centerYCenter Y coordinate
radiusXHorizontal radius
radiusYVertical radius
filledWhether to fill the ellipse
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLine()

void nsbaci::services::DrawingService::drawLine ( int32_t x1,
int32_t y1,
int32_t x2,
int32_t y2 )

Draw a line between two points.

Parameters
x1,y1Start point
x2,y2End point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPixel()

void nsbaci::services::DrawingService::drawPixel ( int32_t x,
int32_t y )

Draw a single pixel at the specified position.

Parameters
xX coordinate
yY coordinate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRectangle()

void nsbaci::services::DrawingService::drawRectangle ( int32_t x,
int32_t y,
int32_t width,
int32_t height,
bool filled = false )

Draw a rectangle at the specified position.

Parameters
xTop-left X coordinate
yTop-left Y coordinate
widthRectangle width
heightRectangle height
filledWhether to fill the rectangle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRequested

void nsbaci::services::DrawingService::drawRequested ( const nsbaci::types::Drawable & drawable)
signal

Emitted when a shape should be drawn.

Parameters
drawableThe drawable object containing shape and color.
Here is the caller graph for this function:

◆ drawShape()

void nsbaci::services::DrawingService::drawShape ( const nsbaci::types::Shape & shape)

Draw a generic shape.

Parameters
shapeThe shape to draw.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawText()

void nsbaci::services::DrawingService::drawText ( int32_t x,
int32_t y,
const std::string & text,
int32_t fontSize = 12 )

Draw text at the specified position.

Parameters
xX coordinate
yY coordinate
textThe text to draw
fontSizeFont size in points
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawTriangle()

void nsbaci::services::DrawingService::drawTriangle ( int32_t x1,
int32_t y1,
int32_t x2,
int32_t y2,
int32_t x3,
int32_t y3,
bool filled = false )

Draw a triangle with three vertices.

Parameters
x1,y1First vertex
x2,y2Second vertex
x3,y3Third vertex
filledWhether to fill the triangle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCanvasSize()

nsbaci::types::Size nsbaci::services::DrawingService::getCanvasSize ( ) const
inline

Get the canvas size.

Returns
The canvas size.

◆ getCurrentColor()

nsbaci::types::Color nsbaci::services::DrawingService::getCurrentColor ( ) const
inline

Get the current drawing color.

Returns
The current color.

◆ getCurrentPosition()

nsbaci::types::Point nsbaci::services::DrawingService::getCurrentPosition ( ) const
inline

Get the current drawing position.

Returns
The current position.

◆ getLineWidth()

int32_t nsbaci::services::DrawingService::getLineWidth ( ) const
inline

Get the current line width.

Returns
The current line width.

◆ processCommand()

void nsbaci::services::DrawingService::processCommand ( const nsbaci::types::DrawCommand & command)

Process a drawing command from the runtime.

This method is intended to be called from the runtime's drawing callback. It processes the command and emits the appropriate signal.

Parameters
commandThe drawing command to process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCanvasSize()

void nsbaci::services::DrawingService::setCanvasSize ( int32_t width,
int32_t height )

Set the canvas size.

Parameters
widthCanvas width
heightCanvas height
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor() [1/3]

void nsbaci::services::DrawingService::setColor ( const nsbaci::types::Color & color)

Set the current drawing color using a Color struct.

Parameters
colorThe color to set.
Here is the call graph for this function:

◆ setColor() [2/3]

void nsbaci::services::DrawingService::setColor ( uint8_t r,
uint8_t g,
uint8_t b )

Set the current drawing color using RGB values.

Parameters
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor() [3/3]

void nsbaci::services::DrawingService::setColor ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t a )

Set the current drawing color using RGBA values.

Parameters
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)
aAlpha component (0-255)
Here is the call graph for this function:

◆ setLineWidth()

void nsbaci::services::DrawingService::setLineWidth ( int32_t width)

Set the line thickness for subsequent drawings.

Parameters
widthLine width in pixels.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPosition() [1/2]

void nsbaci::services::DrawingService::setPosition ( const nsbaci::types::Point & point)

Set the current drawing position using a Point.

Parameters
pointThe position to set.
Here is the call graph for this function:

◆ setPosition() [2/2]

void nsbaci::services::DrawingService::setPosition ( int32_t x,
int32_t y )

Set the current drawing position.

Parameters
xX coordinate
yY coordinate
Here is the call graph for this function:
Here is the caller graph for this function:

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