modernize C++: use bool literals

This commit is contained in:
wmayer
2023-08-06 01:35:39 +02:00
committed by wwmayer
parent 51a34d1fbd
commit 2a88c7c7df
25 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -614,7 +614,7 @@ PyObject* DocumentPy::getObject(PyObject *args)
PyErr_SetString(PyExc_TypeError, "a string or integer is required");
return nullptr;
}
while (0);
while (false);
if (obj)
return obj->getPyObject();
+1 -1
View File
@@ -2806,7 +2806,7 @@ void VariableExpression::addComponent(Component *c) {
var << ObjectIdentifier::RangeComponent(l1,l2,l3);
return;
}
}while(0);
}while(false);
Expression::addComponent(c);
}
+1 -1
View File
@@ -721,7 +721,7 @@ QStringList ExpressionCompleter::splitPath(const QString& input) const
int retry = 0;
std::string lastElem; // used to recover in case of parse failure after ".".
std::string trim; // used to delete ._self added for another recovery path
while (1) {
while (true) {
try {
// this will not work for incomplete Tokens at the end
// "Sketch." will fail to parse and complete.
+1 -1
View File
@@ -1011,7 +1011,7 @@ void SelectionSingleton::selStackGoForward(int count) {
}
std::deque<SelStackItem> tmpStack;
_SelStackForward.swap(tmpStack);
while(1) {
while(true) {
bool found = false;
for(auto &sobjT : _SelStackBack.back()) {
if(sobjT.getSubObject()) {
+1 -1
View File
@@ -5147,7 +5147,7 @@ App::DocumentObject* DocumentObjectItem::getRelativeParent(
auto subname2 = str2.str();
const char* sub = subname.c_str();
const char* sub2 = subname2.c_str();
while (1) {
while (true) {
const char* dot = strchr(sub, '.');
if (!dot) {
str.str("");
+1 -1
View File
@@ -524,7 +524,7 @@ void NaviCubeSettings::parameterChanged(const char* Name)
nc->setBorderWidth(hGrp->GetFloat("BorderWidth", 1.1));
}
else if (strcmp(Name, "ShowCS") == 0) {
nc->setShowCS(hGrp->GetBool("ShowCS", 1));
nc->setShowCS(hGrp->GetBool("ShowCS", true));
}
else if (strcmp(Name, "TextTop") == 0 || strcmp(Name, "TextBottom") == 0
|| strcmp(Name, "TextFront") == 0 || strcmp(Name, "TextRear") == 0
+3 -3
View File
@@ -609,7 +609,7 @@ public:
return false;
auto geoGroup = pcLinked->getObject();
auto sobj = geoGroup;
while(1) {
while(true) {
std::string objname = std::string(nextsub,dot-nextsub+1);
if(!geoGroup->getSubObject(objname.c_str())) {
// this object is not found under the geo group, abort.
@@ -1454,7 +1454,7 @@ bool LinkView::linkGetDetailPath(const char *subname, SoFullPath *path, SoDetail
if (subname[0]>='0' && subname[0]<='9') {
idx = App::LinkBaseExtension::getArrayIndex(subname,&subname);
} else {
while(1) {
while(true) {
const char *dot = strchr(subname,'.');
if(!dot)
break;
@@ -3077,7 +3077,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
// In case of multi-level linking, we recursively call into each level,
// and merge the colors
auto vp = this;
while(1) {
while(true) {
if(wildcard!=ViewProvider::hiddenMarker() && vp->OverrideMaterial.getValue()) {
auto color = ShapeMaterial.getValue().diffuseColor;
color.a = ShapeMaterial.getValue().transparency;
+1 -1
View File
@@ -582,7 +582,7 @@ Py::Object PyResource::value(const Py::Tuple& args)
item = Py::Float(v.toDouble());
break;
case QMetaType::Bool:
item = Py::Boolean(v.toBool() ? 1 : 0);
item = Py::Boolean(v.toBool());
break;
case QMetaType::UInt:
item = Py::Long(static_cast<unsigned long>(v.toUInt()));
@@ -97,7 +97,7 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
if (constraint_type == "Convection") {
ui->rb_convection->setChecked(1);
ui->rb_convection->setChecked(true);
ui->sw_heatflux->setCurrentIndex(0);
Base::Quantity t =
Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
@@ -107,7 +107,7 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
ui->if_filmcoef->setValue(f);
}
else if (constraint_type == "DFlux") {
ui->rb_dflux->setChecked(1);
ui->rb_dflux->setChecked(true);
ui->sw_heatflux->setCurrentIndex(1);
Base::Quantity c = Base::Quantity(pcConstraint->DFlux.getValue(), Base::Unit::HeatFlux);
ui->if_heatflux->setValue(c);
@@ -70,14 +70,14 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(
std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
if (constraint_type == "Temperature") {
ui->rb_temperature->setChecked(1);
ui->rb_temperature->setChecked(true);
ui->if_temperature->setValue(pcConstraint->Temperature.getQuantityValue());
ui->if_temperature->bind(pcConstraint->Temperature);
ui->if_temperature->setUnit(pcConstraint->Temperature.getUnit());
}
else if (constraint_type == "CFlux") {
ui->rb_cflux->setChecked(1);
ui->rb_cflux->setChecked(true);
std::string str = "Concentrated heat flux";
ui->if_temperature->setValue(pcConstraint->CFlux.getQuantityValue());
ui->if_temperature->bind(pcConstraint->CFlux);
@@ -98,13 +98,13 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(
std::string transform_type = pcConstraint->TransformType.getValueAsString();
if (transform_type == "Rectangular") {
ui->sw_transform->setCurrentIndex(0);
ui->rb_rect->setChecked(1);
ui->rb_cylin->setChecked(0);
ui->rb_rect->setChecked(true);
ui->rb_cylin->setChecked(false);
}
else if (transform_type == "Cylindrical") {
ui->sw_transform->setCurrentIndex(1);
ui->rb_rect->setChecked(0);
ui->rb_cylin->setChecked(1);
ui->rb_rect->setChecked(false);
ui->rb_cylin->setChecked(true);
}
ui->lw_Rect->clear();
@@ -734,7 +734,7 @@ bool ViewProviderFemPostObject::setupPipeline()
// Therefore the only way is the hack to filter only if the used Elmer CPU cores are > 1.
auto hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Fem/Elmer");
bool FilterMultiCPUResults = hGrp->GetBool("FilterMultiCPUResults", 1);
bool FilterMultiCPUResults = hGrp->GetBool("FilterMultiCPUResults", true);
int UseNumberOfCores = hGrp->GetInt("UseNumberOfCores", 1);
// filtering is only necessary for pipelines and warp filters
if (FilterMultiCPUResults && (UseNumberOfCores > 1)
+2 -2
View File
@@ -184,7 +184,7 @@ void ExportOCAF::createNode(App::Part* part, int& root_id,
{
TDF_Label shapeLabel = aShapeTool->NewShape();
Handle(TDataStd_Name) N;
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), 1));
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), true));
Base::Placement pl = part->Placement.getValue();
Base::Rotation rot(pl.getRotation());
@@ -241,7 +241,7 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
TDF_Label shapeLabel = aShapeTool->NewShape();
aShapeTool->SetShape(shapeLabel, baseShape);
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), 1));
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), true));
/*
+5 -5
View File
@@ -346,7 +346,7 @@ App::DocumentObject *ImportOCAF2::expandShape(
std::vector<App::DocumentObject*> objs;
if(shape.ShapeType() == TopAbs_COMPOUND) {
for(TopoDS_Iterator it(shape,0,0);it.More();it.Next()) {
for(TopoDS_Iterator it(shape,Standard_False,Standard_False);it.More();it.Next()) {
TDF_Label childLabel;
if(!label.IsNull())
aShapeTool->FindSubShape(label,it.Value(),childLabel);
@@ -671,7 +671,7 @@ void ImportOCAF2::getSHUOColors(TDF_Label label,
// appendFirst tells us whether we shall append the object name of the first label
bool skipFirst = !appendFirst;
ss.str("");
while(1) {
while(true) {
if(skipFirst)
skipFirst = false;
else {
@@ -798,7 +798,7 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
if(newDoc)
doc = getDocument(_doc,label);
for(TopoDS_Iterator it(shape,0,0);it.More();it.Next()) {
for(TopoDS_Iterator it(shape,Standard_False,Standard_False);it.More();it.Next()) {
TopoDS_Shape childShape = it.Value();
if(childShape.IsNull())
continue;
@@ -940,7 +940,7 @@ void ExportOCAF2::setName(TDF_Label label, App::DocumentObject *obj, const char
return;
name = obj->Label.getValue();
}
TDataStd_Name::Set(label, TCollection_ExtendedString(name, 1));
TDataStd_Name::Set(label, TCollection_ExtendedString(name, true));
}
// Similar to XCAFDoc_ShapeTool::FindSHUO but return only main SHUO, i.e. SHUO
@@ -1219,7 +1219,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
int depth = 0;
auto linked = obj;
auto linkedShape = shape;
while(1) {
while(true) {
auto s = Part::Feature::getTopoShape(linked);
if(s.isNull() || !s.getShape().IsPartner(shape.getShape()))
break;
@@ -644,7 +644,7 @@ void LscmRelax::rotate_by_min_bound_area()
double phi;
double min_phi = 0;
double min_area = 0;
bool x_dominant = 0;
bool x_dominant = false;
// rotate vector by 90 degree and find min area
for (int i = 0; i < n + 1; i++ )
{
+4 -4
View File
@@ -2598,7 +2598,7 @@ void GeomArcOfCircle::Restore(Base::XMLReader &reader)
GC_MakeCircle mc(xdir, Radius);
if (!mc.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(mc.Status()))
GC_MakeArcOfCircle ma(mc.Value()->Circ(), StartAngle, EndAngle, 1);
GC_MakeArcOfCircle ma(mc.Value()->Circ(), StartAngle, EndAngle, Standard_True);
if (!ma.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(ma.Status()))
@@ -3123,7 +3123,7 @@ void GeomArcOfEllipse::Restore(Base::XMLReader &reader)
if (!mc.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(mc.Status()))
GC_MakeArcOfEllipse ma(mc.Value()->Elips(), StartAngle, EndAngle, 1);
GC_MakeArcOfEllipse ma(mc.Value()->Elips(), StartAngle, EndAngle, Standard_True);
if (!ma.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(ma.Status()))
@@ -3549,7 +3549,7 @@ void GeomArcOfHyperbola::Restore(Base::XMLReader &reader)
if (!mc.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(mc.Status()))
GC_MakeArcOfHyperbola ma(mc.Value()->Hypr(), StartAngle, EndAngle, 1);
GC_MakeArcOfHyperbola ma(mc.Value()->Hypr(), StartAngle, EndAngle, Standard_True);
if (!ma.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(ma.Status()))
@@ -3901,7 +3901,7 @@ void GeomArcOfParabola::Restore(Base::XMLReader &reader)
if (!mc.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(mc.Status()))
GC_MakeArcOfParabola ma(mc.Value(), StartAngle, EndAngle, 1);
GC_MakeArcOfParabola ma(mc.Value(), StartAngle, EndAngle, Standard_True);
if (!ma.IsDone())
THROWM(Base::CADKernelError,gce_ErrorStatusText(ma.Status()))
+1 -1
View File
@@ -177,7 +177,7 @@ void FeatureExtrude::generatePrism(TopoDS_Shape& prism,
// see e.g. https://forum.freecad.org/viewtopic.php?p=560785#p560785
// It is better not to use BRepFeat_MakePrism here even if we have a support because the
// resulting shape creates problems with Pocket
BRepPrimAPI_MakePrism PrismMaker(from, Ltotal * gp_Vec(direction), 0, 1); // finite prism
BRepPrimAPI_MakePrism PrismMaker(from, Ltotal * gp_Vec(direction), Standard_False, Standard_True); // finite prism
if (!PrismMaker.IsDone())
throw Base::RuntimeError("ProfileBased: Length: Could not extrude the sketch!");
prism = PrismMaker.Shape();
+1 -1
View File
@@ -594,7 +594,7 @@ void Helix::proposeParameters(bool force)
Pitch.setValue(pitch);
Height.setValue(pitch * 3.0);
HasBeenEdited.setValue(1);
HasBeenEdited.setValue(true);
}
}
+3 -3
View File
@@ -1260,9 +1260,9 @@ void Hole::onChanged(const App::Property* prop)
CustomThreadClearance.setReadOnly(true);
ThreadDepth.setReadOnly(true);
ThreadDepthType.setReadOnly(true);
Threaded.setValue(0);
ModelThread.setValue(0);
UseCustomThreadClearance.setValue(0);
Threaded.setValue(false);
ModelThread.setValue(false);
UseCustomThreadClearance.setValue(false);
}
else if (type == "ISOMetricProfile") {
ThreadSize.setEnums(ThreadSize_ISOmetric_Enums);
+1 -1
View File
@@ -279,7 +279,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch)
return; // Sketch is on a face of a solid, do nothing
const App::Document* doc = sketch->getDocument();
PartDesign::Body *body = getBodyFor(sketch, /*messageIfNot*/ 0);
PartDesign::Body *body = getBodyFor(sketch, /*messageIfNot*/ false);
if (!body) {
throw Base::RuntimeError ("Couldn't find body for the sketch");
}
+1 -1
View File
@@ -2203,7 +2203,7 @@ TopoDS_Shape Area::toShape(const CCurve& _c, const gp_Trsf* trsf, int reorient)
double r = center.Distance(pt);
double r2 = center.Distance(pnext);
bool fix_arc = fabs(r - r2) > Precision::Confusion();
while (1) {
while (true) {
if (fix_arc) {
double d = pt.Distance(pnext);
double rr = r * r;
+3 -3
View File
@@ -1216,12 +1216,12 @@ const BaseGeomPtrVector DrawViewPart::getVisibleFaceEdges() const
bool DrawViewPart::handleFaces()
{
return Preferences::getPreferenceGroup("General")->GetBool("HandleFaces", 1l);
return Preferences::getPreferenceGroup("General")->GetBool("HandleFaces", true);
}
bool DrawViewPart::newFaceFinder(void)
{
return Preferences::getPreferenceGroup("General")->GetBool("NewFaceFinder", 0l);
return Preferences::getPreferenceGroup("General")->GetBool("NewFaceFinder", false);
}
//! remove features that are useless without this DVP
@@ -1699,7 +1699,7 @@ bool DrawViewPart::prefIsoHid()
int DrawViewPart::prefIsoCount()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("IsoCount", 0);
return Preferences::getPreferenceGroup("HLR")->GetBool("IsoCount", false);
}
// Python Drawing feature ---------------------------------------------------------
+1 -1
View File
@@ -1280,7 +1280,7 @@ void QGIViewPart::rotateView() {}
bool QGIViewPart::prefFaceEdges()
{
bool result = false;
result = Preferences::getPreferenceGroup("General")->GetBool("DrawFaceEdges", 0l);
result = Preferences::getPreferenceGroup("General")->GetBool("DrawFaceEdges", false);
return result;
}
+2 -2
View File
@@ -122,8 +122,8 @@ public:
}
void init()
{
page->m_atCursor = hGrp->GetBool("ZoomAtCursor", 1l);
page->m_invertZoom = hGrp->GetBool("InvertZoom", 0l);
page->m_atCursor = hGrp->GetBool("ZoomAtCursor", true);
page->m_invertZoom = hGrp->GetBool("InvertZoom", false);
page->m_zoomIncrement = hGrp->GetFloat("ZoomStep", 0.02);
page->m_reversePan = Preferences::getPreferenceGroup("General")->GetInt("KbPan", 1);
+2 -2
View File
@@ -100,7 +100,7 @@ void TaskLineDecor::getDefaults()
m_style = LineFormat::getDefEdgeStyle();
m_color = LineFormat::getDefEdgeColor();
m_weight = LineFormat::getDefEdgeWidth();
m_visible = 1;
m_visible = true;
//set defaults to format of 1st edge
if (!m_edges.empty()) {
@@ -136,7 +136,7 @@ void TaskLineDecor::getDefaults()
m_weight = partVP->LineWidth.getValue();
m_style = Qt::SolidLine; // = 1
m_color = LineFormat::getDefEdgeColor();
m_visible = 1;
m_visible = true;
}
}
}