Added chamfer angle support to PartDesign.
This commit is contained in:
committed by
abdullahtahiriyo
parent
29c5528fde
commit
cc82cf3e50
@@ -41,6 +41,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "FeatureChamfer.h"
|
||||
@@ -52,12 +53,16 @@ using namespace PartDesign;
|
||||
PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp)
|
||||
|
||||
const App::PropertyQuantityConstraint::Constraints floatSize = {0.0,FLT_MAX,0.1};
|
||||
const App::PropertyAngle::Constraints floatAngle = {0.0,89.99,0.1};
|
||||
|
||||
Chamfer::Chamfer()
|
||||
{
|
||||
ADD_PROPERTY(Size,(1.0));
|
||||
Size.setUnit(Base::Unit::Length);
|
||||
Size.setConstraints(&floatSize);
|
||||
ADD_PROPERTY(Angle,(45.0));
|
||||
Size.setUnit(Base::Unit::Angle);
|
||||
Angle.setConstraints(&floatAngle);
|
||||
}
|
||||
|
||||
short Chamfer::mustExecute() const
|
||||
@@ -88,6 +93,10 @@ App::DocumentObjectExecReturn *Chamfer::execute(void)
|
||||
if (size <= 0)
|
||||
return new App::DocumentObjectExecReturn("Size must be greater than zero");
|
||||
|
||||
double angle = Base::toRadians(Angle.getValue());
|
||||
if (angle <= 0 || angle > 89.99)
|
||||
return new App::DocumentObjectExecReturn("Angle must be between 0 and 89.99");
|
||||
|
||||
this->positionByBaseFeature();
|
||||
// create an untransformed copy of the basefeature shape
|
||||
Part::TopoShape baseShape(TopShape);
|
||||
@@ -103,11 +112,7 @@ App::DocumentObjectExecReturn *Chamfer::execute(void)
|
||||
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(baseShape.getSubShape(it->c_str()));
|
||||
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
|
||||
#if OCC_VERSION_HEX > 0x070300
|
||||
mkChamfer.Add(size, size, edge, face);
|
||||
#else
|
||||
mkChamfer.Add(size, edge, face);
|
||||
#endif
|
||||
mkChamfer.AddDA(size, angle, edge, face);
|
||||
}
|
||||
|
||||
mkChamfer.Build();
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
Chamfer();
|
||||
|
||||
App::PropertyQuantityConstraint Size;
|
||||
App::PropertyAngle Angle;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
||||
@@ -63,14 +63,24 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
|
||||
double r = pcChamfer->Size.getValue();
|
||||
|
||||
double r = pcChamfer->Size.getValue();
|
||||
ui->chamferDistance->setUnit(Base::Unit::Length);
|
||||
ui->chamferDistance->setValue(r);
|
||||
ui->chamferDistance->setMinimum(0);
|
||||
ui->chamferDistance->selectNumber();
|
||||
ui->chamferDistance->bind(pcChamfer->Size);
|
||||
QMetaObject::invokeMethod(ui->chamferDistance, "setFocus", Qt::QueuedConnection);
|
||||
|
||||
double a = pcChamfer->Angle.getValue();
|
||||
ui->chamferAngle->setUnit(Base::Unit::Angle);
|
||||
ui->chamferAngle->setValue(a);
|
||||
ui->chamferAngle->setMinimum(0.0);
|
||||
ui->chamferAngle->setMaximum(89.99);
|
||||
ui->chamferAngle->selectAll();
|
||||
ui->chamferAngle->bind(pcChamfer->Angle);
|
||||
QMetaObject::invokeMethod(ui->chamferAngle, "setFocus", Qt::QueuedConnection);
|
||||
|
||||
std::vector<std::string> strings = pcChamfer->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
{
|
||||
@@ -81,6 +91,8 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
|
||||
connect(ui->chamferDistance, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onLengthChanged(double)));
|
||||
connect(ui->chamferAngle, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onAngleChanged(double)));
|
||||
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonRefAdd(bool)));
|
||||
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
|
||||
@@ -179,7 +191,7 @@ void TaskChamferParameters::onRefDeleted(void)
|
||||
// erase the reference
|
||||
refs.erase(refs.begin() + rowNumber);
|
||||
// remove from the list
|
||||
ui->listWidgetReferences->model()->removeRow(rowNumber);
|
||||
ui->listWidgetReferences->model()->removeRow(rowNumber);
|
||||
}
|
||||
|
||||
// update the object
|
||||
@@ -209,6 +221,19 @@ double TaskChamferParameters::getLength(void) const
|
||||
return ui->chamferDistance->value().getValue();
|
||||
}
|
||||
|
||||
void TaskChamferParameters::onAngleChanged(double angle)
|
||||
{
|
||||
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
|
||||
setupTransaction();
|
||||
pcChamfer->Angle.setValue(angle);
|
||||
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
|
||||
}
|
||||
|
||||
double TaskChamferParameters::getAngle(void) const
|
||||
{
|
||||
return ui->chamferAngle->value().getValue();
|
||||
}
|
||||
|
||||
TaskChamferParameters::~TaskChamferParameters()
|
||||
{
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onLengthChanged(double);
|
||||
void onAngleChanged(double);
|
||||
void onRefDeleted(void);
|
||||
|
||||
protected:
|
||||
@@ -51,6 +52,7 @@ protected:
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
double getLength(void) const;
|
||||
double getAngle(void) const;
|
||||
|
||||
private:
|
||||
Ui_TaskChamferParameters* ui;
|
||||
|
||||
@@ -57,15 +57,49 @@ click again to end selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="chamferDistance" native="true"/>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="chamferDistance" native="true" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="chamferAngle" native="true">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum" stdset="0">
|
||||
<double>89.999999999999986</double>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value" stdset="0">
|
||||
<double>45.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user