+ fixes #0001049: Sketcher preferences in preferences editor
This commit is contained in:
parent
f0b54d3ee5
commit
06239e9a57
|
@ -37,6 +37,7 @@
|
||||||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||||
#include <Base/Parameter.h>
|
#include <Base/Parameter.h>
|
||||||
#include <Base/ViewProj.h>
|
#include <Base/ViewProj.h>
|
||||||
|
#include <App/Application.h>
|
||||||
|
|
||||||
#include "ViewProvider2DObject.h"
|
#include "ViewProvider2DObject.h"
|
||||||
#include <Mod/Part/App/PartFeature.h>
|
#include <Mod/Part/App/PartFeature.h>
|
||||||
|
@ -143,9 +144,11 @@ SoSeparator* ViewProvider2DObject::createGrid(void)
|
||||||
mycolor->rgb.setValue(0.7f, 0.7f ,0.7f);
|
mycolor->rgb.setValue(0.7f, 0.7f ,0.7f);
|
||||||
parent->addChild(mycolor);
|
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;
|
SoDrawStyle* DefaultStyle = new SoDrawStyle;
|
||||||
DefaultStyle->lineWidth = 1;
|
DefaultStyle->lineWidth = 1;
|
||||||
DefaultStyle->linePattern = 0x0f0f;
|
DefaultStyle->linePattern = pattern;
|
||||||
|
|
||||||
SoMaterial* LightStyle = new SoMaterial;
|
SoMaterial* LightStyle = new SoMaterial;
|
||||||
LightStyle->transparency = 0.7f;
|
LightStyle->transparency = 0.7f;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
# include <QMessageBox>
|
# include <QMessageBox>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <App/Application.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
#include <Gui/Document.h>
|
#include <Gui/Document.h>
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
|
@ -73,10 +74,15 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch)
|
||||||
vp->draw(); // Redraw
|
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
|
// Ask for the value of the distance immediately
|
||||||
|
if (show) {
|
||||||
EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1);
|
EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1);
|
||||||
editDatumDialog->exec(false);
|
editDatumDialog->exec(false);
|
||||||
delete editDatumDialog;
|
delete editDatumDialog;
|
||||||
|
}
|
||||||
|
|
||||||
//updateActive();
|
//updateActive();
|
||||||
cmd->getSelection().clearSelection();
|
cmd->getSelection().clearSelection();
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
|
# include <QPixmap>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SketcherSettings.h"
|
#include "SketcherSettings.h"
|
||||||
#include "ui_SketcherSettings.h"
|
#include "ui_SketcherSettings.h"
|
||||||
#include "TaskSketcherGeneral.h"
|
#include "TaskSketcherGeneral.h"
|
||||||
|
#include <App/Application.h>
|
||||||
#include <Gui/PrefWidgets.h>
|
#include <Gui/PrefWidgets.h>
|
||||||
|
|
||||||
using namespace SketcherGui;
|
using namespace SketcherGui;
|
||||||
|
@ -39,8 +41,13 @@ SketcherSettings::SketcherSettings(QWidget* parent)
|
||||||
: PreferencePage(parent), ui(new Ui_SketcherSettings)
|
: PreferencePage(parent), ui(new Ui_SketcherSettings)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
form = new SketcherGeneralWidget(ui->groupBox);
|
QGroupBox* groupBox = new QGroupBox(this);
|
||||||
ui->gridLayout->addWidget(form, 1, 0, 1, 1);
|
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
|
// Don't need them at the moment
|
||||||
ui->label_16->hide();
|
ui->label_16->hide();
|
||||||
|
@ -49,6 +56,30 @@ SketcherSettings::SketcherSettings(QWidget* parent)
|
||||||
ui->DefaultSketcherVertexWidth->hide();
|
ui->DefaultSketcherVertexWidth->hide();
|
||||||
ui->label_13->hide();
|
ui->label_13->hide();
|
||||||
ui->DefaultSketcherLineWidth->hide();
|
ui->DefaultSketcherLineWidth->hide();
|
||||||
|
|
||||||
|
QList < QPair<Qt::PenStyle, int> > 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<Qt::PenStyle, int> >::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
|
// Sketch editing
|
||||||
ui->EditSketcherFontSize->onSave();
|
ui->EditSketcherFontSize->onSave();
|
||||||
|
ui->dialogOnDistanceConstraint->onSave();
|
||||||
form->saveSettings();
|
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()
|
void SketcherSettings::loadSettings()
|
||||||
|
@ -107,7 +144,14 @@ void SketcherSettings::loadSettings()
|
||||||
|
|
||||||
// Sketch editing
|
// Sketch editing
|
||||||
ui->EditSketcherFontSize->onRestore();
|
ui->EditSketcherFontSize->onRestore();
|
||||||
|
ui->dialogOnDistanceConstraint->onRestore();
|
||||||
form->loadSettings();
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>359</width>
|
<width>359</width>
|
||||||
<height>544</height>
|
<height>586</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -456,19 +456,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>74</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -517,18 +504,39 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Grid line pattern</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
</item>
|
||||||
<width>71</width>
|
<item>
|
||||||
<height>20</height>
|
<widget class="QComboBox" name="comboBox">
|
||||||
</size>
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="Gui::PrefCheckBox" name="dialogOnDistanceConstraint">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ask for value after creating a distance constraint</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="prefEntry" stdset="0">
|
||||||
|
<cstring>ShowDialogOnDistanceConstraint</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefPath" stdset="0">
|
||||||
|
<cstring>Mod/Sketcher</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -564,6 +572,11 @@
|
||||||
<extends>Gui::ColorButton</extends>
|
<extends>Gui::ColorButton</extends>
|
||||||
<header>Gui/PrefWidgets.h</header>
|
<header>Gui/PrefWidgets.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Gui::PrefCheckBox</class>
|
||||||
|
<extends>QCheckBox</extends>
|
||||||
|
<header>Gui/PrefWidgets.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>CursorTextColor</tabstop>
|
<tabstop>CursorTextColor</tabstop>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user