[Sketcher] Local settings are correctly restored ; fixes #3952,#4058
This commit is contained in:
committed by
abdullahtahiriyo
parent
9d9aaf680f
commit
811a44643c
@@ -362,7 +362,7 @@ public:
|
||||
}
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool avoidredundant = hGrp->GetGroup("General")->GetBool("AvoidRedundantAutoconstraints",true) && sketchgui->Autoconstraints.getValue();
|
||||
bool avoidredundant = sketchgui->AvoidRedundant.getValue() && sketchgui->Autoconstraints.getValue();
|
||||
|
||||
if(avoidredundant)
|
||||
removeRedundantHorizontalVertical(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()),sugConstr1,sugConstr2);
|
||||
@@ -1167,7 +1167,7 @@ public:
|
||||
}
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool avoidredundant = hGrp->GetGroup("General")->GetBool("AvoidRedundantAutoconstraints",true) && sketchgui->Autoconstraints.getValue();
|
||||
bool avoidredundant = sketchgui->AvoidRedundant.getValue() && sketchgui->Autoconstraints.getValue();
|
||||
|
||||
if (Mode == STATUS_Close) {
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
|
||||
this, SIGNAL(emitSetGridSize(double)));
|
||||
connect(ui->checkBoxAutoconstraints, SIGNAL(toggled(bool)),
|
||||
this, SIGNAL(emitToggleAutoconstraints(bool)));
|
||||
connect(ui->checkBoxRedundantAutoconstraints, SIGNAL(toggled(bool)),
|
||||
this, SIGNAL(emitToggleAvoidRedundant(bool)));
|
||||
ui->renderingOrder->installEventFilter(this);
|
||||
}
|
||||
|
||||
@@ -103,6 +105,7 @@ void SketcherGeneralWidget::loadSettings()
|
||||
{
|
||||
ui->checkBoxShowGrid->onRestore();
|
||||
ui->gridSize->onRestore();
|
||||
if (ui->gridSize->rawValue() == 0) { ui->gridSize->setValue(10.0); }
|
||||
ui->checkBoxGridSnap->onRestore();
|
||||
ui->checkBoxAutoconstraints->onRestore();
|
||||
ui->checkBoxRedundantAutoconstraints->onRestore();
|
||||
@@ -160,6 +163,11 @@ void SketcherGeneralWidget::checkAutoconstraints(bool on)
|
||||
ui->checkBoxAutoconstraints->setChecked(on);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::checkAvoidRedundant(bool on)
|
||||
{
|
||||
ui->checkBoxRedundantAutoconstraints->setChecked(on);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::enableGridSettings(bool on)
|
||||
{
|
||||
ui->label->setEnabled(on);
|
||||
@@ -189,6 +197,22 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
// we need a separate container widget to add all controls to
|
||||
widget = new SketcherGeneralWidget(this);
|
||||
this->groupLayout()->addWidget(widget);
|
||||
|
||||
{
|
||||
//Blocker probably not needed as signals aren't connected yet
|
||||
QSignalBlocker block(widget);
|
||||
//Load default settings to get ordering order & avoid redundant values
|
||||
widget->loadSettings();
|
||||
widget->checkGridView(sketchView->ShowGrid.getValue());
|
||||
if (sketchView->GridSize.getValue() > 0) {
|
||||
widget->setGridSize(sketchView->GridSize.getValue());
|
||||
}
|
||||
widget->checkGridSnap(sketchView->GridSnap.getValue());
|
||||
widget->enableGridSettings(sketchView->ShowGrid.getValue());
|
||||
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
|
||||
widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue());
|
||||
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
|
||||
}
|
||||
|
||||
// connecting the needed signals
|
||||
QObject::connect(
|
||||
@@ -210,6 +234,11 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
widget, SIGNAL(emitToggleAutoconstraints(bool)),
|
||||
this , SLOT (onToggleAutoconstraints(bool))
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
widget, SIGNAL(emitToggleAvoidRedundant(bool)),
|
||||
this , SLOT (onToggleAvoidRedundant(bool))
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
widget, SIGNAL(emitRenderOrderChanged()),
|
||||
@@ -217,7 +246,6 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
);
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
widget->loadSettings();
|
||||
|
||||
Gui::Application* app = Gui::Application::Instance;
|
||||
changedSketchView = app->signalChangedObject.connect(boost::bind
|
||||
@@ -239,6 +267,7 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
|
||||
widget->enableGridSettings(sketchView->ShowGrid.getValue());
|
||||
if (sketchView->ShowGrid.getValue()) {
|
||||
sketchView->createGrid();
|
||||
}
|
||||
}
|
||||
else if (&sketchView->GridSize == &prop) {
|
||||
QSignalBlocker block(widget);
|
||||
@@ -253,6 +282,10 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
|
||||
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
|
||||
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
|
||||
}
|
||||
else if (&sketchView->AvoidRedundant == &prop) {
|
||||
QSignalBlocker block(widget);
|
||||
widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +316,12 @@ void TaskSketcherGeneral::onToggleAutoconstraints(bool on)
|
||||
widget->enableAvoidRedundant(on);
|
||||
}
|
||||
|
||||
void TaskSketcherGeneral::onToggleAvoidRedundant(bool on)
|
||||
{
|
||||
Base::ConnectionBlocker block(changedSketchView);
|
||||
sketchView->AvoidRedundant.setValue(on);
|
||||
}
|
||||
|
||||
/// @cond DOXERR
|
||||
void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
|
||||
Gui::SelectionSingleton::MessageType Reason)
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
void checkGridView(bool);
|
||||
void checkGridSnap(bool);
|
||||
void checkAutoconstraints(bool);
|
||||
void checkAvoidRedundant(bool);
|
||||
void enableGridSettings(bool);
|
||||
void enableAvoidRedundant(bool);
|
||||
|
||||
@@ -68,6 +69,7 @@ Q_SIGNALS:
|
||||
void emitToggleGridSnap(bool);
|
||||
void emitSetGridSize(double);
|
||||
void emitToggleAutoconstraints(bool);
|
||||
void emitToggleAvoidRedundant(bool);
|
||||
void emitRenderOrderChanged();
|
||||
|
||||
protected:
|
||||
@@ -94,6 +96,7 @@ public Q_SLOTS:
|
||||
void onSetGridSize(double val);
|
||||
void onToggleGridSnap(bool on);
|
||||
void onToggleAutoconstraints(bool on);
|
||||
void onToggleAvoidRedundant(bool);
|
||||
void onRenderOrderChanged();
|
||||
|
||||
private:
|
||||
|
||||
@@ -291,6 +291,7 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
listener(0)
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Autoconstraints,(true),"Auto Constraints",(App::PropertyType)(App::Prop_None),"Create auto constraints");
|
||||
ADD_PROPERTY_TYPE(AvoidRedundant,(true),"Auto Constraints",(App::PropertyType)(App::Prop_None),"Avoid redundant autoconstraint");
|
||||
ADD_PROPERTY_TYPE(TempoVis,(Py::None()),"Visibility automation",(App::PropertyType)(App::Prop_None),"Object that handles hiding and showing other objects when entering/leaving sketch.");
|
||||
ADD_PROPERTY_TYPE(HideDependent,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects that depend on the sketch are hidden when opening editing.");
|
||||
ADD_PROPERTY_TYPE(ShowLinks,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects used in links to external geometry are shown when opening sketch.");
|
||||
@@ -306,7 +307,11 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
this->RestoreCamera.setValue(hGrp->GetBool("RestoreCamera", true));
|
||||
|
||||
// well it is not visibility automation but a good place nevertheless
|
||||
this->ShowGrid.setValue(hGrp->GetBool("ShowGrid", false));
|
||||
this->GridSize.setValue(Base::Quantity::parse(QString::fromLatin1(hGrp->GetGroup("GridSize")->GetASCII("Hist0", "10.0").c_str())).getValue());
|
||||
this->GridSnap.setValue(hGrp->GetBool("GridSnap", false));
|
||||
this->Autoconstraints.setValue(hGrp->GetBool("AutoConstraints", true));
|
||||
this->AvoidRedundant.setValue(hGrp->GetBool("AvoidRedundantAutoconstraints", true));
|
||||
}
|
||||
|
||||
sPixmap = "Sketcher_Sketch";
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
virtual ~ViewProviderSketch();
|
||||
|
||||
App::PropertyBool Autoconstraints;
|
||||
App::PropertyBool AvoidRedundant;
|
||||
App::PropertyPythonObject TempoVis;
|
||||
App::PropertyBool HideDependent;
|
||||
App::PropertyBool ShowLinks;
|
||||
|
||||
Reference in New Issue
Block a user