Remove magic number and hard type enums in Geometry.h

- Remove currently present magic numbers
- Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers.
This commit is contained in:
Benjamin Bræstrup Sayoc
2025-01-30 01:38:44 +01:00
committed by WandererFan
parent 033817f5fe
commit 97b34f9c57
19 changed files with 198 additions and 210 deletions

View File

@@ -231,9 +231,9 @@ void CosmeticEdgePy::setEnd(Py::Vector arg)
Py::Float CosmeticEdgePy::getRadius() const
{
TechDraw::GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != TechDraw::GeomType::CIRCLE) &&
(gt != TechDraw::GeomType::ARCOFCIRCLE) ) {
GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != GeomType::CIRCLE) &&
(gt != GeomType::ARCOFCIRCLE) ) {
throw Py::TypeError("Not a circle. Can not get radius");
}
double r = getCosmeticEdgePtr()->permaRadius;
@@ -242,9 +242,9 @@ Py::Float CosmeticEdgePy::getRadius() const
void CosmeticEdgePy::setRadius(Py::Float arg)
{
TechDraw::GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != TechDraw::GeomType::CIRCLE) &&
(gt != TechDraw::GeomType::ARCOFCIRCLE) ) {
GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != GeomType::CIRCLE) &&
(gt != GeomType::ARCOFCIRCLE) ) {
throw Py::TypeError("Not a circle. Can not set radius");
}
@@ -258,9 +258,9 @@ void CosmeticEdgePy::setRadius(Py::Float arg)
Py::Vector CosmeticEdgePy::getCenter() const
{
TechDraw::GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != TechDraw::GeomType::CIRCLE) &&
(gt != TechDraw::GeomType::ARCOFCIRCLE) ) {
GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
if ( (gt != GeomType::CIRCLE) &&
(gt != GeomType::ARCOFCIRCLE) ) {
throw Py::TypeError("Not a circle. Can not get center");
}
Base::Vector3d point = getCosmeticEdgePtr()->permaStart;
@@ -270,10 +270,10 @@ Py::Vector CosmeticEdgePy::getCenter() const
void CosmeticEdgePy::setCenter(Py::Vector arg)
{
TechDraw::GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
// PyObject* p = arg.ptr();
if ( (gt != TechDraw::GeomType::CIRCLE) &&
(gt != TechDraw::GeomType::ARCOFCIRCLE) ) {
if ( (gt != GeomType::CIRCLE) &&
(gt != GeomType::ARCOFCIRCLE) ) {
throw Py::TypeError("Not a circle. Can not set center");
}