IntelliPhoto 0.5

IntelliToolRectangle.cpp
Go to the documentation of this file.
1 #include "IntelliToolRectangle.h"
2 #include "Layer/PaintingArea.h"
3 #include "QInputDialog"
4
5 IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker)
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
11 IntelliToolRectangle::~IntelliToolRectangle(){
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
33 void IntelliToolRectangle::onMouseRightPressed(int x, int y){
34 IntelliTool::onMouseRightPressed(x,y);
35 }
36
37 void IntelliToolRectangle::onMouseRightReleased(int x, int y){
38 IntelliTool::onMouseRightReleased(x,y);
39 }
40
41 void IntelliToolRectangle::onMouseLeftPressed(int x, int y){
42 IntelliTool::onMouseLeftPressed(x,y);
43 this->originCornor=QPoint(x,y);
44 drawRectangle(originCornor);
45 Canvas->image->calculateVisiblity();
46 }
47
48 void IntelliToolRectangle::onMouseLeftReleased(int x, int y){
49 IntelliTool::onMouseLeftReleased(x,y);
50 }
51
52 void IntelliToolRectangle::onMouseMoved(int x, int y){
53 if(this->drawing) {
54 this->Canvas->image->drawPlain(Qt::transparent);
55 QPoint next(x,y);
56 drawRectangle(next);
57 }
58 IntelliTool::onMouseMoved(x,y);
59 }
60
61 void IntelliToolRectangle::onWheelScrolled(int value){
62 IntelliTool::onWheelScrolled(value);
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.Changing edgeWidth relativ to value.
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.
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
A Destructor.
Definition: IntelliToolRectangle.cpp:11
IntelliToolRectangle::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click pressed of a mouse. Setting the originCorner and draws a rectangle...
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.Resetting the current draw.
Definition: IntelliToolRectangle.cpp:33
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:36
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.Drawing a rectangle to currrent mouse position.
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:25
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)
A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edg...
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. Merging the draw to the active layer.
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:76