mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 03:40:31 +02:00
Updated it works kinda
TOdo: fix BUGS
This commit is contained in:
@@ -4,11 +4,12 @@
|
||||
#include <QInputDialog>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
|
||||
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings, bool isSettingPolygon)
|
||||
: IntelliTool(Area, colorPicker, Toolsettings){
|
||||
isPointNearStart = false;
|
||||
isDrawing = false;
|
||||
isInside = false;
|
||||
this->isSettingPolygon = isSettingPolygon;
|
||||
this->ActiveType = Tooltype::POLYGON;
|
||||
}
|
||||
|
||||
@@ -19,10 +20,13 @@ IntelliToolPolygon::~IntelliToolPolygon(){
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
||||
QPoint Point(x,y);
|
||||
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
|
||||
if(isSettingPolygon){
|
||||
isInside = true;
|
||||
}
|
||||
}
|
||||
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
isInside = true;
|
||||
@@ -36,14 +40,18 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
QPointList.push_back(drawingPoint);
|
||||
|
||||
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
if(!isSettingPolygon){
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
|
||||
if(QPointList.size() > 2) {
|
||||
isPointNearStart = true;
|
||||
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
if(!isSettingPolygon){
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
else{
|
||||
isInside = false;
|
||||
isDrawing = false;
|
||||
@@ -56,7 +64,9 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
QPoint drawingPoint(x,y);
|
||||
QPointList.push_back(drawingPoint);
|
||||
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
if(!isSettingPolygon){
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +83,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||
isInside = false;
|
||||
isPointNearStart = false;
|
||||
isDrawing = false;
|
||||
if(false){
|
||||
if(!isSettingPolygon){
|
||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
|
||||
QPoint Point;
|
||||
QColor colorTwo(colorPicker->getSecondColor());
|
||||
@@ -94,6 +104,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||
}
|
||||
else{
|
||||
Canvas->image->setPolygon(QPointList);
|
||||
Canvas->image->setImageData(Area->getImageDataOfActiveLayer());
|
||||
}
|
||||
IntelliTool::onMouseLeftReleased(x,y);
|
||||
QPointList.clear();
|
||||
|
||||
Reference in New Issue
Block a user