IntelliPhoto 0.7

PaintingArea.h
Go to the documentation of this file.
1
2 #ifndef PaintingArea_H
3 #define PaintingArea_H
4
5 #include <QColor>
6 #include <QImage>
7 #include <QPoint>
8 #include <QWidget>
9 #include <QList>
10 #include <QLabel>
11 #include "Image/IntelliImage.h"
12 #include "Image/IntelliRasterImage.h"
13 #include "Image/IntelliShapedImage.h"
14 #include "Tool/IntelliTool.h"
15 #include "IntelliHelper/IntelliColorPicker.h"
16
17 //for unit testing
18 class UnitTest;
19 class IntelliPhotoGui;
23 struct LayerObject {
27 IntelliImage* image;
31 int width;
35 int height;
39 int widthOffset;
43 int heightOffset;
47 int alpha = 255;
48
49 LayerObject();
50
51 LayerObject(const LayerObject& layer);
52 };
53
57 class PaintingArea : public QLabel
58 {
59 friend UnitTest;
60 // Declares our class as a QObject which is the base class
61 // for all Qt objects
62 // QObjects handle events
63 Q_OBJECT
64 friend IntelliTool;
65 friend IntelliPhotoGui;
66 public:
73 PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
74
78 ~PaintingArea() override;
79
84 void setRenderSettings(bool isFastRenderingOn);
85
90 bool getRenderSettings();
91
97 bool open(const QString &filePath);
104 bool save(const QString &filePath, const char*fileFormat);
105
109 void deleteAllLayers();
120 int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, int alpha = 255, ImageType type = ImageType::RASTERIMAGE);
131 int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
137 void deleteLayer(int idx, bool isTool = false);
142 void setLayerActive(int idx);
148 void setLayerAlpha(int idx, int alpha);
153 void setPolygon(int idx);
159 void movePositionActive(int x, int y);
164 void moveActiveLayer(int idx);
165
169 void colorPickerSetFirstColor();
173 void colorPickerSetSecondColor();
177 void colorPickerSwapColors();
178
182 void createPenTool();
183
187 void createPlainTool();
188
192 void createLineTool();
193
197 void createRectangleTool();
198
202 void createCircleTool();
203
207 void createPolygonTool();
208
212 void createFloodFillTool();
213
217 void createGradientTool();
218
223 int getWidthOfActive();
228 int getHeightOfActive();
229
234 int getMaxWidth();
235
240 int getMaxHeight();
241
246 ImageType getTypeOfImageActiveLayer();
247
252 std::vector<QPoint> getPolygonDataOfActiveLayer();
253
258 int getIndexOfActiveLayer();
259
264 IntelliImage* getImageOfActiveLayer();
265
270 QImage getImageDataOfActiveLayer();
271
276 std::vector<LayerObject>* getLayerBundle();
277
281 IntelliToolsettings Toolsettings;
282
286 IntelliColorPicker colorPicker;
287
291 void historyadd();
292
296 void historyGoBack();
297
301 void historyGoForward();
302
308 void setCanvasDimensions(int maxWidth, int maxHeight);
309
315 void drawPixelOntoActive(QColor color, QPoint point);
316
321 void setPolygonDataToActive(std::vector<QPoint> points);
322 public slots:
327 void slotActivateLayer(int a);
331 void slotDeleteActiveLayer();
332
333 protected:
338 void mousePressEvent(QMouseEvent*event) override;
339
344 void mouseMoveEvent(QMouseEvent*event) override;
345
350 void mouseReleaseEvent(QMouseEvent*event) override;
351
356 void wheelEvent(QWheelEvent*event) override;
357
362 void paintEvent(QPaintEvent*event) override;
363
364 private:
368 int offsetXDimension;
369
373 int offsetYDimension;
374
378 void selectLayerUp();
379
383 void selectLayerDown();
384
389 IntelliTool* copyActiveTool();
390
394 QImage* Canvas;
395
399 QImage ScaledCanvas;
400
404 int maxWidth;
405
409 int maxHeight;
410
414 bool isSettingPolygon = false;
415
419 IntelliRenderSettings renderSettings;
420
424 IntelliTool* Tool;
425
429 IntelliPhotoGui* guiReference;
430
434 std::vector<LayerObject> layerBundle;
435
439 int activeLayer = -1;
440
445 void drawLayers(bool forSaving = false);
446
452 bool createTempTopLayer(int idx);
453
457 void updateTools();
458
462 std::vector<LayerObject> history[100] = {layerBundle};
463
467 int historyMaxPast = 0;
468
472 int historyMaxFuture = 0;
473
477 int historyPresent = 0;
478
479 };
480
481 #endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:282
PaintingArea::createCircleTool
void createCircleTool()
createCircleTool creates a Circle Tool.
Definition: PaintingArea.cpp:263
ImageType::RASTERIMAGE
@ RASTERIMAGE
ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:22
PaintingArea::addLayerAt
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::RASTERIMAGE)
The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer...
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
IntelliTool.h
PaintingArea::getMaxWidth
int getMaxWidth()
getMaxWidth gets the max width of the Canvas.
Definition: PaintingArea.cpp:290
IntelliShapedImage.h
IntelliImage.h
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
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:143
PaintingArea::getPolygonDataOfActiveLayer
std::vector< QPoint > getPolygonDataOfActiveLayer()
getPolygonDataOfActiveLayer get the polygon data of the active Layer.
Definition: PaintingArea.cpp:302
IntelliRenderSettings
The IntelliRenderSettings class which manages the render Settings.
Definition: IntelliRenderSettings.h:10
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
IntelliPhotoGui
The IntelliPhotoGui base class handles the graphical user interface and events for the intelliPhoto p...
Definition: IntelliPhotoGui.h:34
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
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
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:57
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
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
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::getIndexOfActiveLayer
int getIndexOfActiveLayer()
getIndexOfActiveLayer returns the index of athe active Layer.
Definition: PaintingArea.cpp:465
PaintingArea::historyGoBack
void historyGoBack()
historyGoBack go back in hisotry
Definition: PaintingArea.cpp:526
PaintingArea::createLineTool
void createLineTool()
createLineTool creates a Line Tool.
Definition: PaintingArea.cpp:253
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:234
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:229
IntelliColorPicker.h
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
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
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
PaintingArea::getTypeOfImageActiveLayer
ImageType getTypeOfImageActiveLayer()
getTypeOfImageActiveLayer get the type of the active Layer.
Definition: PaintingArea.cpp:298
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
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
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:14
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
paintEvent handles a painting event
Definition: PaintingArea.cpp:371
UnitTest
Definition: mainUnitTest.cpp:8
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
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
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:239
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
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
PaintingArea::historyGoForward
void historyGoForward()
historyGoForward a function to undo the return of the previous state of the project.
Definition: PaintingArea.cpp:541
PaintingArea::historyadd
void historyadd()
historyadd adds an hisotry step
Definition: PaintingArea.cpp:510
LayerObject::LayerObject
LayerObject()
Definition: PaintingArea.cpp:23
PaintingArea::setPolygonDataToActive
void setPolygonDataToActive(std::vector< QPoint > points)
setPolygonDataToActive sets polygondata to the active Layer.
Definition: PaintingArea.cpp:90
PaintingArea::createGradientTool
void createGradientTool()
createGradientTool creates a Gradient Tool.
Definition: PaintingArea.cpp:277
IntelliToolsettings
The IntelliToolsettings class managing the settings of the tools, independent of an existing tool.
Definition: IntelliToolsettings.h:9