IntelliPhoto  0.5
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 
25 struct LayerObject {
27  int width;
28  int height;
31  int alpha=255;
32 };
33 
37 class PaintingArea : public QWidget
38 {
39 // Declares our class as a QObject which is the base class
40 // for all Qt objects
41 // QObjects handle events
42 Q_OBJECT
43 friend IntelliTool;
44 friend IntelliPhotoGui;
45 public:
52 PaintingArea(int maxWidth=600, int maxHeight=600, QWidget*parent = nullptr);
53 
57 ~PaintingArea() override;
58 
59 // Handles all events
60 
66 bool open(const QString &filePath);
73 bool save(const QString &filePath, const char*fileFormat);
74 
84 int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
95 int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
100 void deleteLayer(int idx);
105 void setLayerActive(int idx);
111 void setLayerAlpha(int idx, int alpha);
119 void floodFill(int r, int g, int b, int a);
125 void movePositionActive(int x, int y);
130 void moveActiveLayer(int idx);
131 
132 //change properties of colorPicker
144 void colorPickerSwapColors();
145 
146 // Create tools
147 void createPenTool();
148 void createPlainTool();
149 void createLineTool();
150 void createRectangleTool();
151 void createCircleTool();
152 void createPolygonTool();
153 void createFloodFillTool();
154 
159 int getWidthOfActive();
164 int getHeightOfActive();
165 
167 
168 std::vector<QPoint> getPolygonDataOfRealLayer();
169 
171 
173 
176 
177 public slots:
178 // Events to handle
183 void slotActivateLayer(int a);
187 void slotDeleteActiveLayer();
188 
189 protected:
190 void mousePressEvent(QMouseEvent*event) override;
191 void mouseMoveEvent(QMouseEvent*event) override;
192 void mouseReleaseEvent(QMouseEvent*event) override;
193 
194 void wheelEvent(QWheelEvent*event) override;
195 // Updates the painting area where we are painting
196 void paintEvent(QPaintEvent*event) override;
197 
198 // Makes sure the area we are drawing on remains
199 // as large as the widget
200 void resizeEvent(QResizeEvent*event) override;
201 
202 private:
203 void setLayerDimensions(int maxWidth, int maxHeight);
204 void selectLayerUp();
205 void selectLayerDown();
206 IntelliTool* copyActiveTool();
207 
208 QImage* Canvas;
209 int maxWidth;
210 int maxHeight;
211 
212 IntelliRenderSettings renderSettings;
213 IntelliTool* Tool;
214 IntelliPhotoGui* DumpyGui;
215 
216 std::vector<LayerObject> layerBundle;
217 int activeLayer=-1;
218 
219 void drawLayers(bool forSaving=false);
220 
221 void resizeLayer(QImage*image_res, const QSize &newSize);
222 
223 // Helper for Tool
224 // TODO: Always create this layer on top and return the id here!
225 void createTempTopLayer(int idx);
226 };
227 
228 #endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:236
PaintingArea::createCircleTool
void createCircleTool()
Definition: PaintingArea.cpp:222
PaintingArea::getImageOfActiveLayer
IntelliImage * getImageOfActiveLayer()
Definition: PaintingArea.cpp:406
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:281
PaintingArea::createRectangleTool
void createRectangleTool()
Definition: PaintingArea.cpp:217
IntelliTool.h
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:115
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:96
IntelliRenderSettings
Definition: IntelliRenderSettings.h:5
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:90
LayerObject::widthOffset
int widthOffset
Definition: PaintingArea.h:29
IntelliPhotoGui
The IntelliPhotoGui class handles the graphical user interface for the intelliPhoto program.
Definition: IntelliPhotoGui.h:24
PaintingArea::floodFill
void floodFill(int r, int g, int b, int a)
The floodFill method fills a the active layer with a given color.
Definition: PaintingArea.cpp:139
LayerObject::heightOffset
int heightOffset
Definition: PaintingArea.h:30
PaintingArea::deleteLayer
void deleteLayer(int idx)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:74
PaintingArea::getHeightOfActive
int getHeightOfActive()
The getHeightOfActive gets the vertical dimensions of the active layer.
Definition: PaintingArea.cpp:240
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:207
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: PaintingArea.cpp:294
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:37
LayerObject
The LayerObject struct holds all the information needed to construct a layer.
Definition: PaintingArea.h:25
PaintingArea::createPenTool
void createPenTool()
Definition: PaintingArea.cpp:202
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:255
IntelliRasterImage.h
LayerObject::alpha
int alpha
Definition: PaintingArea.h:31
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:212
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:193
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:188
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:244
LayerObject::width
int width
Definition: PaintingArea.h:27
PaintingArea::~PaintingArea
~PaintingArea() override
This deconstructor is used to clear up the memory and remove the currently active window.
Definition: PaintingArea.cpp:41
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:271
IntelliPhotoGui.h
PaintingArea::getNumberOfActiveLayer
int getNumberOfActiveLayer()
Definition: PaintingArea.cpp:402
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:14
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
The slotDeleteActiveLayer method handles the deletion of the active layer.
Definition: PaintingArea.cpp:83
PaintingArea::open
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:103
PaintingArea::createPolygonTool
void createPolygonTool()
Definition: PaintingArea.cpp:226
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:160
PaintingArea::colorPicker
IntelliColorPicker colorPicker
Definition: PaintingArea.h:175
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:21
LayerObject::height
int height
Definition: PaintingArea.h:28
PaintingArea::createFloodFillTool
void createFloodFillTool()
Definition: PaintingArea.cpp:231
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:175
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
Definition: PaintingArea.cpp:307
IntelliImage::ImageType::RASTERIMAGE
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:26
PaintingArea::getPolygonDataOfRealLayer
std::vector< QPoint > getPolygonDataOfRealLayer()
Definition: PaintingArea.cpp:248
PaintingArea::Toolsettings
IntelliToolsettings Toolsettings
Definition: PaintingArea.h:174
PaintingArea::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition: PaintingArea.cpp:318
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:198
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:148
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:19
IntelliToolsettings
Definition: IntelliToolsettings.h:4
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:56
IntelliImage::ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:26