IntelliPhoto 0.7

IntelliToolLine.cpp
Go to the documentation of this file.
1 #include "IntelliToolLine.h"
2 #include "Layer/PaintingArea.h"
3 #include "QColorDialog"
4 #include "QInputDialog"
5
6 IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
7 : IntelliTool(Area, colorPicker, Toolsettings){
8 this->ActiveType = Tooltype::LINE;
9 }
10
11 IntelliToolLine::~IntelliToolLine(){
12 IntelliTool::onMouseRightPressed(0,0);
13 }
14
15 void IntelliToolLine::onMouseRightPressed(int x, int y){
16 IntelliTool::onMouseRightPressed(x,y);
17 }
18
19 void IntelliToolLine::onMouseRightReleased(int x, int y){
20 IntelliTool::onMouseRightReleased(x,y);
21 }
22
23 void IntelliToolLine::onMouseLeftPressed(int x, int y){
24 IntelliTool::onMouseLeftPressed(x,y);
25 this->lineStartingPoint = QPoint(x,y);
26 this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
27 Canvas->image->calculateVisiblity();
28 }
29
30 void IntelliToolLine::onMouseLeftReleased(int x, int y){
31 IntelliTool::onMouseLeftReleased(x,y);
32 }
33
34 void IntelliToolLine::onWheelScrolled(int value){
35 IntelliTool::onWheelScrolled(value);
36 Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
37 }
38
39 void IntelliToolLine::onMouseMoved(int x, int y){
40 if(this->isDrawing) {
41 this->Canvas->image->drawPlain(Qt::transparent);
42 QPoint next(x,y);
43 this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),Toolsettings->getLineWidth());
44 }
45 IntelliTool::onMouseMoved(x,y);
46 }
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
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
IntelliToolLine::IntelliToolLine
IntelliToolLine(PaintingArea *Area, IntelliColorPicker *colorPicker, IntelliToolsettings *Toolsettings)
A constructor setting the general paintingArea and colorPicker.
Definition: IntelliToolLine.cpp:6
IntelliToolLine::onMouseMoved
virtual void onMouseMoved(int x, int y) override
A function managing the mouse moved event. Drawing a Line from the startpoint to the current mouse po...
Definition: IntelliToolLine.cpp:39
IntelliToolLine::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event. Changing the lineWidth relative to value.
Definition: IntelliToolLine.cpp:34
IntelliToolLine::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click released of a mouse.
Definition: IntelliToolLine.cpp:19
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
IntelliToolLine.h
IntelliToolLine::~IntelliToolLine
virtual ~IntelliToolLine() override
An abstract Destructor.
Definition: IntelliToolLine.cpp:11
IntelliImage::drawPoint
virtual void drawPoint(const QPoint &p1, const QColor &color, const int &penWidth)
A function that draws a point between on a given point in a given color.
Definition: IntelliImage.cpp:78
IntelliToolLine::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click released of a mouse.
Definition: IntelliToolLine.cpp:30
IntelliToolLine::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y) override
A function managing the right click pressed of a mouse. Clearing the canvas.
Definition: IntelliToolLine.cpp:15
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
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
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:14
LayerObject::image
IntelliImage * image
image - Stores the imageData of the current LayerObject.
Definition: PaintingArea.h:27
IntelliToolLine::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click pressed of a mouse. Sets the starting point of the line.
Definition: IntelliToolLine.cpp:23
IntelliTool::Tooltype::LINE
@ LINE
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:47
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:52
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