From 4c0781a555df99ebba2c7738f45a7aa31fea9401 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 17:15:21 +0430 Subject: [PATCH] Suggestions for Part module moving float -> double --- src/Mod/Part/App/FeatureExtrusion.cpp | 4 +- src/Mod/Part/App/FeatureRevolution.cpp | 6 +- src/Mod/Part/App/ParabolaPyImp.cpp | 2 +- src/Mod/Part/App/PrimitiveFeature.cpp | 136 +++++++++++----------- src/Mod/Part/App/TopoShapeFacePyImp.cpp | 50 ++++---- src/Mod/Part/App/TopoShapeVertexPyImp.cpp | 14 +-- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 2 +- src/Mod/Part/Gui/TaskOffset.cpp | 4 +- src/Mod/Part/Gui/TaskThickness.cpp | 4 +- src/Mod/Part/Gui/ViewProvider.cpp | 48 ++++---- src/Mod/Part/Gui/ViewProviderExt.cpp | 4 +- 11 files changed, 137 insertions(+), 137 deletions(-) diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp index 8f3a205c8..7c4605a8a 100644 --- a/src/Mod/Part/App/FeatureExtrusion.cpp +++ b/src/Mod/Part/App/FeatureExtrusion.cpp @@ -55,7 +55,7 @@ PROPERTY_SOURCE(Part::Extrusion, Part::Feature) Extrusion::Extrusion() { ADD_PROPERTY(Base,(0)); - ADD_PROPERTY(Dir,(Base::Vector3d(0.0f,0.0f,1.0f))); + ADD_PROPERTY(Dir,(Base::Vector3d(0.0,0.0,1.0))); ADD_PROPERTY(Solid,(false)); ADD_PROPERTY(TaperAngle,(0.0)); } @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn *Extrusion::execute(void) Base::Vector3d v = Dir.getValue(); gp_Vec vec(v.x,v.y,v.z); - float taperAngle = TaperAngle.getValue(); + double taperAngle = TaperAngle.getValue(); bool makeSolid = Solid.getValue(); try { diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index 846d7badd..ddb96db07 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -32,15 +32,15 @@ using namespace Part; -App::PropertyFloatConstraint::Constraints Revolution::angleRangeU = {-360.0f,360.0f,1.0f}; +App::PropertyFloatConstraint::Constraints Revolution::angleRangeU = {-360.0,360.0,1.0}; PROPERTY_SOURCE(Part::Revolution, Part::Feature) Revolution::Revolution() { ADD_PROPERTY(Source,(0)); - ADD_PROPERTY(Base,(Base::Vector3d(0.0f,0.0f,0.0f))); - ADD_PROPERTY(Axis,(Base::Vector3d(0.0f,0.0f,1.0f))); + ADD_PROPERTY(Base,(Base::Vector3d(0.0,0.0,0.0))); + ADD_PROPERTY(Axis,(Base::Vector3d(0.0,0.0,1.0))); ADD_PROPERTY(Angle,(360.0)); Angle.setConstraints(&angleRangeU); } diff --git a/src/Mod/Part/App/ParabolaPyImp.cpp b/src/Mod/Part/App/ParabolaPyImp.cpp index 191df05f4..14adc3ef0 100644 --- a/src/Mod/Part/App/ParabolaPyImp.cpp +++ b/src/Mod/Part/App/ParabolaPyImp.cpp @@ -79,7 +79,7 @@ PyObject* ParabolaPy::compute(PyObject *args) } Base::Matrix4D m; - Base::Vector3f v; + Base::Vector3d v; m[0][0] = v1.y * v1.y; m[0][1] = v1.y; m[0][2] = 1; diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index c2e818a52..2bd0cd618 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -68,11 +68,11 @@ namespace Part { - const App::PropertyFloatConstraint::Constraints floatRange = {0.0f,FLT_MAX,0.1f}; - const App::PropertyFloatConstraint::Constraints apexRange = {0.0f,90.0f,0.1f}; - const App::PropertyFloatConstraint::Constraints angleRangeU = {0.0f,360.0f,1.0f}; - const App::PropertyFloatConstraint::Constraints angleRangeV = {-90.0f,90.0f,1.0f}; - const App::PropertyFloatConstraint::Constraints torusRangeV = {-180.0f,180.0f,1.0f}; + const App::PropertyFloatConstraint::Constraints floatRange = {0.0,FLT_MAX,0.1}; + const App::PropertyFloatConstraint::Constraints apexRange = {0.0,90.0,0.1}; + const App::PropertyFloatConstraint::Constraints angleRangeU = {0.0,360.0,1.0}; + const App::PropertyFloatConstraint::Constraints angleRangeV = {-90.0,90.0,1.0}; + const App::PropertyFloatConstraint::Constraints torusRangeV = {-180.0,180.0,1.0}; } using namespace Part; @@ -164,69 +164,69 @@ void Vertex::onChanged(const App::Property* prop) Part::Feature::onChanged(prop); } -PROPERTY_SOURCE(Part::Line, Part::Primitive) - -Line::Line() -{ - ADD_PROPERTY_TYPE(X1,(0.0f),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex"); - ADD_PROPERTY_TYPE(Y1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex"); - ADD_PROPERTY_TYPE(Z1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex"); - ADD_PROPERTY_TYPE(X2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex"); - ADD_PROPERTY_TYPE(Y2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex"); - ADD_PROPERTY_TYPE(Z2,(1.0f),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex"); -} - -Line::~Line() -{ -} - -short Line::mustExecute() const -{ - if (X1.isTouched() || - Y1.isTouched() || - Z1.isTouched() || - X2.isTouched() || - Y2.isTouched() || - Z2.isTouched()) - return 1; - return Part::Feature::mustExecute(); -} - -App::DocumentObjectExecReturn *Line::execute(void) -{ - gp_Pnt point1; - point1.SetX(this->X1.getValue()); - point1.SetY(this->Y1.getValue()); - point1.SetZ(this->Z1.getValue()); - - gp_Pnt point2; - point2.SetX(this->X2.getValue()); - point2.SetY(this->Y2.getValue()); - point2.SetZ(this->Z2.getValue()); - - BRepBuilderAPI_MakeEdge mkEdge(point1, point2); - if (!mkEdge.IsDone()) - return new App::DocumentObjectExecReturn("Failed to create edge"); - const TopoDS_Edge& edge = mkEdge.Edge(); - this->Shape.setValue(edge); - - return App::DocumentObject::StdReturn; -} - -void Line::onChanged(const App::Property* prop) -{ - if (!isRestoring()) { - if (prop == &X1 || prop == &Y1 || prop == &Z1 || prop == &X2 || prop == &Y2 || prop == &Z2){ - try { - App::DocumentObjectExecReturn *ret = recompute(); - delete ret; - } - catch (...) { - } - } - } - Part::Feature::onChanged(prop); -} +PROPERTY_SOURCE(Part::Line, Part::Primitive) + +Line::Line() +{ + ADD_PROPERTY_TYPE(X1,(0.0f),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex"); + ADD_PROPERTY_TYPE(Y1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex"); + ADD_PROPERTY_TYPE(Z1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex"); + ADD_PROPERTY_TYPE(X2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex"); + ADD_PROPERTY_TYPE(Y2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex"); + ADD_PROPERTY_TYPE(Z2,(1.0f),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex"); +} + +Line::~Line() +{ +} + +short Line::mustExecute() const +{ + if (X1.isTouched() || + Y1.isTouched() || + Z1.isTouched() || + X2.isTouched() || + Y2.isTouched() || + Z2.isTouched()) + return 1; + return Part::Feature::mustExecute(); +} + +App::DocumentObjectExecReturn *Line::execute(void) +{ + gp_Pnt point1; + point1.SetX(this->X1.getValue()); + point1.SetY(this->Y1.getValue()); + point1.SetZ(this->Z1.getValue()); + + gp_Pnt point2; + point2.SetX(this->X2.getValue()); + point2.SetY(this->Y2.getValue()); + point2.SetZ(this->Z2.getValue()); + + BRepBuilderAPI_MakeEdge mkEdge(point1, point2); + if (!mkEdge.IsDone()) + return new App::DocumentObjectExecReturn("Failed to create edge"); + const TopoDS_Edge& edge = mkEdge.Edge(); + this->Shape.setValue(edge); + + return App::DocumentObject::StdReturn; +} + +void Line::onChanged(const App::Property* prop) +{ + if (!isRestoring()) { + if (prop == &X1 || prop == &Y1 || prop == &Z1 || prop == &X2 || prop == &Y2 || prop == &Z2){ + try { + App::DocumentObjectExecReturn *ret = recompute(); + delete ret; + } + catch (...) { + } + } + } + Part::Feature::onChanged(prop); +} PROPERTY_SOURCE(Part::Plane, Part::Primitive) diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index b0460a580..7bb261dbe 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -22,34 +22,34 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include +#ifndef _PreComp_ +# include +# include +# include +# include +# include +# include +# include +# include # include # include -# include -# include -# include +# include +# include +# include # include # include # include # include -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include # include # include # include -#endif +#endif #include #include @@ -100,7 +100,7 @@ PyObject *TopoShapeFacePy::PyMake(struct _typeobject *, PyObject *, PyObject *) int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/) { PyObject *pW; - if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pW)) { + if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pW)) { try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->_Shape; if (sh.IsNull()) { @@ -116,17 +116,17 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/) } getTopoShapePtr()->_Shape = mkFace.Face(); return 0; - } + } else if (sh.ShapeType() == TopAbs_FACE) { getTopoShapePtr()->_Shape = sh; return 0; } } - catch (Standard_Failure) { + catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); - PyErr_SetString(PyExc_Exception, e->GetMessageString()); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); return -1; - } + } } PyErr_Clear(); @@ -241,7 +241,7 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyObject* TopoShapeFacePy::makeOffset(PyObject *args) { - float dist; + double dist; if (!PyArg_ParseTuple(args, "f",&dist)) return 0; const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape); diff --git a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp index 013a5167c..9be1003bf 100644 --- a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp @@ -23,10 +23,10 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -# include -# include +#ifndef _PreComp_ +# include +# include +# include # include # include # include @@ -84,9 +84,9 @@ int TopoShapeVertexPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args,"O!",&(PyTuple_Type), &object)) { try { Py::Tuple tuple(object); - x = (float)Py::Float(tuple.getItem(0)); - y = (float)Py::Float(tuple.getItem(1)); - z = (float)Py::Float(tuple.getItem(2)); + x = Py::Float(tuple.getItem(0)); + y = Py::Float(tuple.getItem(1)); + z = Py::Float(tuple.getItem(2)); success = true; } catch (const Py::Exception&) { diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index 0011e2198..3ed758c14 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -209,7 +209,7 @@ PyObject* TopoShapeWirePy::fixWire(PyObject *args) PyObject* TopoShapeWirePy::makeOffset(PyObject *args) { - float dist; + double dist; if (!PyArg_ParseTuple(args, "f",&dist)) return 0; const TopoDS_Wire& w = TopoDS::Wire(getTopoShapePtr()->_Shape); diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp index d288453f3..5da925303 100644 --- a/src/Mod/Part/Gui/TaskOffset.cpp +++ b/src/Mod/Part/Gui/TaskOffset.cpp @@ -90,7 +90,7 @@ Part::Offset* OffsetWidget::getObject() const void OffsetWidget::on_spinOffset_valueChanged(double val) { - d->offset->Value.setValue((float)val); + d->offset->Value.setValue(val); if (d->ui.updateView->isChecked()) d->offset->getDocument()->recomputeFeature(d->offset); } @@ -104,7 +104,7 @@ void OffsetWidget::on_modeType_activated(int val) void OffsetWidget::on_joinType_activated(int val) { - d->offset->Join.setValue((float)val); + d->offset->Join.setValue((long)val); if (d->ui.updateView->isChecked()) d->offset->getDocument()->recomputeFeature(d->offset); } diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp index 58ae38c4c..5a2370f67 100644 --- a/src/Mod/Part/Gui/TaskThickness.cpp +++ b/src/Mod/Part/Gui/TaskThickness.cpp @@ -114,7 +114,7 @@ Part::Thickness* ThicknessWidget::getObject() const void ThicknessWidget::on_spinOffset_valueChanged(double val) { - d->thickness->Value.setValue((float)val); + d->thickness->Value.setValue(val); if (d->ui.updateView->isChecked()) d->thickness->getDocument()->recomputeFeature(d->thickness); } @@ -128,7 +128,7 @@ void ThicknessWidget::on_modeType_activated(int val) void ThicknessWidget::on_joinType_activated(int val) { - d->thickness->Join.setValue((float)val); + d->thickness->Join.setValue((long)val); if (d->ui.updateView->isChecked()) d->thickness->getDocument()->recomputeFeature(d->thickness); } diff --git a/src/Mod/Part/Gui/ViewProvider.cpp b/src/Mod/Part/Gui/ViewProvider.cpp index ac9956fe5..3c2d57559 100644 --- a/src/Mod/Part/Gui/ViewProvider.cpp +++ b/src/Mod/Part/Gui/ViewProvider.cpp @@ -55,8 +55,8 @@ # include # include # include -# include -# include +# include +# include # include # include # include @@ -149,8 +149,8 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartBase, Gui::ViewProviderGeometryObject) //************************************************************************** // Construction/Destruction -App::PropertyFloatConstraint::Constraints ViewProviderPartBase::floatRange = {1.0f,64.0f,1.0f}; -const char* ViewProviderPartBase::LightingEnums[]= {"One side","Two side",NULL}; +App::PropertyFloatConstraint::Constraints ViewProviderPartBase::floatRange = {1.0,64.0,1.0}; +const char* ViewProviderPartBase::LightingEnums[]= {"One side","Two side",NULL}; ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0) { @@ -170,8 +170,8 @@ ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0) PointSize.setConstraints(&floatRange); ADD_PROPERTY(PointSize,(2.0f)); ADD_PROPERTY(ControlPoints,(false)); - ADD_PROPERTY(Lighting,(1)); - Lighting.setEnums(LightingEnums); + ADD_PROPERTY(Lighting,(1)); + Lighting.setEnums(LightingEnums); EdgeRoot = new SoSeparator(); EdgeRoot->ref(); @@ -196,11 +196,11 @@ ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0) pcPointStyle->ref(); pcPointStyle->style = SoDrawStyle::POINTS; pcPointStyle->pointSize = PointSize.getValue(); - - pShapeHints = new SoShapeHints; - pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; - pShapeHints->ref(); - Lighting.touch(); + + pShapeHints = new SoShapeHints; + pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; + pShapeHints->ref(); + Lighting.touch(); sPixmap = "Tree_Part"; loadParameter(); @@ -215,7 +215,7 @@ ViewProviderPartBase::~ViewProviderPartBase() pcPointMaterial->unref(); pcLineStyle->unref(); pcPointStyle->unref(); - pShapeHints->unref(); + pShapeHints->unref(); } void ViewProviderPartBase::onChanged(const App::Property* prop) @@ -265,12 +265,12 @@ void ViewProviderPartBase::onChanged(const App::Property* prop) App::Property* shape = obj->getPropertyByName("Shape"); showControlPoints(ControlPoints.getValue(), shape); } - else if (prop == &Lighting) { - if (Lighting.getValue() == 0) - pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING; - else - pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; - } + else if (prop == &Lighting) { + if (Lighting.getValue() == 0) + pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING; + else + pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; + } else { ViewProviderGeometryObject::onChanged(prop); } @@ -346,7 +346,7 @@ std::vector ViewProviderPartBase::getDisplayModes(void) const return StrList; } - + void ViewProviderPartBase::shapeInfoCallback(void * ud, SoEventCallback * n) { const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent(); @@ -901,7 +901,7 @@ void ViewProviderPartBase::showControlPoints(bool show, const App::Property* pro { if (!pcControlPoints && show) { pcControlPoints = new SoSwitch(); - pcRoot->addChild(pcControlPoints); + pcRoot->addChild(pcControlPoints); } if (pcControlPoints) { @@ -1152,12 +1152,12 @@ void ViewProviderEllipsoid::updateData(const App::Property* prop) return; App::DocumentObject* object = this->getObject(); if (object && object->isDerivedFrom(Part::Ellipsoid::getClassTypeId())) { - float angle1 = static_cast(object)->Angle1.getValue(); - float angle2 = static_cast(object)->Angle2.getValue(); - float angle3 = static_cast(object)->Angle3.getValue(); + double angle1 = static_cast(object)->Angle1.getValue(); + double angle2 = static_cast(object)->Angle2.getValue(); + double angle3 = static_cast(object)->Angle3.getValue(); float radius1 = static_cast(object)->Radius1.getValue(); float radius2 = static_cast(object)->Radius2.getValue(); - if (angle1 == -90.0f && angle2 == 90.0f && angle3 == 360.0f) { + if (angle1 == -90.0 && angle2 == 90.0 && angle3 == 360.0) { float scale = radius1/radius2; pScaling->scaleFactor.setValue(1,1,scale); pSphere->radius.setValue(radius2); diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 7dc155b08..765cd2d17 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -116,8 +116,8 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartExt, Gui::ViewProviderGeometryObject) //************************************************************************** // Construction/Destruction -App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0f,64.0f,1.0f}; -App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001f,100.0f,0.01f}; +App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0,64.0,1.0}; +App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001,100.0,0.01}; const char* ViewProviderPartExt::LightingEnums[]= {"One side","Two side",NULL}; const char* ViewProviderPartExt::DrawStyleEnums[]= {"Solid","Dashed","Dotted","Dashdot",NULL};