diff --git a/src/Bilder.qrc b/src/Bilder.qrc
index 3e190f4..01e8468 100644
--- a/src/Bilder.qrc
+++ b/src/Bilder.qrc
@@ -3,11 +3,12 @@
icons/icon.png
icons/circle-tool.svg
icons/eraser-tool.svg
- icons/flood-fill-tool.svg
- icons/magic-wand-tool.svg
icons/pen-tool.svg
icons/polygon-tool.svg
icons/rectangle-tool.svg
icons/Wechselpfeile.png
+ icons/line-tool.svg
+ icons/flood-fill-tool.svg
+ icons/plain-tool.svg
diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp
index 283f7fb..d427e5f 100644
--- a/src/GUI/IntelliPhotoGui.cpp
+++ b/src/GUI/IntelliPhotoGui.cpp
@@ -95,10 +95,10 @@ void IntelliPhotoGui::slotDeleteLayer(){
// Define the standard Value, min, max, step and ok button
int layerNumber = QInputDialog::getInt(this, tr("delete Layer"),
tr("Number:"),
- paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok);
+ paintingArea->getNumberOfActiveLayer()+1,1, 501, 1, &ok);
// Create New Layer
if (ok) {
- paintingArea->deleteLayer(layerNumber);
+ paintingArea->deleteLayer(layerNumber-1);
UpdateGui();
}
}
@@ -200,6 +200,16 @@ void IntelliPhotoGui::slotSetActiveLayer(){
}
}
+void IntelliPhotoGui::slotUpdateRenderSettingsOn(){
+ paintingArea->setRenderSettings(true);
+ UpdateGui();
+}
+
+void IntelliPhotoGui::slotUpdateRenderSettingsOff(){
+ paintingArea->setRenderSettings(false);
+ UpdateGui();
+}
+
void IntelliPhotoGui::slotSetFirstColor(){
paintingArea->colorPickerSetFirstColor();
UpdateGui();
@@ -356,6 +366,13 @@ void IntelliPhotoGui::createActions(){
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
+ //Create Update RenderSettings Actions here
+ actionUpdateRenderSettingsOn = new QAction(tr("&On"), this);
+ connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOn()));
+
+ actionUpdateRenderSettingsOff = new QAction(tr("&Off"), this);
+ connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOff()));
+
//Create Color Actions here
actionColorPickerFirstColor = new QAction(tr("&Main"), this);
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
@@ -448,6 +465,11 @@ void IntelliPhotoGui::createMenus(){
fileMenu->addSeparator();
fileMenu->addAction(actionExit);
+ //Attach all actions to Render Settings
+ renderMenu = new QMenu(tr("&Fast Renderer"), this);
+ renderMenu->addAction(actionUpdateRenderSettingsOn);
+ renderMenu->addAction(actionUpdateRenderSettingsOff);
+
// Attach all actions to Options
optionMenu = new QMenu(tr("&Options"), this);
optionMenu->addAction(actionSetActiveLayer);
@@ -458,6 +480,8 @@ void IntelliPhotoGui::createMenus(){
optionMenu->addAction(actionMovePositionRight);
optionMenu->addAction(actionMoveLayerUp);
optionMenu->addAction(actionMoveLayerDown);
+ optionMenu->addSeparator();
+ optionMenu->addMenu(renderMenu);
// Attach all actions to Layer
layerMenu = new QMenu(tr("&Layer"), this);
@@ -506,54 +530,54 @@ void IntelliPhotoGui::createGui(){
// create Gui elements
paintingArea = new PaintingArea();
- paintingArea->DumpyGui = this;
+ paintingArea->DummyGui = this;
- p = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
+ preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
CircleButton = new QPushButton();
CircleButton->setFixedSize(Buttonsize);
- CircleButton->setIcon(p);
+ CircleButton->setIcon(preview);
CircleButton->setIconSize(Buttonsize);
CircleButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg");
+ preview = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg");
FloodFillButton = new QPushButton();
FloodFillButton->setFixedSize(Buttonsize);
- FloodFillButton->setIcon(p);
+ FloodFillButton->setIcon(preview);
FloodFillButton->setIconSize(Buttonsize);
FloodFillButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/icon.png");
+ preview = QPixmap(":/Icons/Buttons/icons/line-tool.svg");
LineButton = new QPushButton();
LineButton->setFixedSize(Buttonsize);
- LineButton->setIcon(p);
+ LineButton->setIcon(preview);
LineButton->setIconSize(Buttonsize);
LineButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/pen-tool.svg");
+ preview = QPixmap(":/Icons/Buttons/icons/pen-tool.svg");
PenButton = new QPushButton();
PenButton->setFixedSize(Buttonsize);
- PenButton->setIcon(p);
+ PenButton->setIcon(preview);
PenButton->setIconSize(Buttonsize);
PenButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/icon.png");
+ preview = QPixmap(":/Icons/Buttons/icons/plain-tool.svg");
PlainButton = new QPushButton();
PlainButton->setFixedSize(Buttonsize);
- PlainButton->setIcon(p);
+ PlainButton->setIcon(preview);
PlainButton->setIconSize(Buttonsize);
PlainButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg");
+ preview = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg");
PolygonButton = new QPushButton();
PolygonButton->setFixedSize(Buttonsize);
- PolygonButton->setIcon(p);
+ PolygonButton->setIcon(preview);
PolygonButton->setIconSize(Buttonsize);
PolygonButton->setCheckable(true);
- p = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg");
+ preview = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg");
RectangleButton = new QPushButton();
RectangleButton->setFixedSize(Buttonsize);
- RectangleButton->setIcon(p);
+ RectangleButton->setIcon(preview);
RectangleButton->setIconSize(Buttonsize);
RectangleButton->setCheckable(true);
@@ -587,22 +611,30 @@ void IntelliPhotoGui::createGui(){
SecondColorButton = new QPushButton();
SecondColorButton->setFixedSize(Buttonsize/2);
- p = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
+ preview = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
SwitchColorButton = new QPushButton();
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2);
- SwitchColorButton->setIcon(p);
+ SwitchColorButton->setIcon(preview);
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2));
ActiveLayerLine = new QLabel();
- QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
+ QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1);
ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
- p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
+ IntelliImage* activePicture = paintingArea->getImageOfActiveLayer();
+ if(activePicture){
+ preview = preview.fromImage(activePicture->getImageData());
+ }else{
+ QImage tmp(1,1,QImage::Format_ARGB32);
+ tmp.fill(Qt::transparent);
+ preview = preview.fromImage(tmp);
+ }
+
ActiveLayerImageButton = new QPushButton();
ActiveLayerImageButton->setFixedSize(Buttonsize);
- ActiveLayerImageButton->setIcon(p);
+ ActiveLayerImageButton->setIcon(preview);
ActiveLayerImageButton->setIconSize(Buttonsize);
// set gui elements
@@ -692,10 +724,18 @@ void IntelliPhotoGui::setDefaultToolValue(){
}
void IntelliPhotoGui::UpdateGui(){
- QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
+ QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1);
ActiveLayerLine->setText(string);
- p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
- ActiveLayerImageButton->setIcon(p);
+
+ IntelliImage* activePicture = paintingArea->getImageOfActiveLayer();
+ if(activePicture){
+ preview = preview.fromImage(activePicture->getImageData());
+ }else{
+ QImage tmp(1,1,QImage::Format_ARGB32);
+ tmp.fill(Qt::transparent);
+ preview = preview.fromImage(tmp);
+ }
+ ActiveLayerImageButton->setIcon(preview);
ActiveLayerImageButton->setIconSize(Buttonsize);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h
index 3b478b6..6611b47 100644
--- a/src/GUI/IntelliPhotoGui.h
+++ b/src/GUI/IntelliPhotoGui.h
@@ -56,6 +56,10 @@ void slotPositionMoveRight();
void slotMoveLayerUp();
void slotMoveLayerDown();
+//Rendersetting slots here
+void slotUpdateRenderSettingsOn();
+void slotUpdateRenderSettingsOff();
+
// color Picker slots here
void slotSetFirstColor();
void slotSetSecondColor();
@@ -97,7 +101,7 @@ void setDefaultToolValue();
PaintingArea* paintingArea;
const QSize Buttonsize = QSize(70,70);
-QPixmap p;
+QPixmap preview;
QPushButton* CircleButton;
QPushButton* FloodFillButton;
QPushButton* LineButton;
@@ -122,6 +126,7 @@ QPushButton* ActiveLayerImageButton;
// The menu widgets
QMenu*saveAsMenu;
QMenu*fileMenu;
+QMenu*renderMenu;
QMenu*optionMenu;
QMenu*layerMenu;
QMenu*colorMenu;
@@ -133,6 +138,10 @@ QMenu*helpMenu;
QAction*actionOpen;
QAction*actionExit;
+//Rendersetting actions
+QAction*actionUpdateRenderSettingsOn;
+QAction*actionUpdateRenderSettingsOff;
+
// color Picker actions
QAction*actionColorPickerFirstColor;
QAction*actionColorPickerSecondColor;
diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp
index 4e97513..d1388b6 100644
--- a/src/Image/IntelliImage.cpp
+++ b/src/Image/IntelliImage.cpp
@@ -11,7 +11,7 @@ IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
if(fastRendererOn){
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
}
- this->fastRenderer = fastRendererOn;
+ this->fastRenderering = fastRendererOn;
}
@@ -30,7 +30,7 @@ bool IntelliImage::loadImage(const QString &filePath){
// scaled Image to size of Layer
loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio);
- imageData = loadedImage.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
+ imageData = loadedImage.convertToFormat(fastRenderering ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
return true;
}
@@ -46,14 +46,16 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
// Draw the image
QPainter painter(&newImage);
painter.drawImage(QPoint(0, 0), *image);
- *image = newImage;
- if(fastRenderer){
- this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
+ if(fastRenderering){
+ *image = newImage.convertToFormat(QImage::Format_Indexed8);
+ }
+ else{
+ *image = newImage;
}
}
void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
@@ -64,13 +66,13 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
// Draw a line from the last registered point to the current
painter.drawPoint(p1);
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
}
void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
@@ -80,13 +82,13 @@ void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& p
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
// Draw a line from the last registered point to the current
painter.drawPoint(p1);
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
}
void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
@@ -97,23 +99,23 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
// Draw a line from the last registered point to the current
painter.drawLine(p1, p2);
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
}
void IntelliImage::drawPlain(const QColor& color){
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
imageData.fill(color);
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
}
QColor IntelliImage::getPixelColor(QPoint& point){
- if(fastRenderer){
+ if(fastRenderering){
QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32);
return copy.pixelColor(point);
}
@@ -121,10 +123,29 @@ QColor IntelliImage::getPixelColor(QPoint& point){
}
QImage IntelliImage::getImageData(){
- return this->imageData;
+ QImage copy = imageData;
+ if(fastRenderering){
+ copy = copy.convertToFormat(QImage::Format_ARGB32);
+ }
+ return copy;
+}
+
+void IntelliImage::setImageData(const QImage& newData){
+ imageData = newData;
+ if(fastRenderering){
+ this->imageData = imageData.convertToFormat(QImage::Format_Indexed8);
+ }
+ else {
+ this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
+ }
}
void IntelliImage::updateRendererSetting(bool fastRendererOn){
- this->fastRenderer = fastRendererOn;
- this->imageData = this->imageData.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
+ this->fastRenderering = fastRendererOn;
+ if(fastRenderering){
+ this->imageData = imageData.convertToFormat(QImage::Format_Indexed8);
+ }
+ else {
+ this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
+ }
}
diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h
index 8926990..185063d 100644
--- a/src/Image/IntelliImage.h
+++ b/src/Image/IntelliImage.h
@@ -42,9 +42,9 @@ QImage imageData;
ImageType TypeOfImage;
/*!
- * \brief fastRenderer is the flag that represents the usage of 8bit pictures.
+ * \brief fastRendering is the flag that represents the usage of 8bit pictures.
*/
-bool fastRenderer;
+bool fastRenderering;
public:
/*!
@@ -156,10 +156,16 @@ virtual QColor getPixelColor(QPoint& point);
virtual void updateRendererSetting(bool fastRendererOn);
/*!
- * \brief getImageData returns the data of the current image.
+ * \brief getImageData returns the data of the current image (Note: It will allways return a ARGB32bit QImage!).
*/
virtual QImage getImageData();
+/*!
+ * \brief setImageData overwrites the old imageData the new imageData.
+ * \param newData - represents the new imageData
+ */
+virtual void setImageData(const QImage& newData);
+
};
#endif
diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp
index 4bd0891..c2ea6f9 100644
--- a/src/Image/IntelliRasterImage.cpp
+++ b/src/Image/IntelliRasterImage.cpp
@@ -6,7 +6,7 @@
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
: IntelliImage(width, height, fastRendererOn){
TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
- this->fastRenderer = fastRendererOn;
+ this->fastRenderering = fastRendererOn;
}
IntelliRasterImage::~IntelliRasterImage(){
@@ -30,7 +30,7 @@ QImage IntelliRasterImage::getDisplayable(int alpha){
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData;
- if(fastRenderer){
+ if(fastRenderering){
copy = copy.convertToFormat(QImage::Format_ARGB32);
}
for(int y = 0; yfastRenderer = fastRendererOn;
+ this->fastRenderering = fastRendererOn;
}
IntelliShapedImage::~IntelliShapedImage(){
@@ -27,7 +27,7 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
}
void IntelliShapedImage::calculateVisiblity(){
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
}
@@ -40,7 +40,7 @@ void IntelliShapedImage::calculateVisiblity(){
imageData.setPixelColor(x,y,clr);
}
}
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
return;
@@ -59,14 +59,14 @@ void IntelliShapedImage::calculateVisiblity(){
imageData.setPixelColor(x,y,clr);
}
}
- if(fastRenderer){
+ if(fastRenderering){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
}
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData;
- if(fastRenderer){
+ if(fastRenderering){
copy = copy.convertToFormat(QImage::Format_ARGB32);
}
for(int y = 0; yfastRenderering = Updatedsetting;
+}
+
+bool IntelliRenderSettings::isFastRenderering(){
+ return fastRenderering;
}
diff --git a/src/IntelliHelper/IntelliRenderSettings.h b/src/IntelliHelper/IntelliRenderSettings.h
index e932435..a0be040 100644
--- a/src/IntelliHelper/IntelliRenderSettings.h
+++ b/src/IntelliHelper/IntelliRenderSettings.h
@@ -7,14 +7,19 @@ class IntelliRenderSettings
public:
IntelliRenderSettings();
+/*!
+ * \brief setFastRendering sets fastRendering to Updatedsetting.
+ * \param Updatedsetting - Represents the new value for the Fast Rendering Flag.
+ */
+void setFastRendering(bool Updatedsetting);
/*!
* \brief The getfastRenderer gets the value of the flag for the fastRenderer setting.
* \return Returns true if fastRenderer is active else false
*/
-bool getFastRenderer();
+bool isFastRenderering();
private:
-bool fastRenderer = true;
+bool fastRenderering = true;
};
#endif // INTELLIRENDERSETTINGS_H
diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp
index 2258376..4921cc1 100644
--- a/src/Layer/PaintingArea.cpp
+++ b/src/Layer/PaintingArea.cpp
@@ -21,27 +21,36 @@
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
: QWidget(parent){
this->Tool = nullptr;
- this->setLayerDimensions(maxWidth, maxHeight);
- this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
- layerBundle[0].image->drawPlain(QColor(0,0,255,255));
- std::vector polygon;
- polygon.push_back(QPoint(100,000));
- polygon.push_back(QPoint(200,100));
- polygon.push_back(QPoint(100,200));
- polygon.push_back(QPoint(000,100));
- layerBundle[0].image->setPolygon(polygon);
+ this->setLayerDimensions(maxWidth, maxHeight);
+ //this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
+ //layerBundle[0].image->drawPlain(QColor(0,0,255,255));
+ //std::vector polygon;
+ //polygon.push_back(QPoint(100,000));
+ //polygon.push_back(QPoint(200,100));
+ //polygon.push_back(QPoint(100,200));
+ //polygon.push_back(QPoint(000,100));
+ //layerBundle[0].image->setPolygon(polygon);
+ //
+ //this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
+ //layerBundle[1].image->drawPlain(QColor(0,255,0,255));
+ //layerBundle[1].alpha=200;
- this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
- layerBundle[1].image->drawPlain(QColor(0,255,0,255));
- layerBundle[1].alpha=200;
-
- activeLayer=0;
+ activeLayer=-1;
}
PaintingArea::~PaintingArea(){
delete Tool;
}
+void PaintingArea::setRenderSettings(bool isFastRenderingOn){
+ if(isFastRenderingOn != renderSettings.isFastRenderering()){
+ renderSettings.setFastRendering(isFastRenderingOn);
+ for(auto& layer : layerBundle){
+ layer.image->updateRendererSetting(isFastRenderingOn);
+ }
+ }
+}
+
void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
//set standart parameter
this->maxWidth = maxWidth;
@@ -60,9 +69,9 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
newLayer.widthOffset = widthOffset;
newLayer.heightOffset = heightOffset;
if(type==IntelliImage::ImageType::RASTERIMAGE) {
- newLayer.image = new IntelliRasterImage(width,height,renderSettings.getFastRenderer());
+ newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering());
}else if(type==IntelliImage::ImageType::SHAPEDIMAGE) {
- newLayer.image = new IntelliShapedImage(width, height, renderSettings.getFastRenderer());
+ newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering());
}
newLayer.alpha = 255;
this->layerBundle.push_back(newLayer);
@@ -74,9 +83,12 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
void PaintingArea::deleteLayer(int idx){
if(idx(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+idx);
- if(activeLayer>=idx && activeLayer != 0) {
+ if(activeLayer>=idx) {
activeLayer--;
}
+ if(activeLayer < 0 && layerBundle.size()){
+ activeLayer=0;
+ }
}
}
@@ -253,6 +265,8 @@ std::vector PaintingArea::getPolygonDataOfRealLayer(){
// left button and if so store the current position
// Set that we are currently drawing
void PaintingArea::mousePressEvent(QMouseEvent*event){
+ if(this->activeLayer < 0)
+ return;
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset;
@@ -269,6 +283,8 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){
// we call the drawline function which draws a line
// from the last position to the current
void PaintingArea::mouseMoveEvent(QMouseEvent*event){
+ if(this->activeLayer < 0)
+ return;
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset;
@@ -279,7 +295,9 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){
// If the button is released we set variables to stop drawing
void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
- if(Tool == nullptr)
+ if(this->activeLayer < 0)
+ return;
+ if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast(activeLayer)].heightOffset;
@@ -292,7 +310,9 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
}
void PaintingArea::wheelEvent(QWheelEvent*event){
- if(this->Tool != nullptr) {
+ if(this->activeLayer < 0)
+ return;
+ if(this->Tool != nullptr) {
QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
@@ -373,7 +393,7 @@ void PaintingArea::drawLayers(bool forSaving){
}
}
-void PaintingArea::createTempTopLayer(int idx){
+bool PaintingArea::createTempTopLayer(int idx){
if(idx>=0) {
LayerObject newLayer;
newLayer.alpha = 255;
@@ -383,7 +403,9 @@ void PaintingArea::createTempTopLayer(int idx){
newLayer.widthOffset = layerBundle[static_cast(idx)].widthOffset;
newLayer.image = layerBundle[static_cast(idx)].image->getDeepCopy();
layerBundle.insert(layerBundle.begin()+idx+1,newLayer);
+ return true;
}
+ return false;
}
IntelliTool* PaintingArea::copyActiveTool(){
@@ -404,5 +426,8 @@ int PaintingArea::getNumberOfActiveLayer(){
}
IntelliImage* PaintingArea::getImageOfActiveLayer(){
+ if(activeLayer<0){
+ return nullptr;
+ }
return layerBundle[activeLayer].image;
}
diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h
index 31b3916..655a69e 100644
--- a/src/Layer/PaintingArea.h
+++ b/src/Layer/PaintingArea.h
@@ -58,6 +58,12 @@ public:
// Handles all events
+ /*!
+ * \brief setRenderSettings updates all Images to the new Rendersetting.
+ * \param isFastRenderingOn is the new given flag for the FastRenderer.
+ */
+ void setRenderSettings(bool isFastRenderingOn);
+
/*!
* \brief The open method is used for loading a picture into the current layer
* \param fileName - Path and filename which are used to determine where the to-be-opened file is stored
@@ -211,7 +217,7 @@ private:
IntelliRenderSettings renderSettings;
IntelliTool* Tool;
- IntelliPhotoGui* DumpyGui;
+ IntelliPhotoGui* DummyGui;
std::vector layerBundle;
int activeLayer=-1;
@@ -221,8 +227,7 @@ private:
void resizeLayer(QImage *image_res, const QSize &newSize);
// Helper for Tool
- // TODO: Always create this layer on top and return the id here!
- void createTempTopLayer(int idx);
+ bool createTempTopLayer(int idx);
};
#endif
diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp
index 91979e3..2dd2272 100644
--- a/src/Tool/IntelliTool.cpp
+++ b/src/Tool/IntelliTool.cpp
@@ -24,10 +24,10 @@ void IntelliTool::onMouseRightReleased(int x, int y){
}
void IntelliTool::onMouseLeftPressed(int x, int y){
- this->isDrawing=true;
- //create drawing layer
- this->createToolLayer();
- Canvas->image->calculateVisiblity();
+ this->isDrawing=this->createToolLayer();
+ if(isDrawing){
+ Canvas->image->calculateVisiblity();
+ }
}
void IntelliTool::onMouseLeftReleased(int x, int y){
@@ -48,18 +48,23 @@ void IntelliTool::onWheelScrolled(int value){
//if needed for future general tasks implement in here
}
-void IntelliTool::createToolLayer(){
- Area->createTempTopLayer(Area->activeLayer);
- this->activeLayer=&Area->layerBundle[static_cast(Area->activeLayer)];
- this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)];
+bool IntelliTool::createToolLayer(){
+ if(Area->createTempTopLayer(Area->activeLayer)){
+ this->activeLayer=&Area->layerBundle[static_cast(Area->activeLayer)];
+ this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)];
+ return true;
+ }
+ return false;
}
void IntelliTool::mergeToolLayer(){
QColor clr_0;
QColor clr_1;
+ QImage updatedImage = activeLayer->image->getImageData();
+
for(int y=0; yheight; y++) {
- for(int x=0; xwidth; x++) {
- clr_0=activeLayer->image->imageData.pixelColor(x,y);
+ for(int x=0; xwidth; x++) {
+ clr_0=updatedImage.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast(clr_1.alpha())/255.f;
int r =static_cast(static_cast(clr_1.red())*(t)+static_cast(clr_0.red())*(1.f-t)+0.5f);
@@ -71,10 +76,11 @@ void IntelliTool::mergeToolLayer(){
clr_0.setBlue(b);
clr_0.setAlpha(a);
- activeLayer->image->imageData.setPixelColor(x, y, clr_0);
+ updatedImage.setPixelColor(x, y, clr_0);
}
}
- Area->DumpyGui->UpdateGui();
+ activeLayer->image->setImageData(updatedImage);
+ Area->DummyGui->UpdateGui();
}
void IntelliTool::deleteToolLayer(){
diff --git a/src/Tool/IntelliTool.h b/src/Tool/IntelliTool.h
index 4353018..56404aa 100644
--- a/src/Tool/IntelliTool.h
+++ b/src/Tool/IntelliTool.h
@@ -25,8 +25,9 @@ enum class Tooltype {
private:
/*!
* \brief A function that creates a layer to draw on.
+ * \return Returns if a layer could be created
*/
-void createToolLayer();
+bool createToolLayer();
/*!
* \brief A function that merges the drawing- and the active- layer.
diff --git a/src/Tool/IntelliToolCircle.cpp b/src/Tool/IntelliToolCircle.cpp
index b8e9d59..eba6736 100644
--- a/src/Tool/IntelliToolCircle.cpp
+++ b/src/Tool/IntelliToolCircle.cpp
@@ -57,10 +57,12 @@ void IntelliToolCircle::onMouseRightReleased(int x, int y){
void IntelliToolCircle::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
- this->centerPoint=QPoint(x,y);
- int radius = 1;
- drawCircle(radius);
- Canvas->image->calculateVisiblity();
+ if(this->isDrawing){
+ this->centerPoint=QPoint(x,y);
+ int radius = 1;
+ drawCircle(radius);
+ Canvas->image->calculateVisiblity();
+ }
}
void IntelliToolCircle::onMouseLeftReleased(int x, int y){
diff --git a/src/icons/flood-fill-tool.svg b/src/icons/flood-fill-tool.svg
index 980bb7a..71f019d 100644
--- a/src/icons/flood-fill-tool.svg
+++ b/src/icons/flood-fill-tool.svg
@@ -15,22 +15,10 @@
viewBox="0 0 67.733332 67.733335"
version="1.1"
id="svg8"
- sodipodi:docname="flood-fill-tool.svg"
+ sodipodi:docname="magic-wand-tool.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
-
-
-
-
@@ -52,15 +40,6 @@
x2="-13.131983"
y2="106.49742"
gradientUnits="userSpaceOnUse" />
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/icons/line-tool.svg b/src/icons/line-tool.svg
new file mode 100644
index 0000000..e26bb7b
--- /dev/null
+++ b/src/icons/line-tool.svg
@@ -0,0 +1,99 @@
+
+
+
+
diff --git a/src/icons/magic-wand-tool.svg b/src/icons/magic-wand-tool.svg
deleted file mode 100644
index 71f019d..0000000
--- a/src/icons/magic-wand-tool.svg
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
-
-
diff --git a/src/icons/plain-tool.svg b/src/icons/plain-tool.svg
new file mode 100644
index 0000000..980bb7a
--- /dev/null
+++ b/src/icons/plain-tool.svg
@@ -0,0 +1,194 @@
+
+
+
+