Sketcher: Carbon Copy

=====================

Carbon copy checks for parallel planes, translated origin and rotated axes, so that it can provide flipping detection when using reverse mappings.

This commit enables you to press CTRL will activating the tool in order to bypass this checks. Without the checks you will get a sketch exactly as the one
you want to copy, there are no corrections at all. This enables you to copy a profile on a new plane at a different direction for example for lofting purposes.
This commit is contained in:
Abdullah Tahiri
2017-04-09 15:25:34 +02:00
committed by wmayer
parent 1810164d60
commit fdf040f5b7
3 changed files with 12 additions and 8 deletions

View File

@@ -99,6 +99,7 @@ SketchObject::SketchObject()
ADD_PROPERTY_TYPE(ExternalGeometry,(0,0),"Sketch",(App::PropertyType)(App::Prop_None),"Sketch external geometry");
allowOtherBody = true;
allowUnaligned = true;
for (std::vector<Part::Geometry *>::iterator it=ExternalGeo.begin(); it != ExternalGeo.end(); ++it)
if (*it) delete *it;
@@ -2083,14 +2084,14 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject
double doty = sy * ly;
// the planes of the sketches must be parallel
if(dot != 1.0 && dot != -1.0) {
if(!allowUnaligned && dot != 1.0 && dot != -1.0) {
if (rsn)
*rsn = rlNonParallel;
return false;
}
// the axis must be aligned
if( (dotx != 1.0 && dotx != -1.0) || (doty != 1.0 && doty != -1.0)) {
if(!allowUnaligned && ((dotx != 1.0 && dotx != -1.0) || (doty != 1.0 && doty != -1.0))) {
if (rsn)
*rsn = rlAxesMisaligned;
return false;
@@ -2102,14 +2103,14 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject
double alignment = ddir * lnormal;
if( (alignment != 1.0 && alignment != -1.0) && (psObj->Placement.getValue().getPosition() != this->Placement.getValue().getPosition()) ){
if(!allowUnaligned && (alignment != 1.0 && alignment != -1.0) && (psObj->Placement.getValue().getPosition() != this->Placement.getValue().getPosition()) ){
if (rsn)
*rsn = rlOriginsMisaligned;
return false;
}
xinv = (dotx == 1.0);
yinv = (doty == 1.0);
xinv = allowUnaligned?false:(dotx == 1.0);
yinv = allowUnaligned?false:(doty == 1.0);
return true;
}

View File

@@ -302,6 +302,8 @@ public:
/// Flag to allow external geometry from other bodies than the one this sketch belongs to
bool allowOtherBody;
/// Flag to allow carbon copy from misaligned geometry
bool allowUnaligned;
enum eReasonList{
rlAllowed,

View File

@@ -6199,6 +6199,7 @@ namespace SketcherGui {
Sketcher::SketchObject *sketch = static_cast<Sketcher::SketchObject*>(object);
sketch->allowOtherBody = false;
sketch->allowUnaligned = (QApplication::keyboardModifiers() == Qt::ControlModifier);
this->notAllowedReason = "";
Sketcher::SketchObject::eReasonList msg;
@@ -6219,13 +6220,13 @@ namespace SketcherGui {
this->notAllowedReason = QT_TR_NOOP("This object belongs to another part.");
break;
case Sketcher::SketchObject::rlNonParallel:
this->notAllowedReason = QT_TR_NOOP("The selected sketch is not parallel to this sketch.");
this->notAllowedReason = QT_TR_NOOP("The selected sketch is not parallel to this sketch. Hold Ctrl to allow non-parallel sketchs.");
break;
case Sketcher::SketchObject::rlAxesMisaligned:
this->notAllowedReason = QT_TR_NOOP("The XY axes of the selected sketch do not have the same direction as this sketch.");
this->notAllowedReason = QT_TR_NOOP("The XY axes of the selected sketch do not have the same direction as this sketch. Hold Ctrl to disregard it.");
break;
case Sketcher::SketchObject::rlOriginsMisaligned:
this->notAllowedReason = QT_TR_NOOP("The origin of the selected sketch is not aligned with the origin of this sketch.");
this->notAllowedReason = QT_TR_NOOP("The origin of the selected sketch is not aligned with the origin of this sketch. Hold Ctrl to disregard it.");
break;
default:
break;