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 <QLabel>
#include "Image/IntelliImage.h"
#include "Image/IntelliRasterImage.h"
#include "Image/IntelliShapedImage.h"
#include "Tool/IntelliTool.h"
#include "IntelliHelper/IntelliColorPicker.h"
//for unit testing
class UnitTest;
class IntelliPhotoGui;
struct LayerObject {
IntelliImage* image;
int width;
int height;
int widthOffset;
int heightOffset;
int alpha = 255;
LayerObject();
LayerObject(const LayerObject& layer);
};
class PaintingArea : public QLabel
{
friend UnitTest;
// Declares our class as a QObject which is the base class
// for all Qt objects
// QObjects handle events
Q_OBJECT
friend IntelliTool;
friend IntelliPhotoGui;
public:
PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
~PaintingArea() override;
void setRenderSettings(bool isFastRenderingOn);
bool getRenderSettings();
bool open(const QString &filePath);
bool save(const QString &filePath, const char*fileFormat);
void deleteAllLayers();
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, int alpha = 255, ImageType type = ImageType::RASTERIMAGE);
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
void deleteLayer(int idx, bool isTool = false);
void setLayerActive(int idx);
void setLayerAlpha(int idx, int alpha);
void setPolygon(int idx);
void movePositionActive(int x, int y);
void moveActiveLayer(int idx);
void colorPickerSetFirstColor();
void colorPickerSetSecondColor();
void colorPickerSwapColors();
void createPenTool();
void createPlainTool();
void createLineTool();
void createRectangleTool();
void createCircleTool();
void createPolygonTool();
void createFloodFillTool();
void createGradientTool();
int getWidthOfActive();
int getHeightOfActive();
int getMaxWidth();
int getMaxHeight();
ImageType getTypeOfImageActiveLayer();
std::vector<QPoint> getPolygonDataOfActiveLayer();
int getIndexOfActiveLayer();
IntelliImage* getImageOfActiveLayer();
QImage getImageDataOfActiveLayer();
std::vector<LayerObject>* getLayerBundle();
IntelliToolsettings Toolsettings;
IntelliColorPicker colorPicker;
void historyadd();
void historyGoBack();
void historyGoForward();
void setCanvasDimensions(int maxWidth, int maxHeight);
void drawPixelOntoActive(QColor color, QPoint point);
void setPolygonDataToActive(std::vector<QPoint> points);
public slots:
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;
void paintEvent(QPaintEvent*event) override;
private:
int offsetXDimension;
int offsetYDimension;
void selectLayerUp();
void selectLayerDown();
IntelliTool* copyActiveTool();
QImage* Canvas;
QImage ScaledCanvas;
int maxWidth;
int maxHeight;
bool isSettingPolygon = false;
IntelliRenderSettings renderSettings;
IntelliTool* Tool;
IntelliPhotoGui* guiReference;
std::vector<LayerObject> layerBundle;
int activeLayer = -1;
void drawLayers(bool forSaving = false);
bool createTempTopLayer(int idx);
void updateTools();
std::vector<std::vector<LayerObject> > history = {layerBundle};
int historyPresent = 0;
};
#endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:282
PaintingArea::createCircleTool
void createCircleTool()
createCircleTool creates a Circle Tool.
Definition: PaintingArea.cpp:263
ImageType::RASTERIMAGE
@ RASTERIMAGE
ImageType
ImageType
The Types, which an Image can be.
Definition: IntelliImage.h:22
PaintingArea::addLayerAt
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type=ImageType::RASTERIMAGE)
The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer...
PaintingArea::setRenderSettings
void setRenderSettings(bool isFastRenderingOn)
setRenderSettings updates all Images to the new Rendersetting.
Definition: PaintingArea.cpp:51
PaintingArea::getImageOfActiveLayer
IntelliImage * getImageOfActiveLayer()
getImageOfActiveLayer returns the image of the active Layer.
Definition: PaintingArea.cpp:469
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
mouseReleaseEvent handles a mouse released event
Definition: PaintingArea.cpp:341
PaintingArea::createRectangleTool
void createRectangleTool()
createRectangleTool creates a Rectangle Tool.
Definition: PaintingArea.cpp:258
IntelliTool.h
PaintingArea::getMaxWidth
int getMaxWidth()
getMaxWidth gets the max width of the Canvas.
Definition: PaintingArea.cpp:290
IntelliShapedImage.h
IntelliImage.h
PaintingArea::save
bool save(const QString &filePath, const char *fileFormat)
The save method is used for exporting the current project as one picture.
Definition: PaintingArea.cpp:181
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:143
PaintingArea::getPolygonDataOfActiveLayer
std::vector< QPoint > getPolygonDataOfActiveLayer()
getPolygonDataOfActiveLayer get the polygon data of the active Layer.
Definition: PaintingArea.cpp:302
IntelliRenderSettings
The IntelliRenderSettings class which manages the render Settings.
Definition: IntelliRenderSettings.h:10
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:136
LayerObject::widthOffset
int widthOffset
widthOffset - Stores the number of pixles from the left side of the painting area.
Definition: PaintingArea.h:39
PaintingArea::getMaxHeight
int getMaxHeight()
getMaxHeight gets the max height of the Canvas.
Definition: PaintingArea.cpp:294
PaintingArea::deleteLayer
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:113
IntelliPhotoGui
The IntelliPhotoGui base class handles the graphical user interface and events for the intelliPhoto p...
Definition: IntelliPhotoGui.h:34
LayerObject::heightOffset
int heightOffset
heightOffset - Stores the number of pixles from the top of the painting area.
Definition: PaintingArea.h:43
PaintingArea::getHeightOfActive
int getHeightOfActive()
The getHeightOfActive gets the vertical dimensions of the active layer.
Definition: PaintingArea.cpp:286
PaintingArea::createPlainTool
void createPlainTool()
createPlainTool creates a Plain Tool.
Definition: PaintingArea.cpp:248
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
wheelEvent handles a mouse wheel event
Definition: PaintingArea.cpp:356
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:57
LayerObject
The LayerObject struct holds all the information needed to construct a layer.
Definition: PaintingArea.h:23
PaintingArea::createPenTool
void createPenTool()
createPenTool creates a Pen Tool.
Definition: PaintingArea.cpp:243
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
mousePressEvent handles a mouse pressed event.
Definition: PaintingArea.cpp:309
IntelliRasterImage.h
LayerObject::alpha
int alpha
alpha - Stores the alpha value of the layer (default=255).
Definition: PaintingArea.h:47
PaintingArea::drawPixelOntoActive
void drawPixelOntoActive(QColor color, QPoint point)
drawPixelOntoActive draws a pixel onto the image data of the active Layer.
Definition: PaintingArea.cpp:86
PaintingArea::getIndexOfActiveLayer
int getIndexOfActiveLayer()
getIndexOfActiveLayer returns the index of athe active Layer.
Definition: PaintingArea.cpp:465
PaintingArea::historyGoBack
void historyGoBack()
historyGoBack go back in hisotry
Definition: PaintingArea.cpp:517
PaintingArea::createLineTool
void createLineTool()
createLineTool creates a Line Tool.
Definition: PaintingArea.cpp:253
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:234
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:229
IntelliColorPicker.h
PaintingArea::getLayerBundle
std::vector< LayerObject > * getLayerBundle()
getLayerBundle returns the real active layerbundle (care!)
Definition: PaintingArea.cpp:491
LayerObject::width
int width
width - Stores the width of a layer in pixels.
Definition: PaintingArea.h:31
PaintingArea::~PaintingArea
~PaintingArea() override
This deconstructor is used to clear up the memory and remove the currently active window.
Definition: PaintingArea.cpp:47
PaintingArea::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
mouseMoveEvent handles a mouse moved event
Definition: PaintingArea.cpp:328
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:17
PaintingArea::slotDeleteActiveLayer
void slotDeleteActiveLayer()
The slotDeleteActiveLayer method handles the deletion of the active layer.
Definition: PaintingArea.cpp:128
PaintingArea::getTypeOfImageActiveLayer
ImageType getTypeOfImageActiveLayer()
getTypeOfImageActiveLayer get the type of the active Layer.
Definition: PaintingArea.cpp:298
PaintingArea::open
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:162
PaintingArea::createPolygonTool
void createPolygonTool()
createPolygonTool creates a Polygon Tool.
Definition: PaintingArea.cpp:267
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:211
PaintingArea::colorPicker
IntelliColorPicker colorPicker
colorPicker a class to manage Tool color.
Definition: PaintingArea.h:286
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:40
LayerObject::height
int height
height - Stores the height of a layer in pixels.
Definition: PaintingArea.h:35
PaintingArea::deleteAllLayers
void deleteAllLayers()
deleteAllLayers deletes all layers
Definition: PaintingArea.cpp:173
PaintingArea::setCanvasDimensions
void setCanvasDimensions(int maxWidth, int maxHeight)
setCanvasDimensions sets the dimension of the Canvas
Definition: PaintingArea.cpp:72
PaintingArea::getImageDataOfActiveLayer
QImage getImageDataOfActiveLayer()
getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer ...
Definition: PaintingArea.cpp:476
PaintingArea::createFloodFillTool
void createFloodFillTool()
createFloodFillTool creates a Floodfill Tool.
Definition: PaintingArea.cpp:272
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:222
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:14
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
paintEvent handles a painting event
Definition: PaintingArea.cpp:371
UnitTest
Definition: mainUnitTest.cpp:8
PaintingArea::getRenderSettings
bool getRenderSettings()
getRenderSettings updates all Images to the new Rendersetting.
Definition: PaintingArea.cpp:68
LayerObject::image
IntelliImage * image
image - Stores the imageData of the current LayerObject.
Definition: PaintingArea.h:27
PaintingArea::Toolsettings
IntelliToolsettings Toolsettings
Toolsettings - a class to manage Tool settings.
Definition: PaintingArea.h:281
PaintingArea::setPolygon
void setPolygon(int idx)
setPolygon is used for setting polygondata, it only works on RASTER images
Definition: PaintingArea.cpp:150
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:239
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:204
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:30
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, int alpha=255, ImageType type=ImageType::RASTERIMAGE)
The addLayer adds a layer to the current project/ painting area.
Definition: PaintingArea.cpp:94
PaintingArea::historyGoForward
void historyGoForward()
historyGoForward a function to undo the return of the previous state of the project.
Definition: PaintingArea.cpp:526
PaintingArea::historyadd
void historyadd()
historyadd adds an hisotry step
Definition: PaintingArea.cpp:510
LayerObject::LayerObject
LayerObject()
Definition: PaintingArea.cpp:23
PaintingArea::setPolygonDataToActive
void setPolygonDataToActive(std::vector< QPoint > points)
setPolygonDataToActive sets polygondata to the active Layer.
Definition: PaintingArea.cpp:90
PaintingArea::createGradientTool
void createGradientTool()
createGradientTool creates a Gradient Tool.
Definition: PaintingArea.cpp:277
IntelliToolsettings
The IntelliToolsettings class managing the settings of the tools, independent of an existing tool.
Definition: IntelliToolsettings.h:9