This commit is contained in:
AshBastian
2020-01-07 15:23:14 +01:00
parent 8efe6836bf
commit 28b8d92d72
13 changed files with 88 additions and 18 deletions

View File

@@ -79,3 +79,11 @@ void IntelliTool::deleteToolLayer(){
Area->deleteLayer(Area->activeLayer+1);
this->Canvas=nullptr;
}
IntelliTool::Tooltype IntelliTool::getTooltype(){
return ActiveType;
}
bool IntelliTool::getIsDrawing(){
return isDrawing;
}

View File

@@ -11,6 +11,16 @@ class PaintingArea;
* \brief An abstract class that manages the basic events, like mouse clicks or scrolls events.
*/
class IntelliTool {
public:
enum class Tooltype{
CIRCLE,
FLOODFILL,
LINE,
PEN,
PLAIN,
POLYGON,
RECTANGLE
};
private:
/*!
* \brief A function that creates a layer to draw on.
@@ -32,6 +42,8 @@ protected:
*/
PaintingArea* Area;
Tooltype ActiveType;
/*!
* \brief A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors.
*/
@@ -106,6 +118,9 @@ virtual void onWheelScrolled(int value);
*/
virtual void onMouseMoved(int x, int y);
Tooltype getTooltype();
bool getIsDrawing();
};
#endif

View File

@@ -7,10 +7,11 @@ IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* col
: IntelliTool(Area, colorPicker){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::CIRCLE;
}
IntelliToolCircle::~IntelliToolCircle(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolCircle::drawCircle(int radius){

View File

@@ -7,10 +7,11 @@
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker)
: IntelliTool(Area, colorPicker){
this->ActiveType = Tooltype::FLOODFILL;
}
IntelliToolFloodFill::~IntelliToolFloodFill(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolFloodFill::onMouseRightPressed(int x, int y){

View File

@@ -6,12 +6,13 @@
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker)
: IntelliTool(Area, colorPicker){
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
this->ActiveType = Tooltype::LINE;
//create checkbox or scroll dialog to get line style
this->lineStyle = LineStyle::SOLID_LINE;
}
IntelliToolLine::~IntelliToolLine(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolLine::onMouseRightPressed(int x, int y){

View File

@@ -7,10 +7,11 @@
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker)
: IntelliTool(Area, colorPicker){
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
this->ActiveType = Tooltype::PEN;
}
IntelliToolPen::~IntelliToolPen(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolPen::onMouseRightPressed(int x, int y){

View File

@@ -4,6 +4,7 @@
#include "IntelliTool.h"
#include "QColor"
#include "QPoint"
/*!
* \brief The IntelliToolPen class represents a tool to draw a line.
*/

View File

@@ -4,10 +4,11 @@
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker)
: IntelliTool(Area, colorPicker){
this->ActiveType = Tooltype::PLAIN;
}
IntelliToolPlainTool::~IntelliToolPlainTool(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){

View File

@@ -7,13 +7,16 @@
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker)
: IntelliTool(Area, colorPicker){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
isPointNearStart = false;
isDrawing = false;
this->ActiveType = Tooltype::POLYGON;
}
IntelliToolPolygon::~IntelliToolPolygon(){
if(isDrawing){
IntelliTool::onMouseRightPressed(0,0);
}
}
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
@@ -28,9 +31,17 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
this->Canvas->image->calculateVisiblity();
}
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
this->Canvas->image->calculateVisiblity();
if(QPointList.size() > 2){
isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
this->Canvas->image->calculateVisiblity();
}
else{
isDrawing = false;
QPointList.clear();
IntelliTool::onMouseRightPressed(x,y);
}
}
else if(isDrawing) {
QPoint drawingPoint(x,y);
@@ -48,7 +59,7 @@ void IntelliToolPolygon::onMouseRightPressed(int x, int y){
}
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
if(isPointNearStart && QPointList.size() > 1) {
if(isPointNearStart) {
isPointNearStart = false;
isDrawing = false;
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList);

View File

@@ -6,10 +6,11 @@ IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicke
: IntelliTool(Area, colorPicker){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::RECTANGLE;
}
IntelliToolRectangle::~IntelliToolRectangle(){
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolRectangle::drawRectangle(QPoint otherCorner){