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 
7  : IntelliTool(Area, colorPicker, Toolsettings){
9 }
10 
13 }
14 
17 }
18 
21 }
22 
25  this->lineStartingPoint=QPoint(x,y);
26  this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
28 }
29 
32 }
33 
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  switch(Toolsettings->getLinestyle()) {
45  this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),Toolsettings->getLineWidth());
46  break;
48  QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next;
49  QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint;
50  int m = static_cast<int>(static_cast<float>(p2.y()-p1.y())/static_cast<float>(p2.x()-p1.x())+0.5f);
51  int c = lineStartingPoint.y()-lineStartingPoint.x()*m;
52 
53  break;
54  }
55  }
57 }
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
IntelliToolLine::IntelliToolLine
IntelliToolLine(PaintingArea *Area, IntelliColorPicker *colorPicker, IntelliToolsettings *Toolsettings)
A constructor setting the general paintingArea and colorPicker. And reading in the lineWidth and line...
Definition: IntelliToolLine.cpp:6
IntelliToolsettings::setLineWidth
void setLineWidth()
Definition: IntelliToolsettings.cpp:19
IntelliToolsettings::getLinestyle
LineStyle getLinestyle()
Definition: IntelliToolsettings.cpp:51
IntelliToolsettings::LineStyle::SOLID_LINE
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:37
IntelliTool::isDrawing
bool isDrawing
A flag checking if the user is currently drawing or not.
Definition: IntelliTool.h:68
IntelliToolsettings::LineStyle::DOTTED_LINE
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.
Definition: IntelliImage.cpp:72
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:22
IntelliTool::Canvas
LayerObject * Canvas
A pointer to the drawing canvas of the tool, work on this.
Definition: IntelliTool.h:63
IntelliTool
An abstract class that manages the basic events, like mouse clicks or scrolls events.
Definition: IntelliTool.h:14
PaintingArea.h
IntelliColorPicker::getFirstColor
QColor getFirstColor()
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:16
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
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
IntelliToolsettings::getLineWidth
int getLineWidth()
Definition: IntelliToolsettings.cpp:15
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
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
IntelliImage::drawPlain
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.
Definition: IntelliImage.cpp:105