diff --git a/.gitignore b/.gitignore index 73e7536..f0adfe3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,2 @@ - -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpu6gfxp -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpqakvqm -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts +# Ignoring build files +IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/ diff --git a/IntelliPhoto/.gitignore b/IntelliPhoto/.gitignore deleted file mode 100644 index 73e7536..0000000 --- a/IntelliPhoto/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ - -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpu6gfxp -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpqakvqm -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi -IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts diff --git a/IntelliPhoto/Painting/GUI/IntelliPhotoGui.cpp b/IntelliPhoto/Painting/GUI/IntelliPhotoGui.cpp index 097055d..4b65d13 100644 --- a/IntelliPhoto/Painting/GUI/IntelliPhotoGui.cpp +++ b/IntelliPhoto/Painting/GUI/IntelliPhotoGui.cpp @@ -61,12 +61,14 @@ void IntelliPhotoGui::open() // Called when the user clicks Save As in the menu void IntelliPhotoGui::save() { + // A QAction represents the action of the user clicking QAction *action = qobject_cast(sender()); // Stores the array of bytes of the users data QByteArray fileFormat = action->data().toByteArray(); + // Pass it to be saved saveFile(fileFormat); } @@ -216,9 +218,21 @@ void IntelliPhotoGui::createActions() saveAsActs.append(action); } + QAction *action = new QAction("PNG-8", this); + + // Set an action for each file format + action->setData("PNG"); + + // When clicked call IntelliPhotoGui::save() + connect(action, SIGNAL(triggered()), this, SLOT(save())); + + // Attach each file format option menu item to Save As + saveAsActs.append(action); + + // Create exit action and tie to IntelliPhotoGui::close() - exitAct = new QAction(tr("&Exit"), this); + exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); @@ -392,6 +406,10 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat) // Define path, name and default file type QString initialPath = QDir::currentPath() + "/untitled." + fileFormat; + + + + // Get selected file from dialog // Add the proper file formats and extensions QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), diff --git a/IntelliPhoto/Painting/Image/IntelliImage.cpp b/IntelliPhoto/Painting/Image/IntelliImage.cpp index 879e8c7..42be65d 100644 --- a/IntelliPhoto/Painting/Image/IntelliImage.cpp +++ b/IntelliPhoto/Painting/Image/IntelliImage.cpp @@ -19,10 +19,8 @@ bool IntelliImage::loadImage(const QString &fileName){ if (!loadedImage.load(fileName)) return false; - // scaled Image to size of Layer - // loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); - - imageData = loadedImage.convertToFormat(QImage::Format_ARGB32); + loadedImage =loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); + imageData= loadedImage.convertToFormat(QImage::Format_ARGB32); return true; } diff --git a/IntelliPhoto/Painting/Image/IntelliImage.h b/IntelliPhoto/Painting/Image/IntelliImage.h index a2fb3c0..030e3be 100644 --- a/IntelliPhoto/Painting/Image/IntelliImage.h +++ b/IntelliPhoto/Painting/Image/IntelliImage.h @@ -29,8 +29,8 @@ public: virtual void floodFill(const QColor& color); //returns the filtered output - virtual QImage getDisplayable(const QSize& displaySize, int alpha)=0; - virtual QImage getDisplayable(int alpha=255)=0; + virtual QImage getDisplayable(const QSize& displaySize)=0; + virtual QImage getDisplayable()=0; //returns the filtered output diff --git a/IntelliPhoto/Painting/Image/IntelliRasterImage.cpp b/IntelliPhoto/Painting/Image/IntelliRasterImage.cpp index b73c264..50eaa33 100644 --- a/IntelliPhoto/Painting/Image/IntelliRasterImage.cpp +++ b/IntelliPhoto/Painting/Image/IntelliRasterImage.cpp @@ -12,19 +12,12 @@ IntelliRasterImage::~IntelliRasterImage(){ } -QImage IntelliRasterImage::getDisplayable(int alpha){ - return getDisplayable(imageData.size(), alpha); +QImage IntelliRasterImage::getDisplayable(){ + return getDisplayable(imageData.size()); } -QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ +QImage IntelliRasterImage::getDisplayable(const QSize& displaySize){ QImage copy = imageData; - for(int y = 0; y& polygonData) override; diff --git a/IntelliPhoto/Painting/IntelliPhoto.pro.user.2eff11b b/IntelliPhoto/Painting/IntelliPhoto.pro.user.2eff11b deleted file mode 100644 index 06819e8..0000000 --- a/IntelliPhoto/Painting/IntelliPhoto.pro.user.2eff11b +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - EnvironmentId - {2eff11b9-2504-4003-b4ce-30c119b76df9} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - -fno-delayed-template-parsing - - true - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.12.5 MSVC2017 64bit - Desktop Qt 5.12.5 MSVC2017 64bit - qt.qt5.5125.win64_msvc2017_64_kit - 0 - 0 - 0 - - C:/Users/Basti/OneDrive/Documents/Uni/Softwaretechnologie/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MSVC2017_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Erstellen - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Bereinigen - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - C:/Users/Basti/OneDrive/Documents/Uni/Softwaretechnologie/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MSVC2017_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Erstellen - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Bereinigen - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - C:/Users/Basti/OneDrive/Documents/Uni/Softwaretechnologie/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MSVC2017_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Erstellen - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Bereinigen - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deployment - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deployment-Konfiguration - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - IntelliPhoto - - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Basti/OneDrive/Documents/Uni/Softwaretechnologie/IntelliPhoto/Painting/IntelliPhoto.pro - - 3768 - false - true - true - false - false - true - - C:/Users/Basti/OneDrive/Documents/Uni/Softwaretechnologie/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MSVC2017_64bit-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/IntelliPhoto/Painting/IntelliPhoto.pro.user.426164d b/IntelliPhoto/Painting/IntelliPhoto.pro.user.426164d index 7a6a7ab..8c0d660 100644 --- a/IntelliPhoto/Painting/IntelliPhoto.pro.user.426164d +++ b/IntelliPhoto/Painting/IntelliPhoto.pro.user.426164d @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/IntelliPhoto/Painting/Layer/PaintingArea.cpp b/IntelliPhoto/Painting/Layer/PaintingArea.cpp index f1a228d..cf0ef5e 100644 --- a/IntelliPhoto/Painting/Layer/PaintingArea.cpp +++ b/IntelliPhoto/Painting/Layer/PaintingArea.cpp @@ -1,17 +1,25 @@ // ---------- PaintingArea.cpp ---------- #include -#include +#include #include "PaintingArea.h" #include "Image/IntelliRasterImage.h" #include "Image/IntelliShapedImage.h" -#include -#include +#include +#include -PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) - :QWidget(parent){ - this->setUp(maxWidth, maxHeight); +PaintingArea::PaintingArea(QWidget *parent) + : QWidget(parent) +{ + //create standart image + this->image = new IntelliRasterImage(400,400); + std::vector poly; + poly.push_back(QPoint(200,0)); + poly.push_back(QPoint(400,300)); + poly.push_back(QPoint(0,300)); + poly.push_back(QPoint(200,0)); + image->setPolygon(poly); //tetsing this->addLayer(200,200,0,0,ImageType::Shaped_Image); @@ -29,17 +37,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) activeLayer=1; } - - - -void PaintingArea::setUp(int maxWidth, int maxHeight){ - - //set standart parameter - this->maxWidth = maxWidth; - this->maxHeight = maxHeight; - Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32); - Canvas->fill(Qt::GlobalColor::white); - +void PaintingArea::setUp(){ // Roots the widget to the top left even if resized setAttribute(Qt::WA_StaticContents); @@ -47,16 +45,13 @@ void PaintingArea::setUp(int maxWidth, int maxHeight){ scribbling = false; myPenWidth = 1; myPenColor = Qt::blue; + } -void PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){ - LayerObject newLayer; - newLayer.width = width; - newLayer.height = height; - newLayer.widthOffset = widthOffset; - newLayer.heightOffset = heightOffset; +PaintingArea::PaintingArea(int width, int height, ImageType type, QWidget *parent) + : QWidget(parent){ if(type==ImageType::Raster_Image){ - newLayer.image = new IntelliRasterImage(width,height); + this->image = new IntelliRasterImage(width, height); }else if(type==ImageType::Shaped_Image){ newLayer.image = new IntelliShapedImage(width, height); } @@ -72,19 +67,9 @@ void PaintingArea::deleteLayer(int index){ activeLayer--; } } + this->setUp(); } -void PaintingArea::setLayerToActive(int index) { - if(indexactiveLayer=index; - } -} - -void PaintingArea::setAlphaToLayer(int index, int alpha){ - if(indexactiveLayer==-1){ - return false; - } - IntelliImage* active = layerStructure[activeLayer].image; - bool open = active->loadImage(fileName); + bool open = image->loadImage(fileName); update(); return open; } @@ -206,7 +187,6 @@ void PaintingArea::mousePressEvent(QMouseEvent *event) // from the last position to the current void PaintingArea::mouseMoveEvent(QMouseEvent *event) { - if ((event->buttons() & Qt::LeftButton) && scribbling){ if(this->activeLayer==-1){ return; @@ -258,26 +238,17 @@ void PaintingArea::paintEvent(QPaintEvent *event) // to cut down on the need to resize the image void PaintingArea::resizeEvent(QResizeEvent *event) { - if(this->activeLayer==-1){ - return; - } - LayerObject active = layerStructure[activeLayer]; - QPainter painter(this); QRect dirtyRec(QPoint(0,0), event->size()); - painter.drawImage(dirtyRec, active.image->getDisplayable(event->size(), active.alpha), dirtyRec); + painter.drawImage(dirtyRec, image->getDisplayable(event->size()), dirtyRec); update(); + //QWidget::resizeEvent(event); } void PaintingArea::drawLineTo(const QPoint &endPoint) { - //// Used to draw on the widget - if(this->activeLayer==-1){ - return; - } - LayerObject active = layerStructure[activeLayer]; - - active.image->drawLine(lastPoint, endPoint,myPenColor, myPenWidth); + // Used to draw on the widget + image->drawLine(lastPoint, endPoint,myPenColor, myPenWidth); lastPoint = endPoint; update(); } diff --git a/IntelliPhoto/Painting/Layer/PaintingArea.h b/IntelliPhoto/Painting/Layer/PaintingArea.h index 6346687..62fd3cd 100644 --- a/IntelliPhoto/Painting/Layer/PaintingArea.h +++ b/IntelliPhoto/Painting/Layer/PaintingArea.h @@ -7,7 +7,6 @@ #include"Image/IntelliImage.h" #include #include -#include class PaintingArea : public QWidget { @@ -17,24 +16,19 @@ class PaintingArea : public QWidget Q_OBJECT public: - PaintingArea(int maxWidth=1000, int maxHeight=800, QWidget *parent = nullptr); + //create raster image 400*200 + PaintingArea(QWidget *parent = nullptr); + PaintingArea(int width, int height, ImageType type, QWidget *parent = nullptr); // Handles all events bool openImage(const QString &fileName); bool saveImage(const QString &fileName, const char *fileFormat); - - void addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image); - void deleteLayer(int index); - void setLayerToActive(int index); - void setAlphaToLayer(int index, int alpha); + void setPenColor(const QColor &newColor); + void setPenWidth(int newWidth); // Has the image been modified since last save bool isModified() const { return modified; } - - void setPenColor(const QColor &newColor); QColor penColor() const { return myPenColor; } - - void setPenWidth(int newWidth); int penWidth() const { return myPenWidth; } @@ -53,7 +47,7 @@ public slots: void getMoveLayerUp(); void getMoveLayerDown(); //void setUp helper for konstruktor - void setUp(int maxWidth, int maxHeight); + void setUp(); protected: void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; @@ -101,6 +95,7 @@ private: QColor myPenColor; // Stores the image being drawn + IntelliImage* image; // Stores the location at the current mouse event QPoint lastPoint;