IntelliPhoto  0.6
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 "GUI/IntelliPhotoGui.h"
11 #include "Image/IntelliImage.h"
14 #include "Tool/IntelliTool.h"
16 
17 //for unit testing
18 class UnitTest;
19 
23 struct LayerObject {
31  int width;
35  int height;
47  int alpha = 255;
48 };
49 
53 class PaintingArea : public QWidget
54 {
55 friend UnitTest;
56 // Declares our class as a QObject which is the base class
57 // for all Qt objects
58 // QObjects handle events
59 Q_OBJECT
60 friend IntelliTool;
61 friend IntelliPhotoGui;
62 public:
69 PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
70 
74 ~PaintingArea() override;
75 
80 void setRenderSettings(bool isFastRenderingOn);
81 
87 bool open(const QString &filePath);
94 bool save(const QString &filePath, const char*fileFormat);
95 
105 int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
116 int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
122 void deleteLayer(int idx, bool isTool = false);
127 void setLayerActive(int idx);
133 void setLayerAlpha(int idx, int alpha);
138 void setPolygon(int idx);
144 void movePositionActive(int x, int y);
149 void moveActiveLayer(int idx);
150 
162 void colorPickerSwapColors();
163 
164 void createPenTool();
165 void createPlainTool();
166 void createLineTool();
167 void createRectangleTool();
168 void createCircleTool();
169 void createPolygonTool();
170 void createFloodFillTool();
171 
176 int getWidthOfActive();
181 int getHeightOfActive();
182 
183 int getMaxWidth();
184 
185 int getMaxHeight();
186 
188 
189 std::vector<QPoint> getPolygonDataOfRealLayer();
190 
192 
194 
200 
203 
204 public slots:
209 void slotActivateLayer(int a);
213 void slotDeleteActiveLayer();
214 
215 protected:
216 void mousePressEvent(QMouseEvent*event) override;
217 void mouseMoveEvent(QMouseEvent*event) override;
218 void mouseReleaseEvent(QMouseEvent*event) override;
219 
220 void wheelEvent(QWheelEvent*event) override;
221 
222 void paintEvent(QPaintEvent*event) override;
223 
224 private:
225 void setLayerDimensions(int maxWidth, int maxHeight);
226 void selectLayerUp();
227 void selectLayerDown();
228 IntelliTool* copyActiveTool();
229 
230 QImage* Canvas;
231 int maxWidth;
232 int maxHeight;
233 
234 bool isSettingPolygon = false;
235 
236 IntelliRenderSettings renderSettings;
237 IntelliTool* Tool;
238 IntelliPhotoGui* DummyGui;
239 
240 std::vector<LayerObject> layerBundle;
241 int activeLayer = -1;
242 
243 void drawLayers(bool forSaving = false);
244 
245 bool createTempTopLayer(int idx);
246 
247 void updateTools();
248 };
249 
250 #endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:235
PaintingArea::createCircleTool
void createCircleTool()
Definition: PaintingArea.cpp:221
PaintingArea::setRenderSettings
void setRenderSettings(bool isFastRenderingOn)
setRenderSettings updates all Images to the new Rendersetting.
Definition: PaintingArea.cpp:34
PaintingArea::getImageOfActiveLayer
IntelliImage * getImageOfActiveLayer()
Definition: PaintingArea.cpp:416
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:294
PaintingArea::createRectangleTool
void createRectangleTool()
Definition: PaintingArea.cpp:216
IntelliTool.h
PaintingArea::getMaxWidth
int getMaxWidth()
Definition: PaintingArea.cpp:243
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:141
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:110
IntelliRenderSettings
Definition: IntelliRenderSettings.h:8
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:103
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()
Definition: PaintingArea.cpp:247
PaintingArea::deleteLayer
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:81
IntelliPhotoGui
The IntelliPhotoGui base class handles the graphical user interface and events for the intelliPhoto p...
Definition: IntelliPhotoGui.h:32
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:239
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:206
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: PaintingArea.cpp:309
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:53
LayerObject
The LayerObject struct holds all the information needed to construct a layer.
Definition: PaintingArea.h:23
PaintingArea::createPenTool
void createPenTool()
Definition: PaintingArea.cpp:201
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:262
IntelliRasterImage.h
LayerObject::alpha
int alpha
alpha - Stores the alpha value of the layer (default=255).
Definition: PaintingArea.h:47
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:211
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:192
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:187
PaintingArea::addLayerAt
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type=IntelliImage::ImageType::RASTERIMAGE)
The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer...
IntelliColorPicker.h
PaintingArea::getTypeOfImageRealLayer
IntelliImage::ImageType getTypeOfImageRealLayer()
Definition: PaintingArea.cpp:251
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:30
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:281
IntelliPhotoGui.h
PaintingArea::getNumberOfActiveLayer
int getNumberOfActiveLayer()
Definition: PaintingArea.cpp:412
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:96
PaintingArea::open
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:129
PaintingArea::createPolygonTool
void createPolygonTool()
Definition: PaintingArea.cpp:225
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:170
PaintingArea::colorPicker
IntelliColorPicker colorPicker
Definition: PaintingArea.h:202
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:22
LayerObject::height
int height
height - Stores the height of a layer in pixels.
Definition: PaintingArea.h:35
PaintingArea::getImageDataOfActiveLayer
QImage getImageDataOfActiveLayer()
getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer ...
Definition: PaintingArea.cpp:423
PaintingArea::createFloodFillTool
void createFloodFillTool()
Definition: PaintingArea.cpp:230
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:180
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:14
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
Definition: PaintingArea.cpp:324
IntelliImage::ImageType::RASTERIMAGE
@ RASTERIMAGE
UnitTest
Definition: mainUnitTest.cpp:8
LayerObject::image
IntelliImage * image
image - Stores the imageData of the current LayerObject.
Definition: PaintingArea.h:27
PaintingArea::getPolygonDataOfRealLayer
std::vector< QPoint > getPolygonDataOfRealLayer()
Definition: PaintingArea.cpp:255
PaintingArea::Toolsettings
IntelliToolsettings Toolsettings
Definition: PaintingArea.h:201
PaintingArea::setPolygon
void setPolygon(int idx)
setPolygon is used for setting polygondata, it only works on RASTER images
Definition: PaintingArea.cpp:117
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:197
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:164
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:22
IntelliToolsettings
Definition: IntelliToolsettings.h:7
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type=IntelliImage::ImageType::RASTERIMAGE)
The addLayer adds a layer to the current project/ painting area.
Definition: PaintingArea.cpp:62
IntelliImage::ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:30