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