Fix issue 7 Projection Results
This commit is contained in:
parent
d95bf4786d
commit
14a9fd4fcd
|
@ -89,14 +89,15 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
|
|||
|
||||
ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection normal direction");
|
||||
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view");
|
||||
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines");
|
||||
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.7f),vgroup,App::Prop_None,"The thickness of the resulting lines");
|
||||
ADD_PROPERTY_TYPE(HiddenWidth,(0.15),vgroup,App::Prop_None,"The thickness of the hidden lines, if enabled");
|
||||
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Hidden lines on/off");
|
||||
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Smooth lines on/off");
|
||||
ADD_PROPERTY_TYPE(ShowSeamLines ,(false),group,App::Prop_None,"Seam lines on/off");
|
||||
//ADD_PROPERTY_TYPE(ShowIsoLines ,(false),group,App::Prop_None,"Iso u,v lines on/off");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.7f),vgroup,App::Prop_None,"The thickness of visible lines");
|
||||
ADD_PROPERTY_TYPE(HiddenWidth,(0.15),vgroup,App::Prop_None,"The thickness of hidden lines, if enabled");
|
||||
ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance");
|
||||
Tolerance.setConstraints(&floatRange);
|
||||
ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"X-Axis direction");
|
||||
//ADD_PROPERTY_TYPE(HatchAreas ,(0),vgroup,App::Prop_None,"Hatched areas of this view");
|
||||
ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"Direction to use as X-axis in projection");
|
||||
|
||||
geometryObject = new TechDrawGeometry::GeometryObject();
|
||||
}
|
||||
|
@ -124,22 +125,13 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
}
|
||||
|
||||
try {
|
||||
geometryObject->setTolerance(Tolerance.getValue());
|
||||
geometryObject->setScale(Scale.getValue());
|
||||
geometryObject->extractGeometry(shape,
|
||||
Direction.getValue(),
|
||||
ShowHiddenLines.getValue(),
|
||||
_getValidXDir(this));
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
touch();
|
||||
|
||||
buildGeometryObject(shape);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
|
||||
// There is a guaranteed change so check any references linked to this and touch
|
||||
// We need to update all views pointing at this (ProjectionGroup, ClipGroup, etc)
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
|
@ -150,6 +142,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
}
|
||||
}
|
||||
|
||||
touch();
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
|
@ -160,7 +153,9 @@ short DrawViewPart::mustExecute() const
|
|||
Source.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
ShowHiddenLines.isTouched());
|
||||
ShowHiddenLines.isTouched() ||
|
||||
ShowSmoothLines.isTouched() ||
|
||||
ShowSeamLines.isTouched());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -172,7 +167,9 @@ void DrawViewPart::onChanged(const App::Property* prop)
|
|||
prop == &Source ||
|
||||
prop == &Scale ||
|
||||
prop == &ScaleType ||
|
||||
prop == &ShowHiddenLines) {
|
||||
prop == &ShowHiddenLines ||
|
||||
prop == &ShowSmoothLines ||
|
||||
prop == &ShowSeamLines) {
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
|
@ -183,43 +180,45 @@ void DrawViewPart::onChanged(const App::Property* prop)
|
|||
}
|
||||
DrawView::onChanged(prop);
|
||||
|
||||
//TODO: when scale changes, any Dimensions for this View sb recalculated.
|
||||
//TODO: when scale changes, any Dimensions for this View sb recalculated. (might happen anyway if document is recomputed?)
|
||||
}
|
||||
|
||||
#if 0
|
||||
int DrawViewPart::addHatch(App::DocumentObject *docObj)
|
||||
void DrawViewPart::buildGeometryObject(TopoDS_Shape shape)
|
||||
{
|
||||
if(!docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()))
|
||||
return -1;
|
||||
|
||||
const std::vector<App::DocumentObject *> currAreas = HatchAreas.getValues();
|
||||
std::vector<App::DocumentObject *> newAreas(currAreas);
|
||||
newAreas.push_back(docObj);
|
||||
HatchAreas.setValues(newAreas);
|
||||
HatchAreas.touch();
|
||||
return HatchAreas.getSize();
|
||||
}
|
||||
|
||||
int DrawViewPart::removeHatch(App::DocumentObject *docObj)
|
||||
{
|
||||
if(!docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()))
|
||||
return -1;
|
||||
|
||||
const std::vector<App::DocumentObject*> currAreas = HatchAreas.getValues();
|
||||
std::vector<App::DocumentObject*> newAreas;
|
||||
std::vector<App::DocumentObject*>::const_iterator it = currAreas.begin();
|
||||
for (; it != currAreas.end(); it++) {
|
||||
std::string areaName = docObj->getNameInDocument();
|
||||
if (areaName.compare((*it)->getNameInDocument()) != 0) {
|
||||
newAreas.push_back((*it));
|
||||
}
|
||||
geometryObject->setTolerance(Tolerance.getValue());
|
||||
geometryObject->setScale(Scale.getValue());
|
||||
//TODO: need to pass ShowSmoothLines, ShowSeamLines
|
||||
//geometryObject->extractGeometry(shape,
|
||||
// Direction.getValue(),
|
||||
// ShowHiddenLines.getValue(),
|
||||
// _getValidXDir(this));
|
||||
geometryObject->initHLR(shape,
|
||||
Direction.getValue(),
|
||||
_getValidXDir(this));
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
|
||||
true);
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
|
||||
true);
|
||||
if (ShowSmoothLines.getValue()) {
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
|
||||
true);
|
||||
}
|
||||
HatchAreas.setValues(newAreas);
|
||||
HatchAreas.touch();
|
||||
|
||||
return HatchAreas.getSize();
|
||||
if (ShowSeamLines.getValue()) {
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
|
||||
true);
|
||||
}
|
||||
//if (ShowIsoLines.getValue()) {
|
||||
// geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
|
||||
// true);
|
||||
//}
|
||||
if (ShowHiddenLines.getValue()) {
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
|
||||
false);
|
||||
//geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE, //hidden outline,smooth,seam??
|
||||
// true);
|
||||
}
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
|
||||
{
|
||||
|
|
|
@ -51,10 +51,11 @@ public:
|
|||
virtual ~DrawViewPart();
|
||||
|
||||
App::PropertyLink Source; //Part Feature
|
||||
App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is
|
||||
App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection)
|
||||
App::PropertyVector XAxisDirection;
|
||||
App::PropertyBool ShowHiddenLines;
|
||||
App::PropertyBool ShowSmoothLines;
|
||||
App::PropertyBool ShowSeamLines;
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyFloat HiddenWidth;
|
||||
App::PropertyFloatConstraint Tolerance;
|
||||
|
@ -108,7 +109,7 @@ public:
|
|||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
void buildGeometryObject(TopoDS_Shape shape);
|
||||
TechDrawGeometry::GeometryObject *geometryObject;
|
||||
Base::BoundBox3d bbox;
|
||||
|
||||
|
|
|
@ -204,26 +204,37 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
if (!mkCut.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Section cut has failed");
|
||||
|
||||
// Cache the result
|
||||
result = mkCut.Shape();
|
||||
// Cache the sectionShape
|
||||
sectionShape = mkCut.Shape();
|
||||
|
||||
try {
|
||||
geometryObject->setTolerance(Tolerance.getValue());
|
||||
geometryObject->setScale(Scale.getValue());
|
||||
//TODO: Do we need to check for nonzero XAxisDirection here?
|
||||
geometryObject->extractGeometry(result, Direction.getValue(), ShowHiddenLines.getValue(), XAxisDirection.getValue());
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
|
||||
touch();
|
||||
buildGeometryObject(sectionShape);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
Base::Console().Log("DrawViewSection::execute - extractGeometry failed: %s\n",e->GetMessageString());
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
Handle_Standard_Failure e1 = Standard_Failure::Caught();
|
||||
Base::Console().Log("DrawViewSection::execute - extractGeometry failed: %s\n",e1->GetMessageString());
|
||||
return new App::DocumentObjectExecReturn(e1->GetMessageString());
|
||||
}
|
||||
|
||||
TopoDS_Compound sectionFaces;
|
||||
try {
|
||||
sectionFaces = getSectionFaces();
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e2 = Standard_Failure::Caught();
|
||||
Base::Console().Log("DrawViewSection::execute - getSectionFaces failed: %s\n",e2->GetMessageString());
|
||||
return new App::DocumentObjectExecReturn(e2->GetMessageString());
|
||||
}
|
||||
|
||||
if (!sectionFaces.IsNull()) {
|
||||
//TODO: do something with sectionFaces
|
||||
//?add to GeometryObject faceGeom? but need to tag these faces as "special"
|
||||
//how does QGIVSection know to shade these faces??
|
||||
}
|
||||
|
||||
// TODO: touch references? see DrawViewPart.execute()
|
||||
return DrawView::execute(); //sb DrawViewPart?
|
||||
touch();
|
||||
return DrawView::execute(); //note: not DrawViewPart
|
||||
}
|
||||
|
||||
gp_Pln DrawViewSection::getSectionPlane() const
|
||||
|
@ -234,39 +245,37 @@ gp_Pln DrawViewSection::getSectionPlane() const
|
|||
return gp_Pln(gp_Pnt(plnPnt.x, plnPnt.y, plnPnt.z), gp_Dir(plnNorm.x, plnNorm.y, plnNorm.z));
|
||||
}
|
||||
|
||||
//! tries to find the intersection of the section plane with the part???
|
||||
//face logic is turned off in GeometryObject, so this won't work now.
|
||||
void DrawViewSection::getSectionSurface(std::vector<TechDrawGeometry::Face *> §ionFace) const {
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
if(result.IsNull()){
|
||||
//throw Base::Exception("Sectional View Result is Empty");
|
||||
Base::Console().Log("DrawViewSection::getSectionSurface - Sectional View Result is Empty\n");
|
||||
return;
|
||||
//! tries to find the intersection of the section plane with the sectionShape (a collection of planar faces)
|
||||
TopoDS_Compound DrawViewSection::getSectionFaces(void)
|
||||
{
|
||||
TopoDS_Compound result;
|
||||
if(sectionShape.IsNull()){
|
||||
//throw Base::Exception("Sectional View sectionShape is Empty");
|
||||
Base::Console().Log("DrawViewSection::getSectionSurface - Sectional View sectionShape is Empty\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
gp_Pln pln = getSectionPlane();
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
builder.MakeCompound(result);
|
||||
|
||||
// Iterate through all faces
|
||||
TopExp_Explorer face(result, TopAbs_FACE);
|
||||
for ( ; faces.More(); faces.Next()) {
|
||||
const TopoDS_Face& face = TopoDS::Face(faces.Current());
|
||||
TopExp_Explorer expFaces(sectionShape, TopAbs_FACE);
|
||||
for ( ; expFaces.More(); expFaces.Next()) {
|
||||
const TopoDS_Face& face = TopoDS::Face(expFaces.Current());
|
||||
|
||||
BRepAdaptor_Surface adapt(face);
|
||||
if (adapt.GetType() == GeomAbs_Plane){
|
||||
gp_Pln plane = adapt.Plane();
|
||||
if(plane.Contains(pln.Location(), Precision::Confusion()) && plane.Axis().IsParallel(pln.Axis(), Precision::Angular())) {
|
||||
builder.Add(comp, face);
|
||||
builder.Add(result, face);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: Do we need to check for nonzero XAxisDirection here?
|
||||
geometryObject->projectSurfaces(comp, result, Direction.getValue(), XAxisDirection.getValue(), sectionFace);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "DrawViewPart.h"
|
||||
|
||||
class gp_Pln;
|
||||
class TopoDS_Compound;
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
@ -65,10 +66,10 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
void getSectionSurface(std::vector<TechDrawGeometry::Face *> §ionFace) const;
|
||||
TopoDS_Compound getSectionFaces(void);
|
||||
|
||||
protected:
|
||||
TopoDS_Shape result;
|
||||
TopoDS_Shape sectionShape;
|
||||
gp_Pln getSectionPlane() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
@ -109,50 +110,23 @@ Face::~Face()
|
|||
|
||||
BaseGeom::BaseGeom() :
|
||||
geomType(NOTDEF),
|
||||
reversed(false)
|
||||
extractType(Plain),
|
||||
classOfEdge(ecNONE),
|
||||
visible(true),
|
||||
reversed(false),
|
||||
ref3D(-1)
|
||||
{
|
||||
}
|
||||
|
||||
//! ugh. yuck.
|
||||
std::vector<Base::Vector2D> BaseGeom::findEndPoints()
|
||||
{
|
||||
std::vector<Base::Vector2D> result;
|
||||
switch(this->geomType) {
|
||||
case TechDrawGeometry::CIRCLE: {
|
||||
TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(this);
|
||||
double x = geom->center.fX + geom->radius;
|
||||
result.push_back(Base::Vector2D(x,geom->center.fY));
|
||||
result.push_back(Base::Vector2D(x,geom->center.fY));
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFCIRCLE: {
|
||||
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(this);
|
||||
result.push_back(geom->startPnt);
|
||||
result.push_back(geom->endPnt);
|
||||
} break;
|
||||
case TechDrawGeometry::ELLIPSE: {
|
||||
TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(this);
|
||||
result.push_back(geom->center + Base::Vector2D(geom->major * cos(geom->angle), geom->major * sin(geom->angle)));
|
||||
result.push_back(geom->center + Base::Vector2D(geom->major * cos(geom->angle), geom->major * sin(geom->angle)));
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFELLIPSE: {
|
||||
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(this);
|
||||
result.push_back(geom->startPnt);
|
||||
result.push_back(geom->endPnt);
|
||||
} break;
|
||||
case TechDrawGeometry::BSPLINE: {
|
||||
TechDrawGeometry::BSpline *geom = static_cast<TechDrawGeometry::BSpline *>(this);
|
||||
result.push_back(geom->segments.front().pnts[0]);
|
||||
TechDrawGeometry::BezierSegment tempSeg = geom->segments.back();
|
||||
result.push_back(tempSeg.pnts[tempSeg.poles - 1]);
|
||||
} break;
|
||||
case TechDrawGeometry::GENERIC: {
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(this);
|
||||
result.push_back(geom->points.front());
|
||||
result.push_back(geom->points.back());
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//if (occEdge) {
|
||||
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
|
||||
result.push_back(Base::Vector2D(p.X(),p.Y()));
|
||||
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
|
||||
result.push_back(Base::Vector2D(p.X(),p.Y()));
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -168,15 +142,11 @@ Base::Vector2D BaseGeom::getEndPoint()
|
|||
return verts[1];
|
||||
}
|
||||
|
||||
Ellipse::Ellipse()
|
||||
Ellipse::Ellipse(const TopoDS_Edge &e)
|
||||
{
|
||||
geomType = ELLIPSE;
|
||||
}
|
||||
|
||||
Ellipse::Ellipse(const BRepAdaptor_Curve& c)
|
||||
{
|
||||
geomType = ELLIPSE;
|
||||
|
||||
BRepAdaptor_Curve c(e);
|
||||
occEdge = e;
|
||||
gp_Elips ellp = c.Ellipse();
|
||||
const gp_Pnt &p = ellp.Location();
|
||||
|
||||
|
@ -189,23 +159,20 @@ Ellipse::Ellipse(const BRepAdaptor_Curve& c)
|
|||
angle = xaxis.AngleWithRef(gp_Dir(1, 0, 0), gp_Dir(0, 0, -1));
|
||||
}
|
||||
|
||||
AOE::AOE()
|
||||
{
|
||||
geomType = ARCOFELLIPSE;
|
||||
}
|
||||
|
||||
AOE::AOE(const BRepAdaptor_Curve& c) : Ellipse(c)
|
||||
AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
|
||||
{
|
||||
geomType = ARCOFELLIPSE;
|
||||
|
||||
BRepAdaptor_Curve c(e);
|
||||
double f = c.FirstParameter();
|
||||
double l = c.LastParameter();
|
||||
gp_Pnt s = c.Value(f);
|
||||
gp_Pnt m = c.Value((l+f)/2.0);
|
||||
gp_Pnt e = c.Value(l);
|
||||
gp_Pnt ePt = c.Value(l);
|
||||
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,e);
|
||||
gp_Vec v2(m,ePt);
|
||||
gp_Vec v3(0,0,1);
|
||||
double a = v3.DotCross(v1,v2);
|
||||
|
||||
|
@ -215,38 +182,15 @@ AOE::AOE(const BRepAdaptor_Curve& c) : Ellipse(c)
|
|||
largeArc = (l-f > M_PI) ? true : false;
|
||||
|
||||
startPnt = Base::Vector2D(s.X(), s.Y());
|
||||
endPnt = Base::Vector2D(e.X(), e.Y());
|
||||
endPnt = Base::Vector2D(ePt.X(), ePt.Y());
|
||||
midPnt = Base::Vector2D(m.X(), m.Y());
|
||||
/*
|
||||
char las = (l-f > D_PI) ? '1' : '0'; // large-arc-flag
|
||||
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
|
||||
out << "<path d=\"M" << s.X() << " " << s.Y()
|
||||
<< " A" << r1 << " " << r2 << " "
|
||||
<< angle << " " << las << " " << swp << " "
|
||||
<< e.X() << " " << e.Y() << "\" />" << std::endl;
|
||||
// if (startAngle > endAngle) {// if arc is reversed
|
||||
// std::swap(startAngle, endAngle);
|
||||
// }*/
|
||||
|
||||
// double ax = s.X() - center.fX;
|
||||
// double ay = s.Y() - center.fY;
|
||||
// double bx = e.X() - center.fX;
|
||||
// double by = e.Y() - center.fY;
|
||||
|
||||
// startAngle = f;
|
||||
// float range = l-f;
|
||||
//
|
||||
// endAngle = startAngle + range;
|
||||
}
|
||||
|
||||
Circle::Circle()
|
||||
{
|
||||
geomType = CIRCLE;
|
||||
}
|
||||
|
||||
Circle::Circle(const BRepAdaptor_Curve& c)
|
||||
Circle::Circle(const TopoDS_Edge &e)
|
||||
{
|
||||
geomType = CIRCLE;
|
||||
BRepAdaptor_Curve c(e);
|
||||
occEdge = e;
|
||||
|
||||
gp_Circ circ = c.Circle();
|
||||
const gp_Pnt& p = circ.Location();
|
||||
|
@ -255,23 +199,19 @@ Circle::Circle(const BRepAdaptor_Curve& c)
|
|||
center = Base::Vector2D(p.X(), p.Y());
|
||||
}
|
||||
|
||||
AOC::AOC()
|
||||
{
|
||||
geomType = ARCOFCIRCLE;
|
||||
}
|
||||
|
||||
AOC::AOC(const BRepAdaptor_Curve& c) : Circle(c)
|
||||
AOC::AOC(const TopoDS_Edge &e) : Circle(e)
|
||||
{
|
||||
geomType = ARCOFCIRCLE;
|
||||
BRepAdaptor_Curve c(e);
|
||||
|
||||
double f = c.FirstParameter();
|
||||
double l = c.LastParameter();
|
||||
gp_Pnt s = c.Value(f);
|
||||
gp_Pnt m = c.Value((l+f)/2.0);
|
||||
gp_Pnt e = c.Value(l);
|
||||
gp_Pnt ePt = c.Value(l);
|
||||
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,e);
|
||||
gp_Vec v2(m,ePt);
|
||||
gp_Vec v3(0,0,1);
|
||||
double a = v3.DotCross(v1,v2);
|
||||
|
||||
|
@ -281,46 +221,49 @@ AOC::AOC(const BRepAdaptor_Curve& c) : Circle(c)
|
|||
largeArc = (l-f > M_PI) ? true : false;
|
||||
|
||||
startPnt = Base::Vector2D(s.X(), s.Y());
|
||||
endPnt = Base::Vector2D(e.X(), e.Y());
|
||||
endPnt = Base::Vector2D(ePt.X(), ePt.Y());
|
||||
midPnt = Base::Vector2D(m.X(), m.Y());
|
||||
}
|
||||
|
||||
|
||||
//!Generic is a multiline
|
||||
Generic::Generic(const TopoDS_Edge &e)
|
||||
{
|
||||
geomType = GENERIC;
|
||||
occEdge = e;
|
||||
BRepLib::BuildCurve3d(occEdge);
|
||||
|
||||
TopLoc_Location location;
|
||||
Handle_Poly_Polygon3D polygon = BRep_Tool::Polygon3D(occEdge, location);
|
||||
|
||||
if (!polygon.IsNull()) {
|
||||
const TColgp_Array1OfPnt &nodes = polygon->Nodes();
|
||||
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
|
||||
points.push_back(Base::Vector2D(nodes(i).X(), nodes(i).Y()));
|
||||
}
|
||||
} else {
|
||||
//no polygon representation? approximate with line?
|
||||
Base::Console().Log("INFO - Generic::Generic(edge) - polygon is NULL\n");
|
||||
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
|
||||
points.push_back(Base::Vector2D(p.X(), p.Y()));
|
||||
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
|
||||
points.push_back(Base::Vector2D(p.X(), p.Y()));
|
||||
}
|
||||
}
|
||||
|
||||
Generic::Generic()
|
||||
{
|
||||
geomType = GENERIC;
|
||||
}
|
||||
|
||||
Generic::Generic(const BRepAdaptor_Curve& c)
|
||||
{
|
||||
geomType = GENERIC;
|
||||
|
||||
TopLoc_Location location;
|
||||
Handle_Poly_Polygon3D polygon = BRep_Tool::Polygon3D(c.Edge(), location);
|
||||
if (!polygon.IsNull()) {
|
||||
const TColgp_Array1OfPnt &nodes = polygon->Nodes();
|
||||
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
|
||||
points.push_back(Base::Vector2D(nodes(i).X(), nodes(i).Y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generic::Generic(Base::Vector2D start, Base::Vector2D end)
|
||||
{
|
||||
geomType = GENERIC;
|
||||
points.push_back(start);
|
||||
points.push_back(end);
|
||||
}
|
||||
|
||||
BSpline::BSpline()
|
||||
{
|
||||
geomType = BSPLINE;
|
||||
}
|
||||
|
||||
BSpline::BSpline(const BRepAdaptor_Curve &c)
|
||||
BSpline::BSpline(const TopoDS_Edge &e)
|
||||
{
|
||||
geomType = BSPLINE;
|
||||
BRepAdaptor_Curve c(e);
|
||||
occEdge = e;
|
||||
Handle_Geom_BSplineCurve spline = c.BSpline();
|
||||
if (spline->Degree() > 3) {
|
||||
|
||||
if (spline->Degree() > 3) { //if spline is too complex, approximate it
|
||||
Standard_Real tol3D = 0.001;
|
||||
Standard_Integer maxDegree = 3, maxSegment = 10;
|
||||
Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c);
|
||||
|
@ -359,6 +302,14 @@ BSpline::BSpline(const BRepAdaptor_Curve &c)
|
|||
//! can this BSpline be represented by a straight line?
|
||||
bool BSpline::isLine()
|
||||
{
|
||||
bool result = false;
|
||||
BRepAdaptor_Curve c(occEdge);
|
||||
Handle_Geom_BSplineCurve spline = c.BSpline();
|
||||
if (spline->Degree() == 1) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
#if 0
|
||||
bool result = true;
|
||||
std::vector<BezierSegment>::iterator iSeg = segments.begin();
|
||||
double slope;
|
||||
|
@ -378,6 +329,18 @@ bool BSpline::isLine()
|
|||
}
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
//**** Vertex
|
||||
bool Vertex::isEqual(Vertex* v, double tol)
|
||||
{
|
||||
bool result = false;
|
||||
double dist = (pnt - (v->pnt)).Length();
|
||||
if (dist <= tol) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//**** TechDrawGeometry utility funtions
|
||||
|
@ -401,7 +364,7 @@ std::vector<TechDrawGeometry::BaseGeom*> TechDrawExport chainGeoms(std::vector<T
|
|||
Base::Vector2D atPoint = (geoms[0])->getEndPoint();
|
||||
used[0] = true;
|
||||
for (unsigned int i = 1; i < geoms.size(); i++) { //do size-1 more edges
|
||||
getNextReturn next = nextGeom(atPoint,geoms,used,tolerance);
|
||||
getNextReturnVal next = nextGeom(atPoint,geoms,used,tolerance);
|
||||
if (next.index) { //found an unused edge with vertex == atPoint
|
||||
TechDrawGeometry::BaseGeom* nextEdge = geoms.at(next.index);
|
||||
used[next.index] = true;
|
||||
|
@ -422,12 +385,12 @@ std::vector<TechDrawGeometry::BaseGeom*> TechDrawExport chainGeoms(std::vector<T
|
|||
}
|
||||
|
||||
//! find an unused geom starts or ends at atPoint. returns index[1:geoms.size()),reversed [true,false]
|
||||
getNextReturn TechDrawExport nextGeom(Base::Vector2D atPoint,
|
||||
getNextReturnVal TechDrawExport nextGeom(Base::Vector2D atPoint,
|
||||
std::vector<TechDrawGeometry::BaseGeom*> geoms,
|
||||
std::vector<bool> used,
|
||||
double tolerance)
|
||||
{
|
||||
getNextReturn result(0,false);
|
||||
getNextReturnVal result(0,false);
|
||||
std::vector<TechDrawGeometry::BaseGeom*>::iterator itGeom = geoms.begin();
|
||||
for (; itGeom != geoms.end(); itGeom++) {
|
||||
unsigned int index = itGeom - geoms.begin();
|
||||
|
|
|
@ -24,16 +24,29 @@
|
|||
#define TECHDRAW_GEOMETRY_H
|
||||
|
||||
#include <Base/Tools2D.h>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
||||
class BRepAdaptor_Curve;
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
|
||||
enum ExtractionType {
|
||||
enum ExtractionType { //obs sb vis/hid + hard/smooth/seam/out(edgeClass?)
|
||||
Plain = 0,
|
||||
WithHidden = 1,
|
||||
WithSmooth = 2
|
||||
};
|
||||
|
||||
enum edgeClass {
|
||||
ecNONE, //not used, OCC index starts at 1
|
||||
ecUVISO,
|
||||
ecOUTLINE,
|
||||
ecSMOOTH,
|
||||
ecSEAM,
|
||||
ecHARD
|
||||
};
|
||||
|
||||
enum GeomType {
|
||||
NOTDEF,
|
||||
CIRCLE,
|
||||
|
@ -48,11 +61,15 @@ class TechDrawExport BaseGeom
|
|||
{
|
||||
public:
|
||||
BaseGeom();
|
||||
~BaseGeom() {}
|
||||
virtual ~BaseGeom() {}
|
||||
public:
|
||||
GeomType geomType;
|
||||
ExtractionType extractType;
|
||||
ExtractionType extractType; //obs
|
||||
edgeClass classOfEdge;
|
||||
bool visible;
|
||||
bool reversed;
|
||||
int ref3D;
|
||||
TopoDS_Edge occEdge; //projected Edge
|
||||
std::vector<Base::Vector2D> findEndPoints();
|
||||
Base::Vector2D getStartPoint();
|
||||
Base::Vector2D getEndPoint();
|
||||
|
@ -61,8 +78,7 @@ public:
|
|||
class TechDrawExport Circle: public BaseGeom
|
||||
{
|
||||
public:
|
||||
Circle(const BRepAdaptor_Curve &c);
|
||||
Circle();
|
||||
Circle(const TopoDS_Edge &e);
|
||||
~Circle() {}
|
||||
public:
|
||||
Base::Vector2D center;
|
||||
|
@ -72,8 +88,7 @@ public:
|
|||
class TechDrawExport Ellipse: public BaseGeom
|
||||
{
|
||||
public:
|
||||
Ellipse(const BRepAdaptor_Curve &c);
|
||||
Ellipse();
|
||||
Ellipse(const TopoDS_Edge &e);
|
||||
~Ellipse() {}
|
||||
public:
|
||||
Base::Vector2D center;
|
||||
|
@ -86,8 +101,7 @@ public:
|
|||
class TechDrawExport AOE: public Ellipse
|
||||
{
|
||||
public:
|
||||
AOE(const BRepAdaptor_Curve &c);
|
||||
AOE();
|
||||
AOE(const TopoDS_Edge &e);
|
||||
~AOE() {}
|
||||
public:
|
||||
Base::Vector2D startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
|
||||
|
@ -105,8 +119,7 @@ public:
|
|||
class TechDrawExport AOC: public Circle
|
||||
{
|
||||
public:
|
||||
AOC(const BRepAdaptor_Curve &c);
|
||||
AOC();
|
||||
AOC(const TopoDS_Edge &e);
|
||||
~AOC() {}
|
||||
public:
|
||||
Base::Vector2D startPnt;
|
||||
|
@ -142,23 +155,20 @@ struct BezierSegment
|
|||
class TechDrawExport BSpline: public BaseGeom
|
||||
{
|
||||
public:
|
||||
BSpline(const BRepAdaptor_Curve &c);
|
||||
BSpline();
|
||||
BSpline(const TopoDS_Edge &e);
|
||||
~BSpline(){}
|
||||
public:
|
||||
bool isLine(void);
|
||||
std::vector<BezierSegment> segments;
|
||||
};
|
||||
|
||||
class Generic: public BaseGeom
|
||||
class TechDrawExport Generic: public BaseGeom
|
||||
{
|
||||
public:
|
||||
Generic(Base::Vector2D start, Base::Vector2D end);
|
||||
Generic(const BRepAdaptor_Curve& c);
|
||||
Generic(const TopoDS_Edge &e);
|
||||
Generic();
|
||||
~Generic() {}
|
||||
std::vector<Base::Vector2D> points;
|
||||
|
||||
};
|
||||
|
||||
/// Simple Collection of geometric features based on BaseGeom inherited classes in order
|
||||
|
@ -177,30 +187,35 @@ struct TechDrawExport Face
|
|||
std::vector<Wire *> wires;
|
||||
};
|
||||
|
||||
/// Simple vertex
|
||||
struct TechDrawExport Vertex
|
||||
//! 2D Vertex
|
||||
class TechDrawExport Vertex
|
||||
{
|
||||
public:
|
||||
Vertex(double x, double y) { pnt = Base::Vector2D(x, y); }
|
||||
Vertex(Base::Vector2D v) { pnt = v; }
|
||||
~Vertex() {}
|
||||
Base::Vector2D pnt;
|
||||
ExtractionType extractType;
|
||||
bool visible;
|
||||
int ref3D;
|
||||
TopoDS_Vertex occVertex;
|
||||
bool isEqual(Vertex* v, double tol);
|
||||
};
|
||||
|
||||
//*** utility functions
|
||||
extern "C" {
|
||||
|
||||
struct TechDrawExport getNextReturn {
|
||||
struct TechDrawExport getNextReturnVal {
|
||||
unsigned int index;
|
||||
bool reversed;
|
||||
explicit getNextReturn(int i = 0, bool r = false) :
|
||||
explicit getNextReturnVal(int i = 0, bool r = false) :
|
||||
index(i),
|
||||
reversed(r)
|
||||
{}
|
||||
};
|
||||
|
||||
std::vector<TechDrawGeometry::BaseGeom*> chainGeoms(std::vector<TechDrawGeometry::BaseGeom*> geoms);
|
||||
getNextReturn nextGeom(Base::Vector2D atPoint,
|
||||
getNextReturnVal nextGeom(Base::Vector2D atPoint,
|
||||
std::vector<TechDrawGeometry::BaseGeom*> geoms,
|
||||
std::vector<bool> used,
|
||||
double tolerance);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,6 +23,7 @@
|
|||
#ifndef _TECHDRAW_GEOMETRYOBJECT_H
|
||||
#define _TECHDRAW_GEOMETRYOBJECT_H
|
||||
|
||||
#include <Handle_HLRBRep_Algo.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
|
@ -36,13 +37,13 @@ class HLRBRep_Algo;
|
|||
class Handle_HLRBRep_Data;
|
||||
class HLRBRep_EdgeData;
|
||||
class TopoDS_Wire;
|
||||
class HLRBRep_HLRToShape;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
{
|
||||
|
||||
class BaseGeom;
|
||||
/** Algo class for projecting shapes and creating SVG output of it
|
||||
*/
|
||||
|
||||
class TechDrawExport GeometryObject
|
||||
{
|
||||
public:
|
||||
|
@ -66,39 +67,29 @@ public:
|
|||
const std::vector<int> & getEdgeRefs() const { return edgeReferences; };
|
||||
const std::vector<int> & getFaceRefs() const { return faceReferences; };
|
||||
|
||||
TechDrawGeometry::BaseGeom * projectEdge(const TopoDS_Shape &edge,
|
||||
const TopoDS_Shape &support,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &projXAxis) const;
|
||||
TechDrawGeometry::Vertex * projectVertex(const TopoDS_Shape &vert,
|
||||
const TopoDS_Shape &support,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &projXAxis) const;
|
||||
|
||||
void projectSurfaces(const TopoDS_Shape &face,
|
||||
const TopoDS_Shape &support,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &xaxis,
|
||||
std::vector<TechDrawGeometry::Face *> &result) const;
|
||||
BaseGeom* projectEdge(const TopoDS_Shape &edge,
|
||||
const TopoDS_Shape &support,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &projXAxis) const;
|
||||
Vertex* projectVertex(const TopoDS_Shape &vert,
|
||||
const TopoDS_Shape &support,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &projXAxis) const;
|
||||
|
||||
/// Process 3D shape to get 2D geometry
|
||||
/*!
|
||||
* Applies a projection to the input based on direction and vAxis, then
|
||||
* calls extractEdges (which in turn calls extractVerts) and extractFaces
|
||||
* to populate vectors used by getVertexRefs(), getEdgeRefs(), and
|
||||
* getFaceRefs()
|
||||
*/
|
||||
void extractGeometry(const TopoDS_Shape &input,const Base::Vector3d &direction, bool extractHidden = false, const Base::Vector3d &vAxis = Base::Vector3d(0.,0.,0.));
|
||||
void initHLR(const TopoDS_Shape &input,
|
||||
const Base::Vector3d &direction,
|
||||
const Base::Vector3d &xAxis);
|
||||
void extractGeometry(edgeClass category, bool visible);
|
||||
BaseGeom* edgeToBase(TopoDS_Edge edge);
|
||||
void update3DRefs();
|
||||
|
||||
protected:
|
||||
bool shouldDraw(const bool inFace, const int typ,HLRBRep_EdgeData& ed);
|
||||
bool isSameCurve(const BRepAdaptor_Curve &c1, const BRepAdaptor_Curve &c2) const;
|
||||
|
||||
/// Reimplements HLRBRep Drawing Algorithms to satisfy Drawing Workbench requirements
|
||||
void drawFace(const bool visible, const int iface, Handle_HLRBRep_Data & DS, TopoDS_Shape& Result) const;
|
||||
|
||||
/// Add (visible) intervals of ed to Result as Edges
|
||||
void drawEdge(HLRBRep_EdgeData& ed, TopoDS_Shape& Result, const bool visible) const;
|
||||
void addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass category, bool visible);
|
||||
|
||||
/// Helper for calcBoundingBox()
|
||||
/*! Note that the name of this function isn't totally accurate due to
|
||||
|
@ -121,21 +112,6 @@ protected:
|
|||
*/
|
||||
bool isWithinArc(double theta, double first, double last, bool cw) const;
|
||||
|
||||
void extractVerts(HLRBRep_Algo *myAlgo, const TopoDS_Shape &S, HLRBRep_EdgeData& ed, int ie, ExtractionType extractionType);
|
||||
void extractEdges(HLRBRep_Algo *myAlgo, const TopoDS_Shape &S, int type, bool visible, ExtractionType extractionType);
|
||||
|
||||
void extractFaces(HLRBRep_Algo *myAlgo,
|
||||
const TopoDS_Shape &S,
|
||||
bool visible,
|
||||
ExtractionType extractionType,
|
||||
std::vector<TechDrawGeometry::Face *> &projFaces,
|
||||
std::vector<int> &faceRefs) const;
|
||||
|
||||
int calculateGeometry(const TopoDS_Shape &input, ExtractionType extractionType, std::vector<BaseGeom *> &geoms) const;
|
||||
|
||||
/// Accumulate edges from input and store them in wires
|
||||
void createWire(const TopoDS_Shape &input, std::vector<TopoDS_Wire> &wiresOut) const;
|
||||
|
||||
// Geometry
|
||||
std::vector<BaseGeom *> edgeGeom;
|
||||
std::vector<Vertex *> vertexGeom;
|
||||
|
@ -148,7 +124,7 @@ protected:
|
|||
std::vector<int> edgeReferences;
|
||||
std::vector<int> faceReferences;
|
||||
|
||||
HLRBRep_Algo *brep_hlr;
|
||||
Handle_HLRBRep_Algo brep_hlr;
|
||||
double Tolerance;
|
||||
double Scale;
|
||||
|
||||
|
|
|
@ -111,11 +111,10 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//TODO: do all these validations have to be accessible from Python?
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
|
||||
if (edgeType) {
|
||||
if (edgeType < isCircle) {
|
||||
|
@ -187,12 +186,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -240,11 +234,10 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
if (edgeType == isCircle) {
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false); if (edgeType == isCircle) {
|
||||
centerLine = true;
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
|
@ -272,11 +265,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -325,11 +314,10 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
if (edgeType == isCircle) {
|
||||
centerLine = true;
|
||||
objs.push_back(objFeat);
|
||||
|
@ -358,12 +346,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -413,10 +396,10 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
if ((edgeType == isHorizontal) ||
|
||||
(edgeType == isVertical) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
|
@ -451,12 +434,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -505,10 +483,10 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
if ((edgeType == isHorizontal) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
objs.push_back(objFeat);
|
||||
|
@ -541,12 +519,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -596,10 +569,10 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
if ((edgeType == isVertical) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
objs.push_back(objFeat);
|
||||
|
@ -631,12 +604,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -685,10 +653,10 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//selected edge(s) must have valid reference to Source edge for True Dimension
|
||||
//otherwise Dimension must be Projected
|
||||
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
int edgeType = _isValidEdgeToEdge(this,trueDimAllowed);
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
if (edgeType == isAngle) {
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
|
@ -711,12 +679,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
// make a True dimension if you can, Projected otherwise
|
||||
if (trueDimAllowed) {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
|
|
@ -485,6 +485,7 @@ void MDIViewPage::selectionChanged()
|
|||
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str()));
|
||||
//Base::Console().Message("TRACE - MDIVP::selectionChanged - selection: %s\n",ss.str().c_str());
|
||||
}
|
||||
|
||||
QGIVertex *vert = dynamic_cast<QGIVertex *>(*it);
|
||||
|
|
|
@ -48,9 +48,11 @@
|
|||
#include "../App/DrawUtil.h"
|
||||
#include "../App/DrawViewPart.h"
|
||||
#include "../App/DrawHatch.h"
|
||||
#include "../App/Geometry.h"
|
||||
#include "QGIViewPart.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
void _dumpPath(const char* text,QPainterPath path);
|
||||
|
||||
|
@ -384,33 +386,39 @@ void QGIViewPart::drawViewPart()
|
|||
// Draw Edges
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
const std::vector<int> &refs = viewPart->getEdgeReferences();
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator it = geoms.begin();
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
QGIEdge* item;
|
||||
|
||||
for(int i = 0 ; it != geoms.end(); ++it, i++) {
|
||||
//TODO: investigate if an Edge can be both Hidden and Smooth???
|
||||
if(((*it)->extractType == TechDrawGeometry::Plain) ||
|
||||
(((*it)->extractType == TechDrawGeometry::WithHidden) && viewPart->ShowHiddenLines.getValue()) ||
|
||||
((*it)->extractType == TechDrawGeometry::WithSmooth)) {
|
||||
// (((*it)->extractType == TechDrawGeometry::WithSmooth) && part->ShowSmoothLines.getValue())) {
|
||||
//item = new QGIEdge(refs.at(i));
|
||||
for(int i = 0 ; itEdge != geoms.end(); itEdge++, i++) {
|
||||
bool showEdge = false;
|
||||
if ((*itEdge)->visible) {
|
||||
if (((*itEdge)->classOfEdge == ecHARD) ||
|
||||
((*itEdge)->classOfEdge == ecOUTLINE) ||
|
||||
(((*itEdge)->classOfEdge == ecSMOOTH) && viewPart->ShowSmoothLines.getValue()) ||
|
||||
(((*itEdge)->classOfEdge == ecSEAM) && viewPart->ShowSeamLines.getValue())) {
|
||||
showEdge = true;
|
||||
}
|
||||
} else {
|
||||
if (viewPart->ShowHiddenLines.getValue()) {
|
||||
showEdge = true;
|
||||
}
|
||||
}
|
||||
if (showEdge) {
|
||||
item = new QGIEdge(i);
|
||||
item->setReference(refs.at(i));
|
||||
addToGroup(item); //item is at scene(0,0), not group(0,0)
|
||||
item->setPos(0.0,0.0);
|
||||
item->setStrokeWidth(lineWidth);
|
||||
if((*it)->extractType == TechDrawGeometry::WithHidden) {
|
||||
if(!(*itEdge)->visible) {
|
||||
item->setStrokeWidth(lineWidthHid);
|
||||
item->setHiddenEdge(true);
|
||||
} else if((*it)->extractType == TechDrawGeometry::WithSmooth) {
|
||||
item->setSmoothEdge(true);
|
||||
}
|
||||
item->setPath(drawPainterPath(*it));
|
||||
item->setPath(drawPainterPath(*itEdge));
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
item->setAcceptHoverEvents(true);
|
||||
|
||||
//debug a path
|
||||
//QPainterPath edgePath=drawPainterPath(*it);
|
||||
//QPainterPath edgePath=drawPainterPath(*itEdge);
|
||||
//item->setPath(edgePath);
|
||||
//std::stringstream edgeId;
|
||||
//edgeId << "edge" << i;
|
||||
|
@ -422,7 +430,6 @@ void QGIViewPart::drawViewPart()
|
|||
const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
const std::vector<int> &vertRefs = viewPart->getVertexReferences();
|
||||
std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin();
|
||||
|
||||
for(int i = 0 ; vert != verts.end(); ++vert, i++) {
|
||||
QGIVertex *item = new QGIVertex(i);
|
||||
item->setReference(vertRefs.at(i));
|
||||
|
|
|
@ -72,11 +72,11 @@ void QGIViewSection::drawSectionFace()
|
|||
|
||||
//Base::Console().Log("drawing section face\n");
|
||||
|
||||
// Get the section face from the feature
|
||||
std::vector<TechDrawGeometry::Face *> faceGeoms;
|
||||
part->getSectionSurface(faceGeoms);
|
||||
if (faceGeoms.empty()) {
|
||||
Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No Face available. Check Section plane.\n");
|
||||
// Get the section faces from the feature
|
||||
std::vector<TechDrawGeometry::Face *> sectionFaces;
|
||||
//part->getSectionFaces(faceGeoms);
|
||||
if (sectionFaces.empty()) {
|
||||
Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ void QGIViewSection::drawSectionFace()
|
|||
|
||||
if(graphicsItem) {
|
||||
// Hide any edges that are hidden if option is set.
|
||||
// if((*fit)->extractType == TechDrawGeometry::WithHidden && !part->ShowHiddenLines.getValue())
|
||||
// if(!(*fit)->visible && !part->ShowHiddenLines.getValue())
|
||||
// graphicsItem->hide();
|
||||
|
||||
addToGroup(graphicsItem);
|
||||
|
|
Loading…
Reference in New Issue
Block a user