add angularDeflection property to ViewProvider

issue #1868
This commit is contained in:
Sebastian Hoogen
2015-03-08 21:05:19 +01:00
committed by wmayer
parent 4b9264e208
commit 7cc178adf5
7 changed files with 87 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@@ -70,6 +70,7 @@ void DlgSettings3DViewPart::on_maxDeviation_valueChanged(double v)
void DlgSettings3DViewPart::saveSettings()
{
ui->maxDeviation->onSave();
ui->maxAngularDeflection->onSave();
// search for Part view providers and apply the new settings
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
@@ -85,6 +86,7 @@ void DlgSettings3DViewPart::saveSettings()
void DlgSettings3DViewPart::loadSettings()
{
ui->maxDeviation->onRestore();
ui->maxAngularDeflection->onRestore();
}
/**

View File

@@ -422,6 +422,7 @@ bool ViewProviderPartBase::loadParameter()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
float angularDeflection = hGrp->GetFloat("MeshAngularDeflection",28.65);
bool novertexnormals = hGrp->GetBool("NoPerVertexNormals",false);
bool qualitynormals = hGrp->GetBool("QualityNormals",false);
@@ -429,6 +430,9 @@ bool ViewProviderPartBase::loadParameter()
this->meshDeviation = deviation;
changed = true;
}
if (this->angularDeflection != angularDeflection) {
this->angularDeflection = angularDeflection;
}
if (this->noPerVertexNormals != novertexnormals) {
this->noPerVertexNormals = novertexnormals;
changed = true;
@@ -472,8 +476,14 @@ void ViewProviderPartBase::updateData(const App::Property* prop)
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 *
this->meshDeviation;
Standard_Real AngDeflectionRads = this-> angularDeflection / 180.0 * M_PI;
#if OCC_VERSION_HEX >= 0x060600
BRepMesh_IncrementalMesh(cShape,deflection,Standard_False,
AngDeflectionRads,Standard_True);
#else
BRepMesh_IncrementalMesh(cShape,deflection);
#endif
//BRepMesh_IncrementalMesh MESH(cShape,meshDeviation);
// We must reset the location here because the transformation data
// are set in the placement property

View File

@@ -124,6 +124,7 @@ protected:
private:
// settings stuff
float meshDeviation;
float angularDeflection;
bool noPerVertexNormals;
bool qualityNormals;
static App::PropertyFloatConstraint::Constraints floatRange;

View File

@@ -220,6 +220,7 @@ void GetNormals(const TopoDS_Face& theFace,
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0,64.0,1.0};
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001,100.0,0.01};
App::PropertyQuantityConstraint::Constraints ViewProviderPartExt::angDeflectionRange = {0.0,180.0,0.05};
const char* ViewProviderPartExt::LightingEnums[]= {"One side","Two side",NULL};
const char* ViewProviderPartExt::DrawStyleEnums[]= {"Solid","Dashed","Dotted","Dashdot",NULL};
@@ -250,6 +251,8 @@ ViewProviderPartExt::ViewProviderPartExt()
ADD_PROPERTY(PointSize,(lwidth));
ADD_PROPERTY(Deviation,(0.5f));
Deviation.setConstraints(&tessRange);
ADD_PROPERTY(AngularDeflection,(28.65));
AngularDeflection.setConstraints(&angDeflectionRange);
ADD_PROPERTY(Lighting,(1));
Lighting.setEnums(LightingEnums);
ADD_PROPERTY(DrawStyle,((long int)0));
@@ -321,6 +324,9 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
if (prop == &Deviation) {
VisualTouched = true;
}
if (prop == &AngularDeflection) {
VisualTouched = true;
}
if (prop == &LineWidth) {
pcLineStyle->lineWidth = LineWidth.getValue();
}
@@ -632,6 +638,7 @@ bool ViewProviderPartExt::loadParameter()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
float angularDeflection = hGrp->GetFloat("MeshAngularDeflection",28.65);
bool novertexnormals = hGrp->GetBool("NoPerVertexNormals",false);
bool qualitynormals = hGrp->GetBool("QualityNormals",false);
@@ -639,6 +646,9 @@ bool ViewProviderPartExt::loadParameter()
Deviation.setValue(deviation);
changed = true;
}
if (AngularDeflection.getValue() != angularDeflection ) {
AngularDeflection.setValue(angularDeflection);
}
if (this->noPerVertexNormals != novertexnormals) {
this->noPerVertexNormals = novertexnormals;
changed = true;
@@ -752,12 +762,14 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape)
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 *
Deviation.getValue();
Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI;
// create or use the mesh on the data structure
#if OCC_VERSION_HEX >= 0x060600
BRepMesh_IncrementalMesh myMesh(cShape,deflection,Standard_False,0.5,Standard_True);
BRepMesh_IncrementalMesh(cShape,deflection,Standard_False,
AngDeflectionRads,Standard_True);
#else
BRepMesh_IncrementalMesh myMesh(cShape,deflection);
BRepMesh_IncrementalMesh(cShape,deflection);
#endif
// We must reset the location here because the transformation data
// are set in the placement property

View File

@@ -27,6 +27,7 @@
#include <Standard_math.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_Shape.hxx>
#include <App/PropertyUnits.h>
#include <Gui/ViewProviderGeometryObject.h>
#include <map>
@@ -71,6 +72,7 @@ public:
App::PropertyFloatConstraint LineWidth;
App::PropertyFloatConstraint PointSize;
App::PropertyFloatConstraint Deviation;
App::PropertyAngle AngularDeflection;
App::PropertyColor LineColor;
App::PropertyColor PointColor;
App::PropertyMaterial LineMaterial;
@@ -143,6 +145,7 @@ private:
bool qualityNormals;
static App::PropertyFloatConstraint::Constraints sizeRange;
static App::PropertyFloatConstraint::Constraints tessRange;
static App::PropertyQuantityConstraint::Constraints angDeflectionRange;
static const char* LightingEnums[];
static const char* DrawStyleEnums[];
};

View File

@@ -247,9 +247,15 @@ void ViewProviderTransformed::recomputeFeature(void)
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
}
Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 * Deviation.getValue();
Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI;
// create or use the mesh on the data structure
BRepMesh_IncrementalMesh myMesh(cShape,deflection);
#if OCC_VERSION_HEX >= 0x060600
BRepMesh_IncrementalMesh(cShape,deflection,Standard_False,
AngDeflectionRads,Standard_True);
#else
BRepMesh_IncrementalMesh(cShape,deflection);
#endif
// We must reset the location here because the transformation data
// are set in the placement property
TopLoc_Location aLoc;