[TD]Handle missing XDirection on old files
This commit is contained in:
@@ -131,10 +131,19 @@ bool DrawProjGroupItem::showLock(void) const
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DPGI::execute(%s)\n",Label.getValue());
|
||||
|
||||
bool haveX = checkXDirection();
|
||||
if (!haveX) {
|
||||
//block touch/onChanged stuff
|
||||
Base::Vector3d newX = getXDirection();
|
||||
XDirection.setValue(newX);
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
|
||||
if (DrawUtil::checkParallel(Direction.getValue(),
|
||||
getXDirection())) {
|
||||
return new App::DocumentObjectExecReturn("DPGI: Direction and XDirection are parallel");
|
||||
|
||||
@@ -216,6 +216,15 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
bool haveX = checkXDirection();
|
||||
if (!haveX) {
|
||||
//block touch/onChanged stuff
|
||||
Base::Vector3d newX = getXDirection();
|
||||
XDirection.setValue(newX);
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
|
||||
Base::Vector3d anchor = AnchorPoint.getValue(); //this is a 2D point (in unrotated coords)
|
||||
Base::Vector3d dirDetail = dvp->Direction.getValue();
|
||||
|
||||
|
||||
@@ -241,9 +241,16 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
checkXDirection();
|
||||
bool haveX = checkXDirection();
|
||||
if (!haveX) {
|
||||
//block touch/onChanged stuff
|
||||
Base::Vector3d newX = getXDirection();
|
||||
XDirection.setValue(newX);
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
|
||||
m_saveShape = shape;
|
||||
// m_saveShape = shape;
|
||||
geometryObject = makeGeometryForShape(shape);
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
@@ -321,6 +328,7 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape shape)
|
||||
//center shape on origin
|
||||
TopoDS_Shape centeredShape = TechDraw::moveShape(shape,
|
||||
centroid * -1.0);
|
||||
m_saveShape = centeredShape;
|
||||
|
||||
TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape,
|
||||
getScale());
|
||||
@@ -919,7 +927,7 @@ bool DrawViewPart::checkXDirection(void) const
|
||||
Base::Vector3d origin(0.0,0.0,0.0);
|
||||
Base::Vector3d xDir = getLegacyX(origin,
|
||||
dir);
|
||||
Base::Console().Warning("DVP - %s - XDirection property not set. Try %s\n",
|
||||
Base::Console().Warning("DVP - %s - XDirection property not set. Trying %s\n",
|
||||
getNameInDocument(),
|
||||
DrawUtil::formatVector(xDir).c_str());
|
||||
return false;
|
||||
|
||||
@@ -242,7 +242,15 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
return new App::DocumentObjectExecReturn("BaseView Source object is Null");
|
||||
}
|
||||
|
||||
checkXDirection();
|
||||
// checkXDirection();
|
||||
bool haveX = checkXDirection();
|
||||
if (!haveX) {
|
||||
//block touch/onChanged stuff
|
||||
Base::Vector3d newX = getXDirection();
|
||||
XDirection.setValue(newX);
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
|
||||
//is SectionOrigin valid?
|
||||
Bnd_Box centerBox;
|
||||
@@ -305,7 +313,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
|
||||
Base::Vector3d origin(0.0, 0.0, 0.0);
|
||||
viewAxis = getProjectionCS(origin);
|
||||
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
scaledShape = TechDraw::rotateShape(scaledShape,
|
||||
viewAxis,
|
||||
@@ -569,6 +576,35 @@ bool DrawViewSection::isReallyInBox (const gp_Pnt p, const Bnd_Box& bb) const
|
||||
return !bb.IsOut(p);
|
||||
}
|
||||
|
||||
Base::Vector3d DrawViewSection::getXDirection(void) const
|
||||
{
|
||||
// Base::Console().Message("DVS::getXDirection() - %s\n", Label.getValue());
|
||||
Base::Vector3d result(1.0, 0.0, 0.0); //default X
|
||||
App::Property* prop = getPropertyByName("XDirection");
|
||||
if (prop != nullptr) { //have an XDirection property
|
||||
Base::Vector3d propVal = XDirection.getValue();
|
||||
if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //but it has no value
|
||||
std::string sectName = SectionDirection.getValueAsString();
|
||||
gp_Ax2 cs = getCSFromBase(sectName);
|
||||
gp_Dir gXDir = cs.XDirection();
|
||||
result = Base::Vector3d(gXDir.X(),
|
||||
gXDir.Y(),
|
||||
gXDir.Z());
|
||||
} else {
|
||||
result = propVal; //normal case. XDirection is set.
|
||||
}
|
||||
} else { //no Property. can this happen?
|
||||
std::string sectName = SectionDirection.getValueAsString();
|
||||
gp_Ax2 cs = getCSFromBase(sectName);
|
||||
gp_Dir gXDir = cs.XDirection();
|
||||
result = Base::Vector3d(gXDir.X(),
|
||||
gXDir.Y(),
|
||||
gXDir.Z());
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewSection::setCSFromBase(const std::string sectionName)
|
||||
{
|
||||
// Base::Console().Message("DVS::setCSFromBase(%s)\n", sectionName.c_str());
|
||||
@@ -586,7 +622,7 @@ void DrawViewSection::setCSFromBase(const std::string sectionName)
|
||||
XDirection.setValue(vXDir);
|
||||
}
|
||||
|
||||
gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName)
|
||||
gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const
|
||||
{
|
||||
// Base::Console().Message("DVS::getCSFromBase(%s)\n", sectionName.c_str());
|
||||
Base::Vector3d sectionNormal;
|
||||
@@ -663,7 +699,6 @@ gp_Ax2 DrawViewSection::getSectionCS(void) const
|
||||
catch (...) {
|
||||
Base::Console().Warning("DVS::getSectionCS - %s - failed to create section CS\n", getNameInDocument());
|
||||
}
|
||||
|
||||
return sectionCS;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,12 +91,13 @@ public:
|
||||
std::vector<TechDraw::Face*> getFaceGeometry();
|
||||
|
||||
void setCSFromBase(const std::string sectionName);
|
||||
gp_Ax2 getCSFromBase(const std::string sectionName);
|
||||
gp_Ax2 getCSFromBase(const std::string sectionName) const;
|
||||
|
||||
gp_Ax2 rotateCSArbitrary(gp_Ax2 oldCS,
|
||||
Base::Vector3d axis,
|
||||
double degAngle) const;
|
||||
gp_Ax2 getSectionCS() const;
|
||||
virtual Base::Vector3d getXDirection(void) const override; //don't use XDirection.getValue()
|
||||
|
||||
TechDraw::DrawViewPart* getBaseDVP() const;
|
||||
TechDraw::DrawProjGroupItem* getBaseDPGI() const;
|
||||
|
||||
Reference in New Issue
Block a user