mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 03:40:31 +02:00
Merge branch 'Helper_Variablen' into 'dev-stupidrenderer'
# Conflicts: # src/Image/IntelliImage.h # src/IntelliPhoto.pro # src/Layer/PaintingArea.h
This commit is contained in:
53
src/IntelliHelper/IntelliToolsettings.cpp
Normal file
53
src/IntelliHelper/IntelliToolsettings.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "IntelliToolsettings.h"
|
||||
#include <QInputDialog>
|
||||
|
||||
IntelliToolsettings::IntelliToolsettings()
|
||||
{
|
||||
lineWidth = 1;
|
||||
innerAlpha = 255;
|
||||
Linestyle = LineStyle::SOLID_LINE;
|
||||
}
|
||||
|
||||
IntelliToolsettings::~IntelliToolsettings(){
|
||||
|
||||
}
|
||||
|
||||
int IntelliToolsettings::getLineWidth(){
|
||||
return lineWidth;
|
||||
}
|
||||
|
||||
void IntelliToolsettings::setLineWidth(){
|
||||
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
|
||||
}
|
||||
|
||||
void IntelliToolsettings::setLineWidth(int LineWidth){
|
||||
if(LineWidth < 1){
|
||||
LineWidth = 1;
|
||||
}
|
||||
else if(LineWidth > 50){
|
||||
LineWidth = 50;
|
||||
}
|
||||
lineWidth = LineWidth;
|
||||
}
|
||||
|
||||
int IntelliToolsettings::getInnerAlpha(){
|
||||
return this->innerAlpha;
|
||||
}
|
||||
|
||||
void IntelliToolsettings::setInnerAlpha(){
|
||||
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Aplha Input", "Value",0,0,255,1);
|
||||
}
|
||||
|
||||
void IntelliToolsettings::setInnerAlpha(int innerAlpha){
|
||||
if(innerAlpha < 0){
|
||||
innerAlpha = 0;
|
||||
}
|
||||
else if(innerAlpha > 255){
|
||||
innerAlpha = 255;
|
||||
}
|
||||
this->innerAlpha = innerAlpha;
|
||||
}
|
||||
|
||||
IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){
|
||||
return Linestyle;
|
||||
}
|
||||
29
src/IntelliHelper/IntelliToolsettings.h
Normal file
29
src/IntelliHelper/IntelliToolsettings.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#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();
|
||||
virtual ~IntelliToolsettings();
|
||||
int getLineWidth();
|
||||
void setLineWidth();
|
||||
void setLineWidth(int LineWidth);
|
||||
int getInnerAlpha();
|
||||
void setInnerAlpha();
|
||||
void setInnerAlpha(int innerAlpha);
|
||||
LineStyle getLinestyle();
|
||||
|
||||
private:
|
||||
int lineWidth;
|
||||
int innerAlpha;
|
||||
LineStyle Linestyle;
|
||||
};
|
||||
|
||||
#endif // INTELLITOOLSETTINGS_H
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "IntelliHelper.h"
|
||||
#include "IntelliTriangulation.h"
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
#include <cmath>
|
||||
#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
|
||||
struct TriangleHelper {
|
||||
QPoint vertex;
|
||||
@@ -113,9 +113,9 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
|
||||
return Triangles;
|
||||
}
|
||||
|
||||
bool IntelliHelper::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
|
||||
bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
|
||||
for(auto triangle : triangles) {
|
||||
if(IntelliHelper::isInTriangle(triangle, point)) {
|
||||
if(IntelliTriangulation::isInTriangle(triangle, point)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef INTELLIHELPER_H
|
||||
#define INTELLIHELPER_H
|
||||
#ifndef INTELLITRIANGULATION_H
|
||||
#define INTELLITRIANGULATION_H
|
||||
|
||||
#include <QPoint>
|
||||
#include <vector>
|
||||
@@ -11,7 +11,7 @@ struct Triangle {
|
||||
QPoint A,B,C;
|
||||
};
|
||||
|
||||
namespace IntelliHelper {
|
||||
namespace IntelliTriangulation {
|
||||
|
||||
/*!
|
||||
* \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;
|
||||
bool neg, pos;
|
||||
|
||||
val1 = IntelliHelper::sign(P,tri.A,tri.B);
|
||||
val2 = IntelliHelper::sign(P,tri.B,tri.C);
|
||||
val3 = IntelliHelper::sign(P,tri.C,tri.A);
|
||||
val1 = IntelliTriangulation::sign(P,tri.A,tri.B);
|
||||
val2 = IntelliTriangulation::sign(P,tri.B,tri.C);
|
||||
val3 = IntelliTriangulation::sign(P,tri.C,tri.A);
|
||||
|
||||
neg = (val1<0.f) || (val2<0.f) || (val3<0.f);
|
||||
pos = (val1>0.f) || (val2>0.f) || (val3>0.f);
|
||||
Reference in New Issue
Block a user