IntelliPhoto 0.7

PaintingArea.cpp
Go to the documentation of this file.
1 // ---------- PaintingArea.cpp ----------
2 #include "string.h"
3
4 #include <vector>
5
6 #include <QtWidgets>
7 #include <QPoint>
8 #include <QRect>
9
10 #include "PaintingArea.h"
11 #include "Image/IntelliRasterImage.h"
12 #include "Image/IntelliShapedImage.h"
13 #include "Tool/IntelliToolPen.h"
14 #include "Tool/IntelliToolPlain.h"
15 #include "Tool/IntelliToolLine.h"
16 #include "Tool/IntelliToolCircle.h"
17 #include "Tool/IntelliToolRectangle.h"
18 #include "Tool/IntelliToolFloodFill.h"
19 #include "Tool/IntelliToolPolygon.h"
20 #include "Tool/IntelliToolGradient.h"
21 #include "GUI/IntelliPhotoGui.h"
22
23 LayerObject::LayerObject(){
24
25 }
26
27 LayerObject::LayerObject(const LayerObject& layer){
28 if(layer.image->getTypeOfImage()==ImageType::RASTERIMAGE) {
29 this->image = new IntelliRasterImage(*dynamic_cast<IntelliRasterImage*>(layer.image));
30 }else if(layer.image->getTypeOfImage()==ImageType::SHAPEDIMAGE) {
31 this->image = new IntelliShapedImage(*dynamic_cast<IntelliShapedImage*>(layer.image));
32 }
33 this->width = layer.width;
34 this->height = layer.height;
35 this->widthOffset = layer.widthOffset;
36 this->heightOffset = layer.heightOffset;
37 this->alpha = layer.alpha;
38 }
39
40 PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
41 : QLabel(parent){
42 this->Tool = nullptr;
43 this->setCanvasDimensions(maxWidth, maxHeight);
44 activeLayer = -1;
45 }
46
47 PaintingArea::~PaintingArea(){
48 delete Tool;
49 }
50
51 void PaintingArea::setRenderSettings(bool isFastRenderingOn){
52 bool ToolIsActive;
53
54 if(Tool!=nullptr) {
55 ToolIsActive = Tool->getIsDrawing();
56 }
57 else{
58 ToolIsActive = false;
59 }
60 if(isFastRenderingOn != renderSettings.isFastRenderering() && !ToolIsActive) {
61 renderSettings.setFastRendering(isFastRenderingOn);
62 for(auto& layer : layerBundle) {
63 layer.image->updateRendererSetting(isFastRenderingOn);
64 }
65 }
66 }
67
68 bool PaintingArea::getRenderSettings(){
69 return this->renderSettings.isFastRenderering();
70 }
71
72 void PaintingArea::setCanvasDimensions(int maxWidth, int maxHeight){
73 //set standart parameter
74 this->maxWidth = maxWidth;
75 this->maxHeight = maxHeight;
76 Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
77
78 this->offsetXDimension = maxWidth / 2;
79 this->offsetYDimension = maxHeight / 2;
80
81 // Roots the widget to the top left even if resized
82 setAttribute(Qt::WA_StaticContents);
83
84 }
85
86 void PaintingArea::drawPixelOntoActive(QColor color, QPoint point){
87 layerBundle[static_cast<size_t>(activeLayer)].image->drawPixel(point, color);
88 }
89
90 void PaintingArea::setPolygonDataToActive(std::vector<QPoint> points){
91 layerBundle[static_cast<size_t>(activeLayer)].image->setPolygon(points);
92 }
93
94 int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset,int alpha, ImageType type){
95 LayerObject newLayer;
96 updateTools();
97 newLayer.width = width;
98 newLayer.height = height;
99 newLayer.widthOffset = widthOffset;
100 newLayer.heightOffset = heightOffset;
101 newLayer.alpha = alpha;
102 if(type==ImageType::RASTERIMAGE) {
103 newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering());
104 }else if(type==ImageType::SHAPEDIMAGE) {
105 newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering());
106 }
107 this->layerBundle.push_back(newLayer);
108 activeLayer = static_cast<int>(layerBundle.size()) - 1;
109 return activeLayer;
110 }
111
112
113 void PaintingArea::deleteLayer(int idx, bool isTool){
114 if(!isTool) {
115 updateTools();
116 }
117 if(idx<static_cast<int>(layerBundle.size())&&idx>=0) {
118 this->layerBundle.erase(layerBundle.begin() + idx);
119 if(activeLayer>=idx) {
120 activeLayer--;
121 }
122 if(activeLayer < 0 && layerBundle.size()) {
123 activeLayer = 0;
124 }
125 }
126 }
127
128 void PaintingArea::slotDeleteActiveLayer(){
129 if(activeLayer>=0 && activeLayer < static_cast<int>(layerBundle.size())) {
130 this->layerBundle.erase(layerBundle.begin() + activeLayer);
131 activeLayer--;
132 }
133 historyadd();
134 }
135
136 void PaintingArea::setLayerActive(int idx){
137 updateTools();
138 if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
139 this->activeLayer = idx;
140 }
141 }
142
143 void PaintingArea::setLayerAlpha(int idx, int alpha){
144 if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
145 if(alpha>=0 && alpha<=255) {
146 layerBundle[static_cast<size_t>(idx)].alpha = alpha;
147 }
148 }
149 }
150 void PaintingArea::setPolygon(int idx){
151 if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
152 if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==ImageType::SHAPEDIMAGE) {
153 delete this->Tool;
154 this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
155 isSettingPolygon = true;
156 this->guiReference->setToolWidth(5);
157 }
158 }
159 }
160
161 // Used to load the image and place it in the widget
162 bool PaintingArea::open(const QString &filePath){
163 if(this->activeLayer==-1) {
164 return false;
165 }
166 IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
167 bool open = active->loadImage(filePath);
168 active->calculateVisiblity();
169 update();
170 return open;
171 }
172
173 void PaintingArea::deleteAllLayers(){
174 for(auto layer: layerBundle) {
175 delete layer.image;
176 }
177 layerBundle.clear();
178 }
179
180 // Save the current image
181 bool PaintingArea::save(const QString &filePath, const char*fileFormat){
182 if(layerBundle.size()==0) {
183 return false;
184 }
185 this->drawLayers(true);
186
187 if(!strcmp(fileFormat,"PNG")) {
188 QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
189 fileFormat = "png";
190 if (visibleImage.save(filePath, fileFormat)) {
191 return true;
192 } else {
193 return false;
194 }
195 }
196
197 if (Canvas->save(filePath, fileFormat)) {
198 return true;
199 } else {
200 return false;
201 }
202 }
203
204 void PaintingArea::movePositionActive(int x, int y){
205 updateTools();
206 layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
207 layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
208 historyadd();
209 }
210
211 void PaintingArea::moveActiveLayer(int idx){
212 updateTools();
213 if(idx==1) {
214 this->selectLayerUp();
215 }else if(idx==-1) {
216 this->selectLayerDown();
217 }
218 guiReference->UpdateGui();
219 historyadd();
220 }
221
222 void PaintingArea::slotActivateLayer(int a){
223 updateTools();
224 if(a>=0 && a < static_cast<int>(layerBundle.size())) {
225 this->setLayerActive(a);
226 }
227 }
228
229 void PaintingArea::colorPickerSetFirstColor(){
230 QColor clr = QColorDialog::getColor(colorPicker.getFirstColor(), nullptr, "Main Color", QColorDialog::DontUseNativeDialog);
231 this->colorPicker.setFirstColor(clr);
232 }
233
234 void PaintingArea::colorPickerSetSecondColor(){
235 QColor clr = QColorDialog::getColor(colorPicker.getSecondColor(), nullptr, "Secondary Color", QColorDialog::DontUseNativeDialog);
236 this->colorPicker.setSecondColor(clr);
237 }
238
239 void PaintingArea::colorPickerSwapColors(){
240 this->colorPicker.swapColors();
241 }
242
243 void PaintingArea::createPenTool(){
244 delete this->Tool;
245 Tool = new IntelliToolPen(this, &colorPicker, &Toolsettings);
246 }
247
248 void PaintingArea::createPlainTool(){
249 delete this->Tool;
250 Tool = new IntelliToolPlainTool(this, &colorPicker, &Toolsettings);
251 }
252
253 void PaintingArea::createLineTool(){
254 delete this->Tool;
255 Tool = new IntelliToolLine(this, &colorPicker, &Toolsettings);
256 }
257
258 void PaintingArea::createRectangleTool(){
259 delete this->Tool;
260 Tool = new IntelliToolRectangle(this, &colorPicker, &Toolsettings);
261 }
262
263 void PaintingArea::createCircleTool(){
264 delete this->Tool;
265 Tool = new IntelliToolCircle(this, &colorPicker, &Toolsettings);
266 }
267 void PaintingArea::createPolygonTool(){
268 delete this->Tool;
269 Tool = new IntelliToolPolygon(this, &colorPicker, &Toolsettings);
270 }
271
272 void PaintingArea::createFloodFillTool(){
273 delete this->Tool;
274 Tool = new IntelliToolFloodFill(this, &colorPicker, &Toolsettings);
275 }
276
277 void PaintingArea::createGradientTool(){
278 delete this->Tool;
279 Tool = new IntelliToolGradient(this, &colorPicker, &Toolsettings);
280 }
281
282 int PaintingArea::getWidthOfActive(){
283 return this->layerBundle[static_cast<size_t>(activeLayer)].width;
284 }
285
286 int PaintingArea::getHeightOfActive(){
287 return this->layerBundle[static_cast<size_t>(activeLayer)].height;
288 }
289
290 int PaintingArea::getMaxWidth(){
291 return this->maxWidth;
292 }
293
294 int PaintingArea::getMaxHeight(){
295 return this->maxHeight;
296 }
297
298 ImageType PaintingArea::getTypeOfImageActiveLayer(){
299 return this->layerBundle[static_cast<size_t>(activeLayer)].image->getTypeOfImage();
300 }
301
302 std::vector<QPoint> PaintingArea::getPolygonDataOfActiveLayer(){
303 return this->layerBundle[static_cast<size_t>(activeLayer)].image->getPolygonData();
304 }
305
306 // If a mouse button is pressed check if it was the
307 // left button and if so store the current position
308 // Set that we are currently drawing
309 void PaintingArea::mousePressEvent(QMouseEvent*event){
310 if(this->activeLayer < 0) {
311 return;
312 }
313 if(Tool == nullptr)
314 return;
315 int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
316 int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
317 if(event->button() == Qt::LeftButton) {
318 Tool->onMouseLeftPressed(x, y);
319 }else if(event->button() == Qt::RightButton) {
320 Tool->onMouseRightPressed(x, y);
321 }
322 update();
323 }
324
325 // When the mouse moves if the left button is clicked
326 // we call the drawline function which draws a line
327 // from the last position to the current
328 void PaintingArea::mouseMoveEvent(QMouseEvent*event){
329 if(this->activeLayer < 0) {
330 return;
331 }
332 if(Tool == nullptr)
333 return;
334 int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
335 int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
336 Tool->onMouseMoved(x, y);
337 update();
338 }
339
340 // If the button is released we set variables to stop drawing
341 void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
342 if(this->activeLayer < 0)
343 return;
344 if(Tool == nullptr)
345 return;
346 int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
347 int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
348 if(event->button() == Qt::LeftButton) {
349 Tool->onMouseLeftReleased(x, y);
350 }else if(event->button() == Qt::RightButton) {
351 Tool->onMouseRightReleased(x, y);
352 }
353 update();
354 }
355
356 void PaintingArea::wheelEvent(QWheelEvent*event){
357 if(this->activeLayer < 0)
358 return;
359 if(this->Tool != nullptr) {
360 QPoint numDegrees = event->angleDelta() / 8;
361 if(!numDegrees.isNull()) {
362 QPoint numSteps = numDegrees / 15;
363 Tool->onWheelScrolled(numSteps.y() * -1);
364 }
365 }
366 }
367
368 // QPainter provides functions to draw on the widget
369 // The QPaintEvent is sent to widgets that need to
370 // update themselves
371 void PaintingArea::paintEvent(QPaintEvent*event){
372 this->setFixedSize(QSize(maxWidth * 2,maxHeight * 2));
373 this->drawLayers();
374
375 QPainter painter(this);
376
377 //insert zoom factor here
378 painter.scale(1,1);
379
380 //calulate image here for scroll
381 //Todo set offset in first to parameters and calulate them into mouse position
382 painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension);
383 update();
384 }
385
386 void PaintingArea::selectLayerUp(){
387 updateTools();
388 if(activeLayer != -1 && static_cast<size_t>(activeLayer)<layerBundle.size() - 1) {
389 std::swap(layerBundle[static_cast<size_t>(activeLayer)], layerBundle[static_cast<size_t>(activeLayer + 1)]);
390 activeLayer++;
391 }
392 }
393
394 void PaintingArea::selectLayerDown(){
395 updateTools();
396 if(activeLayer>0) {
397 std::swap(layerBundle[static_cast<size_t>(activeLayer)], layerBundle[static_cast<size_t>(activeLayer - 1)]);
398 activeLayer--;
399 }
400 }
401
402 void PaintingArea::drawLayers(bool forSaving){
403 if(forSaving) {
404 Canvas->fill(Qt::GlobalColor::transparent);
405 }else{
406 Canvas->fill(Qt::GlobalColor::black);
407 }
408 for(size_t i = 0; i<layerBundle.size(); i++) {
409 LayerObject layer = layerBundle[i];
410 QImage cpy = layer.image->getDisplayable(layer.alpha);
411 QColor clr_0;
412 QColor clr_1;
413 for(int y = 0; y<layer.height; y++) {
414 if(layer.heightOffset + y<0) continue;
415 if(layer.heightOffset + y>=maxHeight) break;
416 for(int x = 0; x<layer.width; x++) {
417 if(layer.widthOffset + x<0) continue;
418 if(layer.widthOffset + x>=maxWidth) break;
419 clr_0 = Canvas->pixelColor(layer.widthOffset + x, layer.heightOffset + y);
420 clr_1 = cpy.pixelColor(x,y);
421 float t = static_cast<float>(clr_1.alpha()) / 255.f;
422 int r = static_cast<int>(static_cast<float>(clr_1.red()) * (t) + static_cast<float>(clr_0.red()) * (1.f - t) + 0.5f);
423 int g = static_cast<int>(static_cast<float>(clr_1.green()) * (t) + static_cast<float>(clr_0.green()) * (1.f - t) + 0.5f);
424 int b = static_cast<int>(static_cast<float>(clr_1.blue()) * (t) + static_cast<float>(clr_0.blue() * (1.f - t)) + 0.5f);
425 int a = std::min(clr_0.alpha() + clr_1.alpha(), 255);
426 clr_0.setRed(r);
427 clr_0.setGreen(g);
428 clr_0.setBlue(b);
429 clr_0.setAlpha(a);
430
431 Canvas->setPixelColor(layer.widthOffset + x, layer.heightOffset + y, clr_0);
432 }
433 }
434 }
435 }
436
437 bool PaintingArea::createTempTopLayer(int idx){
438 if(idx>=0) {
439 LayerObject newLayer;
440 newLayer.alpha = 255;
441 newLayer.height = layerBundle[static_cast<size_t>(idx)].height;
442 newLayer.width = layerBundle[static_cast<size_t>(idx)].width;
443 newLayer.heightOffset = layerBundle[static_cast<size_t>(idx)].heightOffset;
444 newLayer.widthOffset = layerBundle[static_cast<size_t>(idx)].widthOffset;
445 newLayer.image = layerBundle[static_cast<size_t>(idx)].image->getDeepCopy();
446 layerBundle.insert(layerBundle.begin() + idx + 1,newLayer);
447 return true;
448 }
449 return false;
450 }
451
452 IntelliTool* PaintingArea::copyActiveTool(){
453 switch(Tool->getTooltype()) {
454 case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(this,&colorPicker, &Toolsettings);
455 case IntelliTool::Tooltype::FLOODFILL: return new IntelliToolFloodFill(this,&colorPicker, &Toolsettings);
456 case IntelliTool::Tooltype::LINE: return new IntelliToolLine(this,&colorPicker, &Toolsettings);
457 case IntelliTool::Tooltype::PEN: return new IntelliToolPen(this,&colorPicker, &Toolsettings);
458 case IntelliTool::Tooltype::PLAIN: return new IntelliToolPlainTool(this,&colorPicker, &Toolsettings);
459 case IntelliTool::Tooltype::POLYGON: return new IntelliToolPolygon(this,&colorPicker, &Toolsettings);
460 case IntelliTool::Tooltype::RECTANGLE: return new IntelliToolRectangle(this,&colorPicker, &Toolsettings);
461 default: return nullptr;
462 }
463 }
464
465 int PaintingArea::getIndexOfActiveLayer(){
466 return activeLayer;
467 }
468
469 IntelliImage* PaintingArea::getImageOfActiveLayer(){
470 if(activeLayer<0) {
471 return nullptr;
472 }
473 return layerBundle[static_cast<size_t>(activeLayer)].image;
474 }
475
476 QImage PaintingArea::getImageDataOfActiveLayer(){
477 QImage returnImage;
478 if(activeLayer<0) {
479 returnImage = QImage(QSize(10,10),QImage::Format_ARGB32);
480 returnImage.fill(QColor(255,255,255,255));
481 }
482 else{
483 returnImage = layerBundle[static_cast<size_t>(activeLayer)].image->getImageData();
484 if(renderSettings.isFastRenderering()) {
485 returnImage = returnImage.convertToFormat(QImage::Format_ARGB32);
486 }
487 }
488 return returnImage;
489 }
490
491 std::vector<LayerObject>* PaintingArea::getLayerBundle(){
492 return &layerBundle;
493 }
494
495 void PaintingArea::updateTools(){
496 if(Tool!=nullptr) {
497 if(Tool->getIsDrawing()) {
498 IntelliTool* temp = copyActiveTool();
499 delete this->Tool;
500 this->Tool = temp;
501 }
502 if(isSettingPolygon) {
503 delete this->Tool;
504 this->Tool = nullptr;
505 isSettingPolygon = false;
506 }
507 }
508 }
509
510 void PaintingArea::historyadd(){
511
512 historyPresent++;
513 if (historyPresent == 100) {
514 historyPresent = 0;
515 }
516 historyMaxFuture = historyPresent;
517 if (historyPresent == historyMaxPast) {
518 historyMaxPast++;
519 if (historyMaxPast == 100) {
520 historyMaxPast = 0;
521 }
522 }
523 history[static_cast<size_t>(historyPresent)] = layerBundle;
524 }
525
526 void PaintingArea::historyGoBack(){
527 if (historyPresent != historyMaxPast) {
528 if (--historyPresent == -1)
529 historyPresent = 99;
530 if (activeLayer == -1)
531 activeLayer = 0;
532 if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
533 activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
534 if (history[static_cast<size_t>(historyPresent)].size() == 0)
535 activeLayer = -1;
536 layerBundle = history[static_cast<size_t>(historyPresent)];
537 }
538 this->guiReference->UpdateGui();
539 }
540
541 void PaintingArea::historyGoForward(){
542 if (historyPresent != historyMaxFuture) {
543 if (++historyPresent == 100)
544 historyPresent = 0;
545 if (activeLayer == -1)
546 activeLayer = 0;
547 if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
548 activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
549 if (history[static_cast<size_t>(historyPresent)].size() == 0)
550 activeLayer = -1;
551 layerBundle = history[static_cast<size_t>(historyPresent)];
552 }
553 this->guiReference->UpdateGui();
554 }
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:282
IntelliTool::Tooltype::PEN
@ PEN
PaintingArea::createCircleTool
void createCircleTool()
createCircleTool creates a Circle Tool.
Definition: PaintingArea.cpp:263
IntelliTool::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y)
A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on....
Definition: IntelliTool.cpp:19
IntelliColorPicker::getFirstColor
QColor getFirstColor() const
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:15
ImageType::RASTERIMAGE
@ RASTERIMAGE
IntelliTool::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y)
A function managing the left click Released of a Mouse. Call this in child classes!
Definition: IntelliTool.cpp:37
ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:22
PaintingArea::setRenderSettings
void setRenderSettings(bool isFastRenderingOn)
setRenderSettings updates all Images to the new Rendersetting.
Definition: PaintingArea.cpp:51
PaintingArea::getImageOfActiveLayer
IntelliImage * getImageOfActiveLayer()
getImageOfActiveLayer returns the image of the active Layer.
Definition: PaintingArea.cpp:469
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
mouseReleaseEvent handles a mouse released event
Definition: PaintingArea.cpp:341
PaintingArea::createRectangleTool
void createRectangleTool()
createRectangleTool creates a Rectangle Tool.
Definition: PaintingArea.cpp:258
IntelliToolPolygon.h
IntelliTool::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y)
A function managing the left click Pressed of a Mouse. Resetting the current draw....
Definition: IntelliTool.cpp:30
IntelliTool::getIsDrawing
bool getIsDrawing() const
getIsDrawing returns if the tool is currently drawing
Definition: IntelliTool.cpp:105
PaintingArea::getMaxWidth
int getMaxWidth()
getMaxWidth gets the max width of the Canvas.
Definition: PaintingArea.cpp:290
IntelliShapedImage.h
IntelliRenderSettings::isFastRenderering
bool isFastRenderering() const
The getfastRenderer gets the value of the flag for the fastRenderer setting.
Definition: IntelliRenderSettings.cpp:12
PaintingArea::save
bool save(const QString &filePath, const char *fileFormat)
The save method is used for exporting the current project as one picture.
Definition: PaintingArea.cpp:181
IntelliTool::getTooltype
Tooltype getTooltype() const
getTooltype returns the tools type
Definition: IntelliTool.cpp:101
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:143
IntelliTool::Tooltype::FLOODFILL
@ FLOODFILL
PaintingArea::getPolygonDataOfActiveLayer
std::vector< QPoint > getPolygonDataOfActiveLayer()
getPolygonDataOfActiveLayer get the polygon data of the active Layer.
Definition: PaintingArea.cpp:302
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:136
LayerObject::widthOffset
int widthOffset
widthOffset - Stores the number of pixles from the left side of the painting area.
Definition: PaintingArea.h:39
PaintingArea::getMaxHeight
int getMaxHeight()
getMaxHeight gets the max height of the Canvas.
Definition: PaintingArea.cpp:294
PaintingArea::deleteLayer
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:113
IntelliToolPlainTool
The IntelliToolPlainTool class represents a tool to fill the whole canvas with one color.
Definition: IntelliToolPlain.h:13
IntelliColorPicker::setSecondColor
void setSecondColor(QColor Color)
A function to set the secondary color.
Definition: IntelliColorPicker.cpp:27
IntelliShapedImage
The IntelliShapedImage manages a Shapedimage.
Definition: IntelliShapedImage.h:13
LayerObject::heightOffset
int heightOffset
heightOffset - Stores the number of pixles from the top of the painting area.
Definition: PaintingArea.h:43
PaintingArea::getHeightOfActive
int getHeightOfActive()
The getHeightOfActive gets the vertical dimensions of the active layer.
Definition: PaintingArea.cpp:286
IntelliToolFloodFill.h
IntelliImage::getDisplayable
virtual QImage getDisplayable(const QSize &displaySize, int alpha)=0
A function returning the displayable ImageData in a requested transparence and size.
PaintingArea::createPlainTool
void createPlainTool()
createPlainTool creates a Plain Tool.
Definition: PaintingArea.cpp:248
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
wheelEvent handles a mouse wheel event
Definition: PaintingArea.cpp:356
IntelliImage::getTypeOfImage
virtual ImageType getTypeOfImage()
Definition: IntelliImage.h:139
LayerObject
The LayerObject struct holds all the information needed to construct a layer.
Definition: PaintingArea.h:23
PaintingArea::createPenTool
void createPenTool()
createPenTool creates a Pen Tool.
Definition: PaintingArea.cpp:243
IntelliToolPlain.h
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
mousePressEvent handles a mouse pressed event.
Definition: PaintingArea.cpp:309
IntelliRasterImage.h
LayerObject::alpha
int alpha
alpha - Stores the alpha value of the layer (default=255).
Definition: PaintingArea.h:47
IntelliColorPicker::getSecondColor
QColor getSecondColor() const
A function to read the secondary selected color.
Definition: IntelliColorPicker.cpp:19
PaintingArea::getIndexOfActiveLayer
int getIndexOfActiveLayer()
getIndexOfActiveLayer returns the index of athe active Layer.
Definition: PaintingArea.cpp:465
PaintingArea::drawPixelOntoActive
void drawPixelOntoActive(QColor color, QPoint point)
drawPixelOntoActive draws a pixel onto the image data of the active Layer.
Definition: PaintingArea.cpp:86
PaintingArea::historyGoBack
void historyGoBack()
historyGoBack go back in hisotry
Definition: PaintingArea.cpp:526
IntelliToolRectangle
The IntelliToolRectangle class represents a tool to draw a rectangle.
Definition: IntelliToolRectangle.h:15
PaintingArea::createLineTool
void createLineTool()
createLineTool creates a Line Tool.
Definition: PaintingArea.cpp:253
IntelliToolLine.h
IntelliToolPen
The IntelliToolPen class represents a tool to draw a line.
Definition: IntelliToolPen.h:14
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:234
IntelliTool::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y)
A function managing the right click Released of a Mouse. Merging the Canvas to Active....
Definition: IntelliTool.cpp:26
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:229
IntelliTool::Tooltype::PLAIN
@ PLAIN
IntelliTool::Tooltype::POLYGON
@ POLYGON
PaintingArea::getLayerBundle
std::vector< LayerObject > * getLayerBundle()
getLayerBundle returns the real active layerbundle (care!)
Definition: PaintingArea.cpp:491
LayerObject::width
int width
width - Stores the width of a layer in pixels.
Definition: PaintingArea.h:31
IntelliToolRectangle.h
PaintingArea::~PaintingArea
~PaintingArea() override
This deconstructor is used to clear up the memory and remove the currently active window.
Definition: PaintingArea.cpp:47
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
mouseMoveEvent handles a mouse moved event
Definition: PaintingArea.cpp:328
IntelliPhotoGui.h
IntelliColorPicker::setFirstColor
void setFirstColor(QColor Color)
A function to set the primary color.
Definition: IntelliColorPicker.cpp:23
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:17
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
The slotDeleteActiveLayer method handles the deletion of the active layer.
Definition: PaintingArea.cpp:128
ImageType::SHAPEDIMAGE
@ SHAPEDIMAGE
PaintingArea::getTypeOfImageActiveLayer
ImageType getTypeOfImageActiveLayer()
getTypeOfImageActiveLayer get the type of the active Layer.
Definition: PaintingArea.cpp:298
IntelliPhotoGui::setToolWidth
void setToolWidth(int value)
setToolWidth stes a width to the tool
Definition: IntelliPhotoGui.cpp:923
PaintingArea::open
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:162
PaintingArea::createPolygonTool
void createPolygonTool()
createPolygonTool creates a Polygon Tool.
Definition: PaintingArea.cpp:267
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:211
PaintingArea::colorPicker
IntelliColorPicker colorPicker
colorPicker a class to manage Tool color.
Definition: PaintingArea.h:286
PaintingArea::PaintingArea
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent=nullptr)
PaintingArea is the constructor of the PaintingArea class, which initiates the working environment.
Definition: PaintingArea.cpp:40
PaintingArea.h
LayerObject::height
int height
height - Stores the height of a layer in pixels.
Definition: PaintingArea.h:35
PaintingArea::deleteAllLayers
void deleteAllLayers()
deleteAllLayers deletes all layers
Definition: PaintingArea.cpp:173
PaintingArea::setCanvasDimensions
void setCanvasDimensions(int maxWidth, int maxHeight)
setCanvasDimensions sets the dimension of the Canvas
Definition: PaintingArea.cpp:72
PaintingArea::getImageDataOfActiveLayer
QImage getImageDataOfActiveLayer()
getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer ...
Definition: PaintingArea.cpp:476
PaintingArea::createFloodFillTool
void createFloodFillTool()
createFloodFillTool creates a Floodfill Tool.
Definition: PaintingArea.cpp:272
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:222
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
paintEvent handles a painting event
Definition: PaintingArea.cpp:371
IntelliRenderSettings::setFastRendering
void setFastRendering(bool Updatedsetting)
setFastRendering sets fastRendering to Updatedsetting.
Definition: IntelliRenderSettings.cpp:8
IntelliPhotoGui::UpdateGui
void UpdateGui()
UpdateGui a function to update all gui elements.
Definition: IntelliPhotoGui.cpp:932
IntelliTool::Tooltype::RECTANGLE
@ RECTANGLE
PaintingArea::getRenderSettings
bool getRenderSettings()
getRenderSettings updates all Images to the new Rendersetting.
Definition: PaintingArea.cpp:68
LayerObject::image
IntelliImage * image
image - Stores the imageData of the current LayerObject.
Definition: PaintingArea.h:27
IntelliImage::loadImage
virtual bool loadImage(const QString &filePath)
A function that loads and sclaes an image to the fitting dimensions.
Definition: IntelliImage.cpp:23
PaintingArea::Toolsettings
IntelliToolsettings Toolsettings
Toolsettings - a class to manage Tool settings.
Definition: PaintingArea.h:281
PaintingArea::setPolygon
void setPolygon(int idx)
setPolygon is used for setting polygondata, it only works on RASTER images
Definition: PaintingArea.cpp:150
IntelliTool::Tooltype::LINE
@ LINE
IntelliColorPicker::swapColors
void swapColors()
A function switching primary and secondary color.
Definition: IntelliColorPicker.cpp:11
IntelliToolFloodFill
The IntelliToolFloodFill class represents a tool to flood FIll a certian area.
Definition: IntelliToolFloodFill.h:14
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:239
IntelliToolPen.h
IntelliToolCircle
The IntelliToolCircle class represents a tool to draw a circle.
Definition: IntelliToolCircle.h:14
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:204
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:30
IntelliTool::onMouseMoved
virtual void onMouseMoved(int x, int y)
A function managing the mouse moved event. Call this in child classes!
Definition: IntelliTool.cpp:47
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, int alpha=255, ImageType type=ImageType::RASTERIMAGE)
The addLayer adds a layer to the current project/ painting area.
Definition: PaintingArea.cpp:94
IntelliToolPolygon
The IntelliToolPolygon managed the Drawing of Polygonforms.
Definition: IntelliToolPolygon.h:15
PaintingArea::historyGoForward
void historyGoForward()
historyGoForward a function to undo the return of the previous state of the project.
Definition: PaintingArea.cpp:541
IntelliImage::calculateVisiblity
virtual void calculateVisiblity()=0
An abstract function that calculates the visiblity of the Image data if needed.
PaintingArea::historyadd
void historyadd()
historyadd adds an hisotry step
Definition: PaintingArea.cpp:510
LayerObject::LayerObject
LayerObject()
Definition: PaintingArea.cpp:23
IntelliTool::onWheelScrolled
virtual void onWheelScrolled(int value)
A function managing the scroll event. A positive value means scrolling outwards. Call this in child c...
Definition: IntelliTool.cpp:52
IntelliRasterImage
The IntelliRasterImage manages a RASTERIMAGE.
Definition: IntelliRasterImage.h:12
PaintingArea::setPolygonDataToActive
void setPolygonDataToActive(std::vector< QPoint > points)
setPolygonDataToActive sets polygondata to the active Layer.
Definition: PaintingArea.cpp:90
IntelliToolCircle.h
PaintingArea::createGradientTool
void createGradientTool()
createGradientTool creates a Gradient Tool.
Definition: PaintingArea.cpp:277
IntelliToolGradient
The IntelliToolGradient class that represents a gradient call.
Definition: IntelliToolGradient.h:7
IntelliToolGradient.h
IntelliTool::Tooltype::CIRCLE
@ CIRCLE
IntelliToolLine
The IntelliToolFloodFill class represents a tool to draw a line.
Definition: IntelliToolLine.h:13