project load and export

This commit is contained in:
Jonas Mucke
2020-01-23 20:13:43 +01:00
parent 48747c1e8a
commit 8692ccd8a3
10 changed files with 146 additions and 39 deletions

View File

@@ -49,6 +49,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;
@@ -60,19 +64,27 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
}
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::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;
if(type==IntelliImage::ImageType::RASTERIMAGE) {
newLayer.alpha = alpha;
if(type==ImageType::RASTERIMAGE) {
newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering());
}else if(type==IntelliImage::ImageType::SHAPEDIMAGE) {
}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;
return activeLayer;
@@ -117,7 +129,7 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){
}
void PaintingArea::setPolygon(int idx){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) {
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==ImageType::SHAPEDIMAGE) {
delete this->Tool;
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
isSettingPolygon = true;
@@ -138,6 +150,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) {
@@ -249,7 +268,7 @@ int PaintingArea::getMaxHeight(){
return this->maxHeight;
}
IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){
ImageType PaintingArea::getTypeOfImageRealLayer(){
return this->layerBundle[static_cast<size_t>(activeLayer)].image->getTypeOfImage();
}

View File

@@ -78,6 +78,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.
@@ -92,16 +98,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, IntelliImage::ImageType type = IntelliImage::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
@@ -112,7 +123,7 @@ int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, I
* \param type - Defining the ImageType of the new layer
* \return Returns the id of the layer position
*/
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
/*!
* \brief The deleteLayer method removes a layer at a given idx
* \param idx - The index of the layer to be removed
@@ -183,7 +194,7 @@ int getMaxWidth();
int getMaxHeight();
IntelliImage::ImageType getTypeOfImageRealLayer();
ImageType getTypeOfImageRealLayer();
std::vector<QPoint> getPolygonDataOfRealLayer();
@@ -206,6 +217,11 @@ std::vector<LayerObject>* getLayerBundle();
IntelliToolsettings Toolsettings;
IntelliColorPicker colorPicker;
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
@@ -227,7 +243,6 @@ void wheelEvent(QWheelEvent*event) override;
void paintEvent(QPaintEvent*event) override;
private:
void setLayerDimensions(int maxWidth, int maxHeight);
void selectLayerUp();
void selectLayerDown();
IntelliTool* copyActiveTool();