diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index f5ae7a1..36fce1f 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -77,3 +77,7 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co void IntelliImage::drawPlain(const QColor& color){ imageData.fill(color); } + +QColor IntelliImage::getPixelColor(int x, int y){ + return imageData.pixelColor(x,y); +} diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h index c098549..26ec56b 100644 --- a/src/Image/IntelliImage.h +++ b/src/Image/IntelliImage.h @@ -110,6 +110,8 @@ public: * \return True if the image could be loaded, false otherwise. */ virtual bool loadImage(const QString &fileName); + + virtual QColor getPixelColor(int x, int y); }; #endif diff --git a/src/IntelliPhoto.pro b/src/IntelliPhoto.pro index 9b0956d..f10c416 100644 --- a/src/IntelliPhoto.pro +++ b/src/IntelliPhoto.pro @@ -25,6 +25,7 @@ SOURCES += \ Layer/PaintingArea.cpp \ Tool/IntelliTool.cpp \ Tool/IntelliToolCircle.cpp \ + Tool/IntelliToolFloodFill.cpp \ Tool/IntelliToolLine.cpp \ Tool/IntelliToolPen.cpp \ Tool/IntelliToolPlain.cpp \ @@ -41,6 +42,7 @@ HEADERS += \ Layer/PaintingArea.h \ Tool/IntelliTool.h \ Tool/IntelliToolCircle.h \ + Tool/IntelliToolFloodFill.h \ Tool/IntelliToolLine.h \ Tool/IntelliToolPen.h \ Tool/IntelliToolPlain.h \ diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 608770e..4d085ea 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -79,3 +79,4 @@ void IntelliTool::deleteToolLayer(){ Area->deleteLayer(Area->activeLayer+1); this->Canvas=nullptr; } + diff --git a/src/Tool/IntelliTool.h b/src/Tool/IntelliTool.h index 2531a55..b66a6b0 100644 --- a/src/Tool/IntelliTool.h +++ b/src/Tool/IntelliTool.h @@ -32,5 +32,7 @@ public: virtual void onWheelScrolled(int value); virtual void onMouseMoved(int x, int y); + + }; #endif diff --git a/src/Tool/IntelliToolFloodFill.cpp b/src/Tool/IntelliToolFloodFill.cpp new file mode 100644 index 0000000..7712f90 --- /dev/null +++ b/src/Tool/IntelliToolFloodFill.cpp @@ -0,0 +1,66 @@ +#include "IntelliToolFloodFill.h" +#include "Layer/PaintingArea.h" +#include "QColorDialog" +#include "QInputDialog" + +IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker) + :IntelliTool(Area, colorPicker){ +} + +IntelliToolFloodFill::~IntelliToolFloodFill(){ + +} + + +void IntelliToolFloodFill::onMouseRightPressed(int x, int y){ + IntelliTool::onMouseRightPressed(x,y); +} + +void IntelliToolFloodFill::onMouseRightReleased(int x, int y){ + IntelliTool::onMouseRightReleased(x,y); +} + +void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){ + IntelliTool::onMouseLeftPressed(x,y); + this->Canvas->image->get + auto depthsearch = [](int x, int y, LayerObject* Canvas){ + + }; + + Canvas->image->calculateVisiblity(); + + +} + +void IntelliToolFloodFill::onMouseLeftReleased(int x, int y){ + IntelliTool::onMouseLeftReleased(x,y); +} + +void IntelliToolFloodFill::onWheelScrolled(int value){ + IntelliTool::onWheelScrolled(value); + this->lineWidth+=value; + if(this->lineWidth<=0){ + this->lineWidth=1; + } +} + +void IntelliToolFloodFill::onMouseMoved(int x, int y){ + IntelliTool::onMouseMoved(x,y); + if(this->drawing){ + this->Canvas->image->drawPlain(Qt::transparent); + QPoint next(x,y); + switch(lineStyle){ + case LineStyle::SOLID_LINE: + this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth); + break; + case LineStyle::DOTTED_LINE: + QPoint p1 =start.x() <= next.x() ? start : next; + QPoint p2 =start.x() < next.x() ? next : start; + int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f; + int c = start.y()-start.x()*m; + + break; + } + } + IntelliTool::onMouseMoved(x,y); +} diff --git a/src/Tool/IntelliToolFloodFill.h b/src/Tool/IntelliToolFloodFill.h new file mode 100644 index 0000000..0aa298f --- /dev/null +++ b/src/Tool/IntelliToolFloodFill.h @@ -0,0 +1,23 @@ +#ifndef INTELLITOOLFLOODFILL_H +#define INTELLITOOLFLOODFILL_H +#include "IntelliTool.h" + +#include "QColor" + +class IntelliToolFloodFill : public IntelliTool{ +public: + IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker); + virtual ~IntelliToolFloodFill() 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 onWheelScrolled(int value) override; + + virtual void onMouseMoved(int x, int y) override; +}; + +#endif // INTELLITOOLFLOODFILL_H diff --git a/src/Tool/IntelliToolLine.h b/src/Tool/IntelliToolLine.h index af1f874..0d5d289 100644 --- a/src/Tool/IntelliToolLine.h +++ b/src/Tool/IntelliToolLine.h @@ -2,7 +2,6 @@ #define INTELLITOOLLINE_H #include "IntelliTool.h" -#include "QColor" #include "QPoint" enum class LineStyle{