diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp index 663d40fa1409..0678fc71a9db 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp +++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp @@ -37,6 +37,7 @@ /// Here the FreeCAD includes sorted by Base,App,Gui...... #include #include +#include #include "ViewProvider2DObject.h" #include @@ -143,9 +144,11 @@ SoSeparator* ViewProvider2DObject::createGrid(void) mycolor->rgb.setValue(0.7f, 0.7f ,0.7f); parent->addChild(mycolor); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); + int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f); SoDrawStyle* DefaultStyle = new SoDrawStyle; DefaultStyle->lineWidth = 1; - DefaultStyle->linePattern = 0x0f0f; + DefaultStyle->linePattern = pattern; SoMaterial* LightStyle = new SoMaterial; LightStyle->transparency = 0.7f; diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 737586929595..e94ac80aa60b 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -26,6 +26,7 @@ # include #endif +#include #include #include #include @@ -73,10 +74,15 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch) vp->draw(); // Redraw } + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + bool show = hGrp->GetBool("ShowDialogOnDistanceConstraint", true); + // Ask for the value of the distance immediately - EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1); - editDatumDialog->exec(false); - delete editDatumDialog; + if (show) { + EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1); + editDatumDialog->exec(false); + delete editDatumDialog; + } //updateActive(); cmd->getSelection().clearSelection(); diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 127a174f5c55..844c85d2ff5a 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -24,11 +24,13 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include #endif #include "SketcherSettings.h" #include "ui_SketcherSettings.h" #include "TaskSketcherGeneral.h" +#include #include using namespace SketcherGui; @@ -39,8 +41,13 @@ SketcherSettings::SketcherSettings(QWidget* parent) : PreferencePage(parent), ui(new Ui_SketcherSettings) { ui->setupUi(this); - form = new SketcherGeneralWidget(ui->groupBox); - ui->gridLayout->addWidget(form, 1, 0, 1, 1); + QGroupBox* groupBox = new QGroupBox(this); + QGridLayout* gridLayout = new QGridLayout(groupBox); + gridLayout->setSpacing(0); + gridLayout->setMargin(0); + form = new SketcherGeneralWidget(groupBox); + gridLayout->addWidget(form, 0, 0, 1, 1); + ui->gridLayout_3->addWidget(groupBox, 2, 0, 1, 1); // Don't need them at the moment ui->label_16->hide(); @@ -49,6 +56,30 @@ SketcherSettings::SketcherSettings(QWidget* parent) ui->DefaultSketcherVertexWidth->hide(); ui->label_13->hide(); ui->DefaultSketcherLineWidth->hide(); + + QList < QPair > styles; + styles << qMakePair(Qt::SolidLine, 0xffff) + << qMakePair(Qt::DashLine, 0x0f0f) + << qMakePair(Qt::DotLine, 0xaaaa); +// << qMakePair(Qt::DashDotLine, 0x????) +// << qMakePair(Qt::DashDotDotLine, 0x????); + ui->comboBox->setIconSize (QSize(80, 12)); + for (QList < QPair >::iterator it = styles.begin(); it != styles.end(); ++it) { + QPixmap px(ui->comboBox->iconSize()); + px.fill(Qt::transparent); + QBrush brush(Qt::black); + QPen pen(it->first); + pen.setBrush(brush); + pen.setWidth(2); + + QPainter painter(&px); + painter.setPen(pen); + double mid = ui->comboBox->iconSize().height() / 2.0; + painter.drawLine(0, mid, ui->comboBox->iconSize().width(), mid); + painter.end(); + + ui->comboBox->addItem(QIcon(px), QString(), QVariant(it->second)); + } } /** @@ -82,7 +113,13 @@ void SketcherSettings::saveSettings() // Sketch editing ui->EditSketcherFontSize->onSave(); + ui->dialogOnDistanceConstraint->onSave(); form->saveSettings(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); + QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex()); + int pattern = data.toInt(); + hGrp->SetInt("GridLinePattern", pattern); } void SketcherSettings::loadSettings() @@ -107,7 +144,14 @@ void SketcherSettings::loadSettings() // Sketch editing ui->EditSketcherFontSize->onRestore(); + ui->dialogOnDistanceConstraint->onRestore(); form->loadSettings(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); + int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f); + int index = ui->comboBox->findData(QVariant(pattern)); + if (index <0) index = 1; + ui->comboBox->setCurrentIndex(index); } /** diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.ui b/src/Mod/Sketcher/Gui/SketcherSettings.ui index 2824c82ca8a6..48d89c955bd1 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettings.ui @@ -7,7 +7,7 @@ 0 0 359 - 544 + 586 @@ -456,19 +456,6 @@ - - - - Qt::Horizontal - - - - 74 - 20 - - - - @@ -517,18 +504,39 @@ - - - - Qt::Horizontal + + + + + + Grid line pattern + + + + + + + -1 + + + + + + + + + Ask for value after creating a distance constraint - - - 71 - 20 - + + true - + + ShowDialogOnDistanceConstraint + + + Mod/Sketcher + + @@ -564,6 +572,11 @@ Gui::ColorButton
Gui/PrefWidgets.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
CursorTextColor