ToolSettings

This commit is contained in:
AshBastian
2020-01-08 15:47:16 +01:00
parent dd55a7158d
commit 52a72c05c5
26 changed files with 111 additions and 77 deletions

View File

@@ -8,7 +8,7 @@
#include <QWidget> #include <QWidget>
#include <vector> #include <vector>
#include "IntelliHelper/IntelliHelper.h" #include "IntelliHelper/IntelliTriangulation.h"
class IntelliTool; class IntelliTool;

View File

@@ -1,5 +1,5 @@
#include "Image/IntelliShapedImage.h" #include "Image/IntelliShapedImage.h"
#include "IntelliHelper/IntelliHelper.h" #include "IntelliHelper/IntelliTriangulation.h"
#include <QPainter> #include <QPainter>
#include <QRect> #include <QRect>
#include <QDebug> #include <QDebug>
@@ -42,7 +42,7 @@ void IntelliShapedImage::calculateVisiblity(){
for(int x=0; x<imageData.width(); x++) { for(int x=0; x<imageData.width(); x++) {
QPoint ptr(x,y); QPoint ptr(x,y);
clr = imageData.pixelColor(x,y); clr = imageData.pixelColor(x,y);
bool isInPolygon = IntelliHelper::isInPolygon(triangles, ptr); bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
if(isInPolygon) { if(isInPolygon) {
clr.setAlpha(std::min(255, clr.alpha())); clr.setAlpha(std::min(255, clr.alpha()));
}else{ }else{
@@ -73,7 +73,7 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
for(auto element:polygonData) { for(auto element:polygonData) {
this->polygonData.push_back(QPoint(element.x(), element.y())); this->polygonData.push_back(QPoint(element.x(), element.y()));
} }
triangles = IntelliHelper::calculateTriangles(polygonData); triangles = IntelliTriangulation::calculateTriangles(polygonData);
} }
calculateVisiblity(); calculateVisiblity();
return; return;

View File

@@ -0,0 +1,19 @@
#include "IntelliToolsettings.h"
IntelliToolsettings::IntelliToolsettings()
{
lineWidth = 1;
innerAlpha = 255;
}
int IntelliToolsettings::getLineWidth(){
return lineWidth;
}
int IntelliToolsettings::getInnerAlpha(){
return innerAlpha;
}
IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){
return Linestyle;
}

View File

@@ -0,0 +1,24 @@
#ifndef INTELLITOOLSETTINGS_H
#define INTELLITOOLSETTINGS_H
class IntelliToolsettings {
public:
/*!
* \brief The LineStyle enum classifing all ways of drawing a line.
*/
enum class LineStyle {
SOLID_LINE,
DOTTED_LINE
};
IntelliToolsettings();
int getLineWidth();
int getInnerAlpha();
LineStyle getLinestyle();
private:
int lineWidth;
int innerAlpha;
LineStyle Linestyle;
};
#endif // INTELLITOOLSETTINGS_H

View File

@@ -1,10 +1,10 @@
#include "IntelliHelper.h" #include "IntelliTriangulation.h"
#include <algorithm> #include <algorithm>
#include <queue> #include <queue>
#include <cmath> #include <cmath>
#define pi 3.1415926535897932384626433832795 #define pi 3.1415926535897932384626433832795
std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> polyPoints){ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoint> polyPoints){
// helper for managing the triangle vertices and their state // helper for managing the triangle vertices and their state
struct TriangleHelper { struct TriangleHelper {
QPoint vertex; QPoint vertex;
@@ -113,9 +113,9 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
return Triangles; return Triangles;
} }
bool IntelliHelper::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){ bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
for(auto triangle : triangles) { for(auto triangle : triangles) {
if(IntelliHelper::isInTriangle(triangle, point)) { if(IntelliTriangulation::isInTriangle(triangle, point)) {
return true; return true;
} }
} }

View File

@@ -1,5 +1,5 @@
#ifndef INTELLIHELPER_H #ifndef INTELLITRIANGULATION_H
#define INTELLIHELPER_H #define INTELLITRIANGULATION_H
#include <QPoint> #include <QPoint>
#include <vector> #include <vector>
@@ -11,7 +11,7 @@ struct Triangle {
QPoint A,B,C; QPoint A,B,C;
}; };
namespace IntelliHelper { namespace IntelliTriangulation {
/*! /*!
* \brief A function to get the 2*area of a traingle, using its determinat. * \brief A function to get the 2*area of a traingle, using its determinat.
@@ -34,9 +34,9 @@ inline bool isInTriangle(Triangle& tri, QPoint& P){
float val1, val2, val3; float val1, val2, val3;
bool neg, pos; bool neg, pos;
val1 = IntelliHelper::sign(P,tri.A,tri.B); val1 = IntelliTriangulation::sign(P,tri.A,tri.B);
val2 = IntelliHelper::sign(P,tri.B,tri.C); val2 = IntelliTriangulation::sign(P,tri.B,tri.C);
val3 = IntelliHelper::sign(P,tri.C,tri.A); val3 = IntelliTriangulation::sign(P,tri.C,tri.A);
neg = (val1<0.f) || (val2<0.f) || (val3<0.f); neg = (val1<0.f) || (val2<0.f) || (val3<0.f);
pos = (val1>0.f) || (val2>0.f) || (val3>0.f); pos = (val1>0.f) || (val2>0.f) || (val3>0.f);

View File

@@ -21,7 +21,8 @@ SOURCES += \
Image/IntelliRasterImage.cpp \ Image/IntelliRasterImage.cpp \
Image/IntelliShapedImage.cpp \ Image/IntelliShapedImage.cpp \
IntelliHelper/IntelliColorPicker.cpp \ IntelliHelper/IntelliColorPicker.cpp \
IntelliHelper/IntelliHelper.cpp \ IntelliHelper/IntelliToolsettings.cpp \
IntelliHelper/IntelliTriangulation.cpp \
Layer/PaintingArea.cpp \ Layer/PaintingArea.cpp \
Tool/IntelliTool.cpp \ Tool/IntelliTool.cpp \
Tool/IntelliToolCircle.cpp \ Tool/IntelliToolCircle.cpp \
@@ -39,7 +40,8 @@ HEADERS += \
Image/IntelliRasterImage.h \ Image/IntelliRasterImage.h \
Image/IntelliShapedImage.h \ Image/IntelliShapedImage.h \
IntelliHelper/IntelliColorPicker.h \ IntelliHelper/IntelliColorPicker.h \
IntelliHelper/IntelliHelper.h \ IntelliHelper/IntelliToolsettings.h \
IntelliHelper/IntelliTriangulation.h \
Layer/PaintingArea.h \ Layer/PaintingArea.h \
Tool/IntelliTool.h \ Tool/IntelliTool.h \
Tool/IntelliToolCircle.h \ Tool/IntelliToolCircle.h \

View File

@@ -194,36 +194,36 @@ void PaintingArea::colorPickerSwapColors(){
void PaintingArea::createPenTool(){ void PaintingArea::createPenTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolPen(this, &colorPicker); Tool = new IntelliToolPen(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createPlainTool(){ void PaintingArea::createPlainTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolPlainTool(this, &colorPicker); Tool = new IntelliToolPlainTool(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createLineTool(){ void PaintingArea::createLineTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolLine(this, &colorPicker); Tool = new IntelliToolLine(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createRectangleTool(){ void PaintingArea::createRectangleTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolRectangle(this, &colorPicker); Tool = new IntelliToolRectangle(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createCircleTool(){ void PaintingArea::createCircleTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolCircle(this, &colorPicker); Tool = new IntelliToolCircle(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createPolygonTool(){ void PaintingArea::createPolygonTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolPolygon(this, &colorPicker); Tool = new IntelliToolPolygon(this, &colorPicker, &Toolsettings);
} }
void PaintingArea::createFloodFillTool(){ void PaintingArea::createFloodFillTool(){
delete this->Tool; delete this->Tool;
Tool = new IntelliToolFloodFill(this, &colorPicker); Tool = new IntelliToolFloodFill(this, &colorPicker, &Toolsettings);
} }
int PaintingArea::getWidthOfActive(){ int PaintingArea::getWidthOfActive(){
@@ -381,13 +381,13 @@ void PaintingArea::createTempTopLayer(int idx){
IntelliTool* PaintingArea::copyActiveTool(){ IntelliTool* PaintingArea::copyActiveTool(){
switch(Tool->getTooltype()){ switch(Tool->getTooltype()){
case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(this,&colorPicker); case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::FLOODFILL: return new IntelliToolFloodFill(this,&colorPicker); case IntelliTool::Tooltype::FLOODFILL: return new IntelliToolFloodFill(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::LINE: return new IntelliToolLine(this,&colorPicker); case IntelliTool::Tooltype::LINE: return new IntelliToolLine(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::PEN: return new IntelliToolPen(this,&colorPicker); case IntelliTool::Tooltype::PEN: return new IntelliToolPen(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::PLAIN: return new IntelliToolPlainTool(this,&colorPicker); case IntelliTool::Tooltype::PLAIN: return new IntelliToolPlainTool(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::POLYGON: return new IntelliToolPolygon(this,&colorPicker); case IntelliTool::Tooltype::POLYGON: return new IntelliToolPolygon(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::RECTANGLE: return new IntelliToolRectangle(this,&colorPicker); case IntelliTool::Tooltype::RECTANGLE: return new IntelliToolRectangle(this,&colorPicker, &Toolsettings);
default: return nullptr; default: return nullptr;
} }
} }

View File

@@ -202,6 +202,7 @@ private:
IntelliTool* Tool; IntelliTool* Tool;
IntelliColorPicker colorPicker; IntelliColorPicker colorPicker;
IntelliToolsettings Toolsettings;
std::vector<LayerObject> layerBundle; std::vector<LayerObject> layerBundle;
int activeLayer=-1; int activeLayer=-1;

View File

@@ -1,9 +1,10 @@
#include "IntelliTool.h" #include "IntelliTool.h"
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
this->Area=Area; this->Area=Area;
this->colorPicker=colorPicker; this->colorPicker=colorPicker;
this->Toolsettings=Toolsettings;
} }

View File

@@ -2,6 +2,7 @@
#define Intelli_Tool_H #define Intelli_Tool_H
#include "IntelliHelper/IntelliColorPicker.h" #include "IntelliHelper/IntelliColorPicker.h"
#include "IntelliHelper/IntelliToolsettings.h"
#include <vector> #include <vector>
struct LayerObject; struct LayerObject;
@@ -49,6 +50,8 @@ Tooltype ActiveType;
*/ */
IntelliColorPicker* colorPicker; IntelliColorPicker* colorPicker;
IntelliToolsettings* Toolsettings;
/*! /*!
* \brief A pointer to the underlying active Layer, do not work on this. This is used for data grabbing or previews. * \brief A pointer to the underlying active Layer, do not work on this. This is used for data grabbing or previews.
*/ */
@@ -70,7 +73,7 @@ public:
* \param Area - The general PaintingArea used by the project. * \param Area - The general PaintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief An abstract Destructor. * \brief An abstract Destructor.

View File

@@ -3,8 +3,8 @@
#include "QInputDialog" #include "QInputDialog"
#include <cmath> #include <cmath>
IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); 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->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::CIRCLE; this->ActiveType = Tooltype::CIRCLE;

View File

@@ -34,7 +34,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.

View File

@@ -5,8 +5,8 @@
#include <functional> #include <functional>
#include <queue> #include <queue>
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::FLOODFILL; this->ActiveType = Tooltype::FLOODFILL;
} }

View File

@@ -14,7 +14,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.

View File

@@ -3,12 +3,10 @@
#include "QColorDialog" #include "QColorDialog"
#include "QInputDialog" #include "QInputDialog"
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
this->ActiveType = Tooltype::LINE; this->ActiveType = Tooltype::LINE;
//create checkbox or scroll dialog to get line style
this->lineStyle = LineStyle::SOLID_LINE;
} }
IntelliToolLine::~IntelliToolLine(){ IntelliToolLine::~IntelliToolLine(){
@@ -46,11 +44,11 @@ void IntelliToolLine::onMouseMoved(int x, int y){
if(this->isDrawing) { if(this->isDrawing) {
this->Canvas->image->drawPlain(Qt::transparent); this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y); QPoint next(x,y);
switch(lineStyle) { switch(Toolsettings->getLinestyle()) {
case LineStyle::SOLID_LINE: case IntelliToolsettings::LineStyle::SOLID_LINE:
this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),lineWidth); this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),lineWidth);
break; break;
case LineStyle::DOTTED_LINE: case IntelliToolsettings::LineStyle::DOTTED_LINE:
QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next; QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next;
QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint; QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint;
int m = static_cast<int>(static_cast<float>(p2.y()-p1.y())/static_cast<float>(p2.x()-p1.x())+0.5f); int m = static_cast<int>(static_cast<float>(p2.y()-p1.y())/static_cast<float>(p2.x()-p1.x())+0.5f);

View File

@@ -4,14 +4,6 @@
#include "QPoint" #include "QPoint"
/*!
* \brief The LineStyle enum classifing all ways of drawing a line.
*/
enum class LineStyle {
SOLID_LINE,
DOTTED_LINE
};
/*! /*!
* \brief The IntelliToolFloodFill class represents a tool to draw a line. * \brief The IntelliToolFloodFill class represents a tool to draw a line.
*/ */
@@ -25,11 +17,6 @@ QPoint lineStartingPoint;
* \brief The width of the line to draw. * \brief The width of the line to draw.
*/ */
int lineWidth; int lineWidth;
/*!
* \brief The style of the line. Apropriate to LineStyle.
*/
LineStyle lineStyle;
public: public:
/*! /*!
@@ -37,7 +24,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief An abstract Destructor. * \brief An abstract Destructor.

View File

@@ -4,8 +4,8 @@
#include "QColorDialog" #include "QColorDialog"
#include "QInputDialog" #include "QInputDialog"
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1); this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
this->ActiveType = Tooltype::PEN; this->ActiveType = Tooltype::PEN;
} }

View File

@@ -23,7 +23,7 @@ public:
* \param Area - The general PaintingArea used by the project. * \param Area - The general PaintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */

View File

@@ -2,8 +2,8 @@
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
#include "QColorDialog" #include "QColorDialog"
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::PLAIN; this->ActiveType = Tooltype::PLAIN;
} }

View File

@@ -13,7 +13,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPlainTool(PaintingArea*Area, IntelliColorPicker* colorPicker); IntelliToolPlainTool(PaintingArea*Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */

View File

@@ -4,8 +4,8 @@
#include <QInputDialog> #include <QInputDialog>
#include <QDebug> #include <QDebug>
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 255,0,255,1); this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 255,0,255,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",5,1,10,1); lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",5,1,10,1);
isPointNearStart = false; isPointNearStart = false;
@@ -22,9 +22,9 @@ IntelliToolPolygon::~IntelliToolPolygon(){
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Shaped_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){ if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Shaped_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(Area->getPolygonDataOfRealLayer()); std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
QPoint Point(x,y); QPoint Point(x,y);
isInside = IntelliHelper::isInPolygon(Triangles,Point); isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
} }
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Raster_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){ else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Raster_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){
isInside = true; isInside = true;
@@ -75,14 +75,14 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
isInside = false; isInside = false;
isPointNearStart = false; isPointNearStart = false;
isDrawing = false; isDrawing = false;
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList); std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
QPoint Point; QPoint Point;
QColor colorTwo(colorPicker->getSecondColor()); QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(innerAlpha); colorTwo.setAlpha(innerAlpha);
for(int i = 0; i < activeLayer->width; i++) { for(int i = 0; i < activeLayer->width; i++) {
for(int j = 0; j < activeLayer->height; j++) { for(int j = 0; j < activeLayer->height; j++) {
Point = QPoint(i,j); Point = QPoint(i,j);
if(IntelliHelper::isInPolygon(Triangles,Point)) { if(IntelliTriangulation::isInPolygon(Triangles,Point)) {
this->Canvas->image->drawPixel(Point, colorTwo); this->Canvas->image->drawPixel(Point, colorTwo);
} }
} }

View File

@@ -2,7 +2,7 @@
#define INTELLITOOLPOLYGON_H #define INTELLITOOLPOLYGON_H
#include "IntelliTool.h" #include "IntelliTool.h"
#include "IntelliHelper/IntelliHelper.h" #include "IntelliHelper/IntelliTriangulation.h"
#include <vector> #include <vector>
#include <QPoint> #include <QPoint>
/*! /*!
@@ -54,7 +54,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */

View File

@@ -2,8 +2,8 @@
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
#include "QInputDialog" #include "QInputDialog"
IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); 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->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::RECTANGLE; this->ActiveType = Tooltype::RECTANGLE;

View File

@@ -33,7 +33,7 @@ public:
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */

View File

@@ -1,7 +1,6 @@
#include "GUI/IntelliPhotoGui.h" #include "GUI/IntelliPhotoGui.h"
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include "IntelliHelper/IntelliHelper.h"
#include <vector> #include <vector>
int main(int argc, char*argv[]){ int main(int argc, char*argv[]){