IntelliPhoto  0.6
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 <QLabel>
11 #include "Image/IntelliImage.h"
14 #include "Tool/IntelliTool.h"
16 
17 //for unit testing
18 class UnitTest;
19 class IntelliPhotoGui;
23 struct LayerObject {
31  int width;
35  int height;
47  int alpha = 255;
48 
49  LayerObject();
50 
51  LayerObject(const LayerObject& layer);
52 };
53 
57 class PaintingArea : public QLabel
58 {
59 friend UnitTest;
60 // Declares our class as a QObject which is the base class
61 // for all Qt objects
62 // QObjects handle events
63 Q_OBJECT
64 friend IntelliTool;
65 friend IntelliPhotoGui;
66 public:
73 PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
74 
78 ~PaintingArea() override;
79 
84 void setRenderSettings(bool isFastRenderingOn);
85 
90 bool getRenderSettings();
91 
97 bool open(const QString &filePath);
104 bool save(const QString &filePath, const char*fileFormat);
105 
109 void deleteAllLayers();
120 int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, int alpha = 255, ImageType type = ImageType::RASTERIMAGE);
131 int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
137 void deleteLayer(int idx, bool isTool = false);
142 void setLayerActive(int idx);
148 void setLayerAlpha(int idx, int alpha);
153 void setPolygon(int idx);
159 void movePositionActive(int x, int y);
164 void moveActiveLayer(int idx);
165 
177 void colorPickerSwapColors();
178 
179 void createPenTool();
180 void createPlainTool();
181 void createLineTool();
182 void createRectangleTool();
183 void createCircleTool();
184 void createPolygonTool();
185 void createFloodFillTool();
186 
191 int getWidthOfActive();
196 int getHeightOfActive();
197 
198 int getMaxWidth();
199 
200 int getMaxHeight();
201 
203 
204 std::vector<QPoint> getPolygonDataOfRealLayer();
205 
207 
209 
215 
220 std::vector<LayerObject>* getLayerBundle();
221 
224 
225 void historyGoBack();
226 void historyGoForward();
227 
228 void setLayerDimensions(int maxWidth, int maxHeight);
229 
230 void setPixelToActive(QColor color, QPoint point);
231 
232 void setPolygonDataToActive(std::vector<QPoint> points);
233 public slots:
238 void slotActivateLayer(int a);
242 void slotDeleteActiveLayer();
243 
244 protected:
245 void mousePressEvent(QMouseEvent*event) override;
246 void mouseMoveEvent(QMouseEvent*event) override;
247 void mouseReleaseEvent(QMouseEvent*event) override;
248 
249 void wheelEvent(QWheelEvent*event) override;
250 
251 void paintEvent(QPaintEvent*event) override;
252 
253 private:
254 //offset for the displayable
255 int offsetXDimension;
256 int offsetYDimension;
257 
258 void selectLayerUp();
259 void selectLayerDown();
260 IntelliTool* copyActiveTool();
261 
262 QImage* Canvas;
263 QImage ScaledCanvas;
264 int maxWidth;
265 int maxHeight;
266 
267 bool isSettingPolygon = false;
268 
269 IntelliRenderSettings renderSettings;
270 IntelliTool* Tool;
271 IntelliPhotoGui* guiReference;
272 
273 std::vector<LayerObject> layerBundle;
274 int activeLayer = -1;
275 
276 void drawLayers(bool forSaving = false);
277 
278 bool createTempTopLayer(int idx);
279 
280 void updateTools();
281 
282 std::vector<LayerObject> history[100] = {layerBundle};
283 int historyMaxPast = 0;
284 int historyMaxFuture = 0;
285 int historyPresent = 0;
286 
287 void historyadd();
288 
289 };
290 
291 #endif
PaintingArea::getWidthOfActive
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
Definition: PaintingArea.cpp:278
PaintingArea::createCircleTool
void createCircleTool()
Definition: PaintingArea.cpp:264
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()
Definition: PaintingArea.cpp:465
PaintingArea::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:337
PaintingArea::createRectangleTool
void createRectangleTool()
Definition: PaintingArea.cpp:259
IntelliTool.h
PaintingArea::getMaxWidth
int getMaxWidth()
Definition: PaintingArea.cpp:286
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:182
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:144
IntelliRenderSettings
Definition: IntelliRenderSettings.h:8
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:137
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()
Definition: PaintingArea.cpp:290
PaintingArea::deleteLayer
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:114
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:282
PaintingArea::createPlainTool
void createPlainTool()
Definition: PaintingArea.cpp:249
PaintingArea::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: PaintingArea.cpp:352
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()
Definition: PaintingArea.cpp:244
PaintingArea::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: PaintingArea.cpp:305
IntelliRasterImage.h
LayerObject::alpha
int alpha
alpha - Stores the alpha value of the layer (default=255).
Definition: PaintingArea.h:47
PaintingArea::historyGoBack
void historyGoBack()
Definition: PaintingArea.cpp:518
PaintingArea::createLineTool
void createLineTool()
Definition: PaintingArea.cpp:254
PaintingArea::colorPickerSetSecondColor
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
Definition: PaintingArea.cpp:235
PaintingArea::colorPickerSetFirstColor
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
Definition: PaintingArea.cpp:230
IntelliColorPicker.h
PaintingArea::getLayerBundle
std::vector< LayerObject > * getLayerBundle()
getLayerBundle returns the real active layerbundle (care!)
Definition: PaintingArea.cpp:487
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
Definition: PaintingArea.cpp:324
PaintingArea::getNumberOfActiveLayer
int getNumberOfActiveLayer()
Definition: PaintingArea.cpp:461
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:129
PaintingArea::getTypeOfImageRealLayer
ImageType getTypeOfImageRealLayer()
Definition: PaintingArea.cpp:294
PaintingArea::open
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
Definition: PaintingArea.cpp:163
PaintingArea::createPolygonTool
void createPolygonTool()
Definition: PaintingArea.cpp:268
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:212
PaintingArea::colorPicker
IntelliColorPicker colorPicker
Definition: PaintingArea.h:223
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:39
PaintingArea::setPixelToActive
void setPixelToActive(QColor color, QPoint point)
Definition: PaintingArea.cpp:86
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:174
PaintingArea::getImageDataOfActiveLayer
QImage getImageDataOfActiveLayer()
getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer ...
Definition: PaintingArea.cpp:472
PaintingArea::setLayerDimensions
void setLayerDimensions(int maxWidth, int maxHeight)
Definition: PaintingArea.cpp:72
PaintingArea::createFloodFillTool
void createFloodFillTool()
Definition: PaintingArea.cpp:273
PaintingArea::slotActivateLayer
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
Definition: PaintingArea.cpp:223
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:14
PaintingArea::paintEvent
void paintEvent(QPaintEvent *event) override
Definition: PaintingArea.cpp:367
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::getPolygonDataOfRealLayer
std::vector< QPoint > getPolygonDataOfRealLayer()
Definition: PaintingArea.cpp:298
PaintingArea::Toolsettings
IntelliToolsettings Toolsettings
Definition: PaintingArea.h:222
PaintingArea::setPolygon
void setPolygon(int idx)
setPolygon is used for setting polygondata, it only works on RASTER images
Definition: PaintingArea.cpp:151
PaintingArea::colorPickerSwapColors
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
Definition: PaintingArea.cpp:240
PaintingArea::movePositionActive
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
Definition: PaintingArea.cpp:205
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()
Definition: PaintingArea.cpp:527
LayerObject::LayerObject
LayerObject()
Definition: PaintingArea.cpp:22
PaintingArea::setPolygonDataToActive
void setPolygonDataToActive(std::vector< QPoint > points)
Definition: PaintingArea.cpp:90
IntelliToolsettings
Definition: IntelliToolsettings.h:7