IntelliPhoto  0.4
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 
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 
14 
15 }
16 
17 
20 }
21 
24 }
25 
28  this->start=QPoint(x,y);
29  this->Canvas->image->drawLine(start, start, colorPicker->getFirstColor(),lineWidth);
31 }
32 
35 }
36 
39  this->lineWidth+=value;
40  if(this->lineWidth<=0){
41  this->lineWidth=1;
42  }
43 }
44 
45 void IntelliToolLine::onMouseMoved(int x, int y){
46  if(this->drawing){
47  this->Canvas->image->drawPlain(Qt::transparent);
48  QPoint next(x,y);
49  switch(lineStyle){
51  this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
52  break;
54  QPoint p1 =start.x() <= next.x() ? start : next;
55  QPoint p2 =start.x() < next.x() ? next : start;
56  int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f;
57  int c = start.y()-start.x()*m;
58 
59  break;
60  }
61  }
63 }
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. Call this in child classes!
Definition: IntelliToolLine.cpp:45
IntelliToolLine::onWheelScrolled
virtual void onWheelScrolled(int value) override
A function managing the scroll event. A Positive Value means scrolling outwards. Call this in child c...
Definition: IntelliToolLine.cpp:37
IntelliToolLine::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y) override
A function managing the right click Released of a Mouse. Merging the Canvas to Active....
Definition: IntelliToolLine.cpp:22
IntelliToolLine::IntelliToolLine
IntelliToolLine(PaintingArea *Area, IntelliColorPicker *colorPicker)
Definition: IntelliToolLine.cpp:6
LineStyle::DOTTED_LINE
PaintingArea
Definition: PaintingArea.h:26
IntelliToolLine.h
IntelliToolLine::~IntelliToolLine
virtual ~IntelliToolLine() override
Definition: IntelliToolLine.cpp:13
IntelliToolLine::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y) override
A function managing the left click Released of a Mouse. Call this in child classes!
Definition: IntelliToolLine.cpp:33
IntelliToolLine::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y) override
A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on....
Definition: IntelliToolLine.cpp:18
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:18
IntelliToolLine::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y) override
A function managing the left click Pressed of a Mouse. Resetting the current draw....
Definition: IntelliToolLine.cpp:26
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:77