From ede3f512cd884145a2eb1bd8f847d68a21d54456 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Mon, 20 Jan 2020 20:05:51 +0100 Subject: [PATCH 01/18] lets go with datamanager --- src/IntelliHelper/IntelliDatamanager.cpp | 16 ++++++++++++++++ src/IntelliHelper/IntelliDatamanager.h | 17 +++++++++++++++++ src/IntelliPhoto.pro | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 src/IntelliHelper/IntelliDatamanager.cpp create mode 100644 src/IntelliHelper/IntelliDatamanager.h diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp new file mode 100644 index 0000000..38996c2 --- /dev/null +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -0,0 +1,16 @@ +#include "IntelliDatamanager.h" + +IntelliDatamanager::IntelliDatamanager() +{ + +} + +void IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ + + + return; +} + +void IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ + return; +} diff --git a/src/IntelliHelper/IntelliDatamanager.h b/src/IntelliHelper/IntelliDatamanager.h new file mode 100644 index 0000000..a70fbe5 --- /dev/null +++ b/src/IntelliHelper/IntelliDatamanager.h @@ -0,0 +1,17 @@ +#ifndef INTELLIDATAMANAGER_H +#define INTELLIDATAMANAGER_H + +#include "Layer/PaintingArea.h" +#include + +class IntelliDatamanager +{ +private: + +public: + void loadProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); + void saveProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); + IntelliDatamanager(); +}; + +#endif // INTELLIDATAMANAGER_H diff --git a/src/IntelliPhoto.pro b/src/IntelliPhoto.pro index faf6c86..2b1d4d5 100755 --- a/src/IntelliPhoto.pro +++ b/src/IntelliPhoto.pro @@ -22,6 +22,7 @@ SOURCES += \ Image/IntelliRasterImage.cpp \ Image/IntelliShapedImage.cpp \ IntelliHelper/IntelliColorPicker.cpp \ + IntelliHelper/IntelliDatamanager.cpp \ IntelliHelper/IntelliRenderSettings.cpp \ IntelliHelper/IntelliToolsettings.cpp \ IntelliHelper/IntelliTriangulation.cpp \ @@ -43,6 +44,7 @@ HEADERS += \ Image/IntelliRasterImage.h \ Image/IntelliShapedImage.h \ IntelliHelper/IntelliColorPicker.h \ + IntelliHelper/IntelliDatamanager.h \ IntelliHelper/IntelliRenderSettings.h \ IntelliHelper/IntelliToolsettings.h \ IntelliHelper/IntelliTriangulation.h \ From 82281d091ce2499958693e621fbf88230a8f63e0 Mon Sep 17 00:00:00 2001 From: Mienek Date: Mon, 20 Jan 2020 20:07:40 +0100 Subject: [PATCH 02/18] Updated Sequenzdiagramme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sequenzdiagramme Pen- und Plaintool überarbeitet --- .../Sequenzdiagram-PenTool.uxf | 332 ++++++++++-------- .../Sequenzdiagram-PlainTool.uxf | 280 ++++++++------- 2 files changed, 342 insertions(+), 270 deletions(-) diff --git a/docs/Sequenzdiagramme/Sequenzdiagram-PenTool.uxf b/docs/Sequenzdiagramme/Sequenzdiagram-PenTool.uxf index 020ddd8..f4c8db6 100644 --- a/docs/Sequenzdiagramme/Sequenzdiagram-PenTool.uxf +++ b/docs/Sequenzdiagramme/Sequenzdiagram-PenTool.uxf @@ -1,13 +1,13 @@ - 10 + 14 UMLGeneric - 530 - 70 - 100 - 30 + 378 + 14 + 140 + 42 _:PaintingArea_ @@ -15,10 +15,10 @@ Relation - 570 - 90 - 30 - 70 + 434 + 42 + 42 + 98 lt=. 10.0;10.0;10.0;50.0 @@ -26,10 +26,10 @@ UMLActor - 340 - 60 - 60 - 110 + 112 + 0 + 84 + 154 @@ -37,10 +37,10 @@ UMLGeneric - 360 - 140 - 20 - 780 + 140 + 112 + 28 + 1092 @@ -48,10 +48,10 @@ UMLGeneric - 570 - 140 - 20 - 780 + 434 + 112 + 28 + 1092 @@ -59,10 +59,10 @@ Relation - 370 - 140 - 220 - 40 + 154 + 112 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -71,10 +71,10 @@ MouseLeftPressed(event) UMLGeneric - 780 - 140 - 20 - 780 + 728 + 112 + 28 + 1092 @@ -82,32 +82,10 @@ MouseLeftPressed(event) UMLGeneric - 740 - 70 - 100 - 30 - - _:IntelliTool_ - - - - Relation - - 780 - 90 - 30 - 70 - - lt=. - 10.0;10.0;10.0;50.0 - - - UMLGeneric - - 950 - 70 - 100 - 30 + 672 + 14 + 140 + 42 _:IntelliToolPen_ @@ -115,10 +93,10 @@ MouseLeftPressed(event) Relation - 990 - 90 - 30 - 70 + 728 + 42 + 42 + 98 lt=. 10.0;10.0;10.0;50.0 @@ -126,10 +104,32 @@ MouseLeftPressed(event) UMLGeneric - 990 - 140 - 20 - 770 + 966 + 14 + 140 + 42 + + _:IntelliTool_ + + + + Relation + + 1022 + 42 + 42 + 98 + + lt=. + 10.0;10.0;10.0;50.0 + + + UMLGeneric + + 1022 + 112 + 28 + 1078 @@ -137,10 +137,10 @@ MouseLeftPressed(event) Relation - 370 - 430 - 220 - 40 + 154 + 518 + 308 + 56 lt=<- updateInterface() @@ -149,10 +149,10 @@ updateInterface() Relation - 580 - 160 - 220 - 40 + 448 + 140 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -161,10 +161,10 @@ MouseLeftPressed(event) Relation - 790 - 180 - 220 - 40 + 742 + 168 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -173,10 +173,10 @@ MouseLeftPressed(event) Relation - 370 - 300 - 220 - 40 + 154 + 336 + 308 + 56 lt=<- MouseMove(event) @@ -185,22 +185,22 @@ MouseMove(event) Relation - 580 - 320 - 220 - 40 + 448 + 364 + 308 + 56 lt=<- -MouseMove(koordinates) +MouseMove(coordinates) 200.0;20.0;10.0;20.0 UMLFrame - 290 - 250 - 840 - 240 + 42 + 266 + 1176 + 336 loop -- @@ -215,34 +215,34 @@ until MouseLeftReleased(event) or MouseRightPressed(event) Relation - 790 - 340 - 220 - 40 + 742 + 392 + 308 + 56 lt=<- -MouseMove(koordinates) +MouseMove(coordinates) 200.0;20.0;10.0;20.0 Relation - 580 - 400 - 430 - 40 + 448 + 476 + 308 + 56 lt=<- -DrwaLineToKoordinates() - 10.0;20.0;410.0;20.0 +DrwaLineToCoordinates() + 10.0;20.0;200.0;20.0 UMLFrame - 290 - 520 - 840 - 350 + 42 + 644 + 1176 + 490 alt -- @@ -262,10 +262,10 @@ DrwaLineToKoordinates() Relation - 370 - 550 - 220 - 40 + 154 + 686 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -274,10 +274,10 @@ MouseLeftReleased(event) Relation - 580 - 570 - 220 - 40 + 448 + 714 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -286,10 +286,10 @@ MouseLeftReleased(event) Relation - 790 - 590 - 220 - 40 + 742 + 742 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -298,22 +298,22 @@ MouseLeftReleased(event) Relation - 580 - 630 - 430 - 40 + 448 + 798 + 308 + 56 lt=<- MergeSubLayer() - 10.0;20.0;410.0;20.0 + 10.0;20.0;200.0;20.0 Relation - 580 + 448 210 - 430 - 40 + 602 + 56 lt=<- CreateSubLayer() @@ -322,10 +322,10 @@ CreateSubLayer() Relation - 370 - 720 - 220 - 40 + 154 + 924 + 308 + 56 lt=<- MouseRightPressed(event) @@ -334,10 +334,10 @@ MouseRightPressed(event) Relation - 580 - 740 - 220 - 40 + 448 + 952 + 308 + 56 lt=<- MouseRightPressed(event) @@ -346,10 +346,10 @@ MouseRightPressed(event) Relation - 790 - 760 - 220 - 40 + 742 + 980 + 308 + 56 lt=<- MouseRightPressed(event) @@ -358,22 +358,22 @@ MouseRightPressed(event) Relation - 580 - 790 - 430 - 40 + 448 + 1022 + 308 + 56 lt=<- DeleteSubLayer() - 10.0;20.0;410.0;20.0 + 10.0;20.0;200.0;20.0 Relation - 370 - 660 - 220 - 40 + 154 + 840 + 308 + 56 lt=<- updateInterface() @@ -382,13 +382,49 @@ updateInterface() Relation - 370 - 820 - 220 - 40 + 154 + 1064 + 308 + 56 lt=<- updateInterface() 10.0;20.0;200.0;20.0 + + Relation + + 742 + 448 + 308 + 56 + + lt=<- +() + 10.0;20.0;200.0;20.0 + + + Relation + + 742 + 770 + 308 + 56 + + lt=<- +() + 10.0;20.0;200.0;20.0 + + + Relation + + 742 + 1008 + 308 + 56 + + lt=<- +() + 10.0;20.0;200.0;20.0 + diff --git a/docs/Sequenzdiagramme/Sequenzdiagram-PlainTool.uxf b/docs/Sequenzdiagramme/Sequenzdiagram-PlainTool.uxf index 9f91896..0e319e4 100644 --- a/docs/Sequenzdiagramme/Sequenzdiagram-PlainTool.uxf +++ b/docs/Sequenzdiagramme/Sequenzdiagram-PlainTool.uxf @@ -1,13 +1,13 @@ - 10 + 14 UMLGeneric - 630 - 80 - 100 - 30 + 392 + 56 + 140 + 42 _:PaintingArea_ @@ -15,10 +15,10 @@ Relation - 670 - 100 - 30 - 70 + 448 + 84 + 42 + 98 lt=. 10.0;10.0;10.0;50.0 @@ -26,10 +26,10 @@ UMLActor - 440 - 70 - 60 - 110 + 126 + 42 + 84 + 154 @@ -37,10 +37,10 @@ UMLGeneric - 460 - 150 - 20 - 490 + 154 + 154 + 28 + 686 @@ -48,10 +48,10 @@ UMLGeneric - 670 - 150 - 20 - 490 + 448 + 154 + 28 + 686 @@ -59,10 +59,10 @@ Relation - 470 - 150 - 220 - 40 + 168 + 154 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -71,10 +71,10 @@ MouseLeftPressed(event) UMLGeneric - 880 - 150 - 20 - 490 + 742 + 154 + 28 + 686 @@ -82,32 +82,10 @@ MouseLeftPressed(event) UMLGeneric - 840 - 80 - 100 - 30 - - _:IntelliTool_ - - - - Relation - - 880 - 100 - 30 - 70 - - lt=. - 10.0;10.0;10.0;50.0 - - - UMLGeneric - - 1050 - 80 - 100 - 30 + 686 + 56 + 140 + 42 _:IntelliToolPlain_ @@ -115,10 +93,10 @@ MouseLeftPressed(event) Relation - 1090 - 100 - 30 - 70 + 742 + 84 + 42 + 98 lt=. 10.0;10.0;10.0;50.0 @@ -126,10 +104,32 @@ MouseLeftPressed(event) UMLGeneric - 1090 - 150 - 20 - 490 + 980 + 56 + 140 + 42 + + _:IntelliTool_ + + + + Relation + + 1036 + 84 + 42 + 98 + + lt=. + 10.0;10.0;10.0;50.0 + + + UMLGeneric + + 1036 + 154 + 28 + 686 @@ -137,10 +137,10 @@ MouseLeftPressed(event) Relation - 680 - 170 - 220 - 40 + 462 + 182 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -149,10 +149,10 @@ MouseLeftPressed(event) Relation - 890 - 190 - 220 - 40 + 756 + 210 + 308 + 56 lt=<- MouseLeftPressed(event) @@ -161,22 +161,22 @@ MouseLeftPressed(event) Relation - 680 - 220 - 430 - 40 + 462 + 252 + 308 + 56 lt=<- CreateSubLayer() - 10.0;20.0;410.0;20.0 + 10.0;20.0;200.0;20.0 Relation - 470 - 280 - 220 - 40 + 168 + 336 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -185,10 +185,10 @@ MouseLeftReleased(event) Relation - 680 - 300 - 220 - 40 + 462 + 364 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -197,10 +197,10 @@ MouseLeftReleased(event) Relation - 890 - 320 - 220 - 40 + 756 + 392 + 308 + 56 lt=<- MouseLeftReleased(event) @@ -209,22 +209,22 @@ MouseLeftReleased(event) Relation - 680 - 360 - 430 - 40 + 462 + 448 + 308 + 56 lt=<- MergeSubLayer() - 10.0;20.0;410.0;20.0 + 10.0;20.0;200.0;20.0 Relation - 470 - 390 - 220 - 40 + 168 + 490 + 308 + 56 lt=<- updateInterface() @@ -233,10 +233,10 @@ updateInterface() UMLFrame - 390 - 250 - 840 - 350 + 56 + 294 + 1176 + 490 alt -- @@ -256,10 +256,10 @@ updateInterface() Relation - 470 - 450 - 220 - 40 + 168 + 574 + 308 + 56 lt=<- MouseRightPressed(event) @@ -268,10 +268,10 @@ MouseRightPressed(event) Relation - 470 - 550 - 220 - 40 + 168 + 714 + 308 + 56 lt=<- updateInterface() @@ -280,22 +280,22 @@ updateInterface() Relation - 680 - 520 - 430 - 40 + 462 + 672 + 308 + 56 lt=<- DeleteSubLayer() - 10.0;20.0;410.0;20.0 + 10.0;20.0;200.0;20.0 Relation - 680 - 470 - 220 - 40 + 462 + 602 + 308 + 56 lt=<- MouseRightPressed(event) @@ -304,13 +304,49 @@ MouseRightPressed(event) Relation - 890 - 490 - 220 - 40 + 756 + 630 + 308 + 56 lt=<- MouseRightPressed(event) 200.0;20.0;10.0;20.0 + + Relation + + 756 + 238 + 308 + 56 + + lt=<- +CreateSubLayer() + 10.0;20.0;200.0;20.0 + + + Relation + + 756 + 420 + 308 + 56 + + lt=<- +() + 10.0;20.0;200.0;20.0 + + + Relation + + 756 + 658 + 308 + 56 + + lt=<- +() + 10.0;20.0;200.0;20.0 + From 8e187ba6b369912a084c00c1f53bb7440be22404 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Wed, 22 Jan 2020 21:19:24 +0100 Subject: [PATCH 03/18] basics of zoom and scroll --- src/GUI/IntelliPhotoGui.cpp | 16 ++++++--- src/GUI/IntelliPhotoGui.h | 70 +++++++++++++++++++++++-------------- src/Layer/PaintingArea.cpp | 17 +++++---- src/Layer/PaintingArea.h | 5 +-- src/Tool/IntelliTool.cpp | 4 +-- 5 files changed, 71 insertions(+), 41 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 5734d47..9fec611 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -18,7 +18,6 @@ IntelliPhotoGui::IntelliPhotoGui(){ setIntelliStyle(); // Size the app resize(600,600); - showMaximized(); setDefaultToolValue(); } @@ -550,6 +549,7 @@ void IntelliPhotoGui::createMenus(){ layerCreationMenu = new QMenu(tr("&Create new Layer"), this); layerCreationMenu->addAction(actionCreateNewRasterLayer); layerCreationMenu->addAction(actionCreateNewShapedLayer); + // Attach all actions to Layer layerMenu = new QMenu(tr("&Layer"), this); layerMenu->addMenu(layerCreationMenu); @@ -626,7 +626,7 @@ void IntelliPhotoGui::createGui(){ // create Gui elements // get and set max width and height paintingArea = new PaintingArea(1280, 720); - paintingArea->DummyGui = this; + paintingArea->guiReference = this; preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg"); CircleButton = new QPushButton(); @@ -740,8 +740,14 @@ void IntelliPhotoGui::createGui(){ QString String = QString("%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height()); dimCanvas->setText(String); + ScrollArea = new QScrollArea(this); + ScrollArea->setBackgroundRole(QPalette::Dark); + ScrollArea->setWidget(paintingArea); + ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + ScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + // set gui elements - mainLayout->addWidget(paintingArea,1,1,20,1); + mainLayout->addWidget(ScrollArea,1,1,20,1); mainLayout->addWidget(CircleButton,1,2,1,1); mainLayout->addWidget(FloodFillButton,1,3,1,1); mainLayout->addWidget(LineButton,2,2,1,1); @@ -846,7 +852,9 @@ void IntelliPhotoGui::UpdateGui(){ tmp.fill(Qt::transparent); preview = preview.fromImage(tmp); } - ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2)); + + + ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2)); string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); FirstColorButton->setStyleSheet(string); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 8d164a4..7a20ccc 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "IntelliInputDialog.h" //for unit testing @@ -96,10 +97,11 @@ void slotSetInnerAlpha(); void slotResetTools(); private: + +//setup functions for gui void createActions(); void createMenus(); void createGui(); -// Set the style of the GUI void setIntelliStyle(); // Will check if changes have occurred since last save @@ -107,13 +109,19 @@ bool maybeSave(); // Opens the Save dialog and saves bool saveFile(const QByteArray &fileFormat); +//basic to set tool values to begin void setDefaultToolValue(); // What we'll draw on PaintingArea* paintingArea; -const QSize Buttonsize = QSize(35,35); +//used to display a preview of the active layer QPixmap preview; + +//size of all buttons +const QSize Buttonsize = QSize(35,35); + +//buttons used for gui QPushButton* CircleButton; QPushButton* FloodFillButton; QPushButton* LineButton; @@ -121,35 +129,42 @@ QPushButton* PenButton; QPushButton* PlainButton; QPushButton* PolygonButton; QPushButton* RectangleButton; -QLabel* WidthLine; -QLabel* innerAlphaLine; -QLineEdit* EditLineWidth; -QLineEdit* EditLineInnerAlpha; -QIntValidator* ValidatorLineWidth; -QIntValidator* ValidatorInnerAlpha; - QPushButton* FirstColorButton; QPushButton* SecondColorButton; QPushButton* SwitchColorButton; - -QLabel* ActiveLayerLine; -QLabel* ActiveLayerImageLabel; - QPushButton* dimActive; QPushButton* dimCanvas; +//labels used for gui +QLabel* WidthLine; +QLabel* innerAlphaLine; +QLabel* ActiveLayerLine; +QLabel* ActiveLayerImageLabel; + +//scroll area to display canvas +QScrollArea* ScrollArea; + +//line edits used for gui +QLineEdit* EditLineWidth; +QLineEdit* EditLineInnerAlpha; + +//int validator used for gui +QIntValidator* ValidatorLineWidth; +QIntValidator* ValidatorInnerAlpha; + + // The menu widgets -QMenu*saveAsMenu; -QMenu*fileMenu; -QMenu*renderMenu; -QMenu*optionMenu; -QMenu*layerCreationMenu; -QMenu*layerMenu; -QMenu*colorMenu; -QMenu*toolCreationMenu; -QMenu*toolSettingsMenu; -QMenu*toolMenu; -QMenu*helpMenu; +QMenu* saveAsMenu; +QMenu* fileMenu; +QMenu* renderMenu; +QMenu* optionMenu; +QMenu* layerCreationMenu; +QMenu* layerMenu; +QMenu* colorMenu; +QMenu* toolCreationMenu; +QMenu* toolSettingsMenu; +QMenu* toolMenu; +QMenu* helpMenu; // All the actions that can occur // meta image actions (need further modularisation) @@ -175,7 +190,9 @@ QAction* actionCreatePolygonTool; QAction* actionCreateFloodFillTool; // dimension actions -QAction*actionChangeDim; +QAction* actionChangeDim; +QAction* actionSetWidth; +QAction* actionSetInnerAlpha; // dialog actions QAction* actionAboutDialog; @@ -198,8 +215,7 @@ QAction* actionMoveLayerDown; // Actions tied to specific file formats QList actionSaveAs; -QAction* actionSetWidth; -QAction* actionSetInnerAlpha; + // main GUI elements QWidget* centralGuiWidget; diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index b471da0..2e23384 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -20,7 +20,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) - : QWidget(parent){ + : QLabel(parent){ this->Tool = nullptr; this->setLayerDimensions(maxWidth, maxHeight); @@ -120,7 +120,7 @@ void PaintingArea::setPolygon(int idx){ delete this->Tool; this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true); isSettingPolygon = true; - this->DummyGui->setToolWidth(5); + this->guiReference->setToolWidth(5); } } } @@ -174,7 +174,7 @@ void PaintingArea::moveActiveLayer(int idx){ }else if(idx==-1) { this->selectLayerDown(); } - DummyGui->UpdateGui(); + guiReference->UpdateGui(); } void PaintingArea::slotActivateLayer(int a){ @@ -322,11 +322,16 @@ void PaintingArea::wheelEvent(QWheelEvent*event){ // The QPaintEvent is sent to widgets that need to // update themselves void PaintingArea::paintEvent(QPaintEvent*event){ + this->setFixedSize(QSize(maxWidth,maxHeight)); this->drawLayers(); - QPainter painter(this); - QRect dirtyRec = event->rect(); - painter.drawImage(dirtyRec, *Canvas, dirtyRec); + QPainter painter(this); + + //insert zoom factor here + painter.scale(1,1); + + //calulate image here for scroll + painter.drawImage(0,0, *Canvas); update(); } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 58eb411..731e972 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -50,7 +50,7 @@ struct LayerObject { /*! * \brief The PaintingArea class manages the methods and stores information about the current painting area, which is the currently opened project */ -class PaintingArea : public QWidget +class PaintingArea : public QLabel { friend UnitTest; // Declares our class as a QObject which is the base class @@ -228,6 +228,7 @@ void selectLayerDown(); IntelliTool* copyActiveTool(); QImage* Canvas; +QImage ScaledCanvas; int maxWidth; int maxHeight; @@ -235,7 +236,7 @@ bool isSettingPolygon = false; IntelliRenderSettings renderSettings; IntelliTool* Tool; -IntelliPhotoGui* DummyGui; +IntelliPhotoGui* guiReference; std::vector layerBundle; int activeLayer = -1; diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 11ed60b..0088f05 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -50,7 +50,7 @@ void IntelliTool::onMouseMoved(int x, int y){ void IntelliTool::onWheelScrolled(int value){ //if needed for future general tasks implement in here - Area->DummyGui->setToolWidth(value + Toolsettings->getLineWidth()); + Area->guiReference->setToolWidth(value + Toolsettings->getLineWidth()); } bool IntelliTool::createToolLayer(){ @@ -88,7 +88,7 @@ void IntelliTool::mergeToolLayer(){ if(Canvas->image->getPolygonData().size() > 0) { activeLayer->image->setPolygon(Canvas->image->getPolygonData()); } - Area->DummyGui->UpdateGui(); + Area->guiReference->UpdateGui(); } void IntelliTool::deleteToolLayer(){ From 651bf806fc7fe5eac9e8bf541582ba26660b6c4d Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Wed, 22 Jan 2020 21:52:08 +0100 Subject: [PATCH 04/18] upset for future work --- src/GUI/IntelliPhotoGui.cpp | 1 + src/Layer/PaintingArea.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 9fec611..cddc0ed 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -5,6 +5,7 @@ #include "QEvent" #include "QCloseEvent" +#include "QScrollBar" // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(){ diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 2e23384..334a4d4 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -322,7 +322,7 @@ void PaintingArea::wheelEvent(QWheelEvent*event){ // The QPaintEvent is sent to widgets that need to // update themselves void PaintingArea::paintEvent(QPaintEvent*event){ - this->setFixedSize(QSize(maxWidth,maxHeight)); + this->setFixedSize(QSize(maxWidth*2,maxHeight*2)); this->drawLayers(); QPainter painter(this); @@ -331,7 +331,8 @@ void PaintingArea::paintEvent(QPaintEvent*event){ painter.scale(1,1); //calulate image here for scroll - painter.drawImage(0,0, *Canvas); + //Todo set offset in first to parameters and calulate them into mouse position + painter.drawImage(0, 0, *Canvas, 0, 0); update(); } From 9651dd98e36bdaf36b565915f03fe61e258dc498 Mon Sep 17 00:00:00 2001 From: Mienek Date: Thu, 23 Jan 2020 13:13:31 +0100 Subject: [PATCH 05/18] start of history --- src/GUI/IntelliPhotoGui.cpp | 22 +++- src/GUI/IntelliPhotoGui.h | 9 +- src/Image/IntelliImage.cpp | 15 ++- src/Image/IntelliImage.h | 22 ++-- src/Image/IntelliRasterImage.cpp | 16 ++- src/Image/IntelliRasterImage.cpp.autosave | 61 +++++++++++ src/Image/IntelliRasterImage.h | 2 + src/Image/IntelliShapedImage.cpp | 15 ++- src/Image/IntelliShapedImage.cpp.autosave | 120 ++++++++++++++++++++++ src/Image/IntelliShapedImage.h | 1 + src/Layer/PaintingArea.cpp | 57 +++++++++- src/Layer/PaintingArea.h | 21 +++- src/Tool/IntelliTool.cpp | 1 + src/Tool/IntelliToolPolygon.cpp | 4 +- 14 files changed, 339 insertions(+), 27 deletions(-) create mode 100644 src/Image/IntelliRasterImage.cpp.autosave create mode 100644 src/Image/IntelliShapedImage.cpp.autosave diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 5734d47..a031e00 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -82,7 +82,7 @@ void IntelliPhotoGui::slotCreateNewRasterLayer(){ // Create New Layer if (ok1&&ok2) { - paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::RASTERIMAGE); + paintingArea->addLayer(width,height,0,0,ImageType::RASTERIMAGE); UpdateGui(); } } @@ -101,7 +101,7 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){ // Create New Layer if (ok1&&ok2) { - paintingArea->addLayer(width, height, 0, 0, IntelliImage::ImageType::SHAPEDIMAGE); + paintingArea->addLayer(width, height, 0, 0, ImageType::SHAPEDIMAGE); UpdateGui(); } } @@ -327,6 +327,14 @@ void IntelliPhotoGui::slotSetInnerAlpha(){ } } +void IntelliPhotoGui::slotGoBack(){ + paintingArea->historyGoBack(); +} + +void IntelliPhotoGui::slotGoForward(){ + paintingArea->historyGoForward(); +} + // Define menu actions that call functions void IntelliPhotoGui::createActions(){ // Get a list of the supported file formats @@ -525,6 +533,14 @@ void IntelliPhotoGui::createActions(){ actionSetInnerAlpha = new QAction(tr("&Set Inner Alpha"),this); actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); connect(actionSetInnerAlpha, SIGNAL(triggered()), this, SLOT(slotSetInnerAlpha())); + + actionGoBack = new QAction(tr("&Go back"),this); + actionGoBack->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z)); + connect(actionGoBack, SIGNAL(triggered()), this, SLOT(slotGoBack())); + + actionGoForward = new QAction(tr("&Go forward"),this); + actionGoForward->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y)); + connect(actionGoForward, SIGNAL(triggered()), this, SLOT(slotGoForward())); } // Create the menubar @@ -597,6 +613,8 @@ void IntelliPhotoGui::createMenus(){ // Attach all actions to Options optionMenu = new QMenu(tr("&Options"), this); + optionMenu->addAction(actionGoBack); + optionMenu->addAction(actionGoForward); optionMenu->addMenu(layerMenu); optionMenu->addMenu(toolMenu); optionMenu->addSeparator(); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 8d164a4..2f177aa 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -95,6 +95,9 @@ void slotSetInnerAlpha(); void slotResetTools(); +void slotGoBack(); +void slotGoForward(); + private: void createActions(); void createMenus(); @@ -195,12 +198,16 @@ QAction* actionMovePositionRight; QAction* actionMoveLayerUp; QAction* actionMoveLayerDown; -// Actions tied to specific file formats +// actions tied to specific file formats QList actionSaveAs; QAction* actionSetWidth; QAction* actionSetInnerAlpha; +// history actions +QAction* actionGoBack; +QAction* actionGoForward; + // main GUI elements QWidget* centralGuiWidget; QGridLayout* mainLayout; diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index 0017877..446997d 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -2,7 +2,7 @@ #include #include -IntelliImage::IntelliImage(int width, int height, bool fastRendererOn) +IntelliImage:: IntelliImage(int width, int height, bool fastRendererOn) : imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){ if(fastRendererOn) { imageData = imageData.convertToFormat(QImage::Format_ARGB32); @@ -15,6 +15,7 @@ IntelliImage::IntelliImage(int width, int height, bool fastRendererOn) } + IntelliImage::~IntelliImage(){ } @@ -158,3 +159,15 @@ void IntelliImage::updateRendererSetting(bool fastRendererOn){ this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); } } + +int IntelliImage::getWidth() const{ + return imageData.width(); +} + +int IntelliImage::getHeight() const{ + return imageData.height(); +} + +bool IntelliImage::isFastRendering() const{ + return this->fastRenderering; +} diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h index 5c19186..3d14259 100644 --- a/src/Image/IntelliImage.h +++ b/src/Image/IntelliImage.h @@ -16,6 +16,14 @@ class UnitTest; class IntelliTool; +/*! + * \brief The Types, which an Image can be. + */ +enum class ImageType { + RASTERIMAGE, + SHAPEDIMAGE +}; + /*! * \brief An abstract class which manages the basic IntelliImage operations. */ @@ -24,13 +32,6 @@ friend UnitTest; friend IntelliTool; public: -/*! - * \brief The Types, which an Image can be. - */ -enum class ImageType { - RASTERIMAGE, - SHAPEDIMAGE -}; protected: void resizeImage(QImage*image, const QSize &newSize); @@ -59,6 +60,7 @@ public: */ IntelliImage(int width, int height, bool fastRendererOn); + /*! * \brief An Abstract Destructor. */ @@ -170,6 +172,12 @@ virtual QImage getImageData(); */ virtual void setImageData(const QImage& newData); +virtual int getWidth() const; + +virtual int getHeight() const; + +virtual bool isFastRendering() const; + }; #endif diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index 3106e36..c70583c 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -5,18 +5,28 @@ IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) : IntelliImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; + TypeOfImage = ImageType::RASTERIMAGE; this->fastRenderering = fastRendererOn; } +/* +IntelliRasterImage::IntelliRasterImage(const IntelliRasterImage& image) + : IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ + this->TypeOfImage = ImageType::RASTERIMAGE; + IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); + raster->imageData.copy(0,0,image.getWidth(),image.getWidth()); +} +*/ + + IntelliRasterImage::~IntelliRasterImage(){ } IntelliImage* IntelliRasterImage::getDeepCopy(){ - IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false); + IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); raster->imageData.fill(Qt::transparent); - raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; + raster->TypeOfImage = ImageType::RASTERIMAGE; return raster; } diff --git a/src/Image/IntelliRasterImage.cpp.autosave b/src/Image/IntelliRasterImage.cpp.autosave new file mode 100644 index 0000000..9626f59 --- /dev/null +++ b/src/Image/IntelliRasterImage.cpp.autosave @@ -0,0 +1,61 @@ +#include "Image/IntelliRasterImage.h" +#include +#include +#include + +IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) + : IntelliImage(width, height, fastRendererOn){ + TypeOfImage = ImageType::RASTERIMAGE; + this->fastRenderering = fastRendererOn; +} + + +IntelliRasterImage::Copy(const IntelliRasterImage& image) + : IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ + this->TypeOfImage = ImageType::RASTERIMAGE; + IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); + raster->imageData.copy(0,0,image.getWidth(),image.getWidth()); +} + + + +IntelliRasterImage::~IntelliRasterImage(){ + +} + +IntelliImage* IntelliRasterImage::getDeepCopy(){ + IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); + raster->imageData.fill(Qt::transparent); + raster->TypeOfImage = ImageType::RASTERIMAGE; + return raster; +} + +void IntelliRasterImage::calculateVisiblity(){ + // not used in raster image +} + +QImage IntelliRasterImage::getDisplayable(int alpha){ + return getDisplayable(imageData.size(), alpha); +} + +QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ + QImage copy = imageData; + if(fastRenderering) { + copy = copy.convertToFormat(QImage::Format_ARGB32); + } + for(int y = 0; y& polygonData){ + return; +} diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index a67472a..8f3eb71 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -26,6 +26,8 @@ public: */ IntelliRasterImage(int width, int height, bool fastRendererOn); +//IntelliRasterImage(const IntelliRasterImage& image); + /*! * \brief An Destructor. */ diff --git a/src/Image/IntelliShapedImage.cpp b/src/Image/IntelliShapedImage.cpp index 14c7b71..9e73d2c 100644 --- a/src/Image/IntelliShapedImage.cpp +++ b/src/Image/IntelliShapedImage.cpp @@ -6,10 +6,19 @@ IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) : IntelliRasterImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + TypeOfImage = ImageType::SHAPEDIMAGE; this->fastRenderering = fastRendererOn; } +/* +IntelliShapedImage::IntelliShapedImage(const IntelliShapedImage& image) + : IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ + this->TypeOfImage = ImageType::SHAPEDIMAGE; + IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); + shaped->imageData.copy(0,0,image.getWidth(),image.getWidth()); +} +*/ + IntelliShapedImage::~IntelliShapedImage(){ } @@ -19,10 +28,10 @@ QImage IntelliShapedImage::getDisplayable(int alpha){ } IntelliImage* IntelliShapedImage::getDeepCopy(){ - IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false); + IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); shaped->setPolygon(this->polygonData); shaped->imageData.fill(Qt::transparent); - shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + shaped->TypeOfImage = ImageType::SHAPEDIMAGE; return shaped; } diff --git a/src/Image/IntelliShapedImage.cpp.autosave b/src/Image/IntelliShapedImage.cpp.autosave new file mode 100644 index 0000000..bfaa053 --- /dev/null +++ b/src/Image/IntelliShapedImage.cpp.autosave @@ -0,0 +1,120 @@ +#include "Image/IntelliShapedImage.h" +#include "IntelliHelper/IntelliTriangulation.h" +#include +#include +#include + +IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) + : IntelliRasterImage(width, height, fastRendererOn){ + TypeOfImage = ImageType::SHAPEDIMAGE; + this->fastRenderering = fastRendererOn; +} + +IntelliShapedImage::Copy(const IntelliShapedImage& image) + : IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ + this->TypeOfImage = ImageType::SHAPEDIMAGE; + IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); + shaped->imageData.copy(0,0,image.getWidth(),image.getWidth()); +} + +IntelliShapedImage::~IntelliShapedImage(){ + +} + +QImage IntelliShapedImage::getDisplayable(int alpha){ + return getDisplayable(imageData.size(),alpha); +} + +IntelliImage* IntelliShapedImage::getDeepCopy(){ + IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); + shaped->setPolygon(this->polygonData); + shaped->imageData.fill(Qt::transparent); + shaped->TypeOfImage = ImageType::SHAPEDIMAGE; + return shaped; +} + +void IntelliShapedImage::calculateVisiblity(){ + if(polygonData.size()<2) { + return; + } + if(fastRenderering) { + this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } + + if(polygonData.size()<=2) { + QColor clr; + for(int y = 0; yimageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } + return; + } + QColor clr; + for(int y = 0; yimageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } +} + +QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){ + QImage copy = imageData; + if(fastRenderering) { + copy = copy.convertToFormat(QImage::Format_ARGB32); + } + for(int y = 0; y& polygonData){ + if(polygonData.size()<3) { + this->polygonData.clear(); + }else{ + this->polygonData.clear(); + for(auto element:polygonData) { + this->polygonData.push_back(QPoint(element.x(), element.y())); + } + triangles = IntelliTriangulation::calculateTriangles(polygonData); + if(fastRenderering) { + imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } + for(int y = 0; ygetTypeOfImage()==ImageType::RASTERIMAGE){ + this->image = new IntelliRasterImage(*dynamic_cast(layer.image)); + }else if(layer.image->getTypeOfImage()==ImageType::SHAPEDIMAGE){ + this->image = new IntelliShapedImage(*dynamic_cast(layer.image)); + } + this->width = layer.width; + this->height = layer.height; + this->widthOffset = layer.widthOffset; + this->heightOffset = layer.heightOffset; + this->alpha = layer.alpha; +} PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) : QWidget(parent){ @@ -59,21 +75,22 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){ } -int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::ImageType type){ +int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){ LayerObject newLayer; updateTools(); newLayer.width = width; newLayer.height = height; newLayer.widthOffset = widthOffset; newLayer.heightOffset = heightOffset; - if(type==IntelliImage::ImageType::RASTERIMAGE) { + 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(layerBundle.size()) - 1; + historyadd(); return activeLayer; } @@ -98,6 +115,7 @@ void PaintingArea::slotDeleteActiveLayer(){ this->layerBundle.erase(layerBundle.begin() + activeLayer); activeLayer--; } + historyadd(); } void PaintingArea::setLayerActive(int idx){ @@ -116,7 +134,7 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){ } void PaintingArea::setPolygon(int idx){ if(idx>=0&&idx(layerBundle.size())) { - if(layerBundle[static_cast(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) { + if(layerBundle[static_cast(idx)].image->getTypeOfImage()==ImageType::SHAPEDIMAGE) { delete this->Tool; this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true); isSettingPolygon = true; @@ -165,6 +183,7 @@ void PaintingArea::movePositionActive(int x, int y){ updateTools(); layerBundle[static_cast(activeLayer)].widthOffset += x; layerBundle[static_cast(activeLayer)].heightOffset += y; + historyadd(); } void PaintingArea::moveActiveLayer(int idx){ @@ -175,6 +194,7 @@ void PaintingArea::moveActiveLayer(int idx){ this->selectLayerDown(); } DummyGui->UpdateGui(); + historyadd(); } void PaintingArea::slotActivateLayer(int a){ @@ -248,7 +268,7 @@ int PaintingArea::getMaxHeight(){ return this->maxHeight; } -IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){ +ImageType PaintingArea::getTypeOfImageRealLayer(){ return this->layerBundle[static_cast(activeLayer)].image->getTypeOfImage(); } @@ -449,3 +469,30 @@ void PaintingArea::updateTools(){ } } } + +void PaintingArea::historyadd(){ + /* + if (++historyPresent == 100) historyPresent = 0; + historyMaxFuture = historyPresent; + if (historyPresent == historyMaxPast) if (++historyMaxPast == 100) historyMaxPast = 0; + history[static_cast(historyPresent)] = layerBundle; + + for (unsigned long long i=0;i < layerBundle.size();i++) { + + }*/ + +} + +void PaintingArea::historyGoBack(){ + if (historyPresent != historyMaxPast){ + if (--historyPresent == -1) historyPresent = 99; + layerBundle = history[static_cast(historyPresent)]; + } +} + +void PaintingArea::historyGoForward(){ + if (historyPresent != historyMaxFuture){ + if (++historyPresent == 100) historyPresent = 0; + layerBundle = history[static_cast(historyPresent)]; + } +} diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 58eb411..a48d4e6 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -45,6 +45,10 @@ struct LayerObject { * \brief alpha - Stores the alpha value of the layer (default=255). */ int alpha = 255; + + LayerObject(); + + LayerObject(const LayerObject& layer); }; /*! @@ -102,7 +106,7 @@ bool save(const QString &filePath, const char*fileFormat); * \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, 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 @@ -113,7 +117,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 @@ -184,7 +188,7 @@ int getMaxWidth(); int getMaxHeight(); -IntelliImage::ImageType getTypeOfImageRealLayer(); +ImageType getTypeOfImageRealLayer(); std::vector getPolygonDataOfRealLayer(); @@ -201,6 +205,9 @@ QImage getImageDataOfActiveLayer(); IntelliToolsettings Toolsettings; IntelliColorPicker colorPicker; +void historyGoBack(); +void historyGoForward(); + public slots: /*! * \brief The slotActivateLayer method handles the event of selecting one layer as active @@ -245,6 +252,14 @@ void drawLayers(bool forSaving = false); bool createTempTopLayer(int idx); void updateTools(); + +std::vector history[100] = {layerBundle}; +int historyMaxPast = 0; +int historyMaxFuture = 0; +int historyPresent = 0; + +void historyadd(); + }; #endif diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 11ed60b..55afd45 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -89,6 +89,7 @@ void IntelliTool::mergeToolLayer(){ activeLayer->image->setPolygon(Canvas->image->getPolygonData()); } Area->DummyGui->UpdateGui(); + Area->historyadd(); } void IntelliTool::deleteToolLayer(){ diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index 507ffb7..d8dc357 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -24,7 +24,7 @@ IntelliToolPolygon::~IntelliToolPolygon(){ } void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ - if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && xgetWidthOfActive() && ygetHeightOfActive()) { + if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::SHAPEDIMAGE && x > 0 && y > 0 && xgetWidthOfActive() && ygetHeightOfActive()) { if(Area->getPolygonDataOfRealLayer().size()>2) { std::vector Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer()); QPoint Point(x,y); @@ -37,7 +37,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ isInside = true; } } - else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x >= 0 && y >= 0 && xgetWidthOfActive() && ygetHeightOfActive()) { + else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::RASTERIMAGE && x >= 0 && y >= 0 && xgetWidthOfActive() && ygetHeightOfActive()) { isInside = true; } From c8b0328f6372afa94d95dd970f37a19c96261011 Mon Sep 17 00:00:00 2001 From: Mienek Date: Thu, 23 Jan 2020 13:15:37 +0100 Subject: [PATCH 06/18] history --- src/Image/IntelliRasterImage.cpp | 6 +- src/Image/IntelliRasterImage.cpp.autosave | 61 ----------- src/Image/IntelliRasterImage.h | 2 +- src/Image/IntelliShapedImage.cpp | 4 +- src/Image/IntelliShapedImage.cpp.autosave | 120 ---------------------- src/Image/IntelliShapedImage.h | 2 +- src/main.cpp | 5 + src/main.cpp.autosave | 15 +++ 8 files changed, 26 insertions(+), 189 deletions(-) delete mode 100644 src/Image/IntelliRasterImage.cpp.autosave delete mode 100644 src/Image/IntelliShapedImage.cpp.autosave create mode 100644 src/main.cpp.autosave diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index c70583c..9626f59 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -9,14 +9,14 @@ IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererO this->fastRenderering = fastRendererOn; } -/* -IntelliRasterImage::IntelliRasterImage(const IntelliRasterImage& image) + +IntelliRasterImage::Copy(const IntelliRasterImage& image) : IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ this->TypeOfImage = ImageType::RASTERIMAGE; IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); raster->imageData.copy(0,0,image.getWidth(),image.getWidth()); } -*/ + IntelliRasterImage::~IntelliRasterImage(){ diff --git a/src/Image/IntelliRasterImage.cpp.autosave b/src/Image/IntelliRasterImage.cpp.autosave deleted file mode 100644 index 9626f59..0000000 --- a/src/Image/IntelliRasterImage.cpp.autosave +++ /dev/null @@ -1,61 +0,0 @@ -#include "Image/IntelliRasterImage.h" -#include -#include -#include - -IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) - : IntelliImage(width, height, fastRendererOn){ - TypeOfImage = ImageType::RASTERIMAGE; - this->fastRenderering = fastRendererOn; -} - - -IntelliRasterImage::Copy(const IntelliRasterImage& image) - : IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ - this->TypeOfImage = ImageType::RASTERIMAGE; - IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); - raster->imageData.copy(0,0,image.getWidth(),image.getWidth()); -} - - - -IntelliRasterImage::~IntelliRasterImage(){ - -} - -IntelliImage* IntelliRasterImage::getDeepCopy(){ - IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); - raster->imageData.fill(Qt::transparent); - raster->TypeOfImage = ImageType::RASTERIMAGE; - return raster; -} - -void IntelliRasterImage::calculateVisiblity(){ - // not used in raster image -} - -QImage IntelliRasterImage::getDisplayable(int alpha){ - return getDisplayable(imageData.size(), alpha); -} - -QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ - QImage copy = imageData; - if(fastRenderering) { - copy = copy.convertToFormat(QImage::Format_ARGB32); - } - for(int y = 0; y& polygonData){ - return; -} diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index 8f3eb71..b6fdc07 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -26,7 +26,7 @@ public: */ IntelliRasterImage(int width, int height, bool fastRendererOn); -//IntelliRasterImage(const IntelliRasterImage& image); +void copy(const IntelliRasterImage& image); /*! * \brief An Destructor. diff --git a/src/Image/IntelliShapedImage.cpp b/src/Image/IntelliShapedImage.cpp index 9e73d2c..bfaa053 100644 --- a/src/Image/IntelliShapedImage.cpp +++ b/src/Image/IntelliShapedImage.cpp @@ -10,14 +10,12 @@ IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererO this->fastRenderering = fastRendererOn; } -/* -IntelliShapedImage::IntelliShapedImage(const IntelliShapedImage& image) +IntelliShapedImage::Copy(const IntelliShapedImage& image) : IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ this->TypeOfImage = ImageType::SHAPEDIMAGE; IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); shaped->imageData.copy(0,0,image.getWidth(),image.getWidth()); } -*/ IntelliShapedImage::~IntelliShapedImage(){ diff --git a/src/Image/IntelliShapedImage.cpp.autosave b/src/Image/IntelliShapedImage.cpp.autosave deleted file mode 100644 index bfaa053..0000000 --- a/src/Image/IntelliShapedImage.cpp.autosave +++ /dev/null @@ -1,120 +0,0 @@ -#include "Image/IntelliShapedImage.h" -#include "IntelliHelper/IntelliTriangulation.h" -#include -#include -#include - -IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) - : IntelliRasterImage(width, height, fastRendererOn){ - TypeOfImage = ImageType::SHAPEDIMAGE; - this->fastRenderering = fastRendererOn; -} - -IntelliShapedImage::Copy(const IntelliShapedImage& image) - : IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ - this->TypeOfImage = ImageType::SHAPEDIMAGE; - IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); - shaped->imageData.copy(0,0,image.getWidth(),image.getWidth()); -} - -IntelliShapedImage::~IntelliShapedImage(){ - -} - -QImage IntelliShapedImage::getDisplayable(int alpha){ - return getDisplayable(imageData.size(),alpha); -} - -IntelliImage* IntelliShapedImage::getDeepCopy(){ - IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); - shaped->setPolygon(this->polygonData); - shaped->imageData.fill(Qt::transparent); - shaped->TypeOfImage = ImageType::SHAPEDIMAGE; - return shaped; -} - -void IntelliShapedImage::calculateVisiblity(){ - if(polygonData.size()<2) { - return; - } - if(fastRenderering) { - this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } - - if(polygonData.size()<=2) { - QColor clr; - for(int y = 0; yimageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } - return; - } - QColor clr; - for(int y = 0; yimageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } -} - -QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){ - QImage copy = imageData; - if(fastRenderering) { - copy = copy.convertToFormat(QImage::Format_ARGB32); - } - for(int y = 0; y& polygonData){ - if(polygonData.size()<3) { - this->polygonData.clear(); - }else{ - this->polygonData.clear(); - for(auto element:polygonData) { - this->polygonData.push_back(QPoint(element.x(), element.y())); - } - triangles = IntelliTriangulation::calculateTriangles(polygonData); - if(fastRenderering) { - imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } - for(int y = 0; y #include #include +#include int main(int argc, char*argv[]){ // The main application QApplication app(argc, argv); + std::fstream file("test.txt"); + file << "Hallo welt"; + file.close(); + // Create and open the main window IntelliPhotoGui window; window.show(); diff --git a/src/main.cpp.autosave b/src/main.cpp.autosave new file mode 100644 index 0000000..30adab2 --- /dev/null +++ b/src/main.cpp.autosave @@ -0,0 +1,15 @@ +#include "GUI/IntelliPhotoGui.h" +#include +#include +#include + +int main(int argc, char*argv[]){ + // The main application + QApplication app(argc, argv); + + // Create and open the main window + IntelliPhotoGui window; + window.show(); + + return app.exec(); +} From 1472028a81bbb6ed24d6c33231235168722a3ced Mon Sep 17 00:00:00 2001 From: Mienek Date: Thu, 23 Jan 2020 13:47:44 +0100 Subject: [PATCH 07/18] Alpha Version it dose something right but let's see --- src/Image/IntelliRasterImage.cpp | 4 ++-- src/Image/IntelliRasterImage.h | 2 +- src/Image/IntelliShapedImage.cpp | 4 ++-- src/Image/IntelliShapedImage.h | 2 +- src/Layer/PaintingArea.cpp | 3 +-- src/main.cpp | 5 ----- src/main.cpp.autosave | 15 --------------- 7 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 src/main.cpp.autosave diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index 9626f59..59466f9 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -10,11 +10,11 @@ IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererO } -IntelliRasterImage::Copy(const IntelliRasterImage& image) - : IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ +IntelliRasterImage* IntelliRasterImage::copy(const IntelliRasterImage& image){ this->TypeOfImage = ImageType::RASTERIMAGE; IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering); raster->imageData.copy(0,0,image.getWidth(),image.getWidth()); + return raster; } diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index b6fdc07..dd65d69 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -26,7 +26,7 @@ public: */ IntelliRasterImage(int width, int height, bool fastRendererOn); -void copy(const IntelliRasterImage& image); +IntelliRasterImage* copy(const IntelliRasterImage& image); /*! * \brief An Destructor. diff --git a/src/Image/IntelliShapedImage.cpp b/src/Image/IntelliShapedImage.cpp index bfaa053..0202577 100644 --- a/src/Image/IntelliShapedImage.cpp +++ b/src/Image/IntelliShapedImage.cpp @@ -10,11 +10,11 @@ IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererO this->fastRenderering = fastRendererOn; } -IntelliShapedImage::Copy(const IntelliShapedImage& image) - : IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){ +IntelliShapedImage* IntelliShapedImage::copy(const IntelliShapedImage& image){ this->TypeOfImage = ImageType::SHAPEDIMAGE; IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering); shaped->imageData.copy(0,0,image.getWidth(),image.getWidth()); + return shaped; } IntelliShapedImage::~IntelliShapedImage(){ diff --git a/src/Image/IntelliShapedImage.h b/src/Image/IntelliShapedImage.h index bca6061..3292211 100644 --- a/src/Image/IntelliShapedImage.h +++ b/src/Image/IntelliShapedImage.h @@ -38,7 +38,7 @@ public: */ IntelliShapedImage(int width, int height, bool fastRendererOn); -void copy(const IntelliShapedImage& image); +IntelliShapedImage* copy(const IntelliShapedImage& image); /*! * \brief An Destructor. */ diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 13ceadd..36d55ab 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -471,7 +471,7 @@ void PaintingArea::updateTools(){ } void PaintingArea::historyadd(){ - /* +/* if (++historyPresent == 100) historyPresent = 0; historyMaxFuture = historyPresent; if (historyPresent == historyMaxPast) if (++historyMaxPast == 100) historyMaxPast = 0; @@ -480,7 +480,6 @@ void PaintingArea::historyadd(){ for (unsigned long long i=0;i < layerBundle.size();i++) { }*/ - } void PaintingArea::historyGoBack(){ diff --git a/src/main.cpp b/src/main.cpp index 9ebbca7..dc5caa5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,11 +7,6 @@ int main(int argc, char*argv[]){ // The main application QApplication app(argc, argv); - - std::fstream file("test.txt"); - file << "Hallo welt"; - file.close(); - // Create and open the main window IntelliPhotoGui window; window.show(); diff --git a/src/main.cpp.autosave b/src/main.cpp.autosave deleted file mode 100644 index 30adab2..0000000 --- a/src/main.cpp.autosave +++ /dev/null @@ -1,15 +0,0 @@ -#include "GUI/IntelliPhotoGui.h" -#include -#include -#include - -int main(int argc, char*argv[]){ - // The main application - QApplication app(argc, argv); - - // Create and open the main window - IntelliPhotoGui window; - window.show(); - - return app.exec(); -} From 5d794819b0af061c4fea2897f81b00849d60facb Mon Sep 17 00:00:00 2001 From: Mienek Date: Thu, 23 Jan 2020 13:48:43 +0100 Subject: [PATCH 08/18] removed /* and*/ ... --- src/Layer/PaintingArea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 36d55ab..b7d9e07 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -471,7 +471,7 @@ void PaintingArea::updateTools(){ } void PaintingArea::historyadd(){ -/* + if (++historyPresent == 100) historyPresent = 0; historyMaxFuture = historyPresent; if (historyPresent == historyMaxPast) if (++historyMaxPast == 100) historyMaxPast = 0; @@ -479,7 +479,7 @@ void PaintingArea::historyadd(){ for (unsigned long long i=0;i < layerBundle.size();i++) { - }*/ + } } void PaintingArea::historyGoBack(){ From 083368dcabeb0b8d4667b6d24928f3568f26e76d Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 23 Jan 2020 14:15:22 +0100 Subject: [PATCH 09/18] Bug with getting the filetype --- src/GUI/IntelliPhotoGui.cpp | 27 +++++++++++++++++++++-- src/GUI/IntelliPhotoGui.h | 1 + src/IntelliHelper/IntelliDatamanager.cpp | 28 +++++++++++++++++------- src/IntelliHelper/IntelliDatamanager.h | 17 +++++++------- src/Layer/PaintingArea.cpp | 1 + src/Layer/PaintingArea.h | 3 +-- src/Tool/IntelliTool.cpp | 1 + 7 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 5734d47..e5af83b 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -3,8 +3,10 @@ #include "IntelliPhotoGui.h" #include "Layer/PaintingArea.h" -#include "QEvent" -#include "QCloseEvent" +#include +#include +#include +#include // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(){ @@ -50,6 +52,15 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea if (!fileName.isEmpty()) { + if(fileName.length()>3){ + if(*(fileName.rend()+1)==QChar('f') && + *(fileName.rend()+2)==QChar('d') && + *(fileName.rend()+3)==QChar('i') && + *(fileName.rend()+4)==QChar('.')){ + qDebug() << "works."; + IntelliDatamanager::loadProject(paintingArea,fileName); + } + } paintingArea->open(fileName); UpdateGui(); } @@ -356,6 +367,14 @@ void IntelliPhotoGui::createActions(){ actionSaveAs.append(pngSaveAction); pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); + QAction*projectSaveAction = new QAction("Projekt", this); + projectSaveAction->setData("idf"); + // When clicked call IntelliPhotoGui::save() + connect(projectSaveAction, SIGNAL(triggered()), this, SLOT(slotSave())); + // Attach each PNG in save Menu + actionSaveAs.append(projectSaveAction); + projectSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); + // Create exit action and tie to IntelliPhotoGui::close() actionExit = new QAction(tr("&Exit"), this); actionExit->setShortcuts(QKeySequence::Quit); @@ -817,6 +836,10 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){ return false; } else { // Call for the file to be saved + if(fileFormat == "idf"){ + return IntelliDatamanager::saveProject(paintingArea, fileName); + + } return paintingArea->save(fileName, fileFormat.constData()); } } diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 8d164a4..b3f3641 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -15,6 +15,7 @@ #include #include #include "IntelliInputDialog.h" +#include "IntelliHelper/IntelliDatamanager.h" //for unit testing class UnitTest; diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index 38996c2..aed051e 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -1,16 +1,28 @@ #include "IntelliDatamanager.h" +#include "Layer/PaintingArea.h" -IntelliDatamanager::IntelliDatamanager() -{ +bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ + QFile openFile(filePath); + + if(openFile.open(QIODevice::WriteOnly)){ + qDebug() << "works."; + openFile.write("Hahaha"); + openFile.close(); + return true; + } + + return false; } -void IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ +bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ + QFile openFile(filePath); + if(openFile.open(QIODevice::ReadOnly)){ + qDebug() << openFile.readAll(); + openFile.close(); + return true; + } - return; -} - -void IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ - return; + return false; } diff --git a/src/IntelliHelper/IntelliDatamanager.h b/src/IntelliHelper/IntelliDatamanager.h index a70fbe5..eb121d9 100644 --- a/src/IntelliHelper/IntelliDatamanager.h +++ b/src/IntelliHelper/IntelliDatamanager.h @@ -1,17 +1,16 @@ #ifndef INTELLIDATAMANAGER_H #define INTELLIDATAMANAGER_H -#include "Layer/PaintingArea.h" #include +#include -class IntelliDatamanager -{ -private: +class PaintingArea; -public: - void loadProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); - void saveProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); - IntelliDatamanager(); -}; +namespace IntelliDatamanager{ + + bool loadProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); + bool saveProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); + +} #endif // INTELLIDATAMANAGER_H diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index b471da0..f3c676f 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -17,6 +17,7 @@ #include "Tool/IntelliToolRectangle.h" #include "Tool/IntelliToolFloodFill.h" #include "Tool/IntelliToolPolygon.h" +#include "GUI/IntelliPhotoGui.h" PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 58eb411..107c6b9 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -7,7 +7,6 @@ #include #include #include -#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 */ diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 11ed60b..a6d3343 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -1,5 +1,6 @@ #include "IntelliTool.h" #include "Layer/PaintingArea.h" +#include "GUI/IntelliPhotoGui.h" IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){ this->Area = Area; From 189f07001648f7ba5a9c570ce0f8e30ffb23a556 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 23 Jan 2020 14:43:33 +0100 Subject: [PATCH 10/18] save nearly done, i guess need help with the open, if(end of fileName = ".idf") --- src/GUI/IntelliPhotoGui.cpp | 8 +++++--- src/IntelliHelper/IntelliDatamanager.cpp | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index e5af83b..3753772 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -61,10 +61,12 @@ void IntelliPhotoGui::slotOpen(){ IntelliDatamanager::loadProject(paintingArea,fileName); } } - paintingArea->open(fileName); + } + //paintingArea->open(fileName); + //TODO remove datamanager funciton and enable painting area function + IntelliDatamanager::loadProject(paintingArea,fileName); UpdateGui(); - } - } + } } // Called when the user clicks Save As in the menu diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index aed051e..fb900df 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -1,13 +1,24 @@ #include "IntelliDatamanager.h" #include "Layer/PaintingArea.h" - bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ QFile openFile(filePath); if(openFile.open(QIODevice::WriteOnly)){ - qDebug() << "works."; - openFile.write("Hahaha"); + QTextStream out(&openFile); + + out << "Format: idf\n" << "Version: 0.7\n" << endl; + out << "Resolution: " << Canvas->getMaxWidth() << "x" << Canvas->getMaxHeight() << endl; + out << "Layers: " << "0" << endl; + if(false){ + out << "width: " << endl; + out << "height: " << endl; + out << "xoffset: " << endl; + out << "yoffset: " << endl; + out << "alpha: " << endl; + out << "imageData: " << endl; + } + openFile.close(); return true; } @@ -19,7 +30,7 @@ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ QFile openFile(filePath); if(openFile.open(QIODevice::ReadOnly)){ - qDebug() << openFile.readAll(); + qDebug() << openFile.readLine(); openFile.close(); return true; } From 244a9b769f58cc9bdd1d9c8333d369c2d1b3ea71 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 23 Jan 2020 15:15:57 +0100 Subject: [PATCH 11/18] added a exporter (NOT TESTET!!!) --- src/IntelliHelper/IntelliDatamanager.cpp | 27 +++++++++++++++++------- src/Layer/PaintingArea.h | 6 ++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index fb900df..d5f7c9f 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -6,17 +6,28 @@ bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ if(openFile.open(QIODevice::WriteOnly)){ QTextStream out(&openFile); + std::vector* layerBundle = Canvas->getLayerBundle(); + size_t numberOfLayers = layerBundle->size(); out << "Format: idf\n" << "Version: 0.7\n" << endl; out << "Resolution: " << Canvas->getMaxWidth() << "x" << Canvas->getMaxHeight() << endl; - out << "Layers: " << "0" << endl; - if(false){ - out << "width: " << endl; - out << "height: " << endl; - out << "xoffset: " << endl; - out << "yoffset: " << endl; - out << "alpha: " << endl; - out << "imageData: " << endl; + out << "Layers: " << numberOfLayers << endl; + for(size_t i = 0; iat(i).width; + int height = layerBundle->at(i).height; + out << "width: " << width << endl; + out << "height: " << height << endl; + out << "xoffset: " << layerBundle->at(i).widthOffset << endl; + out << "yoffset: " << layerBundle->at(i).heightOffset << endl; + out << "alpha: " << layerBundle->at(i).alpha << endl; + for(int j=0; jat(i).image->getImageData().pixelColor(j,k); + out << pixColor.red() << " " << pixColor.green() << " " << pixColor.blue() << " " << pixColor.alpha() << ":"; + } + out << endl; + } + } openFile.close(); diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 107c6b9..74e8eb5 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -197,6 +197,12 @@ IntelliImage* getImageOfActiveLayer(); */ QImage getImageDataOfActiveLayer(); +/*! + * \brief getLayerBundle returns the real active layerbundle (care!) + * \return the reference of the currentLayerBundle + */ +std::vector* getLayerBundle(); + IntelliToolsettings Toolsettings; IntelliColorPicker colorPicker; From 12614096f82034074e0f634841ef30c95d286878 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 16:13:52 +0100 Subject: [PATCH 12/18] ednungs check --- src/GUI/IntelliPhotoGui.cpp | 24 +++++++++++++++--------- src/Layer/PaintingArea.cpp | 4 ++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 3753772..8698b93 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -52,21 +52,27 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea if (!fileName.isEmpty()) { - if(fileName.length()>3){ - if(*(fileName.rend()+1)==QChar('f') && - *(fileName.rend()+2)==QChar('d') && - *(fileName.rend()+3)==QChar('i') && - *(fileName.rend()+4)==QChar('.')){ - qDebug() << "works."; - IntelliDatamanager::loadProject(paintingArea,fileName); + bool rightFileType =true; + if(fileName.size()>=4){ + QString endung(".idf"); + int length = fileName.size(); + for(int i=0; i<4; i++){ + if(endung[i]!=fileName[length-4+i]){ + rightFileType = false; + break; + } } } - } + + if(rightFileType){ //paintingArea->open(fileName); //TODO remove datamanager funciton and enable painting area function IntelliDatamanager::loadProject(paintingArea,fileName); - UpdateGui(); + UpdateGui(); + + } } + } } // Called when the user clicks Save As in the menu diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index f3c676f..a2813af 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -436,6 +436,10 @@ QImage PaintingArea::getImageDataOfActiveLayer(){ return returnImage; } +std::vector* PaintingArea::getLayerBundle(){ + return &layerBundle; +} + void PaintingArea::updateTools(){ if(Tool!=nullptr) { if(Tool->getIsDrawing()) { From 4217b00d88875a1fa898592a6611b52b4e8a8f51 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 16:37:55 +0100 Subject: [PATCH 13/18] scrolol ready --- src/GUI/IntelliPhotoGui.cpp | 9 +++++++-- src/GUI/IntelliPhotoGui.h | 2 +- src/Layer/PaintingArea.cpp | 21 ++++++++++++--------- src/Layer/PaintingArea.h | 4 ++++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index cddc0ed..1600370 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -7,6 +7,8 @@ #include "QCloseEvent" #include "QScrollBar" +#include + // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(){ // create Gui elements and lay them out @@ -19,7 +21,7 @@ IntelliPhotoGui::IntelliPhotoGui(){ setIntelliStyle(); // Size the app resize(600,600); - setDefaultToolValue(); + setDefaultValues(); } // User tried to close the app @@ -118,6 +120,8 @@ void IntelliPhotoGui::slotChangeDim(){ int height = IntelliInputDialog::getInt("New Canvas Size", "Height:", 600, 1, 50000, 1, &ok2); + + // Change dimension if (ok1&&ok2) { paintingArea->setLayerDimensions(width,height); @@ -768,6 +772,7 @@ void IntelliPhotoGui::createGui(){ mainLayout->addWidget(dimActive,13,2,1,2); mainLayout->addWidget(dimCanvas,14,2,1,2); mainLayout->setHorizontalSpacing(0); + } void IntelliPhotoGui::setIntelliStyle(){ @@ -828,7 +833,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){ } } -void IntelliPhotoGui::setDefaultToolValue(){ +void IntelliPhotoGui::setDefaultValues(){ slotEnterPressed(); } diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 7a20ccc..8cf59fe 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -110,7 +110,7 @@ bool maybeSave(); bool saveFile(const QByteArray &fileFormat); //basic to set tool values to begin -void setDefaultToolValue(); +void setDefaultValues(); // What we'll draw on PaintingArea* paintingArea; diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 334a4d4..48774a1 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -54,6 +54,9 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){ this->maxHeight = maxHeight; Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32); + this->offsetXDimension = maxWidth/2; + this->offsetYDimension = maxHeight/2; + // Roots the widget to the top left even if resized setAttribute(Qt::WA_StaticContents); @@ -265,12 +268,12 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){ } if(Tool == nullptr) return; - int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset; - int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset; + int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset-offsetXDimension; + int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset-offsetYDimension; if(event->button() == Qt::LeftButton) { - Tool->onMouseLeftPressed(x, y); + Tool->onMouseLeftPressed(x, y); }else if(event->button() == Qt::RightButton) { - Tool->onMouseRightPressed(x, y); + Tool->onMouseRightPressed(x, y); } update(); } @@ -284,8 +287,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){ } if(Tool == nullptr) return; - int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset; - int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset; + int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset-offsetXDimension; + int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset-offsetYDimension; Tool->onMouseMoved(x, y); update(); } @@ -296,8 +299,8 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){ return; if(Tool == nullptr) return; - int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset; - int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset; + int x = event->x() - layerBundle[static_cast(activeLayer)].widthOffset-offsetXDimension; + int y = event->y() - layerBundle[static_cast(activeLayer)].heightOffset-offsetYDimension; if(event->button() == Qt::LeftButton) { Tool->onMouseLeftReleased(x, y); }else if(event->button() == Qt::RightButton) { @@ -332,7 +335,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){ //calulate image here for scroll //Todo set offset in first to parameters and calulate them into mouse position - painter.drawImage(0, 0, *Canvas, 0, 0); + painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension); update(); } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 731e972..fb8ac02 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -222,6 +222,10 @@ void wheelEvent(QWheelEvent*event) override; void paintEvent(QPaintEvent*event) override; private: +//offset for the displayable +int offsetXDimension; +int offsetYDimension; + void setLayerDimensions(int maxWidth, int maxHeight); void selectLayerUp(); void selectLayerDown(); From 48747c1e8a76f4ecf5b8a4c31a62d3161e1587aa Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 23 Jan 2020 16:38:52 +0100 Subject: [PATCH 14/18] yay updated export works 100% i think --- src/GUI/IntelliPhotoGui.cpp | 5 +++-- src/IntelliHelper/IntelliDatamanager.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 8698b93..4b38c18 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -65,12 +65,13 @@ void IntelliPhotoGui::slotOpen(){ } if(rightFileType){ - //paintingArea->open(fileName); - //TODO remove datamanager funciton and enable painting area function IntelliDatamanager::loadProject(paintingArea,fileName); UpdateGui(); } + else{ + paintingArea->open(fileName); + } } } } diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index d5f7c9f..936dbf3 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -29,7 +29,7 @@ bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ } } - + out << "\nFormat designed and approved by IntelliPhoto Team 7. All rigths reserved."; openFile.close(); return true; } From 8692ccd8a392035853168f21ea5a65dd8efa840f Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 20:13:43 +0100 Subject: [PATCH 15/18] project load and export --- src/GUI/IntelliPhotoGui.cpp | 4 +- src/Image/IntelliImage.h | 16 ++--- src/Image/IntelliRasterImage.cpp | 8 ++- src/Image/IntelliRasterImage.h | 6 ++ src/Image/IntelliShapedImage.cpp | 8 ++- src/Image/IntelliShapedImage.h | 8 +++ src/IntelliHelper/IntelliDatamanager.cpp | 77 ++++++++++++++++++++---- src/Layer/PaintingArea.cpp | 31 ++++++++-- src/Layer/PaintingArea.h | 23 +++++-- src/Tool/IntelliToolPolygon.cpp | 4 +- 10 files changed, 146 insertions(+), 39 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 4b38c18..f470822 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -102,7 +102,7 @@ void IntelliPhotoGui::slotCreateNewRasterLayer(){ // Create New Layer if (ok1&&ok2) { - paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::RASTERIMAGE); + paintingArea->addLayer(width,height,0,0,255,ImageType::RASTERIMAGE); UpdateGui(); } } @@ -121,7 +121,7 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){ // Create New Layer if (ok1&&ok2) { - paintingArea->addLayer(width, height, 0, 0, IntelliImage::ImageType::SHAPEDIMAGE); + paintingArea->addLayer(width, height, 0, 0,255, ImageType::SHAPEDIMAGE); UpdateGui(); } } diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h index 5c19186..732fc34 100644 --- a/src/Image/IntelliImage.h +++ b/src/Image/IntelliImage.h @@ -16,6 +16,14 @@ class UnitTest; class IntelliTool; +/*! + * \brief The Types, which an Image can be. + */ +enum class ImageType { + RASTERIMAGE, + SHAPEDIMAGE +}; + /*! * \brief An abstract class which manages the basic IntelliImage operations. */ @@ -24,14 +32,6 @@ friend UnitTest; friend IntelliTool; public: -/*! - * \brief The Types, which an Image can be. - */ -enum class ImageType { - RASTERIMAGE, - SHAPEDIMAGE -}; - protected: void resizeImage(QImage*image, const QSize &newSize); diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index 3106e36..9e92ad9 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -5,7 +5,7 @@ IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) : IntelliImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; + TypeOfImage = ImageType::RASTERIMAGE; this->fastRenderering = fastRendererOn; } @@ -16,7 +16,7 @@ IntelliRasterImage::~IntelliRasterImage(){ IntelliImage* IntelliRasterImage::getDeepCopy(){ IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false); raster->imageData.fill(Qt::transparent); - raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; + raster->TypeOfImage = ImageType::RASTERIMAGE; return raster; } @@ -49,3 +49,7 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ void IntelliRasterImage::setPolygon(const std::vector& polygonData){ return; } + +std::vector IntelliRasterImage::getPolygon(){ + return std::vector(); +} diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index a67472a..c97ec8c 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -57,6 +57,12 @@ virtual IntelliImage* getDeepCopy() override; * \param polygonData - The Vertices of the Polygon. Nothing happens. */ virtual void setPolygon(const std::vector& polygonData) override; + +/*! + * \brief getPolygon + * \return returns the points of the polygon + */ +virtual std::vector getPolygon(); }; #endif diff --git a/src/Image/IntelliShapedImage.cpp b/src/Image/IntelliShapedImage.cpp index 14c7b71..3ba9ac2 100644 --- a/src/Image/IntelliShapedImage.cpp +++ b/src/Image/IntelliShapedImage.cpp @@ -6,7 +6,7 @@ IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) : IntelliRasterImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + TypeOfImage = ImageType::SHAPEDIMAGE; this->fastRenderering = fastRendererOn; } @@ -22,7 +22,7 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){ IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false); shaped->setPolygon(this->polygonData); shaped->imageData.fill(Qt::transparent); - shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + shaped->TypeOfImage = ImageType::SHAPEDIMAGE; return shaped; } @@ -111,3 +111,7 @@ void IntelliShapedImage::setPolygon(const std::vector& polygonData){ calculateVisiblity(); return; } + +std::vector IntelliShapedImage::getPolygon(){ + return polygonData; +} diff --git a/src/Image/IntelliShapedImage.h b/src/Image/IntelliShapedImage.h index 32c4c9f..781ece5 100644 --- a/src/Image/IntelliShapedImage.h +++ b/src/Image/IntelliShapedImage.h @@ -77,6 +77,14 @@ virtual std::vector getPolygonData() override { * \param polygonData - The Vertices of the Polygon. Just Planar Polygons are allowed. */ virtual void setPolygon(const std::vector& polygonData) override; + + +/*! + * \brief getPolygon + * \return returns the data of the polygon as points + */ +virtual std::vector getPolygon() override; }; + #endif diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index 936dbf3..bce95f6 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -5,27 +5,37 @@ bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ QFile openFile(filePath); if(openFile.open(QIODevice::WriteOnly)){ + QTextStream out(&openFile); std::vector* layerBundle = Canvas->getLayerBundle(); size_t numberOfLayers = layerBundle->size(); - - out << "Format: idf\n" << "Version: 0.7\n" << endl; - out << "Resolution: " << Canvas->getMaxWidth() << "x" << Canvas->getMaxHeight() << endl; - out << "Layers: " << numberOfLayers << endl; + out << 7 << endl; //version tag + out << Canvas->getRenderSettings() << " "; + out << Canvas->getMaxWidth() << " " << Canvas->getMaxHeight() << endl; //dimensions of canvas + out << numberOfLayers << endl; //number of layers for(size_t i = 0; iat(i).width; int height = layerBundle->at(i).height; - out << "width: " << width << endl; - out << "height: " << height << endl; - out << "xoffset: " << layerBundle->at(i).widthOffset << endl; - out << "yoffset: " << layerBundle->at(i).heightOffset << endl; - out << "alpha: " << layerBundle->at(i).alpha << endl; + out << width << endl; //width + out << height << endl; //height + out << layerBundle->at(i).widthOffset << endl; //widthOffset + out << layerBundle->at(i).heightOffset << endl; //HeightOffset + out << layerBundle->at(i).alpha << endl; //alpha of layer + if(layerBundle->at(i).image->getTypeOfImage() == ImageType::RASTERIMAGE){ + out << 0 << " "; + }else{ + out << 1 << " "; + } + std::vector points = layerBundle->at(i).image->getPolygonData(); + out << points.size() << " "; + for(size_t j = 0; jat(i).image->getImageData().pixelColor(j,k); - out << pixColor.red() << " " << pixColor.green() << " " << pixColor.blue() << " " << pixColor.alpha() << ":"; + out << pixColor.red() << " " << pixColor.green() << " " << pixColor.blue() << " " << pixColor.alpha() << " "; } - out << endl; } } @@ -39,9 +49,50 @@ bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ QFile openFile(filePath); - + Canvas->deleteAllLayers(); if(openFile.open(QIODevice::ReadOnly)){ - qDebug() << openFile.readLine(); + QTextStream in(&openFile); + + float version; + int rendersetting; + int widthCanvas, heightCanvas, numberOffLayers; + in >> version; + in >> rendersetting; + in >> widthCanvas >> heightCanvas; + in >> numberOffLayers; + + Canvas->setLayerDimensions(widthCanvas, heightCanvas); + for(int i=0; i> width >> height >> widthOffset >> heightOffset >> alpha; + + int typeFlag; + size_t numberOfPoints; + std::vector polyPoints; + + in >> typeFlag >> numberOfPoints; + if(typeFlag==0){ + Canvas->addLayer(width, height, widthOffset, heightOffset, alpha, ImageType::RASTERIMAGE); + }else{ + Canvas->addLayer(width, height, widthOffset, heightOffset, alpha, ImageType::SHAPEDIMAGE); + } + polyPoints.reserve(numberOfPoints); + for(size_t j=0; j> x >> y; + polyPoints.push_back(QPoint(x,y)); + } + Canvas->setPolygonDataToActive(polyPoints); + + for(int j=0; j> red >> green >> blue >> alpha; + Canvas->setPixelToActive(QColor(red, green, blue, alpha), QPoint(j, k)); + } + } + } + Canvas->setRenderSettings(static_cast(rendersetting)); openFile.close(); return true; } diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index a2813af..97a72cd 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -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(activeLayer)].image->drawPixel(point, color); +} + +void PaintingArea::setPolygonDataToActive(std::vector points){ + layerBundle[static_cast(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(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(layerBundle.size())) { - if(layerBundle[static_cast(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) { + if(layerBundle[static_cast(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(activeLayer)].image->getTypeOfImage(); } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 74e8eb5..264dafa 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -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 getPolygonDataOfRealLayer(); @@ -206,6 +217,11 @@ std::vector* getLayerBundle(); IntelliToolsettings Toolsettings; IntelliColorPicker colorPicker; +void setLayerDimensions(int maxWidth, int maxHeight); + +void setPixelToActive(QColor color, QPoint point); + +void setPolygonDataToActive(std::vector 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(); diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index 507ffb7..d8dc357 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -24,7 +24,7 @@ IntelliToolPolygon::~IntelliToolPolygon(){ } void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ - if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && xgetWidthOfActive() && ygetHeightOfActive()) { + if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::SHAPEDIMAGE && x > 0 && y > 0 && xgetWidthOfActive() && ygetHeightOfActive()) { if(Area->getPolygonDataOfRealLayer().size()>2) { std::vector Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer()); QPoint Point(x,y); @@ -37,7 +37,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ isInside = true; } } - else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x >= 0 && y >= 0 && xgetWidthOfActive() && ygetHeightOfActive()) { + else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::RASTERIMAGE && x >= 0 && y >= 0 && xgetWidthOfActive() && ygetHeightOfActive()) { isInside = true; } From 8a192722cbc2914d1e09dc9d6bd460fb9c8c0a78 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 20:19:59 +0100 Subject: [PATCH 16/18] add cleanup --- src/Layer/PaintingArea.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index b7d9e07..3398d72 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -472,26 +472,28 @@ void PaintingArea::updateTools(){ void PaintingArea::historyadd(){ - if (++historyPresent == 100) historyPresent = 0; - historyMaxFuture = historyPresent; - if (historyPresent == historyMaxPast) if (++historyMaxPast == 100) historyMaxPast = 0; - history[static_cast(historyPresent)] = layerBundle; - - for (unsigned long long i=0;i < layerBundle.size();i++) { - + if (++historyPresent == 100){ + historyPresent = 0; } + historyMaxFuture = historyPresent; + if (historyPresent == historyMaxPast) + if (++historyMaxPast == 100) + historyMaxPast = 0; + history[static_cast(historyPresent)] = layerBundle; } void PaintingArea::historyGoBack(){ if (historyPresent != historyMaxPast){ - if (--historyPresent == -1) historyPresent = 99; + if (--historyPresent == -1) + historyPresent = 99; layerBundle = history[static_cast(historyPresent)]; } } void PaintingArea::historyGoForward(){ if (historyPresent != historyMaxFuture){ - if (++historyPresent == 100) historyPresent = 0; + if (++historyPresent == 100) + historyPresent = 0; layerBundle = history[static_cast(historyPresent)]; } } From 69fcdb8b201f2e0502c5782f852764068eaa4d3e Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 20:24:32 +0100 Subject: [PATCH 17/18] known bugs list --- knownBugs.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 knownBugs.txt diff --git a/knownBugs.txt b/knownBugs.txt new file mode 100644 index 0000000..8314056 --- /dev/null +++ b/knownBugs.txt @@ -0,0 +1 @@ +history tool doesnt load polygon data on undo iff project was loaded \ No newline at end of file From 3aefb6c634766a2d99a621e907dc55af52784a5e Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Thu, 23 Jan 2020 20:36:18 +0100 Subject: [PATCH 18/18] update preview on history --- src/Layer/PaintingArea.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 56938dc..d147488 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -521,6 +521,7 @@ void PaintingArea::historyGoBack(){ historyPresent = 99; layerBundle = history[static_cast(historyPresent)]; } + this->guiReference->UpdateGui(); } void PaintingArea::historyGoForward(){ @@ -529,4 +530,5 @@ void PaintingArea::historyGoForward(){ historyPresent = 0; layerBundle = history[static_cast(historyPresent)]; } + this->guiReference->UpdateGui(); }