IntelliPhoto 0.5

IntelliToolPen.cpp
Go to the documentation of this file.
1 #include "IntelliToolPen.h"
2 #include "Layer/PaintingArea.h"
3 #include "QDebug"
4 #include "QColorDialog"
5 #include "QInputDialog"
6
7 IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
8 : IntelliTool(Area, colorPicker, Toolsettings){
9 this->ActiveType = Tooltype::PEN;
10 }
11
12 IntelliToolPen::~IntelliToolPen(){
13 IntelliTool::onMouseRightPressed(0,0);
14 }
15
16 void IntelliToolPen::onMouseRightPressed(int x, int y){
17 IntelliTool::onMouseRightPressed(x,y);
18 }
19
20 void IntelliToolPen::onMouseRightReleased(int x, int y){
21 IntelliTool::onMouseRightReleased(x,y);
22 }
23
24 void IntelliToolPen::onMouseLeftPressed(int x, int y){
25 IntelliTool::onMouseLeftPressed(x,y);
26 this->previousPoint=QPoint(x,y);
27 this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
28 Canvas->image->calculateVisiblity();
29 }
30
31 void IntelliToolPen::onMouseLeftReleased(int x, int y){
32 IntelliTool::onMouseLeftReleased(x,y);
33 }
34
35 void IntelliToolPen::onMouseMoved(int x, int y){
36 if(this->isDrawing) {
37 QPoint newPoint(x,y);
38 this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
39 this->previousPoint=newPoint;
40 }
41 IntelliTool::onMouseMoved(x,y);
42 }
43
44 void IntelliToolPen::onWheelScrolled(int value){
45 IntelliTool::onWheelScrolled(value);
46 Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
47 }
IntelliTool::Tooltype::PEN
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
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
IntelliToolPen::~IntelliToolPen
virtual ~IntelliToolPen() override
A Destructor.
Definition: IntelliToolPen.cpp:12
IntelliToolPen::onMouseMoved
virtual void onMouseMoved(int x, int y) override
A function managing the mouse moved event. To draw the line.
Definition: IntelliToolPen.cpp:35
IntelliToolPen::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y) override
A function managing the right click pressed of a mouse. Resetting the current draw.
Definition: IntelliToolPen.cpp:16
IntelliToolPen::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click released of a mouse.
Definition: IntelliToolPen.cpp:20
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
IntelliImage::drawPoint
virtual void drawPoint(const QPoint &p1, const QColor &color, const int &penWidth)
A.
Definition: IntelliImage.cpp:72
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
IntelliToolPen::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event. Changing penWidth relativ to value.
Definition: IntelliToolPen.cpp:44
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:14
IntelliToolPen::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click released of a mouse. Merging the drawing to the active layer.
Definition: IntelliToolPen.cpp:31
PaintingArea.h
IntelliColorPicker::getFirstColor
QColor getFirstColor()
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:16
IntelliToolPen::IntelliToolPen
IntelliToolPen(PaintingArea *Area, IntelliColorPicker *colorPicker, IntelliToolsettings *Toolsettings)
A constructor setting the general paintingArea and colorPicker. Reading the penWidth.
Definition: IntelliToolPen.cpp:7
IntelliTool::ActiveType
Tooltype ActiveType
Definition: IntelliTool.h:46
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:26
IntelliToolsettings::getLineWidth
int getLineWidth()
Definition: IntelliToolsettings.cpp:15
IntelliToolPen.h
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
IntelliToolPen::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click pressed of a mouse. Starting the drawing procedure.
Definition: IntelliToolPen.cpp:24
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:47
IntelliToolsettings
Definition: IntelliToolsettings.h:4