nsbaci 1.0
Loading...
Searching...
No Matches
drawingService.h
Go to the documentation of this file.
1
13
14#ifndef NSBACI_SERVICES_DRAWINGSERVICE_H
15#define NSBACI_SERVICES_DRAWINGSERVICE_H
16
17#include <QObject>
18
19#include <memory>
20
21#include "drawingTypes.h"
22
27namespace nsbaci::services {
28
45class DrawingService : public QObject {
46 Q_OBJECT
47
48 public:
49 explicit DrawingService(QObject* parent = nullptr);
50 ~DrawingService() = default;
51
52 // QObject subclasses cannot be copied or moved
53 DrawingService(const DrawingService&) = delete;
54 DrawingService& operator=(const DrawingService&) = delete;
55 DrawingService(DrawingService&&) = delete;
56 DrawingService& operator=(DrawingService&&) = delete;
57
58 // ============== Color Management ==============
59
66 void setColor(uint8_t r, uint8_t g, uint8_t b);
67
75 void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
76
81 void setColor(const nsbaci::types::Color& color);
82
87 nsbaci::types::Color getCurrentColor() const { return currentColor_; }
88
89 // ============== Position Management ==============
90
96 void setPosition(int32_t x, int32_t y);
97
102 void setPosition(const nsbaci::types::Point& point);
103
108 nsbaci::types::Point getCurrentPosition() const { return currentPosition_; }
109
110 // ============== Canvas Operations ==============
111
115 void clear();
116
121 void clear(const nsbaci::types::Color& color);
122
126 void fill();
127
131 void refresh();
132
137 void setLineWidth(int32_t width);
138
143 int32_t getLineWidth() const { return lineWidth_; }
144
145 // ============== Shape Drawing ==============
146
154 void drawCircle(int32_t centerX, int32_t centerY, int32_t radius,
155 bool filled = false);
156
165 void drawRectangle(int32_t x, int32_t y, int32_t width, int32_t height,
166 bool filled = false);
167
175 void drawTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3,
176 int32_t y3, bool filled = false);
177
183 void drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
184
193 void drawEllipse(int32_t centerX, int32_t centerY, int32_t radiusX,
194 int32_t radiusY, bool filled = false);
195
201 void drawPixel(int32_t x, int32_t y);
202
210 void drawText(int32_t x, int32_t y, const std::string& text,
211 int32_t fontSize = 12);
212
217 void drawShape(const nsbaci::types::Shape& shape);
218
219 // ============== Canvas Configuration ==============
220
225 nsbaci::types::Size getCanvasSize() const { return canvasSize_; }
226
232 void setCanvasSize(int32_t width, int32_t height);
233
237 void reset();
238
247 void processCommand(const nsbaci::types::DrawCommand& command);
248
249 signals:
255
260 void clearRequested(const nsbaci::types::Color& backgroundColor);
261
267
272
278
279 private:
280 nsbaci::types::Color currentColor_{0, 0, 0}; // Default black
281 nsbaci::types::Point currentPosition_{0, 0}; // Default origin
282 int32_t lineWidth_ = 1; // Default line width
283 nsbaci::types::Size canvasSize_{800, 600}; // Default canvas size
284 nsbaci::types::Color backgroundColor_{255, 255, 255}; // Default white
285};
286
287} // namespace nsbaci::services
288
289#endif // NSBACI_SERVICES_DRAWINGSERVICE_H
nsbaci::types::Color getCurrentColor() const
Get the current drawing color.
Definition drawingService.h:87
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 drawCommandReceived(const nsbaci::types::DrawCommand &command)
Emitted when a drawing command should be executed.
void setColor(uint8_t r, uint8_t g, uint8_t b)
Set the current drawing color using RGB values.
Definition drawingService.cpp:20
void processCommand(const nsbaci::types::DrawCommand &command)
Process a drawing command from the runtime.
Definition drawingService.cpp:153
void clear()
Clear the canvas with optional background color.
Definition drawingService.cpp:49
void drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
Draw a line between two points.
Definition drawingService.cpp:101
void setPosition(int32_t x, int32_t y)
Set the current drawing position.
Definition drawingService.cpp:37
void drawRectangle(int32_t x, int32_t y, int32_t width, int32_t height, bool filled=false)
Draw a rectangle at the specified position.
Definition drawingService.cpp:84
nsbaci::types::Size getCanvasSize() const
Get the canvas size.
Definition drawingService.h:225
int32_t getLineWidth() const
Get the current line width.
Definition drawingService.h:143
void reset()
Reset the drawing service to initial state.
Definition drawingService.cpp:145
void drawText(int32_t x, int32_t y, const std::string &text, int32_t fontSize=12)
Draw text at the specified position.
Definition drawingService.cpp:124
void drawEllipse(int32_t centerX, int32_t centerY, int32_t radiusX, int32_t radiusY, bool filled=false)
Draw an ellipse at the specified position.
Definition drawingService.cpp:108
void drawShape(const nsbaci::types::Shape &shape)
Draw a generic shape.
Definition drawingService.cpp:132
void setCanvasSize(int32_t width, int32_t height)
Set the canvas size.
Definition drawingService.cpp:140
void drawCircle(int32_t centerX, int32_t centerY, int32_t radius, bool filled=false)
Draw a circle at the specified position.
Definition drawingService.cpp:76
void refresh()
Request a canvas refresh/redraw.
Definition drawingService.cpp:64
void canvasSizeChanged(const nsbaci::types::Size &size)
Emitted when canvas size changes.
void setLineWidth(int32_t width)
Set the line thickness for subsequent drawings.
Definition drawingService.cpp:69
void drawPixel(int32_t x, int32_t y)
Draw a single pixel at the specified position.
Definition drawingService.cpp:117
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.
Definition drawingService.cpp:92
void refreshRequested()
Emitted when the canvas should refresh.
nsbaci::types::Point getCurrentPosition() const
Get the current drawing position.
Definition drawingService.h:108
void fill()
Fill the entire canvas with the current color.
Definition drawingService.cpp:60
Type definitions for drawing-related operations.
Services namespace containing all backend service implementations.
Definition compilerService.cpp:15
std::variant< Circle, Rectangle, Triangle, Line, Ellipse, Pixel, DrawText > Shape
Variant type for all drawable shapes.
Definition drawingTypes.h:203
RGB color representation with values from 0-255.
Definition drawingTypes.h:31
Represents a single drawing command to be executed.
Definition drawingTypes.h:240
Complete drawable object with shape, color, and visibility.
Definition drawingTypes.h:209
2D point/position representation.
Definition drawingTypes.h:69
2D size representation.
Definition drawingTypes.h:93