diff --git a/src/Painting/GUI/IntelliPhotoGui.cpp b/src/Painting/GUI/IntelliPhotoGui.cpp index 51d5731..aa2970e 100644 --- a/src/Painting/GUI/IntelliPhotoGui.cpp +++ b/src/Painting/GUI/IntelliPhotoGui.cpp @@ -219,8 +219,12 @@ void IntelliPhotoGui::slotCreatePenTool(){ paintingArea->createPenTool(); } -void IntelliPhotoGui::slotCreateFloodFillTool(){ - paintingArea->createFloodFillTool(); +void IntelliPhotoGui::slotCreatePlainTool(){ + paintingArea->createPlainTool(); +} + +void IntelliPhotoGui::slotCreateLineTool(){ + paintingArea->createLineTool(); } // Open an about dialog @@ -315,12 +319,14 @@ void IntelliPhotoGui::createActions() connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown())); //Create Tool actions down here - actionCreateFloodFillTool = new QAction(tr("&Flood Fill"), this); - connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool())); + actionCreatePlainTool = new QAction(tr("&Plain"), this); + connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool())); actionCreatePenTool = new QAction(tr("&Pen"),this); connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool())); + actionCreateLineTool = new QAction(tr("&Line"), this); + connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotCreateLineTool())); // Create about action and tie to IntelliPhotoGui::about() actionAboutDialog = new QAction(tr("&About"), this); @@ -366,7 +372,8 @@ void IntelliPhotoGui::createMenus() //Attach all Tool Options toolMenu = new QMenu(tr("&Tools"), this); toolMenu->addAction(actionCreatePenTool); - toolMenu->addAction(actionCreateFloodFillTool); + toolMenu->addAction(actionCreatePlainTool); + toolMenu->addAction(actionCreateLineTool); // Attach all actions to Help helpMenu = new QMenu(tr("&Help"), this); diff --git a/src/Painting/GUI/IntelliPhotoGui.h b/src/Painting/GUI/IntelliPhotoGui.h index 994c0c7..7639383 100644 --- a/src/Painting/GUI/IntelliPhotoGui.h +++ b/src/Painting/GUI/IntelliPhotoGui.h @@ -44,7 +44,8 @@ private slots: void slotMoveLayerDown(); void slotCreatePenTool(); - void slotCreateFloodFillTool(); + void slotCreatePlainTool(); + void slotCreateLineTool(); void slotAboutDialog(); @@ -83,7 +84,8 @@ private: QAction *actionDeleteLayer; QAction *actionCreatePenTool; - QAction *actionCreateFloodFillTool; + QAction *actionCreatePlainTool; + QAction *actionCreateLineTool; QAction *actionAboutDialog; QAction *actionAboutQtDialog; diff --git a/src/Painting/Image/IntelliImage.h b/src/Painting/Image/IntelliImage.h index 55ea479..72a7310 100644 --- a/src/Painting/Image/IntelliImage.h +++ b/src/Painting/Image/IntelliImage.h @@ -19,7 +19,6 @@ class IntelliImage{ friend IntelliTool; protected: void resizeImage(QImage *image, const QSize &newSize); - virtual void calculateVisiblity()=0; QImage imageData; @@ -28,6 +27,7 @@ public: IntelliImage(int weight, int height); virtual ~IntelliImage() = 0; + //start on top left virtual void drawPixel(const QPoint &p1, const QColor& color); virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth); @@ -39,12 +39,13 @@ public: //gets a copy of the image !allocated virtual IntelliImage* getDeepCopy()=0; + virtual void calculateVisiblity()=0; //returns the filtered output //sets the data for the visible image virtual void setPolygon(const std::vector& polygonData)=0; - + virtual std::vector getPolygonData(){ return std::vector();} //loads an image to the ColorBuffer virtual bool loadImage(const QString &fileName); diff --git a/src/Painting/Image/IntelliShapedImage.cpp b/src/Painting/Image/IntelliShapedImage.cpp index 72480f6..4257847 100644 --- a/src/Painting/Image/IntelliShapedImage.cpp +++ b/src/Painting/Image/IntelliShapedImage.cpp @@ -18,8 +18,8 @@ QImage IntelliShapedImage::getDisplayable(int alpha){ IntelliImage* IntelliShapedImage::getDeepCopy(){ IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height()); - shaped->setPolygon(this->polygonData); shaped->imageData.fill(Qt::transparent); + shaped->setPolygon(this->polygonData); return shaped; } diff --git a/src/Painting/Image/IntelliShapedImage.h b/src/Painting/Image/IntelliShapedImage.h index e3ef5bc..2c8c3a3 100644 --- a/src/Painting/Image/IntelliShapedImage.h +++ b/src/Painting/Image/IntelliShapedImage.h @@ -6,18 +6,21 @@ class IntelliShapedImage : public IntelliImage{ friend IntelliTool; protected: - virtual void calculateVisiblity() override; + std::vector polygonData; public: IntelliShapedImage(int weight, int height); virtual ~IntelliShapedImage() override; + virtual void calculateVisiblity() override; + //returns the filtered output virtual QImage getDisplayable(const QSize& displaySize, int alpha=255) override; virtual QImage getDisplayable(int alpha=255) override; //gets a copy of the image !allocated virtual IntelliImage* getDeepCopy() override; + virtual std::vector getPolygonData() override{return polygonData;} //sets the data for the visible image virtual void setPolygon(const std::vector& polygonData) override; diff --git a/src/Painting/IntelliPhoto.pro b/src/Painting/IntelliPhoto.pro index e83f1d7..e4c4ce5 100644 --- a/src/Painting/IntelliPhoto.pro +++ b/src/Painting/IntelliPhoto.pro @@ -23,8 +23,9 @@ SOURCES += \ IntelliHelper/IntelliHelper.cpp \ Layer/PaintingArea.cpp \ Tool/IntelliTool.cpp \ - Tool/IntelliToolFloodFillTool.cpp \ + Tool/IntelliToolLine.cpp \ Tool/IntelliToolPen.cpp \ + Tool/IntelliToolPlain.cpp \ main.cpp HEADERS += \ @@ -35,8 +36,9 @@ HEADERS += \ IntelliHelper/IntelliHelper.h \ Layer/PaintingArea.h \ Tool/IntelliTool.h \ - Tool/IntelliToolFloodFillTool.h \ - Tool/IntelliToolPen.h + Tool/IntelliToolLine.h \ + Tool/IntelliToolPen.h \ + Tool/IntelliToolPlain.h FORMS += \ widget.ui diff --git a/src/Painting/Layer/PaintingArea.cpp b/src/Painting/Layer/PaintingArea.cpp index 2c3ec59..4b7f450 100644 --- a/src/Painting/Layer/PaintingArea.cpp +++ b/src/Painting/Layer/PaintingArea.cpp @@ -11,7 +11,8 @@ #include "Image/IntelliRasterImage.h" #include "Image/IntelliShapedImage.h" #include "Tool/IntelliToolPen.h" -#include "Tool/IntelliToolFloodFillTool.h" +#include "Tool/IntelliToolPlain.h" +#include "Tool/IntelliToolLine.h" PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) @@ -32,7 +33,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) layerBundle[1].image->floodFill(QColor(0,255,0,255)); layerBundle[1].alpha=200; - activeLayer=1; + activeLayer=0; } @@ -165,9 +166,14 @@ void PaintingArea::createPenTool(){ Tool = new IntelliToolPen(this); } -void PaintingArea::createFloodFillTool(){ +void PaintingArea::createPlainTool(){ delete this->Tool; - Tool = new IntelliToolFloodFillTool(this); + Tool = new IntelliToolPlainTool(this); +} + +void PaintingArea::createLineTool(){ + delete this->Tool; + Tool = new IntelliToolLine(this); } // If a mouse button is pressed check if it was the diff --git a/src/Painting/Layer/PaintingArea.h b/src/Painting/Layer/PaintingArea.h index 6c5e208..2a0ab76 100644 --- a/src/Painting/Layer/PaintingArea.h +++ b/src/Painting/Layer/PaintingArea.h @@ -50,7 +50,8 @@ public: //create tools void createPenTool(); - void createFloodFillTool(); + void createPlainTool(); + void createLineTool(); public slots: diff --git a/src/Painting/Tool/IntelliTool.cpp b/src/Painting/Tool/IntelliTool.cpp index 4aa4403..f10b872 100644 --- a/src/Painting/Tool/IntelliTool.cpp +++ b/src/Painting/Tool/IntelliTool.cpp @@ -10,10 +10,6 @@ IntelliTool::~IntelliTool(){ } -void IntelliTool::getColorbar(int firstOrSecondColor){ - //optional for tool -} - void IntelliTool::onMouseRightPressed(int x, int y){ if(drawing){ drawing=false; @@ -69,6 +65,7 @@ void IntelliTool::mergeToolLayer(){ Active->image->imageData.setPixelColor(x, y, clr_0); } + Active->image->calculateVisiblity(); } } diff --git a/src/Painting/Tool/IntelliTool.h b/src/Painting/Tool/IntelliTool.h index 75343ce..466e03c 100644 --- a/src/Painting/Tool/IntelliTool.h +++ b/src/Painting/Tool/IntelliTool.h @@ -21,7 +21,6 @@ public: IntelliTool(PaintingArea* Area); virtual ~IntelliTool() = 0; - virtual void getColorbar(int firstOrSecondColor); virtual void onMouseRightPressed(int x, int y); virtual void onMouseRightReleased(int x, int y); diff --git a/src/Painting/Tool/IntelliToolLine.cpp b/src/Painting/Tool/IntelliToolLine.cpp new file mode 100644 index 0000000..ff94a6b --- /dev/null +++ b/src/Painting/Tool/IntelliToolLine.cpp @@ -0,0 +1,49 @@ +#include "IntelliToolLine.h" +#include "Layer/PaintingArea.h" +#include "QColorDialog" +#include "QInputDialog" + +IntelliToolLine::IntelliToolLine(PaintingArea* Area) + :IntelliTool(Area){ + this->color = QColorDialog::getColor(Qt::blue, nullptr, "Line Color"); + this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); + //create checkbox or scroll dialog to get line style + this->lineStyle = LineStyle::SOLID_LINE; +} + +IntelliToolLine::~IntelliToolLine(){ + +} + + +void IntelliToolLine::onMouseRightPressed(int x, int y){ + IntelliTool::onMouseRightPressed(x,y); +} + +void IntelliToolLine::onMouseRightReleased(int x, int y){ + IntelliTool::onMouseRightReleased(x,y); +} + +void IntelliToolLine::onMouseLeftPressed(int x, int y){ + IntelliTool::onMouseLeftPressed(x,y); + this->start=QPoint(x,y); + this->Canvas->image->drawLine(start, start, this->color, this->lineWidth); +} + +void IntelliToolLine::onMouseLeftReleased(int x, int y){ + IntelliTool::onMouseLeftReleased(x,y); +} + +void IntelliToolLine::onMouseMoved(int x, int y){ + IntelliTool::onMouseMoved(x,y); + if(this->drawing){ + this->Canvas->image->floodFill(Qt::transparent); + QPoint next(x,y); + switch(lineStyle){ + case LineStyle::SOLID_LINE : + this->Canvas->image->drawLine(start,next,color,lineWidth); + break; + } + } + +} diff --git a/src/Painting/Tool/IntelliToolLine.h b/src/Painting/Tool/IntelliToolLine.h new file mode 100644 index 0000000..37faace --- /dev/null +++ b/src/Painting/Tool/IntelliToolLine.h @@ -0,0 +1,31 @@ +#ifndef INTELLITOOLLINE_H +#define INTELLITOOLLINE_H +#include "IntelliTool.h" + +#include "QColor" +#include "QPoint" + +enum class LineStyle{ + SOLID_LINE +}; + +class IntelliToolLine : public IntelliTool +{ + QPoint start; + QColor color; + int lineWidth; + LineStyle lineStyle; +public: + IntelliToolLine(PaintingArea* Area); + virtual ~IntelliToolLine() override; + + + virtual void onMouseRightPressed(int x, int y) override; + virtual void onMouseRightReleased(int x, int y) override; + virtual void onMouseLeftPressed(int x, int y) override; + virtual void onMouseLeftReleased(int x, int y) override; + + virtual void onMouseMoved(int x, int y) override; +}; + +#endif // INTELLITOOLLINE_H diff --git a/src/Painting/Tool/IntelliToolPen.cpp b/src/Painting/Tool/IntelliToolPen.cpp index 4da6754..19b6f0e 100644 --- a/src/Painting/Tool/IntelliToolPen.cpp +++ b/src/Painting/Tool/IntelliToolPen.cpp @@ -7,9 +7,7 @@ IntelliToolPen::IntelliToolPen(PaintingArea* Area) :IntelliTool(Area){ this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color"); - - bool ok; - this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1, &ok); + this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1); } IntelliToolPen::~IntelliToolPen(){ @@ -18,22 +16,18 @@ IntelliToolPen::~IntelliToolPen(){ void IntelliToolPen::onMouseRightPressed(int x, int y){ IntelliTool::onMouseRightPressed(x,y); - //implement in here } void IntelliToolPen::onMouseRightReleased(int x, int y){ IntelliTool::onMouseRightReleased(x,y); - //implemnt in here } void IntelliToolPen::onMouseLeftPressed(int x, int y){ - //implement in here IntelliTool::onMouseLeftPressed(x,y); this->point=QPoint(x,y); } void IntelliToolPen::onMouseLeftReleased(int x, int y){ - //implement in here IntelliTool::onMouseLeftReleased(x,y); } diff --git a/src/Painting/Tool/IntelliToolFloodFillTool.cpp b/src/Painting/Tool/IntelliToolPlain.cpp similarity index 50% rename from src/Painting/Tool/IntelliToolFloodFillTool.cpp rename to src/Painting/Tool/IntelliToolPlain.cpp index 5bc163d..d344eff 100644 --- a/src/Painting/Tool/IntelliToolFloodFillTool.cpp +++ b/src/Painting/Tool/IntelliToolPlain.cpp @@ -1,30 +1,32 @@ -#include "IntelliToolFloodFillTool.h" +#include "IntelliToolPlain.h" #include "Layer/PaintingArea.h" #include "QColorDialog" -IntelliToolFloodFillTool::IntelliToolFloodFillTool(PaintingArea* Area) +IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area) :IntelliTool(Area){ this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color"); } -void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y){ +void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); this->Canvas->image->floodFill(color); } -void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y){ - IntelliTool::onMouseRightPressed(x,y); -} - -void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y){ - IntelliTool::onMouseRightReleased(x,y); -} - -void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y){ +void IntelliToolPlainTool::onMouseLeftReleased(int x, int y){ IntelliTool::onMouseLeftReleased(x,y); } -void IntelliToolFloodFillTool::onMouseMoved(int x, int y){ - IntelliTool::onMouseMoved(x,y); +void IntelliToolPlainTool::onMouseRightPressed(int x, int y){ + IntelliTool::onMouseRightPressed(x,y); +} + +void IntelliToolPlainTool::onMouseRightReleased(int x, int y){ + IntelliTool::onMouseRightReleased(x,y); +} + + +void IntelliToolPlainTool::onMouseMoved(int x, int y){ + IntelliTool::onMouseMoved(x,y); + } diff --git a/src/Painting/Tool/IntelliToolFloodFillTool.h b/src/Painting/Tool/IntelliToolPlain.h similarity index 81% rename from src/Painting/Tool/IntelliToolFloodFillTool.h rename to src/Painting/Tool/IntelliToolPlain.h index b1ea02c..418fccf 100644 --- a/src/Painting/Tool/IntelliToolFloodFillTool.h +++ b/src/Painting/Tool/IntelliToolPlain.h @@ -4,11 +4,11 @@ #include "IntelliTool.h" #include "QColor" -class IntelliToolFloodFillTool : public IntelliTool +class IntelliToolPlainTool : public IntelliTool { QColor color; public: - IntelliToolFloodFillTool(PaintingArea *Area); + IntelliToolPlainTool(PaintingArea *Area); void onMouseLeftPressed(int x, int y) override; void onMouseLeftReleased(int x, int y) override;