IntelliPhoto 0.5

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)
7 : IntelliTool(Area, colorPicker){
8 this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
9 //create checkbox or scroll dialog to get line style
10 this->lineStyle = LineStyle::SOLID_LINE;
11 }
12
13 IntelliToolLine::~IntelliToolLine(){
14
15 }
16
17 void IntelliToolLine::onMouseRightPressed(int x, int y){
18 IntelliTool::onMouseRightPressed(x,y);
19 }
20
21 void IntelliToolLine::onMouseRightReleased(int x, int y){
22 IntelliTool::onMouseRightReleased(x,y);
23 }
24
25 void IntelliToolLine::onMouseLeftPressed(int x, int y){
26 IntelliTool::onMouseLeftPressed(x,y);
27 this->start=QPoint(x,y);
28 this->Canvas->image->drawPoint(start, colorPicker->getFirstColor(),lineWidth);
29 Canvas->image->calculateVisiblity();
30 }
31
32 void IntelliToolLine::onMouseLeftReleased(int x, int y){
33 IntelliTool::onMouseLeftReleased(x,y);
34 }
35
36 void IntelliToolLine::onWheelScrolled(int value){
37 IntelliTool::onWheelScrolled(value);
38 this->lineWidth+=value;
39 if(this->lineWidth<=0) {
40 this->lineWidth=1;
41 }
42 }
43
44 void IntelliToolLine::onMouseMoved(int x, int y){
45 if(this->drawing) {
46 this->Canvas->image->drawPlain(Qt::transparent);
47 QPoint next(x,y);
48 switch(lineStyle) {
49 case LineStyle::SOLID_LINE:
50 this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
51 break;
52 case LineStyle::DOTTED_LINE:
53 QPoint p1 =start.x() <= next.x() ? start : next;
54 QPoint p2 =start.x() < next.x() ? next : start;
55 int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f;
56 int c = start.y()-start.x()*m;
57
58 break;
59 }
60 }
61 IntelliTool::onMouseMoved(x,y);
62 }
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
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
LineStyle::SOLID_LINE
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
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:44
IntelliToolLine::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event. Changing the lineWidth relative to value.
Definition: IntelliToolLine.cpp:36
IntelliToolLine::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click released of a mouse.
Definition: IntelliToolLine.cpp:21
IntelliToolLine::IntelliToolLine
IntelliToolLine(PaintingArea *Area, IntelliColorPicker *colorPicker)
A constructor setting the general paintingArea and colorPicker. And reading in the lineWidth and line...
Definition: IntelliToolLine.cpp:6
LineStyle::DOTTED_LINE
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:36
IntelliToolLine.h
IntelliToolLine::~IntelliToolLine
virtual ~IntelliToolLine() override
An abstract Destructor.
Definition: IntelliToolLine.cpp:13
IntelliImage::drawPoint
virtual void drawPoint(const QPoint &p1, const QColor &color, const int &penWidth)
A.
Definition: IntelliImage.cpp:55
IntelliToolLine::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click released of a mouse.
Definition: IntelliToolLine.cpp:32
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:17
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
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
IntelliColorPicker
The IntelliColorPicker manages the selected colors for one whole project.
Definition: IntelliColorPicker.h:11
LayerObject::image
IntelliImage * image
Definition: PaintingArea.h:25
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: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
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:46
IntelliImage::drawPlain
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.
Definition: IntelliImage.cpp:76