# IntelliPhoto: intelliphoto/src/Layer/PaintingArea.h Source File

PaintingArea.h
Go to the documentation of this file.
#ifndef PaintingArea_H
#define PaintingArea_H
#include <QColor>
#include <QImage>
#include <QPoint>
#include <QWidget>
#include <QList>
#include "Image/IntelliImage.h"
#include "Image/IntelliRasterImage.h"
#include "Image/IntelliShapedImage.h"
#include "Tool/IntelliTool.h"
#include "IntelliHelper/IntelliColorPicker.h"
struct LayerObject{
IntelliImage* image;
int width;
int height;
int widthOffset;
int heightOffset;
int alpha=255;
};
class PaintingArea : public QWidget
{
// Declares our class as a QObject which is the base class
// for all Qt objects
// QObjects handle events
Q_OBJECT
friend IntelliTool;
public:
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
~PaintingArea() override;
// Handles all events
bool open(const QString &fileName);
bool save(const QString &fileName, const char *fileFormat);
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
void deleteLayer(int index);
void setLayerToActive(int index);
void setAlphaOfLayer(int index, int alpha);
void floodFill(int r, int g, int b, int a);
void movePositionActive(int x, int y);
void moveActiveLayer(int idx);
//change properties of colorPicker
void colorPickerSetFirstColor();
void colorPickerSetSecondColor();
void colorPickerSwitchColor();
// Create tools
void createPenTool();
void createPlainTool();
void createLineTool();
void createRectangleTool();
void createCircleTool();
void createPolygonTool();
void createFloodFillTool();
int getWidthOfActive();
int getHeightOfActive();
public slots:
// Events to handle
void slotActivateLayer(int a);
void slotDeleteActiveLayer();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
// Updates the painting area where we are painting
void paintEvent(QPaintEvent *event) override;
// Makes sure the area we are drawing on remains
// as large as the widget
void resizeEvent(QResizeEvent *event) override;
private:
void setUp(int maxWidth, int maxHeight);
void activateUpperLayer();
void activateLowerLayer();
QImage* Canvas;
int maxWidth;
int maxHeight;
IntelliTool* Tool;
IntelliColorPicker colorPicker;
std::vector<LayerObject> layerBundle;
int activeLayer=-1;
void assembleLayers(bool forSaving=false);
void resizeImage(QImage *image_res, const QSize &newSize);
// Helper for Tool
void createTempLayerAfter(int idx);
};
#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