Sketcher: Replace C cast

This commit is contained in:
marioalexis
2022-06-17 12:13:54 -03:00
committed by Chris Hennes
parent 67dc3c5cd1
commit 36968c835d
7 changed files with 45 additions and 45 deletions

View File

@@ -103,7 +103,7 @@ private:
}
if (file.hasExtension("skf")) {
Sketcher::SketchObjectSF *pcFeature = (Sketcher::SketchObjectSF *)pcDoc->addObject("Sketcher::SketchObjectSF",file.fileNamePure().c_str());
Sketcher::SketchObjectSF *pcFeature = static_cast<Sketcher::SketchObjectSF *>(pcDoc->addObject("Sketcher::SketchObjectSF",file.fileNamePure().c_str()));
pcFeature->SketchFlatFile.setValue(EncodedName.c_str());
pcDoc->recompute();

View File

@@ -175,15 +175,15 @@ void Constraint::Restore(XMLReader &reader)
{
reader.readElement("Constrain");
Name = reader.getAttribute("Name");
Type = (ConstraintType) reader.getAttributeAsInteger("Type");
Type = static_cast<ConstraintType>(reader.getAttributeAsInteger("Type"));
Value = reader.getAttributeAsFloat("Value");
First = reader.getAttributeAsInteger("First");
FirstPos = (PointPos) reader.getAttributeAsInteger("FirstPos");
FirstPos = static_cast<PointPos>(reader.getAttributeAsInteger("FirstPos"));
Second = reader.getAttributeAsInteger("Second");
SecondPos = (PointPos) reader.getAttributeAsInteger("SecondPos");
SecondPos = static_cast<PointPos>(reader.getAttributeAsInteger("SecondPos"));
if(this->Type==InternalAlignment) {
AlignmentType = (InternalAlignmentType) reader.getAttributeAsInteger("InternalAlignmentType");
AlignmentType = static_cast<InternalAlignmentType>(reader.getAttributeAsInteger("InternalAlignmentType"));
if (reader.hasAttribute("InternalAlignmentIndex"))
InternalAlignmentIndex = reader.getAttributeAsInteger("InternalAlignmentIndex");
@@ -195,7 +195,7 @@ void Constraint::Restore(XMLReader &reader)
// read the third geo group if present
if (reader.hasAttribute("Third")) {
Third = reader.getAttributeAsInteger("Third");
ThirdPos = (PointPos) reader.getAttributeAsInteger("ThirdPos");
ThirdPos = static_cast<PointPos>(reader.getAttributeAsInteger("ThirdPos"));
}
// Read the distance a constraint label has been moved

View File

@@ -214,7 +214,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
if (valid) {
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(FirstPos);
this->getConstraintPtr()->Second = SecondIndex;
return 0;
}
@@ -249,7 +249,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
SecondIndex = -1;
this->getConstraintPtr()->Type = DistanceX;
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(FirstPos);
this->getConstraintPtr()->setValue(Value);
return 0;
}
@@ -258,7 +258,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
SecondIndex = -1;
this->getConstraintPtr()->Type = DistanceY;
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(FirstPos);
this->getConstraintPtr()->setValue(Value);
return 0;
}
@@ -299,7 +299,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
this->getConstraintPtr()->Second = intArg2;
this->getConstraintPtr()->SecondPos = Sketcher::PointPos::none;
this->getConstraintPtr()->Third = intArg3;
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->ThirdPos = static_cast<Sketcher::PointPos>(intArg4);
return 0;
}
else if (strcmp("PerpendicularViaPoint", ConstraintType) == 0) {
@@ -310,7 +310,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
this->getConstraintPtr()->Second = intArg2;
this->getConstraintPtr()->SecondPos = Sketcher::PointPos::none;
this->getConstraintPtr()->Third = intArg3;
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->ThirdPos = static_cast<Sketcher::PointPos>(intArg4);
return 0;
}
else if (strstr(ConstraintType,"InternalAlignment")) { // InteralAlignment with InternalElementIndex argument
@@ -328,7 +328,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (valid) {
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(intArg2);
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->InternalAlignmentIndex = intArg4;
return 0;
@@ -337,9 +337,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
if (valid) {
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(intArg2);
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(intArg4);
return 0;
}
}
@@ -349,7 +349,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (strcmp("Distance",ConstraintType) == 0 ) {
this->getConstraintPtr()->Type = Distance;
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(intArg2);
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->setValue(Value);
return 0;
@@ -365,9 +365,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (strcmp("Symmetric",ConstraintType) == 0 ) {
this->getConstraintPtr()->Type = Symmetric;
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(intArg2);
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(intArg4);
this->getConstraintPtr()->Third = intArg5;
return 0;
}
@@ -410,15 +410,15 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
this->getConstraintPtr()->Second = intArg2; //let's goof up all the terminology =)
this->getConstraintPtr()->SecondPos = Sketcher::PointPos::none;
this->getConstraintPtr()->Third = intArg3;
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->ThirdPos = static_cast<Sketcher::PointPos>(intArg4);
this->getConstraintPtr()->setValue(Value);
return 0;
}
if (valid) {
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(intArg2);
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(intArg4);
this->getConstraintPtr()->setValue(Value);
return 0;
}
@@ -433,11 +433,11 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (strcmp("Symmetric",ConstraintType) == 0 ) {
this->getConstraintPtr()->Type = Symmetric;
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(FirstPos);
this->getConstraintPtr()->Second = SecondIndex;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) SecondPos;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(SecondPos);
this->getConstraintPtr()->Third = ThirdIndex;
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) ThirdPos;
this->getConstraintPtr()->ThirdPos = static_cast<Sketcher::PointPos>(ThirdPos);
return 0;
}
}
@@ -446,9 +446,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (strcmp("SnellsLaw",ConstraintType) == 0 ) {
this->getConstraintPtr()->Type = SnellsLaw;
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(FirstPos);
this->getConstraintPtr()->Second = SecondIndex;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) SecondPos;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(SecondPos);
this->getConstraintPtr()->Third = ThirdIndex;
this->getConstraintPtr()->ThirdPos = Sketcher::PointPos::none;
this->getConstraintPtr()->setValue(Value);
@@ -571,7 +571,7 @@ void ConstraintPy::setFirstPos(Py::Long arg)
int pos = arg;
if(pos>=static_cast<int>(Sketcher::PointPos::none) && pos<=static_cast<int>(Sketcher::PointPos::mid)) {
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos)pos;
this->getConstraintPtr()->FirstPos = static_cast<Sketcher::PointPos>(pos);
}
else {
std::stringstream str;
@@ -601,7 +601,7 @@ void ConstraintPy::setSecondPos(Py::Long arg)
int pos = arg;
if(pos>=static_cast<int>(Sketcher::PointPos::none) && pos<=static_cast<int>(Sketcher::PointPos::mid)) {
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos)pos;
this->getConstraintPtr()->SecondPos = static_cast<Sketcher::PointPos>(pos);
}
else {
std::stringstream str;
@@ -631,7 +631,7 @@ void ConstraintPy::setThirdPos(Py::Long arg)
int pos = arg;
if(pos>=static_cast<int>(Sketcher::PointPos::none) && pos<=static_cast<int>(Sketcher::PointPos::mid)) {
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos)pos;
this->getConstraintPtr()->ThirdPos = static_cast<Sketcher::PointPos>(pos);
}
else {
std::stringstream str;

View File

@@ -72,7 +72,7 @@ void SketchGeometryExtension::restoreAttributes(Base::XMLReader &reader)
if(reader.hasAttribute("id"))
Id = reader.getAttributeAsInteger("id");
InternalGeometryType = (InternalType::InternalType) reader.getAttributeAsInteger("internalGeometryType");
InternalGeometryType = static_cast<InternalType::InternalType>(reader.getAttributeAsInteger("internalGeometryType"));
GeometryModeFlags = GeometryModeFlagType(reader.getAttribute("geometryModeFlags"));

View File

@@ -571,7 +571,7 @@ PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args)
return nullptr;
if (pos >= static_cast<int>(Sketcher::PointPos::none) && pos <= static_cast<int>(Sketcher::PointPos::mid)) { // This is the whole range of valid positions
if (this->getSketchObjectPtr()->delConstraintOnPoint(Index,(Sketcher::PointPos)pos)) {
if (this->getSketchObjectPtr()->delConstraintOnPoint(Index,static_cast<Sketcher::PointPos>(pos))) {
std::stringstream str;
str << "Not able to delete a constraint on point with the given index: " << Index
<< " and position: " << pos;
@@ -1007,7 +1007,7 @@ PyObject* SketchObjectPy::movePoint(PyObject *args)
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pcObj)->value();
if (this->getSketchObjectPtr()->movePoint(GeoId,(Sketcher::PointPos)PointType,v1,(relative>0))) {
if (this->getSketchObjectPtr()->movePoint(GeoId,static_cast<Sketcher::PointPos>(PointType),v1,(relative>0))) {
std::stringstream str;
str << "Not able to move point with the id and type: (" << GeoId << ", " << PointType << ")";
PyErr_SetString(PyExc_ValueError, str.str().c_str());
@@ -1051,7 +1051,7 @@ PyObject* SketchObjectPy::getPoint(PyObject *args)
return nullptr;
}
return new Base::VectorPy(new Base::Vector3d(obj->getPoint(GeoId,(Sketcher::PointPos)PointType)));
return new Base::VectorPy(new Base::Vector3d(obj->getPoint(GeoId,static_cast<Sketcher::PointPos>(PointType))));
}
PyObject* SketchObjectPy::getAxis(PyObject *args)
@@ -1093,7 +1093,7 @@ PyObject* SketchObjectPy::fillet(PyObject *args)
PyErr_Clear();
// Point, radius
if (PyArg_ParseTuple(args, "iid|iO!", &geoId1, &posId1, &radius, &trim, &PyBool_Type, &createCorner)) {
if (this->getSketchObjectPtr()->fillet(geoId1, (Sketcher::PointPos) posId1, radius, trim,
if (this->getSketchObjectPtr()->fillet(geoId1, static_cast<Sketcher::PointPos>(posId1), radius, trim,
Base::asBoolean(createCorner))) {
std::stringstream str;
str << "Not able to fillet point with ( geoId: " << geoId1 << ", PointPos: " << posId1 << " )";
@@ -1187,7 +1187,7 @@ PyObject* SketchObjectPy::addSymmetric(PyObject *args)
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
}
int ret = this->getSketchObjectPtr()->addSymmetric(geoIdList,refGeoId,(Sketcher::PointPos) refPosId) + 1;
int ret = this->getSketchObjectPtr()->addSymmetric(geoIdList,refGeoId,static_cast<Sketcher::PointPos>(refPosId)) + 1;
if(ret == -1)
throw Py::TypeError("Symmetric operation unsuccessful!");
@@ -1711,11 +1711,11 @@ void SketchObjectPy::setMissingPointOnPointConstraints(Py::List arg)
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));
c.First = static_cast<long>(Py::Long(t.getItem(0)));
c.FirstPos = checkpos(t,1);
c.Second = (long)Py::Long(t.getItem(2));
c.Second = static_cast<long>(Py::Long(t.getItem(2)));
c.SecondPos = checkpos(t,3);
c.Type = (Sketcher::ConstraintType)(long)Py::Long(t.getItem(4));
c.Type = static_cast<Sketcher::ConstraintType>(static_cast<long>(Py::Long(t.getItem(4))));
constraints.push_back(c);
}
@@ -1752,11 +1752,11 @@ void SketchObjectPy::setMissingVerticalHorizontalConstraints(Py::List arg)
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));
c.First = static_cast<long>(Py::Long(t.getItem(0)));
c.FirstPos = checkpos(t,1);
c.Second = (long)Py::Long(t.getItem(2));
c.Second = static_cast<long>(Py::Long(t.getItem(2)));
c.SecondPos = checkpos(t,3);
c.Type = (Sketcher::ConstraintType)(long)Py::Long(t.getItem(4));
c.Type = static_cast<Sketcher::ConstraintType>(static_cast<long>(Py::Long(t.getItem(4))));
constraints.push_back(c);
}

View File

@@ -160,7 +160,7 @@ PyObject* SketchPy::movePoint(PyObject *args)
return nullptr;
Base::Vector3d* toPoint = static_cast<Base::VectorPy*>(pcObj)->getVectorPtr();
return Py::new_reference_to(Py::Long(getSketchPtr()->movePoint(index1,(Sketcher::PointPos)index2,*toPoint,(relative>0))));
return Py::new_reference_to(Py::Long(getSketchPtr()->movePoint(index1,static_cast<Sketcher::PointPos>(index2),*toPoint,(relative>0))));
}
// +++ attributes implementer ++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -398,7 +398,7 @@ void TaskSketcherSolverAdvanced::on_lineEditRedundantSolverParam3_editingFinishe
void TaskSketcherSolverAdvanced::on_comboBoxDefaultSolver_currentIndexChanged(int index)
{
ui->comboBoxDefaultSolver->onSave();
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver=(GCS::Algorithm) index;
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver = static_cast<GCS::Algorithm>(index);
updateDefaultMethodParameters();
}
@@ -478,7 +478,7 @@ void TaskSketcherSolverAdvanced::on_comboBoxQRMethod_currentIndexChanged(int ind
void TaskSketcherSolverAdvanced::on_comboBoxRedundantDefaultSolver_currentIndexChanged(int index)
{
ui->comboBoxRedundantDefaultSolver->onSave();
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant=(GCS::Algorithm) index;
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant = static_cast<GCS::Algorithm>(index);
updateRedundantMethodParameters();
}
@@ -565,14 +565,14 @@ void TaskSketcherSolverAdvanced::updateSketchObject()
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setDebugMode((GCS::DebugMode) ui->comboBoxDebugMode->currentIndex());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setSketchSizeMultiplierRedundant(ui->checkBoxRedundantSketchSizeMultiplier->isChecked());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setMaxIterRedundant(ui->spinBoxRedundantSolverMaxIterations->value());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant=(GCS::Algorithm) ui->comboBoxRedundantDefaultSolver->currentIndex();
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant = static_cast<GCS::Algorithm>(ui->comboBoxRedundantDefaultSolver->currentIndex());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setQRAlgorithm((GCS::QRAlgorithm) ui->comboBoxQRMethod->currentIndex());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setQRPivotThreshold(ui->lineEditQRPivotThreshold->text().toDouble());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setConvergenceRedundant(ui->lineEditRedundantConvergence->text().toDouble());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setConvergence(ui->lineEditConvergence->text().toDouble());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setSketchSizeMultiplier(ui->checkBoxSketchSizeMultiplier->isChecked());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setMaxIter(ui->spinBoxMaxIter->value());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver=(GCS::Algorithm) ui->comboBoxDefaultSolver->currentIndex();
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver = static_cast<GCS::Algorithm>(ui->comboBoxDefaultSolver->currentIndex());
const_cast<Sketcher::Sketch &>(sketchView->getSketchObject()->getSolvedSketch()).setDogLegGaussStep((GCS::DogLegGaussStep) ui->comboBoxDogLegGaussStep->currentIndex());
updateDefaultMethodParameters();