IntelliToolRectangle.cpp
Go to the documentation of this file.
#include "IntelliToolRectangle.h"
#include "Layer/PaintingArea.h"
#include "QInputDialog"
IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::RECTANGLE;
}
IntelliToolRectangle::~IntelliToolRectangle(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
int xMin = std::min(originCorner.x(), otherCorner.x());
int xMax = std::max(originCorner.x(), otherCorner.x());
int yMin = std::min(originCorner.y(), otherCorner.y());
int yMax = std::max(originCorner.y(), otherCorner.y());
QColor clr = colorPicker->getSecondColor();
clr.setAlpha(Toolsettings->getInnerAlpha());
for(int y = yMin; y<=yMax; y++) {
this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
}
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
}
void IntelliToolRectangle::onMouseRightPressed(int x, int y){
IntelliTool::onMouseRightPressed(x,y);
}
void IntelliToolRectangle::onMouseRightReleased(int x, int y){
IntelliTool::onMouseRightReleased(x,y);
}
void IntelliToolRectangle::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->originCorner = QPoint(x,y);
drawRectangle(originCorner);
Canvas->image->calculateVisiblity();
}
void IntelliToolRectangle::onMouseLeftReleased(int x, int y){
IntelliTool::onMouseLeftReleased(x,y);
}
void IntelliToolRectangle::onMouseMoved(int x, int y){
if(this->isDrawing) {
this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y);
drawRectangle(next);
}
IntelliTool::onMouseMoved(x,y);
}
void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
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:19
IntelliColorPicker::getFirstColor
QColor getFirstColor() const
A function to read the primary selected color.
Definition: IntelliColorPicker.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:37
IntelliToolsettings::getLineWidth
int getLineWidth() const
getLineWidth returns the width attribute of the line.
Definition: IntelliToolsettings.cpp:14
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:64
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:97
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:30
IntelliTool::Toolsettings
IntelliToolsettings * Toolsettings
Toolsettings a refrence to the tool settings.
Definition: IntelliTool.h:69
IntelliToolRectangle::~IntelliToolRectangle
virtual ~IntelliToolRectangle() override
A Destructor.
Definition: IntelliToolRectangle.cpp:10
IntelliToolsettings::getInnerAlpha
int getInnerAlpha() const
getInnerAlpha returns the inner alpha value.
Definition: IntelliToolsettings.cpp:28
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
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:57
IntelliTool::isDrawing
bool isDrawing
A flag checking if the user is currently drawing or not.
Definition: IntelliTool.h:84
IntelliColorPicker::getSecondColor
QColor getSecondColor() const
A function to read the secondary selected color.
Definition: IntelliColorPicker.cpp:19
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:26
IntelliTool::Canvas
LayerObject * Canvas
A pointer to the drawing canvas of the tool, work on this.
Definition: IntelliTool.h:79
IntelliToolRectangle.h
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:17
PaintingArea.h
IntelliTool::ActiveType
Tooltype ActiveType
ActiveType the type of the active tool.
Definition: IntelliTool.h:59
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:14
IntelliTool::Tooltype::RECTANGLE
@ RECTANGLE
LayerObject::image
IntelliImage * image
image - Stores the imageData of the current LayerObject.
Definition: PaintingArea.h:27
IntelliToolsettings::setLineWidth
void setLineWidth(int LineWidth)
setLineWidth sets the width attribute of the line.
Definition: IntelliToolsettings.cpp: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:48
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:53
IntelliToolsettings
The IntelliToolsettings class managing the settings of the tools, independent of an existing tool.
Definition: IntelliToolsettings.h:9
IntelliImage::drawPlain
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.
Definition: IntelliImage.cpp:117
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