All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -22,51 +22,51 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <Bnd_Box.hxx>
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
# include <BRepExtrema_DistShapeShape.hxx>
|
||||
# include <BRepMesh_IncrementalMesh.hxx>
|
||||
# include <gp_Trsf.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <Poly_Array1OfTriangle.hxx>
|
||||
# include <Poly_Polygon3D.hxx>
|
||||
# include <Poly_PolygonOnTriangulation.hxx>
|
||||
# include <Poly_Triangulation.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TColgp_Array1OfDir.hxx>
|
||||
# include <TColgp_Array1OfPnt.hxx>
|
||||
# include <TColStd_Array1OfInteger.hxx>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Vertex.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <sstream>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <sstream>
|
||||
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/details/SoFaceDetail.h>
|
||||
# include <Inventor/details/SoLineDetail.h>
|
||||
# include <Inventor/details/SoPointDetail.h>
|
||||
# include <Inventor/errors/SoDebugError.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
# include <Inventor/nodes/SoMaterial.h>
|
||||
# include <Inventor/nodes/SoMaterialBinding.h>
|
||||
# include <Inventor/nodes/SoNormal.h>
|
||||
# include <Inventor/nodes/SoNormalBinding.h>
|
||||
# include <Inventor/nodes/SoPolygonOffset.h>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
#include <Inventor/SoPickedPoint.h>
|
||||
#include <Inventor/details/SoFaceDetail.h>
|
||||
#include <Inventor/details/SoLineDetail.h>
|
||||
#include <Inventor/details/SoPointDetail.h>
|
||||
#include <Inventor/errors/SoDebugError.h>
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoMaterialBinding.h>
|
||||
#include <Inventor/nodes/SoNormal.h>
|
||||
#include <Inventor/nodes/SoNormalBinding.h>
|
||||
#include <Inventor/nodes/SoPolygonOffset.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoShapeHints.h>
|
||||
|
||||
# include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
@@ -103,11 +103,12 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartExt, Gui::ViewProviderGeometryObject)
|
||||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0,64.0,1.0};
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.01,100.0,0.01};
|
||||
App::PropertyQuantityConstraint::Constraints ViewProviderPartExt::angDeflectionRange = {1.0,180.0,0.05};
|
||||
const char* ViewProviderPartExt::LightingEnums[]= {"One side","Two side",nullptr};
|
||||
const char* ViewProviderPartExt::DrawStyleEnums[]= {"Solid","Dashed","Dotted","Dashdot",nullptr};
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0, 64.0, 1.0};
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.01, 100.0, 0.01};
|
||||
App::PropertyQuantityConstraint::Constraints ViewProviderPartExt::angDeflectionRange
|
||||
= {1.0, 180.0, 0.05};
|
||||
const char* ViewProviderPartExt::LightingEnums[] = {"One side", "Two side", nullptr};
|
||||
const char* ViewProviderPartExt::DrawStyleEnums[] = {"Solid", "Dashed", "Dotted", "Dashdot", nullptr};
|
||||
|
||||
ViewProviderPartExt::ViewProviderPartExt()
|
||||
{
|
||||
@@ -118,20 +119,25 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||
NormalsFromUV = true;
|
||||
|
||||
// get default line color
|
||||
unsigned long lcol = Gui::ViewParams::instance()->getDefaultShapeLineColor(); // dark grey (25,25,25)
|
||||
float lr,lg,lb;
|
||||
lr = ((lcol >> 24) & 0xff) / 255.0; lg = ((lcol >> 16) & 0xff) / 255.0; lb = ((lcol >> 8) & 0xff) / 255.0;
|
||||
unsigned long lcol = Gui::ViewParams::instance()->getDefaultShapeLineColor(); // dark grey
|
||||
// (25,25,25)
|
||||
float lr, lg, lb;
|
||||
lr = ((lcol >> 24) & 0xff) / 255.0;
|
||||
lg = ((lcol >> 16) & 0xff) / 255.0;
|
||||
lb = ((lcol >> 8) & 0xff) / 255.0;
|
||||
// get default vertex color
|
||||
unsigned long vcol = Gui::ViewParams::instance()->getDefaultShapeVertexColor();
|
||||
float vr,vg,vb;
|
||||
vr = ((vcol >> 24) & 0xff) / 255.0; vg = ((vcol >> 16) & 0xff) / 255.0; vb = ((vcol >> 8) & 0xff) / 255.0;
|
||||
float vr, vg, vb;
|
||||
vr = ((vcol >> 24) & 0xff) / 255.0;
|
||||
vg = ((vcol >> 16) & 0xff) / 255.0;
|
||||
vb = ((vcol >> 8) & 0xff) / 255.0;
|
||||
int lwidth = Gui::ViewParams::instance()->getDefaultShapeLineWidth();
|
||||
int psize = Gui::ViewParams::instance()->getDefaultShapePointSize();
|
||||
|
||||
|
||||
|
||||
ParameterGrp::handle hPart = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
ParameterGrp::handle hPart = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Part"
|
||||
);
|
||||
NormalsFromUV = hPart->GetBool("NormalsFromUVNodes", NormalsFromUV);
|
||||
|
||||
long twoside = hPart->GetBool("TwoSideRendering", true) ? 1 : 0;
|
||||
@@ -142,49 +148,83 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||
lowerLimit = std::max(lowerLimit, Precision::Confusion());
|
||||
tessRange.LowerBound = lowerLimit;
|
||||
|
||||
static const char *osgroup = "Object Style";
|
||||
static const char* osgroup = "Object Style";
|
||||
|
||||
App::Material lmat;
|
||||
lmat.ambientColor.set(0.2f,0.2f,0.2f);
|
||||
lmat.diffuseColor.set(lr,lg,lb);
|
||||
lmat.specularColor.set(0.0f,0.0f,0.0f);
|
||||
lmat.emissiveColor.set(0.0f,0.0f,0.0f);
|
||||
lmat.ambientColor.set(0.2f, 0.2f, 0.2f);
|
||||
lmat.diffuseColor.set(lr, lg, lb);
|
||||
lmat.specularColor.set(0.0f, 0.0f, 0.0f);
|
||||
lmat.emissiveColor.set(0.0f, 0.0f, 0.0f);
|
||||
lmat.shininess = 1.0f;
|
||||
lmat.transparency = 0.0f;
|
||||
|
||||
App::Material vmat;
|
||||
vmat.ambientColor.set(0.2f,0.2f,0.2f);
|
||||
vmat.diffuseColor.set(vr,vg,vb);
|
||||
vmat.specularColor.set(0.0f,0.0f,0.0f);
|
||||
vmat.emissiveColor.set(0.0f,0.0f,0.0f);
|
||||
vmat.ambientColor.set(0.2f, 0.2f, 0.2f);
|
||||
vmat.diffuseColor.set(vr, vg, vb);
|
||||
vmat.specularColor.set(0.0f, 0.0f, 0.0f);
|
||||
vmat.emissiveColor.set(0.0f, 0.0f, 0.0f);
|
||||
vmat.shininess = 1.0f;
|
||||
vmat.transparency = 0.0f;
|
||||
|
||||
ADD_PROPERTY_TYPE(LineMaterial,(lmat), osgroup, App::Prop_None, "Object line material.");
|
||||
ADD_PROPERTY_TYPE(PointMaterial,(vmat), osgroup, App::Prop_None, "Object point material.");
|
||||
ADD_PROPERTY_TYPE(LineMaterial, (lmat), osgroup, App::Prop_None, "Object line material.");
|
||||
ADD_PROPERTY_TYPE(PointMaterial, (vmat), osgroup, App::Prop_None, "Object point material.");
|
||||
ADD_PROPERTY_TYPE(LineColor, (lmat.diffuseColor), osgroup, App::Prop_None, "Set object line color.");
|
||||
ADD_PROPERTY_TYPE(PointColor, (vmat.diffuseColor), osgroup, App::Prop_None, "Set object point color");
|
||||
ADD_PROPERTY_TYPE(PointColorArray, (PointColor.getValue()), osgroup, App::Prop_None, "Object point color array.");
|
||||
ADD_PROPERTY_TYPE(LineColorArray,(LineColor.getValue()), osgroup, App::Prop_None, "Object line color array.");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(lwidth), osgroup, App::Prop_None, "Set object line width.");
|
||||
ADD_PROPERTY_TYPE(
|
||||
PointColorArray,
|
||||
(PointColor.getValue()),
|
||||
osgroup,
|
||||
App::Prop_None,
|
||||
"Object point color array."
|
||||
);
|
||||
ADD_PROPERTY_TYPE(
|
||||
LineColorArray,
|
||||
(LineColor.getValue()),
|
||||
osgroup,
|
||||
App::Prop_None,
|
||||
"Object line color array."
|
||||
);
|
||||
ADD_PROPERTY_TYPE(LineWidth, (lwidth), osgroup, App::Prop_None, "Set object line width.");
|
||||
LineWidth.setConstraints(&sizeRange);
|
||||
PointSize.setConstraints(&sizeRange);
|
||||
ADD_PROPERTY_TYPE(PointSize,(psize), osgroup, App::Prop_None, "Set object point size.");
|
||||
ADD_PROPERTY_TYPE(Deviation,(0.5f), osgroup, App::Prop_None,
|
||||
"Sets the accuracy of the polygonal representation of the model\n"
|
||||
"in the 3D view (tessellation). Lower values indicate better quality.\n"
|
||||
"The value is in percent of object's size.");
|
||||
ADD_PROPERTY_TYPE(PointSize, (psize), osgroup, App::Prop_None, "Set object point size.");
|
||||
ADD_PROPERTY_TYPE(
|
||||
Deviation,
|
||||
(0.5f),
|
||||
osgroup,
|
||||
App::Prop_None,
|
||||
"Sets the accuracy of the polygonal representation of the model\n"
|
||||
"in the 3D view (tessellation). Lower values indicate better quality.\n"
|
||||
"The value is in percent of object's size."
|
||||
);
|
||||
Deviation.setConstraints(&tessRange);
|
||||
ADD_PROPERTY_TYPE(AngularDeflection,(28.5), osgroup, App::Prop_None,
|
||||
"Specify how finely to generate the mesh for rendering on screen or when exporting.\n"
|
||||
"The default value is 28.5 degrees, or 0.5 radians. The smaller the value\n"
|
||||
"the smoother the appearance in the 3D view, and the finer the mesh that will be exported.");
|
||||
ADD_PROPERTY_TYPE(
|
||||
AngularDeflection,
|
||||
(28.5),
|
||||
osgroup,
|
||||
App::Prop_None,
|
||||
"Specify how finely to generate the mesh for rendering on screen or when exporting.\n"
|
||||
"The default value is 28.5 degrees, or 0.5 radians. The smaller the value\n"
|
||||
"the smoother the appearance in the 3D view, and the finer the mesh that will be exported."
|
||||
);
|
||||
AngularDeflection.setConstraints(&angDeflectionRange);
|
||||
ADD_PROPERTY_TYPE(Lighting,(twoside), osgroup, App::Prop_None, "Set object lighting.");
|
||||
ADD_PROPERTY_TYPE(Lighting, (twoside), osgroup, App::Prop_None, "Set object lighting.");
|
||||
Lighting.setEnums(LightingEnums);
|
||||
ADD_PROPERTY_TYPE(DrawStyle,((long int)0), osgroup, App::Prop_None, "Defines the style of the edges in the 3D view.");
|
||||
ADD_PROPERTY_TYPE(
|
||||
DrawStyle,
|
||||
((long int)0),
|
||||
osgroup,
|
||||
App::Prop_None,
|
||||
"Defines the style of the edges in the 3D view."
|
||||
);
|
||||
DrawStyle.setEnums(DrawStyleEnums);
|
||||
ADD_PROPERTY_TYPE(ShowPlacement,(false), "Display Options", App::Prop_None, "If true, placement of object is additionally rendered.");
|
||||
ADD_PROPERTY_TYPE(
|
||||
ShowPlacement,
|
||||
(false),
|
||||
"Display Options",
|
||||
App::Prop_None,
|
||||
"If true, placement of object is additionally rendered."
|
||||
);
|
||||
|
||||
coords = new SoCoordinate3();
|
||||
coords->ref();
|
||||
@@ -278,16 +318,20 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
// to freeze the GUI
|
||||
// https://forum.freecad.org/viewtopic.php?f=3&t=24912&p=195613
|
||||
if (prop == &Deviation) {
|
||||
if(isUpdateForced()||Visibility.getValue())
|
||||
if (isUpdateForced() || Visibility.getValue()) {
|
||||
updateVisual();
|
||||
else
|
||||
}
|
||||
else {
|
||||
VisualTouched = true;
|
||||
}
|
||||
}
|
||||
if (prop == &AngularDeflection) {
|
||||
if(isUpdateForced()||Visibility.getValue())
|
||||
if (isUpdateForced() || Visibility.getValue()) {
|
||||
updateVisual();
|
||||
else
|
||||
}
|
||||
else {
|
||||
VisualTouched = true;
|
||||
}
|
||||
}
|
||||
if (prop == &LineWidth) {
|
||||
pcLineStyle->lineWidth = LineWidth.getValue();
|
||||
@@ -297,37 +341,49 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
}
|
||||
else if (prop == &LineColor) {
|
||||
const Base::Color& c = LineColor.getValue();
|
||||
pcLineMaterial->diffuseColor.setValue(c.r,c.g,c.b);
|
||||
if (c != LineMaterial.getValue().diffuseColor)
|
||||
pcLineMaterial->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
if (c != LineMaterial.getValue().diffuseColor) {
|
||||
LineMaterial.setDiffuseColor(c);
|
||||
}
|
||||
LineColorArray.setValue(LineColor.getValue());
|
||||
}
|
||||
else if (prop == &PointColor) {
|
||||
const Base::Color& c = PointColor.getValue();
|
||||
pcPointMaterial->diffuseColor.setValue(c.r,c.g,c.b);
|
||||
if (c != PointMaterial.getValue().diffuseColor)
|
||||
pcPointMaterial->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
if (c != PointMaterial.getValue().diffuseColor) {
|
||||
PointMaterial.setDiffuseColor(c);
|
||||
}
|
||||
PointColorArray.setValue(PointColor.getValue());
|
||||
}
|
||||
else if (prop == &LineMaterial) {
|
||||
const App::Material& Mat = LineMaterial.getValue();
|
||||
if (LineColor.getValue() != Mat.diffuseColor)
|
||||
if (LineColor.getValue() != Mat.diffuseColor) {
|
||||
LineColor.setValue(Mat.diffuseColor);
|
||||
pcLineMaterial->ambientColor.setValue(Mat.ambientColor.r,Mat.ambientColor.g,Mat.ambientColor.b);
|
||||
pcLineMaterial->diffuseColor.setValue(Mat.diffuseColor.r,Mat.diffuseColor.g,Mat.diffuseColor.b);
|
||||
pcLineMaterial->specularColor.setValue(Mat.specularColor.r,Mat.specularColor.g,Mat.specularColor.b);
|
||||
pcLineMaterial->emissiveColor.setValue(Mat.emissiveColor.r,Mat.emissiveColor.g,Mat.emissiveColor.b);
|
||||
}
|
||||
pcLineMaterial->ambientColor
|
||||
.setValue(Mat.ambientColor.r, Mat.ambientColor.g, Mat.ambientColor.b);
|
||||
pcLineMaterial->diffuseColor
|
||||
.setValue(Mat.diffuseColor.r, Mat.diffuseColor.g, Mat.diffuseColor.b);
|
||||
pcLineMaterial->specularColor
|
||||
.setValue(Mat.specularColor.r, Mat.specularColor.g, Mat.specularColor.b);
|
||||
pcLineMaterial->emissiveColor
|
||||
.setValue(Mat.emissiveColor.r, Mat.emissiveColor.g, Mat.emissiveColor.b);
|
||||
pcLineMaterial->shininess.setValue(Mat.shininess);
|
||||
pcLineMaterial->transparency.setValue(Mat.transparency);
|
||||
}
|
||||
else if (prop == &PointMaterial) {
|
||||
const App::Material& Mat = PointMaterial.getValue();
|
||||
if (PointColor.getValue() != Mat.diffuseColor)
|
||||
if (PointColor.getValue() != Mat.diffuseColor) {
|
||||
PointColor.setValue(Mat.diffuseColor);
|
||||
pcPointMaterial->ambientColor.setValue(Mat.ambientColor.r,Mat.ambientColor.g,Mat.ambientColor.b);
|
||||
pcPointMaterial->diffuseColor.setValue(Mat.diffuseColor.r,Mat.diffuseColor.g,Mat.diffuseColor.b);
|
||||
pcPointMaterial->specularColor.setValue(Mat.specularColor.r,Mat.specularColor.g,Mat.specularColor.b);
|
||||
pcPointMaterial->emissiveColor.setValue(Mat.emissiveColor.r,Mat.emissiveColor.g,Mat.emissiveColor.b);
|
||||
}
|
||||
pcPointMaterial->ambientColor
|
||||
.setValue(Mat.ambientColor.r, Mat.ambientColor.g, Mat.ambientColor.b);
|
||||
pcPointMaterial->diffuseColor
|
||||
.setValue(Mat.diffuseColor.r, Mat.diffuseColor.g, Mat.diffuseColor.b);
|
||||
pcPointMaterial->specularColor
|
||||
.setValue(Mat.specularColor.r, Mat.specularColor.g, Mat.specularColor.b);
|
||||
pcPointMaterial->emissiveColor
|
||||
.setValue(Mat.emissiveColor.r, Mat.emissiveColor.g, Mat.emissiveColor.b);
|
||||
pcPointMaterial->shininess.setValue(Mat.shininess);
|
||||
pcPointMaterial->transparency.setValue(Mat.transparency);
|
||||
}
|
||||
@@ -362,23 +418,31 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
else if (prop == &Lighting) {
|
||||
if (Lighting.getValue() == 0)
|
||||
if (Lighting.getValue() == 0) {
|
||||
pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
|
||||
else
|
||||
}
|
||||
else {
|
||||
pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
}
|
||||
}
|
||||
else if (prop == &DrawStyle) {
|
||||
if (DrawStyle.getValue() == 0)
|
||||
if (DrawStyle.getValue() == 0) {
|
||||
pcLineStyle->linePattern = 0xffff;
|
||||
else if (DrawStyle.getValue() == 1)
|
||||
}
|
||||
else if (DrawStyle.getValue() == 1) {
|
||||
pcLineStyle->linePattern = 0xf00f;
|
||||
else if (DrawStyle.getValue() == 2)
|
||||
}
|
||||
else if (DrawStyle.getValue() == 2) {
|
||||
pcLineStyle->linePattern = 0x0f0f;
|
||||
else
|
||||
}
|
||||
else {
|
||||
pcLineStyle->linePattern = 0xff88;
|
||||
}
|
||||
}
|
||||
else if (prop == &ShowPlacement) {
|
||||
pcPlacement->whichChild = (ShowPlacement.getValue() && Visibility.getValue()) ? SO_SWITCH_ALL : SO_SWITCH_NONE;
|
||||
pcPlacement->whichChild = (ShowPlacement.getValue() && Visibility.getValue())
|
||||
? SO_SWITCH_ALL
|
||||
: SO_SWITCH_NONE;
|
||||
}
|
||||
else {
|
||||
// if the object was invisible and has been changed, recreate the visual
|
||||
@@ -388,8 +452,10 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
// triggered by an external object through forceUpdate()). And
|
||||
// since ShapeAppearance is not changed here either, do not falsely set
|
||||
// the document modified status
|
||||
Base::ObjectStatusLocker<App::Property::Status,App::Property> guard(
|
||||
App::Property::NoModify, &ShapeAppearance);
|
||||
Base::ObjectStatusLocker<App::Property::Status, App::Property> guard(
|
||||
App::Property::NoModify,
|
||||
&ShapeAppearance
|
||||
);
|
||||
// The material has to be checked again (#0001736)
|
||||
onChanged(&ShapeAppearance);
|
||||
onChanged(&ShowPlacement);
|
||||
@@ -399,13 +465,14 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
ViewProviderGeometryObject::onChanged(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderPartExt::allowOverride(const App::DocumentObject &) const {
|
||||
bool ViewProviderPartExt::allowOverride(const App::DocumentObject&) const
|
||||
{
|
||||
// Many derived view providers still uses static_cast to get object
|
||||
// pointer, so check for exact type here.
|
||||
return is<ViewProviderPartExt>();
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderPartExt::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderGeometryObject::attach(pcFeat);
|
||||
@@ -423,17 +490,11 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat)
|
||||
|
||||
// Must turn off all intermediate render caching, and let pcRoot to handle
|
||||
// cache without interference.
|
||||
pcNormalRoot->renderCaching =
|
||||
pcFlatRoot->renderCaching =
|
||||
pcWireframeRoot->renderCaching =
|
||||
pcPointsRoot->renderCaching =
|
||||
wireframe->renderCaching = SoSeparator::OFF;
|
||||
pcNormalRoot->renderCaching = pcFlatRoot->renderCaching = pcWireframeRoot->renderCaching
|
||||
= pcPointsRoot->renderCaching = wireframe->renderCaching = SoSeparator::OFF;
|
||||
|
||||
pcNormalRoot->boundingBoxCaching =
|
||||
pcFlatRoot->boundingBoxCaching =
|
||||
pcWireframeRoot->boundingBoxCaching =
|
||||
pcPointsRoot->boundingBoxCaching =
|
||||
wireframe->boundingBoxCaching = SoSeparator::OFF;
|
||||
pcNormalRoot->boundingBoxCaching = pcFlatRoot->boundingBoxCaching = pcWireframeRoot->boundingBoxCaching
|
||||
= pcPointsRoot->boundingBoxCaching = wireframe->boundingBoxCaching = SoSeparator::OFF;
|
||||
|
||||
// Avoid any Z-buffer artifacts, so that the lines always appear on top of the faces
|
||||
// The correct order is Edges, Polygon offset, Faces.
|
||||
@@ -476,7 +537,7 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat)
|
||||
pcPointsRoot->addChild(nodeset);
|
||||
|
||||
// Move 'coords' before the switch
|
||||
pcRoot->insertChild(coords,pcRoot->findChild(pcModeSwitch));
|
||||
pcRoot->insertChild(coords, pcRoot->findChild(pcModeSwitch));
|
||||
|
||||
// putting all together with the switch
|
||||
addDisplayMaskMode(pcNormalRoot, "Flat Lines");
|
||||
@@ -487,16 +548,20 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat)
|
||||
|
||||
void ViewProviderPartExt::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Flat Lines",ModeName)==0 )
|
||||
if (strcmp("Flat Lines", ModeName) == 0) {
|
||||
setDisplayMaskMode("Flat Lines");
|
||||
else if ( strcmp("Shaded",ModeName)==0 )
|
||||
}
|
||||
else if (strcmp("Shaded", ModeName) == 0) {
|
||||
setDisplayMaskMode("Shaded");
|
||||
else if ( strcmp("Wireframe",ModeName)==0 )
|
||||
}
|
||||
else if (strcmp("Wireframe", ModeName) == 0) {
|
||||
setDisplayMaskMode("Wireframe");
|
||||
else if ( strcmp("Points",ModeName)==0 )
|
||||
}
|
||||
else if (strcmp("Points", ModeName) == 0) {
|
||||
setDisplayMaskMode("Point");
|
||||
}
|
||||
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
ViewProviderGeometryObject::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderPartExt::getDisplayModes() const
|
||||
@@ -555,7 +620,9 @@ SoDetail* ViewProviderPartExt::getDetail(const char* subelement) const
|
||||
}
|
||||
else if (element == "Vertex") {
|
||||
SoPointDetail* detail = new SoPointDetail();
|
||||
static_cast<SoPointDetail*>(detail)->setCoordinateIndex(index + nodeset->startIndex.getValue() - 1);
|
||||
static_cast<SoPointDetail*>(detail)->setCoordinateIndex(
|
||||
index + nodeset->startIndex.getValue() - 1
|
||||
);
|
||||
return detail;
|
||||
}
|
||||
|
||||
@@ -567,7 +634,7 @@ std::vector<Base::Vector3d> ViewProviderPartExt::getModelPoints(const SoPickedPo
|
||||
try {
|
||||
std::vector<Base::Vector3d> pts;
|
||||
std::string element = this->getElement(pp->getDetail());
|
||||
const auto &shape = getRenderedShape();
|
||||
const auto& shape = getRenderedShape();
|
||||
|
||||
TopoDS_Shape subShape = shape.getSubShape(element.c_str());
|
||||
|
||||
@@ -575,26 +642,26 @@ std::vector<Base::Vector3d> ViewProviderPartExt::getModelPoints(const SoPickedPo
|
||||
if (subShape.ShapeType() == TopAbs_VERTEX) {
|
||||
const TopoDS_Vertex& v = TopoDS::Vertex(subShape);
|
||||
gp_Pnt p = BRep_Tool::Pnt(v);
|
||||
pts.emplace_back(p.X(),p.Y(),p.Z());
|
||||
pts.emplace_back(p.X(), p.Y(), p.Z());
|
||||
}
|
||||
// get the nearest point on the edge
|
||||
else if (subShape.ShapeType() == TopAbs_EDGE) {
|
||||
const SbVec3f& vec = pp->getPoint();
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(vec[0],vec[1],vec[2]));
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(vec[0], vec[1], vec[2]));
|
||||
BRepExtrema_DistShapeShape distSS(subShape, mkVert.Vertex(), 0.1);
|
||||
if (distSS.NbSolution() > 0) {
|
||||
gp_Pnt p = distSS.PointOnShape1(1);
|
||||
pts.emplace_back(p.X(),p.Y(),p.Z());
|
||||
pts.emplace_back(p.X(), p.Y(), p.Z());
|
||||
}
|
||||
}
|
||||
// get the nearest point on the face
|
||||
else if (subShape.ShapeType() == TopAbs_FACE) {
|
||||
const SbVec3f& vec = pp->getPoint();
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(vec[0],vec[1],vec[2]));
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(vec[0], vec[1], vec[2]));
|
||||
BRepExtrema_DistShapeShape distSS(subShape, mkVert.Vertex(), 0.1);
|
||||
if (distSS.NbSolution() > 0) {
|
||||
gp_Pnt p = distSS.PointOnShape1(1);
|
||||
pts.emplace_back(p.X(),p.Y(),p.Z());
|
||||
pts.emplace_back(p.X(), p.Y(), p.Z());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,8 +681,9 @@ std::vector<Base::Vector3d> ViewProviderPartExt::getSelectionShape(const char* /
|
||||
|
||||
void ViewProviderPartExt::setHighlightedFaces(const std::vector<App::Material>& materials)
|
||||
{
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange))
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange)) {
|
||||
getObject()->touch(true);
|
||||
}
|
||||
|
||||
Gui::SoUpdateVBOAction action;
|
||||
action.apply(this->faceset);
|
||||
@@ -640,10 +708,26 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector<App::Material>&
|
||||
float* tr = pcShapeMaterial->transparency.startEditing();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
dc[i].setValue(materials[i].diffuseColor.r, materials[i].diffuseColor.g, materials[i].diffuseColor.b);
|
||||
ac[i].setValue(materials[i].ambientColor.r, materials[i].ambientColor.g, materials[i].ambientColor.b);
|
||||
sc[i].setValue(materials[i].specularColor.r, materials[i].specularColor.g, materials[i].specularColor.b);
|
||||
ec[i].setValue(materials[i].emissiveColor.r, materials[i].emissiveColor.g, materials[i].emissiveColor.b);
|
||||
dc[i].setValue(
|
||||
materials[i].diffuseColor.r,
|
||||
materials[i].diffuseColor.g,
|
||||
materials[i].diffuseColor.b
|
||||
);
|
||||
ac[i].setValue(
|
||||
materials[i].ambientColor.r,
|
||||
materials[i].ambientColor.g,
|
||||
materials[i].ambientColor.b
|
||||
);
|
||||
sc[i].setValue(
|
||||
materials[i].specularColor.r,
|
||||
materials[i].specularColor.g,
|
||||
materials[i].specularColor.b
|
||||
);
|
||||
ec[i].setValue(
|
||||
materials[i].emissiveColor.r,
|
||||
materials[i].emissiveColor.g,
|
||||
materials[i].emissiveColor.b
|
||||
);
|
||||
sh[i] = materials[i].shininess;
|
||||
tr[i] = materials[i].transparency;
|
||||
}
|
||||
@@ -666,10 +750,11 @@ void ViewProviderPartExt::setHighlightedFaces(const App::PropertyMaterialList& a
|
||||
setHighlightedFaces(appearance.getValues());
|
||||
}
|
||||
|
||||
std::map<std::string,Base::Color> ViewProviderPartExt::getElementColors(const char *element) const {
|
||||
std::map<std::string,Base::Color> ret;
|
||||
std::map<std::string, Base::Color> ViewProviderPartExt::getElementColors(const char* element) const
|
||||
{
|
||||
std::map<std::string, Base::Color> ret;
|
||||
|
||||
if(!element || !element[0]) {
|
||||
if (!element || !element[0]) {
|
||||
auto color = ShapeAppearance.getDiffuseColor();
|
||||
color.setTransparency(Base::fromPercent(Transparency.getValue()));
|
||||
ret["Face"] = color;
|
||||
@@ -678,9 +763,9 @@ std::map<std::string,Base::Color> ViewProviderPartExt::getElementColors(const ch
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(boost::starts_with(element,"Face")) {
|
||||
if (boost::starts_with(element, "Face")) {
|
||||
auto size = ShapeAppearance.getSize();
|
||||
if(element[4]=='*') {
|
||||
if (element[4] == '*') {
|
||||
auto color = ShapeAppearance.getDiffuseColor();
|
||||
color.setTransparency(Base::fromPercent(Transparency.getValue()));
|
||||
bool singleColor = true;
|
||||
@@ -700,58 +785,72 @@ std::map<std::string,Base::Color> ViewProviderPartExt::getElementColors(const ch
|
||||
ret.clear();
|
||||
}
|
||||
ret["Face"] = color;
|
||||
}else{
|
||||
int idx = atoi(element+4);
|
||||
if(idx>0 && idx<=size)
|
||||
ret[element] = ShapeAppearance.getDiffuseColor(idx - 1);
|
||||
else
|
||||
ret[element] = ShapeAppearance.getDiffuseColor();
|
||||
if(size==1)
|
||||
ret[element].setTransparency(Base::fromPercent(Transparency.getValue()));
|
||||
}
|
||||
} else if (boost::starts_with(element,"Edge")) {
|
||||
else {
|
||||
int idx = atoi(element + 4);
|
||||
if (idx > 0 && idx <= size) {
|
||||
ret[element] = ShapeAppearance.getDiffuseColor(idx - 1);
|
||||
}
|
||||
else {
|
||||
ret[element] = ShapeAppearance.getDiffuseColor();
|
||||
}
|
||||
if (size == 1) {
|
||||
ret[element].setTransparency(Base::fromPercent(Transparency.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (boost::starts_with(element, "Edge")) {
|
||||
auto size = LineColorArray.getSize();
|
||||
if(element[4]=='*') {
|
||||
if (element[4] == '*') {
|
||||
auto color = LineColor.getValue();
|
||||
bool singleColor = true;
|
||||
for(int i=0;i<size;++i) {
|
||||
if(LineColorArray[i]!=color)
|
||||
ret[std::string(element,4)+std::to_string(i+1)] = LineColorArray[i];
|
||||
singleColor = singleColor && LineColorArray[0]==LineColorArray[i];
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (LineColorArray[i] != color) {
|
||||
ret[std::string(element, 4) + std::to_string(i + 1)] = LineColorArray[i];
|
||||
}
|
||||
singleColor = singleColor && LineColorArray[0] == LineColorArray[i];
|
||||
}
|
||||
if(singleColor && size) {
|
||||
if (singleColor && size) {
|
||||
color = LineColorArray[0];
|
||||
ret.clear();
|
||||
}
|
||||
ret["Edge"] = color;
|
||||
}else{
|
||||
int idx = atoi(element+4);
|
||||
if(idx>0 && idx<=size)
|
||||
ret[element] = LineColorArray[idx-1];
|
||||
else
|
||||
ret[element] = LineColor.getValue();
|
||||
}
|
||||
} else if (boost::starts_with(element,"Vertex")) {
|
||||
else {
|
||||
int idx = atoi(element + 4);
|
||||
if (idx > 0 && idx <= size) {
|
||||
ret[element] = LineColorArray[idx - 1];
|
||||
}
|
||||
else {
|
||||
ret[element] = LineColor.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (boost::starts_with(element, "Vertex")) {
|
||||
auto size = PointColorArray.getSize();
|
||||
if(element[5]=='*') {
|
||||
if (element[5] == '*') {
|
||||
auto color = PointColor.getValue();
|
||||
bool singleColor = true;
|
||||
for(int i=0;i<size;++i) {
|
||||
if(PointColorArray[i]!=color)
|
||||
ret[std::string(element,5)+std::to_string(i+1)] = PointColorArray[i];
|
||||
singleColor = singleColor && PointColorArray[0]==PointColorArray[i];
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (PointColorArray[i] != color) {
|
||||
ret[std::string(element, 5) + std::to_string(i + 1)] = PointColorArray[i];
|
||||
}
|
||||
singleColor = singleColor && PointColorArray[0] == PointColorArray[i];
|
||||
}
|
||||
if(singleColor && size) {
|
||||
if (singleColor && size) {
|
||||
color = PointColorArray[0];
|
||||
ret.clear();
|
||||
}
|
||||
ret["Vertex"] = color;
|
||||
}else{
|
||||
int idx = atoi(element+5);
|
||||
if(idx>0 && idx<=size)
|
||||
ret[element] = PointColorArray[idx-1];
|
||||
else
|
||||
}
|
||||
else {
|
||||
int idx = atoi(element + 5);
|
||||
if (idx > 0 && idx <= size) {
|
||||
ret[element] = PointColorArray[idx - 1];
|
||||
}
|
||||
else {
|
||||
ret[element] = PointColor.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -765,8 +864,9 @@ void ViewProviderPartExt::unsetHighlightedFaces()
|
||||
|
||||
void ViewProviderPartExt::setHighlightedEdges(const std::vector<Base::Color>& colors)
|
||||
{
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange))
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange)) {
|
||||
getObject()->touch(true);
|
||||
}
|
||||
int size = static_cast<int>(colors.size());
|
||||
if (size > 1) {
|
||||
// Although indexed lineset is used the material binding must be PER_FACE!
|
||||
@@ -781,8 +881,9 @@ void ViewProviderPartExt::setHighlightedEdges(const std::vector<Base::Color>& co
|
||||
if (cindices[i] < 0) {
|
||||
ca[linecount].setValue(colors[linecount].r, colors[linecount].g, colors[linecount].b);
|
||||
linecount++;
|
||||
if (linecount >= size)
|
||||
if (linecount >= size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,15 +903,17 @@ void ViewProviderPartExt::unsetHighlightedEdges()
|
||||
|
||||
void ViewProviderPartExt::setHighlightedPoints(const std::vector<Base::Color>& colors)
|
||||
{
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange))
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange)) {
|
||||
getObject()->touch(true);
|
||||
}
|
||||
int size = static_cast<int>(colors.size());
|
||||
if (size > 1) {
|
||||
pcPointBind->value = SoMaterialBinding::PER_VERTEX;
|
||||
pcPointMaterial->diffuseColor.setNum(size);
|
||||
SbColor* ca = pcPointMaterial->diffuseColor.startEditing();
|
||||
for (int i = 0; i < size; ++i)
|
||||
for (int i = 0; i < size; ++i) {
|
||||
ca[i].setValue(colors[i].r, colors[i].g, colors[i].b);
|
||||
}
|
||||
pcPointMaterial->diffuseColor.finishEditing();
|
||||
}
|
||||
else if (size == 1) {
|
||||
@@ -827,17 +930,18 @@ void ViewProviderPartExt::unsetHighlightedPoints()
|
||||
bool ViewProviderPartExt::loadParameter()
|
||||
{
|
||||
bool changed = false;
|
||||
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);
|
||||
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);
|
||||
NormalsFromUV = hGrp->GetBool("NormalsFromUVNodes", NormalsFromUV);
|
||||
|
||||
if (Deviation.getValue() != deviation) {
|
||||
Deviation.setValue(deviation);
|
||||
changed = true;
|
||||
}
|
||||
if (AngularDeflection.getValue() != angularDeflection ) {
|
||||
if (AngularDeflection.getValue() != angularDeflection) {
|
||||
AngularDeflection.setValue(angularDeflection);
|
||||
}
|
||||
|
||||
@@ -846,23 +950,25 @@ bool ViewProviderPartExt::loadParameter()
|
||||
|
||||
void ViewProviderPartExt::reload()
|
||||
{
|
||||
if (loadParameter())
|
||||
if (loadParameter()) {
|
||||
updateVisual();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::updateData(const App::Property* prop)
|
||||
{
|
||||
const char *propName = prop->getName();
|
||||
const char* propName = prop->getName();
|
||||
if (propName && (strcmp(propName, "Shape") == 0 || strstr(propName, "Touched"))) {
|
||||
// calculate the visual only if visible
|
||||
if (isUpdateForced() || Visibility.getValue())
|
||||
if (isUpdateForced() || Visibility.getValue()) {
|
||||
updateVisual();
|
||||
else
|
||||
}
|
||||
else {
|
||||
VisualTouched = true;
|
||||
}
|
||||
|
||||
if (!VisualTouched) {
|
||||
if (this->faceset->partIndex.getNum() >
|
||||
this->pcShapeMaterial->diffuseColor.getNum()) {
|
||||
if (this->faceset->partIndex.getNum() > this->pcShapeMaterial->diffuseColor.getNum()) {
|
||||
this->pcFaceBind->value = SoMaterialBinding::OVERALL;
|
||||
}
|
||||
}
|
||||
@@ -897,7 +1003,7 @@ void ViewProviderPartExt::setupContextMenu(QMenu* menu, QObject* receiver, const
|
||||
|
||||
bool ViewProviderPartExt::changeFaceAppearances()
|
||||
{
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
Gui::Control().showDialog(dlg);
|
||||
return false;
|
||||
@@ -931,15 +1037,17 @@ void ViewProviderPartExt::unsetEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
SoCoordinate3* coords,
|
||||
SoBrepFaceSet* faceset,
|
||||
SoNormal* norm,
|
||||
SoBrepEdgeSet* lineset,
|
||||
SoBrepPointSet* nodeset,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV)
|
||||
void ViewProviderPartExt::setupCoinGeometry(
|
||||
TopoDS_Shape shape,
|
||||
SoCoordinate3* coords,
|
||||
SoBrepFaceSet* faceset,
|
||||
SoNormal* norm,
|
||||
SoBrepEdgeSet* lineset,
|
||||
SoBrepPointSet* nodeset,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV
|
||||
)
|
||||
{
|
||||
if (Part::Tools::isShapeEmpty(shape)) {
|
||||
coords->point.setNum(0);
|
||||
@@ -955,7 +1063,9 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
Base::TimeElapsed startTime;
|
||||
|
||||
[[maybe_unused]]
|
||||
int numTriangles = 0, numNodes = 0, numNorms = 0, numFaces = 0, numEdges = 0, numLines = 0;
|
||||
int numTriangles
|
||||
= 0,
|
||||
numNodes = 0, numNorms = 0, numFaces = 0, numEdges = 0, numLines = 0;
|
||||
|
||||
std::set<int> faceEdges;
|
||||
|
||||
@@ -1176,7 +1286,7 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
verts[faceNodeOffset + N3 - 1] = Base::convertTo<SbVec3f>(V3);
|
||||
|
||||
// set the index vector with the 3 point indexes and the end delimiter
|
||||
index[faceTriaOffset * 4 + 4 * (g - 1)] = faceNodeOffset + N1 - 1;
|
||||
index[faceTriaOffset * 4 + 4 * (g - 1)] = faceNodeOffset + N1 - 1;
|
||||
index[faceTriaOffset * 4 + 4 * (g - 1) + 1] = faceNodeOffset + N2 - 1;
|
||||
index[faceTriaOffset * 4 + 4 * (g - 1) + 2] = faceNodeOffset + N3 - 1;
|
||||
index[faceTriaOffset * 4 + 4 * (g - 1) + 3] = SO_END_FACE_INDEX;
|
||||
@@ -1195,8 +1305,8 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
if (edgeIdxSet.find(edgeIndex) != edgeIdxSet.end()) {
|
||||
|
||||
// this holds the indices of the edge's triangulation to the current polygon
|
||||
Handle(Poly_PolygonOnTriangulation) aPoly =
|
||||
BRep_Tool::PolygonOnTriangulation(curEdge, mesh, aLoc);
|
||||
Handle(Poly_PolygonOnTriangulation) aPoly
|
||||
= BRep_Tool::PolygonOnTriangulation(curEdge, mesh, aLoc);
|
||||
if (aPoly.IsNull()) {
|
||||
continue; // polygon does not exist
|
||||
}
|
||||
@@ -1308,27 +1418,41 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
faceset->partIndex.finishEditing();
|
||||
lineset->coordIndex.finishEditing();
|
||||
|
||||
# ifdef FC_DEBUG
|
||||
Base::Console().log("ViewProvider update time: %f s\n",Base::TimeElapsed::diffTimeF(startTime,Base::TimeElapsed()));
|
||||
Base::Console().log("Shape mesh info: Faces:%d Edges:%d Nodes:%d Triangles:%d IdxVec:%d\n",numFaces,numEdges,numNodes,numTriangles,numLines);
|
||||
# endif
|
||||
#ifdef FC_DEBUG
|
||||
Base::Console().log(
|
||||
"ViewProvider update time: %f s\n",
|
||||
Base::TimeElapsed::diffTimeF(startTime, Base::TimeElapsed())
|
||||
);
|
||||
Base::Console().log(
|
||||
"Shape mesh info: Faces:%d Edges:%d Nodes:%d Triangles:%d IdxVec:%d\n",
|
||||
numFaces,
|
||||
numEdges,
|
||||
numNodes,
|
||||
numTriangles,
|
||||
numLines
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
SoFCShape* node,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV)
|
||||
void ViewProviderPartExt::setupCoinGeometry(
|
||||
TopoDS_Shape shape,
|
||||
SoFCShape* node,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV
|
||||
)
|
||||
{
|
||||
setupCoinGeometry(shape,
|
||||
node->coords,
|
||||
node->faceset,
|
||||
node->norm,
|
||||
node->lineset,
|
||||
node->nodeset,
|
||||
deviation,
|
||||
angularDeflection,
|
||||
normalsFromUV);
|
||||
setupCoinGeometry(
|
||||
shape,
|
||||
node->coords,
|
||||
node->faceset,
|
||||
node->norm,
|
||||
node->lineset,
|
||||
node->nodeset,
|
||||
deviation,
|
||||
angularDeflection,
|
||||
normalsFromUV
|
||||
);
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::updateVisual()
|
||||
@@ -1351,25 +1475,28 @@ void ViewProviderPartExt::updateVisual()
|
||||
try {
|
||||
TopoDS_Shape cShape = getRenderedShape().getShape();
|
||||
|
||||
setupCoinGeometry(cShape,
|
||||
coords,
|
||||
faceset,
|
||||
norm,
|
||||
lineset,
|
||||
nodeset,
|
||||
Deviation.getValue(),
|
||||
AngularDeflection.getValue(),
|
||||
NormalsFromUV);
|
||||
setupCoinGeometry(
|
||||
cShape,
|
||||
coords,
|
||||
faceset,
|
||||
norm,
|
||||
lineset,
|
||||
nodeset,
|
||||
Deviation.getValue(),
|
||||
AngularDeflection.getValue(),
|
||||
NormalsFromUV
|
||||
);
|
||||
|
||||
VisualTouched = false;
|
||||
}
|
||||
catch (const Standard_Failure& e) {
|
||||
FC_ERR("Cannot compute Inventor representation for the shape of "
|
||||
<< pcObject->getFullName() << ": " << e.GetMessageString());
|
||||
FC_ERR(
|
||||
"Cannot compute Inventor representation for the shape of "
|
||||
<< pcObject->getFullName() << ": " << e.GetMessageString()
|
||||
);
|
||||
}
|
||||
catch (...) {
|
||||
FC_ERR("Cannot compute Inventor representation for the shape of "
|
||||
<< pcObject->getFullName());
|
||||
FC_ERR("Cannot compute Inventor representation for the shape of " << pcObject->getFullName());
|
||||
}
|
||||
|
||||
// The material has to be checked again
|
||||
@@ -1378,20 +1505,26 @@ void ViewProviderPartExt::updateVisual()
|
||||
setHighlightedPoints(PointColorArray.getValue());
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::forceUpdate(bool enable) {
|
||||
if(enable) {
|
||||
if(++forceUpdateCount == 1) {
|
||||
if(!isShow() && VisualTouched)
|
||||
void ViewProviderPartExt::forceUpdate(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (++forceUpdateCount == 1) {
|
||||
if (!isShow() && VisualTouched) {
|
||||
updateVisual();
|
||||
}
|
||||
}
|
||||
}else if(forceUpdateCount)
|
||||
}
|
||||
else if (forceUpdateCount) {
|
||||
--forceUpdateCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderPartExt::handleChangedPropertyName(Base::XMLReader& reader,
|
||||
const char* TypeName,
|
||||
const char* PropName)
|
||||
void ViewProviderPartExt::handleChangedPropertyName(
|
||||
Base::XMLReader& reader,
|
||||
const char* TypeName,
|
||||
const char* PropName
|
||||
)
|
||||
{
|
||||
if (strcmp(PropName, "DiffuseColor") == 0
|
||||
&& strcmp(TypeName, App::PropertyColorList::getClassTypeId().getName()) == 0) {
|
||||
@@ -1403,6 +1536,3 @@ void ViewProviderPartExt::handleChangedPropertyName(Base::XMLReader& reader,
|
||||
Gui::ViewProviderGeometryObject::handleChangedPropertyName(reader, TypeName, PropName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user