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

@@ -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 <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;
}
}

View File

@@ -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);