[Base, Sketcher] remove redundant boolean checks

This commit is contained in:
Uwe
2022-10-02 22:14:45 +02:00
parent 2dd9f90f57
commit bf3d7f64ca
3 changed files with 52 additions and 66 deletions

View File

@@ -336,7 +336,7 @@ void SketcherGui::removeRedundantHorizontalVertical(Sketcher::SketchObject* pske
std::vector<AutoConstraint> &sug1,
std::vector<AutoConstraint> &sug2)
{
if(!sug1.empty() && !sug2.empty()) {
if (!sug1.empty() && !sug2.empty()) {
bool rmvhorvert = false;
@@ -349,8 +349,9 @@ void SketcherGui::removeRedundantHorizontalVertical(Sketcher::SketchObject* pske
orig = false;
axis = false;
for(std::vector<AutoConstraint>::const_iterator it = sug.begin(); it!=sug.end(); ++it) {
if( (*it).Type == Sketcher::Coincident && ext == false) {
for (std::vector<AutoConstraint>::const_iterator it = sug.begin(); it != sug.end();
++it) {
if ((*it).Type == Sketcher::Coincident && !ext) {
const std::map<int, Sketcher::PointPos> coincidents = psketch->getAllCoincidentPoints((*it).GeoId, (*it).PosId);
if(!coincidents.empty()) {
@@ -371,8 +372,9 @@ void SketcherGui::removeRedundantHorizontalVertical(Sketcher::SketchObject* pske
orig = ((*it).GeoId == -1 && (*it).PosId == Sketcher::PointPos::start);
}
}
else if( (*it).Type == Sketcher::PointOnObject && axis == false) {
axis = (((*it).GeoId == -1 && (*it).PosId == Sketcher::PointPos::none) || ((*it).GeoId == -2 && (*it).PosId == Sketcher::PointPos::none));
else if ((*it).Type == Sketcher::PointOnObject && !axis) {
axis = (((*it).GeoId == -1 && (*it).PosId == Sketcher::PointPos::none)
|| ((*it).GeoId == -2 && (*it).PosId == Sketcher::PointPos::none));
}
}

View File

@@ -669,7 +669,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
//Base::Console().Log("start dragging, point:%d\n",this->DragPoint);
Mode = STATUS_SELECT_Cross;
done = true;
} else if (preselection.PreselectConstraintSet.empty() != true) {
} else if (!preselection.PreselectConstraintSet.empty()) {
//Base::Console().Log("start dragging, point:%d\n",this->DragPoint);
Mode = STATUS_SELECT_Constraint;
done = true;
@@ -926,7 +926,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
return true;
} else if (preselection.isPreselectCurveValid()) {
return true;
} else if (preselection.PreselectConstraintSet.empty() != true) {
} else if (!preselection.PreselectConstraintSet.empty()) {
return true;
} else {
Gui::MenuItem geom;
@@ -1053,7 +1053,7 @@ void ViewProviderSketch::editDoubleClicked()
else if (preselection.isCrossPreselected()) {
Base::Console().Log("double click cross:%d\n",preselection.PreselectCross);
}
else if (preselection.PreselectConstraintSet.empty() != true) {
else if (!preselection.PreselectConstraintSet.empty()) {
// Find the constraint
const std::vector<Sketcher::Constraint *> &constrlist = getSketchObject()->Constraints.getValues();
@@ -1735,7 +1735,7 @@ void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg)
}
}
bool ViewProviderSketch::detectAndShowPreselection(SoPickedPoint *Point, const SbVec2s &cursorPos)
bool ViewProviderSketch::detectAndShowPreselection(SoPickedPoint * Point, const SbVec2s &cursorPos)
{
assert(isInEditMode());
@@ -1846,7 +1846,7 @@ bool ViewProviderSketch::detectAndShowPreselection(SoPickedPoint *Point, const S
&& result.ConstrIndices.empty())
&& (preselection.isPreselectPointValid() || preselection.isPreselectCurveValid()
|| preselection.isCrossPreselected()
|| preselection.PreselectConstraintSet.empty() != true
|| !preselection.PreselectConstraintSet.empty()
|| preselection.blockedPreselection)) {
// we have just left a preselection
resetPreselectPoint();
@@ -1859,8 +1859,8 @@ bool ViewProviderSketch::detectAndShowPreselection(SoPickedPoint *Point, const S
Point->getPoint()[2]);
}
else if (preselection.isPreselectCurveValid() || preselection.isPreselectPointValid()
|| preselection.PreselectConstraintSet.empty() != true
|| preselection.isCrossPreselected() || preselection.blockedPreselection) {
|| !preselection.PreselectConstraintSet.empty() || preselection.isCrossPreselected()
|| preselection.blockedPreselection) {
resetPreselectPoint();
preselection.blockedPreselection = false;
if (sketchHandler)