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 "Image/IntelliImage.h"
11 #include "Image/IntelliRasterImage.h"
12 #include "Image/IntelliShapedImage.h"
13 #include "Tool/IntelliTool.h"
14 #include "IntelliHelper/IntelliColorPicker.h"
15
24 struct LayerObject{
25 IntelliImage* image;
26 int width;
27 int height;
28 int widthOffset;
29 int heightOffset;
30 int alpha=255;
31 };
32
36 class PaintingArea : public QWidget
37 {
38 // Declares our class as a QObject which is the base class
39 // for all Qt objects
40 // QObjects handle events
41 Q_OBJECT
42 friend IntelliTool;
43 public:
50 PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
51
55 ~PaintingArea() override;
56
57 // Handles all events
58
64 bool open(const QString &fileName);
71 bool save(const QString &fileName, const char *fileFormat);
72
82 int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
93 int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
98 void deleteLayer(int index);
103 void setLayerToActive(int index);
109 void setAlphaOfLayer(int index, int alpha);
117 void floodFill(int r, int g, int b, int a);
123 void movePositionActive(int x, int y);
128 void moveActiveLayer(int idx);
129
130 //change properties of colorPicker
134 void colorPickerSetFirstColor();
138 void colorPickerSetSecondColor();
142 void colorPickerSwitchColor();
143
144 // Create tools
145 void createPenTool();
146 void createPlainTool();
147 void createLineTool();
148 void createRectangleTool();
149 void createCircleTool();
150 void createPolygonTool();
151 void createFloodFillTool();
152
157 int getWidthOfActive();
162 int getHeightOfActive();
163
164 public slots:
165 // Events to handle
170 void slotActivateLayer(int a);
174 void slotDeleteActiveLayer();
175
176 protected:
177 void mousePressEvent(QMouseEvent *event) override;
178 void mouseMoveEvent(QMouseEvent *event) override;
179 void mouseReleaseEvent(QMouseEvent *event) override;
180
181 void wheelEvent(QWheelEvent *event) override;
182 // Updates the painting area where we are painting
183 void paintEvent(QPaintEvent *event) override;
184
185 // Makes sure the area we are drawing on remains
186 // as large as the widget
187 void resizeEvent(QResizeEvent *event) override;
188
189 private:
190 void setUp(int maxWidth, int maxHeight);
191 void activateUpperLayer();
192 void activateLowerLayer();
193
194 QImage* Canvas;
195 int maxWidth;
196 int maxHeight;
197
198 IntelliTool* Tool;
199 IntelliColorPicker colorPicker;
200
201 std::vector<LayerObject> layerBundle;
202 int activeLayer=-1;
203
204 void assembleLayers(bool forSaving=false);
205
206 void resizeImage(QImage *image_res, const QSize &newSize);
207
208 // Helper for Tool
209 void createTempLayerAfter(int idx);
210 };
211
212 #endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:214
PaintingArea::createCircleTool
void createCircleTool()
Definition: PaintingArea.cpp:200
ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:14
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::Raster_Image)
The addLayer adds a layer to the current project/ painting area.
Definition: PaintingArea.cpp:56
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:251
PaintingArea::createRectangleTool
void createRectangleTool()
Definition: PaintingArea.cpp:195
IntelliTool.h
IntelliShapedImage.h
IntelliImage.h
PaintingArea::open
bool open(const QString &fileName)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:102
LayerObject::widthOffset
int widthOffset
Definition: PaintingArea.h:28
PaintingArea::setLayerToActive
void setLayerToActive(int index)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:89
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:138
LayerObject::heightOffset
int heightOffset
Definition: PaintingArea.h:29
PaintingArea::save
bool save(const QString &fileName, const char *fileFormat)
The save method is used for exporting the current project as one picture.
Definition: PaintingArea.cpp:114
PaintingArea::getHeightOfActive
int getHeightOfActive()
The getHeightOfActive gets the vertical dimensions of the active layer.
Definition: PaintingArea.cpp:218
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:185
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: PaintingArea.cpp:264
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:36
LayerObject
The LayerObject struct holds all the information needed to construct a layer.
Definition: PaintingArea.h:24
PaintingArea::deleteLayer
void deleteLayer(int index)
The deleteLayer method removes a layer at a given index.
Definition: PaintingArea.cpp:73
PaintingArea::createPenTool
void createPenTool()
Definition: PaintingArea.cpp:180
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:225
ImageType::Raster_Image
IntelliRasterImage.h
LayerObject::alpha
int alpha
Definition: PaintingArea.h:30
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:190
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:171
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:166
PaintingArea::colorPickerSwitchColor
void colorPickerSwitchColor()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:176
IntelliColorPicker.h
LayerObject::width
int width
Definition: PaintingArea.h:26
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:241
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:13
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
The slotDeleteActiveLayer method handles the deletion of the active layer.
Definition: PaintingArea.cpp:82
PaintingArea::createPolygonTool
void createPolygonTool()
Definition: PaintingArea.cpp:204
PaintingArea::addLayerAt
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::Raster_Image)
The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer...
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:152
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:27
PaintingArea::createFloodFillTool
void createFloodFillTool()
Definition: PaintingArea.cpp:209
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:160
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:275
PaintingArea::setAlphaOfLayer
void setAlphaOfLayer(int index, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:95
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:25
PaintingArea::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition: PaintingArea.cpp:286
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:147
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:24