IntelliPhoto  0.4
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"
13 #include "Tool/IntelliTool.h"
15 
16 struct LayerObject{
18  int width;
19  int hight;
22  int alpha=255;
23 };
24 
25 class PaintingArea : public QWidget
26 {
27  // Declares our class as a QObject which is the base class
28  // for all Qt objects
29  // QObjects handle events
30  Q_OBJECT
31  friend IntelliTool;
32 public:
33  PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
34  ~PaintingArea() override;
35 
36  // Handles all events
37  bool open(const QString &fileName);
38  bool save(const QString &fileName, const char *fileFormat);
39 
40  int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
41  int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
42  void deleteLayer(int index);
43  void setLayerToActive(int index);
44  void setAlphaOfLayer(int index, int alpha);
45  void floodFill(int r, int g, int b, int a);
46  void movePositionActive(int x, int y);
47  void moveActiveLayer(int idx);
48 
49  //change properties of colorPicker
53 
54  //create tools
55  void createPenTool();
56  void createPlainTool();
57  void createLineTool();
58 
59  //get Width and Height of active Layer
60  int getWidthActiveLayer();
62 
63 public slots:
64  // Events to handle
65  void slotActivateLayer(int a);
66  void slotDeleteActiveLayer();
67 
68 protected:
69  void mousePressEvent(QMouseEvent *event) override;
70  void mouseMoveEvent(QMouseEvent *event) override;
71  void mouseReleaseEvent(QMouseEvent *event) override;
72 
73  void wheelEvent(QWheelEvent *event) override;
74  // Updates the painting area where we are painting
75  void paintEvent(QPaintEvent *event) override;
76 
77  // Makes sure the area we are drawing on remains
78  // as large as the widget
79  void resizeEvent(QResizeEvent *event) override;
80 
81 private:
82  void setUp(int maxWidth, int maxHeight);
83  void activateUpperLayer();
84  void activateLowerLayer();
85 
86  QImage* Canvas;
87  int maxWidth;
88  int maxHeight;
89 
90  IntelliTool* Tool;
91  IntelliColorPicker colorPicker;
92 
93  std::vector<LayerObject> layerBundle;
94  int activeLayer=-1;
95 
96  void assembleLayers(bool forSaving=false);
97 
98  void resizeImage(QImage *image_res, const QSize &newSize);
99 
100  //Helper for Tool
101  void createTempLayerAfter(int idx);
102 };
103 
104 #endif
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)
Definition: PaintingArea.cpp:58
PaintingArea::getWidthActiveLayer
int getWidthActiveLayer()
Definition: PaintingArea.cpp:197
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:234
IntelliTool.h
IntelliShapedImage.h
IntelliImage.h
PaintingArea::open
bool open(const QString &fileName)
Definition: PaintingArea.cpp:104
LayerObject::widthOffset
int widthOffset
Definition: PaintingArea.h:20
PaintingArea::setLayerToActive
void setLayerToActive(int index)
Definition: PaintingArea.cpp:91
PaintingArea::getHeightActiveLayer
int getHeightActiveLayer()
Definition: PaintingArea.cpp:201
PaintingArea::floodFill
void floodFill(int r, int g, int b, int a)
Definition: PaintingArea.cpp:140
PaintingArea::save
bool save(const QString &fileName, const char *fileFormat)
Definition: PaintingArea.cpp:116
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:187
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: PaintingArea.cpp:247
PaintingArea
Definition: PaintingArea.h:25
LayerObject
Definition: PaintingArea.h:16
PaintingArea::deleteLayer
void deleteLayer(int index)
Definition: PaintingArea.cpp:75
PaintingArea::createPenTool
void createPenTool()
Definition: PaintingArea.cpp:182
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:208
ImageType::Raster_Image
IntelliRasterImage.h
LayerObject::alpha
int alpha
Definition: PaintingArea.h:22
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:192
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
Definition: PaintingArea.cpp:173
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
Definition: PaintingArea.cpp:168
PaintingArea::colorPickerSwitchColor
void colorPickerSwitchColor()
Definition: PaintingArea.cpp:178
IntelliColorPicker.h
LayerObject::width
int width
Definition: PaintingArea.h:18
PaintingArea::~PaintingArea
~PaintingArea() override
Definition: PaintingArea.cpp:43
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:224
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:13
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
Definition: PaintingArea.cpp:84
PaintingArea::addLayerAt
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::Raster_Image)
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
Definition: PaintingArea.cpp:154
PaintingArea::PaintingArea
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent=nullptr)
Definition: PaintingArea.cpp:21
LayerObject::hight
int hight
Definition: PaintingArea.h:19
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
Definition: PaintingArea.cpp:162
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:258
PaintingArea::setAlphaOfLayer
void setAlphaOfLayer(int index, int alpha)
Definition: PaintingArea.cpp:97
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:17
PaintingArea::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition: PaintingArea.cpp:269
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
Definition: PaintingArea.cpp:149
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:24
LayerObject::hightOffset
int hightOffset
Definition: PaintingArea.h:21