diff --git a/src/Mod/Sketcher/App/AppSketcherPy.cpp b/src/Mod/Sketcher/App/AppSketcherPy.cpp index 9a7389c055..0333eccf77 100644 --- a/src/Mod/Sketcher/App/AppSketcherPy.cpp +++ b/src/Mod/Sketcher/App/AppSketcherPy.cpp @@ -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(pcDoc->addObject("Sketcher::SketchObjectSF",file.fileNamePure().c_str())); pcFeature->SketchFlatFile.setValue(EncodedName.c_str()); pcDoc->recompute(); diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 33094f54a7..6133385634 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -175,15 +175,15 @@ void Constraint::Restore(XMLReader &reader) { reader.readElement("Constrain"); Name = reader.getAttribute("Name"); - Type = (ConstraintType) reader.getAttributeAsInteger("Type"); + Type = static_cast(reader.getAttributeAsInteger("Type")); Value = reader.getAttributeAsFloat("Value"); First = reader.getAttributeAsInteger("First"); - FirstPos = (PointPos) reader.getAttributeAsInteger("FirstPos"); + FirstPos = static_cast(reader.getAttributeAsInteger("FirstPos")); Second = reader.getAttributeAsInteger("Second"); - SecondPos = (PointPos) reader.getAttributeAsInteger("SecondPos"); + SecondPos = static_cast(reader.getAttributeAsInteger("SecondPos")); if(this->Type==InternalAlignment) { - AlignmentType = (InternalAlignmentType) reader.getAttributeAsInteger("InternalAlignmentType"); + AlignmentType = static_cast(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(reader.getAttributeAsInteger("ThirdPos")); } // Read the distance a constraint label has been moved diff --git a/src/Mod/Sketcher/App/ConstraintPyImp.cpp b/src/Mod/Sketcher/App/ConstraintPyImp.cpp index 6c83337376..523058d259 100644 --- a/src/Mod/Sketcher/App/ConstraintPyImp.cpp +++ b/src/Mod/Sketcher/App/ConstraintPyImp.cpp @@ -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(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(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(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(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(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(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(intArg2); this->getConstraintPtr()->Second = intArg3; - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4; + this->getConstraintPtr()->SecondPos = static_cast(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(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(intArg2); this->getConstraintPtr()->Second = intArg3; - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4; + this->getConstraintPtr()->SecondPos = static_cast(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(intArg4); this->getConstraintPtr()->setValue(Value); return 0; } if (valid) { this->getConstraintPtr()->First = intArg1; - this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2; + this->getConstraintPtr()->FirstPos = static_cast(intArg2); this->getConstraintPtr()->Second = intArg3; - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) intArg4; + this->getConstraintPtr()->SecondPos = static_cast(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(FirstPos); this->getConstraintPtr()->Second = SecondIndex; - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) SecondPos; + this->getConstraintPtr()->SecondPos = static_cast(SecondPos); this->getConstraintPtr()->Third = ThirdIndex; - this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) ThirdPos; + this->getConstraintPtr()->ThirdPos = static_cast(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(FirstPos); this->getConstraintPtr()->Second = SecondIndex; - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) SecondPos; + this->getConstraintPtr()->SecondPos = static_cast(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(Sketcher::PointPos::none) && pos<=static_cast(Sketcher::PointPos::mid)) { - this->getConstraintPtr()->FirstPos = (Sketcher::PointPos)pos; + this->getConstraintPtr()->FirstPos = static_cast(pos); } else { std::stringstream str; @@ -601,7 +601,7 @@ void ConstraintPy::setSecondPos(Py::Long arg) int pos = arg; if(pos>=static_cast(Sketcher::PointPos::none) && pos<=static_cast(Sketcher::PointPos::mid)) { - this->getConstraintPtr()->SecondPos = (Sketcher::PointPos)pos; + this->getConstraintPtr()->SecondPos = static_cast(pos); } else { std::stringstream str; @@ -631,7 +631,7 @@ void ConstraintPy::setThirdPos(Py::Long arg) int pos = arg; if(pos>=static_cast(Sketcher::PointPos::none) && pos<=static_cast(Sketcher::PointPos::mid)) { - this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos)pos; + this->getConstraintPtr()->ThirdPos = static_cast(pos); } else { std::stringstream str; diff --git a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp index eb8d422c78..cc988feeb9 100644 --- a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp +++ b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp @@ -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(reader.getAttributeAsInteger("internalGeometryType")); GeometryModeFlags = GeometryModeFlagType(reader.getAttribute("geometryModeFlags")); diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index aa841dde63..d4e5b02ec4 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -571,7 +571,7 @@ PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args) return nullptr; if (pos >= static_cast(Sketcher::PointPos::none) && pos <= static_cast(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(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(pcObj)->value(); - if (this->getSketchObjectPtr()->movePoint(GeoId,(Sketcher::PointPos)PointType,v1,(relative>0))) { + if (this->getSketchObjectPtr()->movePoint(GeoId,static_cast(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(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(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(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(Py::Long(t.getItem(0))); c.FirstPos = checkpos(t,1); - c.Second = (long)Py::Long(t.getItem(2)); + c.Second = static_cast(Py::Long(t.getItem(2))); c.SecondPos = checkpos(t,3); - c.Type = (Sketcher::ConstraintType)(long)Py::Long(t.getItem(4)); + c.Type = static_cast(static_cast(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(Py::Long(t.getItem(0))); c.FirstPos = checkpos(t,1); - c.Second = (long)Py::Long(t.getItem(2)); + c.Second = static_cast(Py::Long(t.getItem(2))); c.SecondPos = checkpos(t,3); - c.Type = (Sketcher::ConstraintType)(long)Py::Long(t.getItem(4)); + c.Type = static_cast(static_cast(Py::Long(t.getItem(4)))); constraints.push_back(c); } diff --git a/src/Mod/Sketcher/App/SketchPyImp.cpp b/src/Mod/Sketcher/App/SketchPyImp.cpp index a00ea2669b..3cb17e82ca 100644 --- a/src/Mod/Sketcher/App/SketchPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchPyImp.cpp @@ -160,7 +160,7 @@ PyObject* SketchPy::movePoint(PyObject *args) return nullptr; Base::Vector3d* toPoint = static_cast(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(index2),*toPoint,(relative>0)))); } // +++ attributes implementer ++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp index 3e46555bca..239e600978 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp @@ -398,7 +398,7 @@ void TaskSketcherSolverAdvanced::on_lineEditRedundantSolverParam3_editingFinishe void TaskSketcherSolverAdvanced::on_comboBoxDefaultSolver_currentIndexChanged(int index) { ui->comboBoxDefaultSolver->onSave(); - const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver=(GCS::Algorithm) index; + const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver = static_cast(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(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant=(GCS::Algorithm) index; + const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant = static_cast(index); updateRedundantMethodParameters(); } @@ -565,14 +565,14 @@ void TaskSketcherSolverAdvanced::updateSketchObject() const_cast(sketchView->getSketchObject()->getSolvedSketch()).setDebugMode((GCS::DebugMode) ui->comboBoxDebugMode->currentIndex()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setSketchSizeMultiplierRedundant(ui->checkBoxRedundantSketchSizeMultiplier->isChecked()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setMaxIterRedundant(ui->spinBoxRedundantSolverMaxIterations->value()); - const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant=(GCS::Algorithm) ui->comboBoxRedundantDefaultSolver->currentIndex(); + const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolverRedundant = static_cast(ui->comboBoxRedundantDefaultSolver->currentIndex()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setQRAlgorithm((GCS::QRAlgorithm) ui->comboBoxQRMethod->currentIndex()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setQRPivotThreshold(ui->lineEditQRPivotThreshold->text().toDouble()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setConvergenceRedundant(ui->lineEditRedundantConvergence->text().toDouble()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setConvergence(ui->lineEditConvergence->text().toDouble()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setSketchSizeMultiplier(ui->checkBoxSketchSizeMultiplier->isChecked()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setMaxIter(ui->spinBoxMaxIter->value()); - const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver=(GCS::Algorithm) ui->comboBoxDefaultSolver->currentIndex(); + const_cast(sketchView->getSketchObject()->getSolvedSketch()).defaultSolver = static_cast(ui->comboBoxDefaultSolver->currentIndex()); const_cast(sketchView->getSketchObject()->getSolvedSketch()).setDogLegGaussStep((GCS::DogLegGaussStep) ui->comboBoxDogLegGaussStep->currentIndex()); updateDefaultMethodParameters();