Edit GCS module and ui
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Click me</string>
|
||||
<string>Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -48,7 +48,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string>Parallel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -61,7 +61,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string>P2P</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -71,7 +71,7 @@
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>1000</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -97,6 +97,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Canvas</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -107,7 +110,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
23
GCS/Geo.cpp
23
GCS/Geo.cpp
@@ -33,6 +33,13 @@ namespace GCS
|
||||
{
|
||||
|
||||
//----------------Point
|
||||
|
||||
Point::Point(double* px, double* py, int _tag) {
|
||||
x = px;
|
||||
y = py;
|
||||
tag = _tag;
|
||||
}
|
||||
|
||||
int Point::PushOwnParams(VEC_pD& pvec)
|
||||
{
|
||||
int cnt = 0;
|
||||
@@ -130,6 +137,12 @@ DeriVector2 Curve::Value(double /*u*/, double /*du*/, const double* /*derivparam
|
||||
|
||||
//----------------Line
|
||||
|
||||
Line::Line(Point _p1, Point _p2, int _tag) {
|
||||
p1 = _p1;
|
||||
p2 = _p2;
|
||||
tag = _tag;
|
||||
}
|
||||
|
||||
DeriVector2 Line::CalculateNormal(const Point& p, const double* derivparam) const
|
||||
{
|
||||
(void)p;
|
||||
@@ -178,6 +191,16 @@ Line* Line::Copy()
|
||||
return crv;
|
||||
}
|
||||
|
||||
void Line::draw(QPainter& p, bool highlight){
|
||||
QPen pen = highlight ? QPen(Qt::red, 4) : QPen(Qt::black, 2);
|
||||
p.setPen(pen);
|
||||
p.drawLine(QPointF(p1.get_X(), p1.get_Y()), QPointF(p2.get_X(), p2.get_Y()));
|
||||
|
||||
p.setBrush(highlight ? Qt::red : Qt::blue);
|
||||
p.drawEllipse(QPointF(p1.get_X(), p1.get_Y()), 4, 4);
|
||||
p.drawEllipse(QPointF(p2.get_X(), p2.get_Y()), 4, 4);
|
||||
}
|
||||
|
||||
|
||||
//---------------circle
|
||||
|
||||
|
||||
66
GCS/Geo.h
66
GCS/Geo.h
@@ -1,4 +1,4 @@
|
||||
/***************************************************************************
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Konstantinos Poulios <logari81@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
@@ -24,16 +24,20 @@
|
||||
#define PLANEGCS_GEO_H
|
||||
|
||||
#include "Util.h"
|
||||
#include <QPainter>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4251)
|
||||
#endif
|
||||
#include <numbers>
|
||||
|
||||
namespace GCS
|
||||
{
|
||||
class Point
|
||||
{
|
||||
private:
|
||||
int tag;
|
||||
public:
|
||||
Point()
|
||||
{
|
||||
@@ -41,24 +45,12 @@ public:
|
||||
y = nullptr;
|
||||
}
|
||||
|
||||
Point(double* px, double* py)
|
||||
{
|
||||
x = px;
|
||||
y = py;
|
||||
}
|
||||
|
||||
Point(double* px, double* py, int _tag)
|
||||
{
|
||||
x = px;
|
||||
y = py;
|
||||
tag = _tag;
|
||||
}
|
||||
Point(double* px, double* py, int _tag = 0);
|
||||
|
||||
double* x;
|
||||
double* y;
|
||||
|
||||
int PushOwnParams(VEC_pD& pvec);
|
||||
|
||||
void ReconstructOnNewPvec(VEC_pD& pvec, int& cnt);
|
||||
|
||||
double get_X() const {
|
||||
@@ -69,8 +61,9 @@ public:
|
||||
return *(this->y);
|
||||
}
|
||||
|
||||
private:
|
||||
int tag;
|
||||
void set_tag(int _tag) {
|
||||
tag = _tag;
|
||||
}
|
||||
};
|
||||
|
||||
using VEC_P = std::vector<Point>;
|
||||
@@ -215,13 +208,14 @@ public:
|
||||
|
||||
class Line: public Curve
|
||||
{
|
||||
private:
|
||||
int tag;
|
||||
public:
|
||||
Line()
|
||||
{}
|
||||
Line(Point _p1, Point _p2) {
|
||||
p1 = _p1;
|
||||
p2 = _p2;
|
||||
}
|
||||
|
||||
Line(Point _p1, Point _p2, int _tag = 0);
|
||||
|
||||
~Line() override
|
||||
{}
|
||||
Point p1;
|
||||
@@ -231,6 +225,13 @@ public:
|
||||
int PushOwnParams(VEC_pD& pvec) override;
|
||||
void ReconstructOnNewPvec(VEC_pD& pvec, int& cnt) override;
|
||||
Line* Copy() override;
|
||||
|
||||
void draw(QPainter& p, bool highlight = false);
|
||||
void set_tag(int _tag) {
|
||||
tag = _tag;
|
||||
p1.set_tag(_tag);
|
||||
p2.set_tag(_tag);
|
||||
}
|
||||
};
|
||||
|
||||
class Circle: public Curve
|
||||
@@ -253,6 +254,8 @@ public:
|
||||
|
||||
class Arc: public Circle
|
||||
{
|
||||
private:
|
||||
int tag;
|
||||
public:
|
||||
Arc()
|
||||
{
|
||||
@@ -260,6 +263,20 @@ public:
|
||||
endAngle = nullptr;
|
||||
rad = nullptr;
|
||||
}
|
||||
|
||||
Arc(Point _center, Point _st, Point _end, double* a, double* b, double *radius, int _tag = 0) {
|
||||
center = _center;
|
||||
start = _st;
|
||||
end = _end;
|
||||
|
||||
startAngle = a;
|
||||
endAngle = b;
|
||||
rad = radius;
|
||||
|
||||
tag = _tag;
|
||||
calculate_arc_points();
|
||||
}
|
||||
|
||||
~Arc() override
|
||||
{}
|
||||
double* startAngle;
|
||||
@@ -272,6 +289,15 @@ public:
|
||||
int PushOwnParams(VEC_pD& pvec) override;
|
||||
void ReconstructOnNewPvec(VEC_pD& pvec, int& cnt) override;
|
||||
Arc* Copy() override;
|
||||
|
||||
private:
|
||||
// Find positions of startpoint and endpoint of arc
|
||||
void calculate_arc_points() {
|
||||
*start.x = *center.x + *rad * cos(*startAngle);
|
||||
*start.y = *center.x + *rad * sin(*startAngle);
|
||||
*end.x = *center.x + *rad * cos(*endAngle);
|
||||
*end.y = *center.x + *rad * sin(*endAngle);
|
||||
}
|
||||
};
|
||||
|
||||
class MajorRadiusConic: public Curve
|
||||
|
||||
Reference in New Issue
Block a user