![]() |
nsbaci 1.0
|
Adapter service for graphical output backends. More...
#include <drawingService.h>


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. | |
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:
The service emits signals that can be connected to any drawing backend (Qt widget, OpenGL, etc.)
|
signal |
Emitted when canvas size changes.
| size | The new canvas size. |

| void nsbaci::services::DrawingService::clear | ( | const nsbaci::types::Color & | color | ) |
Clear the canvas with a specific color.
| color | The background color. |

|
signal |
Emitted when the canvas should be cleared.
| backgroundColor | The color to clear with. |

| void nsbaci::services::DrawingService::drawCircle | ( | int32_t | centerX, |
| int32_t | centerY, | ||
| int32_t | radius, | ||
| bool | filled = false ) |
Draw a circle at the specified position.
| centerX | Center X coordinate |
| centerY | Center Y coordinate |
| radius | Circle radius |
| filled | Whether to fill the circle |


|
signal |
Emitted when a drawing command should be executed.
| command | The drawing command to execute. |

| 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.
| centerX | Center X coordinate |
| centerY | Center Y coordinate |
| radiusX | Horizontal radius |
| radiusY | Vertical radius |
| filled | Whether to fill the ellipse |


| void nsbaci::services::DrawingService::drawLine | ( | int32_t | x1, |
| int32_t | y1, | ||
| int32_t | x2, | ||
| int32_t | y2 ) |
Draw a line between two points.
| x1,y1 | Start point |
| x2,y2 | End point |


| void nsbaci::services::DrawingService::drawPixel | ( | int32_t | x, |
| int32_t | y ) |
Draw a single pixel at the specified position.
| x | X coordinate |
| y | Y coordinate |


| void nsbaci::services::DrawingService::drawRectangle | ( | int32_t | x, |
| int32_t | y, | ||
| int32_t | width, | ||
| int32_t | height, | ||
| bool | filled = false ) |
|
signal |
Emitted when a shape should be drawn.
| drawable | The drawable object containing shape and color. |

| void nsbaci::services::DrawingService::drawShape | ( | const nsbaci::types::Shape & | shape | ) |
Draw a generic shape.
| shape | The shape to draw. |


| 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.
| x | X coordinate |
| y | Y coordinate |
| text | The text to draw |
| fontSize | Font size in points |


| 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.
| x1,y1 | First vertex |
| x2,y2 | Second vertex |
| x3,y3 | Third vertex |
| filled | Whether to fill the triangle |


|
inline |
Get the canvas size.
|
inline |
Get the current drawing color.
|
inline |
Get the current drawing position.
|
inline |
Get the current line width.
| 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.
| command | The drawing command to process. |


| void nsbaci::services::DrawingService::setCanvasSize | ( | int32_t | width, |
| int32_t | height ) |
Set the canvas size.
| width | Canvas width |
| height | Canvas height |


| void nsbaci::services::DrawingService::setColor | ( | const nsbaci::types::Color & | color | ) |
Set the current drawing color using a Color struct.
| color | The color to set. |

| void nsbaci::services::DrawingService::setColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Set the current drawing color using RGB values.
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |


| 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.
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |
| a | Alpha component (0-255) |

| void nsbaci::services::DrawingService::setLineWidth | ( | int32_t | width | ) |
Set the line thickness for subsequent drawings.
| width | Line width in pixels. |


| void nsbaci::services::DrawingService::setPosition | ( | const nsbaci::types::Point & | point | ) |
Set the current drawing position using a Point.
| point | The position to set. |

| void nsbaci::services::DrawingService::setPosition | ( | int32_t | x, |
| int32_t | y ) |
Set the current drawing position.
| x | X coordinate |
| y | Y coordinate |

