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, IntelliToolsettings* Toolsettings)
6 : IntelliTool(Area, colorPicker, Toolsettings){
7 this->ActiveType = Tooltype::RECTANGLE;
8 }
9
10 IntelliToolRectangle::~IntelliToolRectangle(){
11 IntelliTool::onMouseRightPressed(0,0);
12 }
13
14 void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
15 int xMin = std::min(originCorner.x(), otherCorner.x());
16 int xMax = std::max(originCorner.x(), otherCorner.x());
17
18 int yMin = std::min(originCorner.y(), otherCorner.y());
19 int yMax = std::max(originCorner.y(), otherCorner.y());
20
21 QColor clr = colorPicker->getSecondColor();
22 clr.setAlpha(Toolsettings->getInnerAlpha());
23 for(int y=yMin; y<=yMax; y++) {
24 this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
25 }
26 this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
27 this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
28 this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
29 this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
30 }
31
32 void IntelliToolRectangle::onMouseRightPressed(int x, int y){
33 IntelliTool::onMouseRightPressed(x,y);
34 }
35
36 void IntelliToolRectangle::onMouseRightReleased(int x, int y){
37 IntelliTool::onMouseRightReleased(x,y);
38 }
39
40 void IntelliToolRectangle::onMouseLeftPressed(int x, int y){
41 IntelliTool::onMouseLeftPressed(x,y);
42 this->originCorner=QPoint(x,y);
43 drawRectangle(originCorner);
44 Canvas->image->calculateVisiblity();
45 }
46
47 void IntelliToolRectangle::onMouseLeftReleased(int x, int y){
48 IntelliTool::onMouseLeftReleased(x,y);
49 }
50
51 void IntelliToolRectangle::onMouseMoved(int x, int y){
52 if(this->isDrawing) {
53 this->Canvas->image->drawPlain(Qt::transparent);
54 QPoint next(x,y);
55 drawRectangle(next);
56 }
57 IntelliTool::onMouseMoved(x,y);
58 }
59
60 void IntelliToolRectangle::onWheelScrolled(int value){
61 IntelliTool::onWheelScrolled(value);
62 Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
63 }
IntelliToolRectangle::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event.Changing edgeWidth relativ to value.
Definition: IntelliToolRectangle.cpp:60
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:15
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:33
IntelliToolRectangle::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click released of a mouse.
Definition: IntelliToolRectangle.cpp:36
IntelliTool::colorPicker
IntelliColorPicker * colorPicker
A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors.
Definition: IntelliTool.h:51
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:88
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:26
IntelliTool::Toolsettings
IntelliToolsettings * Toolsettings
Definition: IntelliTool.h:53
IntelliToolsettings::setLineWidth
void setLineWidth()
Definition: IntelliToolsettings.cpp:19
IntelliToolRectangle::~IntelliToolRectangle
virtual ~IntelliToolRectangle() override
A Destructor.
Definition: IntelliToolRectangle.cpp:10
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:40
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:32
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:37
IntelliTool::isDrawing
bool isDrawing
A flag checking if the user is currently drawing or not.
Definition: IntelliTool.h:68
IntelliToolsettings::getInnerAlpha
int getInnerAlpha()
Definition: IntelliToolsettings.cpp:33
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:22
IntelliTool::Canvas
LayerObject * Canvas
A pointer to the drawing canvas of the tool, work on this.
Definition: IntelliTool.h:63
IntelliToolRectangle.h
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:14
PaintingArea.h
IntelliColorPicker::getFirstColor
QColor getFirstColor()
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:16
IntelliTool::ActiveType
Tooltype ActiveType
Definition: IntelliTool.h:46
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:51
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
IntelliTool::Tooltype::RECTANGLE
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:26
IntelliToolsettings::getLineWidth
int getLineWidth()
Definition: IntelliToolsettings.cpp:15
IntelliTool::onMouseMoved
virtual void onMouseMoved(int x, int y)
A function managing the mouse moved event. Call this in child classes!
Definition: IntelliTool.cpp:42
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:47
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:47
IntelliToolsettings
Definition: IntelliToolsettings.h:4
IntelliImage::drawPlain
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.
Definition: IntelliImage.cpp:105
IntelliToolRectangle::IntelliToolRectangle
IntelliToolRectangle(PaintingArea *Area, IntelliColorPicker *colorPicker, IntelliToolsettings *Toolsettings)
A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edg...
Definition: IntelliToolRectangle.cpp:5