Sketcher: redundant autoconstraint avoidance - Edit control checkbox

fixes #3079
This commit is contained in:
Abdullah Tahiri
2017-06-10 23:51:40 +02:00
committed by wmayer
parent c093cb1821
commit 25a28b0851
4 changed files with 58 additions and 17 deletions

View File

@@ -340,7 +340,11 @@ public:
Gui::Command::abortCommand();
}
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool avoidredundant = hGrp->GetBool("AvoidRedundantAutoconstraints",true);
if(avoidredundant)
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
// add auto constraints for the line segment start
if (sugConstr1.size() > 0) {
@@ -354,8 +358,6 @@ public:
sugConstr2.clear();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
@@ -1133,14 +1135,19 @@ public:
else
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool avoidredundant = hGrp->GetBool("AvoidRedundantAutoconstraints",true);
if (Mode == STATUS_Close) {
if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints.
if (sugConstr1.size() > 0)
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
else
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),virtualsugConstr1,sugConstr2);
if(avoidredundant) {
if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints.
if (sugConstr1.size() > 0)
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
else
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),virtualsugConstr1,sugConstr2);
}
}
if (sugConstr2.size() > 0) {
@@ -1195,13 +1202,16 @@ public:
sugConstr1.clear();
}
if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints.
if (sugConstr1.size() > 0)
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
else
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),virtualsugConstr1,sugConstr2);
if(avoidredundant) {
if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints.
if (sugConstr1.size() > 0)
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
else
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),virtualsugConstr1,sugConstr2);
}
}
virtualsugConstr1 = sugConstr2; // these are the initial constraints for the next iteration.
if (sugConstr2.size() > 0) {
@@ -1211,7 +1221,7 @@ public:
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
if(autoRecompute)
Gui::Command::updateActive();
else

View File

@@ -56,6 +56,8 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
this, SIGNAL(emitToggleAutoconstraints(int)));
connect(ui->renderingOrder->model(), SIGNAL(layoutChanged()),
this, SLOT(renderOrderChanged()));
connect(ui->checkBoxRedundantAutoconstraints, SIGNAL(stateChanged(int)),
this, SLOT(on_checkBoxRedundantAutoconstraints_stateChanged(int)));
}
SketcherGeneralWidget::~SketcherGeneralWidget()
@@ -108,6 +110,8 @@ void SketcherGeneralWidget::loadSettings()
newItem->setData(Qt::UserRole, QVariant(lowid));
newItem->setText(lowid==1?tr("Normal Geometry"):lowid==2?tr("Construction Geometry"):tr("External Geometry"));
ui->renderingOrder->insertItem(2,newItem);
ui->checkBoxRedundantAutoconstraints->onRestore();
}
void SketcherGeneralWidget::toggleGridView(bool on)
@@ -155,6 +159,11 @@ void SketcherGeneralWidget::renderOrderChanged()
emitRenderOrderChanged();
}
void SketcherGeneralWidget::on_checkBoxRedundantAutoconstraints_stateChanged(int state)
{
ui->checkBoxRedundantAutoconstraints->onSave();
}
// ----------------------------------------------------------------------------
TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)

View File

@@ -62,6 +62,7 @@ public Q_SLOTS:
void setGridSize(double val);
void toggleGridSnap(int state);
void renderOrderChanged();
void on_checkBoxRedundantAutoconstraints_stateChanged(int);
protected:
void changeEvent(QEvent *e);

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>228</height>
<width>275</width>
<height>256</height>
</rect>
</property>
<property name="windowTitle">
@@ -80,6 +80,22 @@
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxRedundantAutoconstraints">
<property name="text">
<string>Avoid redundant auto constraints</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AvoidRedundantAutoconstraints</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
@@ -108,6 +124,11 @@
<extends>QWidget</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>