diff --git a/src/Mod/TechDraw/App/DrawHatch.cpp b/src/Mod/TechDraw/App/DrawHatch.cpp index 9fbad857b5..44587f4203 100644 --- a/src/Mod/TechDraw/App/DrawHatch.cpp +++ b/src/Mod/TechDraw/App/DrawHatch.cpp @@ -52,14 +52,18 @@ PROPERTY_SOURCE(TechDraw::DrawHatch, App::DocumentObject) DrawHatch::DrawHatch(void) { static const char *vgroup = "Hatch"; + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("Hatch", 0x00FF0000)); ADD_PROPERTY_TYPE(DirProjection ,(0,0,1.0) ,vgroup,App::Prop_None,"Projection direction when Hatch was defined"); //sb RO? ADD_PROPERTY_TYPE(Source,(0),vgroup,(App::PropertyType)(App::Prop_None),"The View + Face to be hatched"); ADD_PROPERTY_TYPE(HatchPattern ,(""),vgroup,App::Prop_None,"The hatch pattern file for this area"); - ADD_PROPERTY_TYPE(HatchColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"The color of the hatch pattern"); + ADD_PROPERTY_TYPE(HatchColor,(fcColor),vgroup,App::Prop_None,"The color of the hatch pattern"); - Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files"); std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/patterns/"; std::string defaultFileName = defaultDir + "simple.svg"; diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index 35cd344530..336279bdac 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -74,7 +74,7 @@ DrawPage::DrawPage(void) ProjectionType.setEnums(ProjectionTypeEnums); Base::Reference hGrp = - App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); // In preferences, 0 -> First Angle 1 -> Third Angle int projType = hGrp->GetInt("ProjectionAngle", -1); diff --git a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp index 9726ec6d45..d6ed143c03 100644 --- a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp +++ b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp @@ -59,7 +59,7 @@ DrawViewAnnotation::DrawViewAnnotation(void) static const char *vgroup = "Annotation"; Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); std::string fontName = hGrp->GetASCII("LabelFont", "Sans"); ADD_PROPERTY_TYPE(Text ,("Default Text"),vgroup,App::Prop_None,"The text to be displayed"); diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 55e82f0902..a1b32abab6 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -91,8 +91,9 @@ using namespace std; PROPERTY_SOURCE(TechDraw::DrawViewDetail, TechDraw::DrawViewPart) -DrawViewDetail::DrawViewDetail() : - m_mattingStyle(0) +DrawViewDetail::DrawViewDetail() +// : +// m_mattingStyle(0) { static const char *dgroup = "Detail"; @@ -271,9 +272,9 @@ void DrawViewDetail::getParameters() // handleFaces // radiusFudge? - Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); - m_mattingStyle = hGrp->GetInt("MattingStyle", 0); +// Base::Reference hGrp = App::GetApplication().GetUserParameter() +// .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); +// m_mattingStyle = hGrp->GetInt("MattingStyle", 0); } diff --git a/src/Mod/TechDraw/App/DrawViewDetail.h b/src/Mod/TechDraw/App/DrawViewDetail.h index 7a866e6943..e8a8561811 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.h +++ b/src/Mod/TechDraw/App/DrawViewDetail.h @@ -69,12 +69,12 @@ public: } public: - int getMattingStyle() const {return m_mattingStyle;} + //int getMattingStyle() const {return m_mattingStyle;} protected: Base::Vector3d toR3(const gp_Ax2 fromSystem, const Base::Vector3d fromPoint); void getParameters(void); - int m_mattingStyle; + //int m_mattingStyle; }; diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index af2806f532..9e24f121ce 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -86,13 +86,16 @@ enum RefType{ DrawViewDimension::DrawViewDimension(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); std::string fontName = hGrp->GetASCII("LabelFont", "Sans"); + hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); + double fontSize = hGrp->GetFloat("FontSize", 4.0); ADD_PROPERTY_TYPE(References2D,(0,0),"",(App::PropertyType)(App::Prop_None),"Projected Geometry References"); ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::PropertyType)(App::Prop_None),"3D Geometry References"); ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Format",App::Prop_None, "The name of the font to use"); - ADD_PROPERTY_TYPE(Fontsize,(4) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension text size in mm"); + ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension text size in mm"); ADD_PROPERTY_TYPE(FormatSpec,("%value%") ,"Format",(App::PropertyType)(App::Prop_None),"Dimension Format"); ADD_PROPERTY_TYPE(LineWidth,(0.5) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension line weight"); //ADD_PROPERTY_TYPE(CentreLines,(0) ,"Format",(App::PropertyType)(App::Prop_None),"Arc Dimension Center Mark"); @@ -226,14 +229,6 @@ std::string DrawViewDimension::getFormatedValue() const return str.toUtf8().constData(); } -bool DrawViewDimension::showUnits() const -{ - bool result = false; - Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); - result = hGrp->GetBool("ShowUnits", true); - return result; -} double DrawViewDimension::getDimValue() const { @@ -561,6 +556,15 @@ bool DrawViewDimension::has3DReferences(void) const return (References3D.getSize() > 0); } +bool DrawViewDimension::showUnits() const +{ + bool result = false; + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); + result = hGrp->GetBool("ShowUnits", true); + return result; +} + PyObject *DrawViewDimension::getPyObject(void) { if (PythonObject.is(Py::_None())) { diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 08b099fa6a..60a2b10606 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -544,7 +544,7 @@ const std::vector DrawViewPart::getVisibleFaceEdg void DrawViewPart::getRunControl() { Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/RunControl"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); m_sectionEdges = hGrp->GetBool("ShowSectionEdges", 1l); m_handleFaces = hGrp->GetBool("HandleFaces", 1l); } diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index 67ffa24c0f..52ffb73e55 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -59,7 +59,7 @@ DrawViewSpreadsheet::DrawViewSpreadsheet(void) static const char *vgroup = "Spreadsheet"; Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); std::string fontName = hGrp->GetASCII("LabelFont", "Sans"); ADD_PROPERTY_TYPE(Source ,(0),vgroup,App::Prop_None,"Spreadsheet to view"); diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp index 7a651a47b7..8030942013 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp @@ -35,6 +35,7 @@ #include "Workbench.h" #include "DlgPrefsTechDrawImp.h" +#include "DlgPrefsTechDraw2Imp.h" #include "ViewProviderPage.h" #include "ViewProviderDrawingView.h" #include "ViewProviderDimension.h" @@ -106,6 +107,7 @@ void TechDrawGuiExport initTechDrawGui() // register preferences pages new Gui::PrefPageProducer ("TechDraw"); + new Gui::PrefPageProducer ("TechDraw"); // add resources and reloads the translators loadTechDrawResource(); diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index 05798925b5..70abd4d341 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -34,6 +34,7 @@ set(TechDrawGui_MOC_HDRS QGIViewDimension.h TaskProjGroup.h DlgPrefsTechDrawImp.h + DlgPrefsTechDraw2Imp.h TaskLinkDim.h DlgTemplateField.h TaskSectionView.h @@ -46,6 +47,7 @@ qt4_add_resources(TechDrawGui_SRCS Resources/TechDraw.qrc) set(TechDrawGui_UIC_SRCS DlgPrefsTechDraw.ui + DlgPrefsTechDraw2.ui TaskProjGroup.ui TaskLinkDim.ui DlgTemplateField.ui @@ -72,6 +74,9 @@ SET(TechDrawGui_SRCS DlgPrefsTechDraw.ui DlgPrefsTechDrawImp.cpp DlgPrefsTechDrawImp.h + DlgPrefsTechDraw2.ui + DlgPrefsTechDraw2Imp.cpp + DlgPrefsTechDraw2Imp.h TaskLinkDim.ui TaskLinkDim.cpp TaskLinkDim.h diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 119164cb2a..d7c03ffe38 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -99,7 +99,7 @@ void CmdTechDrawNewPageDef::activated(int iMsg) { Q_UNUSED(iMsg); Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files"); std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/"; std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg"; @@ -169,7 +169,7 @@ void CmdTechDrawNewPage::activated(int iMsg) { Q_UNUSED(iMsg); Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files"); std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates"; QString templateDir = QString::fromStdString(hGrp->GetASCII("TemplateDir", defaultDir.c_str())); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index 20edf20c1f..d026baeb1a 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -6,32 +6,32 @@ 0 0 - 566 - 538 + 558 + 610 - TechDraw + TechDraw 1 - 20 - 250 + 10 + 450 531 - 108 + 151 - Templates + Files - 10 + 20 30 - 501 - 71 + 491 + 118 @@ -49,7 +49,7 @@ - + Gui::FileChooser::Directory @@ -58,17 +58,34 @@ TemplateDir - /Mod/TechDraw + /Mod/TechDraw/Files - + + + + Default Pattern File + + + + TemplateFile - /Mod/TechDraw + /Mod/TechDraw/Files + + + + + + + PatternFile + + + /Mod/TechDraw/Files @@ -78,10 +95,10 @@ - 20 - 160 + 10 + 330 541 - 91 + 121 @@ -91,18 +108,31 @@ - Font + Labels - 10 + 20 30 - 501 - 41 + 491 + 71 - + + + + + 0.100000000000000 + + + LabelSize + + + /Mod/TechDraw/Labels + + + @@ -110,16 +140,6 @@ - - - - LabelFont - - - Mod/TechDraw - - - @@ -136,135 +156,164 @@ + + + + osifont + + + LabelFont + + + Mod/TechDraw/Labels + + + + + + + Label Size + + + - 20 - 380 - 531 + 10 + 10 + 521 141 - Misc + General - - - - 10 - 30 - 501 - 95 - - - - - - - Projection Angle - - - - - - - ProjectionAngle - - - Mod/TechDraw - - + + + + + QFormLayout::AllNonFixedFieldsGrow + + + - First + Projection Angle - - + + + + + + ProjectionAngle + + + /Mod/TechDraw/General + + + + First + + + + + Third + + + + + + - Third + Hidden Line - - - - - - - Hidden Line - - - - - - - 1 - - - HiddenLine - - - Mod/TechDraw - - + + + + + + 1 + + + HiddenLine + + + Mod/TechDraw/General + + + + NeverShow + + + + + Solid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + - NeverShow + Detect Faces - - + + true + + + HandleFaces + + + /Mod/TechDraw/General + + + + + - Solid + Show Section Edges - - - - Dash + + ShowSectionEdges - - - - Dot + + /Mod/TechDraw/General - - - - DashDot - - - - - DashDotDot - - - - - - - - Default Pattern File - - - - - - - PatternFile - - - /Mod/TechDraw - - - - - + + + + + 10 - 10 - 531 - 141 + 160 + 521 + 164 @@ -273,10 +322,34 @@ - - + + - Selected + Section Hatch + + + + + + + Section Face + + + + + + + + 80 + 80 + 80 + + + + Background + + + /Mod/TechDraw/Colors @@ -314,6 +387,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -331,19 +417,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -357,13 +430,6 @@ - - - - Section Face - - - @@ -404,7 +470,7 @@ - Hidden + Hidden Line @@ -425,6 +491,37 @@ + + + + Selected + + + + + + + + 0 + 0 + 0 + + + + Hatch + + + /Mod/TechDraw/Colors + + + + + + + Background + + + @@ -451,6 +548,11 @@ Gui::ColorButton
Gui/PrefWidgets.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
Gui::PrefComboBox QComboBox @@ -461,6 +563,11 @@ QLineEdit
Gui/PrefWidgets.h
+ + Gui::PrefDoubleSpinBox + QDoubleSpinBox +
Gui/PrefWidgets.h
+
diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2.ui new file mode 100644 index 0000000000..6b24d95156 --- /dev/null +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2.ui @@ -0,0 +1,357 @@ + + + TechDrawGui::DlgPrefsTechDraw2Imp + + + + 0 + 0 + 521 + 384 + + + + TechDraw 2 + + + + + 10 + 20 + 501 + 141 + + + + Dimensions + + + + + 20 + 30 + 471 + 90 + + + + + + + Show Units + + + ShowUnits + + + /Mod/TechDraw/Dimensions + + + + + + + Color + + + + + + + Font Size + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 4.000000000000000 + + + FontSize + + + /Mod/TechDraw/Dimensions + + + + + + + + 0 + 0 + 0 + + + + Color + + + /Mod/TechDraw/Dimensions + + + + + + + + + + 10 + 160 + 501 + 201 + + + + Decorations + + + + + 20 + 30 + 471 + 161 + + + + + + + MattingStyle + + + /Mod/TechDraw/Decorations + + + + Round + + + + + Square + + + + + + + + Section Line Style + + + + + + + Center Line Style + + + + + + + Matting Style + + + + + + + + 175 + 175 + 175 + + + + CenterColor + + + /Mod/TechDraw/Decorations + + + + + + + 2 + + + CenterLine + + + /Mod/TechDraw/Decorations + + + + NeverShow + + + + + Sollid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + + + 2 + + + SectionLine + + + /Mod/TechDraw/Decorations + + + + NeverShow + + + + + Solid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + + + Center Line Color + + + + + + + Section Line Color + + + + + + + + 175 + 175 + 175 + + + + SectionColor + + + /Mod/TechDraw/Decorations + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Gui::ColorButton + QPushButton +
Gui/Widgets.h
+
+ + Gui::PrefColorButton + Gui::ColorButton +
Gui/PrefWidgets.h
+
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefComboBox + QComboBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefDoubleSpinBox + QDoubleSpinBox +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.cpp new file mode 100644 index 0000000000..bc56632a96 --- /dev/null +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (c) 2015 FreeCAD Developers * + * Author: WandererFan * + * Based on src/Mod/FEM/Gui/DlgSettingsFEMImp.cpp * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#include "DlgPrefsTechDraw2Imp.h" +#include + +using namespace TechDrawGui; + +DlgPrefsTechDraw2Imp::DlgPrefsTechDraw2Imp( QWidget* parent ) + : PreferencePage( parent ) +{ + this->setupUi(this); +} + +DlgPrefsTechDraw2Imp::~DlgPrefsTechDraw2Imp() +{ + // no need to delete child widgets, Qt does it all for us +} + +void DlgPrefsTechDraw2Imp::saveSettings() +{ + cbShowUnits->onSave(); + dsbFontSize->onSave(); + colDimColor->onSave(); + pcbMatting->onSave(); + pcbCenterStyle->onSave(); + colCenterLine->onSave(); + pcbSectionStyle->onSave(); + colSectionLine->onSave(); +} + +void DlgPrefsTechDraw2Imp::loadSettings() +{ + cbShowUnits->onRestore(); + dsbFontSize->onRestore(); + colDimColor->onRestore(); + pcbMatting->onRestore(); + pcbCenterStyle->onRestore(); + colCenterLine->onRestore(); + pcbSectionStyle->onRestore(); + colSectionLine->onRestore(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgPrefsTechDraw2Imp::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +#include diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.h b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.h new file mode 100644 index 0000000000..430e1aa202 --- /dev/null +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw2Imp.h @@ -0,0 +1,50 @@ + /************************************************************************** + * Copyright (c) 2015 FreeCAD Developers * + * Author: WandererFan * + * Based on src/Mod/FEM/Gui/DlgPrefsTechDraw2Imp.cpp * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef DRAWINGGUI_DLGPREFSTECHDRAW2IMP_H +#define DRAWINGGUI_DLGPREFSTECHDRAW2IMP_H + +#include +#include + +namespace TechDrawGui { + +class DlgPrefsTechDraw2Imp : public Gui::Dialog::PreferencePage, public Ui_DlgPrefsTechDraw2Imp +{ + Q_OBJECT + +public: + DlgPrefsTechDraw2Imp( QWidget* parent = 0 ); + ~DlgPrefsTechDraw2Imp(); + +protected: + void saveSettings(); + void loadSettings(); + void changeEvent(QEvent *e); +}; + +} // namespace TechDrawGui + +#endif // DRAWINGGUI_DLGPREFSTECHDRAW2IMP_H diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index db59942952..c664fc26c7 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -43,33 +43,51 @@ DlgPrefsTechDrawImp::~DlgPrefsTechDrawImp() void DlgPrefsTechDrawImp::saveSettings() { + cb_HidLine->onSave(); + cb_Angle->onSave(); + cb_Faces->onSave(); + cb_SectionEdges->onSave(); + pcb_Normal->onSave(); pcb_Select->onSave(); pcb_PreSelect->onSave(); pcb_Hidden->onSave(); pcb_Surface->onSave(); + pcb_Background->onSave(); + pcb_Hatch->onSave(); + le_LabelFont->onSave(); + dsb_LabelSize->onSave(); + pfc_DefTemp->onSave(); pfc_DefDir->onSave(); - cb_HidLine->onSave(); - cb_Angle->onSave(); pfc_HatchFile->onSave(); //pfc_HatchDir->onSave(); } void DlgPrefsTechDrawImp::loadSettings() { + cb_HidLine->onRestore(); + cb_Angle->onRestore(); + cb_Faces->onRestore(); + cb_SectionEdges->onRestore(); + pcb_Normal->onRestore(); pcb_Select->onRestore(); pcb_PreSelect->onRestore(); pcb_Hidden->onRestore(); pcb_Surface->onRestore(); + pcb_Background->onRestore(); + pcb_Hatch->onRestore(); + le_LabelFont->onRestore(); + dsb_LabelSize->onRestore(); + pfc_DefTemp->onRestore(); pfc_DefDir->onRestore(); - cb_HidLine->onRestore(); - cb_Angle->onRestore(); pfc_HatchFile->onRestore(); + + //pfc_HatchDir->onRestore(); } diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.h b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.h index 5db5c6a052..d5f297c3a5 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.h +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.h @@ -1,7 +1,7 @@ /************************************************************************** * Copyright (c) 2015 FreeCAD Developers * * Author: WandererFan * - * Based on src/Mod/FEM/Gui/DlgPrefsTechDrawImp.cpp * + * Based on src/Mod/FEM/Gui/DlgPrefsTechDrawImp.cpp * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/TechDraw/Gui/QGCustomText.cpp b/src/Mod/TechDraw/Gui/QGCustomText.cpp index a31c315843..5bed7c15db 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomText.cpp @@ -40,6 +40,7 @@ #include #include +#include "QGIView.h" #include "QGCustomText.h" using namespace TechDrawGui; @@ -156,10 +157,24 @@ void QGCustomText::paint ( QPainter * painter, const QStyleOptionGraphicsItem * QColor QGCustomText::getNormalColor() { - Base::Reference hGrp = getParmGroup(); - App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); - return fcColor.asValue(); + QColor result; + QGIView *parent; + QGraphicsItem* qparent = parentItem(); + if (qparent == nullptr) { + parent = nullptr; + } else { + parent = dynamic_cast (qparent); + } + + if (parent != nullptr) { + result = parent->getNormalColor(); + } else { + Base::Reference hGrp = getParmGroup(); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); + result = fcColor.asValue(); + } + return result; } QColor QGCustomText::getPreColor() diff --git a/src/Mod/TechDraw/Gui/QGCustomText.h b/src/Mod/TechDraw/Gui/QGCustomText.h index e6ed3d2fab..be0dddd2a4 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.h +++ b/src/Mod/TechDraw/Gui/QGCustomText.h @@ -54,15 +54,15 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); virtual void centerAt(QPointF centerPos); virtual void centerAt(double cX, double cY); + virtual QColor getNormalColor(void); + virtual QColor getPreColor(void); + virtual QColor getSelectColor(void); protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); QVariant itemChange(GraphicsItemChange change, const QVariant &value); - QColor getNormalColor(void); - QColor getPreColor(void); - QColor getSelectColor(void); Base::Reference getParmGroup(void); bool isHighlighted; diff --git a/src/Mod/TechDraw/Gui/QGICenterLine.cpp b/src/Mod/TechDraw/Gui/QGICenterLine.cpp index c167e747e2..31a6b0a48a 100644 --- a/src/Mod/TechDraw/Gui/QGICenterLine.cpp +++ b/src/Mod/TechDraw/Gui/QGICenterLine.cpp @@ -69,7 +69,7 @@ void QGICenterLine::setBounds(double x1,double y1,double x2,double y2) QColor QGICenterLine::getCenterColor() { Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x08080800)); return fcColor.asValue(); } @@ -77,7 +77,7 @@ QColor QGICenterLine::getCenterColor() Qt::PenStyle QGICenterLine::getCenterStyle() { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> - GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); Qt::PenStyle centerStyle = static_cast (hGrp->GetInt("CenterLine",3)); return centerStyle; } diff --git a/src/Mod/TechDraw/Gui/QGIEdge.cpp b/src/Mod/TechDraw/Gui/QGIEdge.cpp index 28d9a6c3bf..93fc0cf42b 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.cpp +++ b/src/Mod/TechDraw/Gui/QGIEdge.cpp @@ -104,7 +104,7 @@ QColor QGIEdge::getHiddenColor() Qt::PenStyle QGIEdge::getHiddenStyle() { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> - GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); Qt::PenStyle hidStyle = static_cast (hGrp->GetInt("HiddenLine",2)); return hidStyle; } diff --git a/src/Mod/TechDraw/Gui/QGIMatting.cpp b/src/Mod/TechDraw/Gui/QGIMatting.cpp index 67bcfad2f3..f6dd69799b 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.cpp +++ b/src/Mod/TechDraw/Gui/QGIMatting.cpp @@ -46,7 +46,7 @@ using namespace TechDrawGui; QGIMatting::QGIMatting() : m_height(10.0), m_width(10.0), - m_holeStyle(0), + //m_holeStyle(0), m_radius(5.0) { @@ -103,7 +103,7 @@ void QGIMatting::draw() QPainterPath ppOut; ppOut.addRect(outline); QPainterPath ppCut; - if (m_holeStyle == 0) { + if (getHoleStyle() == 0) { QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius); ppCut.addEllipse(roundCutout); } else { @@ -116,6 +116,14 @@ void QGIMatting::draw() m_border->setPath(ppCut); } +int QGIMatting::getHoleStyle() +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); + int style = hGrp->GetInt("MattingStyle", 1l); + return style; +} + void QGIMatting::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; diff --git a/src/Mod/TechDraw/Gui/QGIMatting.h b/src/Mod/TechDraw/Gui/QGIMatting.h index 567d9391a6..054b5eaa51 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.h +++ b/src/Mod/TechDraw/Gui/QGIMatting.h @@ -53,15 +53,16 @@ public: virtual void centerAt(double cX, double cY); virtual void setSize(double w, double h) {m_height = h; m_width = w;} - virtual void setHoleStyle(int hs) {m_holeStyle = hs;} + //virtual void setHoleStyle(int hs) {m_holeStyle = hs;} virtual void setRadius(double r) {m_radius = r;} virtual void draw(void); protected: double m_height; double m_width; - int m_holeStyle; //round or rect + //int m_holeStyle; //round or rect double m_radius; + int getHoleStyle(void); QGraphicsPathItem* m_mat; QGraphicsPathItem* m_border; diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index f2414106aa..226c2184f2 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -130,26 +130,68 @@ void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o QColor QGIPrimPath::getNormalColor() { - Base::Reference hGrp = getParmGroup(); - App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); - return fcColor.asValue(); + QColor result; + QGIView *parent; + QGraphicsItem* qparent = parentItem(); + if (qparent == nullptr) { + parent = nullptr; + } else { + parent = dynamic_cast (qparent); + } + + if (parent != nullptr) { + result = parent->getNormalColor(); + } else { + Base::Reference hGrp = getParmGroup(); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); + result = fcColor.asValue(); + } + return result; } QColor QGIPrimPath::getPreColor() { - Base::Reference hGrp = getParmGroup(); - App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0xFFFF0000)); - return fcColor.asValue(); + QColor result; + QGIView *parent; + QGraphicsItem* qparent = parentItem(); + if (qparent == nullptr) { + parent = nullptr; + } else { + parent = dynamic_cast (qparent); + } + + if (parent != nullptr) { + result = parent->getPreColor(); + } else { + Base::Reference hGrp = getParmGroup(); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0xFFFF0000)); + result = fcColor.asValue(); + } + return result; } QColor QGIPrimPath::getSelectColor() { - Base::Reference hGrp = getParmGroup(); - App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000)); - return fcColor.asValue(); + QColor result; + QGIView *parent; + QGraphicsItem* qparent = parentItem(); + if (qparent == nullptr) { + parent = nullptr; + } else { + parent = dynamic_cast (qparent); + } + + if (parent != nullptr) { + result = parent->getSelectColor(); + } else { + Base::Reference hGrp = getParmGroup(); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000)); + result = fcColor.asValue(); + } + return result; } void QGIPrimPath::setWidth(double w) diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index 04e2cd93a1..d84f937ca0 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -61,9 +61,9 @@ protected: virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - QColor getNormalColor(void); - QColor getPreColor(void); - QColor getSelectColor(void); + virtual QColor getNormalColor(void); + virtual QColor getPreColor(void); + virtual QColor getSelectColor(void); Base::Reference getParmGroup(void); bool isHighlighted; diff --git a/src/Mod/TechDraw/Gui/QGIUserTypes.h b/src/Mod/TechDraw/Gui/QGIUserTypes.h index 2165a9351d..8571677c04 100644 --- a/src/Mod/TechDraw/Gui/QGIUserTypes.h +++ b/src/Mod/TechDraw/Gui/QGIUserTypes.h @@ -1,7 +1,7 @@ /* Derived QGraphicsItem Classes type() Values -Qt First UserType = 65536 +Qt First UserType>> QGraphicsItem::UserType = 65536 QGraphicsItemView : 101 QGraphicsItemViewPart : 102 diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index adf8300647..a92f46e574 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -486,7 +486,7 @@ Base::Reference QGIView::getParmGroupCol() QString QGIView::getPrefFont() { Base::Reference hGrp = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); std::string fontName = hGrp->GetASCII("LabelFont", "Sans"); return QString::fromStdString(fontName); } @@ -494,7 +494,7 @@ QString QGIView::getPrefFont() double QGIView::getPrefFontSize() { Base::Reference hGrp = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); double fontSize = hGrp->GetFloat("LabelSize", 5.0); return fontSize; } diff --git a/src/Mod/TechDraw/Gui/QGIView.h b/src/Mod/TechDraw/Gui/QGIView.h index fa87f921af..008dd5c4c8 100644 --- a/src/Mod/TechDraw/Gui/QGIView.h +++ b/src/Mod/TechDraw/Gui/QGIView.h @@ -53,12 +53,19 @@ public: enum {Type = QGraphicsItem::UserType + 101}; int type() const override { return Type;} + virtual QRectF boundingRect() const override; + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + virtual void paint( QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget = nullptr ) override; const char * getViewName() const; void setViewFeature(TechDraw::DrawView *obj); TechDraw::DrawView * getViewObject() const; virtual void toggleBorder(bool state = true); + virtual void toggleCache(bool state); + virtual void updateView(bool update = false); virtual void drawBorder(void); virtual void isVisible(bool state) { m_visibility = state; }; virtual bool isVisible(void) {return m_visibility;}; @@ -77,14 +84,9 @@ public: void alignTo(QGraphicsItem*, const QString &alignment); void setLocked(bool /*state*/ = true) { locked = true; } - virtual void toggleCache(bool state); - virtual void updateView(bool update = false); - virtual void paint( QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *widget = nullptr ) override; - virtual QRectF boundingRect() const override; - - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + virtual QColor getNormalColor(void); + virtual QColor getPreColor(void); + virtual QColor getSelectColor(void); protected: QGIView* getQGIVByName(std::string name); @@ -99,9 +101,6 @@ protected: virtual QRectF customChildrenBoundingRect(void); void dumpRect(char* text, QRectF r); - QColor getNormalColor(void); - QColor getPreColor(void); - QColor getSelectColor(void); QString getPrefFont(void); double getPrefFontSize(void); Base::Reference getParmGroupCol(void); diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index 82e446f6b6..bb27b0052a 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -146,6 +146,7 @@ QGIViewDimension::QGIViewDimension() : datumLabel = new QGIDatumLabel(); addToGroup(datumLabel); + datumLabel->setPrettyNormal(); dimLines = new QGIDimLines(); addToGroup(dimLines); aHead1 = new QGIArrow(); @@ -1257,4 +1258,15 @@ void QGIViewDimension::setPens(void) dimLines->setWidth(m_lineWidth); } +QColor QGIViewDimension::getNormalColor() +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); + App::Color fcColor; + fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000)); + m_colNormal = fcColor.asValue(); + return m_colNormal; +} + + #include diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.h b/src/Mod/TechDraw/Gui/QGIViewDimension.h index efc761560b..2b6ac837c3 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.h +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "QGIView.h" #include "QGCustomText.h" @@ -97,6 +98,7 @@ public: virtual void drawBorder(); virtual void updateView(bool update = false) override; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); + virtual QColor getNormalColor(void); public Q_SLOTS: void datumLabelDragged(void); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 928951b5ac..974f6eb1e3 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -626,7 +626,7 @@ void QGIViewPart::drawMatting() mat->setRadius(radius); QRectF displayArea = customChildrenBoundingRect(); mat->setSize(displayArea.width(),displayArea.height()); - mat->setHoleStyle(dvd->getMattingStyle()); + //mat->setHoleStyle(dvd->getMattingStyle()); mat->draw(); mat->show(); }