Sketcher: Edit Controls' checkboxes to independently hide/show driving/non-driving constraints

This commit is contained in:
Abdullah Tahiri
2017-04-18 02:19:14 +02:00
committed by wmayer
parent c9fbe9cc6a
commit a76286aa27
5 changed files with 77 additions and 6 deletions

View File

@@ -56,6 +56,10 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
this, SIGNAL(emitToggleAutoconstraints(int)));
connect(ui->renderingOrder->model(), SIGNAL(layoutChanged()),
this, SLOT(renderOrderChanged()));
connect(ui->checkBoxHideDrivenConstraints, SIGNAL(stateChanged(int)),
this, SLOT(constraintcheckboxes_stateChanged(int)));
connect(ui->checkBoxHideDrivingConstraints, SIGNAL(stateChanged(int)),
this, SLOT(constraintcheckboxes_stateChanged(int)));
}
SketcherGeneralWidget::~SketcherGeneralWidget()
@@ -108,6 +112,9 @@ 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->checkBoxHideDrivenConstraints->onRestore();
ui->checkBoxHideDrivingConstraints->onRestore();
}
void SketcherGeneralWidget::toggleGridView(bool on)
@@ -155,6 +162,14 @@ void SketcherGeneralWidget::renderOrderChanged()
emitrenderOrderChanged();
}
void SketcherGeneralWidget::constraintcheckboxes_stateChanged(int state)
{
Q_UNUSED(state);
emithideconstraints(ui->checkBoxHideDrivingConstraints->isChecked(),ui->checkBoxHideDrivenConstraints->isChecked());
ui->checkBoxHideDrivenConstraints->onSave();
ui->checkBoxHideDrivingConstraints->onSave();
}
// ----------------------------------------------------------------------------
TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
@@ -187,9 +202,13 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
QObject::connect(
widget, SIGNAL(emitrenderOrderChanged()),
this , SLOT (renderOrderChanged())
this , SLOT (renderOrderChanged())
);
QObject::connect(
widget, SIGNAL(emithideconstraints(bool,bool)),
this , SLOT (hideconstraints(bool,bool))
);
Gui::Selection().Attach(this);
widget->loadSettings();
@@ -242,4 +261,9 @@ void TaskSketcherGeneral::renderOrderChanged()
sketchView->updateColor();
}
void TaskSketcherGeneral::hideconstraints(bool hidedriving, bool hidedriven)
{
sketchView->showConstraints(hidedriving,hidedriven);
}
#include "moc_TaskSketcherGeneral.cpp"

View File

@@ -56,12 +56,14 @@ Q_SIGNALS:
void emitSetGridSize(double);
void emitToggleAutoconstraints(int);
void emitrenderOrderChanged();
void emithideconstraints(bool,bool);
public Q_SLOTS:
void toggleGridView(bool on);
void setGridSize(double val);
void toggleGridSnap(int state);
void renderOrderChanged();
void constraintcheckboxes_stateChanged(int state);
protected:
void changeEvent(QEvent *e);
@@ -91,6 +93,7 @@ public Q_SLOTS:
void toggleGridSnap(int state);
void toggleAutoconstraints(int state);
void renderOrderChanged();
void hideconstraints(bool hidedriving, bool hidedriven);
private:
ViewProviderSketch *sketchView;

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>228</height>
<width>229</width>
<height>284</height>
</rect>
</property>
<property name="windowTitle">
@@ -80,6 +80,32 @@
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxHideDrivingConstraints">
<property name="text">
<string>Hide driving constraints</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideDrivingConstraints</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxHideDrivenConstraints">
<property name="text">
<string>Hide reference constraints</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideDrivenConstraints</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 +134,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/>

View File

@@ -4797,8 +4797,8 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
SoSwitch *drivingsw = new SoSwitch();
SoSwitch *drivensw = new SoSwitch();
drivingsw->whichChild = hGrpp->GetBool("DrivingConstraintsVisible", true)?SO_SWITCH_ALL:SO_SWITCH_NONE;
drivensw->whichChild = hGrpp->GetBool("DrivenConstraintsVisible", true)?SO_SWITCH_ALL:SO_SWITCH_NONE;
drivingsw->whichChild = hGrpp->GetBool("HideDrivingConstraints", false)?SO_SWITCH_NONE:SO_SWITCH_ALL;
drivensw->whichChild = hGrpp->GetBool("HideDrivenConstraints", false)?SO_SWITCH_NONE:SO_SWITCH_ALL;
drivingsw->ref();
drivensw->ref();
@@ -5890,9 +5890,19 @@ Base::Placement ViewProviderSketch::getPlacement() {
return Plz;
}
void ViewProviderSketch::showRestoreInformationLayer() {
void ViewProviderSketch::showRestoreInformationLayer()
{
visibleInformationChanged = true ;
draw(false,false);
}
void ViewProviderSketch::showConstraints(bool hidedriving, bool hidedriven)
{
SoSwitch *drivingsw = static_cast<SoSwitch *>(edit->constrGroup->getChild(0));
SoSwitch *drivensw = static_cast<SoSwitch *>(edit->constrGroup->getChild(1));
drivingsw->whichChild = hidedriving?SO_SWITCH_NONE:SO_SWITCH_ALL;
drivensw->whichChild = hidedriven?SO_SWITCH_NONE:SO_SWITCH_ALL;
}

View File

@@ -125,6 +125,9 @@ public:
/// Show/Hide nodes from information layer
void showRestoreInformationLayer();
/// Show/Hide constraints
void showConstraints(bool hidedriving = false, bool hidedriven = false);
/** @name handler control */
//@{
/// sets an DrawSketchHandler in control