[TD]Centralize preference getters

This commit is contained in:
wandererfan
2020-04-12 20:44:08 -04:00
committed by WandererFan
parent a2b8aa6b23
commit e80c576241
61 changed files with 881 additions and 501 deletions

View File

@@ -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;
}