Fix Decoration positions on Views derived from DPG Base
- Section faces, detail highlights, center and section lines were wrong when the BaseView was a DPGI
This commit is contained in:
@@ -102,10 +102,6 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
{
|
||||
if (DrawUtil::checkParallel(Direction.getValue(),
|
||||
RotationVector.getValue())) {
|
||||
Base::Console().Message("TRACE - DPGI::execute - Projdir: %s X: %s\n",
|
||||
TechDraw::DrawUtil::formatVector(Direction.getValue()).c_str(),
|
||||
TechDraw::DrawUtil::formatVector(RotationVector.getValue()).c_str());
|
||||
|
||||
return new App::DocumentObjectExecReturn("DPGI: Direction and RotationVector are parallel");
|
||||
}
|
||||
|
||||
@@ -114,7 +110,6 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
|
||||
autoPosition();
|
||||
requestPaint();
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
@@ -122,10 +117,6 @@ void DrawProjGroupItem::autoPosition()
|
||||
{
|
||||
auto pgroup = getPGroup();
|
||||
Base::Vector3d newPos;
|
||||
// if (isAnchor()) {
|
||||
// X.setValue(0.0);
|
||||
// Y.setValue(0.0);
|
||||
// } else
|
||||
if ((pgroup != nullptr) &&
|
||||
(pgroup->AutoDistribute.getValue()) &&
|
||||
(!LockPosition.getValue())) {
|
||||
@@ -176,39 +167,32 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip) const
|
||||
{
|
||||
(void) flip;
|
||||
gp_Ax2 viewAxis;
|
||||
Base::Vector3d x = RotationVector.getValue();
|
||||
Base::Vector3d nx = x;
|
||||
x.Normalize();
|
||||
Base::Vector3d na = axis;
|
||||
na.Normalize();
|
||||
(void) flip;
|
||||
gp_Ax2 viewAxis;
|
||||
Base::Vector3d projDir = Direction.getValue();
|
||||
Base::Vector3d rotVec = RotationVector.getValue();
|
||||
|
||||
if (DrawUtil::checkParallel(nx,na)) {
|
||||
Base::Console().Warning("DPGI::getVA - axis and X parallel. using defaults\n");
|
||||
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,false);
|
||||
} else {
|
||||
viewAxis = TechDrawGeometry::getViewAxis(pt,na,nx,false);
|
||||
}
|
||||
// gp_Dir va_Main = viewAxis.Direction();
|
||||
// gp_Dir va_X = viewAxis.XDirection();
|
||||
// gp_Ax3 R3;
|
||||
// gp_Ax3 viewCS(viewAxis);
|
||||
// gp_Trsf txTo, txFrom;
|
||||
// txTo.SetTransformation(R3,viewCS);
|
||||
// txFrom = txTo.Inverted();
|
||||
// gp_Dir dirFrom = va_Main.Transformed(txFrom);
|
||||
// gp_Dir dirTo = va_Main.Transformed(txTo);
|
||||
// Base::Console().Message("TRACE - DPGI::getVA - dirFrom: %s dirTo: %s\n",
|
||||
// DrawUtil::formatVector(dirFrom).c_str(),
|
||||
// DrawUtil::formatVector(dirTo).c_str());
|
||||
// gp_Dir xFrom = va_X.Transformed(txFrom);
|
||||
// gp_Dir xTo = va_X.Transformed(txTo);
|
||||
// Base::Console().Message("TRACE - DPGI::getVA - xFrom: %s xTo: %s\n",
|
||||
// DrawUtil::formatVector(xFrom).c_str(),
|
||||
// DrawUtil::formatVector(xTo).c_str());
|
||||
// mirror projDir through XZ plane
|
||||
Base::Vector3d yNorm(0.0,1.0,0.0);
|
||||
projDir = projDir - (yNorm * 2.0) * (projDir.Dot(yNorm));
|
||||
rotVec = rotVec - (yNorm * 2.0) * (rotVec.Dot(yNorm));
|
||||
|
||||
return viewAxis;
|
||||
if (DrawUtil::checkParallel(projDir,rotVec)) {
|
||||
Base::Console().Warning("DPGI::getVA - %s - Direction and RotationVector parallel. using defaults\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
try {
|
||||
viewAxis = gp_Ax2(gp_Pnt(pt.x,pt.y,pt.z),
|
||||
gp_Dir(projDir.x, projDir.y, projDir.z),
|
||||
gp_Dir(rotVec.x, rotVec.y, rotVec.z));
|
||||
}
|
||||
catch (Standard_Failure& e4) {
|
||||
Base::Console().Message("PROBLEM - DPGI (%s) failed to create viewAxis: %s **\n",
|
||||
getNameInDocument(),e4.GetMessageString());
|
||||
return TechDrawGeometry::getViewAxis(pt,axis,false);
|
||||
}
|
||||
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
//obs??
|
||||
|
||||
@@ -246,8 +246,11 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
|
||||
inputCenter = TechDrawGeometry::findCentroid(shape,
|
||||
Direction.getValue());
|
||||
getViewAxis(stdOrg,Direction.getValue()));
|
||||
|
||||
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
|
||||
TopoDS_Shape mirroredShape;
|
||||
mirroredShape = TechDrawGeometry::mirrorShape(shape,
|
||||
@@ -332,6 +335,7 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape
|
||||
go->projectShape(shape,
|
||||
viewAxis);
|
||||
}
|
||||
|
||||
go->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines
|
||||
true);
|
||||
go->extractGeometry(TechDrawGeometry::ecOUTLINE,
|
||||
@@ -472,7 +476,7 @@ void DrawViewPart::extractFaces()
|
||||
ew.loadEdges(newEdges);
|
||||
bool success = ew.perform();
|
||||
if (!success) {
|
||||
Base::Console().Warning("DVP::extractFaces - input is not planar graph. No face detection\n");
|
||||
Base::Console().Warning("DVP::extractFaces - %s -Can't make faces from projected edges\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
|
||||
@@ -692,13 +696,7 @@ gp_Ax2 DrawViewPart::getViewAxis(const Base::Vector3d& pt,
|
||||
{
|
||||
gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip);
|
||||
|
||||
//put X dir of viewAxis on other side to get view right side up
|
||||
gp_Ax1 rotAxis(viewAxis.Location(),viewAxis.Direction());
|
||||
gp_Dir xDir = viewAxis.XDirection();
|
||||
gp_Dir newX = xDir.Rotated(rotAxis, M_PI);
|
||||
viewAxis.SetXDirection(newX);
|
||||
|
||||
return viewAxis;
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
void DrawViewPart::saveParamSpace(const Base::Vector3d& direction, const Base::Vector3d& xAxis)
|
||||
|
||||
@@ -161,18 +161,6 @@ void GeometryObject::clear()
|
||||
void GeometryObject::projectShape(const TopoDS_Shape& input,
|
||||
const gp_Ax2 viewAxis)
|
||||
{
|
||||
gp_Pnt org(0.0,0.0,0.0);
|
||||
gp_Dir stdY(0.0,1.0,0.0);
|
||||
gp_Dir stdX(1.0,0.0,0.0);
|
||||
|
||||
gp_Ax2 yPlane(org,stdY,stdX); //XZ plane
|
||||
gp_Dir va_Main = viewAxis.Direction();
|
||||
gp_Dir dirRev = va_Main.Mirrored(yPlane);
|
||||
gp_Dir va_X = viewAxis.XDirection();
|
||||
gp_Dir xRev = va_X.Mirrored(yPlane);
|
||||
|
||||
gp_Ax2 projAxis(org,dirRev,xRev);
|
||||
|
||||
// Clear previous Geometry
|
||||
clear();
|
||||
|
||||
@@ -184,10 +172,12 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
|
||||
brep_hlr->Add(input, m_isoCount);
|
||||
if (m_isPersp) {
|
||||
double fLength = std::max(Precision::Confusion(),m_focus);
|
||||
HLRAlgo_Projector projector( projAxis, fLength );
|
||||
// HLRAlgo_Projector projector( projAxis, fLength );
|
||||
HLRAlgo_Projector projector( viewAxis, fLength );
|
||||
brep_hlr->Projector(projector);
|
||||
} else {
|
||||
HLRAlgo_Projector projector( projAxis );
|
||||
// HLRAlgo_Projector projector( projAxis );
|
||||
HLRAlgo_Projector projector( viewAxis );
|
||||
brep_hlr->Projector(projector);
|
||||
}
|
||||
brep_hlr->Update();
|
||||
@@ -562,19 +552,29 @@ gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
const bool flip)
|
||||
{
|
||||
(void) flip;
|
||||
gp_Ax2 viewAxis;
|
||||
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
|
||||
Base::Vector3d stdZ(0.0,0.0,1.0);
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
Base::Vector3d flipDirection(direction.x,-direction.y,direction.z);
|
||||
flipDirection = Base::Vector3d(direction.x,direction.y,direction.z);
|
||||
if (!flip) {
|
||||
flipDirection = Base::Vector3d(direction.x,direction.y,direction.z);
|
||||
}
|
||||
Base::Vector3d cross = flipDirection;
|
||||
//special case
|
||||
// //special case
|
||||
if (TechDraw::DrawUtil::checkParallel(flipDirection, stdZ)) {
|
||||
cross = Base::Vector3d(1.0,0.0,0.0);
|
||||
} else {
|
||||
cross.Normalize();
|
||||
cross = cross.Cross(stdZ);
|
||||
}
|
||||
gp_Ax2 viewAxis;
|
||||
|
||||
if (cross.IsEqual(stdOrg,FLT_EPSILON)) {
|
||||
viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z));
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
|
||||
gp_Dir(cross.x, cross.y, cross.z));
|
||||
@@ -590,20 +590,14 @@ gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
{
|
||||
(void) flip;
|
||||
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
|
||||
Base::Vector3d projDir(direction.x,direction.y,direction.z);
|
||||
|
||||
gp_Ax2 viewAxis;
|
||||
|
||||
if (TechDraw::DrawUtil::checkParallel(projDir, xAxis)) {
|
||||
Base::Console().Warning("GO::getViewAxis2 - direction and axis parallel - using default VA\n");
|
||||
viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(projDir.x, projDir.y, projDir.z));
|
||||
|
||||
} else {
|
||||
viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(projDir.x, projDir.y, projDir.z),
|
||||
gp_Dir(xAxis.x, xAxis.y, xAxis.z));
|
||||
Base::Vector3d flipDirection(direction.x,-direction.y,direction.z);
|
||||
if (!flip) {
|
||||
flipDirection = Base::Vector3d(direction.x,direction.y,direction.z);
|
||||
}
|
||||
gp_Ax2 viewAxis;
|
||||
viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
|
||||
gp_Dir(xAxis.x, xAxis.y, xAxis.z));
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
@@ -613,6 +607,15 @@ gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
{
|
||||
Base::Vector3d origin(0.0,0.0,0.0);
|
||||
gp_Ax2 viewAxis = getViewAxis(origin,direction);
|
||||
return findCentroid(shape,viewAxis);
|
||||
}
|
||||
|
||||
//! Returns the centroid of shape, as viewed according to direction
|
||||
gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
const gp_Ax2 viewAxis)
|
||||
{
|
||||
// Base::Vector3d origin(0.0,0.0,0.0);
|
||||
// gp_Ax2 viewAxis = getViewAxis(origin,direction);
|
||||
|
||||
gp_Trsf tempTransform;
|
||||
tempTransform.SetTransformation(viewAxis);
|
||||
|
||||
@@ -66,6 +66,8 @@ TopoDS_Shape TechDrawExport moveShape(const TopoDS_Shape &input,
|
||||
//! Returns the centroid of shape, as viewed according to direction
|
||||
gp_Pnt TechDrawExport findCentroid(const TopoDS_Shape &shape,
|
||||
const Base::Vector3d &direction);
|
||||
gp_Pnt TechDrawExport findCentroid(const TopoDS_Shape &shape,
|
||||
const gp_Ax2 viewAxis);
|
||||
Base::Vector3d TechDrawExport findCentroidVec(const TopoDS_Shape &shape,
|
||||
const Base::Vector3d &direction);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user