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 };
27 
28 class PaintingArea : public QWidget
29 {
30  // Declares our class as a QObject which is the base class
31  // for all Qt objects
32  // QObjects handle events
33  Q_OBJECT
34  friend IntelliTool;
35 public:
36  PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
37  ~PaintingArea();
38 
39  // Handles all events
40  bool open(const QString &fileName);
41  bool save(const QString &fileName, const char *fileFormat);
42 
43  int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
44  int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
45  void deleteLayer(int index);
46  void setLayerToActive(int index);
47  void setAlphaOfLayer(int index, int alpha);
48  void floodFill(int r, int g, int b, int a);
49  void movePositionActive(int x, int y);
50  void moveActiveLayer(int idx);
51 
52  //change properties of colorPicker
56 
57  //create tools
58  void createPenTool();
59  void createPlainTool();
60  void createLineTool();
61 
62 public slots:
63 
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  // Updates the painting area where we are painting
74  void paintEvent(QPaintEvent *event) override;
75 
76  // Makes sure the area we are drawing on remains
77  // as large as the widget
78  void resizeEvent(QResizeEvent *event) override;
79 
80 private:
81  void setUp(int maxWidth, int maxHeight);
82  void activateUpperLayer();
83  void activateLowerLayer();
84 
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 
101  //Helper for Tool
102  void createTempLayerAfter(int idx);
103 };
104 
105 #endif
106 
ImageType
ImageType
Definition: IntelliImage.h:11
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::Raster_Image)
Definition: PaintingArea.cpp:53
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:221
IntelliTool.h
IntelliShapedImage.h
IntelliImage.h
PaintingArea::open
bool open(const QString &fileName)
Definition: PaintingArea.cpp:99
LayerObject::widthOffset
int widthOffset
Definition: PaintingArea.h:21
PaintingArea::setLayerToActive
void setLayerToActive(int index)
Definition: PaintingArea.cpp:86
PaintingArea::floodFill
void floodFill(int r, int g, int b, int a)
Definition: PaintingArea.cpp:135
PaintingArea::save
bool save(const QString &fileName, const char *fileFormat)
Definition: PaintingArea.cpp:111
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:182
PaintingArea
Definition: PaintingArea.h:28
LayerObject
Definition: PaintingArea.h:17
PaintingArea::deleteLayer
void deleteLayer(int index)
Definition: PaintingArea.cpp:70
PaintingArea::createPenTool
void createPenTool()
Definition: PaintingArea.cpp:177
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:195
ImageType::Raster_Image
IntelliRasterImage.h
LayerObject::alpha
int alpha
Definition: PaintingArea.h:23
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:187
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
Definition: PaintingArea.cpp:168
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
Definition: PaintingArea.cpp:163
PaintingArea::colorPickerSwitchColor
void colorPickerSwitchColor()
Definition: PaintingArea.cpp:173
IntelliColorPicker.h
LayerObject::width
int width
Definition: PaintingArea.h:19
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:211
IntelliTool
Definition: IntelliTool.h:10
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
Definition: PaintingArea.cpp:79
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:149
PaintingArea::~PaintingArea
~PaintingArea()
Definition: PaintingArea.cpp:38
PaintingArea::PaintingArea
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent=nullptr)
Definition: PaintingArea.cpp:17
LayerObject::hight
int hight
Definition: PaintingArea.h:20
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
Definition: PaintingArea.cpp:157
IntelliColorPicker
Definition: IntelliColorPicker.h:8
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
Definition: PaintingArea.cpp:237
PaintingArea::setAlphaOfLayer
void setAlphaOfLayer(int index, int alpha)
Definition: PaintingArea.cpp:92
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:18
PaintingArea::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition: PaintingArea.cpp:248
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
Definition: PaintingArea.cpp:144
IntelliImage
Definition: IntelliImage.h:18
LayerObject::hightOffset
int hightOffset
Definition: PaintingArea.h:22