IntelliPhoto  0.4
IntelliToolRectangle.cpp
Go to the documentation of this file.
2 #include "Layer/PaintingArea.h"
3 #include "QInputDialog"
4 
6  :IntelliTool(Area, colorPicker){
7  this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
8  this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
9 }
10 
12 
13 }
14 
15 void IntelliToolRectangle::drawRectangle(QPoint otherCornor){
16  int xMin = std::min(originCornor.x(), otherCornor.x());
17  int xMax = std::max(originCornor.x(), otherCornor.x());
18 
19  int yMin = std::min(originCornor.y(), otherCornor.y());
20  int yMax = std::max(originCornor.y(), otherCornor.y());
21 
22  QColor clr = colorPicker->getSecondColor();
23  clr.setAlpha(alphaInner);
24  for(int y=yMin; y<=yMax; y++){
25  this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
26  }
27  this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth);
28  this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth);
29  this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth);
30  this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth);
31 }
32 
35 }
36 
39 }
40 
43  this->originCornor=QPoint(x,y);
44  drawRectangle(originCornor);
46 }
47 
50 }
51 
53  if(this->drawing){
54  this->Canvas->image->drawPlain(Qt::transparent);
55  QPoint next(x,y);
56  drawRectangle(next);
57  }
59 }
60 
63  this->edgeWidth+=value;
64  if(this->edgeWidth<=0){
65  this->edgeWidth=1;
66  }
67 }
IntelliToolRectangle::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event. A Positive Value means scrolling outwards. Call this in child c...
Definition: IntelliToolRectangle.cpp:61
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
IntelliToolRectangle::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click Released of a Mouse. Merging the Canvas to Active....
Definition: IntelliToolRectangle.cpp:37
IntelliTool::colorPicker
IntelliColorPicker * colorPicker
A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors.
Definition: IntelliTool.h:38
IntelliImage::drawLine
virtual void drawLine(const QPoint &p1, const QPoint &p2, const QColor &color, const int &penWidth)
A function that draws A Line between two given Points in a given color.
Definition: IntelliImage.cpp:65
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
IntelliToolRectangle::~IntelliToolRectangle
virtual ~IntelliToolRectangle() override
Definition: IntelliToolRectangle.cpp:11
IntelliToolRectangle::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click Pressed of a Mouse. Resetting the current draw....
Definition: IntelliToolRectangle.cpp:41
IntelliColorPicker::getSecondColor
QColor getSecondColor()
A function to read the secondary selected color.
Definition: IntelliColorPicker.cpp:20
IntelliToolRectangle::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y) override
A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on....
Definition: IntelliToolRectangle.cpp:33
PaintingArea
Definition: PaintingArea.h:26
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
IntelliToolRectangle.h
IntelliTool::drawing
bool drawing
A flag checking if the user is currently drawing or not.
Definition: IntelliTool.h:53
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
IntelliToolRectangle::onMouseMoved
virtual void onMouseMoved(int x, int y) override
A function managing the mouse moved event. Call this in child classes!
Definition: IntelliToolRectangle.cpp:52
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:18
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
IntelliToolRectangle::IntelliToolRectangle
IntelliToolRectangle(PaintingArea *Area, IntelliColorPicker *colorPicker)
Definition: IntelliToolRectangle.cpp:5
IntelliImage::calculateVisiblity
virtual void calculateVisiblity()=0
An abstract function that calculates the visiblity of the Image data if needed.
IntelliToolRectangle::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click Released of a Mouse. Call this in child classes!
Definition: IntelliToolRectangle.cpp:48
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
IntelliImage::drawPlain
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.
Definition: IntelliImage.cpp:77