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#include <memory>
19
20#include "drawingTypes.h"
21
26namespace nsbaci::services {
27
44class DrawingService : public QObject {
45 Q_OBJECT
46
47 public:
48 explicit DrawingService(QObject* parent = nullptr);
49 ~DrawingService() = default;
50
51 // QObject subclasses cannot be copied or moved
52 DrawingService(const DrawingService&) = delete;
53 DrawingService& operator=(const DrawingService&) = delete;
54 DrawingService(DrawingService&&) = delete;
55 DrawingService& operator=(DrawingService&&) = delete;
56
57 // ============== Color Management ==============
58
65 void setColor(uint8_t r, uint8_t g, uint8_t b);
66
74 void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
75
80 void setColor(const nsbaci::types::Color& color);
81
86 nsbaci::types::Color getCurrentColor() const { return currentColor_; }
87
88 // ============== Position Management ==============
89
95 void setPosition(int32_t x, int32_t y);
96
101 void setPosition(const nsbaci::types::Point& point);
102
107 nsbaci::types::Point getCurrentPosition() const { return currentPosition_; }
108
109 // ============== Canvas Operations ==============
110
114 void clear();
115
120 void clear(const nsbaci::types::Color& color);
121
125 void fill();
126
130 void refresh();
131
136 void setLineWidth(int32_t width);
137
142 int32_t getLineWidth() const { return lineWidth_; }
143
144 // ============== Shape Drawing ==============
145
153 void drawCircle(int32_t centerX, int32_t centerY, int32_t radius,
154 bool filled = false);
155
164 void drawRectangle(int32_t x, int32_t y, int32_t width, int32_t height,
165 bool filled = false);
166
174 void drawTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3,
175 int32_t y3, bool filled = false);
176
182 void drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
183
192 void drawEllipse(int32_t centerX, int32_t centerY, int32_t radiusX,
193 int32_t radiusY, bool filled = false);
194
200 void drawPixel(int32_t x, int32_t y);
201
209 void drawText(int32_t x, int32_t y, const std::string& text,
210 int32_t fontSize = 12);
211
216 void drawShape(const nsbaci::types::Shape& shape);
217
218 // ============== Canvas Configuration ==============
219
224 nsbaci::types::Size getCanvasSize() const { return canvasSize_; }
225
231 void setCanvasSize(int32_t width, int32_t height);
232
236 void reset();
237
246 void processCommand(const nsbaci::types::DrawCommand& command);
247
248 signals:
254
259 void clearRequested(const nsbaci::types::Color& backgroundColor);
260
266
271
277
278 private:
279 nsbaci::types::Color currentColor_{0, 0, 0}; // Default black
280 nsbaci::types::Point currentPosition_{0, 0}; // Default origin
281 int32_t lineWidth_ = 1; // Default line width
282 nsbaci::types::Size canvasSize_{800, 600}; // Default canvas size
283 nsbaci::types::Color backgroundColor_{255, 255, 255}; // Default white
284};
285
286} // namespace nsbaci::services
287
288#endif // NSBACI_SERVICES_DRAWINGSERVICE_H
nsbaci::types::Color getCurrentColor() const
Get the current drawing color.
Definition drawingService.h:86
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:224
int32_t getLineWidth() const
Get the current line width.
Definition drawingService.h:142
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:107
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:241
Complete drawable object with shape, color, and visibility.
Definition drawingTypes.h:210
2D point/position representation.
Definition drawingTypes.h:69
2D size representation.
Definition drawingTypes.h:93