Merge pull request #11796 from WandererFan/HybridDimError
[TD]Fix Landmark Dimension #11783
This commit is contained in:
@@ -87,19 +87,16 @@ short LandmarkDimension::mustExecute() const
|
||||
|
||||
App::DocumentObjectExecReturn *LandmarkDimension::execute()
|
||||
{
|
||||
Base::Console().Message("LD::execute() - %s\n", getNameInDocument());
|
||||
if (!keepUpdated()) {
|
||||
// Base::Console().Message("LD::execute() - %s\n", getNameInDocument());
|
||||
if (!okToProceed()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
DrawViewPart* dvp = getViewPart();
|
||||
if (!dvp) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
References2D.setValue(dvp);
|
||||
|
||||
std::vector<DocumentObject*> features = References3D.getValues();
|
||||
Base::Console().Message("LD::execute - features: %d\n", features.size());
|
||||
// Base::Console().Message("LD::execute - features: %d\n", features.size());
|
||||
//if distance, required size = 2
|
||||
//if angle, required size = 3; //not implemented yet
|
||||
unsigned int requiredSize = 2;
|
||||
@@ -130,18 +127,18 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute()
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Base::Console().Message("LD::execute - front: %s back: %s\n",
|
||||
DrawUtil::formatVector(points.front()).c_str(),
|
||||
DrawUtil::formatVector(points.back()).c_str());
|
||||
// Base::Console().Message("LD::execute - front: %s back: %s\n",
|
||||
// DrawUtil::formatVector(points.front()).c_str(),
|
||||
// DrawUtil::formatVector(points.back()).c_str());
|
||||
setLinearPoints(points.front(), points.back());
|
||||
|
||||
App::DocumentObjectExecReturn* dvdResult = DrawViewDimension::execute();
|
||||
// App::DocumentObjectExecReturn* dvdResult = DrawViewDimension::execute();
|
||||
|
||||
dvp->addReferencesToGeom();
|
||||
dvp->requestPaint();
|
||||
// dvp->requestPaint();
|
||||
|
||||
overrideKeepUpdated(false);
|
||||
return dvdResult;
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawViewPart* dvp) const
|
||||
|
||||
@@ -406,13 +406,15 @@ bool ShapeExtractor::isEdgeType(App::DocumentObject* obj)
|
||||
|
||||
bool ShapeExtractor::isPointType(App::DocumentObject* obj)
|
||||
{
|
||||
// Base::Console().Message("SE::isPointType(%s)\n", obj->getNameInDocument());
|
||||
// Base::Console().Message("SE::isPointType(%s)\n", obj->getNameInDocument());
|
||||
if (obj) {
|
||||
Base::Type t = obj->getTypeId();
|
||||
if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) {
|
||||
return true;
|
||||
} else if (isDraftPoint(obj)) {
|
||||
return true;
|
||||
} else if (isDatumPoint(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -433,11 +435,21 @@ bool ShapeExtractor::isDraftPoint(App::DocumentObject* obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShapeExtractor::isDatumPoint(App::DocumentObject* obj)
|
||||
{
|
||||
std::string objTypeName = obj->getTypeId().getName();
|
||||
std::string pointToken("Point");
|
||||
if (objTypeName.find(pointToken) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! get the location of a point object
|
||||
Base::Vector3d ShapeExtractor::getLocation3dFromFeat(App::DocumentObject* obj)
|
||||
{
|
||||
Base::Console().Message("SE::getLocation3dFromFeat()\n");
|
||||
// Base::Console().Message("SE::getLocation3dFromFeat()\n");
|
||||
if (!isPointType(obj)) {
|
||||
return Base::Vector3d(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
static bool isEdgeType(App::DocumentObject* obj);
|
||||
static bool isPointType(App::DocumentObject* obj);
|
||||
static bool isDraftPoint(App::DocumentObject* obj);
|
||||
static bool isDatumPoint(App::DocumentObject* obj);
|
||||
static Base::Vector3d getLocation3dFromFeat(App::DocumentObject *obj);
|
||||
|
||||
static TopoDS_Shape stripInfiniteShapes(TopoDS_Shape inShape);
|
||||
|
||||
@@ -429,7 +429,7 @@ void execDistance(Gui::Command* cmd)
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys(
|
||||
{isVertical, isHorizontal, isDiagonal});
|
||||
{isVertical, isHorizontal, isDiagonal, isHybrid});
|
||||
|
||||
//what 2d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
@@ -528,7 +528,7 @@ void execDistanceX(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isHorizontal, isDiagonal});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isHorizontal, isDiagonal, isHybrid});
|
||||
|
||||
//what 2d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
@@ -627,7 +627,7 @@ void execDistanceY(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isVertical, isDiagonal});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isVertical, isDiagonal, isHybrid});
|
||||
|
||||
//what 2d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
|
||||
@@ -278,7 +278,12 @@ bool TechDraw::checkGeometryOccurences(StringVector subNames, GeomCountMap keyed
|
||||
//return the first valid configuration contained in the already validated references
|
||||
DimensionGeometryType TechDraw::getGeometryConfiguration(ReferenceVector valid2dReferences)
|
||||
{
|
||||
DimensionGeometryType config = isValidMultiEdge(valid2dReferences);
|
||||
DimensionGeometryType config = isValidHybrid(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
return config;
|
||||
}
|
||||
|
||||
config = isValidMultiEdge(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
return config;
|
||||
}
|
||||
@@ -290,10 +295,6 @@ DimensionGeometryType TechDraw::getGeometryConfiguration(ReferenceVector valid2d
|
||||
if (config > isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidHybrid(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// no valid configuration found
|
||||
return isInvalid;
|
||||
@@ -660,7 +661,7 @@ DimensionGeometryType TechDraw::isValidHybrid(ReferenceVector refs)
|
||||
}
|
||||
if (vertexCount > 0 && edgeCount > 0) {
|
||||
//must be a diagonal dim? could it be isHorizontal or isVertical?
|
||||
return isDiagonal;
|
||||
return isHybrid;
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
@@ -670,7 +671,7 @@ DimensionGeometryType TechDraw::isValidHybrid(ReferenceVector refs)
|
||||
DimensionGeometryType TechDraw::isValidHybrid3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
{
|
||||
(void)dvp;
|
||||
//we don't have a special check for 3d in this case
|
||||
//we can reuse the 2d check here.
|
||||
return isValidHybrid(refs);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ enum DimensionGeometryEnum {
|
||||
isAngle3Pt,
|
||||
isMultiEdge,
|
||||
isZLimited,
|
||||
isHybrid,
|
||||
isViewReference //never needs to be specified in the acceptable list
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user