add intersection-toggle to thickness-tool

see: “Thickness tools is missing intersection-toogle”
https://forum.freecadweb.org/viewtopic.php?f=19&t=37952
This commit is contained in:
Matthias Berberich
2019-07-31 12:41:17 +02:00
committed by wmayer
parent c53d3074ae
commit b01ebbc01e
5 changed files with 44 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ Thickness::Thickness()
ADD_PROPERTY_TYPE(Join,(long(0)),"Thickness",App::Prop_None,"Join type"); ADD_PROPERTY_TYPE(Join,(long(0)),"Thickness",App::Prop_None,"Join type");
Join.setEnums(JoinEnums); Join.setEnums(JoinEnums);
ADD_PROPERTY_TYPE(Reversed,(false),"Thickness",App::Prop_None,"Apply the thickness towards the solids interior"); ADD_PROPERTY_TYPE(Reversed,(false),"Thickness",App::Prop_None,"Apply the thickness towards the solids interior");
ADD_PROPERTY_TYPE(Intersection,(false),"Thickness",App::Prop_None,"Enable intersection-handling");
} }
short Thickness::mustExecute() const short Thickness::mustExecute() const
@@ -76,6 +77,7 @@ App::DocumentObjectExecReturn *Thickness::execute(void)
} }
bool reversed = Reversed.getValue(); bool reversed = Reversed.getValue();
bool intersection = Intersection.getValue();
double thickness = (reversed ? -1. : 1. )*Value.getValue(); double thickness = (reversed ? -1. : 1. )*Value.getValue();
double tol = Precision::Confusion(); double tol = Precision::Confusion();
short mode = (short)Mode.getValue(); short mode = (short)Mode.getValue();
@@ -85,7 +87,7 @@ App::DocumentObjectExecReturn *Thickness::execute(void)
join = 2; join = 2;
if (fabs(thickness) > 2*tol) if (fabs(thickness) > 2*tol)
this->Shape.setValue(getSolid(TopShape.makeThickSolid(closingFaces, thickness, tol, false, false, mode, join))); this->Shape.setValue(getSolid(TopShape.makeThickSolid(closingFaces, thickness, tol, intersection, false, mode, join)));
else else
this->Shape.setValue(getSolid(TopShape.getShape())); this->Shape.setValue(getSolid(TopShape.getShape()));
return App::DocumentObject::StdReturn; return App::DocumentObject::StdReturn;

View File

@@ -41,6 +41,7 @@ public:
App::PropertyLength Value; App::PropertyLength Value;
App::PropertyBool Reversed; App::PropertyBool Reversed;
App::PropertyBool Intersection;
App::PropertyEnumeration Mode; App::PropertyEnumeration Mode;
App::PropertyEnumeration Join; App::PropertyEnumeration Join;

View File

@@ -73,6 +73,9 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
bool r = pcThickness->Reversed.getValue(); bool r = pcThickness->Reversed.getValue();
ui->checkReverse->setChecked(r); ui->checkReverse->setChecked(r);
bool i = pcThickness->Intersection.getValue();
ui->checkIntersection->setChecked(i);
std::vector<std::string> strings = pcThickness->Base.getSubValues(); std::vector<std::string> strings = pcThickness->Base.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++) for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
{ {
@@ -85,6 +88,8 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
this, SLOT(onValueChanged(double))); this, SLOT(onValueChanged(double)));
connect(ui->checkReverse, SIGNAL(toggled(bool)), connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onReversedChanged(bool))); this, SLOT(onReversedChanged(bool)));
connect(ui->checkIntersection, SIGNAL(toggled(bool)),
this, SLOT(onIntersectionChanged(bool)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool))); this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
@@ -192,6 +197,18 @@ bool TaskThicknessParameters::getReversed(void) const
return ui->checkReverse->isChecked(); return ui->checkReverse->isChecked();
} }
void TaskThicknessParameters::onIntersectionChanged(const bool on) {
clearButtons(none);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
pcThickness->Intersection.setValue(on);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
bool TaskThicknessParameters::getIntersection(void) const
{
return ui->checkIntersection->isChecked();
}
int TaskThicknessParameters::getJoinType(void) const { int TaskThicknessParameters::getJoinType(void) const {
return ui->joinComboBox->currentIndex(); return ui->joinComboBox->currentIndex();
@@ -264,6 +281,7 @@ bool TaskDlgThicknessParameters::accept()
FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue()); FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue());
FCMD_OBJ_CMD(obj,"Reversed = " << draftparameter->getReversed()); FCMD_OBJ_CMD(obj,"Reversed = " << draftparameter->getReversed());
FCMD_OBJ_CMD(obj,"Mode = " << draftparameter->getMode()); FCMD_OBJ_CMD(obj,"Mode = " << draftparameter->getMode());
FCMD_OBJ_CMD(obj,"Intersection = " << draftparameter->getIntersection());
FCMD_OBJ_CMD(obj,"Join = " << draftparameter->getJoinType()); FCMD_OBJ_CMD(obj,"Join = " << draftparameter->getJoinType());
return TaskDlgDressUpParameters::accept(); return TaskDlgDressUpParameters::accept();

View File

@@ -41,6 +41,7 @@ public:
double getValue(void) const; double getValue(void) const;
bool getReversed(void) const; bool getReversed(void) const;
bool getIntersection(void) const;
int getMode(void) const; int getMode(void) const;
int getJoinType(void) const; int getJoinType(void) const;
@@ -49,6 +50,7 @@ private Q_SLOTS:
void onModeChanged(int mode); void onModeChanged(int mode);
void onJoinTypeChanged(int join); void onJoinTypeChanged(int join);
void onReversedChanged(bool reversed); void onReversedChanged(bool reversed);
void onIntersectionChanged(bool intersection);
void onRefDeleted(void); void onRefDeleted(void);
protected: protected:

View File

@@ -52,6 +52,9 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="Value" native="true"> <widget class="Gui::QuantitySpinBox" name="Value" native="true">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="unit" stdset="0"> <property name="unit" stdset="0">
<string notr="true">mm</string> <string notr="true">mm</string>
</property> </property>
@@ -118,6 +121,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="checkIntersection">
<property name="text">
<string>Intersection</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkReverse"> <widget class="QCheckBox" name="checkReverse">
<property name="text"> <property name="text">
@@ -134,6 +144,16 @@
<header>Gui/QuantitySpinBox.h</header> <header>Gui/QuantitySpinBox.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>Value</tabstop>
<tabstop>modeComboBox</tabstop>
<tabstop>joinComboBox</tabstop>
<tabstop>checkIntersection</tabstop>
<tabstop>checkReverse</tabstop>
<tabstop>buttonRefAdd</tabstop>
<tabstop>buttonRefRemove</tabstop>
<tabstop>listWidgetReferences</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>