IntelliPhoto  0.4
IntelliToolFloodFill.cpp
Go to the documentation of this file.
1 #include "IntelliToolFloodFill.h"
2 #include "Layer/PaintingArea.h"
3 #include "QColorDialog"
4 #include "QInputDialog"
5 #include <functional>
6 #include <queue>
7 
9  :IntelliTool(Area, colorPicker){
10 }
11 
13 
14 }
15 
16 
19 }
20 
23 }
24 
27 
28  QPoint start(x,y);
29  std::queue<QPoint> Q;
30  Q.push(start);
31 
32  QColor oldColor = this->Active->image->getPixelColor(start);
33  QColor newColor = this->colorPicker->getFirstColor();
34  Canvas->image->drawPixel(start,newColor);
35 
36  QPoint left, right, top, down;
37  while(!Q.empty()){
38  QPoint Current = Q.front();
39  Q.pop();
40 
41  left = QPoint(Current.x()-1,Current.y() );
42  right = QPoint(Current.x()+1,Current.y() );
43  top = QPoint(Current.x() ,Current.y()-1);
44  down = QPoint(Current.x() ,Current.y()+1);
45  if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (Active->image->getPixelColor(right) == oldColor)){
46  Canvas->image->drawPixel(right,newColor);
47  Q.push(right);
48  }
49  if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (Active->image->getPixelColor(left) == oldColor)){
50  Canvas->image->drawPixel(left,newColor);
51  Q.push(left);
52  }
53  if((top.y() < Canvas->hight) && (Canvas->image->getPixelColor(top) != newColor) && (Active->image->getPixelColor(top) == oldColor)){
54  Canvas->image->drawPixel(top,newColor);
55  Q.push(top);
56  }
57  if((down.y() >= 0) && (Canvas->image->getPixelColor(down) != newColor) && (Active->image->getPixelColor(down) == oldColor)){
58  Canvas->image->drawPixel(down,newColor);
59  Q.push(down);
60  }
61  }
62 
64 }
65 
68 }
69 
72 
73 }
74 
77 }
IntelliTool::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y)
A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on....
Definition: IntelliTool.cpp:14
IntelliTool::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y)
A function managing the left click Released of a Mouse. Call this in child classes!
Definition: IntelliTool.cpp:32
IntelliTool::colorPicker
IntelliColorPicker * colorPicker
A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors.
Definition: IntelliTool.h:38
IntelliToolFloodFill::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click released of a mouse.
Definition: IntelliToolFloodFill.cpp:21
IntelliTool::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y)
A function managing the left click Pressed of a Mouse. Resetting the current draw....
Definition: IntelliTool.cpp:25
IntelliImage::drawPixel
virtual void drawPixel(const QPoint &p1, const QColor &color)
A funtcion used to draw a pixel on the Image with the given Color.
Definition: IntelliImage.cpp:44
IntelliToolFloodFill::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click released of a mouse.
Definition: IntelliToolFloodFill.cpp:66
IntelliToolFloodFill::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event.
Definition: IntelliToolFloodFill.cpp:70
IntelliToolFloodFill.h
IntelliToolFloodFill::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click pressed of a mouse. Sets the point to flood fill around and does t...
Definition: IntelliToolFloodFill.cpp:25
PaintingArea
Definition: PaintingArea.h:25
IntelliToolFloodFill::~IntelliToolFloodFill
virtual ~IntelliToolFloodFill() override
A Destructor.
Definition: IntelliToolFloodFill.cpp:12
IntelliToolFloodFill::IntelliToolFloodFill
IntelliToolFloodFill(PaintingArea *Area, IntelliColorPicker *colorPicker)
A constructor setting the general paintingArea and colorPicker.
Definition: IntelliToolFloodFill.cpp:8
IntelliTool::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y)
A function managing the right click Released of a Mouse. Merging the Canvas to Active....
Definition: IntelliTool.cpp:21
IntelliTool::Canvas
LayerObject * Canvas
A pointer to the drawing canvas of the tool, work on this.
Definition: IntelliTool.h:48
LayerObject::width
int width
Definition: PaintingArea.h:18
IntelliToolFloodFill::onMouseMoved
virtual void onMouseMoved(int x, int y) override
A function managing the mouse moved event.
Definition: IntelliToolFloodFill.cpp:75
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:13
PaintingArea.h
IntelliColorPicker::getFirstColor
QColor getFirstColor()
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:16
IntelliImage::getPixelColor
virtual QColor getPixelColor(QPoint &point)
A function that returns the pixelcolor at a certain point.
Definition: IntelliImage.cpp:80
LayerObject::hight
int hight
Definition: PaintingArea.h:19
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
IntelliToolFloodFill::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y) override
A function managing the right click pressed of a mouse. Clearing the canvas.
Definition: IntelliToolFloodFill.cpp:17
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:17
IntelliTool::Active
LayerObject * Active
A pointer to the underlying active Layer, do not work on this. This is used for data grabbing or prev...
Definition: IntelliTool.h:43
IntelliTool::onMouseMoved
virtual void onMouseMoved(int x, int y)
A function managing the mouse moved event. Call this in child classes!
Definition: IntelliTool.cpp:41
IntelliImage::calculateVisiblity
virtual void calculateVisiblity()=0
An abstract function that calculates the visiblity of the Image data if needed.
IntelliTool::onWheelScrolled
virtual void onWheelScrolled(int value)
A function managing the scroll event. A positive value means scrolling outwards. Call this in child c...
Definition: IntelliTool.cpp:46