mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Tool anpassungen
This commit is contained in:
@@ -2,43 +2,36 @@
|
||||
#include "Layer/PaintingArea.h"
|
||||
#include <QDebug>
|
||||
#include <QCursor>
|
||||
#include <QInputDialog>
|
||||
|
||||
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
lineWidth = 5;
|
||||
isDrawing = false;
|
||||
this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
|
||||
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);;
|
||||
PointIsNearStart = false;
|
||||
drawingPoint.setX(0);
|
||||
drawingPoint.setY(0);
|
||||
Point.setX(0);
|
||||
Point.setY(0);
|
||||
isDrawing = false;
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
if(!isDrawing){
|
||||
width = Area->getWidthActiveLayer();
|
||||
height = Area->getHeightActiveLayer();
|
||||
}
|
||||
if(!isDrawing && x > 0 && y > 0 && x < width && y < height){
|
||||
isDrawing = true;
|
||||
drawingPoint.setX(x);
|
||||
drawingPoint.setY(y);
|
||||
QPointList.push_back(drawingPoint);
|
||||
if(!isDrawing && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->Canvas->image->drawPlain(Qt::transparent);
|
||||
QPoint drawingPoint = QPoint(x,y);
|
||||
|
||||
isDrawing = true;
|
||||
QPointList.push_back(drawingPoint);
|
||||
|
||||
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
else if(isDrawing && isNearStart(x,y,QPointList.front())){
|
||||
PointIsNearStart = isNearStart(x,y,QPointList.front());
|
||||
PointIsNearStart = true;
|
||||
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
else if(isDrawing){
|
||||
drawingPoint.setX(x);
|
||||
drawingPoint.setY(y);
|
||||
QPoint drawingPoint(x,y);
|
||||
QPointList.push_back(drawingPoint);
|
||||
this->Canvas->image->drawLine(QPointList.operator[](QPointList.size() - 2), QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), lineWidth);
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
@@ -52,29 +45,35 @@ void IntelliToolPolygon::onMouseRightPressed(int x, int y){
|
||||
|
||||
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||
if(PointIsNearStart && QPointList.size() > 1){
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
PointIsNearStart = false;
|
||||
isDrawing = false;
|
||||
Triangles = IntelliHelper::calculateTriangles(QPointList);
|
||||
for(int i = 0; i < width; i++){
|
||||
for(int j = 0; j < height; j++){
|
||||
Point.setX(i);
|
||||
Point.setY(j);
|
||||
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList);
|
||||
QPoint Point;
|
||||
QColor colorTwo(colorPicker->getSecondColor());
|
||||
colorTwo.setAlpha(alphaInner);
|
||||
for(int i = 0; i < Active->width; i++){
|
||||
for(int j = 0; j < Active->hight; j++){
|
||||
Point = QPoint(i,j);
|
||||
if(IntelliHelper::isInPolygon(Triangles,Point)){
|
||||
this->Canvas->image->drawPixel(QPoint(i,j), colorPicker->getFirstColor());
|
||||
this->Canvas->image->drawPixel(Point, colorTwo);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0; i<QPointList.size(); i++){
|
||||
int next = (i+1)%QPointList.size();
|
||||
this->Canvas->image->drawLine(QPointList[i], QPointList[next], colorPicker->getFirstColor(), lineWidth);
|
||||
}
|
||||
QPointList.clear();
|
||||
IntelliTool::onMouseLeftReleased(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onMouseRightReleased(int x, int y){
|
||||
|
||||
IntelliTool::onMouseRightReleased(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
if(!isDrawing){
|
||||
if(lineWidth + value < 10){
|
||||
lineWidth += value;
|
||||
@@ -86,7 +85,7 @@ void IntelliToolPolygon::onWheelScrolled(int value){
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onMouseMoved(int x, int y){
|
||||
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
|
||||
bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
|
||||
|
||||
Reference in New Issue
Block a user