[TD]Centralize preference getters
This commit is contained in:
@@ -155,6 +155,8 @@ SET(TechDraw_SRCS
|
||||
LineGroup.h
|
||||
ArrowPropEnum.cpp
|
||||
ArrowPropEnum.h
|
||||
Preferences.cpp
|
||||
Preferences.h
|
||||
)
|
||||
|
||||
SET(Geometry_SRCS
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <Mod/TechDraw/App/CosmeticVertexPy.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Preferences.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "Geometry.h"
|
||||
#include "DrawViewPart.h"
|
||||
@@ -105,9 +106,7 @@ std::string LineFormat::toString(void) const
|
||||
//static preference getters.
|
||||
double LineFormat::getDefEdgeWidth()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
std::string lgName = Preferences::lineGroup();
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
double width = lg->getWeight("Graphic");
|
||||
@@ -117,11 +116,7 @@ double LineFormat::getDefEdgeWidth()
|
||||
|
||||
App::Color LineFormat::getDefEdgeColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); //black
|
||||
return fcColor;
|
||||
return Preferences::normalColor();
|
||||
}
|
||||
|
||||
int LineFormat::getDefEdgeStyle()
|
||||
@@ -139,14 +134,9 @@ TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence)
|
||||
CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
|
||||
{
|
||||
point(Base::Vector3d(0.0, 0.0, 0.0));
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x00000000));
|
||||
|
||||
permaPoint = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
linkGeom = -1;
|
||||
color = fcColor;
|
||||
color = Preferences::vertexColor();
|
||||
size = 3.0;
|
||||
style = 1;
|
||||
visible = true;
|
||||
@@ -172,14 +162,9 @@ CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::V
|
||||
|
||||
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0xff000000));
|
||||
|
||||
permaPoint = loc;
|
||||
linkGeom = -1;
|
||||
color = fcColor;
|
||||
color = Preferences::vertexColor();
|
||||
//TODO: size = hGrp->getFloat("VertexSize",30.0);
|
||||
size = 30.0;
|
||||
style = 1; //TODO: implement styled vertexes
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "DrawViewDimension.h"
|
||||
#include "DrawViewBalloon.h"
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPagePy.h> // generated from DrawPagePy.xml
|
||||
|
||||
@@ -77,12 +78,9 @@ DrawPage::DrawPage(void)
|
||||
static const char *group = "Page";
|
||||
nowUnsetting = false;
|
||||
forceRedraw(false);
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", true); //this is the default value for new pages!
|
||||
|
||||
ADD_PROPERTY_TYPE(KeepUpdated, (autoUpdate), group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(KeepUpdated, (Preferences::keepPagesUpToDate()),
|
||||
group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(Template, (0), group, (App::PropertyType)(App::Prop_None), "Attached Template");
|
||||
Template.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(Views, (0), group, (App::PropertyType)(App::Prop_None), "Attached Views");
|
||||
@@ -90,25 +88,18 @@ DrawPage::DrawPage(void)
|
||||
|
||||
// Projection Properties
|
||||
ProjectionType.setEnums(ProjectionTypeEnums);
|
||||
ADD_PROPERTY(ProjectionType, ((long)Preferences::projectionAngle()));
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
double defScale = hGrp->GetFloat("DefaultScale",1.0);
|
||||
ADD_PROPERTY_TYPE(Scale, (defScale), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page");
|
||||
|
||||
// In preferences, 0 -> First Angle 1 -> Third Angle
|
||||
int projType = hGrp->GetInt("ProjectionAngle", -1);
|
||||
|
||||
if (projType == -1) {
|
||||
ADD_PROPERTY(ProjectionType, ((long)0)); // Default to first angle
|
||||
} else {
|
||||
ADD_PROPERTY(ProjectionType, ((long)projType));
|
||||
}
|
||||
|
||||
ADD_PROPERTY_TYPE(Scale, (1.0), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page");
|
||||
ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, (App::PropertyType)(App::Prop_None),
|
||||
"Auto-numbering for Balloons");
|
||||
|
||||
Scale.setConstraints(&scaleRange);
|
||||
double defScale = hGrp->GetFloat("DefaultScale",1.0);
|
||||
Scale.setValue(defScale);
|
||||
balloonPlacing = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Preferences.h"
|
||||
#include "DrawPage.h"
|
||||
#include "DrawProjGroupItem.h"
|
||||
#include "DrawProjGroup.h"
|
||||
@@ -1250,10 +1251,7 @@ std::vector<DrawProjGroupItem*> DrawProjGroup::getViewsAsDPGI()
|
||||
|
||||
int DrawProjGroup::getDefProjConv(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
int defProjConv = hGrp->GetInt("ProjectionAngle",0);
|
||||
return defProjConv;
|
||||
return Preferences::projectionAngle();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "DrawUtil.h"
|
||||
|
||||
@@ -499,9 +500,8 @@ double DrawUtil::sensibleScale(double working_scale)
|
||||
|
||||
double DrawUtil::getDefaultLineWeight(std::string lineType)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
std::string lgName = Preferences::lineGroup();
|
||||
|
||||
auto lg = LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
double weight = lg->getWeight(lineType);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "DrawProjGroup.h"
|
||||
#include "DrawProjGroupItem.h"
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "Preferences.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "Geometry.h"
|
||||
#include "Cosmetic.h"
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "DrawViewAnnotation.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -58,15 +59,12 @@ DrawViewAnnotation::DrawViewAnnotation(void)
|
||||
{
|
||||
static const char *vgroup = "Annotation";
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
double defFontSize = hGrp->GetFloat("LabelSize", 5.0);
|
||||
|
||||
ADD_PROPERTY_TYPE(Text ,("Default Text"),vgroup,App::Prop_None,"Annotation text");
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),vgroup,App::Prop_None, "Font name");
|
||||
ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()),
|
||||
vgroup,App::Prop_None, "Font name");
|
||||
ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"Text color");
|
||||
ADD_PROPERTY_TYPE(TextSize,(defFontSize),vgroup,App::Prop_None,"Text size");
|
||||
ADD_PROPERTY_TYPE(TextSize, (Preferences::labelFontSizeMM()),
|
||||
vgroup,App::Prop_None,"Text size");
|
||||
ADD_PROPERTY_TYPE(MaxWidth,(-1.0),vgroup,App::Prop_None,"Maximum width of the annotation block.\n -1 means no maximum width.");
|
||||
ADD_PROPERTY_TYPE(LineSpace,(80),vgroup,App::Prop_None,"Line spacing in %. 100 means the height of a line.");
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
|
||||
#include <Mod/Measure/App/Measurement.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Geometry.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewBalloon.h"
|
||||
@@ -273,12 +274,8 @@ int DrawViewBalloon::prefShape(void) const
|
||||
}
|
||||
|
||||
int DrawViewBalloon::prefEnd(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
int end = hGrp->GetInt("BalloonArrow", 1);
|
||||
return end;
|
||||
{
|
||||
return Preferences::balloonArrow();
|
||||
}
|
||||
|
||||
Base::Vector3d DrawViewBalloon::getOriginOffset() const
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "Cosmetic.h"
|
||||
@@ -446,14 +447,6 @@ void DrawViewDetail::unsetupObject()
|
||||
|
||||
void DrawViewDetail::getParameters()
|
||||
{
|
||||
// what parameters are useful?
|
||||
// handleFaces
|
||||
// radiusFudge?
|
||||
|
||||
// Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
// .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
|
||||
// m_mattingStyle = hGrp->GetInt("MattingStyle", 0);
|
||||
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
|
||||
#include <Mod/Measure/App/Measurement.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Geometry.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewDimension.h"
|
||||
@@ -1164,12 +1165,8 @@ bool DrawViewDimension::showUnits() const
|
||||
}
|
||||
|
||||
bool DrawViewDimension::useDecimals() const
|
||||
{
|
||||
bool result = false;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
result = hGrp->GetBool("UseGlobalDecimals", true);
|
||||
return result;
|
||||
{
|
||||
return Preferences::useGlobalDecimals();
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getPrefix() const
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "DrawGeomHatch.h"
|
||||
#include "DrawHatch.h"
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "Cosmetic.h"
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "DrawViewSpreadsheet.h"
|
||||
|
||||
#include <Mod/Spreadsheet/App/Cell.h>
|
||||
@@ -58,15 +59,12 @@ DrawViewSpreadsheet::DrawViewSpreadsheet(void)
|
||||
{
|
||||
static const char *vgroup = "Spreadsheet";
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
|
||||
ADD_PROPERTY_TYPE(Source ,(0),vgroup,App::Prop_None,"Spreadsheet to view");
|
||||
Source.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(CellStart ,("A1"),vgroup,App::Prop_None,"The top left cell of the range to display");
|
||||
ADD_PROPERTY_TYPE(CellEnd ,("B2"),vgroup,App::Prop_None,"The bottom right cell of the range to display");
|
||||
ADD_PROPERTY_TYPE(Font ,((fontName.c_str())),vgroup,App::Prop_None,"The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()),
|
||||
vgroup,App::Prop_None,"The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"The default color of the text and lines");
|
||||
ADD_PROPERTY_TYPE(TextSize,(12.0),vgroup,App::Prop_None,"The size of the text");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the cell lines");
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "LineGroup.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -173,16 +174,7 @@ LineGroup* LineGroup::lineGroupFactory(std::string groupName)
|
||||
{
|
||||
LineGroup* lg = new LineGroup(groupName);
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
|
||||
std::string defaultFileName = defaultDir + "LineGroup.csv";
|
||||
|
||||
std::string lgFileName = hGrp->GetASCII("LineGroupFile",defaultFileName.c_str());
|
||||
if (lgFileName.empty()) {
|
||||
lgFileName = defaultFileName;
|
||||
}
|
||||
std::string lgFileName = Preferences::lineGroupFile();
|
||||
|
||||
std::string lgRecord = LineGroup::getRecordFromFile(lgFileName, groupName);
|
||||
|
||||
@@ -202,11 +194,9 @@ LineGroup* LineGroup::lineGroupFactory(std::string groupName)
|
||||
double LineGroup::getDefaultWidth(std::string weightName, std::string groupName)
|
||||
{
|
||||
//default line weights
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = groupName;
|
||||
if (groupName.empty()) {
|
||||
lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
lgName = Preferences::lineGroup();
|
||||
}
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
|
||||
212
src/Mod/TechDraw/App/Preferences.cpp
Normal file
212
src/Mod/TechDraw/App/Preferences.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2020 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <string>
|
||||
#include <QString>
|
||||
//#include <QFont>
|
||||
//#include <QColor>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
|
||||
//getters for parameters used in multiple places.
|
||||
//ensure this is in sync with preference page uis
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
const double Preferences::DefaultFontSizeInMM = 5.0;
|
||||
|
||||
std::string Preferences::labelFont()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
return fontName;
|
||||
}
|
||||
|
||||
QString Preferences::labelFontQString()
|
||||
{
|
||||
std::string fontName = labelFont();
|
||||
return QString::fromStdString(fontName);
|
||||
}
|
||||
|
||||
double Preferences::labelFontSizeMM()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Labels");
|
||||
return hGrp->GetFloat("LabelSize", DefaultFontSizeInMM);
|
||||
}
|
||||
|
||||
double Preferences::dimFontSizeMM()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
return hGrp->GetFloat("FontSize", DefaultFontSizeInMM);
|
||||
}
|
||||
|
||||
App::Color Preferences::normalColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::selectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("SelectionColor", 0x00FF00FF); //#00FF00 lime
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", defColor));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::preselectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("HighlightColor", 0xFFFF00FF); //#FFFF00 yellow
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", defColor));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::vertexColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
|
||||
//lightgray #D3D3D3
|
||||
|
||||
bool Preferences::keepPagesUpToDate()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", true);
|
||||
return autoUpdate;
|
||||
}
|
||||
|
||||
bool Preferences::useGlobalDecimals()
|
||||
{
|
||||
bool result = false;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
|
||||
GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
result = hGrp->GetBool("UseGlobalDecimals", true);
|
||||
return result;
|
||||
}
|
||||
|
||||
int Preferences::projectionAngle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
int projType = hGrp->GetInt("ProjectionAngle", 0); //First Angle
|
||||
return projType;
|
||||
}
|
||||
|
||||
std::string Preferences::lineGroup()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
return lgName;
|
||||
}
|
||||
|
||||
int Preferences::balloonArrow()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
int end = hGrp->GetInt("BalloonArrow", 0);
|
||||
return end;
|
||||
}
|
||||
|
||||
QString Preferences::defaultTemplate()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Files");
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/";
|
||||
std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg";
|
||||
QString templateFileName = QString::fromStdString(hGrp->GetASCII("TemplateFile",defaultFileName.c_str()));
|
||||
if (templateFileName.isEmpty()) {
|
||||
templateFileName = QString::fromStdString(defaultFileName);
|
||||
}
|
||||
return templateFileName;
|
||||
}
|
||||
|
||||
QString Preferences::defaultTemplateDir()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.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()));
|
||||
return templateDir;
|
||||
}
|
||||
|
||||
std::string Preferences::lineGroupFile()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
|
||||
GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
|
||||
std::string defaultFileName = defaultDir + "LineGroup.csv";
|
||||
|
||||
std::string lgFileName = hGrp->GetASCII("LineGroupFile",defaultFileName.c_str());
|
||||
return lgFileName;
|
||||
}
|
||||
75
src/Mod/TechDraw/App/Preferences.h
Normal file
75
src/Mod/TechDraw/App/Preferences.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2020 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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 _Preferences_h_
|
||||
#define _Preferences_h_
|
||||
|
||||
#include <string>
|
||||
|
||||
//#include <QString>
|
||||
//#include <QFont>
|
||||
|
||||
//class QFont;
|
||||
class QString;
|
||||
//class QColor;
|
||||
|
||||
namespace App
|
||||
{
|
||||
class Color;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
//getters for parameters used in multiple places.
|
||||
class TechDrawExport Preferences {
|
||||
|
||||
public:
|
||||
static std::string labelFont();
|
||||
static QString labelFontQString();
|
||||
static double labelFontSizeMM();
|
||||
static double dimFontSizeMM();
|
||||
|
||||
static App::Color normalColor();
|
||||
static App::Color selectColor();
|
||||
static App::Color preselectColor();
|
||||
static App::Color vertexColor();
|
||||
|
||||
static bool useGlobalDecimals();
|
||||
static bool keepPagesUpToDate();
|
||||
|
||||
static int projectionAngle();
|
||||
static std::string lineGroup();
|
||||
|
||||
static int balloonArrow();
|
||||
|
||||
static QString defaultTemplate();
|
||||
static QString defaultTemplateDir();
|
||||
static std::string lineGroupFile();
|
||||
|
||||
|
||||
|
||||
static const double DefaultFontSizeInMM;
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
#endif
|
||||
Reference in New Issue
Block a user