[TD]common preference getters for hatches

This commit is contained in:
wandererfan
2020-03-17 19:32:12 -04:00
committed by WandererFan
parent 6a92cb968d
commit 4bc0718a3b
6 changed files with 45 additions and 32 deletions

View File

@@ -627,6 +627,15 @@ std::string DrawGeomHatch::prefGeomHatchName()
return result;
}
App::Color DrawGeomHatch::prefGeomHatchColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000));
return fcColor;
}
// Python Drawing feature ---------------------------------------------------------

View File

@@ -23,9 +23,10 @@
#ifndef _TechDraw_DrawGeomHatch_h_
#define _TechDraw_DrawGeomHatch_h_
# include <App/DocumentObject.h>
# include <App/FeaturePython.h>
# include <App/PropertyLinks.h>
#include <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/Material.h>
#include <App/PropertyLinks.h>
#include <App/PropertyFile.h>
class TopoDS_Edge;
@@ -80,6 +81,8 @@ public:
static TopoDS_Face extractFace(DrawViewPart* source, int iface );
static std::string prefGeomHatchFile(void);
static std::string prefGeomHatchName();
static App::Color prefGeomHatchColor();
protected:
virtual void onDocumentRestored() override;

View File

@@ -261,7 +261,7 @@ void DrawHatch::unsetupObject(void)
App::DocumentObject::unsetupObject();
}
//standard preference getter
//standard preference getters
std::string DrawHatch::prefSvgHatch(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
@@ -273,6 +273,16 @@ std::string DrawHatch::prefSvgHatch(void)
return result;
}
App::Color DrawHatch::prefSvgHatchColor(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Hatch", 0x00FF0000));
return fcColor;
}
// Python Drawing feature ---------------------------------------------------------
namespace App {

View File

@@ -23,9 +23,10 @@
#ifndef _TechDraw_DrawHatch_h_
#define _TechDraw_DrawHatch_h_
# include <App/DocumentObject.h>
# include <App/FeaturePython.h>
# include <App/PropertyLinks.h>
#include <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/Material.h>
#include <App/PropertyLinks.h>
#include <App/PropertyFile.h>
namespace TechDraw
@@ -62,7 +63,8 @@ public:
bool empty(void);
static bool faceIsHatched(int i,std::vector<TechDraw::DrawHatch*> hatchObjs);
static std::string prefSvgHatch(void);
static App::Color prefSvgHatchColor(void);
protected:
void onChanged(const App::Property* prop) override;
virtual void onDocumentRestored() override;

View File

@@ -71,7 +71,8 @@ ViewProviderGeomHatch::ViewProviderGeomHatch()
static const char *vgroup = "GeomHatch";
ADD_PROPERTY_TYPE(ColorPattern,(0),vgroup,App::Prop_None,"Color of the pattern");
ADD_PROPERTY_TYPE(ColorPattern,(TechDraw::DrawGeomHatch::prefGeomHatchColor()),
vgroup,App::Prop_None,"Color of the pattern");
ADD_PROPERTY_TYPE(WeightPattern,(0),vgroup,App::Prop_None,"GeometricHatch pattern line thickness");
getParameters();
@@ -183,13 +184,9 @@ void ViewProviderGeomHatch::updateGraphic(void)
void ViewProviderGeomHatch::getParameters(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000));
ColorPattern.setValue(fcColor);
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Graphic");

View File

@@ -32,15 +32,11 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
//#include <Base/Exception.h>
//#include <Base/Sequencer.h>
#include <Base/UnitsApi.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
//#include <Gui/SoFCSelection.h>
//#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
@@ -68,12 +64,8 @@ ViewProviderHatch::ViewProviderHatch()
sPixmap = "TechDraw_Tree_Hatch";
static const char *vgroup = "Hatch";
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Hatch", 0x00FF0000));
ADD_PROPERTY_TYPE(HatchColor,(fcColor),vgroup,App::Prop_None,"The color of the hatch pattern");
ADD_PROPERTY_TYPE(HatchColor,(TechDraw::DrawHatch::prefSvgHatchColor()),
vgroup,App::Prop_None,"The color of the hatch pattern");
ADD_PROPERTY_TYPE(HatchScale,(1.0),vgroup,App::Prop_None,"Hatch pattern size adjustment");
HatchScale.setConstraints(&scaleRange);
}
@@ -124,12 +116,12 @@ TechDraw::DrawHatch* ViewProviderHatch::getViewObject() const
return dynamic_cast<TechDraw::DrawHatch*>(pcObject);
}
bool ViewProviderHatch::canDelete(App::DocumentObject *obj) const
{
// deletion of hatches don't destroy anything
// thus we can pass this action
Q_UNUSED(obj)
return true;
bool ViewProviderHatch::canDelete(App::DocumentObject *obj) const
{
// deletion of hatches don't destroy anything
// thus we can pass this action
Q_UNUSED(obj)
return true;
}
Gui::MDIView *ViewProviderHatch::getMDIView() const