Add some debug and util routines.
This commit is contained in:
@@ -75,6 +75,8 @@ class TechDrawExport DrawUtil {
|
||||
Base::Vector3d org = Base::Vector3d(0.0,0.0,0.0));
|
||||
static Base::Vector3d closestBasis(Base::Vector3d v);
|
||||
static double getDefaultLineWeight(std::string s);
|
||||
static Base::Vector3d vector23(const Base::Vector2d& v2) { return Base::Vector3d(v2.x,v2.y,0.0); }
|
||||
static Base::Vector2d vector32(const Base::Vector3d& v3) { return Base::Vector2d(v3.x,v3.y); }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "DrawUtil.h"
|
||||
|
||||
using namespace TechDrawGeometry;
|
||||
using namespace TechDraw;
|
||||
|
||||
// Collection of Geometric Features
|
||||
Wire::Wire()
|
||||
@@ -426,6 +427,44 @@ Generic::Generic()
|
||||
geomType = GENERIC;
|
||||
}
|
||||
|
||||
Base::Vector2d Generic::asVector(void)
|
||||
{
|
||||
Base::Vector2d result = getEndPoint() - getStartPoint();
|
||||
return result;
|
||||
}
|
||||
|
||||
double Generic::slope(void)
|
||||
{
|
||||
double slope;
|
||||
Base::Vector2d v = asVector();
|
||||
if (v.x == 0.0) {
|
||||
slope = DOUBLE_MAX;
|
||||
} else {
|
||||
slope = v.y/v.x;
|
||||
}
|
||||
return slope;
|
||||
}
|
||||
|
||||
Base::Vector2d Generic::apparentInter(Generic* g)
|
||||
{
|
||||
Base::Vector3d dir0 = DrawUtil::vector23(asVector());
|
||||
Base::Vector3d dir1 = DrawUtil::vector23(g->asVector());
|
||||
|
||||
// Line Intersetion (taken from ViewProviderSketch.cpp)
|
||||
double det = dir0.x*dir1.y - dir0.y*dir1.x;
|
||||
if ((det > 0 ? det : -det) < 1e-10)
|
||||
throw Base::Exception("Invalid selection - Det = 0");
|
||||
|
||||
double c0 = dir0.y*points.at(0).x - dir0.x*points.at(0).y;
|
||||
double c1 = dir1.y*g->points.at(1).x - dir1.x*g->points.at(1).y;
|
||||
double x = (dir0.x*c1 - dir1.x*c0)/det;
|
||||
double y = (dir0.y*c1 - dir1.y*c0)/det;
|
||||
|
||||
// Apparent Intersection point
|
||||
Base::Vector2d result = Base::Vector2d(x,y);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
BSpline::BSpline(const TopoDS_Edge &e)
|
||||
{
|
||||
@@ -520,6 +559,8 @@ Vertex::Vertex(double x, double y)
|
||||
visible = false;
|
||||
ref3D = -1; //obs. never used.
|
||||
isCenter = false;
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x,y,0.0));
|
||||
occVertex = mkVert.Vertex();
|
||||
}
|
||||
|
||||
bool Vertex::isEqual(Vertex* v, double tol)
|
||||
|
||||
@@ -192,7 +192,10 @@ class TechDrawExport Generic: public BaseGeom
|
||||
Generic();
|
||||
~Generic() = default;
|
||||
|
||||
std::vector<Base::Vector2d> points;
|
||||
Base::Vector2d asVector(void);
|
||||
double slope(void);
|
||||
Base::Vector2d apparentInter(Generic* g);
|
||||
std::vector<Base::Vector2d> points;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGCustomBorder.h"
|
||||
#include "QGCustomLabel.h"
|
||||
#include "QGIView.h"
|
||||
@@ -61,6 +62,7 @@
|
||||
#include "QGIViewClip.h"
|
||||
#include "ViewProviderDrawingView.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGICMark.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewClip.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||
@@ -558,3 +560,14 @@ void QGIView::dumpRect(char* text, QRectF r) {
|
||||
Base::Console().Message("DUMP - %s - rect: (%.3f,%.3f) x (%.3f,%.3f)\n",text,
|
||||
r.left(),r.top(),r.right(),r.bottom());
|
||||
}
|
||||
|
||||
void QGIView::makeMark(double x, double y)
|
||||
{
|
||||
QGICMark* cmItem = new QGICMark(-1);
|
||||
cmItem->setParentItem(this);
|
||||
cmItem->setPos(x,y);
|
||||
cmItem->setThick(1.0);
|
||||
cmItem->setSize(40.0);
|
||||
cmItem->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
virtual void draw(void);
|
||||
virtual void drawCaption(void);
|
||||
virtual void rotateView(void);
|
||||
void makeMark(double x, double y);
|
||||
|
||||
|
||||
/** Methods to ensure that Y-Coordinates are orientated correctly.
|
||||
* @{ */
|
||||
|
||||
Reference in New Issue
Block a user