[PD] some fixes for the new pad length feature

- disable 2 properties when no custom direction is used
- rename a property because its name is the opposite of what it is doing
This commit is contained in:
donovaly
2021-03-23 02:05:12 +01:00
committed by wwmayer
parent 3b4e96d4a7
commit 00a7221a95
4 changed files with 21 additions and 13 deletions

View File

@@ -68,9 +68,9 @@ Pad::Pad()
Type.setEnums(TypeEnums);
ADD_PROPERTY_TYPE(Length, (100.0), "Pad", App::Prop_None,"Pad length");
ADD_PROPERTY_TYPE(Length2, (100.0), "Pad", App::Prop_None,"Second Pad length");
ADD_PROPERTY_TYPE(UseCustomVector, (0), "Pad", App::Prop_None, "Use custom vector for pad direction");
ADD_PROPERTY_TYPE(UseCustomVector, (false), "Pad", App::Prop_None, "Use custom vector for pad direction");
ADD_PROPERTY_TYPE(Direction, (Base::Vector3d(1.0, 1.0, 1.0)), "Pad", App::Prop_None, "Pad direction vector");
ADD_PROPERTY_TYPE(AlongCustomVector, (true), "Pad", App::Prop_None, "Measure length along custom direction vector");
ADD_PROPERTY_TYPE(AlongSketchNormal, (true), "Pad", App::Prop_None, "Measure pad length along the sketch normal direction");
ADD_PROPERTY_TYPE(UpToFace, (0), "Pad", App::Prop_None, "Face where pad will end");
ADD_PROPERTY_TYPE(Offset, (0.0), "Pad", App::Prop_None, "Offset from face in which pad will end");
static const App::PropertyQuantityConstraint::Constraints signedLengthConstraint = {-DBL_MAX, DBL_MAX, 1.0};
@@ -79,6 +79,10 @@ Pad::Pad()
// Remove the constraints and keep the type to allow to accept negative values
// https://forum.freecadweb.org/viewtopic.php?f=3&t=52075&p=448410#p447636
Length2.setConstraints(nullptr);
// for new pads UseCustomVector is false, thus disable Direction and AlongSketchNormal
AlongSketchNormal.setReadOnly(true);
Direction.setReadOnly(true);
}
short Pad::mustExecute() const
@@ -89,7 +93,7 @@ short Pad::mustExecute() const
Length2.isTouched() ||
UseCustomVector.isTouched() ||
Direction.isTouched() ||
AlongCustomVector.isTouched() ||
AlongSketchNormal.isTouched() ||
Offset.isTouched() ||
UpToFace.isTouched())
return 1;
@@ -159,6 +163,10 @@ App::DocumentObjectExecReturn *Pad::execute(void)
paddingDirection = Direction.getValue();
}
// disable options of UseCustomVector
AlongSketchNormal.setReadOnly(!UseCustomVector.getValue());
Direction.setReadOnly(!UseCustomVector.getValue());
// create vector in padding direction with length 1
gp_Dir dir(paddingDirection.x, paddingDirection.y, paddingDirection.z);
@@ -178,7 +186,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
return new App::DocumentObjectExecReturn("Pad: Creation failed because direction is orthogonal to sketch's normal vector");
// perform the length correction if not along custom vector
if (AlongCustomVector.getValue()) {
if (AlongSketchNormal.getValue()) {
L = L / factor;
L2 = L2 / factor;
}

View File

@@ -45,7 +45,7 @@ public:
App::PropertyLength Length2;
App::PropertyBool UseCustomVector;
App::PropertyVector Direction;
App::PropertyBool AlongCustomVector;
App::PropertyBool AlongSketchNormal;
App::PropertyLength Offset;
/** @name methods override feature */

View File

@@ -75,7 +75,7 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView, QWidget *parent,
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
Base::Quantity l = pcPad->Length.getQuantityValue();
Base::Quantity l2 = pcPad->Length2.getQuantityValue();
bool alongCustom = pcPad->AlongCustomVector.getValue();
bool alongCustom = pcPad->AlongSketchNormal.getValue();
bool useCustom = pcPad->UseCustomVector.getValue();
double xs = pcPad->Direction.getValue().x;
double ys = pcPad->Direction.getValue().y;
@@ -157,7 +157,7 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView, QWidget *parent,
connect(ui->lengthEdit2, SIGNAL(valueChanged(double)),
this, SLOT(onLength2Changed(double)));
connect(ui->checkBoxAlongDirection, SIGNAL(toggled(bool)),
this, SLOT(onAlongDirectionChanged(bool)));
this, SLOT(onAlongSketchNormalChanged(bool)));
connect(ui->groupBoxDirection, SIGNAL(toggled(bool)),
this, SLOT(onDirectionToggled(bool)));
connect(ui->XDirectionEdit, SIGNAL(valueChanged(double)),
@@ -310,10 +310,10 @@ void TaskPadParameters::onLength2Changed(double len)
recomputeFeature();
}
void TaskPadParameters::onAlongDirectionChanged(bool on)
void TaskPadParameters::onAlongSketchNormalChanged(bool on)
{
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
pcPad->AlongCustomVector.setValue(on);
pcPad->AlongSketchNormal.setValue(on);
recomputeFeature();
}
@@ -466,7 +466,7 @@ double TaskPadParameters::getLength2(void) const
return ui->lengthEdit2->value().getValue();
}
bool TaskPadParameters::getAlongCustom(void) const
bool TaskPadParameters::getAlongSketchNormal(void) const
{
return ui->checkBoxAlongDirection->isChecked();
}
@@ -602,7 +602,7 @@ void TaskPadParameters::apply()
FCMD_OBJ_CMD(obj, "UseCustomVector = " << (getCustom() ? 1 : 0));
FCMD_OBJ_CMD(obj, "Direction = ("
<< getXDirection() << ", " << getYDirection() << ", " << getZDirection() << ")");
FCMD_OBJ_CMD(obj, "AlongCustomVector = " << (getAlongCustom() ? 1 : 0));
FCMD_OBJ_CMD(obj, "AlongSketchNormal = " << (getAlongSketchNormal() ? 1 : 0));
FCMD_OBJ_CMD(obj,"Type = " << getMode());
QString facename = getFaceName();
FCMD_OBJ_CMD(obj,"UpToFace = " << facename.toLatin1().data());

View File

@@ -58,7 +58,7 @@ public:
private Q_SLOTS:
void onLengthChanged(double);
void onLength2Changed(double);
void onAlongDirectionChanged(bool);
void onAlongSketchNormalChanged(bool);
void onDirectionToggled(bool);
void onXDirectionEditChanged(double);
void onYDirectionEditChanged(double);
@@ -76,7 +76,7 @@ protected:
private:
double getLength(void) const;
double getLength2(void) const;
bool getAlongCustom(void) const;
bool getAlongSketchNormal(void) const;
bool getCustom(void) const;
double getXDirection(void) const;
double getYDirection(void) const;