Suggestions for Part module moving float -> double

This commit is contained in:
jrheinlaender 2013-03-25 17:15:21 +04:30
parent 67a518083d
commit 4c0781a555
11 changed files with 137 additions and 137 deletions

View File

@ -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 {

View File

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

View File

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

View File

@ -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)

View File

@ -22,34 +22,34 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRep_Builder.hxx>
# include <BRep_Tool.hxx>
# include <BRepTools.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <ShapeAnalysis.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepLProp_SLProps.hxx>
# include <BRepOffsetAPI_MakeOffset.hxx>
#ifndef _PreComp_
# include <BRep_Builder.hxx>
# include <BRep_Tool.hxx>
# include <BRepTools.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <ShapeAnalysis.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepLProp_SLProps.hxx>
# include <BRepOffsetAPI_MakeOffset.hxx>
# include <Geom_BezierSurface.hxx>
# include <Geom_BSplineSurface.hxx>
# include <Geom_Plane.hxx>
# include <Geom_CylindricalSurface.hxx>
# include <Geom_ConicalSurface.hxx>
# include <Geom_Plane.hxx>
# include <Geom_CylindricalSurface.hxx>
# include <Geom_ConicalSurface.hxx>
# include <Geom_SphericalSurface.hxx>
# include <Geom_ToroidalSurface.hxx>
# include <Handle_Geom_Surface.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <gp_Pnt2d.hxx>
# include <gp_Pln.hxx>
# include <gp_Cylinder.hxx>
# include <gp_Cone.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <gp_Pnt2d.hxx>
# include <gp_Pln.hxx>
# include <gp_Cylinder.hxx>
# include <gp_Cone.hxx>
# include <gp_Sphere.hxx>
# include <gp_Torus.hxx>
# include <Standard_Version.hxx>
#endif
#endif
#include <BRepTopAdaptor_FClass2d.hxx>
#include <BRepPrimAPI_MakeHalfSpace.hxx>
@ -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<Part::TopoShapePy*>(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);

View File

@ -23,10 +23,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <gp_Pnt.hxx>
# include <gp_Ax1.hxx>
# include <BRep_Tool.hxx>
#ifndef _PreComp_
# include <gp_Pnt.hxx>
# include <gp_Ax1.hxx>
# include <BRep_Tool.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Vertex.hxx>
# include <BRep_Builder.hxx>
@ -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&) {

View File

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

View File

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

View File

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

View File

@ -55,8 +55,8 @@
# include <TopTools_IndexedMapOfShape.hxx>
# include <Poly_PolygonOnTriangulation.hxx>
# include <TColStd_Array1OfInteger.hxx>
# include <TopTools_ListOfShape.hxx>
# include <Inventor/SoPickedPoint.h>
# include <TopTools_ListOfShape.hxx>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
@ -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<std::string> 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<Part::Ellipsoid*>(object)->Angle1.getValue();
float angle2 = static_cast<Part::Ellipsoid*>(object)->Angle2.getValue();
float angle3 = static_cast<Part::Ellipsoid*>(object)->Angle3.getValue();
double angle1 = static_cast<Part::Ellipsoid*>(object)->Angle1.getValue();
double angle2 = static_cast<Part::Ellipsoid*>(object)->Angle2.getValue();
double angle3 = static_cast<Part::Ellipsoid*>(object)->Angle3.getValue();
float radius1 = static_cast<Part::Ellipsoid*>(object)->Radius1.getValue();
float radius2 = static_cast<Part::Ellipsoid*>(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);

View File

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