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 + 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 diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 5734d47..44cdf63 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(){ @@ -18,8 +20,7 @@ IntelliPhotoGui::IntelliPhotoGui(){ setIntelliStyle(); // Size the app resize(600,600); - showMaximized(); - setDefaultToolValue(); + setDefaultValues(); } // User tried to close the app @@ -50,10 +51,28 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea if (!fileName.isEmpty()) { - paintingArea->open(fileName); - UpdateGui(); - } - } + 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){ + IntelliDatamanager::loadProject(paintingArea,fileName); + UpdateGui(); + + } + else{ + paintingArea->open(fileName); + } + } + } } // Called when the user clicks Save As in the menu @@ -82,7 +101,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(); } } @@ -101,7 +120,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(); } } @@ -118,6 +137,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); @@ -327,6 +348,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 @@ -356,6 +385,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); @@ -525,6 +562,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 @@ -550,6 +595,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); @@ -597,6 +643,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(); @@ -626,7 +674,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 +788,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); @@ -761,6 +815,7 @@ void IntelliPhotoGui::createGui(){ mainLayout->addWidget(dimActive,13,2,1,2); mainLayout->addWidget(dimCanvas,14,2,1,2); mainLayout->setHorizontalSpacing(0); + } void IntelliPhotoGui::setIntelliStyle(){ @@ -817,11 +872,15 @@ 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()); } } -void IntelliPhotoGui::setDefaultToolValue(){ +void IntelliPhotoGui::setDefaultValues(){ slotEnterPressed(); } @@ -846,7 +905,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..8c1b000 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -14,7 +14,9 @@ #include #include #include +#include #include "IntelliInputDialog.h" +#include "IntelliHelper/IntelliDatamanager.h" //for unit testing class UnitTest; @@ -95,11 +97,15 @@ void slotSetInnerAlpha(); void slotResetTools(); +void slotGoBack(); +void slotGoForward(); + 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 +113,19 @@ bool maybeSave(); // Opens the Save dialog and saves bool saveFile(const QByteArray &fileFormat); -void setDefaultToolValue(); +//basic to set tool values to begin +void setDefaultValues(); // 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 +133,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 +194,9 @@ QAction* actionCreatePolygonTool; QAction* actionCreateFloodFillTool; // dimension actions -QAction*actionChangeDim; +QAction* actionChangeDim; +QAction* actionSetWidth; +QAction* actionSetInnerAlpha; // dialog actions QAction* actionAboutDialog; @@ -195,11 +216,14 @@ 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; 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..a767c54 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); @@ -59,6 +59,7 @@ public: */ IntelliImage(int width, int height, bool fastRendererOn); + /*! * \brief An Abstract Destructor. */ @@ -170,6 +171,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..de9412f 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::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; +} + + + 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; } @@ -49,3 +59,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..5b224dc 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -26,6 +26,8 @@ public: */ IntelliRasterImage(int width, int height, bool fastRendererOn); +IntelliRasterImage* copy(const IntelliRasterImage& image); + /*! * \brief An Destructor. */ @@ -57,6 +59,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..6aca975 100644 --- a/src/Image/IntelliShapedImage.cpp +++ b/src/Image/IntelliShapedImage.cpp @@ -6,10 +6,17 @@ IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) : IntelliRasterImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + TypeOfImage = ImageType::SHAPEDIMAGE; this->fastRenderering = fastRendererOn; } +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(){ } @@ -19,10 +26,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; } @@ -111,3 +118,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..6f236ab 100644 --- a/src/Image/IntelliShapedImage.h +++ b/src/Image/IntelliShapedImage.h @@ -38,6 +38,7 @@ public: */ IntelliShapedImage(int width, int height, bool fastRendererOn); +IntelliShapedImage* copy(const IntelliShapedImage& image); /*! * \brief An Destructor. */ @@ -77,6 +78,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 new file mode 100644 index 0000000..bce95f6 --- /dev/null +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -0,0 +1,101 @@ +#include "IntelliDatamanager.h" +#include "Layer/PaintingArea.h" + +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 << 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 << 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 << "\nFormat designed and approved by IntelliPhoto Team 7. All rigths reserved."; + openFile.close(); + return true; + } + + return false; +} + +bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ + QFile openFile(filePath); + Canvas->deleteAllLayers(); + if(openFile.open(QIODevice::ReadOnly)){ + 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; + } + + return false; +} diff --git a/src/IntelliHelper/IntelliDatamanager.h b/src/IntelliHelper/IntelliDatamanager.h new file mode 100644 index 0000000..eb121d9 --- /dev/null +++ b/src/IntelliHelper/IntelliDatamanager.h @@ -0,0 +1,16 @@ +#ifndef INTELLIDATAMANAGER_H +#define INTELLIDATAMANAGER_H + +#include +#include + +class PaintingArea; + +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/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 \ diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index b471da0..d147488 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -17,10 +17,27 @@ #include "Tool/IntelliToolRectangle.h" #include "Tool/IntelliToolFloodFill.h" #include "Tool/IntelliToolPolygon.h" +#include "GUI/IntelliPhotoGui.h" +LayerObject::LayerObject(){ + +} + +LayerObject::LayerObject(const LayerObject& layer){ + if(layer.image->getTypeOfImage()==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){ + : QLabel(parent){ this->Tool = nullptr; this->setLayerDimensions(maxWidth, maxHeight); @@ -48,32 +65,48 @@ 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; 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); } -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; + historyadd(); return activeLayer; } @@ -98,6 +131,7 @@ void PaintingArea::slotDeleteActiveLayer(){ this->layerBundle.erase(layerBundle.begin() + activeLayer); activeLayer--; } + historyadd(); } void PaintingArea::setLayerActive(int idx){ @@ -116,11 +150,11 @@ 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; - this->DummyGui->setToolWidth(5); + this->guiReference->setToolWidth(5); } } } @@ -137,6 +171,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) { @@ -165,6 +206,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){ @@ -174,7 +216,8 @@ void PaintingArea::moveActiveLayer(int idx){ }else if(idx==-1) { this->selectLayerDown(); } - DummyGui->UpdateGui(); + guiReference->UpdateGui(); + historyadd(); } void PaintingArea::slotActivateLayer(int a){ @@ -248,7 +291,7 @@ int PaintingArea::getMaxHeight(){ return this->maxHeight; } -IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){ +ImageType PaintingArea::getTypeOfImageRealLayer(){ return this->layerBundle[static_cast(activeLayer)].image->getTypeOfImage(); } @@ -265,12 +308,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 +327,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 +339,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) { @@ -322,11 +365,17 @@ 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*2,maxHeight*2)); 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 + //Todo set offset in first to parameters and calulate them into mouse position + painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension); update(); } @@ -435,6 +484,10 @@ QImage PaintingArea::getImageDataOfActiveLayer(){ return returnImage; } +std::vector* PaintingArea::getLayerBundle(){ + return &layerBundle; +} + void PaintingArea::updateTools(){ if(Tool!=nullptr) { if(Tool->getIsDrawing()) { @@ -449,3 +502,33 @@ 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; +} + +void PaintingArea::historyGoBack(){ + if (historyPresent != historyMaxPast){ + if (--historyPresent == -1) + historyPresent = 99; + layerBundle = history[static_cast(historyPresent)]; + } + this->guiReference->UpdateGui(); +} + +void PaintingArea::historyGoForward(){ + if (historyPresent != historyMaxFuture){ + if (++historyPresent == 100) + historyPresent = 0; + layerBundle = history[static_cast(historyPresent)]; + } + this->guiReference->UpdateGui(); +} diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 58eb411..4c6d109 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -7,7 +7,7 @@ #include #include #include -#include "GUI/IntelliPhotoGui.h" +#include #include "Image/IntelliImage.h" #include "Image/IntelliRasterImage.h" #include "Image/IntelliShapedImage.h" @@ -16,7 +16,7 @@ //for unit testing class UnitTest; - +class IntelliPhotoGui; /*! * \brief The LayerObject struct holds all the information needed to construct a layer */ @@ -45,12 +45,16 @@ struct LayerObject { * \brief alpha - Stores the alpha value of the layer (default=255). */ int alpha = 255; + + LayerObject(); + + LayerObject(const LayerObject& layer); }; /*! * \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 @@ -79,6 +83,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. @@ -93,16 +103,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 @@ -113,7 +128,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 +199,7 @@ int getMaxWidth(); int getMaxHeight(); -IntelliImage::ImageType getTypeOfImageRealLayer(); +ImageType getTypeOfImageRealLayer(); std::vector getPolygonDataOfRealLayer(); @@ -198,9 +213,23 @@ 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; +void historyGoBack(); +void historyGoForward(); + +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 @@ -222,12 +251,16 @@ void wheelEvent(QWheelEvent*event) override; void paintEvent(QPaintEvent*event) override; private: -void setLayerDimensions(int maxWidth, int maxHeight); +//offset for the displayable +int offsetXDimension; +int offsetYDimension; + void selectLayerUp(); void selectLayerDown(); IntelliTool* copyActiveTool(); QImage* Canvas; +QImage ScaledCanvas; int maxWidth; int maxHeight; @@ -235,7 +268,7 @@ bool isSettingPolygon = false; IntelliRenderSettings renderSettings; IntelliTool* Tool; -IntelliPhotoGui* DummyGui; +IntelliPhotoGui* guiReference; std::vector layerBundle; int activeLayer = -1; @@ -245,6 +278,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..d113410 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; @@ -50,7 +51,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 +89,8 @@ void IntelliTool::mergeToolLayer(){ if(Canvas->image->getPolygonData().size() > 0) { activeLayer->image->setPolygon(Canvas->image->getPolygonData()); } - Area->DummyGui->UpdateGui(); + Area->guiReference->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; } diff --git a/src/main.cpp b/src/main.cpp index 30adab2..dc5caa5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,11 +2,11 @@ #include #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();