PartDesign: Chamfer direction flipping support
This commit is contained in:
committed by
abdullahtahiriyo
parent
d2d26ab8d0
commit
e1240fb18d
@@ -74,6 +74,8 @@ Chamfer::Chamfer()
|
||||
ADD_PROPERTY(Angle,(45.0));
|
||||
Angle.setUnit(Base::Unit::Angle);
|
||||
Angle.setConstraints(&floatAngle);
|
||||
|
||||
ADD_PROPERTY(FlipDirection, (false));
|
||||
}
|
||||
|
||||
short Chamfer::mustExecute() const
|
||||
@@ -104,6 +106,7 @@ App::DocumentObjectExecReturn *Chamfer::execute(void)
|
||||
const double size = Size.getValue();
|
||||
const double size2 = Size2.getValue();
|
||||
const double angle = Angle.getValue();
|
||||
const bool flipDirection = FlipDirection.getValue();
|
||||
|
||||
auto res = validateParameters(chamferType, size, size2, angle);
|
||||
if (res != App::DocumentObject::StdReturn) {
|
||||
@@ -124,7 +127,9 @@ 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());
|
||||
const TopoDS_Face& face = (chamferType != 0 && flipDirection) ?
|
||||
TopoDS::Face(mapEdgeFace.FindFromKey(edge).Last()) :
|
||||
TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
|
||||
switch (chamferType) {
|
||||
case 0: // Equal distance
|
||||
mkChamfer.Add(size, size, edge, face);
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
App::PropertyQuantityConstraint Size;
|
||||
App::PropertyQuantityConstraint Size2;
|
||||
App::PropertyAngle Angle;
|
||||
App::PropertyBool FlipDirection;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
||||
@@ -83,6 +83,8 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
this, SLOT(onSize2Changed(double)));
|
||||
connect(ui->chamferAngle, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onAngleChanged(double)));
|
||||
connect(ui->flipDirection, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onFlipDirection(bool)));
|
||||
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonRefAdd(bool)));
|
||||
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
|
||||
@@ -105,6 +107,9 @@ void TaskChamferParameters::setUpUI(PartDesign::Chamfer* pcChamfer)
|
||||
const int index = pcChamfer->ChamferType.getValue();
|
||||
ui->chamferType->setCurrentIndex(index);
|
||||
|
||||
ui->flipDirection->setEnabled(index != 0); // Enable if type is not "Equal distance"
|
||||
ui->flipDirection->setChecked(pcChamfer->FlipDirection.getValue());
|
||||
|
||||
ui->chamferSize->setUnit(Base::Unit::Length);
|
||||
ui->chamferSize->setMinimum(0);
|
||||
ui->chamferSize->setValue(pcChamfer->Size.getValue());
|
||||
@@ -121,6 +126,8 @@ void TaskChamferParameters::setUpUI(PartDesign::Chamfer* pcChamfer)
|
||||
ui->chamferAngle->setMaximum(180.0);
|
||||
ui->chamferAngle->setValue(pcChamfer->Angle.getValue());
|
||||
ui->chamferAngle->bind(pcChamfer->Angle);
|
||||
|
||||
ui->stackedWidget->setFixedHeight(ui->chamferSize2->sizeHint().height());
|
||||
}
|
||||
|
||||
void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
@@ -226,7 +233,7 @@ void TaskChamferParameters::onTypeChanged(int index)
|
||||
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
|
||||
pcChamfer->ChamferType.setValue(index);
|
||||
ui->stackedWidget->setCurrentIndex(index);
|
||||
ui->stackedWidget->setFixedHeight(ui->chamferSize2->sizeHint().height());
|
||||
ui->flipDirection->setEnabled(index != 0); // Enable if type is not "Equal distance"
|
||||
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
|
||||
}
|
||||
|
||||
@@ -254,6 +261,14 @@ void TaskChamferParameters::onAngleChanged(double angle)
|
||||
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
|
||||
}
|
||||
|
||||
void TaskChamferParameters::onFlipDirection(bool flip)
|
||||
{
|
||||
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
|
||||
setupTransaction();
|
||||
pcChamfer->FlipDirection.setValue(flip);
|
||||
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
|
||||
}
|
||||
|
||||
int TaskChamferParameters::getType(void) const
|
||||
{
|
||||
return ui->chamferType->currentIndex();
|
||||
@@ -274,6 +289,11 @@ double TaskChamferParameters::getAngle(void) const
|
||||
return ui->chamferAngle->value().getValue();
|
||||
}
|
||||
|
||||
bool TaskChamferParameters::getFlipDirection(void) const
|
||||
{
|
||||
return ui->flipDirection->isChecked();
|
||||
}
|
||||
|
||||
TaskChamferParameters::~TaskChamferParameters()
|
||||
{
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
@@ -49,6 +49,7 @@ private Q_SLOTS:
|
||||
void onSizeChanged(double);
|
||||
void onSize2Changed(double);
|
||||
void onAngleChanged(double);
|
||||
void onFlipDirection(bool);
|
||||
void onRefDeleted(void);
|
||||
|
||||
protected:
|
||||
@@ -61,6 +62,7 @@ protected:
|
||||
double getSize(void) const;
|
||||
double getSize2(void) const;
|
||||
double getAngle(void) const;
|
||||
bool getFlipDirection(void) const;
|
||||
|
||||
private:
|
||||
void setUpUI(PartDesign::Chamfer* pcChamfer);
|
||||
|
||||
@@ -58,31 +58,55 @@ click again to end selection</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="typeLabel">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="typeLabel">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="chamferType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Equal distance</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Two distances</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Distance and angle</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="chamferType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Equal distance</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Two distances</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Distance and angle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="flipDirection">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Flip direction</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/PartDesign_Flip_Direction.svg</normaloff>:/icons/PartDesign_Flip_Direction.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -90,7 +114,7 @@ click again to end selection</string>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="sizeLabel_2">
|
||||
<widget class="QLabel" name="sizeLabel">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
@@ -126,7 +150,7 @@ click again to end selection</string>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="sizeLabel">
|
||||
<widget class="QLabel" name="size2Label">
|
||||
<property name="text">
|
||||
<string>Size 2</string>
|
||||
</property>
|
||||
@@ -171,7 +195,7 @@ click again to end selection</string>
|
||||
<number>180.000000000000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>0.100000000000000</number>
|
||||
<number>1.000000000000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>45.000000000000000</number>
|
||||
|
||||
Reference in New Issue
Block a user