mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 04:10:31 +02:00
Merge branch 'dev-save' into dev-history
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "Tool/IntelliToolRectangle.h"
|
||||
#include "Tool/IntelliToolFloodFill.h"
|
||||
#include "Tool/IntelliToolPolygon.h"
|
||||
#include "GUI/IntelliPhotoGui.h"
|
||||
|
||||
LayerObject::LayerObject(){
|
||||
|
||||
@@ -64,6 +65,10 @@ void PaintingArea::setRenderSettings(bool isFastRenderingOn){
|
||||
}
|
||||
}
|
||||
|
||||
bool PaintingArea::getRenderSettings(){
|
||||
return this->renderSettings.isFastRenderering();
|
||||
}
|
||||
|
||||
void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
//set standart parameter
|
||||
this->maxWidth = maxWidth;
|
||||
@@ -75,19 +80,27 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
|
||||
}
|
||||
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
|
||||
void PaintingArea::setPixelToActive(QColor color, QPoint point){
|
||||
layerBundle[static_cast<size_t>(activeLayer)].image->drawPixel(point, color);
|
||||
}
|
||||
|
||||
void PaintingArea::setPolygonDataToActive(std::vector<QPoint> points){
|
||||
layerBundle[static_cast<size_t>(activeLayer)].image->setPolygon(points);
|
||||
}
|
||||
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset,int alpha, ImageType type){
|
||||
LayerObject newLayer;
|
||||
updateTools();
|
||||
newLayer.width = width;
|
||||
newLayer.height = height;
|
||||
newLayer.widthOffset = widthOffset;
|
||||
newLayer.heightOffset = heightOffset;
|
||||
newLayer.alpha = alpha;
|
||||
if(type==ImageType::RASTERIMAGE) {
|
||||
newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering());
|
||||
}else if(type==ImageType::SHAPEDIMAGE) {
|
||||
newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering());
|
||||
}
|
||||
newLayer.alpha = 255;
|
||||
this->layerBundle.push_back(newLayer);
|
||||
activeLayer = static_cast<int>(layerBundle.size()) - 1;
|
||||
historyadd();
|
||||
@@ -155,6 +168,13 @@ bool PaintingArea::open(const QString &filePath){
|
||||
return open;
|
||||
}
|
||||
|
||||
void PaintingArea::deleteAllLayers(){
|
||||
for(auto layer: layerBundle){
|
||||
delete layer.image;
|
||||
}
|
||||
layerBundle.clear();
|
||||
}
|
||||
|
||||
// Save the current image
|
||||
bool PaintingArea::save(const QString &filePath, const char*fileFormat){
|
||||
if(layerBundle.size()==0) {
|
||||
@@ -455,6 +475,10 @@ QImage PaintingArea::getImageDataOfActiveLayer(){
|
||||
return returnImage;
|
||||
}
|
||||
|
||||
std::vector<LayerObject>* PaintingArea::getLayerBundle(){
|
||||
return &layerBundle;
|
||||
}
|
||||
|
||||
void PaintingArea::updateTools(){
|
||||
if(Tool!=nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include "GUI/IntelliPhotoGui.h"
|
||||
#include "Image/IntelliImage.h"
|
||||
#include "Image/IntelliRasterImage.h"
|
||||
#include "Image/IntelliShapedImage.h"
|
||||
@@ -16,7 +15,7 @@
|
||||
|
||||
//for unit testing
|
||||
class UnitTest;
|
||||
|
||||
class IntelliPhotoGui;
|
||||
/*!
|
||||
* \brief The LayerObject struct holds all the information needed to construct a layer
|
||||
*/
|
||||
@@ -83,6 +82,12 @@ PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
|
||||
*/
|
||||
void setRenderSettings(bool isFastRenderingOn);
|
||||
|
||||
/*!
|
||||
* \brief getRenderSettings updates all Images to the new Rendersetting.
|
||||
* \param isFastRenderingOn is the new given flag for the FastRenderer.
|
||||
*/
|
||||
bool getRenderSettings();
|
||||
|
||||
/*!
|
||||
* \brief The open method is used for loading a picture into the current layer.
|
||||
* \param filePath - Path and Name which are used to determine where the to-be-opened file is stored.
|
||||
@@ -97,16 +102,21 @@ bool open(const QString &filePath);
|
||||
*/
|
||||
bool save(const QString &filePath, const char*fileFormat);
|
||||
|
||||
/*!
|
||||
* \brief deleteAllLayers deletes all layers
|
||||
*/
|
||||
void deleteAllLayers();
|
||||
/*!
|
||||
* \brief The addLayer adds a layer to the current project/ painting area
|
||||
* \param width - Width of the layer in pixles
|
||||
* \param height - Height of the layer in pixles
|
||||
* \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles
|
||||
* \param heightOffset - Offset of the layer measured to the top border of the painting area in pixles
|
||||
* \param alpha - Transparence of the layer
|
||||
* \param type - Defining the ImageType of the new layer
|
||||
* \return Returns the number of layers in the project
|
||||
*/
|
||||
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
|
||||
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, int alpha=255, ImageType type = ImageType::RASTERIMAGE);
|
||||
/*!
|
||||
* \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack
|
||||
* \param idx - Index of the position the new layer should be added
|
||||
@@ -202,12 +212,23 @@ IntelliImage* getImageOfActiveLayer();
|
||||
*/
|
||||
QImage getImageDataOfActiveLayer();
|
||||
|
||||
/*!
|
||||
* \brief getLayerBundle returns the real active layerbundle (care!)
|
||||
* \return the reference of the currentLayerBundle
|
||||
*/
|
||||
std::vector<LayerObject>* getLayerBundle();
|
||||
|
||||
IntelliToolsettings Toolsettings;
|
||||
IntelliColorPicker colorPicker;
|
||||
|
||||
void historyGoBack();
|
||||
void historyGoForward();
|
||||
|
||||
void setLayerDimensions(int maxWidth, int maxHeight);
|
||||
|
||||
void setPixelToActive(QColor color, QPoint point);
|
||||
|
||||
void setPolygonDataToActive(std::vector<QPoint> points);
|
||||
public slots:
|
||||
/*!
|
||||
* \brief The slotActivateLayer method handles the event of selecting one layer as active
|
||||
@@ -229,7 +250,6 @@ void wheelEvent(QWheelEvent*event) override;
|
||||
void paintEvent(QPaintEvent*event) override;
|
||||
|
||||
private:
|
||||
void setLayerDimensions(int maxWidth, int maxHeight);
|
||||
void selectLayerUp();
|
||||
void selectLayerDown();
|
||||
IntelliTool* copyActiveTool();
|
||||
|
||||
Reference in New Issue
Block a user