Skip to content

Commit

Permalink
[Sketch] remove unnecessary Boolean comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
donovaly committed Jun 19, 2022
1 parent f489148 commit 68a4995
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/App/Sketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList,

int cid = 0;
for (std::vector<Constraint *>::const_iterator it = ConstraintList.begin();it!=ConstraintList.end();++it,++cid) {
if (!unenforceableConstraints[cid] && (*it)->Type != Block && (*it)->isActive == true) {
if (!unenforceableConstraints[cid] && (*it)->Type != Block && (*it)->isActive) {
rtn = addConstraint (*it);

if(rtn == -1) {
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Sketcher/App/SketchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ int SketchObject::toggleDriving(int ConstrId)

bool extorconstructionpoint1 = (vals[ConstrId]->First == GeoEnum::GeoUndef) ||
(vals[ConstrId]->First < 0) ||
(geof1 && geof1->isGeoType(Part::GeomPoint::getClassTypeId()) && geof1->getConstruction() == true);
(geof1 && geof1->isGeoType(Part::GeomPoint::getClassTypeId()) && geof1->getConstruction());
bool extorconstructionpoint2 = (vals[ConstrId]->Second == GeoEnum::GeoUndef)||
(vals[ConstrId]->Second < 0) ||
(geof2 && geof2->isGeoType(Part::GeomPoint::getClassTypeId()) && geof2->getConstruction() == true);
(geof2 && geof2->isGeoType(Part::GeomPoint::getClassTypeId()) && geof2->getConstruction());
bool extorconstructionpoint3 = (vals[ConstrId]->Third == GeoEnum::GeoUndef) ||
(vals[ConstrId]->Third < 0) ||
(geof3 && geof3->isGeoType(Part::GeomPoint::getClassTypeId()) && geof3->getConstruction() == true);
(geof3 && geof3->isGeoType(Part::GeomPoint::getClassTypeId()) && geof3->getConstruction());

if (extorconstructionpoint1 && extorconstructionpoint2 && extorconstructionpoint3 && vals[ConstrId]->isDriving==false)
if (extorconstructionpoint1 && extorconstructionpoint2 && extorconstructionpoint3 && !vals[ConstrId]->isDriving)
return -4;

// copy the list
Expand Down Expand Up @@ -467,7 +467,7 @@ int SketchObject::testDrivingChange(int ConstrId, bool isdriving)
if (!vals[ConstrId]->isDimensional())
return -2;

if (!(vals[ConstrId]->First>=0 || vals[ConstrId]->Second>=0 || vals[ConstrId]->Third>=0) && isdriving==true)
if (!(vals[ConstrId]->First>=0 || vals[ConstrId]->Second>=0 || vals[ConstrId]->Third>=0) && isdriving)
return -3; // a constraint that does not have at least one element as not-external-geometry can never be driving.

return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Sketcher/App/SketchObjectPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ PyObject* SketchObjectPy::convertToNURBS(PyObject *args)
if (!PyArg_ParseTuple(args, "i", &GeoId))
return nullptr;

if (this->getSketchObjectPtr()->convertToNURBS(GeoId)==false) {
if (!this->getSketchObjectPtr()->convertToNURBS(GeoId)) {
std::stringstream str;
str << "Object does not support NURBS conversion: " << GeoId;
PyErr_SetString(PyExc_ValueError, str.str().c_str());
Expand All @@ -1510,7 +1510,7 @@ PyObject* SketchObjectPy::increaseBSplineDegree(PyObject *args)
if (!PyArg_ParseTuple(args, "i|i", &GeoId, &incr))
return nullptr;

if (this->getSketchObjectPtr()->increaseBSplineDegree(GeoId, incr)==false) {
if (!this->getSketchObjectPtr()->increaseBSplineDegree(GeoId, incr)) {
std::stringstream str;
str << "Degree increase failed for: " << GeoId;
PyErr_SetString(PyExc_ValueError, str.str().c_str());
Expand Down Expand Up @@ -1541,7 +1541,7 @@ PyObject* SketchObjectPy::modifyBSplineKnotMultiplicity(PyObject *args)
if (!PyArg_ParseTuple(args, "ii|i", &GeoId, &knotIndex, &multiplicity))
return nullptr;

if (this->getSketchObjectPtr()->modifyBSplineKnotMultiplicity(GeoId, knotIndex, multiplicity)==false) {
if (!this->getSketchObjectPtr()->modifyBSplineKnotMultiplicity(GeoId, knotIndex, multiplicity)) {
std::stringstream str;
str << "Multiplicity modification failed for: " << GeoId;
PyErr_SetString(PyExc_ValueError, str.str().c_str());
Expand All @@ -1560,7 +1560,7 @@ PyObject* SketchObjectPy::insertBSplineKnot(PyObject *args)
if (!PyArg_ParseTuple(args, "id|i", &GeoId, &knotParam, &multiplicity))
return nullptr;

if (this->getSketchObjectPtr()->insertBSplineKnot(GeoId, knotParam, multiplicity)==false) {
if (!this->getSketchObjectPtr()->insertBSplineKnot(GeoId, knotParam, multiplicity)) {
std::stringstream str;
str << "Knot insertion failed for: " << GeoId;
PyErr_SetString(PyExc_ValueError, str.str().c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void removeRedundantHorizontalVertical(Sketcher::SketchObject* psketch,
axis = false;

for(std::vector<AutoConstraint>::const_iterator it = sug.begin(); it!=sug.end(); ++it) {
if( (*it).Type == Sketcher::Coincident && ext == false) {
if( (*it).Type == Sketcher::Coincident && !ext) {
const std::map<int, Sketcher::PointPos> coincidents = psketch->getAllCoincidentPoints((*it).GeoId, (*it).PosId);

if(!coincidents.empty()) {
Expand All @@ -162,7 +162,7 @@ void removeRedundantHorizontalVertical(Sketcher::SketchObject* psketch,
orig = ((*it).GeoId == -1 && (*it).PosId == Sketcher::PointPos::start);
}
}
else if( (*it).Type == Sketcher::PointOnObject && axis == false) {
else if( (*it).Type == Sketcher::PointOnObject && !axis) {
axis = (((*it).GeoId == -1 && (*it).PosId == Sketcher::PointPos::none) || ((*it).GeoId == -2 && (*it).PosId == Sketcher::PointPos::none));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/Gui/TaskSketcherElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ void TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(void)
for (int i=0;i<ui->listWidgetElements->count(); i++) {
ElementItem * ite=static_cast<ElementItem*>(ui->listWidgetElements->item(i));

if(multipleselection==false && multipleconsecutiveselection==false && ite!=itf) {
if(!multipleselection && !multipleconsecutiveselection && ite != itf) {
ite->isLineSelected=false;
ite->isStartingPointSelected=false;
ite->isEndPointSelected=false;
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ bool ViewProviderSketch::keyPressed(bool pressed, int key)
sketchHandler->quit();
return true;
}
if (isInEditMode() && (drag.DragConstraintSet.empty() == false)) {
if (isInEditMode() && !drag.DragConstraintSet.empty()) {
if (!pressed) {
drag.DragConstraintSet.clear();
}
Expand Down Expand Up @@ -827,7 +827,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
Mode = STATUS_NONE;
return true;
case STATUS_SKETCH_DragConstraint:
if (drag.DragConstraintSet.empty() == false) {
if (!drag.DragConstraintSet.empty()) {
getDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Drag Constraint"));
auto idset = drag.DragConstraintSet;
for(int id : idset) {
Expand Down Expand Up @@ -1249,7 +1249,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
}
return true;
case STATUS_SKETCH_DragConstraint:
if (drag.DragConstraintSet.empty() == false) {
if (!drag.DragConstraintSet.empty()) {
auto idset = drag.DragConstraintSet;
for(int id : idset)
moveConstraint(id, Base::Vector2d(x,y));
Expand Down Expand Up @@ -1728,7 +1728,7 @@ bool ViewProviderSketch::detectAndShowPreselection(SoPickedPoint * Point, const
sketchHandler->applyCursor();
return true;
}
} else if (result.ConstrIndices.empty() == false && result.ConstrIndices != preselection.PreselectConstraintSet) { // if a constraint is hit
} else if (!result.ConstrIndices.empty() && result.ConstrIndices != preselection.PreselectConstraintSet) { // if a constraint is hit
bool accepted = true;
for(std::set<int>::iterator it = result.ConstrIndices.begin(); it != result.ConstrIndices.end(); ++it) {
std::stringstream ss;
Expand Down

0 comments on commit 68a4995

Please sign in to comment.