From 858b1d08b7e1320af76c8789fd5c32d13f8faad2 Mon Sep 17 00:00:00 2001 From: vosk Date: Tue, 16 Feb 2021 21:44:53 +0200 Subject: [PATCH] [Base] - Eliminate PropertyType and typeless "attr" for Property --- src/App/CMakeLists.txt | 3 + src/App/Document.cpp | 46 +-- src/App/DocumentObject.cpp | 95 ++++--- src/App/DocumentObject.h | 55 ++-- src/App/DocumentObjectFileIncluded.cpp | 2 +- src/App/DocumentObjectGroup.cpp | 2 +- src/App/DocumentObjectPyImp.cpp | 47 ++-- src/App/DocumentObserver.cpp | 2 +- src/App/DocumentObserverPython.cpp | 66 ++--- src/App/DynamicProperty.cpp | 163 +++-------- src/App/DynamicProperty.h | 86 ++---- src/App/Extension.cpp | 40 +-- src/App/Extension.h | 23 +- src/App/ExtensionContainer.cpp | 110 +------- src/App/ExtensionContainer.h | 20 +- src/App/FeaturePython.cpp | 14 +- src/App/FeatureTest.cpp | 2 +- src/App/GeoFeature.cpp | 18 +- src/App/GeoFeatureGroupExtension.cpp | 90 +++--- src/App/GeoFeaturePyImp.cpp | 11 +- src/App/GroupExtension.cpp | 52 ++-- src/App/LegacyPropertyStatus.h | 70 +++++ src/App/Link.cpp | 97 +++---- src/App/Link.h | 2 +- src/App/LinkBaseExtensionPyImp.cpp | 7 +- src/App/MeasureDistance.cpp | 2 +- src/App/ObjectIdentifier.cpp | 2 +- src/App/Origin.cpp | 4 +- src/App/OriginFeature.cpp | 4 +- src/App/OriginGroupExtension.cpp | 2 +- src/App/Part.cpp | 12 +- src/App/Property.cpp | 101 ++----- src/App/Property.h | 178 +++++------- src/App/PropertyContainer.cpp | 261 ++++-------------- src/App/PropertyContainer.h | 100 ++----- src/App/PropertyContainerPyImp.cpp | 74 +++-- src/App/PropertyExpressionEngine.cpp | 54 ++-- src/App/PropertyFile.cpp | 12 +- src/App/PropertyGeo.cpp | 10 +- src/App/PropertyLinks.cpp | 2 +- src/App/PropertyStandard.cpp | 4 +- src/App/StatusCollection.h | 69 +++++ src/App/StatusContainer.h | 65 +++++ src/App/TextDocument.cpp | 2 +- src/App/Transactions.cpp | 85 +++--- src/App/Transactions.h | 5 +- src/App/VRMLObject.cpp | 4 +- src/Base/Writer.cpp | 5 +- src/Base/Writer.h | 4 +- src/Gui/CallTips.cpp | 2 +- src/Gui/DAGView/DAGModel.cpp | 234 ++++++++-------- src/Gui/DlgDisplayPropertiesImp.cpp | 11 +- src/Gui/Document.cpp | 5 +- src/Gui/DocumentObserverPython.cpp | 16 +- src/Gui/ExpressionBinding.cpp | 2 +- src/Gui/ExpressionCompleter.cpp | 4 +- src/Gui/Placement.cpp | 6 +- src/Gui/PropertyView.cpp | 6 +- src/Gui/QuantitySpinBox.cpp | 2 +- src/Gui/SelectionView.cpp | 5 +- src/Gui/TaskView/TaskAppearance.cpp | 4 +- src/Gui/Tree.cpp | 6 +- src/Gui/ViewProviderAnnotation.cpp | 10 +- src/Gui/ViewProviderDocumentObject.cpp | 42 +-- src/Gui/ViewProviderDocumentObject.h | 10 +- src/Gui/ViewProviderDragger.cpp | 2 +- src/Gui/ViewProviderGroupExtension.cpp | 2 +- src/Gui/ViewProviderInventorObject.cpp | 2 +- src/Gui/ViewProviderLink.cpp | 48 ++-- src/Gui/ViewProviderLink.h | 2 +- src/Gui/ViewProviderMeasureDistance.cpp | 4 +- src/Gui/ViewProviderOrigin.cpp | 4 +- src/Gui/ViewProviderOriginFeature.cpp | 4 +- src/Gui/ViewProviderPyImp.cpp | 21 +- src/Gui/ViewProviderPythonFeature.cpp | 20 +- src/Gui/ViewProviderTextDocument.cpp | 8 +- src/Gui/ViewProviderVRMLObject.cpp | 2 +- src/Gui/propertyeditor/PropertyEditor.cpp | 39 ++- src/Gui/propertyeditor/PropertyItem.cpp | 14 +- src/Gui/propertyeditor/PropertyItem.h | 26 +- src/Gui/propertyeditor/PropertyModel.cpp | 16 +- src/Mod/Drawing/App/FeatureClip.cpp | 10 +- src/Mod/Drawing/App/FeaturePage.cpp | 4 +- src/Mod/Drawing/App/FeatureView.cpp | 8 +- src/Mod/Drawing/Gui/ViewProviderPage.cpp | 4 +- src/Mod/Drawing/Gui/ViewProviderView.cpp | 4 +- src/Mod/Fem/App/FemAnalysis.cpp | 2 +- src/Mod/Fem/App/FemConstraint.cpp | 6 +- src/Mod/Fem/App/FemConstraintBearing.cpp | 6 +- src/Mod/Fem/App/FemConstraintContact.cpp | 4 +- src/Mod/Fem/App/FemConstraintDisplacement.cpp | 4 +- src/Mod/Fem/App/FemConstraintFixed.cpp | 4 +- .../Fem/App/FemConstraintFluidBoundary.cpp | 30 +- src/Mod/Fem/App/FemConstraintForce.cpp | 6 +- src/Mod/Fem/App/FemConstraintGear.cpp | 4 +- src/Mod/Fem/App/FemConstraintHeatflux.cpp | 6 +- .../App/FemConstraintInitialTemperature.cpp | 8 +- .../Fem/App/FemConstraintPlaneRotation.cpp | 4 +- src/Mod/Fem/App/FemConstraintPressure.cpp | 4 +- src/Mod/Fem/App/FemConstraintPulley.cpp | 6 +- src/Mod/Fem/App/FemConstraintTemperature.cpp | 6 +- src/Mod/Fem/App/FemConstraintTransform.cpp | 16 +- src/Mod/Fem/App/FemPostFilter.cpp | 12 +- src/Mod/Fem/App/FemResultObject.cpp | 6 +- .../Gui/ViewProviderFemConstraintBearing.cpp | 6 +- .../Gui/ViewProviderFemConstraintContact.cpp | 2 +- .../ViewProviderFemConstraintDisplacement.cpp | 2 +- .../Gui/ViewProviderFemConstraintFixed.cpp | 2 +- ...ViewProviderFemConstraintFluidBoundary.cpp | 8 +- .../Gui/ViewProviderFemConstraintForce.cpp | 4 +- .../Fem/Gui/ViewProviderFemConstraintGear.cpp | 6 +- .../Gui/ViewProviderFemConstraintHeatflux.cpp | 2 +- ...ViewProviderFemConstraintPlaneRotation.cpp | 2 +- .../Gui/ViewProviderFemConstraintPressure.cpp | 2 +- .../Gui/ViewProviderFemConstraintPulley.cpp | 8 +- .../ViewProviderFemConstraintTemperature.cpp | 2 +- .../ViewProviderFemConstraintTransform.cpp | 2 +- .../Fem/Gui/ViewProviderFemPostFunction.cpp | 10 +- src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp | 2 +- .../Fem/Gui/ViewProviderFemPostPipeline.cpp | 2 +- .../Inspection/Gui/ViewProviderInspection.cpp | 16 +- src/Mod/Mesh/App/MeshFeature.cpp | 4 +- src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp | 34 +-- src/Mod/Mesh/Gui/MeshEditor.cpp | 10 +- src/Mod/Mesh/Gui/ViewProvider.cpp | 6 +- src/Mod/Part/App/AttachExtension.cpp | 29 +- src/Mod/Part/App/FeatureCompound.cpp | 2 +- src/Mod/Part/App/FeatureOffset.cpp | 2 +- src/Mod/Part/App/FeaturePartBoolean.cpp | 6 +- src/Mod/Part/App/FeaturePartBox.cpp | 29 +- src/Mod/Part/App/FeaturePartCommon.cpp | 6 +- src/Mod/Part/App/FeaturePartFuse.cpp | 6 +- src/Mod/Part/App/FeatureRevolution.cpp | 4 +- src/Mod/Part/App/PartFeature.cpp | 11 +- src/Mod/Part/App/PrimitiveFeature.cpp | 2 +- src/Mod/Part/Gui/ViewProvider2DObject.cpp | 16 +- src/Mod/Part/Gui/ViewProviderExt.cpp | 4 +- src/Mod/Part/Gui/ViewProviderSpline.cpp | 4 +- src/Mod/PartDesign/App/Body.cpp | 4 +- src/Mod/PartDesign/App/DatumLine.cpp | 6 +- src/Mod/PartDesign/App/DatumPlane.cpp | 12 +- src/Mod/PartDesign/App/Feature.cpp | 8 +- src/Mod/PartDesign/App/FeatureAddSub.cpp | 2 +- src/Mod/PartDesign/App/FeatureBase.cpp | 4 +- src/Mod/PartDesign/App/FeatureBoolean.cpp | 4 +- src/Mod/PartDesign/App/FeatureChamfer.cpp | 2 +- src/Mod/PartDesign/App/FeatureDraft.cpp | 4 +- src/Mod/PartDesign/App/FeatureDressUp.cpp | 6 +- src/Mod/PartDesign/App/FeatureGroove.cpp | 2 +- src/Mod/PartDesign/App/FeatureHole.cpp | 244 ++++++++-------- .../PartDesign/App/FeatureLinearPattern.cpp | 2 +- src/Mod/PartDesign/App/FeatureMirrored.cpp | 2 +- .../PartDesign/App/FeaturePolarPattern.cpp | 2 +- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 4 +- src/Mod/PartDesign/App/FeatureTransformed.cpp | 4 +- src/Mod/PartDesign/App/ShapeBinder.cpp | 15 +- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 6 +- src/Mod/PartDesign/Gui/TaskHoleParameters.cpp | 54 ++-- src/Mod/PartDesign/Gui/ViewProvider.cpp | 4 +- src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp | 6 +- src/Mod/PartDesign/Gui/ViewProviderBase.cpp | 18 +- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 10 +- src/Mod/PartDesign/Gui/ViewProviderDatum.cpp | 2 +- .../PartDesign/Gui/ViewProviderDatumCS.cpp | 6 +- .../PartDesign/Gui/ViewProviderDatumLine.cpp | 4 +- .../PartDesign/Gui/ViewProviderDatumPlane.cpp | 6 +- .../PartDesign/Gui/ViewProviderDatumPoint.cpp | 2 +- .../Gui/ViewProviderShapeBinder.cpp | 30 +- src/Mod/Path/App/ParamsHelper.h | 4 +- src/Mod/Path/Gui/ViewProviderPath.cpp | 2 +- src/Mod/Points/App/Structured.cpp | 6 +- src/Mod/Raytracing/App/RaySegment.cpp | 5 +- src/Mod/Sketcher/App/SketchObject.cpp | 8 +- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 3 +- src/Mod/Sketcher/App/SketchObjectSF.cpp | 2 +- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 16 +- src/Mod/Spreadsheet/App/PropertySheet.cpp | 2 +- src/Mod/Spreadsheet/App/Sheet.cpp | 51 ++-- src/Mod/Spreadsheet/App/SheetObserver.cpp | 7 +- src/Mod/TechDraw/App/DrawGeomHatch.cpp | 10 +- src/Mod/TechDraw/App/DrawHatch.cpp | 4 +- src/Mod/TechDraw/App/DrawLeaderLine.cpp | 18 +- src/Mod/TechDraw/App/DrawPage.cpp | 10 +- .../TechDraw/App/DrawParametricTemplate.cpp | 2 +- .../App/DrawParametricTemplatePyImp.cpp | 3 +- src/Mod/TechDraw/App/DrawProjGroup.cpp | 10 +- src/Mod/TechDraw/App/DrawProjGroupItem.cpp | 16 +- src/Mod/TechDraw/App/DrawRichAnno.cpp | 10 +- src/Mod/TechDraw/App/DrawSVGTemplate.cpp | 6 +- src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp | 3 +- src/Mod/TechDraw/App/DrawTemplate.cpp | 6 +- src/Mod/TechDraw/App/DrawTemplatePyImp.cpp | 3 +- src/Mod/TechDraw/App/DrawTile.cpp | 4 +- src/Mod/TechDraw/App/DrawTileWeld.cpp | 6 +- src/Mod/TechDraw/App/DrawView.cpp | 28 +- src/Mod/TechDraw/App/DrawViewAnnotation.cpp | 6 +- src/Mod/TechDraw/App/DrawViewBalloon.cpp | 48 ++-- src/Mod/TechDraw/App/DrawViewClip.cpp | 8 +- src/Mod/TechDraw/App/DrawViewDetail.cpp | 12 +- src/Mod/TechDraw/App/DrawViewDimExtent.cpp | 6 +- src/Mod/TechDraw/App/DrawViewDimension.cpp | 52 ++-- src/Mod/TechDraw/App/DrawViewMulti.cpp | 4 +- src/Mod/TechDraw/App/DrawViewSection.cpp | 24 +- src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp | 2 +- src/Mod/TechDraw/App/DrawViewSymbol.cpp | 2 +- src/Mod/TechDraw/App/DrawWeldSymbol.cpp | 10 +- src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp | 6 +- .../TechDraw/Gui/ViewProviderDimension.cpp | 9 +- .../TechDraw/Gui/ViewProviderDrawingView.cpp | 6 +- src/Mod/TechDraw/Gui/ViewProviderLeader.cpp | 8 +- src/Mod/TechDraw/Gui/ViewProviderPage.cpp | 6 +- src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp | 16 +- src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp | 6 +- src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderWeld.cpp | 4 +- src/Mod/Test/Document.py | 8 + 216 files changed, 1854 insertions(+), 2291 deletions(-) create mode 100644 src/App/LegacyPropertyStatus.h create mode 100644 src/App/StatusCollection.h create mode 100644 src/App/StatusContainer.h diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index d97f8cd8d791..f65d6b8102c0 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -233,6 +233,9 @@ SET(Properties_HPP_SRCS DynamicProperty.h ObjectIdentifier.h Property.h + LegacyPropertyStatus.h + StatusCollection.h + StatusContainer.h PropertyContainer.h PropertyFile.h PropertyGeo.h diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 3c9cfc041bd8..4b2c47ffb8c8 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1162,7 +1162,7 @@ void Document::_checkTransaction(DocumentObject* pcDelObj, const Property *What, const char *name = GetApplication().getActiveTransaction(&tid); if(name && tid>0) { bool ignore = false; - if(What && What->testStatus(Property::NoModify)) + if(What && What->testStatus(App::PropertyStatus::NoModify)) ignore = true; if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) { if(What) @@ -1549,24 +1549,24 @@ Document::Document(const char *name) ("User parameter:BaseApp/Preferences/Document")->GetASCII("prefAuthor",""); std::string AuthorComp = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetASCII("prefCompany",""); - ADD_PROPERTY_TYPE(Label,("Unnamed"),0,Prop_None,"The name of the document"); - ADD_PROPERTY_TYPE(FileName,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly),"The path to the file where the document is saved to"); - ADD_PROPERTY_TYPE(CreatedBy,(Author.c_str()),0,Prop_None,"The creator of the document"); - ADD_PROPERTY_TYPE(CreationDate,(CreationDateString.c_str()),0,Prop_ReadOnly,"Date of creation"); - ADD_PROPERTY_TYPE(LastModifiedBy,(""),0,Prop_None,0); - ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),0,Prop_ReadOnly,"Date of last modification"); - ADD_PROPERTY_TYPE(Company,(AuthorComp.c_str()),0,Prop_None,"Additional tag to save the name of the company"); - ADD_PROPERTY_TYPE(Comment,(""),0,Prop_None,"Additional tag to save a comment"); - ADD_PROPERTY_TYPE(Meta,(),0,Prop_None,"Map with additional meta information"); - ADD_PROPERTY_TYPE(Material,(),0,Prop_None,"Map with material properties"); + ADD_PROPERTY_TYPE(Label,("Unnamed"),"",Prop_None,"The name of the document"); + ADD_PROPERTY_TYPE(FileName,(""),"",Prop_Transient+Prop_ReadOnly,"The path to the file where the document is saved to"); + ADD_PROPERTY_TYPE(CreatedBy,(Author.c_str()),"",Prop_None,"The creator of the document"); + ADD_PROPERTY_TYPE(CreationDate,(CreationDateString.c_str()),"",Prop_ReadOnly,"Date of creation"); + ADD_PROPERTY_TYPE(LastModifiedBy,(""),"",Prop_None,""); + ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),"",Prop_ReadOnly,"Date of last modification"); + ADD_PROPERTY_TYPE(Company,(AuthorComp.c_str()),"",Prop_None,"Additional tag to save the name of the company"); + ADD_PROPERTY_TYPE(Comment,(""),"", Prop_None,"Additional tag to save a comment"); + ADD_PROPERTY_TYPE(Meta,(),"", Prop_None,"Map with additional meta information"); + ADD_PROPERTY_TYPE(Material,(),"", Prop_None,"Map with material properties"); // create the uuid for the document Base::Uuid id; - ADD_PROPERTY_TYPE(Id,(""),0,Prop_None,"ID of the document"); - ADD_PROPERTY_TYPE(Uid,(id),0,Prop_ReadOnly,"UUID of the document"); + ADD_PROPERTY_TYPE(Id,(""),"",Prop_None,"ID of the document"); + ADD_PROPERTY_TYPE(Uid,(id),"",Prop_ReadOnly,"UUID of the document"); // license stuff - ADD_PROPERTY_TYPE(License,("CC-BY 3.0"),0,Prop_None,"License string of the Item"); - ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),0,Prop_None,"URL to the license text/contract"); + ADD_PROPERTY_TYPE(License,("CC-BY 3.0"),"",Prop_None,"License string of the Item"); + ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),"", Prop_None,"URL to the license text/contract"); // license stuff int licenseId = App::GetApplication().GetParameterGroupByPath @@ -1618,17 +1618,17 @@ Document::Document(const char *name) licenseUrl = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetASCII("prefLicenseUrl", licenseUrl.c_str()); - ADD_PROPERTY_TYPE(License,(license.c_str()),0,Prop_None,"License string of the Item"); - ADD_PROPERTY_TYPE(LicenseURL,(licenseUrl.c_str()),0,Prop_None,"URL to the license text/contract"); - ADD_PROPERTY_TYPE(ShowHidden,(false), 0,PropertyType(Prop_None), + ADD_PROPERTY_TYPE(License,(license.c_str()),"",Prop_None,"License string of the Item"); + ADD_PROPERTY_TYPE(LicenseURL,(licenseUrl.c_str()),"",Prop_None,"URL to the license text/contract"); + ADD_PROPERTY_TYPE(ShowHidden,(false), "",Prop_None, "Whether to show hidden object items in the tree view"); // this creates and sets 'TransientDir' in onChanged() - ADD_PROPERTY_TYPE(TransientDir,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly), + ADD_PROPERTY_TYPE(TransientDir,(""),"",Prop_Transient+Prop_ReadOnly, "Transient directory, where the files live while the document is open"); - ADD_PROPERTY_TYPE(Tip,(0),0,PropertyType(Prop_Transient), + ADD_PROPERTY_TYPE(Tip,(0),"",Prop_Transient, "Link of the tip object of the document"); - ADD_PROPERTY_TYPE(TipName,(""),0,PropertyType(Prop_Hidden|Prop_ReadOnly), + ADD_PROPERTY_TYPE(TipName,(""),"",Prop_Hidden+Prop_ReadOnly, "Link of the tip object of the document"); Uid.touch(); } @@ -4384,8 +4384,8 @@ Document::importLinks(const std::vector &objArray) propList.clear(); obj->getPropertyList(propList); for(auto prop : propList) { - auto linkProp = Base::freecad_dynamic_cast(prop); - if(linkProp && !prop->testStatus(Property::Immutable) && !obj->isReadOnly(prop)) { + auto *linkProp = Base::freecad_dynamic_cast(prop); + if(linkProp && !prop->testStatus(Immutable) && !prop->testStatus(Prop_ReadOnly)) { auto copy = linkProp->CopyOnImportExternal(nameMap); if(copy) propMap[linkProp].reset(copy); diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index fe929c315243..d455470480a5 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -66,18 +66,17 @@ DocumentObject::DocumentObject(void) { // define Label of type 'Output' to avoid being marked as touched after relabeling ADD_PROPERTY_TYPE(Label,("Unnamed"),"Base",Prop_Output,"User name of the object (UTF8)"); - ADD_PROPERTY_TYPE(Label2,(""),"Base",Prop_Hidden,"User description of the object (UTF8)"); - Label2.setStatus(App::Property::Output,true); + ADD_PROPERTY_TYPE(Label2,(""),"Base",Prop_Hidden+Output,"User description of the object (UTF8)"); ADD_PROPERTY_TYPE(ExpressionEngine,(),"Base",Prop_Hidden,"Property expressions"); ADD_PROPERTY(Visibility, (true)); // default set Visibility status to hidden and output (no touch) for - // compatibitily reason. We use setStatus instead of PropertyType to + // compatibitily reason. We use setStatus instead of PropertyType to // allow user to change its status later - Visibility.setStatus(Property::Output,true); - Visibility.setStatus(Property::Hidden,true); - Visibility.setStatus(Property::NoModify,true); + Visibility.setStatus(Output,true); + Visibility.setStatus(Hidden,true); + Visibility.setStatus(NoModify,true); } DocumentObject::~DocumentObject(void) @@ -143,6 +142,12 @@ App::DocumentObjectExecReturn* DocumentObject::executeExtensions() return StdReturn; } +void DocumentObject::onStatusChanged(const ObjectStatus& pos, bool newValue) +{ + (void)newValue; + (void)pos; +} + bool DocumentObject::recomputeFeature(bool recursive) { Document* doc = this->getDocument(); @@ -161,8 +166,8 @@ bool DocumentObject::recomputeFeature(bool recursive) void DocumentObject::touch(bool noRecompute) { if(!noRecompute) - StatusBits.set(ObjectStatus::Enforce); - StatusBits.set(ObjectStatus::Touch); + setStatus(ObjectStatus::Enforce); + setStatus(ObjectStatus::Touch); if (_pDoc) _pDoc->signalTouchedObject(*this); } @@ -173,7 +178,7 @@ void DocumentObject::touch(bool noRecompute) */ bool DocumentObject::isTouched() const { - return ExpressionEngine.isTouched() || StatusBits.test(ObjectStatus::Touch); + return ExpressionEngine.isTouched() || testStatus(ObjectStatus::Touch); } /** @@ -194,7 +199,7 @@ void DocumentObject::enforceRecompute(void) */ bool DocumentObject::mustRecompute(void) const { - if (StatusBits.test(ObjectStatus::Enforce)) + if (testStatus(ObjectStatus::Enforce)) return true; return mustExecute() > 0; @@ -410,7 +415,7 @@ std::vector DocumentObject::getInListRecursive(void) const // More efficient algorithm to find the recursive inList of an object, // including possible external parents. One shortcoming of this algorithm is // it does not detect cyclic reference, althgouth it won't crash either. -void DocumentObject::getInListEx(std::set &inSet, +void DocumentObject::getInListEx(std::set &inSet, bool recursive, std::vector *inList) const { #ifdef USE_OLD_DAG @@ -438,7 +443,7 @@ void DocumentObject::getInListEx(std::set &inSet, auto &outList = v.second; // Check the outList to see if the object is there, and pend the // object for recursive check if it's not already in the inList - if(outList.find(obj)!=outList.end() && + if(outList.find(obj)!=outList.end() && inSet.insert(v.first).second && recursive) { @@ -658,13 +663,13 @@ void DocumentObject::setDocument(App::Document* doc) onSettingDocument(); } -bool DocumentObject::removeDynamicProperty(const char* name) +bool DocumentObject::removeDynamicProperty(const std::string& name) { - if (!_pDoc) + if (!_pDoc) return false; Property* prop = getDynamicPropertyByName(name); - if(!prop || prop->testStatus(App::Property::LockDynamic)) + if(!prop || prop->testStatus(LockDynamic)) return false; if(prop->isDerivedFrom(PropertyLinkBase::getClassTypeId())) @@ -689,10 +694,9 @@ bool DocumentObject::removeDynamicProperty(const char* name) } App::Property* DocumentObject::addDynamicProperty( - const char* type, const char* name, const char* group, const char* doc, - short attr, bool ro, bool hidden) + const std::string& type, const std::string& name, const std::string& group, const std::string& doc) { - auto prop = TransactionalObject::addDynamicProperty(type,name,group,doc,attr,ro,hidden); + auto *prop = TransactionalObject::addDynamicProperty(type,name,group,doc); if(prop && _pDoc) _pDoc->addOrRemovePropertyOfObject(this, prop, true); return prop; @@ -717,9 +721,9 @@ void DocumentObject::onChanged(const Property* prop) if(GetApplication().isClosingAll()) return; - if(!GetApplication().isRestoring() && - !prop->testStatus(Property::PartialTrigger) && - getDocument() && + if(!GetApplication().isRestoring() && + !prop->testStatus(PartialTrigger) && + getDocument() && getDocument()->testStatus(Document::PartialDoc)) { static App::Document *warnedDoc; @@ -739,17 +743,17 @@ void DocumentObject::onChanged(const Property* prop) _pDoc->signalRelabelObject(*this); // set object touched if it is an input property - if (!testStatus(ObjectStatus::NoTouch) - && !(prop->getType() & Prop_Output) - && !prop->testStatus(Property::Output)) + if (!testStatus(ObjectStatus::NoTouch) + && !prop->testStatus(Prop_Output) + && !prop->testStatus(Output)) { - if(!StatusBits.test(ObjectStatus::Touch)) { + if(!testStatus(ObjectStatus::Touch)) { FC_TRACE("touch '" << getFullName() << "' on change of '" << prop->getName() << "'"); - StatusBits.set(ObjectStatus::Touch); + setStatus(ObjectStatus::Touch); } // must execute on document recompute - if (!(prop->getType() & Prop_NoRecompute)) - StatusBits.set(ObjectStatus::Enforce); + if (!prop->testStatus(Prop_NoRecompute)) + setStatus(ObjectStatus::Enforce); } //call the parent for appropriate handling @@ -863,7 +867,7 @@ std::vector > DocumentObject::getPa for(auto parent : getInList()) { if(!parent || !parent->getNameInDocument()) continue; - if(!parent->hasChildElement() && + if(!parent->hasChildElement() && !parent->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId())) continue; if(!parent->getSubObject(name.c_str())) @@ -873,9 +877,9 @@ std::vector > DocumentObject::getPa links.insert(parent); for(auto parent : links) { auto parents = parent->getParents(depth+1); - if(parents.empty()) + if(parents.empty()) parents.emplace_back(parent,std::string()); - for(auto &v : parents) + for(auto &v : parents) ret.emplace_back(v.first,v.second+name); } } @@ -883,7 +887,7 @@ std::vector > DocumentObject::getPa } DocumentObject *DocumentObject::getLinkedObject( - bool recursive, Base::Matrix4D *mat, bool transform, int depth) const + bool recursive, Base::Matrix4D *mat, bool transform, int depth) const { DocumentObject *ret = 0; auto exts = getExtensionsDerivedFromType(); @@ -949,10 +953,10 @@ void DocumentObject::onDocumentRestored() { //call all extensions auto vector = getExtensionsDerivedFromType(); - for(auto ext : vector) + for(auto *ext : vector) ext->onExtendedDocumentRestored(); - if(Visibility.testStatus(Property::Output)) - Visibility.setStatus(Property::NoModify,true); + if(Visibility.testStatus(Output)) + Visibility.setStatus(NoModify,true); } void DocumentObject::onUndoRedoFinished() @@ -1002,12 +1006,12 @@ void App::DocumentObject::_addBackLink(DocumentObject* newObj) #ifndef USE_OLD_DAG //we need to add all links, even if they are available multiple times. The reason for this is the //removal: If a link loses this object it removes the backlink. If we would have added it only once - //this removal would clear the object from the inlist, even though there may be other link properties + //this removal would clear the object from the inlist, even though there may be other link properties //from this object that link to us. _inList.push_back(newObj); #else (void)newObj; -#endif //USE_OLD_DAG +#endif //USE_OLD_DAG } int DocumentObject::setElementVisible(const char *element, bool visible) { @@ -1036,8 +1040,8 @@ bool DocumentObject::hasChildElement() const { return false; } -DocumentObject *DocumentObject::resolve(const char *subname, - App::DocumentObject **parent, std::string *childName, const char **subElement, +DocumentObject *DocumentObject::resolve(const char *subname, + App::DocumentObject **parent, std::string *childName, const char **subElement, PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const { auto self = const_cast(this); @@ -1058,7 +1062,7 @@ DocumentObject *DocumentObject::resolve(const char *subname, const char *dot=0; if(Data::ComplexGeoData::isMappedElement(subname) || !(dot=strrchr(subname,'.')) || - dot == subname) + dot == subname) { if(subElement) *subElement = dot?dot+1:subname; @@ -1081,7 +1085,7 @@ DocumentObject *DocumentObject::resolve(const char *subname, const char *sub = dot==subname?dot:dot+1; if(Data::ComplexGeoData::isMappedElement(sub)) { lastDot = dot; - if(dot==subname) + if(dot==subname) break; else continue; @@ -1138,7 +1142,7 @@ DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname, subcheck += '.'; if(getSubObject(subcheck.c_str())==link) { ret = getSubObject(std::string(sub,dot+1-sub).c_str()); - if(!ret) + if(!ret) return 0; subname = std::string(dot+1); break; @@ -1227,8 +1231,9 @@ bool DocumentObject::redirectSubName(std::ostringstream &, DocumentObject *, Doc return false; } -void DocumentObject::onPropertyStatusChanged(const Property &prop, unsigned long oldStatus) { - (void)oldStatus; - if(!Document::isAnyRestoring() && getNameInDocument() && getDocument()) +void DocumentObject::onPropertyStatusChanged(const Property &prop, const App::PropertyStatus& status) { + (void)status; + if(!Document::isAnyRestoring() && getNameInDocument() && getDocument() + && (status == PropertyStatus::ReadOnly || status == PropertyStatus::Hidden)) getDocument()->signalChangePropertyEditor(*getDocument(),prop); } diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index b4b166075f35..d1107df46400 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -92,7 +92,7 @@ class AppExport DocumentObjectExecReturn /** Base class of all Classes handled in the Document */ -class AppExport DocumentObject: public App::TransactionalObject +class AppExport DocumentObject: public App::TransactionalObject, public App::StatusContainer { PROPERTY_HEADER_WITH_OVERRIDE(App::DocumentObject); @@ -157,25 +157,21 @@ class AppExport DocumentObject: public App::TransactionalObject bool mustRecompute(void) const; /// reset this document object touched void purgeTouched(void) { - StatusBits.reset(ObjectStatus::Touch); - StatusBits.reset(ObjectStatus::Enforce); - setPropertyStatus(0,false); + setStatus(ObjectStatus::Touch, false); + setStatus(ObjectStatus::Enforce, false); + setPropertyStatus(Touched,false); } /// set this feature to error - bool isError(void) const {return StatusBits.test(ObjectStatus::Error);} - bool isValid(void) const {return !StatusBits.test(ObjectStatus::Error);} + bool isError(void) const {return testStatus(ObjectStatus::Error);} + bool isValid(void) const {return !testStatus(ObjectStatus::Error);} /// remove the error from the object - void purgeError(void){StatusBits.reset(ObjectStatus::Error);} + void purgeError(void){setStatus(ObjectStatus::Error, false);} /// returns true if this objects is currently recomputing - bool isRecomputing() const {return StatusBits.test(ObjectStatus::Recompute);} + bool isRecomputing() const {return testStatus(ObjectStatus::Recompute);} /// returns true if this objects is currently restoring from file - bool isRestoring() const {return StatusBits.test(ObjectStatus::Restore);} + bool isRestoring() const {return testStatus(ObjectStatus::Restore);} /// returns true if this objects is currently removed from the document - bool isRemoving() const {return StatusBits.test(ObjectStatus::Remove);} - /// return the status bits - unsigned long getStatus() const {return StatusBits.to_ulong();} - bool testStatus(ObjectStatus pos) const {return StatusBits.test((size_t)pos);} - void setStatus(ObjectStatus pos, bool on) {StatusBits.set((size_t)pos, on);} + bool isRemoving() const {return testStatus(ObjectStatus::Remove);} //@} int isExporting() const; @@ -434,12 +430,12 @@ class AppExport DocumentObject: public App::TransactionalObject return _pcViewProviderName.c_str(); } - virtual bool removeDynamicProperty(const char* prop) override; + virtual bool removeDynamicProperty(const std::string& prop) override; virtual App::Property* addDynamicProperty( - const char* type, const char* name=0, - const char* group=0, const char* doc=0, - short attr=0, bool ro=false, bool hidden=false) override; + const std::string& type, const std::string& name, + const std::string& group = std::string(), const std::string& doc = std::string() + ) override; /** Resolve the last document object referenced in the subname * @@ -573,26 +569,11 @@ class AppExport DocumentObject: public App::TransactionalObject */ App::DocumentObjectExecReturn *executeExtensions(); - /** Status bits of the document object - * The first 8 bits are used for the base system the rest can be used in - * descendent classes to mark special statuses on the objects. - * The bits and their meaning are listed below: - * 0 - object is marked as 'touched' - * 1 - object is marked as 'erroneous' - * 2 - object is marked as 'new' - * 3 - object is marked as 'recompute', i.e. the object gets recomputed now - * 4 - object is marked as 'restoring', i.e. the object gets loaded at the moment - * 5 - object is marked as 'deleting', i.e. the object gets deleted at the moment - * 6 - reserved - * 7 - reserved - * 16 - object is marked as 'expanded' in the tree view - */ - std::bitset<32> StatusBits; - - void setError(void){StatusBits.set(ObjectStatus::Error);} - void resetError(void){StatusBits.reset(ObjectStatus::Error);} + void setError(void){testStatus(ObjectStatus::Error);} + void resetError(void){setStatus(ObjectStatus::Error, false);} void setDocument(App::Document* doc); + virtual void onStatusChanged(const ObjectStatus& pos, bool newValue); /// get called before the value is changed virtual void onBeforeChange(const Property* prop) override; /// get called by the container when a property was changed @@ -609,7 +590,7 @@ class AppExport DocumentObject: public App::TransactionalObject virtual void unsetupObject(); /// get called when a property status has changed - virtual void onPropertyStatusChanged(const Property &prop, unsigned long oldStatus) override; + virtual void onPropertyStatusChanged(const Property &prop, const App::PropertyStatus& status) override; /// python object of this class and all descendent protected: // attributes diff --git a/src/App/DocumentObjectFileIncluded.cpp b/src/App/DocumentObjectFileIncluded.cpp index a7e051614181..4607196209be 100644 --- a/src/App/DocumentObjectFileIncluded.cpp +++ b/src/App/DocumentObjectFileIncluded.cpp @@ -36,7 +36,7 @@ PROPERTY_SOURCE(App::DocumentObjectFileIncluded, App::DocumentObject) DocumentObjectFileIncluded::DocumentObjectFileIncluded() { - ADD_PROPERTY_TYPE(File,(0),"",(App::PropertyType)(Prop_None),"File to include into Project File"); + ADD_PROPERTY_TYPE(File,(0),"", Prop_None, "File to include into Project File"); } DocumentObjectFileIncluded::~DocumentObjectFileIncluded() diff --git a/src/App/DocumentObjectGroup.cpp b/src/App/DocumentObjectGroup.cpp index deb985984a0c..ee902b8386ce 100644 --- a/src/App/DocumentObjectGroup.cpp +++ b/src/App/DocumentObjectGroup.cpp @@ -38,7 +38,7 @@ PROPERTY_SOURCE_WITH_EXTENSIONS(App::DocumentObjectGroup, App::DocumentObject) DocumentObjectGroup::DocumentObjectGroup(void): DocumentObject(), GroupExtension() { GroupExtension::initExtension(this); - _GroupTouched.setStatus(App::Property::Output,true); + _GroupTouched.setStatus(App::PropertyStatus::Output,true); } DocumentObjectGroup::~DocumentObjectGroup() { diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 618968d42fa4..f5358c7662e1 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -30,6 +30,7 @@ #include "GeoFeature.h" #include "GroupExtension.h" #include "GeoFeatureGroupExtension.h" +#include "LegacyPropertyStatus.h" // inclusion of the generated files (generated out of DocumentObjectPy.xml) #include @@ -76,13 +77,25 @@ Py::Object DocumentObjectPy::getDocument(void) const PyObject* DocumentObjectPy::addProperty(PyObject *args) { char *sType,*sName=0,*sGroup=0,*sDoc=0; + std::string sTypeStr, sNameStr, sGroupStr, sDocStr; short attr=0; - std::string sDocStr; PyObject *ro = Py_False, *hd = Py_False; if (!PyArg_ParseTuple(args, "s|ssethO!O!", &sType,&sName,&sGroup,"utf-8",&sDoc,&attr, &PyBool_Type, &ro, &PyBool_Type, &hd)) // convert args: Python->C return NULL; // NULL triggers exception + if (sType) { + sTypeStr = sType; + } + + if (sName) { + sNameStr = sName; + } + + if (sGroup) { + sGroupStr = sGroup; + } + if (sDoc) { sDocStr = sDoc; PyMem_Free(sDoc); @@ -90,8 +103,10 @@ PyObject* DocumentObjectPy::addProperty(PyObject *args) App::Property* prop=0; try { - prop = getDocumentObjectPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr, - PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); + prop = getDocumentObjectPtr()->addDynamicProperty(sTypeStr,sNameStr,sGroupStr,sDocStr); + prop->setStatus(App::fromLegacyAttributes(StatusCollection(attr))); + prop->setStatus(App::PropertyStatus::Prop_ReadOnly, PyObject_IsTrue(ro) ); + prop->setStatus(App::PropertyStatus::Prop_Hidden, PyObject_IsTrue(hd) ); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); @@ -141,15 +156,15 @@ PyObject* DocumentObjectPy::supportedProperties(PyObject *args) PyObject* DocumentObjectPy::touch(PyObject * args) { char *propName = 0; - if (!PyArg_ParseTuple(args, "|s",&propName)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "|s",&propName)) // convert args: Python->C + return NULL; // NULL triggers exception if(propName) { if(!propName[0]) { getDocumentObjectPtr()->touch(true); Py_Return; } auto prop = getDocumentObjectPtr()->getPropertyByName(propName); - if(!prop) + if(!prop) throw Py::RuntimeError("Property not found"); prop->touch(); Py_Return; @@ -161,8 +176,8 @@ PyObject* DocumentObjectPy::touch(PyObject * args) PyObject* DocumentObjectPy::purgeTouched(PyObject * args) { - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "")) // convert args: Python->C + return NULL; // NULL triggers exception getDocumentObjectPtr()->purgeTouched(); Py_Return; } @@ -281,12 +296,12 @@ Py::List DocumentObjectPy::getInListRecursive(void) const for (std::vector::iterator It = list.begin(); It != list.end(); ++It) ret.append(Py::Object((*It)->getPyObject(), true)); - + } catch (const Base::Exception& e) { throw Py::IndexError(e.what()); } - return ret; + return ret; } Py::List DocumentObjectPy::getOutList(void) const @@ -510,7 +525,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) sub.c_str(),retType!=0&&retType!=2?0:&pyObj,&info.mat,transform,depth); if(pyObj) info.pyObj = Py::Object(pyObj,true); - if(info.sobj) + if(info.sobj) info.obj = Py::Object(info.sobj->getPyObject(),true); } if(ret.empty()) @@ -769,7 +784,7 @@ int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj) if (prop) { if(prop->testStatus(Property::Immutable)) { std::stringstream s; - s << "'DocumentObject' attribute '" << attr << "' is read-only"; + s << "'DocumentObject' attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); } prop->setPyObject(obj); @@ -802,7 +817,7 @@ int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj) (getDocumentObjectPtr()->getPropertyType(prop) & Prop_ReadOnly)) { std::stringstream s; - s << "'DocumentObject' attribute '" << attr << "' is read-only"; + s << "'DocumentObject' attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); } @@ -815,7 +830,7 @@ int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj) throw Py::TypeError(s.str()); } return 1; - } + } #endif return 0; @@ -833,7 +848,7 @@ PyObject *DocumentObjectPy::resolve(PyObject *args) { const char *subname; if (!PyArg_ParseTuple(args, "s",&subname)) - return NULL; // NULL triggers exception + return NULL; // NULL triggers exception PY_TRY { std::string elementName; @@ -858,7 +873,7 @@ PyObject *DocumentObjectPy::resolveSubElement(PyObject *args) PyObject *append = Py_False; int type = 0; if (!PyArg_ParseTuple(args, "s|Oi",&subname,&append,&type)) - return NULL; // NULL triggers exception + return NULL; // NULL triggers exception PY_TRY { std::pair elementName; diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index f17c59a4a998..b23380a2a4ee 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -174,7 +174,7 @@ void DocumentObjectT::operator=(const DocumentObject* obj) } void DocumentObjectT::operator=(const Property *prop) { - if(!prop || !prop->getName() + if(!prop || !prop->getContainer() || !prop->getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { diff --git a/src/App/DocumentObserverPython.cpp b/src/App/DocumentObserverPython.cpp index 957c3507842a..36bb8cdbeb13 100644 --- a/src/App/DocumentObserverPython.cpp +++ b/src/App/DocumentObserverPython.cpp @@ -258,17 +258,15 @@ void DocumentObserverPython::slotCloseTransaction(bool abort) } } -void DocumentObserverPython::slotBeforeChangeDocument(const App::Document& Doc, const App::Property& Prop) -{ +void DocumentObserverPython::slotBeforeChangeDocument(const App::Document& Doc, const App::Property& Prop) +{ Base::PyGILStateLocker lock; try { Py::Tuple args(2); args.setItem(0, Py::Object(const_cast(Doc).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Doc.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if ( Doc.isOwnerOf(Prop) ) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyBeforeChangeDocument.ptr(),args.ptr()); } } @@ -278,17 +276,15 @@ void DocumentObserverPython::slotBeforeChangeDocument(const App::Document& Doc, } } -void DocumentObserverPython::slotChangedDocument(const App::Document& Doc, const App::Property& Prop) +void DocumentObserverPython::slotChangedDocument(const App::Document& Doc, const App::Property& Prop) { Base::PyGILStateLocker lock; try { Py::Tuple args(2); args.setItem(0, Py::Object(const_cast(Doc).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Doc.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (Doc.isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyChangedDocument.ptr(),args.ptr()); } } @@ -333,11 +329,9 @@ void DocumentObserverPython::slotBeforeChangeObject(const App::DocumentObject& O try { Py::Tuple args(2); args.setItem(0, Py::Object(const_cast(Obj).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Obj.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (Obj.isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyBeforeChangeObject.ptr(),args.ptr()); } } @@ -353,12 +347,10 @@ void DocumentObserverPython::slotChangedObject(const App::DocumentObject& Obj, Base::PyGILStateLocker lock; try { Py::Tuple args(2); - args.setItem(0, Py::Object(const_cast(Obj).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Obj.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + args.setItem(0, Py::Object(const_cast(Obj).getPyObject(), true)); + + if (Obj.isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyChangedObject.ptr(),args.ptr()); } } @@ -460,11 +452,9 @@ void DocumentObserverPython::slotAppendDynamicProperty(const App::Property& Prop auto container = Prop.getContainer(); Py::Tuple args(2); args.setItem(0, Py::Object(container->getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = container->getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (container->isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyAppendDynamicProperty.ptr(),args.ptr()); } } @@ -481,18 +471,16 @@ void DocumentObserverPython::slotRemoveDynamicProperty(const App::Property& Prop auto container = Prop.getContainer(); Py::Tuple args(2); args.setItem(0, Py::Object(container->getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = container->getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (container->isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyRemoveDynamicProperty.ptr(),args.ptr()); } } catch (Py::Exception&) { Base::PyException e; // extract the Python error text e.ReportException(); - } + } } void DocumentObserverPython::slotChangePropertyEditor(const App::Document &, const App::Property& Prop) @@ -502,11 +490,9 @@ void DocumentObserverPython::slotChangePropertyEditor(const App::Document &, con auto container = Prop.getContainer(); Py::Tuple args(2); args.setItem(0, Py::Object(container->getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = container->getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (container->isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyChangePropertyEditor.ptr(),args.ptr()); } } diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp index 9b78d578e559..69b42919714b 100644 --- a/src/App/DynamicProperty.cpp +++ b/src/App/DynamicProperty.cpp @@ -28,6 +28,7 @@ #include "DynamicProperty.h" #include "Property.h" +#include "LegacyPropertyStatus.h" #include "PropertyContainer.h" #include "Application.h" #include "ExtensionContainer.h" @@ -55,28 +56,28 @@ DynamicProperty::~DynamicProperty() void DynamicProperty::clear() { auto &index = props.get<0>(); for(auto &v : index) - delete v.property; + delete v->property; index.clear(); } void DynamicProperty::getPropertyList(std::vector &List) const { for (auto &v : props.get<0>()) - List.push_back(v.property); + List.push_back(v->property); } void DynamicProperty::getPropertyMap(std::map &Map) const { for (auto &v : props.get<0>()) - Map[v.name] = v.property; + Map[v->Name] = v->property; } -Property *DynamicProperty::getDynamicPropertyByName(const char* name) const +Property *DynamicProperty::getDynamicPropertyByName(const std::string& name) const { auto &index = props.get<0>(); auto it = index.find(name); if (it != index.end()) - return it->property; + return (*it)->property; return 0; } @@ -86,70 +87,14 @@ std::vector DynamicProperty::getDynamicPropertyNames() const auto &index = props.get<0>(); names.reserve(index.size()); for(auto &v : index) - names.push_back(v.name); + names.push_back(v->Name); return names; } -short DynamicProperty::getPropertyType(const Property* prop) const +Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const std::string& type, + const std::string& name, const std::string& group, const std::string& doc) { - return prop?prop->getType():0; -} - -short DynamicProperty::getPropertyType(const char *name) const -{ - auto &index = props.get<0>(); - auto it = index.find(name); - if (it != index.end()) { - short attr = it->attr; - if (it->hidden) - attr |= Prop_Hidden; - if (it->readonly) - attr |= Prop_ReadOnly; - return attr; - } - return 0; -} - -const char* DynamicProperty::getPropertyGroup(const Property* prop) const -{ - auto &index = props.get<1>(); - auto it = index.find(const_cast(prop)); - if(it!=index.end()) - return it->group.c_str(); - return 0; -} - -const char* DynamicProperty::getPropertyGroup(const char *name) const -{ - auto &index = props.get<0>(); - auto it = index.find(name); - if (it != index.end()) - return it->group.c_str(); - return 0; -} - -const char* DynamicProperty::getPropertyDocumentation(const Property* prop) const -{ - auto &index = props.get<1>(); - auto it = index.find(const_cast(prop)); - if(it!=index.end()) - return it->doc.c_str(); - return 0; -} - -const char* DynamicProperty::getPropertyDocumentation(const char *name) const -{ - auto &index = props.get<0>(); - auto it = index.find(name); - if (it != index.end()) - return it->doc.c_str(); - return 0; -} - -Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const char* type, - const char* name, const char* group, const char* doc, short attr, bool ro, bool hidden) -{ - Base::BaseClass* base = static_cast(Base::Type::createInstanceByName(type,true)); + Base::BaseClass* base = static_cast(Base::Type::createInstanceByName(type.c_str(),true)); if (!base) return 0; if (!base->getTypeId().isDerivedFrom(Property::getClassTypeId())) { @@ -161,38 +106,28 @@ Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const char* // get unique name Property* pcProperty = static_cast(base); - if (!name || !name[0]) - name = type; - - auto res = props.get<0>().emplace(pcProperty, - getUniquePropertyName(pc,name), nullptr, group, doc, attr, ro, hidden); + std::string decidedName; + if(name.empty()) //TODO: remove this + decidedName=type; + else + decidedName=name; + auto res = props.get<0>().insert( + std::shared_ptr + ( + new DynamicProperty::PropData(pcProperty, getUniquePropertyName(pc,decidedName), group, doc) + ) + ); pcProperty->setContainer(&pc); - pcProperty->myName = res.first->name.c_str(); - - if(ro) attr |= Prop_ReadOnly; - if(hidden) attr |= Prop_Hidden; + pcProperty->setPropertySpec(*res.first); - pcProperty->syncType(attr); - pcProperty->StatusBits.set((size_t)Property::PropDynamic); + pcProperty->setStatus(Prop_Dynamic); GetApplication().signalAppendDynamicProperty(*pcProperty); return pcProperty; } -bool DynamicProperty::addProperty(Property *prop) -{ - if(!prop || !prop->getName()) - return false; - auto &index = props.get<0>(); - if(index.count(prop->getName())) - return false; - index.emplace(prop,std::string(),prop->getName(), - prop->getGroup(),prop->getDocumentation(),prop->getType(),false,false); - return true; -} - bool DynamicProperty::removeProperty(const Property *prop) { auto &index = props.get<1>(); @@ -204,16 +139,16 @@ bool DynamicProperty::removeProperty(const Property *prop) return false; } -bool DynamicProperty::removeDynamicProperty(const char* name) +bool DynamicProperty::removeDynamicProperty(const std::string& name) { auto &index = props.get<0>(); auto it = index.find(name); if (it != index.end()) { - if(it->property->testStatus(Property::LockDynamic)) + if((*it)->property->testStatus(PropertyStatus::LockDynamic)) throw Base::RuntimeError("property is locked"); - else if(!it->property->testStatus(Property::PropDynamic)) + else if(!(*it)->property->testStatus(PropertyStatus::Prop_Dynamic)) throw Base::RuntimeError("property is not dynamic"); - Property *prop = it->property; + Property *prop = (*it)->property; GetApplication().signalRemoveDynamicProperty(*prop); Property::destroy(prop); index.erase(it); @@ -223,7 +158,7 @@ bool DynamicProperty::removeDynamicProperty(const char* name) return false; } -std::string DynamicProperty::getUniquePropertyName(PropertyContainer &pc, const char *Name) const +std::string DynamicProperty::getUniquePropertyName(PropertyContainer &pc, const std::string& Name) const { std::string CleanName = Base::Tools::getIdentifier(Name); @@ -251,11 +186,10 @@ void DynamicProperty::save(const Property *prop, Base::Writer &writer) const auto &index = props.get<1>(); auto it = index.find(const_cast(prop)); if(it != index.end()) { - auto &data = *it; - writer.Stream() << "\" group=\"" << Base::Persistence::encodeAttribute(data.group) - << "\" doc=\"" << Base::Persistence::encodeAttribute(data.doc) - << "\" attr=\"" << data.attr << "\" ro=\"" << data.readonly - << "\" hide=\"" << data.hidden; + writer.Stream() << "\" group=\"" << Base::Persistence::encodeAttribute(prop->getGroup()) + << "\" doc=\"" << Base::Persistence::encodeAttribute(prop->getDocumentation()) + << "\" ro=\"" << prop->testStatus(Prop_ReadOnly) + << "\" hide=\"" << prop->testStatus(Prop_Hidden); } } @@ -265,15 +199,16 @@ Property *DynamicProperty::restore(PropertyContainer &pc, if (!reader.hasAttribute("group")) return 0; - short attribute = 0; + StatusCollection attribute ; bool readonly = false, hidden = false; - const char *group=0, *doc=0, *attr=0, *ro=0, *hide=0; + std::string group, doc; + const char *attr=0, *ro=0, *hide=0; group = reader.getAttribute("group"); if (reader.hasAttribute("doc")) doc = reader.getAttribute("doc"); if (reader.hasAttribute("attr")) { attr = reader.getAttribute("attr"); - if (attr) attribute = attr[0]-48; + if (attr) attribute = StatusCollection (attr[0]-48); } if (reader.hasAttribute("ro")) { ro = reader.getAttribute("ro"); @@ -283,23 +218,11 @@ Property *DynamicProperty::restore(PropertyContainer &pc, hide = reader.getAttribute("hide"); if (hide) hidden = (hide[0]-48) != 0; } - return addDynamicProperty(pc,TypeName, PropName, group, doc, attribute, readonly, hidden); -} - -DynamicProperty::PropData DynamicProperty::getDynamicPropertyData(const Property *prop) const -{ - auto &index = props.get<1>(); - auto it = index.find(const_cast(prop)); - if(it != index.end()) - return *it; - return PropData(); -} - -const char *DynamicProperty::getPropertyName(const Property *prop) const -{ - auto &index = props.get<1>(); - auto it = index.find(const_cast(prop)); - if(it != index.end()) - return it->getName(); - return 0; + Property * prop = addDynamicProperty(pc,TypeName, PropName, group, doc); + if (prop) { + prop->setStatus(App::fromLegacyAttributes(attribute)); + prop->setStatus(App::PropertyStatus::Prop_ReadOnly, readonly); + prop->setStatus(App::PropertyStatus::Prop_Hidden, hidden); + } + return prop; } diff --git a/src/App/DynamicProperty.h b/src/App/DynamicProperty.h index 760bfdc834d1..e4731f5c30bc 100644 --- a/src/App/DynamicProperty.h +++ b/src/App/DynamicProperty.h @@ -36,6 +36,7 @@ #include #include #include +#include namespace Base { class Writer; @@ -78,60 +79,29 @@ class AppExport DynamicProperty /// Get all properties of the class (including parent) void getPropertyMap(std::map &Map) const; /// Find a dynamic property by its name - Property *getDynamicPropertyByName(const char* name) const; + Property *getDynamicPropertyByName(const std::string& name) const; /*! Add a dynamic property of the type @a type and with the name @a name. @a Group gives the grouping name which appears in the property editor and @a doc shows the tooltip there. - With @a attr, @a ro and @a hidden the behaviour of the property can be controlled. - @a attr is an OR'ed value of the PropertyType enumeration. - If no special attribute should be set Prop_None can be set (or leave the default of 0). - For convenience the attributes for 'Read-Only' and 'Hidden' can also be controlled with - the values @a ro or @a hidden. This means, - @code - addDynamicProperty(..., ..., "Base","blah", Prop_ReadOnly | Prop_Hidden); - @endcode - is equivalent to - @code - addDynamicProperty(..., ..., "Base","blah", Prop_None, true, true); - @endcode + The new property has status Prop_Dynamic set to true */ - Property* addDynamicProperty(PropertyContainer &pc, const char* type, const char* name=0, const char* group=0, - const char* doc=0, short attr=0, bool ro=false, bool hidden=false); - /** Add a pre-existing property - * - * The property is not treated as dynamic, and will not trigger signal. - * - * @return Return false if there is a property exist with the same name. - */ - bool addProperty(Property *prop); + Property* addDynamicProperty( + PropertyContainer &pc, + const std::string& type, + const std::string& name, + const std::string& group, + const std::string& doc + ); /*! Removes a dynamic property by name. Returns true if the property is part of the container, otherwise false is returned. */ - bool removeDynamicProperty(const char* name); + bool removeDynamicProperty(const std::string& name); /// Remove pre-existing property, which will not be deleted. bool removeProperty(const Property *prop); /// Get a list of all dynamic properties. std::vector getDynamicPropertyNames() const; - /// Get the name of a property - const char* getPropertyName(const Property* prop) const; - //@} - - /** @name Property attributes */ - //@{ - /// Get the attributes of a property - short getPropertyType(const Property* prop) const; - /// Get the attributes of a named property - short getPropertyType(const char *name) const; - /// Get the group name of a property - const char* getPropertyGroup(const Property* prop) const; - /// Get the group name of a named property - const char* getPropertyGroup(const char *name) const; - /// Get the documentation of a property - const char* getPropertyDocumentation(const Property* prop) const; - /// Get the documentation of a named property - const char* getPropertyDocumentation(const char *name) const; //@} /// Remove all properties @@ -142,43 +112,27 @@ class AppExport DynamicProperty void save(const Property *prop, Base::Writer &writer) const; - Property *restore(PropertyContainer &pc, + Property *restore(PropertyContainer &pc, const char *PropName, const char *TypeName, Base::XMLReader &reader); - struct PropData { + struct PropData : public App::PropertySpec { Property* property; - std::string name; - const char *pName; - std::string group; - std::string doc; - short attr; - bool readonly; - bool hidden; - - PropData(Property *prop=0, std::string &&n=std::string(), const char *pn=0, - const char *g=0, const char *d=0, short a=0, bool ro=false, bool h=false) - :property(prop),name(std::move(n)),pName(pn) - ,group(g?g:""),doc(d?d:""),attr(a),readonly(ro),hidden(h) - {} - const char *getName() const { - return pName?pName:name.c_str(); - } + PropData(Property *prop, const std::string& pn, + const std::string& g, const std::string& d) + :PropertySpec(pn,g,d,-1),property(prop) + {} }; - PropData getDynamicPropertyData(const Property* prop) const; - private: - std::string getUniquePropertyName(PropertyContainer &pc, const char *Name) const; + std::string getUniquePropertyName(PropertyContainer &pc, const std::string& Name) const; private: bmi::multi_index_container< - PropData, + std::shared_ptr, bmi::indexed_by< bmi::hashed_unique< - bmi::const_mem_fun, - CStringHasher, - CStringHasher + bmi::member >, bmi::hashed_unique< bmi::member diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp index 18e21d5f1e66..c7e6cc8970cd 100644 --- a/src/App/Extension.cpp +++ b/src/App/Extension.cpp @@ -119,49 +119,11 @@ std::string Extension::name() const { return std::string(); } - - -Property* Extension::extensionGetPropertyByName(const char* name) const { +Property* Extension::extensionGetPropertyByName(const std::string& name) const { return extensionGetPropertyData().getPropertyByName(this, name); } -short int Extension::extensionGetPropertyType(const Property* prop) const { - - return extensionGetPropertyData().getType(this, prop); -} - -short int Extension::extensionGetPropertyType(const char* name) const { - - return extensionGetPropertyData().getType(this, name); -} - -const char* Extension::extensionGetPropertyName(const Property* prop) const { - - return extensionGetPropertyData().getName(this,prop); -} - -const char* Extension::extensionGetPropertyGroup(const Property* prop) const { - - return extensionGetPropertyData().getGroup(this,prop); -} - -const char* Extension::extensionGetPropertyGroup(const char* name) const { - - return extensionGetPropertyData().getGroup(this,name); -} - - -const char* Extension::extensionGetPropertyDocumentation(const Property* prop) const { - - return extensionGetPropertyData().getDocumentation(this, prop); -} - -const char* Extension::extensionGetPropertyDocumentation(const char* name) const { - - return extensionGetPropertyData().getDocumentation(this, name); -} - void Extension::extensionGetPropertyList(std::vector< Property* >& List) const { extensionGetPropertyData().getPropertyList(this, List); diff --git a/src/App/Extension.h b/src/App/Extension.h index 4f2da76a06c3..68ff1bd8e999 100644 --- a/src/App/Extension.h +++ b/src/App/Extension.h @@ -250,26 +250,12 @@ class AppExport Extension /** @name Access properties */ //@{ /// find a property by its name - virtual Property *extensionGetPropertyByName(const char* name) const; - /// get the name of a property - virtual const char* extensionGetPropertyName(const Property* prop) const; + virtual Property *extensionGetPropertyByName(const std::string& name) const; /// get all properties of the class (including properties of the parent) virtual void extensionGetPropertyMap(std::map &Map) const; /// get all properties of the class (including properties of the parent) virtual void extensionGetPropertyList(std::vector &List) const; - /// get the Type of a Property - virtual short extensionGetPropertyType(const Property* prop) const; - /// get the Type of a named Property - virtual short extensionGetPropertyType(const char *name) const; - /// get the Group of a Property - virtual const char* extensionGetPropertyGroup(const Property* prop) const; - /// get the Group of a named Property - virtual const char* extensionGetPropertyGroup(const char *name) const; - /// get the Group of a Property - virtual const char* extensionGetPropertyDocumentation(const Property* prop) const; - /// get the Group of a named Property - virtual const char* extensionGetPropertyDocumentation(const char *name) const; //@} /** @name Persistence */ @@ -304,7 +290,7 @@ class AppExport Extension #define _EXTENSION_ADD_PROPERTY(_name, _prop_, _defaultval_) \ do { \ this->_prop_.setValue _defaultval_;\ - propertyData.addProperty(static_cast(this), _name, &this->_prop_); \ + propertyData.addProperty(static_cast(this), _name, &this->_prop_, std::string(), std::string() ); \ } while (0) @@ -313,8 +299,9 @@ class AppExport Extension #define _EXTENSION_ADD_PROPERTY_TYPE(_name, _prop_, _defaultval_, _group_,_type_,_Docu_) \ do { \ - this->_prop_.setValue _defaultval_;\ - propertyData.addProperty(static_cast(this), _name, &this->_prop_, (_group_),(_type_),(_Docu_)); \ + this->_prop_.setValue _defaultval_;\ + this->_prop_.setStatus( _type_ ); \ + propertyData.addProperty(static_cast(this), _name, &this->_prop_, (_group_), (_Docu_)); \ } while (0) #define EXTENSION_ADD_PROPERTY_TYPE(_prop_, _defaultval_, _group_,_type_,_Docu_) \ diff --git a/src/App/ExtensionContainer.cpp b/src/App/ExtensionContainer.cpp index 528cd5ee4aaf..02da2a955d28 100644 --- a/src/App/ExtensionContainer.cpp +++ b/src/App/ExtensionContainer.cpp @@ -155,7 +155,7 @@ void ExtensionContainer::getPropertyMap(std::map< std::string, Property* >& Map) entry.second->extensionGetPropertyMap(Map); } -Property* ExtensionContainer::getPropertyByName(const char* name) const { +Property* ExtensionContainer::getPropertyByName(const std::string& name) const { auto prop = App::PropertyContainer::getPropertyByName(name); if(prop) return prop; @@ -170,110 +170,10 @@ Property* ExtensionContainer::getPropertyByName(const char* name) const { } -short int ExtensionContainer::getPropertyType(const Property* prop) const { - short int res = App::PropertyContainer::getPropertyType(prop); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyType(prop); - if(res != 0) - return res; - } - - return 0; -} - -short int ExtensionContainer::getPropertyType(const char* name) const { - - short int res = App::PropertyContainer::getPropertyType(name); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyType(name); - if(res != 0) - return res; - } - - return 0; -} - - -const char* ExtensionContainer::getPropertyName(const Property* prop) const { - - const char* res = App::PropertyContainer::getPropertyName(prop); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyName(prop); - if(res != 0) - return res; - } - - return 0; -} - -const char* ExtensionContainer::getPropertyGroup(const Property* prop) const { - - const char* res = App::PropertyContainer::getPropertyGroup(prop); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyGroup(prop); - if(res != 0) - return res; - } - - return 0; -} - -const char* ExtensionContainer::getPropertyGroup(const char* name) const { - - const char* res = App::PropertyContainer::getPropertyGroup(name); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyGroup(name); - if(res != 0) - return res; - } - - return 0; -} - - -const char* ExtensionContainer::getPropertyDocumentation(const Property* prop) const { - - const char* res = App::PropertyContainer::getPropertyDocumentation(prop); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyDocumentation(prop); - if(res != 0) - return res; - } - - return 0; -} - -const char* ExtensionContainer::getPropertyDocumentation(const char* name) const { - - const char* res = App::PropertyContainer::getPropertyDocumentation(name); - if(res != 0) - return res; - - for(auto entry : _extensions) { - res = entry.second->extensionGetPropertyDocumentation(name); - if(res != 0) - return res; - } - - return 0; +bool ExtensionContainer::isOwnerOf(const Property& prop) const { + if(App::PropertyContainer::isOwnerOf(prop)) + return true; + return prop.getContainer() == this; } void ExtensionContainer::onChanged(const Property* prop) { diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h index ec44365462ec..9cb9ae33297a 100644 --- a/src/App/ExtensionContainer.h +++ b/src/App/ExtensionContainer.h @@ -155,26 +155,14 @@ class AppExport ExtensionContainer : public App::PropertyContainer /** @name Access properties */ //@{ /// find a property by its name - virtual Property *getPropertyByName(const char* name) const override; - /// get the name of a property - virtual const char* getPropertyName(const Property* prop) const override; + virtual Property *getPropertyByName(const std::string& name) const override; /// get all properties of the class (including properties of the parent) virtual void getPropertyMap(std::map &Map) const override; /// get all properties of the class (including properties of the parent) virtual void getPropertyList(std::vector &List) const override; - - /// get the Type of a Property - virtual short getPropertyType(const Property* prop) const override; - /// get the Type of a named Property - virtual short getPropertyType(const char *name) const override; - /// get the Group of a Property - virtual const char* getPropertyGroup(const Property* prop) const override; - /// get the Group of a named Property - virtual const char* getPropertyGroup(const char *name) const override; - /// get the Group of a Property - virtual const char* getPropertyDocumentation(const Property* prop) const override; - /// get the Group of a named Property - virtual const char* getPropertyDocumentation(const char *name) const override; + /// test if a property is owned by this container + virtual bool isOwnerOf(const Property& prop) const override; + //@} virtual void onChanged(const Property*) override; diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index 65de2fec782c..3d831689a8da 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -131,18 +131,17 @@ void FeaturePythonImp::onBeforeChange(const Property* prop) // Run the execute method of the proxy object. Base::PyGILStateLocker lock; try { - const char *prop_name = object->getPropertyName(prop); - if(prop_name == 0) + if(!object->isOwnerOf(*prop)) return; if (has__object__) { Py::Tuple args(1); - args.setItem(0, Py::String(prop_name)); + args.setItem(0, Py::String(prop->getName())); Base::pyCall(py_onBeforeChange.ptr(),args.ptr()); } else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - args.setItem(1, Py::String(prop_name)); + args.setItem(1, Py::String(prop->getName())); Base::pyCall(py_onBeforeChange.ptr(),args.ptr()); } } @@ -185,18 +184,17 @@ void FeaturePythonImp::onChanged(const Property* prop) // Run the execute method of the proxy object. Base::PyGILStateLocker lock; try { - const char *prop_name = object->getPropertyName(prop); - if(prop_name == 0) + if(!object->isOwnerOf(*prop)) return; if (has__object__) { Py::Tuple args(1); - args.setItem(0, Py::String(prop_name)); + args.setItem(0, Py::String( prop->getName())); Base::pyCall(py_onChanged.ptr(),args.ptr()); } else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - args.setItem(1, Py::String(prop_name)); + args.setItem(1, Py::String( prop->getName())); Base::pyCall(py_onChanged.ptr(),args.ptr()); } } diff --git a/src/App/FeatureTest.cpp b/src/App/FeatureTest.cpp index a24f6046f87f..670e03e9313e 100644 --- a/src/App/FeatureTest.cpp +++ b/src/App/FeatureTest.cpp @@ -104,7 +104,7 @@ FeatureTest::FeatureTest() ADD_PROPERTY_TYPE(TypeOutput ,(4711),group,Prop_Output ,"An example property which has the type 'Output'" ); ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" ); ADD_PROPERTY_TYPE(TypeNoRecompute,(4711),group,Prop_NoRecompute,"An example property which has the type 'NoRecompute'"); - ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ), + ADD_PROPERTY_TYPE(TypeAll ,(4711),group, Prop_Output+Prop_ReadOnly+Prop_Hidden, "An example property which has the types 'Output', 'ReadOnly', and 'Hidden'"); ADD_PROPERTY(QuantityLength,(1.0)); diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index 0e9df0b3e653..8160c3bed5a8 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -42,7 +42,7 @@ PROPERTY_SOURCE(App::GeoFeature, App::DocumentObject) GeoFeature::GeoFeature(void) { - ADD_PROPERTY_TYPE(Placement,(Base::Placement()),nullptr,Prop_NoRecompute,nullptr); + ADD_PROPERTY_TYPE(Placement,(Base::Placement()), "", Prop_NoRecompute,""); } GeoFeature::~GeoFeature(void) @@ -63,7 +63,7 @@ Base::Placement GeoFeature::globalPlacement() const auto ext = group->getExtensionByType(); return ext->globalGroupPlacement() * Placement.getValue(); } - return Placement.getValue(); + return Placement.getValue(); } const PropertyComplexGeoData* GeoFeature::getPropertyOfGeometry() const @@ -93,9 +93,9 @@ std::pair GeoFeature::getElementName( return ret; } -DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subname, - std::pair &elementName, bool append, - ElementNameType type, const DocumentObject *filter, +DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subname, + std::pair &elementName, bool append, + ElementNameType type, const DocumentObject *filter, const char **_element, GeoFeature **geoFeature) { if(!obj || !obj->getNameInDocument()) @@ -109,24 +109,24 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn return 0; obj = sobj->getLinkedObject(true); auto geo = dynamic_cast(obj); - if(geoFeature) + if(geoFeature) *geoFeature = geo; if(!obj || (filter && obj!=filter)) return 0; if(!element || !element[0]) { - if(append) + if(append) elementName.second = Data::ComplexGeoData::oldElementName(subname); return sobj; } if(!geo || hasHiddenMarker(element)) { - if(!append) + if(!append) elementName.second = element; else elementName.second = Data::ComplexGeoData::oldElementName(subname); return sobj; } - if(!append) + if(!append) elementName = geo->getElementName(element,type); else{ const auto &names = geo->getElementName(element,type); diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index deeec66a0449..00eb04076b42 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -60,10 +60,10 @@ GeoFeatureGroupExtension::~GeoFeatureGroupExtension(void) } void GeoFeatureGroupExtension::initExtension(ExtensionContainer* obj) { - + if(!obj->isDerivedFrom(App::GeoFeature::getClassTypeId())) throw Base::RuntimeError("GeoFeatureGroupExtension can only be applied to GeoFeatures"); - + App::GroupExtension::initExtension(obj); } @@ -71,7 +71,7 @@ PropertyPlacement& GeoFeatureGroupExtension::placement() { if(!getExtendedContainer()) throw Base::RuntimeError("GeoFeatureGroupExtension was not applied to GeoFeature"); - + return static_cast(getExtendedContainer())->Placement; } @@ -88,19 +88,19 @@ DocumentObject* GeoFeatureGroupExtension::getGroupOfObject(const DocumentObject* { if(!obj) return nullptr; - + //we will find origins, but not origin features - if(obj->isDerivedFrom(App::OriginFeature::getClassTypeId())) + if(obj->isDerivedFrom(App::OriginFeature::getClassTypeId())) return OriginGroupExtension::getGroupOfObject(obj); - + //compared to GroupExtension we do return here all GeoFeatureGroups including all extensions derived from it //like OriginGroup. That is needed as we use this function to get all local coordinate systems. Also there //is no reason to distinguish between GeoFeatuerGroups, there is only between group/geofeaturegroup auto list = obj->getInList(); for (auto inObj : list) { - - //There is a chance that a derived geofeaturegroup links with a local link and hence is not - //the parent group even though it links to the object. We use hasObject as one and only truth + + //There is a chance that a derived geofeaturegroup links with a local link and hence is not + //the parent group even though it links to the object. We use hasObject as one and only truth //if it has the object within the group auto group = inObj->getExtensionByType(true); if(group && group->hasObject(obj)) @@ -121,59 +121,59 @@ Base::Placement GeoFeatureGroupExtension::globalGroupPlacement() { Base::Placement GeoFeatureGroupExtension::recursiveGroupPlacement(GeoFeatureGroupExtension* group) { - + auto inList = group->getExtendedObject()->getInList(); for(auto* link : inList) { auto parent = link->getExtensionByType(true); if(parent && parent->hasObject(group->getExtendedObject())) return recursiveGroupPlacement(parent) * group->placement().getValue(); } - + return group->placement().getValue(); } std::vector GeoFeatureGroupExtension::addObjects(std::vector objects) { - + std::vector grp = Group.getValues(); std::vector ret; - + for(auto object : objects) { - + if(!allowObject(object)) continue; - - //cross CoordinateSystem links are not allowed, so we need to move the whole link group + + //cross CoordinateSystem links are not allowed, so we need to move the whole link group std::vector links = getCSRelevantLinks(object); links.push_back(object); - + for( auto obj : links) { - //only one geofeaturegroup per object. + //only one geofeaturegroup per object. auto *group = App::GeoFeatureGroupExtension::getGroupOfObject(obj); if(group && group != getExtendedObject()) group->getExtensionByType()->removeObject(obj); - + if (!hasObject(obj)) { grp.push_back(obj); ret.push_back(obj); } } } - + Group.setValues(grp); return ret; } std::vector GeoFeatureGroupExtension::removeObjects(std::vector objects) { - + std::vector removed; std::vector grp = Group.getValues(); - + for(auto object : objects) { - //cross CoordinateSystem links are not allowed, so we need to remove the whole link group + //cross CoordinateSystem links are not allowed, so we need to remove the whole link group std::vector< DocumentObject* > links = getCSRelevantLinks(object); links.push_back(object); - - //remove all links out of group + + //remove all links out of group for(auto link : links) { auto end = std::remove(grp.begin(), grp.end(), link); if(end != grp.end()) { @@ -182,22 +182,22 @@ std::vector GeoFeatureGroupExtension::removeObjects(std::vector } } } - + if(!removed.empty()) Group.setValues(grp); - + return removed; } void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) { //objects are only allowed in a single GeoFeatureGroup - if(p == &Group && !Group.testStatus(Property::User3)) { - + if(p == &Group && !Group.testStatus(PropertyStatus::User3)) { + if((!getExtendedObject()->isRestoring() || getExtendedObject()->getDocument()->testStatus(Document::Importing)) && !getExtendedObject()->getDocument()->isPerformingTransaction()) { - + bool error = false; auto corrected = Group.getValues(); for(auto obj : Group.getValues()) { @@ -218,7 +218,7 @@ void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) { //if an error was found we need to correct the values and inform the user if(error) { - Base::ObjectStatusLocker guard(Property::User3, &Group); + Base::ObjectStatusLocker guard(PropertyStatus::User3, &Group); Group.setValues(corrected); throw Base::RuntimeError("Object can only be in a single GeoFeatureGroup"); } @@ -276,7 +276,7 @@ void GeoFeatureGroupExtension::getCSOutList(const App::DocumentObject* obj, //we get all relevant linked objects. We can't use outList() as this includes the links from expressions, //also we only want links with scope Local auto result = getScopedObjectsFromLinks(obj, LinkScope::Local); - + //we remove all links to origin features and origins, they belong to a CS too and can't be moved result.erase(std::remove_if(result.begin(), result.end(), [](App::DocumentObject* obj)->bool { return (obj->isDerivedFrom(App::OriginFeature::getClassTypeId()) || @@ -303,7 +303,7 @@ void GeoFeatureGroupExtension::getCSInList(const DocumentObject* obj, if(parent->hasExtension(App::GroupExtension::getExtensionClassTypeId())) continue; - //check if the link is real Local scope one or if it is a expression one (could also be both, so it is not + //check if the link is real Local scope one or if it is a expression one (could also be both, so it is not //enough to check the expressions) auto res = getScopedObjectsFromLinks(parent, LinkScope::Local); if(std::find(res.begin(), res.end(), obj) != res.end()) @@ -320,7 +320,7 @@ std::vector< DocumentObject* > GeoFeatureGroupExtension::getCSRelevantLinks(cons if(!obj) return std::vector< DocumentObject* >(); - //get all out links + //get all out links std::vector vec; recursiveCSRelevantLinks(obj, vec); @@ -333,7 +333,7 @@ std::vector< DocumentObject* > GeoFeatureGroupExtension::getCSRelevantLinks(cons return vec; } -void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* obj, +void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* obj, std::vector< DocumentObject* >& vec) { if(!obj) @@ -344,7 +344,7 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob getCSInList(obj, links); //go on traversing the graph in all directions! - for(auto o : links) { + for(auto o : links) { if(!o || o == obj || std::find(vec.begin(), vec.end(), o) != vec.end()) continue; @@ -354,14 +354,14 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob } bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, - PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const + PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const { ret = 0; const char *dot; if(!subname || *subname==0) { auto obj = dynamic_cast(getExtendedContainer()); ret = const_cast(obj); - if(mat && transform) + if(mat && transform) *mat *= const_cast(this)->placement().getValue().toMatrix(); }else if((dot=strchr(subname,'.'))) { if(subname[0]!='$') @@ -377,9 +377,9 @@ bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const } if(ret) { if(dot) ++dot; - if(dot && *dot + if(dot && *dot && !ret->hasExtension(App::LinkBaseExtension::getExtensionClassTypeId()) - && !ret->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId())) + && !ret->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId())) { // Consider this // Body @@ -402,7 +402,7 @@ bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const } } } - if(mat && transform) + if(mat && transform) *mat *= const_cast(this)->placement().getValue().toMatrix(); ret = ret->getSubObject(dot?dot:"",pyObj,mat,true,depth+1); } @@ -443,7 +443,7 @@ bool GeoFeatureGroupExtension::isLinkValid(App::Property* prop) { auto result = getScopedObjectsFromLink(prop, LinkScope::Local); auto group = getGroupOfObject(obj); for(auto link : result) { - if(getGroupOfObject(link) != group) + if(getGroupOfObject(link) != group) return false; } @@ -452,7 +452,7 @@ bool GeoFeatureGroupExtension::isLinkValid(App::Property* prop) { result = getScopedObjectsFromLink(prop, LinkScope::Child); auto groupExt = obj->getExtensionByType(); for(auto link : result) { - if(!groupExt->hasObject(link, true)) + if(!groupExt->hasObject(link, true)) return false; } } @@ -469,7 +469,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj, auto result = getScopedObjectsFromLinks(obj, LinkScope::Local); auto group = obj->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()) ? obj : getGroupOfObject(obj); for(auto link : result) { - if(getGroupOfObject(link) != group) + if(getGroupOfObject(link) != group) vec.push_back(link); } @@ -478,7 +478,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj, result = getScopedObjectsFromLinks(obj, LinkScope::Child); auto groupExt = group->getExtensionByType(); for(auto link : result) { - if(!groupExt->hasObject(link, true)) + if(!groupExt->hasObject(link, true)) vec.push_back(link); } } diff --git a/src/App/GeoFeaturePyImp.cpp b/src/App/GeoFeaturePyImp.cpp index 27a0fb30b75a..75d6ef903db5 100644 --- a/src/App/GeoFeaturePyImp.cpp +++ b/src/App/GeoFeaturePyImp.cpp @@ -46,10 +46,10 @@ PyObject* GeoFeaturePy::getPaths(PyObject * /*args*/) } PyObject* GeoFeaturePy::getGlobalPlacement(PyObject * args) { - + if (!PyArg_ParseTuple(args, "")) return 0; - + try { Base::Placement p = static_cast(getDocumentObjectPtr())->globalPlacement(); return new Base::PlacementPy(new Base::Placement(p)); @@ -66,9 +66,8 @@ PyObject* GeoFeaturePy::getPropertyNameOfGeometry(PyObject * args) GeoFeature* object = this->getGeoFeaturePtr(); const PropertyComplexGeoData* prop = object->getPropertyOfGeometry(); - const char* name = prop ? prop->getName() : 0; - if (name) { - return Py::new_reference_to(Py::String(std::string(name))); + if (prop) { + return Py::new_reference_to(Py::String(prop->getName())); } return Py::new_reference_to(Py::None()); } @@ -93,5 +92,5 @@ PyObject *GeoFeaturePy::getCustomAttributes(const char* /*attr*/) const int GeoFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { - return 0; + return 0; } diff --git a/src/App/GroupExtension.cpp b/src/App/GroupExtension.cpp index b56963c04cdd..4e18cc8b3c1e 100644 --- a/src/App/GroupExtension.cpp +++ b/src/App/GroupExtension.cpp @@ -51,11 +51,11 @@ template class AppExport ExtensionPythonT> GroupExtension::GroupExtension() { initExtensionType(GroupExtension::getExtensionClassTypeId()); - - EXTENSION_ADD_PROPERTY_TYPE(Group,(0),"Base",(App::PropertyType)(Prop_None),"List of referenced objects"); - EXTENSION_ADD_PROPERTY_TYPE(_GroupTouched, (false), "Base", - PropertyType(Prop_Hidden|Prop_Transient),0); + EXTENSION_ADD_PROPERTY_TYPE(Group,(0),"Base", Prop_None,"List of referenced objects"); + + EXTENSION_ADD_PROPERTY_TYPE(_GroupTouched, (false), "Base", + Prop_Hidden+Prop_Transient, ""); } GroupExtension::~GroupExtension() @@ -80,23 +80,23 @@ std::vector GroupExtension::addObject(DocumentObject* obj) } std::vector< DocumentObject* > GroupExtension::addObjects(std::vector< DocumentObject* > objs) { - + std::vector added; std::vector grp = Group.getValues(); for(auto obj : objs) { - + if(!allowObject(obj)) continue; - + if (hasObject(obj)) continue; - + //only one group per object. Note that it is allowed to be in a group and geofeaturegroup. However, //getGroupOfObject() returns only normal groups, no GeoFeatureGroups. Hence this works. auto *group = App::GroupExtension::getGroupOfObject(obj); if(group && group != getExtendedObject()) group->getExtensionByType()->removeObject(obj); - + //if we are in a geofeaturegroup we need to ensure the object is too auto geogrp = GeoFeatureGroupExtension::getGroupOfObject(getExtendedObject()); auto objgrp = GeoFeatureGroupExtension::getGroupOfObject(obj); @@ -104,16 +104,16 @@ std::vector< DocumentObject* > GroupExtension::addObjects(std::vector< DocumentO //what to do depends on if we are in geofeature group or not if(geogrp) geogrp->getExtensionByType()->addObject(obj); - else + else objgrp->getExtensionByType()->removeObject(obj); } - + grp.push_back(obj); added.push_back(obj); } - + Group.setValues(grp); - + return added; } @@ -136,19 +136,19 @@ std::vector< DocumentObject* > GroupExtension::removeObjects(std::vector< Docume std::vector removed; std::vector::iterator end = newGrp.end(); - for(auto obj : objs) { + for(auto obj : objs) { auto res = std::remove(newGrp.begin(), end, obj); if(res != end) { end = res; removed.push_back(obj); } } - + newGrp.erase(end, newGrp.end()); if (grp.size() != newGrp.size()) { Group.setValues (newGrp); } - + return removed; } @@ -230,11 +230,11 @@ bool GroupExtension::hasObject(const DocumentObject* obj, bool recursive) const return false; } -bool GroupExtension::recursiveHasObject(const DocumentObject* obj, const GroupExtension* group, +bool GroupExtension::recursiveHasObject(const DocumentObject* obj, const GroupExtension* group, std::vector< const GroupExtension* > history) const { - //the purpose is to prevent infinite recursion when groups form a cyclic graph. To do this - //we store every group we processed on the current leave of the tree, and if we reach an + //the purpose is to prevent infinite recursion when groups form a cyclic graph. To do this + //we store every group we processed on the current leave of the tree, and if we reach an //already processed group we know that it not really is a tree but a cycle. history.push_back(this); @@ -252,7 +252,7 @@ bool GroupExtension::recursiveHasObject(const DocumentObject* obj, const GroupEx if ( child->hasExtension(GroupExtension::getExtensionClassTypeId()) ) { auto ext = child->getExtensionByType(); - + if(std::find(history.begin(), history.end(), ext) != history.end()) Base::RuntimeError("Cyclic dependencies detected: Search cannot be performed"); @@ -328,11 +328,11 @@ void GroupExtension::extensionOnChanged(const Property* p) { //objects are only allowed in a single group. Note that this check must only be done for normal //groups, not any derived classes if((this->getExtensionTypeId() == GroupExtension::getExtensionClassTypeId()) - && p == &Group && !Group.testStatus(Property::User3)) + && p == &Group && !Group.testStatus(PropertyStatus::User3)) { if(!getExtendedObject()->isRestoring() && !getExtendedObject()->getDocument()->isPerformingTransaction()) { - + bool error = false; auto corrected = Group.getValues(); for(auto obj : Group.getValues()) { @@ -351,7 +351,7 @@ void GroupExtension::extensionOnChanged(const Property* p) { //if an error was found we need to correct the values and inform the user if(error) { - Base::ObjectStatusLocker guard(Property::User3, &Group); + Base::ObjectStatusLocker guard(PropertyStatus::User3, &Group); Group.setValues(corrected); throw Base::RuntimeError("Object can only be in a single Group"); } @@ -377,7 +377,7 @@ void GroupExtension::slotChildChanged(const DocumentObject &obj, const Property } bool GroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, - PyObject **pyObj, Base::Matrix4D *mat, bool /*transform*/, int depth) const + PyObject **pyObj, Base::Matrix4D *mat, bool /*transform*/, int depth) const { const char *dot; if(!subname || *subname==0) { @@ -399,7 +399,7 @@ bool GroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *sub } } } - if(!ret) + if(!ret) return false; return ret->getSubObject(dot+1,pyObj,mat,true,depth+1); } @@ -435,7 +435,7 @@ void GroupExtension::getAllChildren(std::vector &res, continue; res.push_back(obj); auto ext = obj->getExtensionByType(true,false); - if(ext) + if(ext) ext->getAllChildren(res,rset); } } diff --git a/src/App/LegacyPropertyStatus.h b/src/App/LegacyPropertyStatus.h new file mode 100644 index 000000000000..c594fd9e6c88 --- /dev/null +++ b/src/App/LegacyPropertyStatus.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (c) 2005 Jürgen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef APP_LEGACYPROPERTYSTATUS_H +#define APP_LEGACYPROPERTYSTATUS_H + +#include "Property.h" +#include "StatusCollection.h" +#include + +namespace App +{ + +class LegacyPropertyStatus +{ + public: + enum Value + { + Prop_ReadOnly = 0, /*!< Property is read-only in the editor */ + Prop_Transient = 1, /*!< Property content won't be saved to file, but still saves name, type and status */ + Prop_Hidden = 2, /*!< Property won't appear in the editor */ + Prop_Output = 3, /*!< Modified property doesn't touch its parent container */ + Prop_NoRecompute = 4, /*!< Modified property doesn't touch its container for recompute */ + Prop_NoPersist = 5, /*!< Property won't be saved to file at all */ + }; +}; + +inline StatusCollection fromLegacyAttributes(const StatusCollection & attrs) { + std::map conversion = { + { App::LegacyPropertyStatus::Prop_ReadOnly, App::PropertyStatus::Prop_ReadOnly}, + { App::LegacyPropertyStatus::Prop_Transient, App::PropertyStatus::Prop_Transient}, + { App::LegacyPropertyStatus::Prop_Hidden, App::PropertyStatus::Prop_Hidden}, + { App::LegacyPropertyStatus::Prop_Output, App::PropertyStatus::Prop_Output}, + { App::LegacyPropertyStatus::Prop_NoRecompute, App::PropertyStatus::Prop_NoRecompute}, + { App::LegacyPropertyStatus::Prop_NoPersist, App::PropertyStatus::Prop_NoPersist}, + }; + + StatusCollection converted; + + for(const auto &pair: conversion) { + if(attrs.test(pair.first)) { + converted.set(pair.second); + } + } + return converted; +} + +} //namespace App + +#endif // APP_LEGACYPROPERTYSTATUS_H diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 624d77286a06..eda69b18e855 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -57,9 +57,9 @@ LinkBaseExtension::LinkBaseExtension(void) { initExtensionType(LinkBaseExtension::getExtensionClassTypeId()); EXTENSION_ADD_PROPERTY_TYPE(_LinkTouched, (false), " Link", - PropertyType(Prop_Hidden|Prop_NoPersist),0); + (Prop_Hidden+Prop_NoPersist), ""); EXTENSION_ADD_PROPERTY_TYPE(_ChildCache, (), " Link", - PropertyType(Prop_Hidden|Prop_NoPersist|Prop_ReadOnly),0); + (Prop_Hidden+Prop_NoPersist+Prop_ReadOnly), ""); _ChildCache.setScope(LinkScope::Global); props.resize(PropMax,0); } @@ -114,7 +114,7 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { LINK_THROW(Base::RuntimeError,"App::LinkBaseExtension: property index out of range"); if(props[idx]) { - props[idx]->setStatus(Property::LockDynamic,false); + props[idx]->setStatus(PropertyStatus::LockDynamic,false); props[idx] = 0; } if(!prop) @@ -128,7 +128,7 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { } props[idx] = prop; - props[idx]->setStatus(Property::LockDynamic,true); + props[idx]->setStatus(PropertyStatus::LockDynamic,true); switch(idx) { case PropLinkMode: { @@ -145,37 +145,28 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { getPlacementProperty()) { bool transform = getLinkTransformValue(); - getPlacementProperty()->setStatus(Property::Hidden,transform); - getLinkPlacementProperty()->setStatus(Property::Hidden,!transform); + getPlacementProperty()->setStatus(PropertyStatus::Hidden,transform); + getLinkPlacementProperty()->setStatus(PropertyStatus::Hidden,!transform); } break; case PropElementList: - getElementListProperty()->setStatus(Property::Hidden,true); + getElementListProperty()->setStatus(PropertyStatus::Hidden,true); // fall through case PropLinkedObject: // Make ElementList as read-only if we are not a group (i.e. having // LinkedObject property), because it is for holding array elements. if(getElementListProperty()) getElementListProperty()->setStatus( - Property::Immutable,getLinkedObjectProperty()!=0); + PropertyStatus::Immutable,getLinkedObjectProperty()!=0); break; case PropVisibilityList: - getVisibilityListProperty()->setStatus(Property::Immutable,true); - getVisibilityListProperty()->setStatus(Property::Hidden,true); + getVisibilityListProperty()->setStatus(PropertyStatus::Immutable,true); + getVisibilityListProperty()->setStatus(PropertyStatus::Hidden,true); break; } if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_TRACE)) { - const char *propName; - if(!prop) - propName = ""; - else if(prop->getContainer()) - propName = prop->getName(); - else - propName = extensionGetPropertyName(prop); - if(!propName) - propName = "?"; - FC_TRACE("set property " << infos[idx].name << ": " << propName); + FC_TRACE("set property " << infos[idx].name << ": " << prop->getName()); } } @@ -325,9 +316,9 @@ int LinkBaseExtension::extensionSetElementVisible(const char *element, bool visi if(visible) return 1; propElementVis->setSize(index+1, true); } - propElementVis->setStatus(Property::User3,true); + propElementVis->setStatus(PropertyStatus::User3,true); propElementVis->set1Value(index,visible); - propElementVis->setStatus(Property::User3,false); + propElementVis->setStatus(PropertyStatus::User3,false); const auto &elements = _getElementListValue(); if(index<(int)elements.size()) { if(!visible) @@ -753,7 +744,7 @@ bool LinkBaseExtension::extensionGetLinkedObject(DocumentObject *&ret, void LinkBaseExtension::extensionOnChanged(const Property *prop) { auto parent = getContainer(); - if(parent && !parent->isRestoring() && prop && !prop->testStatus(Property::User3)) + if(parent && !parent->isRestoring() && prop && !prop->testStatus(PropertyStatus::User3)) update(parent,prop); inherited::extensionOnChanged(prop); } @@ -863,26 +854,26 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop auto dst = getPlacementProperty(); if(src!=prop) std::swap(src,dst); if(src && dst) { - dst->setStatus(Property::User3,true); + dst->setStatus(PropertyStatus::User3,true); dst->setValue(src->getValue()); - dst->setStatus(Property::User3,false); + dst->setStatus(PropertyStatus::User3,false); } }else if(prop == getScaleProperty()) { - if(!prop->testStatus(Property::User3) && getScaleVectorProperty()) { + if(!prop->testStatus(User3) && getScaleVectorProperty()) { auto s = getScaleValue(); auto p = getScaleVectorProperty(); - p->setStatus(Property::User3,true); + p->setStatus(User3,true); p->setValue(s,s,s); - p->setStatus(Property::User3,false); + p->setStatus(User3,false); } }else if(prop == getScaleVectorProperty()) { - if(!prop->testStatus(Property::User3) && getScaleProperty()) { + if(!prop->testStatus(PropertyStatus::User3) && getScaleProperty()) { const auto &v = getScaleVectorValue(); if(v.x == v.y && v.x == v.z) { auto p = getScaleProperty(); - p->setStatus(Property::User3,true); + p->setStatus(User3,true); p->setValue(v.x); - p->setStatus(Property::User3,false); + p->setStatus(User3,false); } } }else if(prop == _getShowElementProperty()) { @@ -908,16 +899,16 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop } // touch the property again to make sure view provider has been // signaled before clearing the elements - getShowElementProperty()->setStatus(App::Property::User3,true); + getShowElementProperty()->setStatus(App::PropertyStatus::User3,true); getShowElementProperty()->touch(); - getShowElementProperty()->setStatus(App::Property::User3,false); + getShowElementProperty()->setStatus(App::PropertyStatus::User3,false); getElementListProperty()->setValues(std::vector()); if(getPlacementListProperty()) { - getPlacementListProperty()->setStatus(Property::User3,getScaleListProperty()!=0); + getPlacementListProperty()->setStatus(PropertyStatus::User3,getScaleListProperty()!=0); getPlacementListProperty()->setValue(placements); - getPlacementListProperty()->setStatus(Property::User3,false); + getPlacementListProperty()->setStatus(PropertyStatus::User3,false); } if(getScaleListProperty()) getScaleListProperty()->setValue(scales); @@ -940,9 +931,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop if(getScaleListProperty()) { auto scales = getScaleListValue(); scales.resize(elementCount,Base::Vector3d(1,1,1)); - getScaleListProperty()->setStatus(Property::User3,true); + getScaleListProperty()->setStatus(User3,true); getScaleListProperty()->setValue(scales); - getScaleListProperty()->setStatus(Property::User3,false); + getScaleListProperty()->setStatus(User3,false); } if(getPlacementListProperty()) { auto placements = getPlacementListValue(); @@ -951,9 +942,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop placements.emplace_back(Base::Vector3d(i%10,(i/10)%10,i/100),Base::Rotation()); }else placements.resize(elementCount); - getPlacementListProperty()->setStatus(Property::User3,true); + getPlacementListProperty()->setStatus(PropertyStatus::User3,true); getPlacementListProperty()->setValue(placements); - getPlacementListProperty()->setStatus(Property::User3,false); + getPlacementListProperty()->setStatus(PropertyStatus::User3,false); } }else if(getElementListProperty()) { auto objs = getElementListValue(); @@ -1041,9 +1032,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop }else if(prop == getElementListProperty() || prop == &_ChildCache) { if(prop == getElementListProperty()) { - _ChildCache.setStatus(Property::User3,true); + _ChildCache.setStatus(User3,true); updateGroup(); - _ChildCache.setStatus(Property::User3,false); + _ChildCache.setStatus(User3,false); } const auto &elements = _getElementListValue(); @@ -1068,9 +1059,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop myHiddenElements.swap(hiddenElements); if(vis != getVisibilityListValue()) { auto propVis = getVisibilityListProperty(); - propVis->setStatus(Property::User3,true); + propVis->setStatus(PropertyStatus::User3,true); propVis->setValue(vis); - propVis->setStatus(Property::User3,false); + propVis->setStatus(PropertyStatus::User3,false); } } } @@ -1086,9 +1077,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop }else if(prop == getLinkedObjectProperty()) { auto group = linkedPlainGroup(); if(getShowElementProperty()) - getShowElementProperty()->setStatus(Property::Hidden, !!group); + getShowElementProperty()->setStatus(Hidden, !!group); if(getElementCountProperty()) - getElementCountProperty()->setStatus(Property::Hidden, !!group); + getElementCountProperty()->setStatus(PropertyStatus::Hidden, !!group); if(group) updateGroup(); else if(_ChildCache.getSize()) @@ -1100,8 +1091,8 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop auto placement = getPlacementProperty(); if(linkPlacement && placement) { bool transform = getLinkTransformValue(); - placement->setStatus(Property::Hidden,transform); - linkPlacement->setStatus(Property::Hidden,!transform); + placement->setStatus(PropertyStatus::Hidden,transform); + linkPlacement->setStatus(PropertyStatus::Hidden,!transform); } syncElementList(); } @@ -1144,13 +1135,13 @@ void LinkBaseExtension::syncElementList() { element->myOwner = ownerID; - element->LinkTransform.setStatus(Property::Hidden,transform!=0); - element->LinkTransform.setStatus(Property::Immutable,transform!=0); + element->LinkTransform.setStatus(PropertyStatus::Hidden,transform!=0); + element->LinkTransform.setStatus(PropertyStatus::Immutable,transform!=0); if(transform && element->LinkTransform.getValue()!=transform->getValue()) element->LinkTransform.setValue(transform->getValue()); - element->LinkedObject.setStatus(Property::Hidden,link!=0); - element->LinkedObject.setStatus(Property::Immutable,link!=0); + element->LinkedObject.setStatus(PropertyStatus::Hidden,link!=0); + element->LinkedObject.setStatus(PropertyStatus::Immutable,link!=0); if(xlink) { if(element->LinkedObject.getValue()!=xlink->getValue() || element->LinkedObject.getSubValues()!=xlink->getSubValues()) @@ -1421,11 +1412,11 @@ static bool isExcludedProperties(const char *name) { return false; } -Property *LinkBaseExtension::extensionGetPropertyByName(const char* name) const { +Property *LinkBaseExtension::extensionGetPropertyByName(const string& name) const { if (checkingProperty) return inherited::extensionGetPropertyByName(name); Base::StateLocker guard(checkingProperty); - if(isExcludedProperties(name)) + if(isExcludedProperties(name.c_str())) return nullptr; auto owner = getContainer(); if (owner) { diff --git a/src/App/Link.h b/src/App/Link.h index ff06365ad9a3..efaa8b5ed494 100644 --- a/src/App/Link.h +++ b/src/App/Link.h @@ -269,7 +269,7 @@ class AppExport LinkBaseExtension : public App::DocumentObjectExtension virtual PyObject* getExtensionPyObject(void) override; - virtual Property *extensionGetPropertyByName(const char* name) const override; + virtual Property *extensionGetPropertyByName(const std::string& name) const override; static int getArrayIndex(const char *subname, const char **psubname=0); int getElementIndex(const char *subname, const char **psubname=0) const; diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp index be38bc2fc570..445ca2c072f2 100644 --- a/src/App/LinkBaseExtensionPyImp.cpp +++ b/src/App/LinkBaseExtensionPyImp.cpp @@ -164,12 +164,7 @@ PyObject* LinkBaseExtensionPy::getLinkExtPropertyName(PyObject *args) { PyErr_SetString(PyExc_RuntimeError, "no extended container"); return 0; } - name = container->getPropertyName(prop); - if(!name) { - PyErr_SetString(PyExc_RuntimeError, "cannot find property name"); - return 0; - } - return Py::new_reference_to(Py::String(name)); + return Py::new_reference_to(Py::String( prop->getName())); } PyObject* LinkBaseExtensionPy::getLinkPropertyInfo(PyObject *args) diff --git a/src/App/MeasureDistance.cpp b/src/App/MeasureDistance.cpp index d1bde29b1c53..b9835e59a5ac 100644 --- a/src/App/MeasureDistance.cpp +++ b/src/App/MeasureDistance.cpp @@ -37,7 +37,7 @@ MeasureDistance::MeasureDistance() { ADD_PROPERTY_TYPE(P1,(Base::Vector3d()),"Measurement",Prop_None,"First point of measurement"); ADD_PROPERTY_TYPE(P2,(Base::Vector3d()),"Measurement",Prop_None,"Second point of measurement"); - ADD_PROPERTY_TYPE(Distance,(0.0) ,"Measurement",App::PropertyType(Prop_ReadOnly|Prop_Output), + ADD_PROPERTY_TYPE(Distance,(0.0) ,"Measurement",Prop_ReadOnly+Prop_Output, "Distance between the points"); } diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index 0ac3f82b1a3d..4ede39eb9b6a 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -1272,7 +1272,7 @@ Property *ObjectIdentifier::resolveProperty(const App::DocumentObject *obj, } auto prop = obj->getPropertyByName(propertyName); - if(prop && !prop->testStatus(Property::Hidden) && !(prop->getType() & PropertyType::Prop_Hidden)) + if(prop && !prop->testStatus(PropertyStatus::Hidden) && !prop->testStatus(PropertyStatus::Prop_Hidden)) return prop; auto linked = obj->getLinkedObject(true); diff --git a/src/App/Origin.cpp b/src/App/Origin.cpp index ef3bab407388..be613f227adf 100644 --- a/src/App/Origin.cpp +++ b/src/App/Origin.cpp @@ -49,7 +49,7 @@ const char* Origin::AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"}; const char* Origin::PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"}; Origin::Origin(void) : extension(this) { - ADD_PROPERTY_TYPE ( OriginFeatures, (0), 0, App::Prop_Hidden, + ADD_PROPERTY_TYPE ( OriginFeatures, (0), "", Prop_Hidden, "Axis and baseplanes controlled by the origin" ); setStatus(App::NoAutoExpand,true); @@ -189,7 +189,7 @@ void Origin::unsetupObject () { Origin::OriginExtension::OriginExtension(Origin* obj) : obj(obj) { - Group.setStatus(Property::Transient, true); + Group.setStatus(Transient, true); } void Origin::OriginExtension::initExtension(ExtensionContainer* obj) { diff --git a/src/App/OriginFeature.cpp b/src/App/OriginFeature.cpp index 7bfb92b2fac0..1c40d9302600 100644 --- a/src/App/OriginFeature.cpp +++ b/src/App/OriginFeature.cpp @@ -38,10 +38,10 @@ PROPERTY_SOURCE(App::Line, App::OriginFeature) OriginFeature::OriginFeature() { - ADD_PROPERTY_TYPE ( Role, (""), 0, App::Prop_ReadOnly, "Role of the feature in the Origin" ) ; + ADD_PROPERTY_TYPE ( Role, (""), "", Prop_ReadOnly, "Role of the feature in the Origin" ) ; // Set placement to read-only - Placement.setStatus(Property::Hidden, true); + Placement.setStatus(Hidden, true); } OriginFeature::~OriginFeature() diff --git a/src/App/OriginGroupExtension.cpp b/src/App/OriginGroupExtension.cpp index 52a97dd4564e..4c1a67f51287 100644 --- a/src/App/OriginGroupExtension.cpp +++ b/src/App/OriginGroupExtension.cpp @@ -44,7 +44,7 @@ OriginGroupExtension::OriginGroupExtension () { initExtensionType(OriginGroupExtension::getExtensionClassTypeId()); - EXTENSION_ADD_PROPERTY_TYPE ( Origin, (0), 0, App::Prop_Hidden, "Origin linked to the group" ); + EXTENSION_ADD_PROPERTY_TYPE ( Origin, (0), "" , Prop_Hidden, "Origin linked to the group" ); Origin.setScope(LinkScope::Child); } diff --git a/src/App/Part.cpp b/src/App/Part.cpp index c56bee1c847e..af473941a522 100644 --- a/src/App/Part.cpp +++ b/src/App/Part.cpp @@ -46,17 +46,17 @@ PROPERTY_SOURCE_WITH_EXTENSIONS(App::Part, App::GeoFeature) Part::Part(void) { ADD_PROPERTY(Type,("")); - ADD_PROPERTY_TYPE(Material, (), 0, App::Prop_None, "Map with material properties"); - ADD_PROPERTY_TYPE(Meta, (), 0, App::Prop_None, "Map with additional meta information"); + ADD_PROPERTY_TYPE(Material, (), "", Prop_None, "Map with material properties"); + ADD_PROPERTY_TYPE(Meta, (), "", Prop_None, "Map with additional meta information"); // create the uuid for the document Base::Uuid id; - ADD_PROPERTY_TYPE(Id, (""), 0, App::Prop_None, "ID (Part-Number) of the Item"); - ADD_PROPERTY_TYPE(Uid, (id), 0, App::Prop_None, "UUID of the Item"); + ADD_PROPERTY_TYPE(Id, (""), "", Prop_None, "ID (Part-Number) of the Item"); + ADD_PROPERTY_TYPE(Uid, (id), "", Prop_None, "UUID of the Item"); // license stuff (leave them empty to avoid confusion with imported 3rd party STEP/IGES files) - ADD_PROPERTY_TYPE(License, (""), 0, App::Prop_None, "License string of the Item"); - ADD_PROPERTY_TYPE(LicenseURL, (""), 0, App::Prop_None, "URL to the license text/contract"); + ADD_PROPERTY_TYPE(License, (""), "", Prop_None, "License string of the Item"); + ADD_PROPERTY_TYPE(LicenseURL, (""), "", Prop_None, "URL to the license text/contract"); // color and appearance ADD_PROPERTY(Color, (1.0, 1.0, 1.0, 1.0)); // set transparent -> not used diff --git a/src/App/Property.cpp b/src/App/Property.cpp index b0ab46c021b7..ef05cf39266f 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -50,7 +50,7 @@ TYPESYSTEM_SOURCE_ABSTRACT(App::Property , Base::Persistence) // Here is the implementation! Description should take place in the header file! Property::Property() - :father(0), myName(0) + :father(0), propertySpec() { } @@ -60,57 +60,36 @@ Property::~Property() } -const char* Property::getName(void) const +std::string Property::getName(void) const { - return myName; + if(propertySpec) + return propertySpec->Name; + return ""; } std::string Property::getFullName() const { std::string name; - if(myName) { + if (!getName().empty()) { if(father) name = father->getFullName() + "."; - name += myName; + name += getName(); }else return "?"; return name; } -short Property::getType(void) const +const std::string Property::getGroup(void) const { - short type = 0; -#define GET_PTYPE(_name) do {\ - if(testStatus(App::Property::Prop##_name)) type|=Prop_##_name;\ - }while(0) - GET_PTYPE(ReadOnly); - GET_PTYPE(Hidden); - GET_PTYPE(Output); - GET_PTYPE(Transient); - GET_PTYPE(NoRecompute); - GET_PTYPE(NoPersist); - return type; + if(propertySpec) + return propertySpec->Group; + return ""; } -void Property::syncType(unsigned type) { -#define SYNC_PTYPE(_name) do{\ - if(type & Prop_##_name) StatusBits.set((size_t)Prop##_name);\ - }while(0) - SYNC_PTYPE(ReadOnly); - SYNC_PTYPE(Transient); - SYNC_PTYPE(Hidden); - SYNC_PTYPE(Output); - SYNC_PTYPE(NoRecompute); - SYNC_PTYPE(NoPersist); -} - -const char* Property::getGroup(void) const -{ - return father->getPropertyGroup(this); -} - -const char* Property::getDocumentation(void) const +const std::string Property::getDocumentation(void) const { - return father->getPropertyDocumentation(this); + if(propertySpec) + return propertySpec->Docu; + return ""; } void Property::setContainer(PropertyContainer *Father) @@ -196,25 +175,10 @@ void Property::destroy(Property *p) { } } -void Property::touch() -{ - PropertyCleaner guard(this); - if (father) - father->onChanged(this); - StatusBits.set(Touched); -} - -void Property::setReadOnly(bool readOnly) -{ - this->setStatus(App::Property::ReadOnly, readOnly); -} - void Property::hasSetValue(void) { - PropertyCleaner guard(this); - if (father) - father->onChanged(this); - StatusBits.set(Touched); + setStatus(Touched,false); + setStatus(Touched); } void Property::aboutToSetValue(void) @@ -241,32 +205,17 @@ void Property::Paste(const Property& /*from*/) assert(0); } -void Property::setStatusValue(unsigned long status) { - static const unsigned long mask = - (1<onPropertyStatusChanged(*this,oldStatus); +void Property::onStatusChanged(const PropertyStatus& status, bool newValue ) { + (void)newValue; + if( father ) + father->onPropertyStatusChanged(*this,status); + if( father && status == Touched && newValue) + { + PropertyCleaner guard(this); + father->onChanged(this); } } -void Property::setStatus(Status pos, bool on) { - auto bits = StatusBits; - bits.set(pos,on); - setStatusValue(bits.to_ulong()); -} //************************************************************************** //************************************************************************** // PropertyListsBase diff --git a/src/App/Property.h b/src/App/Property.h index 7a1cc6494403..9e8e1635a349 100644 --- a/src/App/Property.h +++ b/src/App/Property.h @@ -28,9 +28,10 @@ #include #include +#include "StatusContainer.h" #include #include -#include +#include namespace Py { class Object; @@ -41,6 +42,60 @@ namespace App class PropertyContainer; class ObjectIdentifier; +struct AppExport PropertySpec +{ + const std::string Name; + const std::string Group; + const std::string Docu; + const short Offset; + + inline PropertySpec(const std::string& name,const std::string& group, const std::string& doc, short offset) + :Name(name),Group(group),Docu(doc), Offset(offset) + {} +}; + + +enum PropertyStatus //Do not edit values, they are persisted +{ + Touched = 0, // touched property + Immutable = 1, // can't modify property + ReadOnly = 2, // for property editor + Hidden = 3, // for property editor + Transient = 4, // for property container save + MaterialEdit = 5, // to turn ON PropertyMaterial edit + NoMaterialListEdit = 6, // to turn OFF PropertyMaterialList edit + Output = 7, // same effect as Prop_Output + LockDynamic = 8, // prevent being removed from dynamic property + NoModify = 9, // prevent causing Gui::Document::setModified() + PartialTrigger = 10, // allow change in partial doc + NoRecompute = 11, // touch owner for recompute on property change + Single = 12, // for save/load of floating point numbers + Ordered = 13, // for PropertyLists whether the order of the elements is + // relevant for the container using it + EvalOnRestore = 14, // In case of expression binding, evaluate the + // expression on restore and touch the object on value change. + + // The following bits are corresponding to PropertyType set when the + // property added. These types are meant to be static, and cannot be + // changed in runtime. + + Prop_StaticBegin = 21, + Prop_Dynamic = 21, // indicating the property is dynamically added + Prop_NoPersist = 22, // corresponding to Prop_NoPersist + Prop_NoRecompute = 23, // corresponding to Prop_NoRecompute + Prop_ReadOnly = 24, // corresponding to Prop_ReadOnly + Prop_Transient= 25, // corresponding to Prop_Transient + Prop_Hidden = 26, // corresponding to Prop_Hidden + Prop_Output = 27, // corresponding to Prop_Output + Prop_StaticEnd = 28, + + User1 = 28, // user-defined status + User2 = 29, // user-defined status + User3 = 30, // user-defined status + User4 = 31 // user-defined status +}; +//Readability shortcut, it can be replaced by an empty initializer list: '{}' +constexpr StatusCollection Prop_None= StatusCollection(); /** Base class of all properties * This is the father of all properties. Properties are objects which are used @@ -51,51 +106,11 @@ class ObjectIdentifier; * possible properties. It is also possible to define user properties * and use them in the framework... */ -class AppExport Property : public Base::Persistence +class AppExport Property : public Base::Persistence , public StatusContainer { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - enum Status - { - Touched = 0, // touched property - Immutable = 1, // can't modify property - ReadOnly = 2, // for property editor - Hidden = 3, // for property editor - Transient = 4, // for property container save - MaterialEdit = 5, // to turn ON PropertyMaterial edit - NoMaterialListEdit = 6, // to turn OFF PropertyMaterialList edit - Output = 7, // same effect as Prop_Output - LockDynamic = 8, // prevent being removed from dynamic property - NoModify = 9, // prevent causing Gui::Document::setModified() - PartialTrigger = 10, // allow change in partial doc - NoRecompute = 11, // touch owner for recompute on property change - Single = 12, // for save/load of floating point numbers - Ordered = 13, // for PropertyLists whether the order of the elements is - // relevant for the container using it - EvalOnRestore = 14, // In case of expression binding, evaluate the - // expression on restore and touch the object on value change. - - // The following bits are corresponding to PropertyType set when the - // property added. These types are meant to be static, and cannot be - // changed in runtime. It is mirrored here to save the linear search - // required in PropertyContainer::getPropertyType() - // - PropStaticBegin = 21, - PropDynamic = 21, // indicating the property is dynamically added - PropNoPersist = 22, // corresponding to Prop_NoPersist - PropNoRecompute = 23, // corresponding to Prop_NoRecompute - PropReadOnly = 24, // corresponding to Prop_ReadOnly - PropTransient= 25, // corresponding to Prop_Transient - PropHidden = 26, // corresponding to Prop_Hidden - PropOutput = 27, // corresponding to Prop_Output - PropStaticEnd = 28, - - User1 = 28, // user-defined status - User2 = 29, // user-defined status - User3 = 30, // user-defined status - User4 = 31 // user-defined status - }; Property(); virtual ~Property(); @@ -111,25 +126,22 @@ class AppExport Property : public Base::Persistence */ virtual unsigned int getMemSize (void) const override { // you have to implement this method in all property classes! - return sizeof(father) + sizeof(StatusBits); + return sizeof(father) + sizeof(StatusContainer); } /// get the name of this property in the belonging container - const char* getName(void) const; + std::string getName(void) const; std::string getFullName() const; /// Get the class name of the associated property editor item virtual const char* getEditorName(void) const { return ""; } - /// Get the type of the property in the container - short getType(void) const; - /// Get the group of this property - const char* getGroup(void) const; + const std::string getGroup(void) const; /// Get the documentation of this property - const char* getDocumentation(void) const; + const std::string getDocumentation(void) const; /// Is called by the framework to set the father (container) void setContainer(PropertyContainer *Father); @@ -189,38 +201,13 @@ class AppExport Property : public Base::Persistence */ //@{ /// Set the property touched - void touch(); + inline void touch() {setStatus(Touched); } /// Test if this property is touched inline bool isTouched(void) const { - return StatusBits.test(Touched); + return testStatus(Touched); } /// Reset this property touched - inline void purgeTouched(void) { - StatusBits.reset(Touched); - } - /// return the status bits - inline unsigned long getStatus() const { - return StatusBits.to_ulong(); - } - inline bool testStatus(Status pos) const { - return StatusBits.test(static_cast(pos)); - } - void setStatus(Status pos, bool on); - void setStatusValue(unsigned long status); - ///Sets property editable/grayed out in property editor - void setReadOnly(bool readOnly); - inline bool isReadOnly() const { - return testStatus(App::Property::ReadOnly); - } - /// Sets precision of properties using floating point - /// numbers to single, the default is double. - void setSinglePrecision(bool single) { - setStatus(App::Property::Single, single); - } - /// Gets precision of properties using floating point numbers - inline bool isSinglePrecision() const { - return testStatus(App::Property::Single); - } + inline void purgeTouched(void) { setStatus(Touched, false); } //@} /// Returns a new copy of the property (mainly for Undo/Redo and transactions) @@ -232,24 +219,10 @@ class AppExport Property : public Base::Persistence virtual void hasSetChildValue(Property &) {} /// Called before a child property changing value virtual void aboutToSetChildValue(Property &) {} - - friend class PropertyContainer; - friend struct PropertyData; - friend class DynamicProperty; - -protected: - /** Status bits of the property - * The first 8 bits are used for the base system the rest can be used in - * descendent classes to mark special statuses on the objects. - * The bits and their meaning are listed below: - * 0 - object is marked as 'touched' - * 1 - object is marked as 'immutable' - * 2 - object is marked as 'read-only' (for property editor) - * 3 - object is marked as 'hidden' (for property editor) - */ - std::bitset<32> StatusBits; - + void setPropertySpec(const std::shared_ptr & spec) { if(!propertySpec) propertySpec=spec; } + std::shared_ptr getPropertySpec() const {return propertySpec; } protected: + virtual void onStatusChanged(const PropertyStatus& status, bool newValue ) override; /// Gets called by all setValue() methods after the value has changed virtual void hasSetValue(void); /// Gets called by all setValue() methods before the value has changed @@ -263,12 +236,9 @@ class AppExport Property : public Base::Persistence Property(const Property&); Property& operator = (const Property&); - // Sync status with Property_Type - void syncType(unsigned type); - private: PropertyContainer *father; - const char *myName; + std::shared_ptr propertySpec; }; @@ -390,8 +360,8 @@ template class AtomicPropertyChangeInterface { class AppExport PropertyListsBase { public: - virtual void setSize(int newSize)=0; - virtual int getSize(void) const =0; + virtual void setSize(int newSize)=0; + virtual int getSize(void) const =0; const std::set &getTouchList() const { return _touchList; @@ -431,8 +401,8 @@ class AppExport PropertyLists : public Property, public PropertyListsBase // if the order of the elements in the list relevant? // if yes, certain operations, like restoring must make sure that the // order is kept despite errors. - inline void setOrderRelevant(bool on) { this->setStatus(Status::Ordered,on); }; - inline bool isOrderRelevant() const { return this->testStatus(Status::Ordered);} + inline void setOrderRelevant(bool on) { this->setStatus(Ordered,on); }; + inline bool isOrderRelevant() const { return this->testStatus(Ordered);} }; @@ -484,7 +454,7 @@ class PropertyListsT: public ParentT // alias to getValues const ListT &getValue(void) const{return getValues();} - const_reference operator[] (int idx) const {return _lValueList[idx];} + const_reference operator[] (int idx) const {return _lValueList[idx];} virtual void setPyObject(PyObject *value) override { try { @@ -511,7 +481,7 @@ class PropertyListsT: public ParentT protected: - void setPyValues(const std::vector &vals, const std::vector &indices) override + void setPyValues(const std::vector &vals, const std::vector &indices) override { if (indices.empty()) { ListT values; diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 5fda5ce27906..b5967c417b0b 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -76,15 +76,14 @@ unsigned int PropertyContainer::getMemSize (void) const App::Property* PropertyContainer::addDynamicProperty( - const char* type, const char* name, const char* group, const char* doc, - short attr, bool ro, bool hidden) + const std::string& type, const std::string& name, const std::string& group, const std::string& doc) { - return dynamicProps.addDynamicProperty(*this,type,name,group,doc,attr,ro,hidden); + return dynamicProps.addDynamicProperty(*this,type,name,group,doc); } -Property *PropertyContainer::getPropertyByName(const char* name) const +Property *PropertyContainer::getPropertyByName(const std::string& name) const { - auto prop = dynamicProps.getDynamicPropertyByName(name); + auto *prop = dynamicProps.getDynamicPropertyByName(name); if(prop) return prop; return getPropertyData().getPropertyByName(this,name); } @@ -101,78 +100,19 @@ void PropertyContainer::getPropertyList(std::vector &List) const getPropertyData().getPropertyList(this,List); } -void PropertyContainer::setPropertyStatus(unsigned char bit,bool value) +void PropertyContainer::setPropertyStatus(PropertyStatus bit,bool value) const { std::vector List; getPropertyList(List); for(std::vector::const_iterator it=List.begin();it!=List.end();++it) - (**it).StatusBits.set(bit,value); -} - -short PropertyContainer::getPropertyType(const Property* prop) const -{ - return prop?prop->getType():0; -} - -short PropertyContainer::getPropertyType(const char *name) const -{ - return getPropertyType(getPropertyByName(name)); -} - -const char* PropertyContainer::getPropertyGroup(const Property* prop) const -{ - auto group = dynamicProps.getPropertyGroup(prop); - if(group) return group; - return getPropertyData().getGroup(this,prop); -} - -const char* PropertyContainer::getPropertyGroup(const char *name) const -{ - auto group = dynamicProps.getPropertyGroup(name); - if(group) return group; - return getPropertyData().getGroup(this,name); -} - -const char* PropertyContainer::getPropertyDocumentation(const Property* prop) const -{ - auto doc = dynamicProps.getPropertyDocumentation(prop); - if(doc) return doc; - return getPropertyData().getDocumentation(this,prop); -} - -const char* PropertyContainer::getPropertyDocumentation(const char *name) const -{ - auto doc = dynamicProps.getPropertyDocumentation(name); - if(doc) return doc; - return getPropertyData().getDocumentation(this,name); -} - -bool PropertyContainer::isReadOnly(const Property* prop) const -{ - return (getPropertyType(prop) & Prop_ReadOnly) == Prop_ReadOnly; -} - -bool PropertyContainer::isReadOnly(const char *name) const -{ - return (getPropertyType(name) & Prop_ReadOnly) == Prop_ReadOnly; -} - -bool PropertyContainer::isHidden(const Property* prop) const -{ - return (getPropertyType(prop) & Prop_Hidden) == Prop_Hidden; + { + (**it).setStatus(bit,value); + } } -bool PropertyContainer::isHidden(const char *name) const -{ - return (getPropertyType(name) & Prop_Hidden) == Prop_Hidden; -} -const char* PropertyContainer::getPropertyName(const Property* prop)const -{ - auto res = dynamicProps.getPropertyName(prop); - if(!res) - res = getPropertyData().getName(this,prop); - return res; +bool PropertyContainer::isOwnerOf(const Property & prop) const { + return prop.getContainer() == this; } const PropertyData * PropertyContainer::getPropertyDataPtr(void){return &propertyData;} @@ -218,7 +158,7 @@ void PropertyContainer::handleChangedPropertyType(XMLReader &reader, const char PropertyData PropertyContainer::propertyData; -void PropertyContainer::Save (Base::Writer &writer) const +void PropertyContainer::Save (Base::Writer &writer) const { std::map Map; getPropertyMap(Map); @@ -226,13 +166,13 @@ void PropertyContainer::Save (Base::Writer &writer) const std::vector transients; for(auto it=Map.begin();it!=Map.end();) { auto prop = it->second; - if(prop->testStatus(Property::PropNoPersist)) { + if(prop->testStatus(PropertyStatus::Prop_NoPersist)) { it = Map.erase(it); continue; } - if(!prop->testStatus(Property::PropDynamic) - && (prop->testStatus(Property::Transient) || - getPropertyType(prop) & Prop_Transient)) + if(!prop->testStatus(PropertyStatus::Prop_Dynamic) + && (prop->testStatus(PropertyStatus::Transient) || + prop->testStatus(PropertyStatus::Prop_Transient))) { transients.push_back(prop); it = Map.erase(it); @@ -249,9 +189,9 @@ void PropertyContainer::Save (Base::Writer &writer) const // older versions of FC. writer.incInd(); for(auto prop : transients) { - writer.Stream() << writer.ind() << "<_Property name=\"" << prop->getName() - << "\" type=\"" << prop->getTypeId().getName() - << "\" status=\"" << prop->getStatus() << "\"/>" << std::endl; + writer.Stream() << writer.ind() << "<_Property name=\"" << prop->getName() + << "\" type=\"" << prop->getTypeId().getName() + << "\" status=\"" << prop->getStatus().to_ullong() << "\"/>" << std::endl; } writer.decInd(); @@ -259,18 +199,16 @@ void PropertyContainer::Save (Base::Writer &writer) const for (auto it = Map.begin(); it != Map.end(); ++it) { writer.incInd(); // indentation for 'Property name' - writer.Stream() << writer.ind() << "first << "\" type=\"" + writer.Stream() << writer.ind() << "first << "\" type=\"" << it->second->getTypeId().getName(); dynamicProps.save(it->second,writer); - auto status = it->second->getStatus(); - if(status) - writer.Stream() << "\" status=\"" << status; - writer.Stream() << "\">"; + auto status = it->second->getStatus().to_ullong(); + writer.Stream() << "\" status=\"" << status << "\">"; - if(it->second->testStatus(Property::Transient) - || it->second->getType() & Prop_Transient) + if(it->second->testStatus(PropertyStatus::Transient) + || it->second->testStatus(PropertyStatus::Prop_Transient) ) { writer.decInd(); writer.Stream() << "" << std::endl; @@ -278,7 +216,7 @@ void PropertyContainer::Save (Base::Writer &writer) const } writer.Stream() << std::endl; - + writer.incInd(); // indentation for the actual property try { @@ -302,7 +240,7 @@ void PropertyContainer::Save (Base::Writer &writer) const } #endif writer.decInd(); // indentation for the actual property - writer.Stream() << writer.ind() << "" << endl; + writer.Stream() << writer.ind() << "" << endl; writer.decInd(); // indentation for 'Property name' } writer.Stream() << writer.ind() << "" << endl; @@ -324,8 +262,11 @@ void PropertyContainer::Restore(Base::XMLReader &reader) Property* prop = getPropertyByName(reader.getAttribute("name")); if(prop) FC_TRACE("restore transient '" << prop->getName() << "'"); - if(prop && reader.hasAttribute("status")) - prop->setStatusValue(reader.getAttributeAsUnsigned("status")); + if(prop && reader.hasAttribute("status")) { + auto status= StatusCollection(reader.getAttribute("status")); + prop->setStatus(status); + } + } for (int i=0 ;isetStatusValue(status.to_ulong()); + if(prop && reader.hasAttribute("status")) { + auto status= StatusCollection(reader.getAttribute("status")); + prop->setStatus(status); } // NOTE: We must also check the type of the current property because a // subclass of PropertyContainer might change the type of a property but @@ -349,10 +288,8 @@ void PropertyContainer::Restore(Base::XMLReader &reader) try { // name and type match if (prop && strcmp(prop->getTypeId().getName(), TypeName.c_str()) == 0) { - if (!prop->testStatus(Property::Transient) - && !status.test(Property::Transient) - && !status.test(Property::PropTransient) - && !(getPropertyType(prop) & Prop_Transient)) + if (!prop->testStatus(PropertyStatus::Transient) + && !prop->testStatus(PropertyStatus::Prop_Transient)) { FC_TRACE("restore property '" << prop->getName() << "'"); prop->Restore(reader); @@ -401,16 +338,16 @@ void PropertyContainer::Restore(Base::XMLReader &reader) reader.readEndElement("Properties"); } -void PropertyContainer::onPropertyStatusChanged(const Property &prop, unsigned long oldStatus) +void PropertyContainer::onPropertyStatusChanged(const Property &prop, const App::PropertyStatus& status) { (void)prop; - (void)oldStatus; + (void)status; } -void PropertyData::addProperty(OffsetBase offsetBase,const char* PropName, Property *Prop, const char* PropertyGroup , PropertyType Type, const char* PropertyDocu) +void PropertyData::addProperty(OffsetBase offsetBase, const std::string& PropName, Property *Prop, const std::string& PropertyGroup , const std::string& PropertyDocu) { #ifdef FC_DEBUG - if(!parentMerged) + if(!parentMerged) #endif { short offset = offsetBase.getOffsetTo(Prop); @@ -421,18 +358,16 @@ void PropertyData::addProperty(OffsetBase offsetBase,const char* PropName, Prope if(it == index.end()) { if(parentMerged) throw Base::RuntimeError("Cannot add static property"); - index.emplace(PropName, PropertyGroup, PropertyDocu, offset, Type); + index.insert(std::shared_ptr(new PropertySpec(PropName, PropertyGroup, PropertyDocu, offset))); } else{ #ifdef FC_DEBUG - if(it->Offset != offset) { + if((*it)->Offset != offset) { FC_ERR("Duplicate property '" << PropName << "'"); } #endif - } + } } - - Prop->syncType(Type); - Prop->myName = PropName; + Prop->setPropertySpec(*(propertyData.get<1>().find(PropName))); } void PropertyData::merge(PropertyData *other) const { @@ -446,7 +381,7 @@ void PropertyData::merge(PropertyData *other) const { if(other) { other->merge(); auto &index = propertyData.get<0>(); - for(const auto &spec : other->propertyData.get<0>()) + for(auto &spec : other->propertyData.get<0>()) index.push_back(spec); } } @@ -459,110 +394,28 @@ void PropertyData::split(PropertyData *other) { } if(other) { auto &index = propertyData.get<2>(); - for(const auto &spec : other->propertyData.get<0>()) - index.erase(spec.Offset); + for(const auto &spec : other->propertyData.get<0>()) { + const short offset = spec->Offset; + index.erase(offset); + } + } } -const PropertyData::PropertySpec *PropertyData::findProperty(OffsetBase offsetBase,const char* PropName) const +std::shared_ptr PropertyData::findProperty(OffsetBase offsetBase,const std::string& PropName) const { (void)offsetBase; merge(); auto &index = propertyData.get<1>(); auto it = index.find(PropName); if(it != index.end()) - return &(*it); - return 0; -} - -const PropertyData::PropertySpec *PropertyData::findProperty(OffsetBase offsetBase,const Property* prop) const -{ - merge(); - int diff = offsetBase.getOffsetTo(prop); - if(diff<0) - return 0; - - auto &index = propertyData.get<2>(); - auto it = index.find(diff); - if(it!=index.end()) - return &(*it); - - return 0; -} - -const char* PropertyData::getName(OffsetBase offsetBase,const Property* prop) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,prop); - - if(Spec) - return Spec->Name; - else - return 0; -} - -short PropertyData::getType(OffsetBase offsetBase,const Property* prop) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,prop); - - if(Spec) - return Spec->Type; - else - return 0; -} - -short PropertyData::getType(OffsetBase offsetBase,const char* name) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,name); - - if(Spec) - return Spec->Type; - else - return 0; -} - -const char* PropertyData::getGroup(OffsetBase offsetBase,const Property* prop) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,prop); - - if(Spec) - return Spec->Group; - else - return 0; -} - -const char* PropertyData::getGroup(OffsetBase offsetBase,const char* name) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,name); - - if(Spec) - return Spec->Group; - else - return 0; -} - -const char* PropertyData::getDocumentation(OffsetBase offsetBase,const Property* prop) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,prop); - - if(Spec) - return Spec->Docu; - else - return 0; -} - -const char* PropertyData::getDocumentation(OffsetBase offsetBase,const char* name) const -{ - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,name); - - if(Spec) - return Spec->Docu; - else + return *it; return 0; } -Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const char* name) const +Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const std::string& name) const { - const PropertyData::PropertySpec* Spec = findProperty(offsetBase,name); + auto Spec = findProperty(offsetBase,name); if(Spec) return (Property *) (Spec->Offset + offsetBase.getOffset()); @@ -573,8 +426,8 @@ Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const char* name void PropertyData::getPropertyMap(OffsetBase offsetBase,std::map &Map) const { merge(); - for(auto &spec : propertyData.get<0>()) - Map[spec.Name] = (Property *) (spec.Offset + offsetBase.getOffset()); + for(auto &spec : propertyData.get<0>()) + Map[spec->Name] = (Property *) (spec->Offset + offsetBase.getOffset()); } void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector &List) const @@ -583,7 +436,7 @@ void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector size_t base = List.size(); List.reserve(base+propertyData.size()); for (auto &spec : propertyData.get<0>()) - List.push_back((Property *) (spec.Offset + offsetBase.getOffset())); + List.push_back((Property *) (spec->Offset + offsetBase.getOffset())); } diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index bb03473cec59..749f9271a40f 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -28,7 +28,7 @@ #include #include #include - +#include "Property.h" #include "DynamicProperty.h" namespace Base { @@ -38,35 +38,12 @@ class Writer; namespace App { -class Property; class PropertyContainer; class DocumentObject; class Extension; -enum PropertyType -{ - Prop_None = 0, /*!< No special property type */ - Prop_ReadOnly = 1, /*!< Property is read-only in the editor */ - Prop_Transient = 2, /*!< Property content won't be saved to file, but still saves name, type and status */ - Prop_Hidden = 4, /*!< Property won't appear in the editor */ - Prop_Output = 8, /*!< Modified property doesn't touch its parent container */ - Prop_NoRecompute = 16,/*!< Modified property doesn't touch its container for recompute */ - Prop_NoPersist = 32,/*!< Property won't be saved to file at all */ -}; - struct AppExport PropertyData { - struct PropertySpec - { - const char * Name; - const char * Group; - const char * Docu; - short Offset, Type; - - inline PropertySpec(const char *name, const char *group, const char *doc, short offset, short type) - :Name(name),Group(group),Docu(doc),Offset(offset),Type(type) - {} - }; //purpose of this struct is to be constructible from all acceptable container types and to //be able to return the offset to a property from the accepted containers. This allows to use @@ -96,16 +73,14 @@ struct AppExport PropertyData // * hash index on property name // * hash index on property pointer offset mutable bmi::multi_index_container< - PropertySpec, + std::shared_ptr, bmi::indexed_by< bmi::sequenced<>, bmi::hashed_unique< - bmi::member, - CStringHasher, - CStringHasher + bmi::member >, bmi::hashed_unique< - bmi::member + bmi::member > > > propertyData; @@ -114,20 +89,11 @@ struct AppExport PropertyData const PropertyData* parentPropertyData; - void addProperty(OffsetBase offsetBase,const char* PropName, Property *Prop, const char* PropertyGroup= 0, PropertyType = Prop_None, const char* PropertyDocu= 0 ); - - const PropertySpec *findProperty(OffsetBase offsetBase,const char* PropName) const; - const PropertySpec *findProperty(OffsetBase offsetBase,const Property* prop) const; + void addProperty(OffsetBase offsetBase, const std::string& PropName, Property *Prop, const std::string& PropertyGroup, const std::string& PropertyDocu ); - const char* getName (OffsetBase offsetBase,const Property* prop) const; - short getType (OffsetBase offsetBase,const Property* prop) const; - short getType (OffsetBase offsetBase,const char* name) const; - const char* getGroup (OffsetBase offsetBase,const char* name) const; - const char* getGroup (OffsetBase offsetBase,const Property* prop) const; - const char* getDocumentation(OffsetBase offsetBase,const char* name) const; - const char* getDocumentation(OffsetBase offsetBase,const Property* prop) const; + std::shared_ptr findProperty(OffsetBase offsetBase,const std::string& PropName) const; - Property *getPropertyByName(OffsetBase offsetBase,const char* name) const; + Property *getPropertyByName(OffsetBase offsetBase,const std::string& name) const; void getPropertyMap(OffsetBase offsetBase,std::map &Map) const; void getPropertyList(OffsetBase offsetBase,std::vector &List) const; @@ -161,56 +127,33 @@ class AppExport PropertyContainer: public Base::Persistence virtual std::string getFullName() const {return std::string();} /// find a property by its name - virtual Property *getPropertyByName(const char* name) const; - /// get the name of a property - virtual const char* getPropertyName(const Property* prop) const; + virtual Property *getPropertyByName(const std::string& name) const; /// get all properties of the class (including properties of the parent) virtual void getPropertyMap(std::map &Map) const; /// get all properties of the class (including properties of the parent) virtual void getPropertyList(std::vector &List) const; /// set the Status bit of all properties at once - void setPropertyStatus(unsigned char bit,bool value); - - /// get the Type of a Property - virtual short getPropertyType(const Property* prop) const; - /// get the Type of a named Property - virtual short getPropertyType(const char *name) const; - /// get the Group of a Property - virtual const char* getPropertyGroup(const Property* prop) const; - /// get the Group of a named Property - virtual const char* getPropertyGroup(const char *name) const; - /// get the Group of a Property - virtual const char* getPropertyDocumentation(const Property* prop) const; - /// get the Group of a named Property - virtual const char* getPropertyDocumentation(const char *name) const; - /// check if the property is read-only - bool isReadOnly(const Property* prop) const; - /// check if the named property is read-only - bool isReadOnly(const char *name) const; - /// check if the property is hidden - bool isHidden(const Property* prop) const; - /// check if the named property is hidden - bool isHidden(const char *name) const; + void setPropertyStatus(PropertyStatus bit,bool value) const; + + /// test if a property is owned by this container + virtual bool isOwnerOf(const Property & prop) const; virtual App::Property* addDynamicProperty( - const char* type, const char* name=0, - const char* group=0, const char* doc=0, - short attr=0, bool ro=false, bool hidden=false); + const std::string& type, const std::string& name, + const std::string& group,const std::string& doc + ); - DynamicProperty::PropData getDynamicPropertyData(const Property* prop) const { - return dynamicProps.getDynamicPropertyData(prop); - } - virtual bool removeDynamicProperty(const char* name) { + virtual bool removeDynamicProperty(const std::string& name) { return dynamicProps.removeDynamicProperty(name); } virtual std::vector getDynamicPropertyNames() const { return dynamicProps.getDynamicPropertyNames(); } - virtual App::Property *getDynamicPropertyByName(const char* name) const { + virtual App::Property *getDynamicPropertyByName(const std::string& name) const { return dynamicProps.getDynamicPropertyByName(name); } - virtual void onPropertyStatusChanged(const Property &prop, unsigned long oldStatus); + virtual void onPropertyStatusChanged(const Property &prop, const App::PropertyStatus& status); virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); @@ -257,8 +200,9 @@ class AppExport PropertyContainer: public Base::Persistence #define _ADD_PROPERTY(_name,_prop_, _defaultval_) \ do { \ this->_prop_.setValue _defaultval_;\ + this->_prop_.setStatus(App::PropertyStatus::Touched, false); \ this->_prop_.setContainer(this); \ - propertyData.addProperty(static_cast(this), _name, &this->_prop_); \ + propertyData.addProperty(static_cast(this), _name, &this->_prop_, std::string(), std::string() ); \ } while (0) #define ADD_PROPERTY(_prop_, _defaultval_) \ @@ -267,8 +211,10 @@ class AppExport PropertyContainer: public Base::Persistence #define _ADD_PROPERTY_TYPE(_name,_prop_, _defaultval_, _group_,_type_,_Docu_) \ do { \ this->_prop_.setValue _defaultval_;\ + this->_prop_.setStatus(App::PropertyStatus::Touched, false); \ + this->_prop_.setStatus(_type_); \ this->_prop_.setContainer(this); \ - propertyData.addProperty(static_cast(this), _name, &this->_prop_, (_group_),(_type_),(_Docu_)); \ + propertyData.addProperty(static_cast(this), _name, &this->_prop_, (_group_),(_Docu_)); \ } while (0) #define ADD_PROPERTY_TYPE(_prop_, _defaultval_, _group_,_type_,_Docu_) \ diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index f1775bb1270f..568353d4193c 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -102,16 +102,15 @@ PyObject* PropertyContainerPy::getTypeOfProperty(PyObject *args) return 0; } - short Type = prop->getType(); - if (Type & Prop_Hidden) + if (prop->testStatus(Prop_Hidden)) ret.append(Py::String("Hidden")); - if (Type & Prop_ReadOnly) + if (prop->testStatus(Prop_ReadOnly)) ret.append(Py::String("ReadOnly")); - if (Type & Prop_Output) + if (prop->testStatus(Prop_Output)) ret.append(Py::String("Output")); - if (Type & Prop_NoRecompute) + if (prop->testStatus(Prop_NoRecompute)) ret.append(Py::String("NoRecompute")); - if (Type & Prop_Transient) + if (prop->testStatus(Prop_Transient)) ret.append(Py::String("Transient")); return Py::new_reference_to(ret); @@ -144,10 +143,8 @@ PyObject* PropertyContainerPy::setEditorMode(PyObject *args) return 0; } - std::bitset<32> status(prop->getStatus()); - status.set(Property::ReadOnly, (type & 1) > 0); - status.set(Property::Hidden, (type & 2) > 0); - prop->setStatusValue(status.to_ulong()); + prop->setStatus(PropertyStatus::ReadOnly, (type & 1) > 0); + prop->setStatus(PropertyStatus::Hidden, (type & 2) > 0); Py_Return; } @@ -163,18 +160,17 @@ PyObject* PropertyContainerPy::setEditorMode(PyObject *args) return 0; } - // reset all bits first - std::bitset<32> status(prop->getStatus()); - status.reset(Property::ReadOnly); - status.reset(Property::Hidden); + bool readOnly=false; + bool hidden = false; for (Py::Sequence::iterator it = seq.begin();it!=seq.end();++it) { std::string str = (std::string)Py::String(*it); if (str == "ReadOnly") - status.set(Property::ReadOnly); + readOnly=true; else if (str == "Hidden") - status.set(Property::Hidden); + hidden=true; } - prop->setStatusValue(status.to_ulong()); + prop->setStatus(PropertyStatus::ReadOnly, readOnly); + prop->setStatus(PropertyStatus::Hidden, hidden); Py_Return; } @@ -187,16 +183,16 @@ PyObject* PropertyContainerPy::setEditorMode(PyObject *args) static const std::map &getStatusMap() { static std::map statusMap; if(statusMap.empty()) { - statusMap["Immutable"] = Property::Immutable; - statusMap["ReadOnly"] = Property::ReadOnly; - statusMap["Hidden"] = Property::Hidden; - statusMap["Transient"] = Property::Transient; - statusMap["MaterialEdit"] = Property::MaterialEdit; - statusMap["NoMaterialListEdit"] = Property::NoMaterialListEdit; - statusMap["Output"] = Property::Output; - statusMap["LockDynamic"] = Property::LockDynamic; - statusMap["NoModify"] = Property::NoModify; - statusMap["PartialTrigger"] = Property::PartialTrigger; + statusMap["Immutable"] = PropertyStatus::Immutable; + statusMap["ReadOnly"] = PropertyStatus::ReadOnly; + statusMap["Hidden"] = PropertyStatus::Hidden; + statusMap["Transient"] = PropertyStatus::Transient; + statusMap["MaterialEdit"] = PropertyStatus::MaterialEdit; + statusMap["NoMaterialListEdit"] = PropertyStatus::NoMaterialListEdit; + statusMap["Output"] = PropertyStatus::Output; + statusMap["LockDynamic"] = PropertyStatus::LockDynamic; + statusMap["NoModify"] = PropertyStatus::NoModify; + statusMap["PartialTrigger"] = PropertyStatus::PartialTrigger; } return statusMap; } @@ -214,7 +210,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args) } auto linkProp = Base::freecad_dynamic_cast(prop); - std::bitset<32> status(prop->getStatus()); + auto status = prop->getStatus(); size_t count = 1; bool isSeq = false; if(PyList_Check(pyValue) || PyTuple_Check(pyValue)) { @@ -260,7 +256,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args) } } - prop->setStatusValue(status.to_ulong()); + prop->setStatus(status); Py_Return; } @@ -311,10 +307,9 @@ PyObject* PropertyContainerPy::getEditorMode(PyObject *args) App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name); Py::List ret; if (prop) { - short Type = prop->getType(); - if ((prop->testStatus(Property::ReadOnly)) || (Type & Prop_ReadOnly)) + if ((prop->testStatus(ReadOnly)) ||prop->testStatus(Prop_ReadOnly)) ret.append(Py::String("ReadOnly")); - if ((prop->testStatus(Property::Hidden)) || (Type & Prop_Hidden)) + if ((prop->testStatus(Hidden)) || prop->testStatus(Prop_Hidden)) ret.append(Py::String("Hidden")); } return Py::new_reference_to(ret); @@ -332,11 +327,7 @@ PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args) return 0; } - const char* Group = getPropertyContainerPtr()->getPropertyGroup(prop); - if (Group) - return Py::new_reference_to(Py::String(Group)); - else - return Py::new_reference_to(Py::String("")); + return Py::new_reference_to(Py::String(prop->getGroup())); } PyObject* PropertyContainerPy::getDocumentationOfProperty(PyObject *args) @@ -351,11 +342,8 @@ PyObject* PropertyContainerPy::getDocumentationOfProperty(PyObject *args) return 0; } - const char* Group = getPropertyContainerPtr()->getPropertyDocumentation(prop); - if (Group) - return Py::new_reference_to(Py::String(Group)); - else - return Py::new_reference_to(Py::String("")); + + return Py::new_reference_to(Py::String(prop->getDocumentation())); } PyObject* PropertyContainerPy::getEnumerationsOfProperty(PyObject *args) @@ -567,7 +555,7 @@ int PropertyContainerPy::setCustomAttributes(const char* attr, PyObject *obj) Property *prop = getPropertyContainerPtr()->getPropertyByName(attr); if (prop) { // Read-only attributes must not be set over its Python interface - if(prop->testStatus(Property::Immutable)) { + if(prop->testStatus(PropertyStatus::Immutable)) { std::stringstream s; s << "Object attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 3801f475b854..c6882619c71a 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -63,7 +63,7 @@ void PropertyExpressionContainer::slotRelabelDocument(const App::Document &doc) // For use a private _ExprContainers to track all living // PropertyExpressionContainer including those inside undo/redo stack, // because document relabel is not undoable/redoable. - + if(doc.getOldLabel() != doc.Label.getValue()) { for(auto prop : _ExprContainers) prop->onRelabeledDocument(doc); @@ -172,11 +172,11 @@ void PropertyExpressionEngine::Save(Base::Writer &writer) const PropertyExpressionContainer::Save(writer); } for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) { - writer.Stream() << writer.ind() << "first.toString()) <<"\" expression=\"" + writer.Stream() << writer.ind() << "first.toString()) <<"\" expression=\"" << Property::encodeAttribute(it->second.expression->toString(true)) << "\""; if (it->second.expression->comment.size() > 0) - writer.Stream() << " comment=\"" + writer.Stream() << " comment=\"" << Property::encodeAttribute(it->second.expression->comment) << "\""; writer.Stream() << "/>" << std::endl; } @@ -320,7 +320,7 @@ void PropertyExpressionEngine::onContainerRestored() { UpdateElementReferenceExpressionVisitor v(*this); for(auto &e : expressions) { auto expr = e.second.expression; - if(expr) + if(expr) expr->visit(v); } } @@ -407,7 +407,7 @@ struct cycle_detector : public boost::dfs_visitor<> { */ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs, - boost::unordered_map & revNodes, + boost::unordered_map & revNodes, DiGraph & g, ExecuteOption option) const { boost::unordered_map nodes; @@ -419,13 +419,13 @@ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs, auto prop = it->first.getProperty(); if(!prop) throw Base::RuntimeError("Path does not resolve to a property."); - bool is_output = prop->testStatus(App::Property::Output)||(prop->getType()&App::Prop_Output); + bool is_output = prop->testStatus(App::PropertyStatus::Output)||prop->testStatus(Prop_Output); if((is_output && option==ExecuteNonOutput) || (!is_output && option==ExecuteOutput)) continue; - if(option == ExecuteOnRestore - && !prop->testStatus(Property::Transient) - && !(prop->getType() & Prop_Transient) - && !prop->testStatus(Property::EvalOnRestore)) + if(option == ExecuteOnRestore + && !prop->testStatus(PropertyStatus::Transient) + && !prop->testStatus(Prop_Transient) + && !prop->testStatus(PropertyStatus::EvalOnRestore)) continue; } buildGraphStructures(it->first, it->second.expression, nodes, revNodes, edges); @@ -498,9 +498,9 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute(ExecuteOption o auto prop = e.first.getProperty(); if(!prop) continue; - if(prop->testStatus(App::Property::Transient) - || (prop->getType()&App::Prop_Transient) - || prop->testStatus(App::Property::EvalOnRestore)) + if(prop->testStatus(App::PropertyStatus::Transient) + || prop->testStatus(App::Prop_Transient) + || prop->testStatus(App::PropertyStatus::EvalOnRestore)) { found = true; break; @@ -553,7 +553,7 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute(ExecuteOption o try { // Evaluate expression value = expressions[*it].expression->getValueAsAny(); - if(option == ExecuteOnRestore && prop->testStatus(Property::EvalOnRestore)) { + if(option == ExecuteOnRestore && prop->testStatus(PropertyStatus::EvalOnRestore)) { if(isAnyEqual(value, prop->getPathValue(*it))) continue; if(touched) @@ -598,7 +598,7 @@ void PropertyExpressionEngine::getPathsToDocumentObject(DocumentObject* obj, auto it = deps.find(obj); if(it==deps.end()) continue; - for(auto &dep : it->second) + for(auto &dep : it->second) paths.insert(paths.end(),dep.second.begin(),dep.second.end()); } } @@ -789,7 +789,7 @@ bool PropertyExpressionEngine::adjustLink(const std::set &inLis return true; } -void PropertyExpressionEngine::updateElementReference(DocumentObject *feature, bool reverse, bool notify) +void PropertyExpressionEngine::updateElementReference(DocumentObject *feature, bool reverse, bool notify) { (void)notify; if(!feature) @@ -814,7 +814,7 @@ bool PropertyExpressionEngine::referenceChanged() const { } Property *PropertyExpressionEngine::CopyOnImportExternal( - const std::map &nameMap) const + const std::map &nameMap) const { std::unique_ptr engine; for(auto it=expressions.begin();it!=expressions.end();++it) { @@ -823,7 +823,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal( #else boost::shared_ptr expr(it->second.expression->importSubNames(nameMap)); #endif - if(!expr && !engine) + if(!expr && !engine) continue; if(!engine) { engine.reset(new PropertyExpressionEngine); @@ -841,7 +841,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal( return engine.release(); } -Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj, +Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const { std::unique_ptr engine; @@ -851,7 +851,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj, #else boost::shared_ptr expr(it->second.expression->updateLabelReference(obj,ref,newLabel)); #endif - if(!expr && !engine) + if(!expr && !engine) continue; if(!engine) { engine.reset(new PropertyExpressionEngine); @@ -869,7 +869,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj, return engine.release(); } -Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject *parent, +Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const { std::unique_ptr engine; @@ -881,7 +881,7 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject boost::shared_ptr expr( it->second.expression->replaceObject(parent,oldObj,newObj)); #endif - if(!expr && !engine) + if(!expr && !engine) continue; if(!engine) { engine.reset(new PropertyExpressionEngine); @@ -899,11 +899,11 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject return engine.release(); } -std::map -PropertyExpressionEngine::getExpressions() const +std::map +PropertyExpressionEngine::getExpressions() const { std::map res; - for(auto &v : expressions) + for(auto &v : expressions) res[v.first] = v.second.expression.get(); return res; } @@ -924,6 +924,6 @@ void PropertyExpressionEngine::setExpressions( void PropertyExpressionEngine::onRelabeledDocument(const App::Document &doc) { RelabelDocumentExpressionVisitor v(doc); - for(auto &e : expressions) + for(auto &e : expressions) e.second.expression->visit(v); } diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 93394d47ec6f..9c8658d36c40 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -80,9 +80,9 @@ void PropertyFileIncluded::aboutToSetValue(void) // If Copy() is directly called (e.g. to copy the file to // another document) a copy of the file needs to be created. // This copy will be deleted again in the class destructor. - this->StatusBits.set(10); + this->setStatus(PropertyStatus::PartialTrigger); Property::aboutToSetValue(); - this->StatusBits.reset(10); + this->setStatus(PropertyStatus::PartialTrigger, false); } std::string PropertyFileIncluded::getDocTransientPath(void) const @@ -199,7 +199,7 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName) Base::FileInfo dst(_cValue); dst.setPermissions(Base::FileInfo::ReadOnly); } - // otherwise copy from origin location + // otherwise copy from origin location else { // if file already exists in transient dir make a new unique name Base::FileInfo fi(_cValue); @@ -318,7 +318,7 @@ void PropertyFileIncluded::setPyObject(PyObject *value) #endif else if (PyTuple_Check(value)) { if (PyTuple_Size(value) != 2) - throw Base::TypeError("Tuple needs size of (filePath,newFileName)"); + throw Base::TypeError("Tuple needs size of (filePath,newFileName)"); PyObject* file = PyTuple_GetItem(value,0); PyObject* name = PyTuple_GetItem(value,1); @@ -420,7 +420,7 @@ void PropertyFileIncluded::Save (Base::Writer &writer) const } } else { - // instead initiate an extra file + // instead initiate an extra file if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str()); std::string filename = writer.addFile(file.fileName().c_str(), this); @@ -525,7 +525,7 @@ Property *PropertyFileIncluded::Copy(void) const if (file.exists()) { // create a new name in the document transient directory Base::FileInfo newName(getUniqueFileName(file.dirPath(), file.fileName())); - if (this->StatusBits.test(10)) { + if (this->testStatus(PropertyStatus::PartialTrigger)) { // rename the file bool done = file.renameFile(newName.filePath().c_str()); if (!done) { diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 85a0b962ce0c..cdd69267df91 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -362,7 +362,7 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)getSize(); str << uCt; - if (!isSinglePrecision()) { + if (!testStatus(PropertyStatus::Single)) { for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { str << it->x << it->y << it->z; } @@ -383,7 +383,7 @@ void PropertyVectorList::RestoreDocFile(Base::Reader &reader) uint32_t uCt=0; str >> uCt; std::vector values(uCt); - if (!isSinglePrecision()) { + if (!testStatus(PropertyStatus::Single)) { for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { str >> it->x >> it->y >> it->z; } @@ -717,7 +717,7 @@ void PropertyPlacement::setPyObject(PyObject *value) void PropertyPlacement::Save (Base::Writer &writer) const { writer.Stream() << writer.ind() << "::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { str << it->getPosition().x << it->getPosition().y << it->getPosition().z << it->getRotation()[0] << it->getRotation()[1] << it->getRotation()[2] << it->getRotation()[3] ; @@ -867,7 +867,7 @@ void PropertyPlacementList::RestoreDocFile(Base::Reader &reader) uint32_t uCt=0; str >> uCt; std::vector values(uCt); - if (!isSinglePrecision()) { + if (!testStatus(PropertyStatus::Single)) { for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { Base::Vector3d pos; double q0, q1, q2, q3; diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 44b79a607c25..297aca878783 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -181,7 +181,7 @@ PropertyLinkBase::updateLabelReferences(App::DocumentObject *obj, const char *ne static std::string propertyName(const Property *prop) { if(!prop) return std::string(); - if(!prop->getContainer() || !prop->getName()) { + if(!prop->getContainer()) { auto xlink = Base::freecad_dynamic_cast(prop); if(xlink) return propertyName(xlink->parent()); diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 02245e6caaeb..2c4745badfd9 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1282,7 +1282,7 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)getSize(); str << uCt; - if (!isSinglePrecision()) { + if (!testStatus(PropertyStatus::Single)) { for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { str << *it; } @@ -1301,7 +1301,7 @@ void PropertyFloatList::RestoreDocFile(Base::Reader &reader) uint32_t uCt=0; str >> uCt; std::vector values(uCt); - if (!isSinglePrecision()) { + if (!testStatus(PropertyStatus::Single)) { for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { str >> *it; } diff --git a/src/App/StatusCollection.h b/src/App/StatusCollection.h new file mode 100644 index 000000000000..a650ce1de21b --- /dev/null +++ b/src/App/StatusCollection.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * Copyright (c) 2002 Jürgen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef APP_STATUSCOLLECTION_H +#define APP_STATUSCOLLECTION_H + +#include +#include +#include + +namespace App +{ + +template +class StatusCollection : public std::bitset +{ +public: + static const size_t StatusBitLength = sizeof(ENUM)*8; + + constexpr StatusCollection() : std::bitset() {} + explicit StatusCollection(unsigned long long val): std::bitset(val) {} + StatusCollection(const char * str) : std::bitset( strtoull(str,0,10)) {} + StatusCollection(const StatusCollection &col) : std::bitset(col) {} + StatusCollection(ENUM status) { this->set(status);} + + StatusCollection& operator=(const StatusCollection & src) { + std::bitset::operator=(src); + return *this; + } +}; + +template +StatusCollection operator+(ENUM status1, ENUM status2) { + StatusCollection collection; + collection.set(status1); + collection.set(status2); + return collection; +} + +template +StatusCollection operator+(const StatusCollection& c, ENUM status2) { + StatusCollection collection(c); + collection.set(status2); + return collection; +} + +} + +#endif // APP_STATUSCOLLECTION_H diff --git a/src/App/StatusContainer.h b/src/App/StatusContainer.h new file mode 100644 index 000000000000..d7a3df432eeb --- /dev/null +++ b/src/App/StatusContainer.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (c) 2002 Jürgen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef APP_STATUSCONTAINER_H +#define APP_STATUSCONTAINER_H + +#include "StatusCollection.h" + +namespace App +{ + +template +class StatusContainer +{ +public: + void setStatus(const StatusCollection & other) { + for (size_t bit=0;bit< StatusCollection::StatusBitLength;bit++) { + if (other.test(bit)) { + setStatus(static_cast(bit)); + } + } + } + + const StatusCollection& getStatus() const { return this->statusBits;} + + bool testStatus(const ENUM& pos) const {return statusBits.test(pos);} + + void setStatus(const ENUM& pos, bool on=true) { + + if (testStatus(pos)!=on) { + statusBits.set(pos, on); + onStatusChanged(pos, on); + } + } + + bool testStatusAny() const { return statusBits.any();} + +protected: + virtual void onStatusChanged(const ENUM& pos, bool newValue) =0; + +private: + StatusCollection statusBits; +}; + +}; +#endif // APP_STATUSCONTAINER_H diff --git a/src/App/TextDocument.cpp b/src/App/TextDocument.cpp index 82e4416d8c35..968d0b789891 100644 --- a/src/App/TextDocument.cpp +++ b/src/App/TextDocument.cpp @@ -38,7 +38,7 @@ PROPERTY_SOURCE(App::TextDocument, App::DocumentObject) TextDocument::TextDocument() { ADD_PROPERTY_TYPE( - Text, (""), 0, App::Prop_Hidden, + Text, (""), "", App::Prop_Hidden, "Content of the document."); } diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 57359c5beee9..8116d1e24693 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -169,11 +169,11 @@ void Transaction::apply(Document &Doc, bool forward) std::string errMsg; try { auto &index = _Objects.get<0>(); - for(auto &info : index) + for(auto &info : index) info.second->applyDel(Doc, const_cast(info.first)); - for(auto &info : index) + for(auto &info : index) info.second->applyNew(Doc, const_cast(info.first)); - for(auto &info : index) + for(auto &info : index) info.second->applyChn(Doc, const_cast(info.first), forward); }catch(Base::Exception &e) { e.ReportException(); @@ -184,7 +184,7 @@ void Transaction::apply(Document &Doc, bool forward) errMsg = "Unknown exception"; } if(errMsg.size()) { - FC_ERR("Exception on " << (forward?"redo":"undo") << " '" + FC_ERR("Exception on " << (forward?"redo":"undo") << " '" << Name << "':" << errMsg); } } @@ -281,8 +281,6 @@ TransactionObject::TransactionObject() */ TransactionObject::~TransactionObject() { - for(auto &v : _PropChangeMap) - delete v.second.property; } void TransactionObject::applyDel(Document & /*Doc*/, TransactionalObject * /*pcObj*/) @@ -298,40 +296,30 @@ void TransactionObject::applyChn(Document & /*Doc*/, TransactionalObject *pcObj, if (status == New || status == Chn) { // Property change order is not preserved, as it is recursive in nature for(auto &v : _PropChangeMap) { - auto &data = v.second; - auto prop = const_cast(v.first); - if(!data.property) { + if(!v.second) { // here means we are undoing/redoing and property add operation - pcObj->removeDynamicProperty(v.second.name.c_str()); + pcObj->removeDynamicProperty(v.first->Name); continue; } - // getPropertyName() is specially coded to be safe even if prop has - // been destroies. We must prepare for the case where user removed - // a dynamic property but does not recordered as transaction. - auto name = pcObj->getPropertyName(prop); - if(!name) { - // Here means the original property is not found, probably removed - if(v.second.name.empty()) { - // not a dynamic property, nothing to do - continue; - } + auto prop= pcObj->getPropertyByName(v.first->Name); + if(!prop) { // It is possible for the dynamic property to be removed and // restored. But since restoring property is actually creating // a new property, the property key inside redo stack will not // match. So we search by name first. - prop = pcObj->getDynamicPropertyByName(v.second.name.c_str()); + prop = pcObj->getDynamicPropertyByName(v.second->getName()); if(!prop) { // Still not found, re-create the property prop = pcObj->addDynamicProperty( - data.property->getTypeId().getName(), - v.second.name.c_str(), data.group.c_str(), data.doc.c_str(), - data.attr, data.readonly, data.hidden); + v.second->getTypeId().getName(), + v.second->getName(),v.second->getGroup(),v.second->getDocumentation() + ); if(!prop) continue; - prop->setStatusValue(data.property->getStatus()); + prop->setStatus(v.second->getStatus()); } } @@ -349,7 +337,7 @@ void TransactionObject::applyChn(Document & /*Doc*/, TransactionalObject *pcObj, // continue; // } try { - prop->Paste(*data.property); + prop->Paste(*v.second); } catch (Base::Exception &e) { e.ReportException(); FC_ERR("exception while restoring " << prop->getFullName() << ": " << e.what()); @@ -363,13 +351,12 @@ void TransactionObject::applyChn(Document & /*Doc*/, TransactionalObject *pcObj, void TransactionObject::setProperty(const Property* pcProp) { - auto &data = _PropChangeMap[pcProp]; - if(!data.property && data.name.empty()) { - static_cast(data) = - pcProp->getContainer()->getDynamicPropertyData(pcProp); - data.property = pcProp->Copy(); - data.propertyType = pcProp->getTypeId(); - data.property->setStatusValue(pcProp->getStatus()); + //This if looks like defeat. We should not need this. This happens because setProperty is called WHILE undoing + if( _PropChangeMap.find(pcProp->getPropertySpec()) == _PropChangeMap.end()) { + std::shared_ptr copyProperty(pcProp->Copy()); + copyProperty->setStatus(pcProp->getStatus()); + copyProperty->setPropertySpec(pcProp->getPropertySpec()); + _PropChangeMap[pcProp->getPropertySpec()]=copyProperty; } } @@ -379,28 +366,20 @@ void TransactionObject::addOrRemoveProperty(const Property* pcProp, bool add) if(!pcProp || !pcProp->getContainer()) return; - auto &data = _PropChangeMap[pcProp]; - if(data.name.size()) { - if(!add && !data.property) { - // this means add and remove the same property inside a single - // transaction, so they cancel each other out. - _PropChangeMap.erase(pcProp); - } - return; - } - if(data.property) { - delete data.property; - data.property = 0; + if(!add + && _PropChangeMap.find(pcProp->getPropertySpec()) != _PropChangeMap.end() + && _PropChangeMap[pcProp->getPropertySpec()]) { + // this means add and remove the same property inside a single + // transaction, so they cancel each other out. + _PropChangeMap.erase(pcProp->getPropertySpec()); } + return; - static_cast(data) = - pcProp->getContainer()->getDynamicPropertyData(pcProp); - if(add) - data.property = 0; + if(add){ + _PropChangeMap[pcProp->getPropertySpec()] = std::shared_ptr(); + } else { - data.property = pcProp->Copy(); - data.propertyType = pcProp->getTypeId(); - data.property->setStatusValue(pcProp->getStatus()); + setProperty(pcProp); } } @@ -452,7 +431,7 @@ void TransactionDocumentObject::applyDel(Document &Doc, TransactionalObject *pcO #ifndef USE_OLD_DAG //Make sure the backlinks of all linked objects are updated. As the links of the removed - //object are never set to [] they also do not remove the backlink. But as they are + //object are never set to [] they also do not remove the backlink. But as they are //not in the document anymore we need to remove them anyway to ensure a correct graph auto list = obj->getOutList(); for (auto link : list) diff --git a/src/App/Transactions.h b/src/App/Transactions.h index 94eceb7a44b4..ab46b1ab7aba 100644 --- a/src/App/Transactions.h +++ b/src/App/Transactions.h @@ -130,10 +130,7 @@ class AppExport TransactionObject : public Base::Persistence protected: enum Status {New,Del,Chn} status; - struct PropData : DynamicProperty::PropData { - Base::Type propertyType; - }; - std::unordered_map _PropChangeMap; + std::unordered_map, std::shared_ptr > _PropChangeMap; std::string _NameInDocument; }; diff --git a/src/App/VRMLObject.cpp b/src/App/VRMLObject.cpp index 008e0aa19900..bb406255a5af 100644 --- a/src/App/VRMLObject.cpp +++ b/src/App/VRMLObject.cpp @@ -42,9 +42,9 @@ PROPERTY_SOURCE(App::VRMLObject, App::GeoFeature) VRMLObject::VRMLObject() : index(0) { ADD_PROPERTY_TYPE(VrmlFile,(0),"",Prop_None,"Included file with the VRML definition"); - ADD_PROPERTY_TYPE(Urls,(""),"",static_cast(Prop_ReadOnly|Prop_Output|Prop_Transient), + ADD_PROPERTY_TYPE(Urls,(""),"",Prop_ReadOnly+Prop_Output+Prop_Transient, "Resource files loaded by the VRML file"); - ADD_PROPERTY_TYPE(Resources,(""),"",static_cast(Prop_ReadOnly|Prop_Output), + ADD_PROPERTY_TYPE(Resources,(""),"",Prop_ReadOnly+Prop_Output, "Resource files loaded by the VRML file"); Urls.setSize(0); Resources.setSize(0); diff --git a/src/Base/Writer.cpp b/src/Base/Writer.cpp index 753e4b5b31a7..e41fad6a9fcc 100644 --- a/src/Base/Writer.cpp +++ b/src/Base/Writer.cpp @@ -162,7 +162,7 @@ std::vector Writer::getErrors() const return Errors; } -std::string Writer::addFile(const char* Name,const Base::Persistence *Object) +std::string Writer::addFile(const std::string& Name,const Base::Persistence *Object) { // always check isForceXML() before requesting a file! assert(isForceXML()==false); @@ -179,10 +179,9 @@ std::string Writer::addFile(const char* Name,const Base::Persistence *Object) return temp.FileName; } -std::string Writer::getUniqueFileName(const char *Name) +std::string Writer::getUniqueFileName(std::string CleanName) { // name in use? - std::string CleanName = (Name ? Name : ""); std::vector::const_iterator pos; pos = find(FileNames.begin(),FileNames.end(),CleanName); diff --git a/src/Base/Writer.h b/src/Base/Writer.h index bbf29619cdbd..88aca1b6b082 100644 --- a/src/Base/Writer.h +++ b/src/Base/Writer.h @@ -76,7 +76,7 @@ class BaseExport Writer /** @name additional file writing */ //@{ /// add a write request of a persistent object - std::string addFile(const char* Name, const Base::Persistence *Object); + std::string addFile(const std::string& Name, const Base::Persistence *Object); /// process the requested file storing virtual void writeFiles(void)=0; /// get all registered file names @@ -119,7 +119,7 @@ class BaseExport Writer std::string ObjectName; protected: - std::string getUniqueFileName(const char *Name); + std::string getUniqueFileName(std::string Name); struct FileEntry { std::string FileName; const Base::Persistence *Object; diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index d6e71d96fa52..6fe4d0d2920d 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -460,7 +460,7 @@ void CallTipsList::extractTipsFromProperties(Py::Object& obj, QMapfirst.c_str()); tip.name = str; tip.type = CallTip::Property; - QString longdoc = QString::fromUtf8(container->getPropertyDocumentation(It->second)); + QString longdoc = QString::fromStdString(It->second->getDocumentation()); // a point, mesh or shape property if (It->second->isDerivedFrom(Base::Type::fromName("App::PropertyComplexGeoData"))) { Py::Object data(It->second->getPyObject(), true); diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index d299c0a14a8b..877278a54f1f 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -88,7 +88,7 @@ void LineEdit::keyPressEvent(QKeyEvent *eventIn) eventIn->accept(); return; } - + QLineEdit::keyPressEvent(eventIn); } @@ -107,31 +107,31 @@ Model::Model(QObject *parentIn, const Gui::Document &documentIn) : QGraphicsScen //turned off BSP as it was giving inconsistent discovery of items //underneath cursor. this->setItemIndexMethod(QGraphicsScene::NoIndex); - + theGraph = std::make_shared(); graphLink = std::make_shared(); setupViewConstants(); setupFilters(); - + graphDirty = false; currentPrehighlight = nullptr; - + ParameterGrp::handle group = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("DAGView"); selectionMode = static_cast(group->GetInt("SelectionMode", 0)); group->SetInt("SelectionMode", static_cast(selectionMode)); //ensure entry exists. - + QIcon temp(Gui::BitmapFactory().iconFromTheme("dagViewVisible")); visiblePixmapEnabled = temp.pixmap(iconSize, iconSize, QIcon::Normal, QIcon::On); visiblePixmapDisabled = temp.pixmap(iconSize, iconSize, QIcon::Disabled, QIcon::Off); - + QIcon passIcon(Gui::BitmapFactory().iconFromTheme("dagViewPass")); passPixmap = passIcon.pixmap(iconSize, iconSize); QIcon failIcon(Gui::BitmapFactory().iconFromTheme("dagViewFail")); failPixmap = failIcon.pixmap(iconSize, iconSize); QIcon pendingIcon(Gui::BitmapFactory().iconFromTheme("dagViewPending")); pendingPixmap = pendingIcon.pixmap(iconSize, iconSize); - + renameAction = new QAction(this); renameAction->setText(tr("Rename")); renameAction->setStatusTip(tr("Rename object")); @@ -139,13 +139,13 @@ Model::Model(QObject *parentIn, const Gui::Document &documentIn) : QGraphicsScen renameAction->setShortcut(Qt::Key_F2); #endif connect(renameAction, SIGNAL(triggered()), this, SLOT(onRenameSlot())); - + editingFinishedAction = new QAction(this); editingFinishedAction->setText(tr("Finish editing")); editingFinishedAction->setStatusTip(tr("Finish editing object")); connect(this->editingFinishedAction, SIGNAL(triggered()), this, SLOT(editingFinishedSlot())); - + connectNewObject = documentIn.signalNewObject.connect(boost::bind(&Model::slotNewObject, this, bp::_1)); connectDelObject = documentIn.signalDeletedObject.connect(boost::bind(&Model::slotDeleteObject, this, bp::_1)); connectChgObject = documentIn.signalChangedObject.connect(boost::bind(&Model::slotChangeObject, this, bp::_1, bp::_2)); @@ -171,7 +171,7 @@ Model::~Model() connectEdtObject.disconnect(); if(connectResObject.connected()) connectResObject.disconnect(); - + removeAllItems(); } @@ -186,7 +186,7 @@ void Model::setupViewConstants() { ParameterGrp::handle group = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("DAGView"); - + //get font point size. int fontPointSize = group->GetInt("FontPointSize", 0); group->SetInt("FontPointSize", fontPointSize); //ensure entry exists. @@ -196,13 +196,13 @@ void Model::setupViewConstants() tempFont.setPointSize(fontPointSize); this->setFont(tempFont); } - + //get direction direction = group->GetFloat("Direction", 1.0); if (direction != -1.0 && direction != 1.0) direction = 1.0; group->SetFloat("Direction", direction); //ensure entry exists. - + QFontMetrics fontMetric(this->font()); fontHeight = fontMetric.height(); verticalSpacing = 1.0; @@ -215,7 +215,7 @@ void Model::setupViewConstants() iconToText = iconSize / 2.0; rowPadding = fontHeight; backgroundBrushes = {this->palette().base(), this->palette().alternateBase()}; - forgroundBrushes = + forgroundBrushes = { QBrush(Qt::red), QBrush(Qt::darkRed), @@ -238,9 +238,9 @@ void Model::setupViewConstants() void Model::slotNewObject(const ViewProviderDocumentObject &VPDObjectIn) { Vertex virginVertex = boost::add_vertex(*theGraph); - + addVertexItemsToScene(virginVertex); - + GraphLinkRecord virginRecord; virginRecord.DObject = VPDObjectIn.getObject(); virginRecord.VPDObject = &VPDObjectIn; @@ -248,19 +248,19 @@ void Model::slotNewObject(const ViewProviderDocumentObject &VPDObjectIn) virginRecord.uniqueName = std::string(virginRecord.DObject->getNameInDocument()); virginRecord.vertex = virginVertex; graphLink->insert(virginRecord); - + //setup rectangle. auto *rectangle = (*theGraph)[virginVertex].rectangle.get(); rectangle->setEditingBrush(QBrush(Qt::yellow)); - + auto icon = (*theGraph)[virginVertex].icon; icon->setPixmap(VPDObjectIn.getIcon().pixmap(iconSize, iconSize)); (*theGraph)[virginVertex].stateIcon->setPixmap(passPixmap); (*theGraph)[virginVertex].text->setFont(this->font()); - (*theGraph)[virginVertex].connChangeIcon = + (*theGraph)[virginVertex].connChangeIcon = const_cast(VPDObjectIn).signalChangeIcon.connect( boost::bind(&Model::slotChangeIcon, this, boost::cref(VPDObjectIn), icon)); - + graphDirty = true; lastAddedVertex = Graph::null_vertex(); } @@ -274,42 +274,40 @@ void Model::slotChangeIcon(const ViewProviderDocumentObject &VPDObjectIn, std::s void Model::slotDeleteObject(const ViewProviderDocumentObject &VPDObjectIn) { Vertex vertex = findRecord(&VPDObjectIn, *graphLink).vertex; - + //remove items from scene. removeVertexItemsFromScene(vertex); - - //remove connector items + + //remove connector items auto outRange = boost::out_edges(vertex, *theGraph); for (auto outEdgeIt = outRange.first; outEdgeIt != outRange.second; ++outEdgeIt) this->removeItem((*theGraph)[*outEdgeIt].connector.get()); auto inRange = boost::in_edges(vertex, *theGraph); for (auto inEdgeIt = inRange.first; inEdgeIt != inRange.second; ++inEdgeIt) this->removeItem((*theGraph)[*inEdgeIt].connector.get()); - + if (vertex == lastAddedVertex) lastAddedVertex = Graph::null_vertex(); (*theGraph)[vertex].connChangeIcon.disconnect(); - + //remove the actual vertex. boost::clear_vertex(vertex, *theGraph); boost::remove_vertex(vertex, *theGraph); - + eraseRecord(&VPDObjectIn, *graphLink); graphDirty = true; } void Model::slotChangeObject(const ViewProviderDocumentObject &VPDObjectIn, const App::Property& propertyIn) { - std::string name("Empty Name"); - if (propertyIn.getName()) //getName can return 0. - name = propertyIn.getName(); + std::string name = propertyIn.getName(); assert(!name.empty()); - -// std::cout << std::endl << "inside changed object." << std::endl << + +// std::cout << std::endl << "inside changed object." << std::endl << // "Property name is: " << name << std::endl << // "Property type is: " << propertyIn.getTypeId().getName() << std::endl << std::endl; - + //renaming of objects. if (std::string("Label") == name) { @@ -343,23 +341,23 @@ void Model::selectionChanged(const SelectionChanges& msg) { //TODO: note that treeview uses set selection which sends a message with just a document name //and no object name. Have to explore further. - + auto getAllEdges = [this](const Vertex &vertexIn) { //is there really no function to get both in and out edges? std::vector out; - + OutEdgeIterator outIt, outItEnd; for (boost::tie(outIt, outItEnd) = boost::out_edges(vertexIn, *theGraph); outIt != outItEnd; ++outIt) out.push_back(*outIt); - + InEdgeIterator inIt, inItEnd; for (boost::tie(inIt, inItEnd) = boost::in_edges(vertexIn, *theGraph); inIt != inItEnd; ++inIt) out.push_back(*inIt); - + return out; }; - + auto highlightConnectorOn = [this, getAllEdges](const Vertex &vertexIn) { QColor color = (*theGraph)[vertexIn].text->defaultTextColor(); @@ -372,7 +370,7 @@ void Model::selectionChanged(const SelectionChanges& msg) (*theGraph)[edge].connector->setZValue(1.0); } }; - + auto highlightConnectorOff = [this, getAllEdges](const Vertex &vertexIn) { auto edges = getAllEdges(vertexIn); @@ -382,7 +380,7 @@ void Model::selectionChanged(const SelectionChanges& msg) (*theGraph)[edge].connector->setZValue(0.0); } }; - + //lamda for clearing selections. auto clearSelection = [this, highlightConnectorOff]() { @@ -394,7 +392,7 @@ void Model::selectionChanged(const SelectionChanges& msg) highlightConnectorOff(currentVertex); } }; - + //lamda for getting rectangle. auto getRectangle = [this](const char *in) { @@ -406,7 +404,7 @@ void Model::selectionChanged(const SelectionChanges& msg) assert(rect); return rect; }; - + if (msg.Type == SelectionChanges::AddSelection) { if (msg.pObjectName) @@ -428,7 +426,7 @@ void Model::selectionChanged(const SelectionChanges& msg) else if(msg.Type == SelectionChanges::SetSelection) { clearSelection(); - + auto selections = Gui::Selection().getSelection(msg.pDocName); for (const auto &selection : selections) { @@ -442,7 +440,7 @@ void Model::selectionChanged(const SelectionChanges& msg) { clearSelection(); } - + this->invalidate(); } @@ -460,13 +458,13 @@ void Model::updateSlot() { //empty outList means it is a root. //empty inList means it is a leaf. - + //NOTE: some of the following loops can/should be combined //for speed. Not doing yet, as I want a simple algorithm until //a more complete picture is formed. - + Base::TimeInfo startTime; - + //here we will cycle through the graph updating edges. //we have to do this first and in isolation because everything is dependent on an up to date graph. BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) @@ -488,7 +486,7 @@ void Model::updateSlot() } } } - + //apply filters. BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) { @@ -501,7 +499,7 @@ void Model::updateSlot() (*theGraph)[currentVertex].dagVisible = false; } } - //inclusion takes precedence. Separate loop because filters might probe + //inclusion takes precedence. Separate loop because filters might probe //children and parents. So we want to ensure all exclusions are done //before inclusions start. BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) @@ -514,7 +512,7 @@ void Model::updateSlot() (*theGraph)[currentVertex].dagVisible = true; } } - + //sync scene items to graph vertex dagVisible. BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) { @@ -523,20 +521,20 @@ void Model::updateSlot() if ((!(*theGraph)[currentVertex].dagVisible) && (*theGraph)[currentVertex].rectangle->scene()) removeVertexItemsFromScene(currentVertex); } - + //sync scene items for graph edge. BGL_FORALL_EDGES(currentEdge, *theGraph, Graph) { Vertex source = boost::source(currentEdge, *theGraph); Vertex target = boost::target(currentEdge, *theGraph); - + bool edgeVisible = (*theGraph)[source].dagVisible && (*theGraph)[target].dagVisible; if (edgeVisible && (!(*theGraph)[currentEdge].connector->scene())) this->addItem((*theGraph)[currentEdge].connector.get()); if ((!edgeVisible) && (*theGraph)[currentEdge].connector->scene()) this->removeItem((*theGraph)[currentEdge].connector.get()); } - + indexVerticesEdges(); Path sorted; try @@ -557,7 +555,7 @@ void Model::updateSlot() (*theGraph)[currentVertex].topoSortIndex = tempIndex; tempIndex++; } - + //draw graph(nodes and connectors). int currentRow = 0; int currentColumn = -1; //we know first column is going to be root so will be kicked up to 0. @@ -567,7 +565,7 @@ void Model::updateSlot() { if (!(*theGraph)[currentVertex].dagVisible) continue; - + if (boost::out_degree(currentVertex, *theGraph) == 0) currentColumn = 0; else @@ -581,7 +579,7 @@ void Model::updateSlot() for (;it != itEnd; ++it) { // std::cout << std::endl << "name: " << findRecord(currentVertex, *graphLink).DObject->Label.getValue() << std::endl; - + Vertex target = boost::target(*it, *theGraph); parentVertices.push_back(target); int currentParentIndex = (*theGraph)[target].topoSortIndex; @@ -593,23 +591,23 @@ void Model::updateSlot() for (it = start; it != end; ++it) { // std::cout << " parent: " << findRecord(*it, *graphLink).DObject->Label.getValue() << std::endl; - + columnMask |= (*theGraph)[*it].column; } farthestParentIndex = currentParentIndex; } } - + //have to create a smaller subset to get through std::cout. // std::bitset<8> testSet; // for (unsigned int index = 0; index < testSet.size(); ++index) // testSet[index]= columnMask[index]; // std::cout << "mask for " << findRecord(currentVertex, *graphLink).DObject->Label.getValue() << " " << // testSet.to_string() << std::endl; - + //now we should have a mask representing the columns that are being used. //this is from the lowest parent, in the topo sort, to last entry. - + //try to use the same column as one of the parents.(*theGraph)[*it].column int destinationColumn = 0; //default to first column for (const auto ¤tParent : parentVertices) @@ -638,9 +636,9 @@ void Model::updateSlot() currentColumn = destinationColumn; } - + assert(currentColumn < static_cast(ColumnMask().size())); //temp limitation. - + maxColumn = std::max(currentColumn, maxColumn); QBrush currentBrush(forgroundBrushes.at(currentColumn % forgroundBrushes.size())); @@ -648,26 +646,26 @@ void Model::updateSlot() rectangle->setRect(-rowPadding, 0.0, rowPadding, rowHeight); //calculate actual length later. rectangle->setTransform(QTransform::fromTranslate(0, rowHeight * currentRow)); rectangle->setBackgroundBrush(backgroundBrushes[currentRow % backgroundBrushes.size()]); - + auto *point = (*theGraph)[currentVertex].point.get(); point->setRect(0.0, 0.0, pointSize, pointSize); point->setTransform(QTransform::fromTranslate(pointSpacing * currentColumn, rowHeight * currentRow + rowHeight / 2.0 - pointSize / 2.0)); point->setBrush(currentBrush); - + float cheat = 0.0; if (direction == -1) cheat = rowHeight; - + auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); visiblePixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - + auto *statePixmap = (*theGraph)[currentVertex].stateIcon.get(); statePixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - + auto *pixmap = (*theGraph)[currentVertex].icon.get(); pixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - + auto *text = (*theGraph)[currentVertex].text.get(); text->setPlainText(QString::fromUtf8(findRecord(currentVertex, *graphLink).DObject->Label.getValue())); text->setDefaultTextColor(currentBrush.color()); @@ -675,11 +673,11 @@ void Model::updateSlot() text->setTransform(QTransform::fromTranslate (0.0, rowHeight * currentRow - verticalSpacing * 2.0 + cheat)); //calculate x location later. (*theGraph)[currentVertex].lastVisibleState = VisibilityState::None; //force visual update for color. - + //store column and row int the graph. use for connectors later. (*theGraph)[currentVertex].row = currentRow; (*theGraph)[currentVertex].column.reset().set((currentColumn)); - + //our list is topo sorted so all dependents should be located, so we can build the connectors. //will have some more logic for connector path, simple for now. float currentX = pointSpacing * currentColumn + pointSize / 2.0; @@ -694,7 +692,7 @@ void Model::updateSlot() float dependentX = pointSpacing * static_cast(columnFromMask((*theGraph)[target].column)) + pointSize / 2.0; //on center. columnFromMask((*theGraph)[target].column); float dependentY = rowHeight * (*theGraph)[target].row + rowHeight / 2.0; - + QGraphicsPathItem *pathItem = (*theGraph)[*it].connector.get(); pathItem->setBrush(Qt::NoBrush); QPainterPath path; @@ -705,9 +703,9 @@ void Model::updateSlot() { //connector with bend. float radius = pointSpacing / 1.9; //no zero length line. - + path.lineTo(currentX, dependentY + radius * direction); - + float yPosition; if (direction == -1.0) yPosition = dependentY - 2.0 * radius; @@ -729,10 +727,10 @@ void Model::updateSlot() } pathItem->setPath(path); } - + currentRow++; } - + //now that we have the graph drawn we know where to place icons and text. float columnSpacing = (maxColumn * pointSpacing); for (const auto ¤tVertex : sorted) @@ -742,32 +740,32 @@ void Model::updateSlot() auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); QTransform visibleIconTransform = QTransform::fromTranslate(localCurrentX, 0.0); visiblePixmap->setTransform(visiblePixmap->transform() * visibleIconTransform); - + localCurrentX += iconSize + iconToIcon; auto *statePixmap = (*theGraph)[currentVertex].stateIcon.get(); QTransform stateIconTransform = QTransform::fromTranslate(localCurrentX, 0.0); statePixmap->setTransform(statePixmap->transform() * stateIconTransform); - + localCurrentX += iconSize + iconToIcon; auto *pixmap = (*theGraph)[currentVertex].icon.get(); QTransform iconTransform = QTransform::fromTranslate(localCurrentX, 0.0); pixmap->setTransform(pixmap->transform() * iconTransform); - + localCurrentX += iconSize + iconToText; auto *text = (*theGraph)[currentVertex].text.get(); QTransform textTransform = QTransform::fromTranslate(localCurrentX, 0.0); text->setTransform(text->transform() * textTransform); - + auto *rectangle = (*theGraph)[currentVertex].rectangle.get(); QRectF rect = rectangle->rect(); rect.setWidth(localCurrentX + maxTextLength + 2.0 * rowPadding); rectangle->setRect(rect); } - + //Modeling_Challenge_Casting_ta4 with 59 features: "Initialize DAG View time: 0.007" //keeping algo simple with extra loops only added 0.002 to above number. // std::cout << "Initialize DAG View time: " << Base::TimeInfo::diffTimeF(startTime, Base::TimeInfo()) << std::endl; - + // outputGraphviz(*theGraph, "./graphviz.dot"); graphDirty = false; } @@ -775,7 +773,7 @@ void Model::updateSlot() void Model::indexVerticesEdges() { std::size_t index = 0; - + //index vertices. VertexIterator it, itEnd; for(boost::tie(it, itEnd) = boost::vertices(*theGraph); it != itEnd; ++it) @@ -800,7 +798,7 @@ void Model::removeAllItems() { BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) removeVertexItemsFromScene(currentVertex); - + BGL_FORALL_EDGES(currentEdge, *theGraph, Graph) { if ((*theGraph)[currentEdge].connector->scene()) @@ -839,11 +837,11 @@ void Model::updateStates() { //not sure I want to use the same pixmap merge for failing feature icons. //thinking maybe red background or another column of icons for state? - + BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) { const GraphLinkRecord &record = findRecord(currentVertex, *graphLink); - + auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); VisibilityState currentVisibilityState = (record.VPDObject->isShow()) ? (VisibilityState::On) : (VisibilityState::Off); if @@ -858,7 +856,7 @@ void Model::updateStates() visiblePixmap->setPixmap(visiblePixmapDisabled); (*theGraph)[currentVertex].lastVisibleState = currentVisibilityState; } - + FeatureState currentFeatureState = FeatureState::Pass; if (record.DObject->isError()) currentFeatureState = FeatureState::Fail; @@ -898,7 +896,7 @@ RectItem* Model::getRectFromPosition(const QPointF& position) rect = dynamic_cast(currentItem); if (rect) break; } - + return rect; } @@ -912,22 +910,22 @@ void Model::mouseMoveEvent(QGraphicsSceneMouseEvent* event) currentPrehighlight = nullptr; } }; - + RectItem *rect = getRectFromPosition(event->scenePos()); if (!rect) { clearPrehighlight(); return; } - + if (rect == currentPrehighlight) return; - + clearPrehighlight(); rect->preHighlightOn(); currentPrehighlight = rect; invalidate(); - + QGraphicsScene::mouseMoveEvent(event); } @@ -947,7 +945,7 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) selectionRecord.DObject->getNameInDocument()); } }; - + auto toggleSelect = [](const App::DocumentObject *dObjectIn, RectItem *rectIn) { if (rectIn->isSelected()) @@ -955,17 +953,17 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) else Gui::Selection().addSelection(dObjectIn->getDocument()->getName(), dObjectIn->getNameInDocument()); }; - + if (proxy) renameAcceptedSlot(); - + if (event->button() == Qt::LeftButton) { RectItem *rect = getRectFromPosition(event->scenePos()); if (rect) { const GraphLinkRecord &record = findRecord(rect, *graphLink); - + //don't like that I am doing this again here after getRectFromPosition call. QGraphicsItem *item = itemAt(event->scenePos(), QTransform()); QGraphicsPixmapItem *pixmapItem = dynamic_cast(item); @@ -976,10 +974,10 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) const_cast(record.VPDObject)->show(); //const hack else const_cast(record.VPDObject)->hide(); //const hack - + return; } - + const App::DocumentObject *dObject = record.DObject; if (selectionMode == SelectionMode::Single) { @@ -1017,7 +1015,7 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) Gui::Selection().clearSelection(); //get document name? } } - + QGraphicsScene::mousePressEvent(event); } @@ -1035,7 +1033,7 @@ void Model::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) getMainWindow()->setActiveWindow(view); const_cast(record.VPDObject)->doubleClicked(); } - + QGraphicsScene::mouseDoubleClickEvent(event); } @@ -1043,13 +1041,13 @@ void Model::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) std::vector Model::getAllSelected() { std::vector out; - + BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph) { if ((*theGraph)[currentVertex].rectangle->isSelected()) out.push_back(currentVertex); } - + return out; } @@ -1059,7 +1057,7 @@ void Model::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) if (rect) { const GraphLinkRecord &record = findRecord(rect, *graphLink); - + //don't like that I am doing this again here after getRectFromPosition call. QGraphicsItem *item = itemAt(event->scenePos(), QTransform()); QGraphicsPixmapItem *pixmapItem = dynamic_cast(item); @@ -1068,7 +1066,7 @@ void Model::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) visiblyIsolate(record.vertex); return; } - + if (!rect->isSelected()) { Gui::Selection().clearSelection(record.DObject->getDocument()->getName()); @@ -1076,12 +1074,12 @@ void Model::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) lastPickValid = true; lastPick = event->scenePos(); } - + MenuItem view; Gui::Application::Instance->setupContextMenu("Tree", &view); QMenu contextMenu; MenuManager::getInstance()->setupContextMenu(&view, contextMenu); - + //actions for only one selection. std::vector selections = getAllSelected(); if (selections.size() == 1) @@ -1094,11 +1092,11 @@ void Model::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) else contextMenu.addAction(editingFinishedAction); } - + if (contextMenu.actions().count() > 0) contextMenu.exec(event->screenPos()); } - + QGraphicsScene::contextMenuEvent(event); } @@ -1107,32 +1105,32 @@ void Model::onRenameSlot() assert(proxy == nullptr); std::vector selections = getAllSelected(); assert(selections.size() == 1); - + LineEdit *lineEdit = new LineEdit(); auto *text = (*theGraph)[selections.front()].text.get(); lineEdit->setText(text->toPlainText()); connect(lineEdit, SIGNAL(acceptedSignal()), this, SLOT(renameAcceptedSlot())); connect(lineEdit, SIGNAL(rejectedSignal()), this, SLOT(renameRejectedSlot())); - + proxy = this->addWidget(lineEdit); proxy->setGeometry(text->sceneBoundingRect()); - + lineEdit->selectAll(); - QTimer::singleShot(0, lineEdit, SLOT(setFocus())); + QTimer::singleShot(0, lineEdit, SLOT(setFocus())); } void Model::renameAcceptedSlot() { assert(proxy); - + std::vector selections = getAllSelected(); assert(selections.size() == 1); const GraphLinkRecord &record = findRecord(selections.front(), *graphLink); - + LineEdit *lineEdit = dynamic_cast(proxy->widget()); assert(lineEdit); const_cast(record.DObject)->Label.setValue(lineEdit->text().toUtf8().constData()); //const hack - + finishRename(); } @@ -1190,10 +1188,10 @@ void Model::visiblyIsolate(Gui::DAG::Vertex sourceIn) if (type != Base::Type::badType()) out.push_back(type); type = Base::Type::fromName("PartDesign::Body"); if (type != Base::Type::badType()) out.push_back(type); - + return out; }; - + auto testSkipType = [](const App::DocumentObject *dObject, const std::vector &types) { for (const auto ¤tType : types) @@ -1203,13 +1201,13 @@ void Model::visiblyIsolate(Gui::DAG::Vertex sourceIn) } return false; }; - + indexVerticesEdges(); Path connectedVertices; ConnectionVisitor visitor(connectedVertices); boost::breadth_first_search(*theGraph, sourceIn, boost::visitor(visitor)); boost::breadth_first_search(boost::make_reverse_graph(*theGraph), sourceIn, boost::visitor(visitor)); - + //note source vertex is added twice to Path. Once for each search. static std::vector skipTypes = buildSkipTypes(); for (const auto ¤tVertex : connectedVertices) @@ -1219,7 +1217,7 @@ void Model::visiblyIsolate(Gui::DAG::Vertex sourceIn) continue; const_cast(record.VPDObject)->hide(); //const hack } - + const GraphLinkRecord &sourceRecord = findRecord(sourceIn, *graphLink); if (!testSkipType(sourceRecord.DObject, skipTypes)) const_cast(sourceRecord.VPDObject)->show(); //const hack diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 2a52d7db4ac5..2ffffe71703a 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -110,9 +110,9 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, Gui::Selection().Attach(this); - d->connectChangedObject = - Gui::Application::Instance->signalChangedObject.connect(boost::bind - (&DlgDisplayPropertiesImp::slotChangedObject, this, bp::_1, bp::_2)); + d->connectChangedObject = + Gui::Application::Instance->signalChangedObject.connect(boost::bind + (&DlgDisplayPropertiesImp::slotChangedObject, this, bp::_1, bp::_2)); } /** @@ -171,11 +171,10 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, (Provider.begin(), Provider.end(), [&obj](Gui::ViewProvider* v) { return v == &obj; }); if (vp != Provider.end()) { - const char* name = obj.getPropertyName(&prop); // this is not a property of the view provider but of the document object - if (!name) + if (!obj.isOwnerOf(prop)) return; - std::string prop_name = name; + std::string prop_name = prop.getName();; if (prop.getTypeId() == App::PropertyColor::getClassTypeId()) { App::Color value = static_cast(prop).getValue(); if (prop_name == "ShapeColor") { diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 0b938181ff4c..5c35a7351420 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -803,8 +803,7 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop && d->_editingObject && d->_editViewProviderParent && (Prop.isDerivedFrom(App::PropertyPlacement::getClassTypeId()) - // Issue ID 0004230 : getName() can return null in which case strstr() crashes - || (Prop.getName() && strstr(Prop.getName(),"Scale"))) + || Prop.getName().find("Scale")!= std::string::npos) && d->_editObjs.count(&Obj)) { Base::Matrix4D mat; @@ -836,7 +835,7 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop } // a property of an object has changed - if(!Prop.testStatus(App::Property::NoModify) && !isModified()) { + if(!Prop.testStatus(App::PropertyStatus::NoModify) && !isModified()) { FC_LOG(Prop.getFullName() << " modified"); setModified(true); } diff --git a/src/Gui/DocumentObserverPython.cpp b/src/Gui/DocumentObserverPython.cpp index b98c86f4d722..13291ccc76e5 100644 --- a/src/Gui/DocumentObserverPython.cpp +++ b/src/Gui/DocumentObserverPython.cpp @@ -200,11 +200,9 @@ void DocumentObserverPython::slotBeforeChangeObject(const Gui::ViewProvider& Obj try { Py::Tuple args(2); args.setItem(0, Py::Object(const_cast(Obj).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Obj.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (Obj.isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyBeforeChangeObject.ptr(),args.ptr()); } } @@ -221,11 +219,9 @@ void DocumentObserverPython::slotChangedObject(const Gui::ViewProvider& Obj, try { Py::Tuple args(2); args.setItem(0, Py::Object(const_cast(Obj).getPyObject(), true)); - // If a property is touched but not part of a document object then its name is null. - // In this case the slot function must not be called. - const char* prop_name = Obj.getPropertyName(&Prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + + if (Obj.isOwnerOf(Prop)) { + args.setItem(1, Py::String(Prop.getName())); Base::pyCall(pyChangedObject.ptr(),args.ptr()); } } diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp index 0be9f992c659..44ba83b72738 100644 --- a/src/Gui/ExpressionBinding.cpp +++ b/src/Gui/ExpressionBinding.cpp @@ -232,7 +232,7 @@ bool ExpressionBinding::apply() throw Base::RuntimeError("Document object not found."); /* Skip updating read-only properties */ - if (prop->isReadOnly()) + if (prop->testStatus(App::PropertyStatus::ReadOnly)) return true; std::string _path = getPath().toEscapedString(); diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 15b99eed2c78..a6cd021ae3c7 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -202,7 +202,7 @@ class ExpressionCompleterModel: public QAbstractItemModel { if(idx>=0 && v) { QString res; if(prop) - res = QString::fromLatin1(prop->getName()); + res = QString::fromStdString(prop->getName()); else if(obj) { if(idx & 1) res = QString::fromUtf8(quote(obj->Label.getStrValue()).c_str()); @@ -260,7 +260,7 @@ class ExpressionCompleterModel: public QAbstractItemModel { *count = propSize; } if(v) - *v = QString::fromLatin1(prop->getName()); + *v = QString::fromStdString(prop->getName()); return; } diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 04b2e6ad355a..1d1c3d16c49d 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -61,13 +61,13 @@ class find_placement { if (elem.first == propertyname) { // flag set that property is read-only or hidden - if (elem.second->testStatus(App::Property::ReadOnly) || elem.second->testStatus(App::Property::Hidden)) + if (elem.second->testStatus(App::PropertyStatus::ReadOnly) || elem.second->testStatus(App::PropertyStatus::Hidden)) return false; App::PropertyContainer* parent = elem.second->getContainer(); if (parent) { // flag set that property is read-only or hidden - if (parent->isReadOnly(elem.second) || - parent->isHidden(elem.second)) + if (elem.second->testStatus(App::PropertyStatus::Prop_ReadOnly) || + elem.second->testStatus(App::PropertyStatus::Prop_Hidden)) return false; } return elem.second->isDerivedFrom diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index eef9f699cb3e..d8fdf2c9bb28 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -224,7 +224,7 @@ void PropertyView::slotChangePropertyView(const Gui::ViewProvider&, const App::P bool PropertyView::isPropertyHidden(const App::Property *prop) { return prop && !showAll() && - ((prop->getType() & App::Prop_Hidden) || prop->testStatus(App::Property::Hidden)); + (prop->testStatus(App::PropertyStatus::Prop_Hidden) || prop->testStatus(App::PropertyStatus::Hidden)); } void PropertyView::slotAppendDynamicProperty(const App::Property& prop) @@ -482,7 +482,7 @@ void PropertyView::onTimer() { if(it!=propMap.end() && !isPropertyHidden(it->second)) continue; std::vector items(1,prop); - if(prop->testStatus(App::Property::PropDynamic)) + if(prop->testStatus(App::PropertyStatus::Prop_Dynamic)) dataPropsMap.emplace(name+"*",std::move(items)); else dataProps.emplace_back(name+"*", std::move(items)); @@ -514,7 +514,7 @@ void PropertyView::onTimer() { for (it = propDataMap.begin(); it != propDataMap.end(); ++it) { if (it->propList.size() == sels.size()) { - if(it->propList[0]->testStatus(App::Property::PropDynamic)) + if(it->propList[0]->testStatus(App::PropertyStatus::Prop_Dynamic)) dataPropsMap.emplace(it->propName, std::move(it->propList)); else dataProps.emplace_back(it->propName, std::move(it->propList)); diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 4b64ecc7b2d4..ce0b4d34267c 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -465,7 +465,7 @@ bool QuantitySpinBox::apply(const std::string & propName) const Property * prop = path.getProperty(); /* Skip update if property is bound and we know it is read-only */ - if (prop && prop->isReadOnly()) + if (prop && prop->testStatus(App::PropertyStatus::ReadOnly)) return true; if (prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) { diff --git a/src/Gui/SelectionView.cpp b/src/Gui/SelectionView.cpp index 4459b02d60fb..105820c31b5a 100644 --- a/src/Gui/SelectionView.cpp +++ b/src/Gui/SelectionView.cpp @@ -537,9 +537,8 @@ QString SelectionView::getProperty(App::DocumentObject* obj) const if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { App::GeoFeature* geo = static_cast(obj); const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry(); - const char* name = data ? data->getName() : nullptr; - if (name) { - property = QString::fromLatin1(name); + if(data) { + property = QString::fromStdString(data->getName()); } } diff --git a/src/Gui/TaskView/TaskAppearance.cpp b/src/Gui/TaskView/TaskAppearance.cpp index 10b034f0675d..9e02c3f16502 100644 --- a/src/Gui/TaskView/TaskAppearance.cpp +++ b/src/Gui/TaskView/TaskAppearance.cpp @@ -80,7 +80,7 @@ void TaskAppearance::changeEvent(QEvent *e) void TaskAppearance::OnChange(Gui::SelectionSingleton::SubjectType &rCaller, Gui::SelectionSingleton::MessageType Reason) { - Q_UNUSED(rCaller); + Q_UNUSED(rCaller); if (Reason.Type == SelectionChanges::AddSelection || Reason.Type == SelectionChanges::RmvSelection || Reason.Type == SelectionChanges::SetSelection || @@ -104,7 +104,7 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj, (Provider.begin(), Provider.end(), [&obj](Gui::ViewProvider* v) { return v == &obj; }); if (vp != Provider.end()) { - std::string prop_name = obj.getPropertyName(&prop); + std::string prop_name = prop.getName(); if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { long value = static_cast(prop).getValue(); if (prop_name == "Transparency") { diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 1b340b671337..a8bd56d15dfc 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -421,7 +421,7 @@ QWidget* TreeWidgetEditDelegate::createEditor( ExpLineEdit *le = new ExpLineEdit(parent); le->setFrame(false); - le->setReadOnly(prop.isReadOnly()); + le->setReadOnly(prop.testStatus(App::PropertyStatus::ReadOnly)); le->bind(App::ObjectIdentifier(prop)); le->setAutoApply(true); return le; @@ -3612,8 +3612,8 @@ void TreeWidget::slotChangeObject( } auto &s = ChangedObjects[obj]; - if(prop.testStatus(App::Property::Output) - || prop.testStatus(App::Property::NoRecompute)) + if(prop.testStatus(App::PropertyStatus::Output) + || prop.testStatus(App::PropertyStatus::NoRecompute)) { s.set(CS_Output); } diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index 3c5c9fb41a65..08f78a5cd865 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -241,7 +241,7 @@ void ViewProviderAnnotation::attach(App::DocumentObject* f) void ViewProviderAnnotation::updateData(const App::Property* prop) { if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() && - strcmp(prop->getName(),"LabelText") == 0) { + prop->getName() == "LabelText") { const std::vector lines = static_cast(prop)->getValues(); int index=0; pLabel->string.setNum((int)lines.size()); @@ -263,7 +263,7 @@ void ViewProviderAnnotation::updateData(const App::Property* prop) } } else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && - strcmp(prop->getName(),"Position") == 0) { + prop->getName() == "Position") { Base::Vector3d v = static_cast(prop)->getValue(); pTranslation->translation.setValue(v.x,v.y,v.z); } @@ -382,16 +382,16 @@ void ViewProviderAnnotationLabel::attach(App::DocumentObject* f) void ViewProviderAnnotationLabel::updateData(const App::Property* prop) { if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() && - strcmp(prop->getName(),"LabelText") == 0) { + prop->getName() == "LabelText") { drawImage(static_cast(prop)->getValues()); } else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && - strcmp(prop->getName(),"BasePosition") == 0) { + prop->getName() == "BasePosition") { Base::Vector3d v = static_cast(prop)->getValue(); pBaseTranslation->translation.setValue(v.x,v.y,v.z); } else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && - strcmp(prop->getName(),"TextPosition") == 0) { + prop->getName() == "TextPosition") { Base::Vector3d v = static_cast(prop)->getValue(); pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z)); pTextTranslation->translation.setValue(v.x,v.y,v.z); diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 0230117675d5..a0363dd1209a 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -132,10 +132,10 @@ const char* ViewProviderDocumentObject::detachFromDocument() return ""; } -bool ViewProviderDocumentObject::removeDynamicProperty(const char* name) +bool ViewProviderDocumentObject::removeDynamicProperty(const std::string& name) { App::Property* prop = getDynamicPropertyByName(name); - if(!prop || prop->testStatus(App::Property::LockDynamic)) + if(!prop || prop->testStatus(App::PropertyStatus::LockDynamic)) return false; // transactions of view providers are also managed in App::Document. @@ -148,10 +148,9 @@ bool ViewProviderDocumentObject::removeDynamicProperty(const char* name) } App::Property* ViewProviderDocumentObject::addDynamicProperty( - const char* type, const char* name, const char* group, const char* doc, - short attr, bool ro, bool hidden) + const std::string& type, const std::string& name, const std::string& group, const std::string& doc) { - auto prop = ViewProvider::addDynamicProperty(type,name,group,doc,attr,ro,hidden); + auto prop = ViewProvider::addDynamicProperty(type,name,group,doc); if(prop) { // transactions of view providers are also managed in App::Document. App::DocumentObject* docobject = getObject(); @@ -182,12 +181,12 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop) } else if (prop == &Visibility) { // use this bit to check whether show() or hide() must be called - if (Visibility.testStatus(App::Property::User2) == false) { - Visibility.setStatus(App::Property::User2, true); + if (Visibility.testStatus(App::PropertyStatus::User2) == false) { + Visibility.setStatus(App::PropertyStatus::User2, true); Visibility.getValue() ? show() : hide(); - Visibility.setStatus(App::Property::User2, false); + Visibility.setStatus(App::PropertyStatus::User2, false); } - if (!Visibility.testStatus(App::Property::User1) + if (!Visibility.testStatus(App::PropertyStatus::User1) && getObject() && getObject()->Visibility.getValue()!=Visibility.getValue()) { @@ -228,10 +227,10 @@ void ViewProviderDocumentObject::hide(void) { ViewProvider::hide(); // use this bit to check whether 'Visibility' must be adjusted - if (Visibility.testStatus(App::Property::User2) == false) { - Visibility.setStatus(App::Property::User2, true); + if (Visibility.testStatus(App::PropertyStatus::User2) == false) { + Visibility.setStatus(App::PropertyStatus::User2, true); Visibility.setValue(false); - Visibility.setStatus(App::Property::User2, false); + Visibility.setStatus(App::PropertyStatus::User2, false); } } @@ -273,10 +272,10 @@ void ViewProviderDocumentObject::show(void) } // use this bit to check whether 'Visibility' must be adjusted - if (Visibility.testStatus(App::Property::User2) == false) { - Visibility.setStatus(App::Property::User2, true); + if (Visibility.testStatus(App::PropertyStatus::User2) == false) { + Visibility.setStatus(App::PropertyStatus::User2, true); Visibility.setValue(true); - Visibility.setStatus(App::Property::User2, false); + Visibility.setStatus(App::PropertyStatus::User2, false); } } @@ -293,7 +292,7 @@ void ViewProviderDocumentObject::updateView() Base::ObjectStatusLocker lock(ViewStatus::UpdatingView,this); // Disable object visibility syncing - Base::ObjectStatusLocker lock2(App::Property::User1, &Visibility); + Base::ObjectStatusLocker lock2(App::PropertyStatus::User1, &Visibility); std::map Map; pcObject->getPropertyMap(Map); @@ -358,8 +357,8 @@ void ViewProviderDocumentObject::update(const App::Property* prop) Visibility.setValue(!Visibility.getValue()); } else { // Disable object visibility syncing - Base::ObjectStatusLocker - guard(App::Property::User1, &Visibility); + Base::ObjectStatusLocker + guard(App::PropertyStatus::User1, &Visibility); ViewProvider::update(prop); } } @@ -638,10 +637,11 @@ bool ViewProviderDocumentObject::getDetailPath(const char *subname, SoFullPath * } void ViewProviderDocumentObject::onPropertyStatusChanged( - const App::Property &prop, unsigned long oldStatus) + const App::Property &prop, const App::PropertyStatus& status) { - (void)oldStatus; - if(!App::Document::isAnyRestoring() && pcObject && pcObject->getDocument()) + (void)status; + if(!App::Document::isAnyRestoring() && pcObject && pcObject->getDocument() + && (status == App::PropertyStatus::ReadOnly || status == App::PropertyStatus::Hidden)) pcObject->getDocument()->signalChangePropertyEditor(*pcObject->getDocument(),prop); } diff --git a/src/Gui/ViewProviderDocumentObject.h b/src/Gui/ViewProviderDocumentObject.h index 3af4173d13b2..60ea6a6bb9de 100644 --- a/src/Gui/ViewProviderDocumentObject.h +++ b/src/Gui/ViewProviderDocumentObject.h @@ -121,12 +121,12 @@ class GuiExport ViewProviderDocumentObject : public ViewProvider virtual void finishRestoring(); //@} - virtual bool removeDynamicProperty(const char* prop) override; + virtual bool removeDynamicProperty(const std::string& prop) override; virtual App::Property* addDynamicProperty( - const char* type, const char* name=0, - const char* group=0, const char* doc=0, - short attr=0, bool ro=false, bool hidden=false) override; + const std::string& type, const std::string& name, + const std::string& group,const std::string& doc + ) override; /** Return the linked view object * @@ -197,7 +197,7 @@ class GuiExport ViewProviderDocumentObject : public ViewProvider virtual const char* detachFromDocument() override; /// get called when a property status has changed - virtual void onPropertyStatusChanged(const App::Property &prop, unsigned long oldStatus) override; + virtual void onPropertyStatusChanged(const App::Property &prop, const App::PropertyStatus& status) override; //@} diff --git a/src/Gui/ViewProviderDragger.cpp b/src/Gui/ViewProviderDragger.cpp index bf2bc001e1fb..cfe51df96192 100644 --- a/src/Gui/ViewProviderDragger.cpp +++ b/src/Gui/ViewProviderDragger.cpp @@ -81,7 +81,7 @@ ViewProviderDragger::~ViewProviderDragger() void ViewProviderDragger::updateData(const App::Property* prop) { if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId()) && - strcmp(prop->getName(), "Placement") == 0) { + prop->getName() == "Placement") { // Note: If R is the rotation, c the rotation center and t the translation // vector then Inventor applies the following transformation: R*(x-c)+c+t // In FreeCAD a placement only has a rotation and a translation part but diff --git a/src/Gui/ViewProviderGroupExtension.cpp b/src/Gui/ViewProviderGroupExtension.cpp index fd251d108f32..2fe35b27d74a 100644 --- a/src/Gui/ViewProviderGroupExtension.cpp +++ b/src/Gui/ViewProviderGroupExtension.cpp @@ -149,7 +149,7 @@ void ViewProviderGroupExtension::extensionHide(void) { // Property::User1 is used by ViewProviderDocumentObject to mark for // temporary visibility changes. Do not propagate the change to children. if (!getExtendedViewProvider()->isRestoring() - && !getExtendedViewProvider()->Visibility.testStatus(App::Property::User1)) + && !getExtendedViewProvider()->Visibility.testStatus(App::PropertyStatus::User1)) { auto* group = getExtendedViewProvider()->getObject()->getExtensionByType(); for(auto obj : group->Group.getValues()) { diff --git a/src/Gui/ViewProviderInventorObject.cpp b/src/Gui/ViewProviderInventorObject.cpp index 0dee18dbe257..efc5fceeb44d 100644 --- a/src/Gui/ViewProviderInventorObject.cpp +++ b/src/Gui/ViewProviderInventorObject.cpp @@ -126,7 +126,7 @@ void ViewProviderInventorObject::updateData(const App::Property* prop) } } else if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId()) && - strcmp(prop->getName(), "Placement") == 0) { + prop->getName() == "Placement") { // Note: If R is the rotation, c the rotation center and t the translation // vector then Inventor applies the following transformation: R*(x-c)+c+t // In FreeCAD a placement only has a rotation and a translation part but diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 2ebc20ec6d84..d3844513cac2 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -1318,8 +1318,8 @@ void LinkView::onLinkedUpdateData(LinkInfoPtr info, const App::Property *prop) { if(info!=linkInfo || !linkOwner || !linkOwner->isLinked() || info==linkOwner) return; auto ext = linkOwner->pcLinked->getObject()->getExtensionByType(true); - if (ext && !(prop->getType() & App::Prop_Output) && - !prop->testStatus(App::Property::Output)) + if (ext && !prop->testStatus(App::PropertyStatus::Prop_Output) && + !prop->testStatus(App::PropertyStatus::Output)) { // propagate the signalChangedObject to potentially multiple levels // of links, to inform tree view of children change, and other @@ -1605,14 +1605,14 @@ ViewProviderLink::ViewProviderLink() { sPixmap = _LinkIcon; - ADD_PROPERTY_TYPE(Selectable, (true), " Link", App::Prop_None, 0); + ADD_PROPERTY_TYPE(Selectable, (true), " Link", App::Prop_None, ""); ADD_PROPERTY_TYPE(OverrideMaterial, (false), " Link", App::Prop_None, "Override linked object's material"); App::Material mat(App::Material::DEFAULT); mat.diffuseColor.setPackedValue(ViewParams::instance()->getDefaultLinkColor()); - ADD_PROPERTY_TYPE(ShapeMaterial, (mat), " Link", App::Prop_None, 0); - ShapeMaterial.setStatus(App::Property::MaterialEdit, true); + ADD_PROPERTY_TYPE(ShapeMaterial, (mat), " Link", App::Prop_None, ""); + ShapeMaterial.setStatus(App::PropertyStatus::MaterialEdit, true); ADD_PROPERTY_TYPE(DrawStyle,((long int)0), " Link", App::Prop_None, ""); static const char* DrawStyleEnums[]= {"None","Solid","Dashed","Dotted","Dashdot",NULL}; @@ -1628,15 +1628,15 @@ ViewProviderLink::ViewProviderLink() PointSize.setConstraints(&sizeRange); ADD_PROPERTY(MaterialList,()); - MaterialList.setStatus(App::Property::NoMaterialListEdit, true); + MaterialList.setStatus(App::PropertyStatus::NoMaterialListEdit, true); ADD_PROPERTY(OverrideMaterialList,()); ADD_PROPERTY(OverrideColorList,()); ADD_PROPERTY(ChildViewProvider, ("")); - ChildViewProvider.setStatus(App::Property::Hidden,true); + ChildViewProvider.setStatus(App::PropertyStatus::Hidden,true); - DisplayMode.setStatus(App::Property::Status::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); linkView = new LinkView; } @@ -1807,10 +1807,10 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: applyColors(); checkIcon(ext); }else if(prop==ext->getColoredElementsProperty()) { - if(!prop->testStatus(App::Property::User3)) + if(!prop->testStatus(App::PropertyStatus::User3)) applyColors(); }else if(prop==ext->getScaleProperty() || prop==ext->getScaleVectorProperty()) { - if(!prop->testStatus(App::Property::User3)) { + if(!prop->testStatus(App::PropertyStatus::User3)) { const auto &v = ext->getScaleVector(); pcTransform->scaleFactor.setValue(v.x,v.y,v.z); linkView->renderDoubleSide(v.x*v.y*v.z < 0); @@ -1826,7 +1826,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: } }else if(prop == ext->getLinkedObjectProperty()) { - if(!prop->testStatus(App::Property::User3)) { + if(!prop->testStatus(App::PropertyStatus::User3)) { std::vector subs; const char *subname = ext->getSubName(); std::string sub; @@ -1895,14 +1895,14 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: } if(!overrideMaterial) overrideMaterials.clear(); - OverrideMaterialList.setStatus(App::Property::User3,true); + OverrideMaterialList.setStatus(App::PropertyStatus::User3,true); OverrideMaterialList.setValue(overrideMaterials); - OverrideMaterialList.setStatus(App::Property::User3,false); + OverrideMaterialList.setStatus(App::PropertyStatus::User3,false); if(!hasMaterial) materials.clear(); - MaterialList.setStatus(App::Property::User3,true); + MaterialList.setStatus(App::PropertyStatus::User3,true); MaterialList.setValue(materials); - MaterialList.setStatus(App::Property::User3,false); + MaterialList.setStatus(App::PropertyStatus::User3,false); linkView->setSize(ext->_getElementCountValue()); updateDataPrivate(ext,ext->getVisibilityListProperty()); @@ -1911,7 +1911,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: } } }else if(prop==ext->getScaleListProperty() || prop==ext->getPlacementListProperty()) { - if(!prop->testStatus(App::Property::User3) && + if(!prop->testStatus(App::PropertyStatus::User3) && linkView->getSize() && !ext->_getShowElementValue()) { @@ -2981,18 +2981,18 @@ void ViewProviderLink::setElementColors(const std::map auto prop = ext->getColoredElementsProperty(); if(subs!=prop->getSubValues() || colors!=OverrideColorList.getValues()) { - prop->setStatus(App::Property::User3,true); + prop->setStatus(App::PropertyStatus::User3,true); prop->setValue(getObject(),subs); - prop->setStatus(App::Property::User3,false); + prop->setStatus(App::PropertyStatus::User3,false); OverrideColorList.setValues(colors); } if(hasFaceColor) { auto mat = ShapeMaterial.getValue(); mat.diffuseColor = faceColor; mat.transparency = faceColor.a; - ShapeMaterial.setStatus(App::Property::User3,true); + ShapeMaterial.setStatus(App::PropertyStatus::User3,true); ShapeMaterial.setValue(mat); - ShapeMaterial.setStatus(App::Property::User3,false); + ShapeMaterial.setStatus(App::PropertyStatus::User3,false); } OverrideMaterial.setValue(hasFaceColor); } @@ -3078,13 +3078,13 @@ static bool isExcludedProperties(const char *name) { return false; } -App::Property *ViewProviderLink::getPropertyByName(const char *name) const { +App::Property *ViewProviderLink::getPropertyByName(const std::string& name) const { auto prop = inherited::getPropertyByName(name); - if(prop || isExcludedProperties(name)) + if(prop || isExcludedProperties(name.c_str())) return prop; if(childVp) { prop = childVp->getPropertyByName(name); - if(prop && !prop->testStatus(App::Property::Hidden)) + if(prop && !prop->testStatus(App::PropertyStatus::Hidden)) return prop; prop = 0; } @@ -3106,7 +3106,7 @@ void ViewProviderLink::getPropertyMap(std::map &Map) auto ret = Map.insert(v); if(!ret.second) { auto myProp = ret.first->second; - if(myProp->testStatus(App::Property::Hidden)) + if(myProp->testStatus(App::PropertyStatus::Hidden)) ret.first->second = v.second; } } diff --git a/src/Gui/ViewProviderLink.h b/src/Gui/ViewProviderLink.h index f679cccb1da6..d12d0c8ea78a 100644 --- a/src/Gui/ViewProviderLink.h +++ b/src/Gui/ViewProviderLink.h @@ -258,7 +258,7 @@ class GuiExport ViewProviderLink : public ViewProviderDocumentObject return childVp; } - virtual App::Property *getPropertyByName(const char* name) const override; + virtual App::Property *getPropertyByName(const std::string& name) const override; virtual void getPropertyMap(std::map &Map) const override; virtual void getPropertyList(std::vector &List) const override; diff --git a/src/Gui/ViewProviderMeasureDistance.cpp b/src/Gui/ViewProviderMeasureDistance.cpp index 17ecf1e5545f..123c73c3dbd1 100644 --- a/src/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Gui/ViewProviderMeasureDistance.cpp @@ -192,11 +192,11 @@ void ViewProviderMeasureDistance::updateData(const App::Property* prop) { if (prop->getTypeId() == App::PropertyVector::getClassTypeId() || prop == &Mirror || prop == &DistFactor) { - if (strcmp(prop->getName(),"P1") == 0) { + if (prop->getName() == "P1") { Base::Vector3d v = static_cast(prop)->getValue(); pCoords->point.set1Value(0, SbVec3f(v.x,v.y,v.z)); } - else if (strcmp(prop->getName(),"P2") == 0) { + else if (prop->getName() == "P2") { Base::Vector3d v = static_cast(prop)->getValue(); pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z)); } diff --git a/src/Gui/ViewProviderOrigin.cpp b/src/Gui/ViewProviderOrigin.cpp index 37ea28864e86..29c03cdd5b3d 100644 --- a/src/Gui/ViewProviderOrigin.cpp +++ b/src/Gui/ViewProviderOrigin.cpp @@ -63,9 +63,9 @@ PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderDocumentObject) */ ViewProviderOrigin::ViewProviderOrigin() { - ADD_PROPERTY_TYPE ( Size, (Base::Vector3d(10,10,10)), 0, App::Prop_None, + ADD_PROPERTY_TYPE ( Size, (Base::Vector3d(10,10,10)), "", App::Prop_None, QT_TRANSLATE_NOOP("App::Property", "The displayed size of the origin")); - Size.setStatus(App::Property::ReadOnly, true); + Size.setStatus(App::PropertyStatus::ReadOnly, true); sPixmap = "Std_CoordinateSystem"; Visibility.setValue(false); diff --git a/src/Gui/ViewProviderOriginFeature.cpp b/src/Gui/ViewProviderOriginFeature.cpp index 3b28561e71c3..2799f9887492 100644 --- a/src/Gui/ViewProviderOriginFeature.cpp +++ b/src/Gui/ViewProviderOriginFeature.cpp @@ -51,11 +51,11 @@ using namespace Gui; PROPERTY_SOURCE(Gui::ViewProviderOriginFeature, Gui::ViewProviderGeometryObject) ViewProviderOriginFeature::ViewProviderOriginFeature () { - ADD_PROPERTY_TYPE ( Size, (ViewProviderOrigin::defaultSize()), 0, App::Prop_ReadOnly, + ADD_PROPERTY_TYPE ( Size, (ViewProviderOrigin::defaultSize()), "", App::Prop_ReadOnly, QT_TRANSLATE_NOOP("App::Property", "Visual size of the feature")); ShapeColor.setValue ( 50.f/255, 150.f/255, 250.f/255 ); // Set default color for origin (light-blue) - BoundingBox.setStatus(App::Property::Hidden, true); // Hide Boundingbox from the user due to it doesn't make sense + BoundingBox.setStatus(App::PropertyStatus::Hidden, true); // Hide Boundingbox from the user due to it doesn't make sense // Create node for scaling the origin pScale = new SoScale (); diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index c8669d99f8e9..97dc79059f00 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -53,6 +53,7 @@ #include #include #include +#include "App/LegacyPropertyStatus.h" using namespace Gui; @@ -65,13 +66,25 @@ std::string ViewProviderPy::representation(void) const PyObject* ViewProviderPy::addProperty(PyObject *args) { char *sType,*sName=0,*sGroup=0,*sDoc=0; + std::string sTypeStr, sNameStr, sGroupStr, sDocStr; short attr=0; - std::string sDocStr; PyObject *ro = Py_False, *hd = Py_False; if (!PyArg_ParseTuple(args, "s|ssethO!O!", &sType,&sName,&sGroup,"utf-8",&sDoc,&attr, &PyBool_Type, &ro, &PyBool_Type, &hd)) // convert args: Python->C return NULL; // NULL triggers exception + if (sType) { + sTypeStr = sType; + } + + if (sName) { + sNameStr = sName; + } + + if (sGroup) { + sGroupStr = sGroup; + } + if (sDoc) { sDocStr = sDoc; PyMem_Free(sDoc); @@ -79,8 +92,10 @@ PyObject* ViewProviderPy::addProperty(PyObject *args) App::Property* prop=0; try { - prop = getViewProviderPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr, - PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); + prop = getViewProviderPtr()->addDynamicProperty(sTypeStr,sNameStr,sGroupStr,sDocStr); + prop->setStatus(App::fromLegacyAttributes(App::StatusCollection(attr))); + prop->setStatus(App::PropertyStatus::Prop_ReadOnly, PyObject_IsTrue(ro) ); + prop->setStatus(App::PropertyStatus::Prop_Hidden ,PyObject_IsTrue(hd) ); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index 56c32885de86..10c48a352054 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -817,18 +817,16 @@ void ViewProviderPythonFeatureImp::updateData(const App::Property* prop) try { if (has__object__) { Py::Tuple args(1); - const char* prop_name = object->getObject()->getPropertyName(prop); - if (prop_name) { - args.setItem(0, Py::String(prop_name)); + if (object->isOwnerOf(*prop)) { + args.setItem(0, Py::String(prop->getName()) ); Base::pyCall(py_updateData.ptr(),args.ptr()); } } else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getObject()->getPyObject(), true)); - const char* prop_name = object->getObject()->getPropertyName(prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + if (object->isOwnerOf(*prop)) { + args.setItem(1, Py::String(prop->getName()) ); Base::pyCall(py_updateData.ptr(),args.ptr()); } } @@ -849,18 +847,16 @@ void ViewProviderPythonFeatureImp::onChanged(const App::Property* prop) try { if (has__object__) { Py::Tuple args(1); - const char* prop_name = object->getPropertyName(prop); - if (prop_name) { - args.setItem(0, Py::String(prop_name)); + if (object->isOwnerOf(*prop)) { + args.setItem(0, Py::String(prop->getName()) ); Base::pyCall(py_onChanged.ptr(),args.ptr()); } } else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - const char* prop_name = object->getPropertyName(prop); - if (prop_name) { - args.setItem(1, Py::String(prop_name)); + if (object->isOwnerOf(*prop)) { + args.setItem(1, Py::String(prop->getName()) ); Base::pyCall(py_onChanged.ptr(),args.ptr()); } } diff --git a/src/Gui/ViewProviderTextDocument.cpp b/src/Gui/ViewProviderTextDocument.cpp index 12ec48505912..c0f07687be03 100644 --- a/src/Gui/ViewProviderTextDocument.cpp +++ b/src/Gui/ViewProviderTextDocument.cpp @@ -65,10 +65,10 @@ ViewProviderTextDocument::ViewProviderTextDocument() ADD_PROPERTY_TYPE(SyntaxHighlighter,(static_cast(0)), "Editor", App::Prop_None, "Syntax highlighting"); SyntaxHighlighter.setEnums(SyntaxEnums); - DisplayMode.setStatus(App::Property::Hidden, true); - OnTopWhenSelected.setStatus(App::Property::Hidden, true); - SelectionStyle.setStatus(App::Property::Hidden, true); - Visibility.setStatus(App::Property::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); + OnTopWhenSelected.setStatus(App::PropertyStatus::Hidden, true); + SelectionStyle.setStatus(App::PropertyStatus::Hidden, true); + Visibility.setStatus(App::PropertyStatus::Hidden, true); } void ViewProviderTextDocument::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) diff --git a/src/Gui/ViewProviderVRMLObject.cpp b/src/Gui/ViewProviderVRMLObject.cpp index 3fd616dd6900..27495ad1a903 100644 --- a/src/Gui/ViewProviderVRMLObject.cpp +++ b/src/Gui/ViewProviderVRMLObject.cpp @@ -251,7 +251,7 @@ void ViewProviderVRMLObject::updateData(const App::Property* prop) } } else if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId()) && - strcmp(prop->getName(), "Placement") == 0) { + strcmp(prop->getName().c_str(), "Placement") == 0) { // Note: If R is the rotation, c the rotation center and t the translation // vector then Inventor applies the following transformation: R*(x-c)+c+t // In FreeCAD a placement only has a rotation and a translation part but diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 99a4ed491722..6c10c9853616 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -392,7 +392,7 @@ void PropertyEditor::setEditorMode(const QModelIndex & parent, int start, int en for (int i=start; i<=end; i++) { QModelIndex item = propertyModel->index(i, column, parent); PropertyItem* propItem = static_cast(item.internalPointer()); - if (!PropertyView::showAll() && propItem && propItem->testStatus(App::Property::Hidden)) { + if (!PropertyView::showAll() && propItem && propItem->testStatus(App::PropertyStatus::Hidden)) { setRowHidden (i, parent, true); } if (propItem && propItem->isSeparator()) { @@ -410,7 +410,7 @@ void PropertyEditor::updateEditorMode(const App::Property& prop) return; bool hidden = PropertyView::isPropertyHidden(&prop); - bool readOnly = prop.testStatus(App::Property::ReadOnly); + bool readOnly = prop.testStatus(App::PropertyStatus::ReadOnly); int column = 1; int numRows = propertyModel->rowCount(); @@ -515,13 +515,9 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { menu.addAction(tr("Add property"))->setData(QVariant(MA_AddProp)); bool canRemove = !props.empty(); - unsigned long propType = 0; - unsigned long propStatus = 0xffffffff; - for(auto prop : props) { - propType |= prop->getType(); - propStatus &= prop->getStatus(); - if(!prop->testStatus(App::Property::PropDynamic) - || prop->testStatus(App::Property::LockDynamic)) + for(auto *prop : props) { + if(!prop->testStatus(App::PropertyStatus::Prop_Dynamic) + || prop->testStatus(App::PropertyStatus::LockDynamic)) { canRemove = false; } @@ -532,10 +528,10 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { if(props.size() == 1) { auto item = static_cast(contextIndex.internalPointer()); auto prop = *props.begin(); - if(item->isBound() + if(item->isBound() && !prop->isDerivedFrom(App::PropertyExpressionEngine::getClassTypeId()) - && !prop->isReadOnly() - && !(prop->getType() & App::Prop_ReadOnly)) + && !prop->testStatus(App::PropertyStatus::ReadOnly) + && !prop->testStatus(App::PropertyStatus::Prop_ReadOnly)) { contextIndex = propertyModel->buddy(contextIndex); setCurrentIndex(contextIndex); @@ -544,7 +540,11 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { } } - if(props.size()) { + if(!props.empty()) { + auto propStatus = (*props.begin())->getStatus(); + for(auto *prop : props) { + propStatus &= prop->getStatus(); + } menu.addSeparator(); QAction *action; @@ -554,12 +554,12 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { action = menu.addAction(text);\ action->setData(QVariant(MA_##_name));\ action->setCheckable(true);\ - if(propStatus & (1<setChecked(true);\ }while(0) #define ACTION_SETUP(_name) do {\ _ACTION_SETUP(_name);\ - if(propType & App::Prop_##_name) {\ + if(propStatus.test(App::PropertyStatus::Prop_##_name)) {\ action->setText(text + QString::fromLatin1(" *"));\ action->setChecked(true);\ }\ @@ -591,7 +591,7 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { #define ACTION_CHECK(_name) \ case MA_##_name:\ for(auto prop : props) \ - prop->setStatus(App::Property::_name,action->isChecked());\ + prop->setStatus(App::PropertyStatus::_name,action->isChecked());\ break ACTION_CHECK(Transient); ACTION_CHECK(ReadOnly); @@ -599,11 +599,8 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) { ACTION_CHECK(Hidden); ACTION_CHECK(EvalOnRestore); case MA_Touched: - for(auto prop : props) { - if(action->isChecked()) - prop->touch(); - else - prop->purgeTouched(); + for(auto *prop : props) { + prop->setStatus(App::PropertyStatus::Touched, action->isChecked()); } break; case MA_Expression: diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 6be34a396bee..6952adede10c 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -148,7 +148,7 @@ void PropertyItem::setPropertyData(const std::vector& items) try { // Check for 'DocumentObject' as parent because otherwise 'ObjectIdentifier' raises an exception App::DocumentObject * docObj = Base::freecad_dynamic_cast(p.getContainer()); - if (docObj && !docObj->isReadOnly(&p)) { + if (docObj->isOwnerOf(p) && !p.testStatus(App::PropertyStatus::ReadOnly)) { App::ObjectIdentifier id(p); std::vector paths; p.getPaths(paths); @@ -175,7 +175,7 @@ void PropertyItem::updateData() it != propertyItems.end(); ++it) { App::PropertyContainer* parent = (*it)->getContainer(); if (parent) - ro &= (parent->isReadOnly(*it) || (*it)->testStatus(App::Property::ReadOnly)); + ro &= (*it)->testStatus(App::PropertyStatus::Prop_ReadOnly) || (*it)->testStatus(App::PropertyStatus::ReadOnly); } this->setReadOnly(ro); } @@ -305,7 +305,7 @@ bool PropertyItem::isLinked() const return linked; } -bool PropertyItem::testStatus(App::Property::Status pos) const +bool PropertyItem::testStatus(App::PropertyStatus pos) const { std::vector::const_iterator it; for (it = propertyItems.begin(); it != propertyItems.end(); ++it) { @@ -333,7 +333,7 @@ QVariant PropertyItem::displayName() const QVariant PropertyItem::toolTip(const App::Property* prop) const { QString str = QApplication::translate("App::Property", - prop->getDocumentation()); + prop->getDocumentation().c_str()); return QVariant(str); } @@ -487,7 +487,7 @@ void PropertyItem::setPropertyValue(const QString& value) it != propertyItems.end(); ++it) { auto prop = *it; App::PropertyContainer* parent = prop->getContainer(); - if (!parent || parent->isReadOnly(prop) || prop->testStatus(App::Property::ReadOnly)) + if (!parent ||prop->testStatus(App::PropertyStatus::Prop_ReadOnly) || prop->testStatus(App::PropertyStatus::ReadOnly)) continue; if (parent->isDerivedFrom(App::Document::getClassTypeId())) { @@ -540,8 +540,8 @@ QVariant PropertyItem::data(int column, int role) const if (role == Qt::BackgroundRole || role == Qt::TextColorRole) { if(PropertyView::showAll() && propertyItems.size() == 1 - && propertyItems.front()->testStatus(App::Property::PropDynamic) - && !propertyItems.front()->testStatus(App::Property::LockDynamic)) + && propertyItems.front()->testStatus(App::PropertyStatus::Prop_Dynamic) + && !propertyItems.front()->testStatus(App::PropertyStatus::LockDynamic)) { return role==Qt::BackgroundRole ? QVariant::fromValue(QColor(0xFF,0xFF,0x99)) diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 571d735109cc..3012606d7a42 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -66,8 +66,8 @@ void _class_::init(void) { \ namespace Gui { -namespace Dialog { -class TaskPlacement; +namespace Dialog { +class TaskPlacement; class DlgPropertyLink; } @@ -136,7 +136,7 @@ class GuiExport PropertyItem : public QObject, public ExpressionBinding void setExpressionEditorData(QWidget *editor, const QVariant& data) const; QVariant expressionEditorData(QWidget *editor) const; - /**override the bind functions to ensure we issue the propertyBound() call, which is then overloaded by + /**override the bind functions to ensure we issue the propertyBound() call, which is then overloaded by childs which like to be informed of a binding*/ virtual void bind(const App::Property& prop); virtual void bind(const App::ObjectIdentifier& _path); @@ -152,7 +152,7 @@ class GuiExport PropertyItem : public QObject, public ExpressionBinding void setReadOnly(bool); bool isReadOnly() const; - bool testStatus(App::Property::Status pos) const; + bool testStatus(App::PropertyStatus pos) const; void setDecimals(int); int decimals() const; @@ -407,7 +407,7 @@ class GuiExport PropertyAngleItem : public PropertyUnitConstraintItem }; /** - * Edit properties of boolean type. + * Edit properties of boolean type. * \author Werner Mayer */ class GuiExport PropertyBoolItem: public PropertyItem @@ -428,7 +428,7 @@ class GuiExport PropertyBoolItem: public PropertyItem }; /** - * Edit properties of vector type. + * Edit properties of vector type. * \author Werner Mayer */ class PropertyFloatItem; @@ -458,7 +458,7 @@ class GuiExport PropertyVectorItem: public PropertyItem protected: PropertyVectorItem(); - virtual void propertyBound(); + virtual void propertyBound(); private: PropertyFloatItem* m_x; @@ -519,7 +519,7 @@ class GuiExport PropertyVectorListItem : public PropertyItem }; /** - * Edit properties of vector type which hold distances. + * Edit properties of vector type which hold distances. * \author Stefan Troeger */ class PropertyUnitItem; @@ -627,7 +627,7 @@ class GuiExport PropertyMatrixItem: public PropertyItem void setA43(double A43); double getA44() const; void setA44(double A44); - + protected: virtual QVariant toString(const QVariant&) const; virtual QVariant value(const App::Property*) const; @@ -653,7 +653,7 @@ class GuiExport PropertyMatrixItem: public PropertyItem PropertyFloatItem* m_a41; PropertyFloatItem* m_a42; PropertyFloatItem* m_a43; - PropertyFloatItem* m_a44; + PropertyFloatItem* m_a44; }; class PlacementEditor : public Gui::LabelButton @@ -677,7 +677,7 @@ private Q_SLOTS: }; /** - * Edit properties of placement type. + * Edit properties of placement type. * \author Werner Mayer */ class GuiExport PropertyPlacementItem: public PropertyItem @@ -721,7 +721,7 @@ class GuiExport PropertyPlacementItem: public PropertyItem }; /** - * Edit properties of enum type. + * Edit properties of enum type. * \author Werner Mayer */ class GuiExport PropertyEnumItem: public PropertyItem @@ -1045,7 +1045,7 @@ protected Q_SLOTS: }; /** - * Edit properties of link type. + * Edit properties of link type. * \author Werner Mayer */ class GuiExport PropertyLinkItem: public PropertyItem diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 41254c580128..350f0b0fbbd2 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -220,7 +220,7 @@ struct PropItemInfo { static void setPropertyItemName(PropertyItem *item, const char *propName, QString groupName) { QString name = QString::fromLatin1(propName); - if(name.size()>groupName.size()+1 + if(name.size()>groupName.size()+1 && name.startsWith(groupName + QLatin1Char('_'))) name = name.right(name.size()-groupName.size()-1); @@ -239,9 +239,8 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props) PropertyModel::PropertyList::const_iterator jt; for (jt = props.begin(); jt != props.end(); ++jt) { App::Property* prop = jt->second.front(); - const char* group = prop->getGroup(); - bool isEmpty = (group == 0 || group[0] == '\0'); - std::string grp = isEmpty ? QT_TRANSLATE_NOOP("App::Property", "Base") : group; + const std::string& group = prop->getGroup(); + std::string grp = group.empty() ? QT_TRANSLATE_NOOP("App::Property", "Base") : group; propGroup[grp].emplace_back(jt->first,jt->second); } @@ -273,7 +272,7 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props) child->setParent(rootItem); rootItem->appendChild(child); - setPropertyItemName(child,prop->getName(),groupName); + setPropertyItemName(child,prop->getName().c_str(),groupName); child->setPropertyData(info.props); } @@ -315,9 +314,8 @@ void PropertyModel::appendProperty(const App::Property& prop) return; } - const char* group = prop.getGroup(); - bool isEmpty = (group == 0 || group[0] == '\0'); - std::string grp = isEmpty ? QT_TRANSLATE_NOOP("App::Property", "Base") : group; + const std::string& group = prop.getGroup(); + std::string grp = group.empty() ? QT_TRANSLATE_NOOP("App::Property", "Base") : group; QString groupName = QString::fromStdString(grp); // go through all group names and check if one matches @@ -383,7 +381,7 @@ void PropertyModel::appendProperty(const App::Property& prop) std::vector data; data.push_back(const_cast(&prop)); - setPropertyItemName(item,prop.getName(),groupName); + setPropertyItemName(item,prop.getName().c_str(),groupName); item->setPropertyData(data); endInsertRows(); diff --git a/src/Mod/Drawing/App/FeatureClip.cpp b/src/Mod/Drawing/App/FeatureClip.cpp index 3931172c5b85..866fd8d2a32d 100644 --- a/src/Mod/Drawing/App/FeatureClip.cpp +++ b/src/Mod/Drawing/App/FeatureClip.cpp @@ -48,11 +48,10 @@ using namespace std; PROPERTY_SOURCE(Drawing::FeatureClip, App::DocumentObjectGroup) -FeatureClip::FeatureClip(void) +FeatureClip::FeatureClip(void) { static const char *group = "Drawing view"; - App::PropertyType hidden = (App::PropertyType)(App::Prop_Hidden); - ADD_PROPERTY_TYPE(ViewResult ,(""),group,hidden,"Resulting SVG view of this clip"); + ADD_PROPERTY_TYPE(ViewResult ,(""),group,App::Prop_Hidden,"Resulting SVG view of this clip"); ADD_PROPERTY_TYPE(X ,(10),group,App::Prop_None ,"The left margin of the view area of this clip"); ADD_PROPERTY_TYPE(Y ,(10),group,App::Prop_None ,"The top margin of the view area of this clip"); ADD_PROPERTY_TYPE(Height ,(10),group,App::Prop_None ,"The height of the view area of this clip"); @@ -60,8 +59,7 @@ FeatureClip::FeatureClip(void) ADD_PROPERTY_TYPE(ShowFrame ,(0),group,App::Prop_None,"Specifies if the clip frame appears on the page or not"); // The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag set to // avoid to call the execute() method. The view provider touches the page object, instead. - App::PropertyType propType = static_cast(App::Prop_Hidden|App::Prop_Output); - ADD_PROPERTY_TYPE(Visible, (true),group,propType,"Control whether frame is visible in page object"); + ADD_PROPERTY_TYPE(Visible, (true),group,App::Prop_Hidden+App::Prop_Output,"Control whether frame is visible in page object"); } FeatureClip::~FeatureClip() @@ -88,7 +86,7 @@ App::DocumentObjectExecReturn *FeatureClip::execute(void) // show clip frame on the page if needed if (ShowFrame.getValue()) { - svg << "StatusBits.set(App::Restore); // the 'Restore' flag + this->setStatus(App::Restore); // the 'Restore' flag Base::FileInfo templateInfo(Template.getValue()); if (!templateInfo.exists()) { @@ -120,7 +120,7 @@ void FeaturePage::onDocumentRestored() Template.setValue(path); } - this->StatusBits.reset(App::Restore); // the 'Restore' flag + this->setStatus(App::Restore, false); // the 'Restore' flag } App::DocumentObjectExecReturn *FeaturePage::execute(void) diff --git a/src/Mod/Drawing/App/FeatureView.cpp b/src/Mod/Drawing/App/FeatureView.cpp index b7321bf0d61c..69f489219e52 100644 --- a/src/Mod/Drawing/App/FeatureView.cpp +++ b/src/Mod/Drawing/App/FeatureView.cpp @@ -47,7 +47,7 @@ PROPERTY_SOURCE(Drawing::FeatureView, App::DocumentObject) -FeatureView::FeatureView(void) +FeatureView::FeatureView(void) { static const char *group = "Drawing view"; ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the drawing in modelling units (mm)"); @@ -56,11 +56,9 @@ FeatureView::FeatureView(void) ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view in degrees counterclockwise"); // The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag set to // avoid to call the execute() method. The view provider touches the page object, instead. - App::PropertyType propType = static_cast(App::Prop_Hidden|App::Prop_Output); - ADD_PROPERTY_TYPE(Visible, (true),group,propType,"Control whether view is visible in page object"); + ADD_PROPERTY_TYPE(Visible, (true),group,App::Prop_Hidden+App::Prop_Output,"Control whether view is visible in page object"); - App::PropertyType type = (App::PropertyType)(App::Prop_Hidden); - ADD_PROPERTY_TYPE(ViewResult ,(0),group,type,"Resulting SVG fragment of that view"); + ADD_PROPERTY_TYPE(ViewResult ,(0),group,App::Prop_Hidden,"Resulting SVG fragment of that view"); } FeatureView::~FeatureView() diff --git a/src/Mod/Drawing/Gui/ViewProviderPage.cpp b/src/Mod/Drawing/Gui/ViewProviderPage.cpp index 3ee0535a7070..791c5d4b9941 100644 --- a/src/Mod/Drawing/Gui/ViewProviderPage.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderPage.cpp @@ -64,8 +64,8 @@ ViewProviderDrawingPage::ViewProviderDrawingPage() ADD_PROPERTY(HintOffsetY,(10.0)); // do not show this in the property editor - Visibility.setStatus(App::Property::Hidden, true); - DisplayMode.setStatus(App::Property::Hidden, true); + Visibility.setStatus(App::PropertyStatus::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); } ViewProviderDrawingPage::~ViewProviderDrawingPage() diff --git a/src/Mod/Drawing/Gui/ViewProviderView.cpp b/src/Mod/Drawing/Gui/ViewProviderView.cpp index f8858d7e11ee..204cab0cd790 100644 --- a/src/Mod/Drawing/Gui/ViewProviderView.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderView.cpp @@ -50,7 +50,7 @@ ViewProviderDrawingView::ViewProviderDrawingView() sPixmap = "Page"; // Do not show in property editor - DisplayMode.setStatus(App::Property::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); } ViewProviderDrawingView::~ViewProviderDrawingView() @@ -148,7 +148,7 @@ ViewProviderDrawingClip::ViewProviderDrawingClip() sPixmap = "Page"; // Do not show in property editor - DisplayMode.setStatus(App::Property::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); } ViewProviderDrawingClip::~ViewProviderDrawingClip() diff --git a/src/Mod/Fem/App/FemAnalysis.cpp b/src/Mod/Fem/App/FemAnalysis.cpp index 1d686d246533..2c49f3f8832f 100644 --- a/src/Mod/Fem/App/FemAnalysis.cpp +++ b/src/Mod/Fem/App/FemAnalysis.cpp @@ -41,7 +41,7 @@ PROPERTY_SOURCE(Fem::FemAnalysis, App::DocumentObjectGroup) FemAnalysis::FemAnalysis() { Base::Uuid id; - ADD_PROPERTY_TYPE(Uid,(id),0,App::Prop_None,"UUID of the Analysis"); + ADD_PROPERTY_TYPE(Uid,(id),"",App::Prop_None,"UUID of the Analysis"); } FemAnalysis::~FemAnalysis() diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index 35e7c098a6c2..0e42d84e3445 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -77,9 +77,9 @@ PROPERTY_SOURCE(Fem::Constraint, App::DocumentObject) Constraint::Constraint() { - ADD_PROPERTY_TYPE(References,(0,0),"Constraint",(App::PropertyType)(App::Prop_None),"Elements where the constraint is applied"); - ADD_PROPERTY_TYPE(NormalDirection,(Base::Vector3d(0,0,1)),"Constraint",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),"Normal direction pointing outside of solid"); - ADD_PROPERTY_TYPE(Scale,(1),"Base",App::PropertyType(App::Prop_Output),"Scale used for drawing constraints"); //OvG: Add scale parameter inherited by all derived constraints + ADD_PROPERTY_TYPE(References,(0,0),"Constraint",App::Prop_None,"Elements where the constraint is applied"); + ADD_PROPERTY_TYPE(NormalDirection,(Base::Vector3d(0,0,1)),"Constraint",App::Prop_ReadOnly+App::Prop_Output,"Normal direction pointing outside of solid"); + ADD_PROPERTY_TYPE(Scale,(1),"Base",App::Prop_Output,"Scale used for drawing constraints"); //OvG: Add scale parameter inherited by all derived constraints References.setScope(App::LinkScope::Global); } diff --git a/src/Mod/Fem/App/FemConstraintBearing.cpp b/src/Mod/Fem/App/FemConstraintBearing.cpp index 79fb24763f63..65ffb44a3bc5 100644 --- a/src/Mod/Fem/App/FemConstraintBearing.cpp +++ b/src/Mod/Fem/App/FemConstraintBearing.cpp @@ -45,15 +45,15 @@ PROPERTY_SOURCE(Fem::ConstraintBearing, Fem::Constraint) ConstraintBearing::ConstraintBearing() { - ADD_PROPERTY_TYPE(Location,(0),"ConstraintBearing",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(Location,(0),"ConstraintBearing",App::Prop_None, "Element giving axial location of constraint"); ADD_PROPERTY(Dist,(0.0)); ADD_PROPERTY(AxialFree,(0)); ADD_PROPERTY(Radius,(0.0)); ADD_PROPERTY(Height,(0.0)); - ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintBearing",App::Prop_ReadOnly+App::Prop_Output, "Base point of cylindrical bearing seat"); - ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintBearing",App::Prop_ReadOnly+App::Prop_Output, "Axis of bearing seat"); } diff --git a/src/Mod/Fem/App/FemConstraintContact.cpp b/src/Mod/Fem/App/FemConstraintContact.cpp index 390f09efc43e..d33519eb81ae 100644 --- a/src/Mod/Fem/App/FemConstraintContact.cpp +++ b/src/Mod/Fem/App/FemConstraintContact.cpp @@ -47,9 +47,9 @@ ConstraintContact::ConstraintContact() ADD_PROPERTY(Friction,(0.0)); /* */ - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintContact",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintContact",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintContact",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintContact",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintDisplacement.cpp b/src/Mod/Fem/App/FemConstraintDisplacement.cpp index 6a50add28c88..661d6121003e 100644 --- a/src/Mod/Fem/App/FemConstraintDisplacement.cpp +++ b/src/Mod/Fem/App/FemConstraintDisplacement.cpp @@ -80,9 +80,9 @@ ConstraintDisplacement::ConstraintDisplacement() ADD_PROPERTY(rotzFree,(1)); ADD_PROPERTY(zRotation,(0.0)); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintFixed.cpp b/src/Mod/Fem/App/FemConstraintFixed.cpp index 4d809454903f..f8c67493ccbf 100644 --- a/src/Mod/Fem/App/FemConstraintFixed.cpp +++ b/src/Mod/Fem/App/FemConstraintFixed.cpp @@ -54,9 +54,9 @@ PROPERTY_SOURCE(Fem::ConstraintFixed, Fem::Constraint) ConstraintFixed::ConstraintFixed() { - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp b/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp index a34dc50772a5..7f5ff4d95642 100644 --- a/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/App/FemConstraintFluidBoundary.cpp @@ -69,46 +69,46 @@ static const char* ThermalBoundaryHelpTexts[] = {"fixed Temperature [K]", "no he ConstraintFluidBoundary::ConstraintFluidBoundary() { /// momemtum boundary: pressure and velocity - ADD_PROPERTY_TYPE(BoundaryType,(1),"FluidBoundary",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(BoundaryType,(1),"FluidBoundary",App::Prop_None, "Basic boundary type like inlet, wall, outlet,etc"); BoundaryType.setEnums(BoundaryTypes); - ADD_PROPERTY_TYPE(Subtype,(1),"FluidBoundary",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(Subtype,(1),"FluidBoundary",App::Prop_None, "Subtype defines more specific boundary types"); Subtype.setEnums(WallSubtypes); - ADD_PROPERTY_TYPE(BoundaryValue,(0.0),"FluidBoundary",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(BoundaryValue,(0.0),"FluidBoundary",App::Prop_None, "Scaler value for the specific value subtype, like pressure, velocity magnitude"); /// Direction should be allowed to edit in property editor, if no edge is available in CAD model - ADD_PROPERTY_TYPE(Direction,(0),"FluidBoundary",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(Direction,(0),"FluidBoundary",App::Prop_None, "Vector direction of BoundaryValue"); - ADD_PROPERTY_TYPE(Reversed,(0),"FluidBoundary",(App::PropertyType)(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Reversed,(0),"FluidBoundary",App::Prop_ReadOnly+App::Prop_Output, "To distinguish inlet (flow outward from solid) or outlet boundary condition"); /// turbulence model setup for boundary - ADD_PROPERTY_TYPE(TurbulenceSpecification,(1),"Turbulence",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TurbulenceSpecification,(1),"Turbulence",App::Prop_None, "Method to specify burbulence magnitude on the boundary"); TurbulenceSpecification.setEnums(TurbulenceSpecifications); // Turbulence Specification Method - ADD_PROPERTY_TYPE(TurbulentIntensityValue,(0.0),"Turbulence",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TurbulentIntensityValue,(0.0),"Turbulence",App::Prop_None, "Scaler value for Turbulent intensity etc"); - ADD_PROPERTY_TYPE(TurbulentLengthValue,(0.0),"Turbulence",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TurbulentLengthValue,(0.0),"Turbulence",App::Prop_None, "Scaler value for Turbulent length scale, hydraulic diameter etc"); /// consider using the newly added Fem::ConstraintTemperature, but it is too hard to export the settings - ADD_PROPERTY_TYPE(ThermalBoundaryType,(1),"HeatTransfer",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(ThermalBoundaryType,(1),"HeatTransfer",App::Prop_None, "Thermal boundary type"); ThermalBoundaryType.setEnums(ThermalBoundaryTypes); - ADD_PROPERTY_TYPE(TemperatureValue,(0.0),"HeatTransfer",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TemperatureValue,(0.0),"HeatTransfer",App::Prop_None, "Temperature value for thermal boundary condition"); - ADD_PROPERTY_TYPE(HeatFluxValue,(0.0),"HeatTransfer",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(HeatFluxValue,(0.0),"HeatTransfer",App::Prop_None, "Heat flux value for thermal boundary condition"); - ADD_PROPERTY_TYPE(HTCoeffValue,(0.0),"HeatTransfer",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(HTCoeffValue,(0.0),"HeatTransfer",App::Prop_None, "Heat transfer coefficient for convective boundary condition"); /// geometry rendering related properties - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"FluidBoundary",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"FluidBoundary",App::Prop_ReadOnly+App::Prop_Output, "Points where arrows are drawn"); Points.setValues(std::vector()); - ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"FluidBoundary",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"FluidBoundary",App::Prop_ReadOnly+App::Prop_Output, "Direction of arrows"); naturalDirectionVector = Base::Vector3d(0,0,0); // by default use the null vector to indicate an invalid value // property from: FemConstraintFixed object - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"FluidBoundary",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"FluidBoundary",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Normals.setValues(std::vector()); } diff --git a/src/Mod/Fem/App/FemConstraintForce.cpp b/src/Mod/Fem/App/FemConstraintForce.cpp index 45397cdc6e12..cdccabb7e895 100644 --- a/src/Mod/Fem/App/FemConstraintForce.cpp +++ b/src/Mod/Fem/App/FemConstraintForce.cpp @@ -46,12 +46,12 @@ PROPERTY_SOURCE(Fem::ConstraintForce, Fem::Constraint) ConstraintForce::ConstraintForce() { ADD_PROPERTY(Force,(0.0)); - ADD_PROPERTY_TYPE(Direction,(0),"ConstraintForce",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(Direction,(0),"ConstraintForce",App::Prop_None, "Element giving direction of constraint"); ADD_PROPERTY(Reversed,(0)); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintForce",App::Prop_ReadOnly+App::Prop_Output, "Points where arrows are drawn"); - ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"ConstraintForce",App::Prop_ReadOnly+App::Prop_Output, "Direction of arrows"); naturalDirectionVector = Base::Vector3d(0,0,0); // by default use the null vector to indicate an invalid value Points.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintGear.cpp b/src/Mod/Fem/App/FemConstraintGear.cpp index 39a59847c64d..386ee828a327 100644 --- a/src/Mod/Fem/App/FemConstraintGear.cpp +++ b/src/Mod/Fem/App/FemConstraintGear.cpp @@ -48,10 +48,10 @@ ConstraintGear::ConstraintGear() ADD_PROPERTY(Diameter,(100.0)); ADD_PROPERTY(Force,(1000.0)); ADD_PROPERTY(ForceAngle,(0.0)); - ADD_PROPERTY_TYPE(Direction,(0),"ConstraintGear",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(Direction,(0),"ConstraintGear",App::Prop_None, "Element giving direction of gear force"); ADD_PROPERTY(Reversed,(0)); - ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(1,1,1).Normalize()),"ConstraintGear",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(1,1,1).Normalize()),"ConstraintGear",App::Prop_ReadOnly+App::Prop_Output, "Direction of gear force"); naturalDirectionVector = Base::Vector3d(1,1,1).Normalize(); } diff --git a/src/Mod/Fem/App/FemConstraintHeatflux.cpp b/src/Mod/Fem/App/FemConstraintHeatflux.cpp index 9485b9790734..f61d79550c7f 100644 --- a/src/Mod/Fem/App/FemConstraintHeatflux.cpp +++ b/src/Mod/Fem/App/FemConstraintHeatflux.cpp @@ -49,13 +49,13 @@ ConstraintHeatflux::ConstraintHeatflux() /*ADD_PROPERTY(FaceTemp,(0.0));*/ ADD_PROPERTY(FilmCoef,(0.0)); ADD_PROPERTY(DFlux,(0.0)); - ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintHeatflux",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintHeatflux",App::Prop_None, "Type of constraint, surface convection or surface heat flux"); ConstraintType.setEnums(ConstraintTypes); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintHeatflux",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintHeatflux",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp b/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp index ace92e206130..4892e9ac66a7 100644 --- a/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp @@ -46,15 +46,15 @@ ConstraintInitialTemperature::ConstraintInitialTemperature() { ADD_PROPERTY(initialTemperature,(300.0)); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintInitialTemperature",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintInitialTemperature",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); - References.setStatus(App::Property::ReadOnly, true); - References.setStatus(App::Property::Hidden, true); + References.setStatus(App::PropertyStatus::ReadOnly, true); + References.setStatus(App::PropertyStatus::Hidden, true); } App::DocumentObjectExecReturn *ConstraintInitialTemperature::execute(void) diff --git a/src/Mod/Fem/App/FemConstraintPlaneRotation.cpp b/src/Mod/Fem/App/FemConstraintPlaneRotation.cpp index 283184014119..1bcbd1b21292 100644 --- a/src/Mod/Fem/App/FemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/App/FemConstraintPlaneRotation.cpp @@ -43,9 +43,9 @@ PROPERTY_SOURCE(Fem::ConstraintPlaneRotation, Fem::Constraint) ConstraintPlaneRotation::ConstraintPlaneRotation() { - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPlaneRotation",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPlaneRotation",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPlaneRotation",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPlaneRotation",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintPressure.cpp b/src/Mod/Fem/App/FemConstraintPressure.cpp index 75365ba96009..9feb6e0d6eca 100644 --- a/src/Mod/Fem/App/FemConstraintPressure.cpp +++ b/src/Mod/Fem/App/FemConstraintPressure.cpp @@ -44,10 +44,10 @@ ConstraintPressure::ConstraintPressure() ADD_PROPERTY(Pressure,(0.0)); ADD_PROPERTY(Reversed,(0)); ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPressure", - App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + App::Prop_ReadOnly+App::Prop_Output, "Points where arrows are drawn"); ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPressure", - App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintPulley.cpp b/src/Mod/Fem/App/FemConstraintPulley.cpp index 634857523b08..3db820ddf7da 100644 --- a/src/Mod/Fem/App/FemConstraintPulley.cpp +++ b/src/Mod/Fem/App/FemConstraintPulley.cpp @@ -50,11 +50,11 @@ ConstraintPulley::ConstraintPulley() ADD_PROPERTY(IsDriven,(0)); ADD_PROPERTY(TensionForce,(0.0)); - ADD_PROPERTY_TYPE(BeltAngle,(0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(BeltAngle,(0),"ConstraintPulley",App::Prop_ReadOnly+App::Prop_Output, "Angle of belt forces"); - ADD_PROPERTY_TYPE(BeltForce1,(0.0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(BeltForce1,(0.0),"ConstraintPulley",App::Prop_ReadOnly+App::Prop_Output, "First belt force"); - ADD_PROPERTY_TYPE(BeltForce2,(0.0),"ConstraintPulley",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(BeltForce2,(0.0),"ConstraintPulley",App::Prop_ReadOnly+App::Prop_Output, "Second belt force"); ForceAngle.setValue(00.0); Diameter.setValue(300.0); diff --git a/src/Mod/Fem/App/FemConstraintTemperature.cpp b/src/Mod/Fem/App/FemConstraintTemperature.cpp index 363a34b07f2b..2711c93d5cef 100644 --- a/src/Mod/Fem/App/FemConstraintTemperature.cpp +++ b/src/Mod/Fem/App/FemConstraintTemperature.cpp @@ -48,13 +48,13 @@ ConstraintTemperature::ConstraintTemperature() { ADD_PROPERTY(Temperature,(300.0)); ADD_PROPERTY(CFlux,(0.0)); - ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintTemperature",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintTemperature",App::Prop_None, "Type of constraint, temperature or concentrated heat flux"); ConstraintType.setEnums(ConstraintTypes); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTemperature",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTemperature",App::Prop_ReadOnly+App::Prop_Output, "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); diff --git a/src/Mod/Fem/App/FemConstraintTransform.cpp b/src/Mod/Fem/App/FemConstraintTransform.cpp index 4f2e2c172c10..4378613d5dc0 100644 --- a/src/Mod/Fem/App/FemConstraintTransform.cpp +++ b/src/Mod/Fem/App/FemConstraintTransform.cpp @@ -47,19 +47,19 @@ ConstraintTransform::ConstraintTransform() ADD_PROPERTY(X_rot,(0.0)); //numeric value, 0.0 ADD_PROPERTY(Y_rot,(0.0)); ADD_PROPERTY(Z_rot,(0.0)); - ADD_PROPERTY_TYPE(TransformType,(1),"ConstraintTransform",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TransformType,(1),"ConstraintTransform",App::Prop_None, "Type of transform, rectangular or cylindrical"); TransformType.setEnums(TransformTypes); - ADD_PROPERTY_TYPE(RefDispl,(0,0),"ConstraintTransform",(App::PropertyType)(App::Prop_None),"Elements where the constraint is applied"); - ADD_PROPERTY_TYPE(NameDispl,(0),"ConstraintTransform",(App::PropertyType)(App::Prop_None),"Elements where the constraint is applied"); - ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintTransform",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(RefDispl,(0,0),"ConstraintTransform",App::Prop_None,"Elements where the constraint is applied"); + ADD_PROPERTY_TYPE(NameDispl,(0),"ConstraintTransform",App::Prop_None,"Elements where the constraint is applied"); + ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintTransform",App::Prop_ReadOnly+App::Prop_Output, "Base point of cylindrical surface"); - ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintTransform",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintTransform",App::Prop_ReadOnly+App::Prop_Output, "Axis of cylindrical surface"); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTransform",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTransform",App::Prop_ReadOnly+App::Prop_Output, "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTransform",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), - "Normals where symbols are drawn"); + ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTransform",App::Prop_ReadOnly+App::Prop_Output, + "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); } diff --git a/src/Mod/Fem/App/FemPostFilter.cpp b/src/Mod/Fem/App/FemPostFilter.cpp index 805b1973165b..2ca761204aed 100644 --- a/src/Mod/Fem/App/FemPostFilter.cpp +++ b/src/Mod/Fem/App/FemPostFilter.cpp @@ -194,9 +194,9 @@ FemPostDataAlongLineFilter::FemPostDataAlongLineFilter(void) : FemPostFilter() { ADD_PROPERTY_TYPE(YAxisData,(0), "DataAlongLine",App::Prop_None,"Y axis data values used for plotting"); ADD_PROPERTY_TYPE(PlotData ,(""),"DataAlongLine",App::Prop_None,"Field used for plotting"); - PlotData.setStatus(App::Property::ReadOnly, true); - XAxisData.setStatus(App::Property::ReadOnly, true); - YAxisData.setStatus(App::Property::ReadOnly, true); + PlotData.setStatus(App::PropertyStatus::ReadOnly, true); + XAxisData.setStatus(App::PropertyStatus::ReadOnly, true); + YAxisData.setStatus(App::PropertyStatus::ReadOnly, true); FilterPipeline clip; @@ -312,9 +312,9 @@ FemPostDataAtPointFilter::FemPostDataAtPointFilter(void) : FemPostFilter() { ADD_PROPERTY_TYPE(FieldName,(""),"DataAtPoint",App::Prop_None,"Field used for plotting"); ADD_PROPERTY_TYPE(Unit,(""),"DataAtPoint",App::Prop_None,"Unit used for Field"); - PointData.setStatus(App::Property::ReadOnly, true); - FieldName.setStatus(App::Property::ReadOnly, true); - Unit.setStatus(App::Property::ReadOnly, true); + PointData.setStatus(App::PropertyStatus::ReadOnly, true); + FieldName.setStatus(App::PropertyStatus::ReadOnly, true); + Unit.setStatus(App::PropertyStatus::ReadOnly, true); FilterPipeline clip; diff --git a/src/Mod/Fem/App/FemResultObject.cpp b/src/Mod/Fem/App/FemResultObject.cpp index 5f96d237ffcc..91bb1e684659 100644 --- a/src/Mod/Fem/App/FemResultObject.cpp +++ b/src/Mod/Fem/App/FemResultObject.cpp @@ -44,9 +44,9 @@ FemResultObject::FemResultObject() ADD_PROPERTY_TYPE(Time,(0), "Data",Prop_None,"Time of analysis increment"); // make read-only for property editor - NodeNumbers.setStatus(App::Property::ReadOnly, true); - Stats.setStatus(App::Property::ReadOnly, true); - Time.setStatus(App::Property::ReadOnly, true); + NodeNumbers.setStatus(App::PropertyStatus::ReadOnly, true); + Stats.setStatus(App::PropertyStatus::ReadOnly, true); + Time.setStatus(App::PropertyStatus::ReadOnly, true); } FemResultObject::~FemResultObject() diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp index 16d36031e127..b48969a8f94c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp @@ -114,10 +114,10 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) // Gets called whenever a property of the attached object changes Fem::ConstraintBearing* pcConstraint = static_cast(this->getObject()); - if (strcmp(prop->getName(),"References") == 0) + if (prop->getName() == "References") Base::Console().Error("\n"); // enable a breakpoint here - if (strcmp(prop->getName(),"BasePoint") == 0) { + if (prop->getName() == "BasePoint") { // Remove and recreate the symbol Gui::coinRemoveAllChildren(pShapeSep); @@ -133,7 +133,7 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) createPlacement(pShapeSep, b, rot); pShapeSep->addChild(createFixed(radius/2, radius/2 * 1.5, pcConstraint->AxialFree.getValue())); - } else if (strcmp(prop->getName(),"AxialFree") == 0) { + } else if (prop->getName() == "AxialFree") { if (pShapeSep->getNumChildren() > 0) { // Change the symbol Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp index e18800257be4..0c9f3c8e75a3 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp @@ -113,7 +113,7 @@ void ViewProviderFemConstraintContact::updateData(const App::Property* prop) float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index b9fa4f3120cd..f081db1266ee 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -146,7 +146,7 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index 41f20556832c..673ab64c7488 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -130,7 +130,7 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp index 2bcd624095ce..e2b024b39c7a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp @@ -125,7 +125,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue(); std::string boundaryType = pcConstraint->BoundaryType.getValueAsString(); - if (strcmp(prop->getName(),"BoundaryType") == 0) + if (prop->getName() == "BoundaryType") { if (boundaryType == "wall") { @@ -161,7 +161,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); #ifdef USE_MULTIPLE_COPY @@ -204,7 +204,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro cp->matrix.finishEditing(); #endif } - else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector" + else if (prop->getName() == "DirectionVector") { // Note: "Reversed" also triggers "DirectionVector" // Re-orient all arrows Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); @@ -259,7 +259,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 8b6c3aaf68e1..abec00066c58 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -130,7 +130,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); #ifdef USE_MULTIPLE_COPY @@ -173,7 +173,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) cp->matrix.finishEditing(); #endif } - else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector" + else if (prop->getName() == "DirectionVector") { // Note: "Reversed" also triggers "DirectionVector" // Re-orient all arrows Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index 62d644f1f135..d0f8d74f1ce3 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -113,7 +113,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Fem::ConstraintGear* pcConstraint = static_cast(this->getObject()); // Gets called whenever a property of the attached object changes - if (strcmp(prop->getName(),"BasePoint") == 0) { + if (prop->getName() == "BasePoint") { if (pcConstraint->Height.getValue() > Precision::Confusion()) { // Remove and recreate the symbol Gui::coinRemoveAllChildren(pShapeSep); @@ -139,7 +139,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) createPlacement(pShapeSep, SbVec3f(dia/2 * sin(angle), 0, dia/2 * cos(angle)), SbRotation(ax, dir)); pShapeSep->addChild(createArrow(dia/2, dia/8)); } - } else if (strcmp(prop->getName(),"Diameter") == 0) { + } else if (prop->getName() == "Diameter") { if (pShapeSep->getNumChildren() > 0) { // Change the symbol Base::Vector3d axis = pcConstraint->Axis.getValue(); @@ -161,7 +161,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) sep = static_cast(pShapeSep->getChild(5)); updateArrow(sep, 0, dia/2, dia/8); } - } else if ((strcmp(prop->getName(),"DirectionVector") == 0) || (strcmp(prop->getName(),"ForceAngle") == 0)) { + } else if ((prop->getName() == "DirectionVector") || (prop->getName() == "ForceAngle")) { // Note: "Reversed" also triggers "DirectionVector" if (pShapeSep->getNumChildren() > 0) { // Re-orient the symbol diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp index 104053078fbb..b7d277797087 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp @@ -112,7 +112,7 @@ void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop) // //float facetemp = pcConstraint->FaceTemp.getValue(); //float filmcoef = pcConstraint->FilmCoef.getValue(); - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp index e98a78c90d35..fcef02f497f9 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp @@ -111,7 +111,7 @@ void ViewProviderFemConstraintPlaneRotation::updateData(const App::Property* pro float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp index 8d1deefdf3ee..5892b588a449 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp @@ -112,7 +112,7 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) } #endif - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp index d9c30481f9cd..39df422be74c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp @@ -112,7 +112,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) // Gets called whenever a property of the attached object changes Fem::ConstraintPulley* pcConstraint = static_cast(this->getObject()); - if (strcmp(prop->getName(),"BasePoint") == 0) { + if (prop->getName() == "BasePoint") { if (pcConstraint->Height.getValue() > Precision::Confusion()) { // Remove and recreate the symbol Gui::coinRemoveAllChildren(pShapeSep); @@ -152,7 +152,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) sep->addChild(createArrow(dia/8 + dia/2 * rat2, dia/8)); pShapeSep->addChild(sep); // child 4 } - } else if (strcmp(prop->getName(),"Diameter") == 0) { + } else if (prop->getName() == "Diameter") { if (pShapeSep->getNumChildren() > 0) { // Change the symbol double radius = pcConstraint->Radius.getValue(); @@ -184,7 +184,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) subsep = static_cast(sep->getChild(4)); updateArrow(subsep, 0, dia/8 + dia/2 * rat2, dia/8); } - } else if ((strcmp(prop->getName(), "ForceAngle") == 0) || (strcmp(prop->getName(), "BeltAngle") == 0)) { + } else if ((prop->getName() == "ForceAngle") || (prop->getName() == "BeltAngle")) { if (pShapeSep->getNumChildren() > 0) { double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); @@ -200,7 +200,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) updatePlacement(sep, 0, SbVec3f(-dia/2 * sin(forceAngle-beltAngle), 0, -dia/2 * cos(forceAngle-beltAngle)), SbRotation(SbVec3f(0,1,0), SbVec3f(-sin(forceAngle-beltAngle-M_PI_2),0,-cos(forceAngle-beltAngle-M_PI_2)))); } - } else if ((strcmp(prop->getName(), "BeltForce1") == 0) || (strcmp(prop->getName(), "BeltForce2") == 0)) { + } else if ((prop->getName() == "BeltForce1") || (prop->getName() == "BeltForce2")) { if (pShapeSep->getNumChildren() > 0) { double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp index d03b70f9a730..7da1179444dc 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp @@ -111,7 +111,7 @@ void ViewProviderFemConstraintTemperature::updateData(const App::Property* prop) float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); //float temperature = pcConstraint->temperature.getValue(); - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp index 2c808ed84246..a516ea60787e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp @@ -127,7 +127,7 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) std::string transform_type = pcConstraint->TransformType.getValueAsString(); if (transform_type == "Rectangular") { - if (strcmp(prop->getName(),"Points") == 0) { + if (prop->getName() == "Points") { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); if (points.size() != normals.size()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index 76959d7c79a4..bfa7146cbc50 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -113,7 +113,7 @@ void ViewProviderFemPostFunctionProvider::onChanged(const App::Property* prop) { void ViewProviderFemPostFunctionProvider::updateData(const App::Property* prop) { Gui::ViewProviderDocumentObject::updateData(prop); - if(strcmp(prop->getName(), "Functions") == 0) { + if (prop->getName() == "Functions") { updateSize(); } } @@ -428,13 +428,13 @@ void PlaneWidget::setViewProvider(ViewProviderFemPostFunction* view) { void PlaneWidget::onChange(const App::Property& p) { setBlockObjectUpdates(true); - if(strcmp(p.getName(), "Normal") == 0) { + if (p.getName() == "Normal") { const Base::Vector3d& vec = static_cast(&p)->getValue(); ui->normalX->setValue(vec.x); ui->normalY->setValue(vec.y); ui->normalZ->setValue(vec.z); } - else if(strcmp(p.getName(), "Origin") == 0) { + else if (p.getName() == "Origin") { const Base::Vector3d& vec = static_cast(&p)->getValue(); ui->originX->setValue(vec.x); ui->originY->setValue(vec.y); @@ -587,11 +587,11 @@ void SphereWidget::setViewProvider(ViewProviderFemPostFunction* view) { void SphereWidget::onChange(const App::Property& p) { setBlockObjectUpdates(true); - if(strcmp(p.getName(), "Radius") == 0) { + if (p.getName() == "Radius") { double val = static_cast(&p)->getValue(); ui->radius->setValue(val); } - else if(strcmp(p.getName(), "Center") == 0) { + else if (p.getName() == "Center") { const Base::Vector3d& vec = static_cast(&p)->getValue(); ui->centerX->setValue(vec.x); ui->centerY->setValue(vec.y); diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index 5294aeac0219..02cc169ea62e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -509,7 +509,7 @@ void ViewProviderFemPostObject::WriteTransparency() { void ViewProviderFemPostObject::updateData(const App::Property* p) { - if( strcmp(p->getName(), "Data") == 0 ) { + if (p->getName() == "Data") { updateVtk(); } } diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp index 139fe1b762de..b21a262bd72d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp @@ -62,7 +62,7 @@ std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren3D void ViewProviderFemPostPipeline::updateData(const App::Property* prop) { FemGui::ViewProviderFemPostObject::updateData(prop); - if(strcmp(prop->getName(), "Function") == 0) { + if (prop->getName() == "Function") { updateFunctionSize(); } diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index f04cc0c6fe0c..8b7b1440b72e 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -72,8 +72,8 @@ PROPERTY_SOURCE(InspectionGui::ViewProviderInspection, Gui::ViewProviderDocument ViewProviderInspection::ViewProviderInspection() : search_radius(FLT_MAX) { - ADD_PROPERTY_TYPE(OutsideGrayed,(false),"",(App::PropertyType) (App::Prop_Output|App::Prop_Hidden),""); - ADD_PROPERTY_TYPE(PointSize,(1.0),"Display",(App::PropertyType) (App::Prop_None/*App::Prop_Hidden*/),""); + ADD_PROPERTY_TYPE(OutsideGrayed,(false),"",App::Prop_Output+App::Prop_Hidden,""); + ADD_PROPERTY_TYPE(PointSize,(1.0),"Display",App::Prop_None/*App::Prop_Hidden*/,""); PointSize.setConstraints(&floatRange); pcColorRoot = new SoSeparator(); @@ -82,7 +82,7 @@ ViewProviderInspection::ViewProviderInspection() : search_radius(FLT_MAX) pcMatBinding->ref(); pcColorMat = new SoMaterial; pcColorMat->ref(); - pcColorStyle = new SoDrawStyle(); + pcColorStyle = new SoDrawStyle(); pcColorRoot->addChild(pcColorStyle); pcCoords = new SoCoordinate3; pcCoords->ref(); @@ -169,7 +169,7 @@ void ViewProviderInspection::attach(App::DocumentObject *pcFeat) if (pcBar) { float fMin = pcColorBar->getMinValue(); float fMax = pcColorBar->getMaxValue(); - + // Attach to the foreign color bar and delete our own bar pcBar->Attach(this); pcBar->ref(); @@ -288,7 +288,7 @@ void ViewProviderInspection::updateData(const App::Property* prop) } } else if (prop->getTypeId() == App::PropertyFloat::getClassTypeId()) { - if (strcmp(prop->getName(), "SearchRadius") == 0) { + if (prop->getName() == "SearchRadius") { float fSearchRadius = ((App::PropertyFloat*)prop)->getValue(); this->search_radius = fSearchRadius; pcColorBar->setRange( -fSearchRadius, fSearchRadius, 4 ); @@ -313,7 +313,7 @@ void ViewProviderInspection::setDistances() return; } if (pDistances->getTypeId() != Inspection::PropertyDistanceList::getClassTypeId()) { - SoDebugError::post("ViewProviderInspection::setDistances", + SoDebugError::post("ViewProviderInspection::setDistances", "Property 'Distances' has type %s (Inspection::PropertyDistanceList was expected)", pDistances->getTypeId().getName()); return; } @@ -575,7 +575,7 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const float fVal1 = (*dist)[index1]; float fVal2 = (*dist)[index2]; float fVal3 = (*dist)[index3]; - + App::Property* pActual = this->pcObject->getPropertyByName("Actual"); if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) { float fSearchRadius = this->search_radius; diff --git a/src/Mod/Mesh/App/MeshFeature.cpp b/src/Mod/Mesh/App/MeshFeature.cpp index 8ef2dbacc572..65e785515265 100644 --- a/src/Mod/Mesh/App/MeshFeature.cpp +++ b/src/Mod/Mesh/App/MeshFeature.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include "Core/MeshIO.h" @@ -49,7 +49,7 @@ PROPERTY_SOURCE(Mesh::Feature, App::GeoFeature) Feature::Feature() { - ADD_PROPERTY_TYPE(Mesh,(MeshObject()),0,App::Prop_Output,"The mesh kernel"); + ADD_PROPERTY_TYPE(Mesh,(MeshObject()),"",App::Prop_Output,"The mesh kernel"); } Feature::~Feature() diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp index cf4ef6631b2b..892b54f06b75 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp @@ -231,7 +231,7 @@ void DlgEvaluateMeshImp::slotChangedObject(const App::DocumentObject& Obj, const else if (Obj.getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { // if the label has changed update the entry in the list if (Prop.getTypeId() == App::PropertyString::getClassTypeId() && - strcmp(Prop.getName(), "Label") == 0) { + Prop.getName() == "Label") { QString label = QString::fromUtf8(Obj.Label.getValue()); QString name = QString::fromLatin1(Obj.getNameInDocument()); int index = d->ui.meshNameButton->findData(name); @@ -248,7 +248,7 @@ void DlgEvaluateMeshImp::slotDeletedDocument(const App::Document& Doc) delete it->second; } - d->vp.clear(); + d->vp.clear(); // try to attach to the active document this->detachDocument(); @@ -262,7 +262,7 @@ void DlgEvaluateMeshImp::setMesh(Mesh::Feature* m) App::Document* doc = m->getDocument(); if (doc != getDocument()) attachDocument(doc); - + refreshList(); int ct = d->ui.meshNameButton->count(); @@ -492,7 +492,7 @@ void DlgEvaluateMeshImp::on_repairOrientationButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairOrientationButton->setEnabled(false); d->ui.checkOrientationButton->setChecked(false); removeViewProvider( "MeshGui::ViewProviderMeshOrientation" ); @@ -594,7 +594,7 @@ void DlgEvaluateMeshImp::on_repairNonmanifoldsButton_clicked() , "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()" , docName, objName); } - } + } catch (const Base::Exception& e) { QMessageBox::warning(this, tr("Non-manifolds"), QString::fromLatin1(e.what())); } @@ -604,7 +604,7 @@ void DlgEvaluateMeshImp::on_repairNonmanifoldsButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairNonmanifoldsButton->setEnabled(false); d->ui.checkNonmanifoldsButton->setChecked(false); removeViewProvider("MeshGui::ViewProviderMeshNonManifolds"); @@ -635,7 +635,7 @@ void DlgEvaluateMeshImp::on_analyzeIndicesButton_clicked() MeshEvalRangePoint rp(rMesh); MeshEvalCorruptedFacets cf(rMesh); MeshEvalNeighbourhood nb(rMesh); - + if (!rf.Evaluate()) { d->ui.checkIndicesButton->setText(tr("Invalid face indices")); d->ui.checkIndicesButton->setChecked(true); @@ -694,7 +694,7 @@ void DlgEvaluateMeshImp::on_repairIndicesButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairIndicesButton->setEnabled(false); d->ui.checkIndicesButton->setChecked(false); removeViewProvider("MeshGui::ViewProviderMeshIndices"); @@ -722,7 +722,7 @@ void DlgEvaluateMeshImp::on_analyzeDegeneratedButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalDegeneratedFacets eval(rMesh, d->epsilonDegenerated); std::vector degen = eval.GetIndices(); - + if (degen.empty()) { d->ui.checkDegenerationButton->setText(tr("No degenerations")); d->ui.checkDegenerationButton->setChecked(false); @@ -788,7 +788,7 @@ void DlgEvaluateMeshImp::on_analyzeDuplicatedFacesButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalDuplicateFacets eval(rMesh); std::vector dupl = eval.GetIndices(); - + if (dupl.empty()) { d->ui.checkDuplicatedFacesButton->setText(tr("No duplicated faces")); d->ui.checkDuplicatedFacesButton->setChecked(false); @@ -827,7 +827,7 @@ void DlgEvaluateMeshImp::on_repairDuplicatedFacesButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairDuplicatedFacesButton->setEnabled(false); d->ui.checkDuplicatedFacesButton->setChecked(false); removeViewProvider("MeshGui::ViewProviderMeshDuplicatedFaces"); @@ -854,7 +854,7 @@ void DlgEvaluateMeshImp::on_analyzeDuplicatedPointsButton_clicked() const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); MeshEvalDuplicatePoints eval(rMesh); - + if (eval.Evaluate()) { d->ui.checkDuplicatedPointsButton->setText(tr("No duplicated points")); d->ui.checkDuplicatedPointsButton->setChecked(false); @@ -892,7 +892,7 @@ void DlgEvaluateMeshImp::on_repairDuplicatedPointsButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairDuplicatedPointsButton->setEnabled(false); d->ui.checkDuplicatedPointsButton->setChecked(false); removeViewProvider("MeshGui::ViewProviderMeshDuplicatedPoints"); @@ -982,7 +982,7 @@ void DlgEvaluateMeshImp::on_repairSelfIntersectionButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + d->ui.repairSelfIntersectionButton->setEnabled(false); d->ui.checkSelfIntersectionButton->setChecked(false); removeViewProvider("MeshGui::ViewProviderMeshSelfIntersections"); @@ -1014,7 +1014,7 @@ void DlgEvaluateMeshImp::on_analyzeFoldsButton_clicked() bool ok1 = s_eval.Evaluate(); bool ok2 = b_eval.Evaluate(); bool ok3 = f_eval.Evaluate(); - + if (ok1 && ok2 && ok3) { d->ui.checkFoldsButton->setText(tr("No folds on surface")); d->ui.checkFoldsButton->setChecked(false); @@ -1031,7 +1031,7 @@ void DlgEvaluateMeshImp::on_analyzeFoldsButton_clicked() // remove duplicates std::sort(inds.begin(), inds.end()); inds.erase(std::unique(inds.begin(), inds.end()), inds.end()); - + d->ui.checkFoldsButton->setText(tr("%1 folds on surface").arg(inds.size())); d->ui.checkFoldsButton->setChecked(true); d->ui.repairFoldsButton->setEnabled(true); @@ -1063,7 +1063,7 @@ void DlgEvaluateMeshImp::on_repairFoldsButton_clicked() doc->commitCommand(); doc->getDocument()->recompute(); - + qApp->restoreOverrideCursor(); d->ui.repairFoldsButton->setEnabled(false); d->ui.checkFoldsButton->setChecked(false); diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index 1343450329dc..87e69e5e7114 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -289,7 +289,7 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp) int face_index = fd->getFaceIndex(); if (face_index >= (int)facets.size()) return; - // is a border facet picked? + // is a border facet picked? MeshCore::MeshFacet f = facets[face_index]; if (!f.HasOpenEdge()) { // check if a neighbour facet is at the border @@ -418,7 +418,7 @@ namespace MeshGui { // for sorting of elements struct NofFacetsCompare { - bool operator () (const std::vector &rclC1, + bool operator () (const std::vector &rclC1, const std::vector &rclC2) { return rclC1.size() < rclC2.size(); @@ -542,7 +542,7 @@ void MeshFillHole::closeBridge() void MeshFillHole::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) { - if (&Obj == myMesh && strcmp(Prop.getName(),"Mesh") == 0) { + if (&Obj == myMesh && Prop.getName() == "Mesh") { Gui::coinRemoveAllChildren(myBoundariesGroup); myVertex->point.setNum(0); myNumPoints = 0; @@ -576,7 +576,7 @@ void MeshFillHole::createPolygons() borders.sort(NofFacetsCompare()); int32_t count=0; - for (std::list >::iterator it = + for (std::list >::iterator it = borders.begin(); it != borders.end(); ++it) { if (it->front() == it->back()) it->pop_back(); @@ -589,7 +589,7 @@ void MeshFillHole::createPolygons() coords->point.setNum(count); int32_t index = 0; - for (std::list >::iterator it = + for (std::list >::iterator it = borders.begin(); it != borders.end(); ++it) { SoPolygon* polygon = new SoPolygon(); polygon->startIndex = index; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 1cb57b763f11..43d51f2c72e7 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -325,7 +325,7 @@ ViewProviderMesh::ViewProviderMesh() : pcOpenEdge(0) SelectionStyle.setValue(1); } - Coloring.setStatus(App::Property::Hidden, true); + Coloring.setStatus(App::PropertyStatus::Hidden, true); } ViewProviderMesh::~ViewProviderMesh() @@ -486,7 +486,7 @@ void ViewProviderMesh::attach(App::DocumentObject *pcFeat) addDisplayMaskMode(pcFlatWireRoot, "Flat Lines"); if (getColorProperty()) { - Coloring.setStatus(App::Property::Hidden, false); + Coloring.setStatus(App::PropertyStatus::Hidden, false); } } @@ -496,7 +496,7 @@ void ViewProviderMesh::updateData(const App::Property* prop) //if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { //} if (prop->getTypeId() == App::PropertyColorList::getClassTypeId()) { - Coloring.setStatus(App::Property::Hidden, false); + Coloring.setStatus(App::PropertyStatus::Hidden, false); } } diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index 9a2be718f34e..4a03f4fd0edb 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -41,10 +41,9 @@ EXTENSION_PROPERTY_SOURCE(Part::AttachExtension, App::DocumentObjectExtension) AttachExtension::AttachExtension() : _attacher(0) { - EXTENSION_ADD_PROPERTY_TYPE(AttacherType, ("Attacher::AttachEngine3D"), "Attachment",(App::PropertyType)(App::Prop_None),"Class name of attach engine object driving the attachment."); - this->AttacherType.setStatus(App::Property::Status::Hidden, true); + EXTENSION_ADD_PROPERTY_TYPE(AttacherType, ("Attacher::AttachEngine3D"), "Attachment",App::Prop_None+App::Hidden,"Class name of attach engine object driving the attachment."); - EXTENSION_ADD_PROPERTY_TYPE(Support, (0,0), "Attachment",(App::PropertyType)(App::Prop_None),"Support of the 2D geometry"); + EXTENSION_ADD_PROPERTY_TYPE(Support, (0,0), "Attachment",App::Prop_None,"Support of the 2D geometry"); EXTENSION_ADD_PROPERTY_TYPE(MapMode, (mmDeactivated), "Attachment", App::Prop_None, "Mode of attachment to other object"); MapMode.setEditorName("PartGui::PropertyEnumAttacherItem"); @@ -59,9 +58,9 @@ AttachExtension::AttachExtension() EXTENSION_ADD_PROPERTY_TYPE(AttachmentOffset, (Base::Placement()), "Attachment", App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)"); // Only show these properties when applicable. Controlled by extensionOnChanged - this->MapPathParameter.setStatus(App::Property::Status::Hidden, true); - this->MapReversed.setStatus(App::Property::Status::Hidden, true); - this->AttachmentOffset.setStatus(App::Property::Status::Hidden, true); + this->MapPathParameter.setStatus(App::PropertyStatus::Hidden, true); + this->MapReversed.setStatus(App::PropertyStatus::Hidden, true); + this->AttachmentOffset.setStatus(App::PropertyStatus::Hidden, true); setAttacher(new AttachEngine3D);//default attacher initExtensionType(AttachExtension::getExtensionClassTypeId()); @@ -203,10 +202,10 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) hasOneRef = true; } - this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); - this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); - this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); - getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. + this->MapPathParameter.setStatus(App::PropertyStatus::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); + this->MapReversed.setStatus(App::PropertyStatus::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::PropertyStatus::Hidden, !bAttached); + getPlacement().setStatus(App::ReadOnly, bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. } } @@ -248,10 +247,10 @@ void AttachExtension::onExtendedDocumentRestored() hasOneRef = true; } - this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); - this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); - this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); - getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. + this->MapPathParameter.setStatus(App::PropertyStatus::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); + this->MapReversed.setStatus(App::PropertyStatus::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::PropertyStatus::Hidden, !bAttached); + getPlacement().setStatus(App::ReadOnly, bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. } catch (Base::Exception&) { } @@ -280,7 +279,7 @@ App::PropertyPlacement& AttachExtension::getPlacement() const { } PyObject* AttachExtension::getExtensionPyObject(void) { - + if (ExtensionPythonObject.is(Py::_None())){ // ref counter is set to 1 ExtensionPythonObject = Py::Object(new AttachExtensionPy(this),true); diff --git a/src/Mod/Part/App/FeatureCompound.cpp b/src/Mod/Part/App/FeatureCompound.cpp index c66ba91e8618..6a5989a9e322 100644 --- a/src/Mod/Part/App/FeatureCompound.cpp +++ b/src/Mod/Part/App/FeatureCompound.cpp @@ -111,7 +111,7 @@ App::DocumentObjectExecReturn *Compound::execute(void) PROPERTY_SOURCE(Part::Compound2, Part::Compound) Compound2::Compound2() { - Shape.setStatus(App::Property::Transient,true); + Shape.setStatus(App::PropertyStatus::Transient,true); } void Compound2::onDocumentRestored() { diff --git a/src/Mod/Part/App/FeatureOffset.cpp b/src/Mod/Part/App/FeatureOffset.cpp index 5fc375b54707..7b365f32fe14 100644 --- a/src/Mod/Part/App/FeatureOffset.cpp +++ b/src/Mod/Part/App/FeatureOffset.cpp @@ -102,7 +102,7 @@ PROPERTY_SOURCE(Part::Offset2D, Part::Offset) Offset2D::Offset2D() { - this->SelfIntersection.setStatus(App::Property::Status::Hidden, true); + this->SelfIntersection.setStatus(App::PropertyStatus::Hidden, true); this->Mode.setValue(1); //switch to Pipe mode by default, because skin mode does not function properly on closed profiles. } diff --git a/src/Mod/Part/App/FeaturePartBoolean.cpp b/src/Mod/Part/App/FeaturePartBoolean.cpp index eb6ec947150f..a467e9852494 100644 --- a/src/Mod/Part/App/FeaturePartBoolean.cpp +++ b/src/Mod/Part/App/FeaturePartBoolean.cpp @@ -44,11 +44,11 @@ Boolean::Boolean(void) { ADD_PROPERTY(Base,(0)); ADD_PROPERTY(Tool,(0)); - ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", (App::PropertyType) - (App::Prop_Output|App::Prop_Transient|App::Prop_Hidden), "Shape history"); + ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", + App::Prop_Output+App::Prop_Transient+App::Prop_Hidden, "Shape history"); History.setSize(0); - ADD_PROPERTY_TYPE(Refine,(0),"Boolean",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after this boolean operation"); + ADD_PROPERTY_TYPE(Refine,(0),"Boolean",App::Prop_None,"Refine shape (clean up redundant edges) after this boolean operation"); //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() diff --git a/src/Mod/Part/App/FeaturePartBox.cpp b/src/Mod/Part/App/FeaturePartBox.cpp index c3281aa4ccae..181068344286 100644 --- a/src/Mod/Part/App/FeaturePartBox.cpp +++ b/src/Mod/Part/App/FeaturePartBox.cpp @@ -98,8 +98,10 @@ void Box::Restore(Base::XMLReader &reader) for (int i=0;isetStatusValue(reader.getAttributeAsUnsigned("status")); + if(prop && reader.hasAttribute("status")) { + auto status= App::StatusCollection(reader.getAttribute("status")); + prop->setStatus(status); + } } bool location_xyz = false; @@ -118,17 +120,16 @@ void Box::Restore(Base::XMLReader &reader) if(!prop) prop = getPropertyByName(PropName); - std::bitset<32> status; + if(reader.hasAttribute("status")) { - status = reader.getAttributeAsUnsigned("status"); - if(prop) - prop->setStatusValue(status.to_ulong()); + if(prop) { + auto status= App::StatusCollection(reader.getAttribute("status")); + prop->setStatus(status); + } } if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) { - if (!prop->testStatus(App::Property::Transient) - && !status.test(App::Property::Transient) - && !status.test(App::Property::PropTransient) - && !(getPropertyType(prop) & App::Prop_Transient)) + if (!prop->testStatus(App::PropertyStatus::Transient) + && !prop->testStatus(App::PropertyStatus::Prop_Transient)) { prop->Restore(reader); } @@ -206,7 +207,7 @@ void Box::Restore(Base::XMLReader &reader) if (location_xyz) { plm.setPosition(Base::Vector3d(x.getValue(),y.getValue(),z.getValue())); this->Placement.setValue(this->Placement.getValue() * plm); - this->Shape.setStatus(App::Property::User1, true); // override the shape's location later on + this->Shape.setStatus(App::PropertyStatus::User1, true); // override the shape's location later on } // for 0.8 releases else if (location_axis) { @@ -217,7 +218,7 @@ void Box::Restore(Base::XMLReader &reader) plm.setRotation(rot); plm.setPosition(Base::Vector3d(p.x,p.y,p.z)); this->Placement.setValue(this->Placement.getValue() * plm); - this->Shape.setStatus(App::Property::User1, true); // override the shape's location later on + this->Shape.setStatus(App::PropertyStatus::User1, true); // override the shape's location later on } reader.readEndElement("Properties"); @@ -233,8 +234,8 @@ void Box::onChanged(const App::Property* prop) } else if (prop == &this->Shape) { // see Box::Restore - if (this->Shape.testStatus(App::Property::User1)) { - this->Shape.setStatus(App::Property::User1, false); + if (this->Shape.testStatus(App::PropertyStatus::User1)) { + this->Shape.setStatus(App::PropertyStatus::User1, false); App::DocumentObjectExecReturn *ret = recompute(); delete ret; return; diff --git a/src/Mod/Part/App/FeaturePartCommon.cpp b/src/Mod/Part/App/FeaturePartCommon.cpp index e5f8388a53b1..76d89cb2a5fd 100644 --- a/src/Mod/Part/App/FeaturePartCommon.cpp +++ b/src/Mod/Part/App/FeaturePartCommon.cpp @@ -63,11 +63,11 @@ MultiCommon::MultiCommon(void) { ADD_PROPERTY(Shapes,(0)); Shapes.setSize(0); - ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", (App::PropertyType) - (App::Prop_Output|App::Prop_Transient|App::Prop_Hidden), "Shape history"); + ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", + App::Prop_Output+App::Prop_Transient+App::Prop_Hidden, "Shape history"); History.setSize(0); - ADD_PROPERTY_TYPE(Refine,(0),"Boolean",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after this boolean operation"); + ADD_PROPERTY_TYPE(Refine,(0),"Boolean",App::Prop_None,"Refine shape (clean up redundant edges) after this boolean operation"); //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() diff --git a/src/Mod/Part/App/FeaturePartFuse.cpp b/src/Mod/Part/App/FeaturePartFuse.cpp index bd3296549eb6..69113cca267b 100644 --- a/src/Mod/Part/App/FeaturePartFuse.cpp +++ b/src/Mod/Part/App/FeaturePartFuse.cpp @@ -62,11 +62,11 @@ MultiFuse::MultiFuse(void) { ADD_PROPERTY(Shapes,(0)); Shapes.setSize(0); - ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", (App::PropertyType) - (App::Prop_Output|App::Prop_Transient|App::Prop_Hidden), "Shape history"); + ADD_PROPERTY_TYPE(History,(ShapeHistory()), "Boolean", + App::Prop_Output+App::Prop_Transient+App::Prop_Hidden, "Shape history"); History.setSize(0); - ADD_PROPERTY_TYPE(Refine,(0),"Boolean",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after this boolean operation"); + ADD_PROPERTY_TYPE(Refine,(0),"Boolean",App::Prop_None,"Refine shape (clean up redundant edges) after this boolean operation"); //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index 0b53c14a8381..48f4e429b647 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -75,8 +75,8 @@ void Revolution::onChanged(const App::Property* prop) { if(! this->isRestoring()){ if(prop == &AxisLink){ - Base.setReadOnly(AxisLink.getValue() != nullptr); - Axis.setReadOnly(AxisLink.getValue() != nullptr); + Base.setStatus(App::PropertyStatus::ReadOnly, AxisLink.getValue() != nullptr); + Axis.setStatus(App::PropertyStatus::ReadOnly, AxisLink.getValue() != nullptr); } } Part::Feature::onChanged(prop); diff --git a/src/Mod/Part/App/PartFeature.cpp b/src/Mod/Part/App/PartFeature.cpp index 252a2d089140..ca68ab18fefc 100644 --- a/src/Mod/Part/App/PartFeature.cpp +++ b/src/Mod/Part/App/PartFeature.cpp @@ -235,12 +235,11 @@ struct ShapeCache { } void slotChanged(const App::DocumentObject &obj, const App::Property &prop) { - const char *propName = prop.getName(); - if(!propName) - return; - if(strcmp(propName,"Shape")==0 - || strcmp(propName,"Group")==0 - || strstr(propName,"Touched")!=0) + const std::string& propName= prop.getName(); + + if(propName == "Shape" + || propName == "Group" + || propName.find("Touched") != std::string::npos) slotClear(obj); } diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 119078c35fe7..5cffe09d4eab 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -191,7 +191,7 @@ void Primitive::onChanged(const App::Property* prop) if (!isRestoring()) { // Do not support sphere, ellipsoid and torus because the creation // takes too long and thus is not feasible - std::string grp = (prop->getGroup() ? prop->getGroup() : ""); + std::string grp = prop->getGroup(); if (grp == "Plane" || grp == "Cylinder" || grp == "Cone") { try { App::DocumentObjectExecReturn *ret = recompute(); diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp index b4dc8ca5c226..45dcf59753c5 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp +++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp @@ -64,14 +64,14 @@ PROPERTY_SOURCE(PartGui::ViewProvider2DObjectGrid, PartGui::ViewProvider2DObject ViewProvider2DObjectGrid::ViewProvider2DObjectGrid() { - ADD_PROPERTY_TYPE(ShowGrid,(false),"Grid",(App::PropertyType)(App::Prop_None),"Switch the grid on/off"); - ADD_PROPERTY_TYPE(ShowOnlyInEditMode,(true),"Grid",(App::PropertyType)(App::Prop_None),"Show only while in edit mode"); - ADD_PROPERTY_TYPE(GridSize,(10.0),"Grid",(App::PropertyType)(App::Prop_None),"Gap size of the grid"); - ADD_PROPERTY_TYPE(GridStyle,(0L),"Grid",(App::PropertyType)(App::Prop_None),"Appearance style of the grid"); - ADD_PROPERTY_TYPE(TightGrid,(true),"Grid",(App::PropertyType)(App::Prop_None),"Switch the tight grid mode on/off"); - ADD_PROPERTY_TYPE(GridSnap,(false),"Grid",(App::PropertyType)(App::Prop_None),"Switch the grid snap on/off"); - ADD_PROPERTY_TYPE(GridAutoSize,(true),"Grid",(App::PropertyType)(App::Prop_Hidden),"Autosize grid based on shape boundbox"); - ADD_PROPERTY_TYPE(maxNumberOfLines,(10000),"Grid",(App::PropertyType)(App::Prop_None),"Maximum Number of Lines in grid"); + ADD_PROPERTY_TYPE(ShowGrid,(false),"Grid",App::Prop_None,"Switch the grid on/off"); + ADD_PROPERTY_TYPE(ShowOnlyInEditMode,(true),"Grid",App::Prop_None,"Show only while in edit mode"); + ADD_PROPERTY_TYPE(GridSize,(10.0),"Grid",App::Prop_None,"Gap size of the grid"); + ADD_PROPERTY_TYPE(GridStyle,(0L),"Grid",App::Prop_None,"Appearance style of the grid"); + ADD_PROPERTY_TYPE(TightGrid,(true),"Grid",App::Prop_None,"Switch the tight grid mode on/off"); + ADD_PROPERTY_TYPE(GridSnap,(false),"Grid",App::Prop_None,"Switch the grid snap on/off"); + ADD_PROPERTY_TYPE(GridAutoSize,(true),"Grid",App::Prop_Hidden,"Autosize grid based on shape boundbox"); + ADD_PROPERTY_TYPE(maxNumberOfLines,(10000),"Grid",App::Prop_None,"Maximum Number of Lines in grid"); GridRoot = new SoAnnotation(); GridRoot->ref(); diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 5dcfd971359b..45f0427a2f05 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -937,8 +937,8 @@ void ViewProviderPartExt::reload() void ViewProviderPartExt::updateData(const App::Property* prop) { - const char *propName = prop->getName(); - if (propName && (strcmp(propName, "Shape") == 0 || strstr(propName, "Touched") != nullptr)) { + const std::string &propName = prop->getName(); + if ( propName == "Shape" || propName.find("Touched") != std::string::npos) { // calculate the visual only if visible if (isUpdateForced() || Visibility.getValue()) updateVisual(); diff --git a/src/Mod/Part/Gui/ViewProviderSpline.cpp b/src/Mod/Part/Gui/ViewProviderSpline.cpp index e9d1ce23c4e7..f5a73a1e3bb2 100644 --- a/src/Mod/Part/Gui/ViewProviderSpline.cpp +++ b/src/Mod/Part/Gui/ViewProviderSpline.cpp @@ -98,7 +98,7 @@ void ViewProviderSpline::toggleControlPoints(bool on) void ViewProviderSpline::updateData(const App::Property* prop) { ViewProviderPartExt::updateData(prop); - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && strcmp(prop->getName(), "Shape") == 0) { + if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && prop->getName() == "Shape") { // update control points if there if (pcControlPoints) { Gui::coinRemoveAllChildren(pcControlPoints); @@ -345,7 +345,7 @@ void ViewProviderSplineExtension::extensionSetupContextMenu(QMenu* menu, QObject void ViewProviderSplineExtension::extensionUpdateData(const App::Property* prop) { Gui::ViewProviderExtension::extensionUpdateData(prop); - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && strcmp(prop->getName(), "Shape") == 0) { + if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && prop->getName() == "Shape") { // update control points if there if (pcControlPoints) { Gui::coinRemoveAllChildren(pcControlPoints); diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index face2936ebc3..0560101c8ff7 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -55,7 +55,7 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Body, Part::BodyBase) Body::Body() { - _GroupTouched.setStatus(App::Property::Output,true); + _GroupTouched.setStatus(App::PropertyStatus::Output,true); } /* @@ -543,7 +543,7 @@ void Body::onDocumentRestored() if(obj->isDerivedFrom(PartDesign::Feature::getClassTypeId())) static_cast(obj)->_Body.setValue(this); } - _GroupTouched.setStatus(App::Property::Output,true); + _GroupTouched.setStatus(App::PropertyStatus::Output,true); DocumentObject::onDocumentRestored(); } diff --git a/src/Mod/PartDesign/App/DatumLine.cpp b/src/Mod/PartDesign/App/DatumLine.cpp index bd63bf1c96fd..687cc61da3e1 100644 --- a/src/Mod/PartDesign/App/DatumLine.cpp +++ b/src/Mod/PartDesign/App/DatumLine.cpp @@ -50,7 +50,7 @@ Line::Line() ADD_PROPERTY_TYPE(ResizeMode,(static_cast(0)), "Size", App::Prop_Output, "Automatic or manual resizing"); ResizeMode.setEnums(ResizeModeEnums); ADD_PROPERTY_TYPE(Length,(20), "Size", App::Prop_Output, "Length of the line"); - Length.setReadOnly(true); + Length.setStatus(App::PropertyStatus::ReadOnly,true); this->setAttacher(new AttachEngineLine); // Create a shape, which will be used by the Sketcher. Them main function is to avoid a dependency of @@ -81,10 +81,10 @@ void Line::onChanged(const App::Property *prop) { if (prop == &ResizeMode) { if (ResizeMode.getValue() == 0) { - Length.setReadOnly(true); + Length.setStatus(App::PropertyStatus::ReadOnly,true); } else { - Length.setReadOnly(false); + Length.setStatus(App::PropertyStatus::ReadOnly,false); } } Datum::onChanged(prop); diff --git a/src/Mod/PartDesign/App/DatumPlane.cpp b/src/Mod/PartDesign/App/DatumPlane.cpp index 8e065ba83414..87a93c2e392f 100644 --- a/src/Mod/PartDesign/App/DatumPlane.cpp +++ b/src/Mod/PartDesign/App/DatumPlane.cpp @@ -52,8 +52,8 @@ Plane::Plane() ADD_PROPERTY_TYPE(Length,(20), "Size", App::Prop_Output, "Length of the plane"); ADD_PROPERTY_TYPE(Width,(20), "Size", App::Prop_Output, "Width of the plane"); - Length.setReadOnly(true); - Width.setReadOnly(true); + Length.setStatus(App::PropertyStatus::ReadOnly,true); + Width.setStatus(App::PropertyStatus::ReadOnly,true); this->setAttacher(new AttachEnginePlane); // Create a shape, which will be used by the Sketcher. Them main function is to avoid a dependency of @@ -91,12 +91,12 @@ void Plane::onChanged(const App::Property *prop) { if (prop == &ResizeMode) { if (ResizeMode.getValue() == 0) { - Length.setReadOnly(true); - Width.setReadOnly(true); + Length.setStatus(App::PropertyStatus::ReadOnly,true); + Width.setStatus(App::PropertyStatus::ReadOnly,true); } else { - Length.setReadOnly(false); - Width.setReadOnly(false); + Length.setStatus(App::PropertyStatus::ReadOnly,false); + Width.setStatus(App::PropertyStatus::ReadOnly,false); } } diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index c9cba283245d..53b2a4c61b35 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -57,10 +57,10 @@ PROPERTY_SOURCE(PartDesign::Feature,Part::Feature) Feature::Feature() { ADD_PROPERTY(BaseFeature,(0)); - ADD_PROPERTY_TYPE(_Body,(0),"Base",(App::PropertyType)( - App::Prop_ReadOnly|App::Prop_Hidden|App::Prop_Output|App::Prop_Transient),0); - Placement.setStatus(App::Property::Hidden, true); - BaseFeature.setStatus(App::Property::Hidden, true); + ADD_PROPERTY_TYPE(_Body,(0),"Base", + App::Prop_ReadOnly+App::Prop_Hidden+App::Prop_Output+App::Prop_Transient,""); + Placement.setStatus(App::PropertyStatus::Hidden, true); + BaseFeature.setStatus(App::PropertyStatus::Hidden, true); } short Feature::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeatureAddSub.cpp b/src/Mod/PartDesign/App/FeatureAddSub.cpp index 335d8e3c4cbc..01c70b84f540 100644 --- a/src/Mod/PartDesign/App/FeatureAddSub.cpp +++ b/src/Mod/PartDesign/App/FeatureAddSub.cpp @@ -46,7 +46,7 @@ FeatureAddSub::FeatureAddSub() : addSubType(Additive) { ADD_PROPERTY(AddSubShape,(TopoDS_Shape())); - ADD_PROPERTY_TYPE(Refine,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting"); + ADD_PROPERTY_TYPE(Refine,(0),"Part Design",App::Prop_None,"Refine shape (clean up redundant edges) after adding/subtracting"); //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); diff --git a/src/Mod/PartDesign/App/FeatureBase.cpp b/src/Mod/PartDesign/App/FeatureBase.cpp index 123af4b02ebc..91273ee7d1b4 100644 --- a/src/Mod/PartDesign/App/FeatureBase.cpp +++ b/src/Mod/PartDesign/App/FeatureBase.cpp @@ -40,7 +40,7 @@ PROPERTY_SOURCE(PartDesign::FeatureBase,PartDesign::Feature) FeatureBase::FeatureBase() { BaseFeature.setScope(App::LinkScope::Global); - BaseFeature.setStatus(App::Property::Hidden, false); + BaseFeature.setStatus(App::PropertyStatus::Hidden, false); } Part::Feature* FeatureBase::getBaseObject(bool) const { @@ -96,7 +96,7 @@ void FeatureBase::onDocumentRestored() // if the base is not part of a body then show its placement property again auto body = getFeatureBody(); if (!body) - Placement.setStatus(App::Property::Hidden, false); + Placement.setStatus(App::PropertyStatus::Hidden, false); } }//namespace PartDesign diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index 16f89ff3e499..4f2c9a840ab1 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -57,7 +57,7 @@ Boolean::Boolean() ADD_PROPERTY(Type,((long)0)); Type.setEnums(TypeEnums); - ADD_PROPERTY_TYPE(Refine,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting"); + ADD_PROPERTY_TYPE(Refine,(0),"Part Design",App::Prop_None,"Refine shape (clean up redundant edges) after adding/subtracting"); Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); this->Refine.setValue(hGrp->GetBool("RefineModel", false)); @@ -164,7 +164,7 @@ App::DocumentObjectExecReturn *Boolean::execute(void) void Boolean::onChanged(const App::Property* prop) { - if(strcmp(prop->getName(), "Group") == 0) + if(prop->getName() == "Group") touch(); PartDesign::Feature::onChanged(prop); diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index 7980872c15b9..a0cf809be551 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -244,7 +244,7 @@ void Chamfer::updateProperties() auto chamferType = ChamferType.getValue(); auto disableproperty = [](App::Property * prop, bool on) { - prop->setStatus(App::Property::ReadOnly, on); + prop->setStatus(App::PropertyStatus::ReadOnly, on); }; switch (chamferType) { diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 18afe45e9320..b58dea2fcc99 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -74,8 +74,8 @@ Draft::Draft() { ADD_PROPERTY(Angle,(1.5)); Angle.setConstraints(&floatAngle); - ADD_PROPERTY_TYPE(NeutralPlane,(0),"Draft",(App::PropertyType)(App::Prop_None),"NeutralPlane"); - ADD_PROPERTY_TYPE(PullDirection,(0),"Draft",(App::PropertyType)(App::Prop_None),"PullDirection"); + ADD_PROPERTY_TYPE(NeutralPlane,(0),"Draft",App::Prop_None,"NeutralPlane"); + ADD_PROPERTY_TYPE(PullDirection,(0),"Draft",App::Prop_None,"PullDirection"); ADD_PROPERTY(Reversed,(0)); } diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index dc16fb2ef4fb..6ecfc974bdee 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -48,13 +48,13 @@ PROPERTY_SOURCE(PartDesign::DressUp, PartDesign::FeatureAddSub) DressUp::DressUp() { ADD_PROPERTY(Base,(0)); - Placement.setStatus(App::Property::ReadOnly, true); + Placement.setStatus(App::PropertyStatus::ReadOnly, true); ADD_PROPERTY_TYPE(SupportTransform,(false),"Base", App::Prop_None, "Include the base additive/subtractive shape when used in pattern features.\n" "If disabled, only the dressed part of the shape is used for patterning."); - AddSubShape.setStatus(App::Property::Output, true); + AddSubShape.setStatus(App::PropertyStatus::Output, true); } short DressUp::mustExecute() const @@ -211,7 +211,7 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap for(Feature *current=this; ;current=static_cast(base)) { base = Base::freecad_dynamic_cast(current->getBaseObject(true)); if(!base) - FC_THROWM(Base::CADKernelError, + FC_THROWM(Base::CADKernelError, "Cannot find additive or subtractive support for " << getFullName()); if(!base->isDerivedFrom(DressUp::getClassTypeId())) break; diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index 27cc5653a8f5..1f8c6e417835 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -62,7 +62,7 @@ Groove::Groove() ADD_PROPERTY_TYPE(Base,(Base::Vector3d(0.0f,0.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Base"); ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0f,1.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Axis"); ADD_PROPERTY_TYPE(Angle,(360.0),"Groove", App::Prop_None, "Angle"); - ADD_PROPERTY_TYPE(ReferenceAxis,(0),"Groove",(App::PropertyType)(App::Prop_None),"Reference axis of Groove"); + ADD_PROPERTY_TYPE(ReferenceAxis,(0),"Groove",App::Prop_None,"Reference axis of Groove"); } short Groove::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 508753a15630..575fb25d8138 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -607,7 +607,7 @@ Hole::Hole() ADD_PROPERTY_TYPE(ThreadDirection, (0L), "Hole", App::Prop_None, "Thread direction"); ThreadDirection.setEnums(ThreadDirectionEnums); - ThreadDirection.setReadOnly(true); + ThreadDirection.setStatus(App::PropertyStatus::ReadOnly,true); ADD_PROPERTY_TYPE(HoleCutType, (0L), "Hole", App::Prop_None, "Head cut type"); HoleCutType.setEnums(HoleCutType_None_Enums); @@ -686,9 +686,9 @@ void Hole::updateHoleCutParams() } if (HoleCutDepth.getValue() == 0.0) HoleCutDepth.setValue(dimen.depth); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); } else if (holeCutTypeStr == "Countersink") { // read ISO 10642 values @@ -697,7 +697,7 @@ void Hole::updateHoleCutParams() const CounterSinkDimension& dimen = counter.get_sink(threadSizeStr); if (dimen.diameter != 0.0) { HoleCutDiameter.setValue(dimen.diameter); - } + } else { HoleCutDiameter.setValue(Diameter.getValue() + 0.1); } @@ -706,9 +706,9 @@ void Hole::updateHoleCutParams() if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(counter.angle); } - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } // cut definition @@ -718,37 +718,37 @@ void Hole::updateHoleCutParams() if (counter.cut_type == CutDimensionSet::Counterbore) { // disable HoleCutCountersinkAngle and reset it to ISO's default HoleCutCountersinkAngle.setValue(90.0); - HoleCutCountersinkAngle.setReadOnly(true); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); const CounterBoreDimension &dimen = counter.get_bore(threadSizeStr); if (dimen.thread == "None") { // valid values for visual feedback HoleCutDiameter.setValue(Diameter.getValue() + 0.1); HoleCutDepth.setValue(0.1); // we force custom values since there are no normed ones - HoleCutCustomValues.setReadOnly(true); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly,true); // important to set only if not already true, to avoid loop call of updateHoleCutParams() if (!HoleCutCustomValues.getValue()) { HoleCutCustomValues.setValue(true); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); } } else { // set normed values if not overwritten or if previously there // were no normed values available and thus HoleCutCustomValues is checked and read-only if (!HoleCutCustomValues.getValue() - || (HoleCutCustomValues.getValue() && HoleCutCustomValues.isReadOnly())) { + || (HoleCutCustomValues.getValue() && HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly))) { HoleCutDiameter.setValue(dimen.diameter); HoleCutDepth.setValue(dimen.depth); - HoleCutDiameter.setReadOnly(true); - HoleCutDepth.setReadOnly(true); - if (HoleCutCustomValues.getValue() && HoleCutCustomValues.isReadOnly()) + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly,true); + if (HoleCutCustomValues.getValue() && HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)) HoleCutCustomValues.setValue(false); } else { - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); } - HoleCutCustomValues.setReadOnly(false); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly, false); } } else if (counter.cut_type == CutDimensionSet::Countersink) { const CounterSinkDimension &dimen = counter.get_sink(threadSizeStr); @@ -760,33 +760,33 @@ void Hole::updateHoleCutParams() HoleCutCountersinkAngle.setValue(counter.angle); } // we force custom values since there are no normed ones - HoleCutCustomValues.setReadOnly(true); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly,true); // important to set only if not already true, to avoid loop call of updateHoleCutParams() if (!HoleCutCustomValues.getValue()) { HoleCutCustomValues.setValue(true); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } } else { // set normed values if not overwritten or if previously there // were no normed values available and thus HoleCutCustomValues is checked and read-only if (!HoleCutCustomValues.getValue() - || (HoleCutCustomValues.getValue() && HoleCutCustomValues.isReadOnly())) { + || (HoleCutCustomValues.getValue() && HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly))) { HoleCutDiameter.setValue(dimen.diameter); - HoleCutDiameter.setReadOnly(true); - HoleCutDepth.setReadOnly(true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly,true); HoleCutCountersinkAngle.setValue(counter.angle); - HoleCutCountersinkAngle.setReadOnly(true); - if (HoleCutCustomValues.getValue() && HoleCutCustomValues.isReadOnly()) + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); + if (HoleCutCustomValues.getValue() && HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)) HoleCutCustomValues.setValue(false); } else { - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } - HoleCutCustomValues.setReadOnly(false); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly, false); } } } @@ -798,8 +798,8 @@ void Hole::updateHoleCutParams() else if (holeCutTypeStr == "Cheesehead (deprecated)") { HoleCutDiameter.setValue(diameterVal * 1.6); HoleCutDepth.setValue(diameterVal * 0.6); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); } else if (holeCutTypeStr == "Countersink socket screw (deprecated)") { HoleCutDiameter.setValue(diameterVal * 2.0); @@ -807,15 +807,15 @@ void Hole::updateHoleCutParams() if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(90.0); } - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } else if (holeCutTypeStr == "Cap screw (deprecated)") { HoleCutDiameter.setValue(diameterVal * 1.5); HoleCutDepth.setValue(diameterVal * 1.25); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); } } else { // we have an UTS profile or none @@ -831,14 +831,14 @@ void Hole::updateHoleCutParams() } if (HoleCutDepth.getValue() == 0.0) HoleCutDepth.setValue(diameterVal * 0.9); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); } else if (holeCutTypeStr == "Countersink") { if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { HoleCutDiameter.setValue(diameterVal * 1.7); // 82 degrees for UTS, 90 otherwise - if (threadTypeStr != "None") + if (threadTypeStr != "None") HoleCutCountersinkAngle.setValue(82.0); else HoleCutCountersinkAngle.setValue(90.0); @@ -849,9 +849,9 @@ void Hole::updateHoleCutParams() else HoleCutCountersinkAngle.setValue(90.0); } - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } } } @@ -902,7 +902,7 @@ void Hole::updateDiameterParam() if (threadType == "ISOMetricProfile" || threadType == "UNC" || threadType == "UNF" || threadType == "UNEF") { diameter = threadDescription[ThreadType.getValue()][ThreadSize.getValue()].CoreHole; - } + } // if nothing available, we must calculate else { // this fits exactly the definition for ISO metric fine @@ -1053,11 +1053,11 @@ void Hole::onChanged(const App::Property *prop) ThreadSize.setEnums(ThreadSize_None_Enums); ThreadClass.setEnums(ThreadClass_None_Enums); HoleCutType.setEnums(HoleCutType_None_Enums); - Threaded.setReadOnly(true); - ThreadSize.setReadOnly(true); - ThreadFit.setReadOnly(true); - ThreadClass.setReadOnly(true); - Diameter.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly,true); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly,true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly,true); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly,true); + Diameter.setStatus(App::PropertyStatus::ReadOnly, false); Threaded.setValue(0); } else if ( type == "ISOMetricProfile" ) { @@ -1065,98 +1065,98 @@ void Hole::onChanged(const App::Property *prop) ThreadClass.setEnums(ThreadClass_ISOmetric_Enums); HoleCutType.setEnums(HoleCutType_ISOmetric_Enums); ThreadFit.setEnums(ClearanceMetricEnums); - Threaded.setReadOnly(false); - ThreadSize.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly, false); // thread class and direction are only sensible if threaded // fit only sensible if not threaded - ThreadFit.setReadOnly(Threaded.getValue()); - ThreadClass.setReadOnly(!Threaded.getValue()); - Diameter.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, Threaded.getValue()); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, !Threaded.getValue()); + Diameter.setStatus(App::PropertyStatus::ReadOnly,true); } else if ( type == "ISOMetricFineProfile" ) { ThreadSize.setEnums(ThreadSize_ISOmetricfine_Enums); ThreadClass.setEnums(ThreadClass_ISOmetricfine_Enums); HoleCutType.setEnums(HoleCutType_ISOmetricfine_Enums); ThreadFit.setEnums(ClearanceMetricEnums); - Threaded.setReadOnly(false); - ThreadSize.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly, false); // thread class and direction are only sensible if threaded // fit only sensible if not threaded - ThreadFit.setReadOnly(Threaded.getValue()); - ThreadClass.setReadOnly(!Threaded.getValue()); - Diameter.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, Threaded.getValue()); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, !Threaded.getValue()); + Diameter.setStatus(App::PropertyStatus::ReadOnly,true); } else if ( type == "UNC" ) { ThreadSize.setEnums(ThreadSize_UNC_Enums); ThreadClass.setEnums(ThreadClass_UNC_Enums); HoleCutType.setEnums(HoleCutType_UNC_Enums); ThreadFit.setEnums(ClearanceUTSEnums); - Threaded.setReadOnly(false); - ThreadSize.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly, false); // thread class and direction are only sensible if threaded // fit only sensible if not threaded - ThreadFit.setReadOnly(Threaded.getValue()); - ThreadClass.setReadOnly(!Threaded.getValue()); - Diameter.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, Threaded.getValue()); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, !Threaded.getValue()); + Diameter.setStatus(App::PropertyStatus::ReadOnly,true); } else if ( type == "UNF" ) { ThreadSize.setEnums(ThreadSize_UNF_Enums); ThreadClass.setEnums(ThreadClass_UNF_Enums); HoleCutType.setEnums(HoleCutType_UNF_Enums); ThreadFit.setEnums(ClearanceUTSEnums); - Threaded.setReadOnly(false); - ThreadSize.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly, false); // thread class and direction are only sensible if threaded // fit only sensible if not threaded - ThreadFit.setReadOnly(Threaded.getValue()); - ThreadClass.setReadOnly(!Threaded.getValue()); - Diameter.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, Threaded.getValue()); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, !Threaded.getValue()); + Diameter.setStatus(App::PropertyStatus::ReadOnly,true); } else if ( type == "UNEF" ) { ThreadSize.setEnums(ThreadSize_UNEF_Enums); ThreadClass.setEnums(ThreadClass_UNEF_Enums); HoleCutType.setEnums(HoleCutType_UNEF_Enums); ThreadFit.setEnums(ClearanceUTSEnums); - Threaded.setReadOnly(false); - ThreadSize.setReadOnly(false); + Threaded.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadSize.setStatus(App::PropertyStatus::ReadOnly, false); // thread class and direction are only sensible if threaded // fit only sensible if not threaded - ThreadFit.setReadOnly(Threaded.getValue()); - ThreadClass.setReadOnly(!Threaded.getValue());; - Diameter.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, Threaded.getValue()); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, !Threaded.getValue()); + Diameter.setStatus(App::PropertyStatus::ReadOnly,true); } if (holeCutTypeStr == "None") { - HoleCutCustomValues.setReadOnly(true); - HoleCutDiameter.setReadOnly(true); - HoleCutDepth.setReadOnly(true); - HoleCutCountersinkAngle.setReadOnly(true); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); } else if (holeCutTypeStr == "Counterbore") { - HoleCutCustomValues.setReadOnly(true); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(true); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); } else if (holeCutTypeStr == "Countersink") { - HoleCutCustomValues.setReadOnly(true); - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); - HoleCutCountersinkAngle.setReadOnly(false); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly, false); } else { // screw definition - HoleCutCustomValues.setReadOnly(false); + HoleCutCustomValues.setStatus(App::PropertyStatus::ReadOnly, false); if (HoleCutCustomValues.getValue()) { - HoleCutDiameter.setReadOnly(false); - HoleCutDepth.setReadOnly(false); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly, false); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly, false); // we must not set HoleCutCountersinkAngle here because the info if this can // be enabled is first available in updateHoleCutParams and thus handled there updateHoleCutParams(); } else { - HoleCutDiameter.setReadOnly(true); - HoleCutDepth.setReadOnly(true); - HoleCutCountersinkAngle.setReadOnly(true); + HoleCutDiameter.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutDepth.setStatus(App::PropertyStatus::ReadOnly,true); + HoleCutCountersinkAngle.setStatus(App::PropertyStatus::ReadOnly,true); } } @@ -1167,10 +1167,10 @@ void Hole::onChanged(const App::Property *prop) ProfileBased::onChanged(&Threaded); bool v = (type != "None") || !Threaded.getValue() || !ModelActualThread.getValue(); - ThreadPitch.setReadOnly(v); - ThreadAngle.setReadOnly(v); - ThreadCutOffInner.setReadOnly(v); - ThreadCutOffOuter.setReadOnly(v); + ThreadPitch.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadAngle.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadCutOffInner.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadCutOffOuter.setStatus(App::PropertyStatus::ReadOnly, v); // Diameter parameter depends on this if (type != "None" ) @@ -1182,19 +1182,19 @@ void Hole::onChanged(const App::Property *prop) // thread class and direction are only sensible if threaded // fit only sensible if not threaded if (Threaded.getValue()) { - ThreadClass.setReadOnly(false); - ThreadDirection.setReadOnly(false); - ThreadFit.setReadOnly(true); - ModelActualThread.setReadOnly(true); // For now set this one to read only + ThreadClass.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadDirection.setStatus(App::PropertyStatus::ReadOnly, false); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly,true); + ModelActualThread.setStatus(App::PropertyStatus::ReadOnly,true); // For now set this one to read only } else { - ThreadClass.setReadOnly(true); - ThreadDirection.setReadOnly(true); + ThreadClass.setStatus(App::PropertyStatus::ReadOnly,true); + ThreadDirection.setStatus(App::PropertyStatus::ReadOnly,true); if (type == "None") - ThreadFit.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly,true); else - ThreadFit.setReadOnly(false); - ModelActualThread.setReadOnly(true); + ThreadFit.setStatus(App::PropertyStatus::ReadOnly, false); + ModelActualThread.setStatus(App::PropertyStatus::ReadOnly,true); } // Diameter parameter depends on this @@ -1202,29 +1202,29 @@ void Hole::onChanged(const App::Property *prop) } else if (prop == &ModelActualThread) { bool v =(!ModelActualThread.getValue()) || - (Threaded.isReadOnly()) || + (Threaded.testStatus(App::PropertyStatus::ReadOnly)) || (std::string(ThreadType.getValueAsString()) != "None"); - ThreadPitch.setReadOnly(v); - ThreadAngle.setReadOnly(v); - ThreadCutOffInner.setReadOnly(v); - ThreadCutOffOuter.setReadOnly(v); + ThreadPitch.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadAngle.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadCutOffInner.setStatus(App::PropertyStatus::ReadOnly, v); + ThreadCutOffOuter.setStatus(App::PropertyStatus::ReadOnly, v); } else if (prop == &DrillPoint) { if (DrillPoint.getValue() == 1) { - DrillPointAngle.setReadOnly(false); - DrillForDepth.setReadOnly(false); + DrillPointAngle.setStatus(App::PropertyStatus::ReadOnly, false); + DrillForDepth.setStatus(App::PropertyStatus::ReadOnly, false); } else { - DrillPointAngle.setReadOnly(true); - DrillForDepth.setReadOnly(true); + DrillPointAngle.setStatus(App::PropertyStatus::ReadOnly,true); + DrillForDepth.setStatus(App::PropertyStatus::ReadOnly,true); } } else if (prop == &Tapered) { if (Tapered.getValue()) - TaperedAngle.setReadOnly(false); + TaperedAngle.setStatus(App::PropertyStatus::ReadOnly, false); else - TaperedAngle.setReadOnly(true); + TaperedAngle.setStatus(App::PropertyStatus::ReadOnly,true); } else if (prop == &ThreadSize) { updateDiameterParam(); @@ -1253,10 +1253,10 @@ void Hole::onChanged(const App::Property *prop) updateHoleCutParams(); } else if (prop == &DepthType) { - Depth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); - DrillPoint.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); - DrillPointAngle.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); - DrillForDepth.setReadOnly((std::string(DepthType.getValueAsString()) != "Dimension")); + Depth.setStatus(App::PropertyStatus::ReadOnly, (std::string(DepthType.getValueAsString()) != "Dimension")); + DrillPoint.setStatus(App::PropertyStatus::ReadOnly, (std::string(DepthType.getValueAsString()) != "Dimension")); + DrillPointAngle.setStatus(App::PropertyStatus::ReadOnly, (std::string(DepthType.getValueAsString()) != "Dimension")); + DrillForDepth.setStatus(App::PropertyStatus::ReadOnly, (std::string(DepthType.getValueAsString()) != "Dimension")); } ProfileBased::onChanged(prop); } diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index 463339fd2b13..07b222bc8912 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -51,7 +51,7 @@ PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed) LinearPattern::LinearPattern() { - ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",(App::PropertyType)(App::Prop_None),"Direction"); + ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",App::Prop_None,"Direction"); ADD_PROPERTY(Reversed,(0)); ADD_PROPERTY(Length,(100.0)); ADD_PROPERTY(Occurrences,(3)); diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index 5aa3e7649572..c470cacd7c86 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -47,7 +47,7 @@ PROPERTY_SOURCE(PartDesign::Mirrored, PartDesign::Transformed) Mirrored::Mirrored() { - ADD_PROPERTY_TYPE(MirrorPlane,(0),"Mirrored",(App::PropertyType)(App::Prop_None),"Mirror plane"); + ADD_PROPERTY_TYPE(MirrorPlane,(0),"Mirrored",App::Prop_None,"Mirror plane"); } short Mirrored::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index 7b31c7a8443d..88a7254545c6 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -49,7 +49,7 @@ PROPERTY_SOURCE(PartDesign::PolarPattern, PartDesign::Transformed) PolarPattern::PolarPattern() { - ADD_PROPERTY_TYPE(Axis,(0),"PolarPattern",(App::PropertyType)(App::Prop_None),"Direction"); + ADD_PROPERTY_TYPE(Axis,(0),"PolarPattern",App::Prop_None,"Direction"); ADD_PROPERTY(Reversed,(0)); ADD_PROPERTY(Angle,(360.0)); ADD_PROPERTY(Occurrences,(3)); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index ffd61417d46d..445bccce5769 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -91,7 +91,7 @@ ProfileBased::ProfileBased() ADD_PROPERTY_TYPE(Profile,(0),"SketchBased", App::Prop_None, "Reference to sketch"); ADD_PROPERTY_TYPE(Midplane,(0),"SketchBased", App::Prop_None, "Extrude symmetric to sketch face"); ADD_PROPERTY_TYPE(Reversed, (0),"SketchBased", App::Prop_None, "Reverse extrusion direction"); - ADD_PROPERTY_TYPE(UpToFace,(0),"SketchBased",(App::PropertyType)(App::Prop_None),"Face where feature will end"); + ADD_PROPERTY_TYPE(UpToFace,(0),"SketchBased",App::Prop_None,"Face where feature will end"); ADD_PROPERTY_TYPE(AllowMultiFace,(false),"SketchBased", App::Prop_None, "Allow multiple faces in profile"); } @@ -397,7 +397,7 @@ void ProfileBased::onChanged(const App::Property* prop) { if (prop == &Profile) { // if attached to a sketch then mark it as read-only - this->Placement.setStatus(App::Property::ReadOnly, Profile.getValue() != 0); + this->Placement.setStatus(App::PropertyStatus::ReadOnly, Profile.getValue() != 0); } FeatureAddSub::onChanged(prop); diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 1818338dbcf8..42672472fa2d 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -63,9 +63,9 @@ Transformed::Transformed() { ADD_PROPERTY(Originals,(0)); Originals.setSize(0); - Placement.setStatus(App::Property::ReadOnly, true); + Placement.setStatus(App::PropertyStatus::ReadOnly, true); - ADD_PROPERTY_TYPE(Refine,(0),"SketchBased",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting"); + ADD_PROPERTY_TYPE(Refine,(0),"SketchBased",App::Prop_None,"Refine shape (clean up redundant edges) after adding/subtracting"); //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index b1db1349bc09..2d7da7844d2e 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -60,8 +60,7 @@ PROPERTY_SOURCE(PartDesign::ShapeBinder, Part::Feature) ShapeBinder::ShapeBinder() { - ADD_PROPERTY_TYPE(Support, (0,0), "",(App::PropertyType)(App::Prop_None),"Support of the geometry"); - Placement.setStatus(App::Property::Hidden, true); + ADD_PROPERTY_TYPE(Support, (0,0), "",App::Hidden,"Support of the geometry"); ADD_PROPERTY_TYPE(TraceSupport, (false), "", App::Prop_None, "Trace support shape"); } @@ -278,8 +277,7 @@ PROPERTY_SOURCE(PartDesign::SubShapeBinder, Part::Feature) SubShapeBinder::SubShapeBinder() { - ADD_PROPERTY_TYPE(Support, (0), "",(App::PropertyType)(App::Prop_None), "Support of the geometry"); - Support.setStatus(App::Property::ReadOnly, true); + ADD_PROPERTY_TYPE(Support, (0), "",App::ReadOnly, "Support of the geometry"); ADD_PROPERTY_TYPE(Fuse, (false), "Base",App::Prop_None,"Fuse solids from bound shapes"); ADD_PROPERTY_TYPE(MakeFace, (true), "Base",App::Prop_None,"Create face using wires from bound shapes"); ADD_PROPERTY_TYPE(ClaimChildren, (false), "Base",App::Prop_Output,"Claim linked object as children"); @@ -288,10 +286,9 @@ SubShapeBinder::SubShapeBinder() "Synchronized: auto update binder shape on changed of bound object.\n" "Frozen: disable auto update, but can be updated manually using context menu.\n" "Detached: copy the shape of bound object and then remove the binding immediately."); - ADD_PROPERTY_TYPE(PartialLoad, (false), "Base", App::Prop_None, + ADD_PROPERTY_TYPE(PartialLoad, (false), "Base", App::PartialTrigger, "Enable partial loading, which disables auto loading of external document for" "external bound object."); - PartialLoad.setStatus(App::Property::PartialTrigger,true); static const char *BindModeEnum[] = {"Synchronized", "Frozen", "Detached", 0}; BindMode.setEnums(BindModeEnum); @@ -300,8 +297,7 @@ SubShapeBinder::SubShapeBinder() "the relative placement of the bound shape"); Context.setScope(App::LinkScope::Hidden); - ADD_PROPERTY_TYPE(_Version,(0),"Base",(App::PropertyType)( - App::Prop_Hidden|App::Prop_ReadOnly), ""); + ADD_PROPERTY_TYPE(_Version,(0),"Base", App::Prop_Hidden+App::Prop_ReadOnly, ""); } void SubShapeBinder::setupObject() { @@ -567,7 +563,8 @@ void SubShapeBinder::update(SubShapeBinder::UpdateOption options) { if(!prop || !prop->isDerivedFrom(App::PropertyMatrix::getClassTypeId())) { if(prop) removeDynamicProperty(name); - prop = addDynamicProperty("App::PropertyMatrix",name,"Cache",0,0,false,true); + prop = addDynamicProperty("App::PropertyMatrix",name,"Cache"); + prop->setStatus(App::PropertyStatus::Prop_Hidden); } caches.erase(name); static_cast(prop)->setValue(v.second); diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 905323e59b9b..2d7cc86d2e41 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -327,12 +327,12 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st for( App::Property* prop : props ) { //independent copies don't have links and are not attached - if(independent && ( + if (independent && ( prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId()) || prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId()) || prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId()) || prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())|| - ( prop->getGroup() && strcmp(prop->getGroup(),"Attachment")==0) )) { + ( prop->getGroup() == "Attachment" ) )) { ++it; continue; @@ -340,7 +340,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st App::Property* cprop = *it++; - if( strcmp(prop->getName(), "Label") == 0 ) { + if (prop->getName() == "Label") { static_cast(cprop)->setValue(name.c_str()); continue; } diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index dbd5a866bda2..432916b58932 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -116,15 +116,15 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole *HoleView, QWidget *pare } ui->HoleCutType->setCurrentIndex(pcHole->HoleCutType.getValue()); ui->HoleCutCustomValues->setChecked(pcHole->HoleCutCustomValues.getValue()); - ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.isReadOnly()); + ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)); // HoleCutDiameter must not be smaller or equal than the Diameter ui->HoleCutDiameter->setMinimum(pcHole->Diameter.getValue() + 0.1); ui->HoleCutDiameter->setValue(pcHole->HoleCutDiameter.getValue()); - ui->HoleCutDiameter->setDisabled(pcHole->HoleCutDiameter.isReadOnly()); + ui->HoleCutDiameter->setDisabled(pcHole->HoleCutDiameter.testStatus(App::PropertyStatus::ReadOnly)); ui->HoleCutDepth->setValue(pcHole->HoleCutDepth.getValue()); - ui->HoleCutDepth->setDisabled(pcHole->HoleCutDepth.isReadOnly()); + ui->HoleCutDepth->setDisabled(pcHole->HoleCutDepth.testStatus(App::PropertyStatus::ReadOnly)); ui->HoleCutCountersinkAngle->setValue(pcHole->HoleCutCountersinkAngle.getValue()); - ui->HoleCutCountersinkAngle->setDisabled(pcHole->HoleCutCountersinkAngle.isReadOnly()); + ui->HoleCutCountersinkAngle->setDisabled(pcHole->HoleCutCountersinkAngle.testStatus(App::PropertyStatus::ReadOnly)); ui->DepthType->setCurrentIndex(pcHole->DepthType.getValue()); ui->Depth->setValue(pcHole->Depth.getValue()); @@ -261,7 +261,7 @@ void TaskHoleParameters::holeCutTypeChanged(int index) PartDesign::Hole* pcHole = static_cast(vp->getObject()); // the HoleCutDepth is something different for countersinks and counterbores - // therefore reset it, it will be reset to sensible values by setting the new HoleCutType + // therefore reset it, it will be reset to sensible values by setting the new HoleCutType pcHole->HoleCutDepth.setValue(0.0); // when holeCutType was changed, reset HoleCutCustomValues to false because it should @@ -276,11 +276,11 @@ void TaskHoleParameters::holeCutTypeChanged(int index) recomputeFeature(); // apply the result to the widgets - ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.isReadOnly()); + ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)); ui->HoleCutCustomValues->setChecked(pcHole->HoleCutCustomValues.getValue()); // HoleCutCustomValues is only enabled for screw definitions - // we must do this after recomputeFeature() because this gives us the info if + // we must do this after recomputeFeature() because this gives us the info if // the type is a countersink and thus if HoleCutCountersinkAngle can be enabled std::string HoleCutTypeString = pcHole->HoleCutType.getValueAsString(); if (HoleCutTypeString == "None" || HoleCutTypeString == "Counterbore" @@ -293,7 +293,7 @@ void TaskHoleParameters::holeCutTypeChanged(int index) if (ui->HoleCutCustomValues->isChecked()) { ui->HoleCutDiameter->setEnabled(true); ui->HoleCutDepth->setEnabled(true); - if (!pcHole->HoleCutCountersinkAngle.isReadOnly()) + if (!pcHole->HoleCutCountersinkAngle.testStatus(App::PropertyStatus::ReadOnly)) ui->HoleCutCountersinkAngle->setEnabled(true); } else { @@ -313,7 +313,7 @@ void TaskHoleParameters::holeCutCustomValuesChanged() if (ui->HoleCutCustomValues->isChecked()) { ui->HoleCutDiameter->setEnabled(true); ui->HoleCutDepth->setEnabled(true); - if (!pcHole->HoleCutCountersinkAngle.isReadOnly()) + if (!pcHole->HoleCutCountersinkAngle.testStatus(App::PropertyStatus::ReadOnly)) ui->HoleCutCountersinkAngle->setEnabled(true); } else { @@ -322,7 +322,7 @@ void TaskHoleParameters::holeCutCustomValuesChanged() ui->HoleCutCountersinkAngle->setEnabled(false); } - recomputeFeature(); + recomputeFeature(); } void TaskHoleParameters::holeCutDiameterChanged(double value) @@ -483,7 +483,7 @@ void TaskHoleParameters::threadTypeChanged(int index) if (TypeClass == QByteArray("ISO")) { // the size for ISO type has either the form "M3x0.35" or just "M3" // so we need to check if the size contains a 'x'. If yes, check if the string - // up to the 'x' is exists in the new list + // up to the 'x' is exists in the new list if (ThreadSizeString.indexOf(QString::fromLatin1("x")) > -1) { // we have an ISO fine size // cut of the part behind the 'x' @@ -499,7 +499,7 @@ void TaskHoleParameters::threadTypeChanged(int index) ui->ThreadFit->setItemText(0, QCoreApplication::translate("TaskHoleParameters", "Standard", nullptr)); ui->ThreadFit->setItemText(1, QCoreApplication::translate("TaskHoleParameters", "Close", nullptr)); ui->ThreadFit->setItemText(2, QCoreApplication::translate("TaskHoleParameters", "Wide", nullptr)); - } + } else if (TypeClass == QByteArray("UTS")) { // for all UTS types the size entries are the same int threadSizeIndex = ui->ThreadSize->findText(ThreadSizeString, Qt::MatchContains); @@ -538,7 +538,7 @@ void TaskHoleParameters::threadSizeChanged(int index) recomputeFeature(); // apply the recompute result to the widgets - ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.isReadOnly()); + ui->HoleCutCustomValues->setDisabled(pcHole->HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)); ui->HoleCutCustomValues->setChecked(pcHole->HoleCutCustomValues.getValue()); } @@ -599,7 +599,7 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property return; PartDesign::Hole* pcHole = static_cast(vp->getObject()); - bool ro = Prop.isReadOnly(); + bool ro = Prop.testStatus(App::PropertyStatus::ReadOnly); Base::Console().Log("Parameter %s was updated\n", Prop.getName()); @@ -949,31 +949,31 @@ void TaskHoleParameters::apply() ui->DrillPointAngle->apply(); ui->TaperedAngle->apply(); - if (!pcHole->Threaded.isReadOnly()) + if (!pcHole->Threaded.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"Threaded = " << (getThreaded() ? 1 : 0)); - if (!pcHole->ModelActualThread.isReadOnly()) + if (!pcHole->ModelActualThread.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ModelActualThread = " << (getThreaded() ? 1 : 0)); - if (!pcHole->ThreadType.isReadOnly()) + if (!pcHole->ThreadType.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ThreadType = " << getThreadType()); - if (!pcHole->ThreadSize.isReadOnly()) + if (!pcHole->ThreadSize.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ThreadSize = " << getThreadSize()); - if (!pcHole->ThreadClass.isReadOnly()) + if (!pcHole->ThreadClass.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ThreadClass = " << getThreadClass()); - if (!pcHole->ThreadFit.isReadOnly()) + if (!pcHole->ThreadFit.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ThreadFit = " << getThreadFit()); - if (!pcHole->ThreadDirection.isReadOnly()) + if (!pcHole->ThreadDirection.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"ThreadDirection = " << getThreadDirection()); - if (!pcHole->HoleCutType.isReadOnly()) + if (!pcHole->HoleCutType.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"HoleCutType = " << getHoleCutType()); - if (!pcHole->HoleCutCustomValues.isReadOnly()) + if (!pcHole->HoleCutCustomValues.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj, "HoleCutCustomValues = " << (getHoleCutCustomValues() ? 1 : 0)); - if (!pcHole->DepthType.isReadOnly()) + if (!pcHole->DepthType.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"DepthType = " << getDepthType()); - if (!pcHole->DrillPoint.isReadOnly()) + if (!pcHole->DrillPoint.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"DrillPoint = " << getDrillPoint()); - if (!pcHole->DrillForDepth.isReadOnly()) + if (!pcHole->DrillForDepth.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj, "DrillForDepth = " << (getDrillForDepth() ? 1 : 0)); - if (!pcHole->Tapered.isReadOnly()) + if (!pcHole->Tapered.testStatus(App::PropertyStatus::ReadOnly)) FCMD_OBJ_CMD(obj,"Tapered = " << getTapered()); isApplying = false; diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index dff2defa825f..8085f999a408 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -184,7 +184,7 @@ void ViewProvider::updateData(const App::Property* prop) { // TODO What's that? (2015-07-24, Fat-Zer) if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && - strcmp(prop->getName(),"AddSubShape") == 0) { + prop->getName() == "AddSubShape") { return; } @@ -307,7 +307,7 @@ void ViewProvider::setBodyMode(bool bodymode) { if(!vp->getPropertyByName(prop->getName())) continue; - prop->setStatus(App::Property::Hidden, bodymode); + prop->setStatus(App::PropertyStatus::Hidden, bodymode); } } diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp index 85bcf6e551d6..b9a023eef34c 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp @@ -267,7 +267,7 @@ void ViewProviderAddSub::updateAddSubShapeIndicator() { void ViewProviderAddSub::updateData(const App::Property* p) { - if(strcmp(p->getName(), "AddSubShape")==0) + if (p->getName() == "AddSubShape") updateAddSubShapeIndicator(); PartDesignGui::ViewProvider::updateData(p); @@ -280,7 +280,7 @@ void ViewProviderAddSub::setPreviewDisplayMode(bool onoff) { // not sufficient to only revert the mask mode. Also the child // number of the switch node must be reverted. if (onoff) { - if(pcModeSwitch->getChild(getDefaultMode()) == previewShape) + if(pcModeSwitch->getChild(getDefaultMode()) == previewShape) return; displayMode = getActiveDisplayMode(); whichChild = pcModeSwitch->whichChild.getValue(); @@ -288,7 +288,7 @@ void ViewProviderAddSub::setPreviewDisplayMode(bool onoff) { } if (!onoff) { - if(pcModeSwitch->getChild(getDefaultMode()) != previewShape) + if(pcModeSwitch->getChild(getDefaultMode()) != previewShape) return; setDisplayMaskMode(displayMode.c_str()); pcModeSwitch->whichChild.setValue(whichChild); diff --git a/src/Mod/PartDesign/Gui/ViewProviderBase.cpp b/src/Mod/PartDesign/Gui/ViewProviderBase.cpp index 20f51a2ab9e9..8693860741eb 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBase.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBase.cpp @@ -51,9 +51,9 @@ bool ViewProviderBase::doubleClicked(void) // If the Placement is mutable then open the transform panel. // If the Placement can't be modified then just do nothing on double-click. PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { + if (!base->Placement.testStatus(App::PropertyStatus::Immutable) && + !base->Placement.testStatus(App::PropertyStatus::ReadOnly) && + !base->Placement.testStatus(App::PropertyStatus::Hidden)) { try { std::string Msg("Edit "); @@ -74,9 +74,9 @@ void ViewProviderBase::setupContextMenu(QMenu* menu, QObject* receiver, const ch { // If the Placement is mutable then show the context-menu of the base class. PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { + if (!base->Placement.testStatus(App::PropertyStatus::Immutable) && + !base->Placement.testStatus(App::PropertyStatus::ReadOnly) && + !base->Placement.testStatus(App::PropertyStatus::Hidden)) { PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member); } } @@ -84,9 +84,9 @@ void ViewProviderBase::setupContextMenu(QMenu* menu, QObject* receiver, const ch bool ViewProviderBase::setEdit(int ModNum) { PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { + if (!base->Placement.testStatus(App::PropertyStatus::Immutable) && + !base->Placement.testStatus(App::PropertyStatus::ReadOnly) && + !base->Placement.testStatus(App::PropertyStatus::Hidden)) { return PartGui::ViewProviderPart::setEdit(ModNum); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index da312a08a0ab..f5226a4e2e48 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -148,7 +148,7 @@ bool ViewProviderBody::doubleClicked(void) if(!activeDoc) activeDoc = getDocument(); auto activeView = activeDoc->setActiveView(this); - if(!activeView) + if(!activeView) return false; if (activeView->isActiveObject(getObject(),PDBODYKEY)) { @@ -242,7 +242,7 @@ void ViewProviderBody::slotChangedObjectApp ( const App::DocumentObject& obj, co if(App::GetApplication().isRestoring()) return; - + if (!obj.isDerivedFrom ( Part::Feature::getClassTypeId () ) || obj.isDerivedFrom ( Part::BodyBase::getClassTypeId () ) ) { // we are interested only in Part::Features, not in bodies return; @@ -358,7 +358,7 @@ void ViewProviderBody::onChanged(const App::Property* prop) { if(prop == &DisplayModeBody) { auto body = dynamic_cast(getObject()); - + if ( DisplayModeBody.getValue() == 0 ) { //if we are in an override mode we need to make sure to come out, because //otherwise the maskmode is blocked and won't go into "through" @@ -450,9 +450,9 @@ bool ViewProviderBody::canDropObjects() const // if the BaseFeature property is marked as hidden or read-only then // it's not allowed to modify it. PartDesign::Body* body = static_cast(getObject()); - if (body->BaseFeature.testStatus(App::Property::Status::Hidden)) + if (body->BaseFeature.testStatus(App::PropertyStatus::Hidden)) return false; - if (body->BaseFeature.testStatus(App::Property::Status::ReadOnly)) + if (body->BaseFeature.testStatus(App::PropertyStatus::ReadOnly)) return false; return true; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 58bb3fbe28ff..7ac744b07bf9 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -93,7 +93,7 @@ ViewProviderDatum::ViewProviderDatum() pPickStyle = new SoPickStyle(); pPickStyle->ref(); - DisplayMode.setStatus(App::Property::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); // set default color for datums (golden yellow with 60% transparency) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath ( diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp index c334d491c597..3aa621684796 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp @@ -192,7 +192,7 @@ void ViewProviderDatumCoordinateSystem::setupLabels() { void ViewProviderDatumCoordinateSystem::updateData(const App::Property* prop) { - if (strcmp(prop->getName(),"Placement") == 0) + if (prop->getName() == "Placement") updateExtents (); ViewProviderDatum::updateData(prop); @@ -205,7 +205,7 @@ void ViewProviderDatumCoordinateSystem::onChanged(const App::Property *prop) { else if(prop == &Zoom) { autoZoom->scaleFactor.setValue(Zoom.getValue()); updateExtents (); - } else if(prop == &FontSize) + } else if(prop == &FontSize) font->size = FontSize.getValue(); } ViewProviderDatum::onChanged(prop); @@ -214,7 +214,7 @@ void ViewProviderDatumCoordinateSystem::onChanged(const App::Property *prop) { void ViewProviderDatumCoordinateSystem::setExtents (Base::BoundBox3d bbox) { // Axis length of the CS is 1/3 of maximum bbox dimension, any smarter sizing will make it only worse double axisLength; - + if(Zoom.getValue()) { axisLength = 6 * Zoom.getValue(); }else{ diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp index 2129b01e2c55..4d0332c0d4d8 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp @@ -68,10 +68,10 @@ void ViewProviderDatumLine::attach ( App::DocumentObject *obj ) { void ViewProviderDatumLine::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - if (strcmp(prop->getName(),"Placement") == 0) { + if (prop->getName() == "Placement") { updateExtents (); } - else if (strcmp(prop->getName(),"Length") == 0) { + else if (prop->getName() == "Length") { PartDesign::Line* pcDatum = static_cast(this->getObject()); if (pcDatum->ResizeMode.getValue() != 0) setExtents(pcDatum->Length.getValue()); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp index e8489007ff26..fb8715795cbf 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp @@ -90,11 +90,11 @@ void ViewProviderDatumPlane::attach ( App::DocumentObject *obj ) { void ViewProviderDatumPlane::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - if (strcmp(prop->getName(),"Placement") == 0) { + if (prop->getName() == "Placement") { updateExtents (); } - else if (strcmp(prop->getName(),"Length") == 0 || - strcmp(prop->getName(),"Width") == 0) { + else if (prop->getName() == "Length" || + prop->getName() == "Width") { PartDesign::Plane* pcDatum = static_cast(this->getObject()); if (pcDatum->ResizeMode.getValue() != 0) setExtents(pcDatum->Length.getValue(), pcDatum->Width.getValue()); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp index 42b09df07b1d..0acc87a3e979 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp @@ -46,7 +46,7 @@ ViewProviderDatumPoint::ViewProviderDatumPoint() // SoMarkerSet won't be drawn if transparency is nonzero, so disabble it Transparency.setValue (0); - Transparency.setStatus(App::Property::Hidden, true); //< make transparency hidden + Transparency.setStatus(App::PropertyStatus::Hidden, true); //< make transparency hidden } ViewProviderDatumPoint::~ViewProviderDatumPoint() diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index 47bddf8086dd..5cc4dadb4444 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -53,15 +53,15 @@ ViewProviderShapeBinder::ViewProviderShapeBinder() sPixmap = "PartDesign_ShapeBinder.svg"; //make the viewprovider more datum like - AngularDeflection.setStatus(App::Property::Hidden, true); - Deviation.setStatus(App::Property::Hidden, true); - DrawStyle.setStatus(App::Property::Hidden, true); - Lighting.setStatus(App::Property::Hidden, true); - LineColor.setStatus(App::Property::Hidden, true); - LineWidth.setStatus(App::Property::Hidden, true); - PointColor.setStatus(App::Property::Hidden, true); - PointSize.setStatus(App::Property::Hidden, true); - DisplayMode.setStatus(App::Property::Hidden, true); + AngularDeflection.setStatus(App::PropertyStatus::Hidden, true); + Deviation.setStatus(App::PropertyStatus::Hidden, true); + DrawStyle.setStatus(App::PropertyStatus::Hidden, true); + Lighting.setStatus(App::PropertyStatus::Hidden, true); + LineColor.setStatus(App::PropertyStatus::Hidden, true); + LineWidth.setStatus(App::PropertyStatus::Hidden, true); + PointColor.setStatus(App::PropertyStatus::Hidden, true); + PointSize.setStatus(App::PropertyStatus::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); //get the datum coloring scheme // set default color for datums (golden yellow with 60% transparency) @@ -206,7 +206,7 @@ ViewProviderSubShapeBinder::ViewProviderSubShapeBinder() { "User parameter:BaseApp/Preferences/Mod/PartDesign"); unsigned long shcol = hGrp->GetUnsigned ( "DefaultDatumColor", 0xFFD70099 ); App::Color col ( (uint32_t) shcol ); - + ShapeColor.setValue(col); LineColor.setValue(col); PointColor.setValue(col); @@ -214,7 +214,7 @@ ViewProviderSubShapeBinder::ViewProviderSubShapeBinder() { LineWidth.setValue(1); } -bool ViewProviderSubShapeBinder::canDropObjectEx(App::DocumentObject *, +bool ViewProviderSubShapeBinder::canDropObjectEx(App::DocumentObject *, App::DocumentObject *, const char *, const std::vector &) const { return true; @@ -228,7 +228,7 @@ std::string ViewProviderSubShapeBinder::dropObjectEx(App::DocumentObject *obj, A std::map > values; if(!subname) subname = ""; std::string sub(subname); - if(sub.empty()) + if(sub.empty()) values[owner?owner:obj] = elements; else { std::vector subs; @@ -253,7 +253,7 @@ bool ViewProviderSubShapeBinder::doubleClicked() { return true; } -void ViewProviderSubShapeBinder::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) +void ViewProviderSubShapeBinder::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { QAction* act; act = menu->addAction(QObject::tr("Synchronize"), receiver, member); @@ -263,7 +263,7 @@ void ViewProviderSubShapeBinder::setupContextMenu(QMenu* menu, QObject* receiver } bool ViewProviderSubShapeBinder::setEdit(int ModNum) { - + switch(ModNum) { case 0: updatePlacement(true); @@ -305,7 +305,7 @@ void ViewProviderSubShapeBinder::updatePlacement(bool transaction) { if(relative && self->getParents().size()) { const auto &sel = Gui::Selection().getSelection("",0); if(sel.size()!=1 || !sel[0].pObject || - sel[0].pObject->getSubObject(sel[0].SubName)!=self) + sel[0].pObject->getSubObject(sel[0].SubName)!=self) { FC_WARN("invalid selection"); } else { diff --git a/src/Mod/Path/App/ParamsHelper.h b/src/Mod/Path/App/ParamsHelper.h index 88c5d9947cf1..02fd9b0a4cd3 100644 --- a/src/Mod/Path/App/ParamsHelper.h +++ b/src/Mod/Path/App/ParamsHelper.h @@ -986,8 +986,10 @@ #define PARAM_ADD_PROPERTY_TYPE(_prop_, _defaultval_, _group_,_type_,_Docu_) \ do { \ this->_prop_.setValue _defaultval_;\ + this->_prop_.setStatus(App::PropertyStatus::Touched, false); \ + this->_prop_.setStatus( _type_ ); \ this->_prop_.setContainer(this); \ - propertyData.addProperty(static_cast(this), BOOST_PP_STRINGIZE(_prop_), &this->_prop_, (_group_),(_type_),(_Docu_)); \ + propertyData.addProperty(static_cast(this), BOOST_PP_STRINGIZE(_prop_), &this->_prop_, (_group_),(_Docu_)); \ } while (0) /** Generic property adding */ diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index 75793330e882..285e238f36b4 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -229,7 +229,7 @@ ViewProviderPath::ViewProviderPath() NormalColor.touch(); MarkerColor.touch(); - DisplayMode.setStatus(App::Property::Status::Hidden, true); + DisplayMode.setStatus(App::PropertyStatus::Hidden, true); static const char *SelectionStyleEnum[] = {"Shape","BoundBox","None",0}; SelectionStyle.setEnums(SelectionStyleEnum); diff --git a/src/Mod/Points/App/Structured.cpp b/src/Mod/Points/App/Structured.cpp index 00ca45dc8e9f..441d0247e6ed 100644 --- a/src/Mod/Points/App/Structured.cpp +++ b/src/Mod/Points/App/Structured.cpp @@ -67,10 +67,8 @@ PROPERTY_SOURCE(Points::Structured, Points::Feature) Structured::Structured() { -// App::PropertyType type = static_cast(App::Prop_None); - App::PropertyType type = static_cast(App::Prop_ReadOnly); - ADD_PROPERTY_TYPE(Width,(1),"Structured points", type, "Width of the image"); - ADD_PROPERTY_TYPE(Height,(1),"Structured points", type, "Height of the image"); + ADD_PROPERTY_TYPE(Width,(1),"Structured points", App::Prop_ReadOnly, "Width of the image"); + ADD_PROPERTY_TYPE(Height,(1),"Structured points",App::Prop_ReadOnly, "Height of the image"); //Width.setStatus(App::Property::ReadOnly, true); //Height.setStatus(App::Property::ReadOnly, true); } diff --git a/src/Mod/Raytracing/App/RaySegment.cpp b/src/Mod/Raytracing/App/RaySegment.cpp index 5d6d05d395d8..423747d29cc6 100644 --- a/src/Mod/Raytracing/App/RaySegment.cpp +++ b/src/Mod/Raytracing/App/RaySegment.cpp @@ -46,10 +46,9 @@ PROPERTY_SOURCE(Raytracing::RaySegment, App::DocumentObject) -RaySegment::RaySegment(void) +RaySegment::RaySegment(void) { - App::PropertyType type = (App::PropertyType)(App::Prop_Output|App::Prop_Hidden); - ADD_PROPERTY_TYPE(Result ,(0),0,type,"Resulting SVG fragment of that view"); + ADD_PROPERTY_TYPE(Result ,(0),0,App::Prop_Output+App::Prop_Hidden,"Resulting SVG fragment of that view"); } RaySegment::~RaySegment() diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 393af9c703e5..0a246d39c973 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -108,10 +108,10 @@ PROPERTY_SOURCE(Sketcher::SketchObject, Part::Part2DObject) SketchObject::SketchObject() { - ADD_PROPERTY_TYPE(Geometry, (0) ,"Sketch",(App::PropertyType)(App::Prop_None),"Sketch geometry"); - ADD_PROPERTY_TYPE(Constraints, (0) ,"Sketch",(App::PropertyType)(App::Prop_None),"Sketch constraints"); - ADD_PROPERTY_TYPE(ExternalGeometry,(0,0),"Sketch",(App::PropertyType)(App::Prop_None),"Sketch external geometry"); - ADD_PROPERTY_TYPE(FullyConstrained, (false),"Sketch",(App::PropertyType)(App::Prop_Output|App::Prop_ReadOnly |App::Prop_Hidden),"Sketch is fully constrained"); + ADD_PROPERTY_TYPE(Geometry, (0) ,"Sketch",App::Prop_None,"Sketch geometry"); + ADD_PROPERTY_TYPE(Constraints, (0) ,"Sketch",App::Prop_None,"Sketch constraints"); + ADD_PROPERTY_TYPE(ExternalGeometry,(0,0),"Sketch",App::Prop_None,"Sketch external geometry"); + ADD_PROPERTY_TYPE(FullyConstrained, (false),"Sketch",App::Prop_Output+App::Prop_ReadOnly+App::Prop_Hidden,"Sketch is fully constrained"); Geometry.setOrderRelevant(true); diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 315af5a79cf9..6e79402949fa 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -1910,8 +1910,7 @@ int SketchObjectPy::setCustomAttributes(const char* attr, PyObject* obj) App::Property *prop = getSketchObjectPtr()->getPropertyByName(attr); if (prop) { // Read-only attributes must not be set over its Python interface - short Type = getSketchObjectPtr()->getPropertyType(prop); - if (Type & App::Prop_ReadOnly) { + if (prop->testStatus(App::PropertyStatus::Prop_ReadOnly)) { std::stringstream s; s << "Object attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); diff --git a/src/Mod/Sketcher/App/SketchObjectSF.cpp b/src/Mod/Sketcher/App/SketchObjectSF.cpp index ef6c0e8d8cc0..5038aa92d454 100644 --- a/src/Mod/Sketcher/App/SketchObjectSF.cpp +++ b/src/Mod/Sketcher/App/SketchObjectSF.cpp @@ -39,7 +39,7 @@ PROPERTY_SOURCE(Sketcher::SketchObjectSF, Part::Part2DObject) SketchObjectSF::SketchObjectSF() { - ADD_PROPERTY_TYPE(SketchFlatFile,(0),"",(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(SketchFlatFile,(0),"",App::Prop_None, "SketchFlat file (*.skf) which defines this sketch"); } diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 6c96f5871a0a..262264116724 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -320,14 +320,14 @@ ViewProviderSketch::ViewProviderSketch() { PartGui::ViewProviderAttachExtension::initExtension(this); - ADD_PROPERTY_TYPE(Autoconstraints,(true),"Auto Constraints",(App::PropertyType)(App::Prop_None),"Create auto constraints"); - ADD_PROPERTY_TYPE(AvoidRedundant,(true),"Auto Constraints",(App::PropertyType)(App::Prop_None),"Avoid redundant autoconstraint"); - ADD_PROPERTY_TYPE(TempoVis,(Py::None()),"Visibility automation",(App::PropertyType)(App::Prop_None),"Object that handles hiding and showing other objects when entering/leaving sketch."); - ADD_PROPERTY_TYPE(HideDependent,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects that depend on the sketch are hidden when opening editing."); - ADD_PROPERTY_TYPE(ShowLinks,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects used in links to external geometry are shown when opening sketch."); - ADD_PROPERTY_TYPE(ShowSupport,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects this sketch is attached to are shown when opening sketch."); - ADD_PROPERTY_TYPE(RestoreCamera,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, camera position before entering sketch is remembered, and restored after closing it."); - ADD_PROPERTY_TYPE(EditingWorkbench,("SketcherWorkbench"),"Visibility automation",(App::PropertyType)(App::Prop_None),"Name of the workbench to activate when editing this sketch."); + ADD_PROPERTY_TYPE(Autoconstraints,(true),"Auto Constraints",App::Prop_None,"Create auto constraints"); + ADD_PROPERTY_TYPE(AvoidRedundant,(true),"Auto Constraints",App::Prop_None,"Avoid redundant autoconstraint"); + ADD_PROPERTY_TYPE(TempoVis,(Py::None()),"Visibility automation",App::Prop_None,"Object that handles hiding and showing other objects when entering/leaving sketch."); + ADD_PROPERTY_TYPE(HideDependent,(true),"Visibility automation",App::Prop_None,"If true, all objects that depend on the sketch are hidden when opening editing."); + ADD_PROPERTY_TYPE(ShowLinks,(true),"Visibility automation",App::Prop_None,"If true, all objects used in links to external geometry are shown when opening sketch."); + ADD_PROPERTY_TYPE(ShowSupport,(true),"Visibility automation",App::Prop_None,"If true, all objects this sketch is attached to are shown when opening sketch."); + ADD_PROPERTY_TYPE(RestoreCamera,(true),"Visibility automation",App::Prop_None,"If true, camera position before entering sketch is remembered, and restored after closing it."); + ADD_PROPERTY_TYPE(EditingWorkbench,("SketcherWorkbench"),"Visibility automation",App::Prop_None,"Name of the workbench to activate when editing this sketch."); {//visibility automation: update defaults to follow preferences ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 7ae24ec8492e..2332e266b2c3 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -1190,7 +1190,7 @@ void PropertySheet::invalidateDependants(const App::DocumentObject *docObj) } void PropertySheet::slotChangedObject(const App::DocumentObject &obj, const App::Property &prop) { - recomputeDependants(&obj, prop.getName()); + recomputeDependants(&obj, prop.getName().c_str()); } void PropertySheet::onAddDep(App::DocumentObject *obj) { diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index a0a1f6916d1c..4a3e6afcd655 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -85,10 +85,10 @@ Sheet::Sheet() , props(PropertyContainer::dynamicProps) , cells(this) { - ADD_PROPERTY_TYPE(cells, (), "Spreadsheet", (PropertyType)(Prop_Hidden), "Cell contents"); - ADD_PROPERTY_TYPE(columnWidths, (), "Spreadsheet", (PropertyType)(Prop_ReadOnly|Prop_Hidden|Prop_Output), "Column widths"); - ADD_PROPERTY_TYPE(rowHeights, (), "Spreadsheet", (PropertyType)(Prop_ReadOnly|Prop_Hidden|Prop_Output), "Row heights"); - ADD_PROPERTY_TYPE(rowHeights, (), "Spreadsheet", (PropertyType)(Prop_ReadOnly|Prop_Hidden), "Row heights"); + ADD_PROPERTY_TYPE(cells, (), "Spreadsheet", Prop_Hidden, "Cell contents"); + ADD_PROPERTY_TYPE(columnWidths, (), "Spreadsheet", Prop_ReadOnly+Prop_Hidden+Prop_Output, "Column widths"); + ADD_PROPERTY_TYPE(rowHeights, (), "Spreadsheet", Prop_ReadOnly+Prop_Hidden+Prop_Output, "Row heights"); + ADD_PROPERTY_TYPE(rowHeights, (), "Spreadsheet", Prop_ReadOnly+Prop_Hidden, "Row heights"); } /** @@ -481,15 +481,16 @@ void Sheet::onSettingDocument() Property * Sheet::setFloatProperty(CellAddress key, double value) { - Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); + Property * prop = props.getDynamicPropertyByName(key.toString()); PropertyFloat * floatProp; if (!prop || prop->getTypeId() != PropertyFloat::getClassTypeId()) { if (prop) { - this->removeDynamicProperty(key.toString().c_str()); + this->removeDynamicProperty(key.toString()); propAddress.erase(prop); } - floatProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyFloat", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Hidden | Prop_NoPersist)); + floatProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyFloat", key.toString())); + floatProp->setStatus(Prop_ReadOnly + Prop_Hidden + Prop_NoPersist); } else floatProp = static_cast(prop); @@ -510,9 +511,8 @@ Property * Sheet::setIntegerProperty(CellAddress key, long value) this->removeDynamicProperty(key.toString().c_str()); propAddress.erase(prop); } - intProp = freecad_dynamic_cast(addDynamicProperty( - "App::PropertyInteger", key.toString().c_str(), 0, 0, - Prop_ReadOnly | Prop_Hidden | Prop_NoPersist)); + intProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyInteger", key.toString())); + intProp->setStatus(Prop_ReadOnly + Prop_Hidden + Prop_NoPersist); } else intProp = static_cast(prop); @@ -536,15 +536,16 @@ Property * Sheet::setIntegerProperty(CellAddress key, long value) Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base::Unit & unit) { - Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); + Property * prop = props.getDynamicPropertyByName(key.toString()); PropertySpreadsheetQuantity * quantityProp; if (!prop || prop->getTypeId() != PropertySpreadsheetQuantity::getClassTypeId()) { if (prop) { - this->removeDynamicProperty(key.toString().c_str()); + this->removeDynamicProperty(key.toString()); propAddress.erase(prop); } - Property * p = addDynamicProperty("Spreadsheet::PropertySpreadsheetQuantity", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Hidden | Prop_NoPersist); + Property * p = addDynamicProperty("Spreadsheet::PropertySpreadsheetQuantity", key.toString()); + p->setStatus(Prop_ReadOnly + Prop_Hidden + Prop_NoPersist); quantityProp = freecad_dynamic_cast(p); } else @@ -570,15 +571,16 @@ Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base: Property * Sheet::setStringProperty(CellAddress key, const std::string & value) { - Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); + Property * prop = props.getDynamicPropertyByName(key.toString()); PropertyString * stringProp = freecad_dynamic_cast(prop); if (!stringProp) { if (prop) { - this->removeDynamicProperty(key.toString().c_str()); + this->removeDynamicProperty(key.toString()); propAddress.erase(prop); } - stringProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyString", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Hidden | Prop_NoPersist)); + stringProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyString", key.toString())); + stringProp->setStatus(Prop_ReadOnly + Prop_Hidden + Prop_NoPersist); } propAddress[stringProp] = key; @@ -589,15 +591,16 @@ Property * Sheet::setStringProperty(CellAddress key, const std::string & value) Property * Sheet::setObjectProperty(CellAddress key, Py::Object object) { - Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); + Property * prop = props.getDynamicPropertyByName(key.toString()); PropertyPythonObject * pyProp = freecad_dynamic_cast(prop); if (!pyProp) { if (prop) { - this->removeDynamicProperty(key.toString().c_str()); + this->removeDynamicProperty(key.toString()); propAddress.erase(prop); } - pyProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyPythonObject", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Hidden | Prop_NoPersist)); + pyProp = freecad_dynamic_cast(addDynamicProperty("App::PropertyPythonObject", key.toString())); + pyProp-> setStatus(Prop_ReadOnly + Prop_Hidden + Prop_NoPersist); } propAddress[pyProp] = key; @@ -634,8 +637,8 @@ void Sheet::updateAlias(CellAddress key) } if (!aliasProp) { - aliasProp = addDynamicProperty(prop->getTypeId().getName(), alias.c_str(), 0, 0, Prop_ReadOnly | Prop_NoPersist); - aliasProp->setStatus(App::Property::Hidden,true); + aliasProp = addDynamicProperty(prop->getTypeId().getName(), alias); + aliasProp->setStatus(Hidden + Prop_ReadOnly + Prop_NoPersist); } aliasProp->Paste(*prop); @@ -703,12 +706,12 @@ void Sheet::updateProperty(CellAddress key) setFloatProperty(key, number->getValue()); }else{ auto str_expr = freecad_dynamic_cast(output.get()); - if(str_expr) + if(str_expr) setStringProperty(key, str_expr->getText().c_str()); else { Base::PyGILStateLocker lock; auto py_expr = freecad_dynamic_cast(output.get()); - if(py_expr) + if(py_expr) setObjectProperty(key, py_expr->getPyValue()); else setObjectProperty(key, Py::Object()); @@ -1087,7 +1090,7 @@ std::vector Sheet::getUsedCells() const return usedCells; } -void Sheet::updateColumnsOrRows(bool horizontal, int section, int count) +void Sheet::updateColumnsOrRows(bool horizontal, int section, int count) { const auto &sizes = horizontal?columnWidths.getValues():rowHeights.getValues(); auto iter = sizes.lower_bound(section); diff --git a/src/Mod/Spreadsheet/App/SheetObserver.cpp b/src/Mod/Spreadsheet/App/SheetObserver.cpp index 51c8ac3320f7..30a38954932e 100644 --- a/src/Mod/Spreadsheet/App/SheetObserver.cpp +++ b/src/Mod/Spreadsheet/App/SheetObserver.cpp @@ -73,16 +73,15 @@ void SheetObserver::slotChangedObject(const DocumentObject &Obj, const Property if (&Prop == &Obj.Label) sheet->renamedDocumentObject(&Obj); else { - const char * name = Obj.getPropertyName(&Prop); - - if (name == 0) + if (!Obj.isOwnerOf(Prop)) return; + const std::string& name=Prop.getName(); if (isUpdating.find(name) != isUpdating.end()) return; isUpdating.insert(name); - sheet->recomputeDependants(&Obj,Prop.getName()); + sheet->recomputeDependants(&Obj,Prop.getName().c_str()); isUpdating.erase(name); } } diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.cpp b/src/Mod/TechDraw/App/DrawGeomHatch.cpp index 00a703e5d4f0..b594d968c465 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.cpp +++ b/src/Mod/TechDraw/App/DrawGeomHatch.cpp @@ -94,7 +94,7 @@ DrawGeomHatch::DrawGeomHatch(void) { static const char *vgroup = "GeomHatch"; - ADD_PROPERTY_TYPE(Source,(0),vgroup,(App::PropertyType)(App::Prop_None),"The View + Face to be crosshatched"); + ADD_PROPERTY_TYPE(Source,(0),vgroup,App::Prop_None,"The View + Face to be crosshatched"); Source.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(FilePattern ,(prefGeomHatchFile()),vgroup,App::Prop_None,"The crosshatch pattern file for this area"); ADD_PROPERTY_TYPE(PatIncluded, (""), vgroup,App::Prop_None, @@ -238,7 +238,7 @@ std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou std::vector result; gp_Pln p; Base::Vector3d vfc = DrawUtil::getFaceCenter(f); - gp_Pnt fc(vfc.x, vfc.y, vfc.z); + gp_Pnt fc(vfc.x, vfc.y, vfc.z); double dir = -1.0; if (fc.Z() < 0.0) { dir = -dir; @@ -246,7 +246,7 @@ std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou Base::Vector3d stdZ(0.0, 0.0, 1.0); Base::Vector3d offset = stdZ * p.Distance(fc) * dir; - //f may be above or below paper plane and must be moved so Common operation in + //f may be above or below paper plane and must be moved so Common operation in //getTrimmedLines succeeds TopoDS_Shape moved = TechDraw::moveShape(f, offset); @@ -556,7 +556,7 @@ void DrawGeomHatch::replacePatIncluded(std::string newPatFile) } } -void DrawGeomHatch::onDocumentRestored() +void DrawGeomHatch::onDocumentRestored() { // Base::Console().Message("DGH::onDocumentRestored()\n"); if (PatIncluded.isEmpty()) { @@ -646,7 +646,7 @@ App::Color DrawGeomHatch::prefGeomHatchColor() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000)); + fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000)); return fcColor; } diff --git a/src/Mod/TechDraw/App/DrawHatch.cpp b/src/Mod/TechDraw/App/DrawHatch.cpp index 82cecded3412..0da182b90bc2 100644 --- a/src/Mod/TechDraw/App/DrawHatch.cpp +++ b/src/Mod/TechDraw/App/DrawHatch.cpp @@ -59,7 +59,7 @@ DrawHatch::DrawHatch(void) { static const char *vgroup = "Hatch"; - ADD_PROPERTY_TYPE(Source, (0), vgroup, (App::PropertyType)(App::Prop_None), "The View + Face to be hatched"); + ADD_PROPERTY_TYPE(Source, (0), vgroup, App::Prop_None, "The View + Face to be hatched"); Source.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(HatchPattern, (prefSvgHatch()), vgroup, App::Prop_None, "The hatch pattern file for this area"); ADD_PROPERTY_TYPE(SvgIncluded, (""), vgroup,App::Prop_None, @@ -198,7 +198,7 @@ void DrawHatch::replaceSvgIncluded(std::string newSvgFile) } } -void DrawHatch::onDocumentRestored() +void DrawHatch::onDocumentRestored() { //if this is a restore, we should be checking for SvgIncluded empty, // if it is, set it up from hatchPattern, diff --git a/src/Mod/TechDraw/App/DrawLeaderLine.cpp b/src/Mod/TechDraw/App/DrawLeaderLine.cpp index 6904e47f8669..288bdb570a40 100644 --- a/src/Mod/TechDraw/App/DrawLeaderLine.cpp +++ b/src/Mod/TechDraw/App/DrawLeaderLine.cpp @@ -72,7 +72,7 @@ DrawLeaderLine::DrawLeaderLine(void) { static const char *group = "Leader"; - ADD_PROPERTY_TYPE(LeaderParent,(0),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(LeaderParent,(0),group,App::Prop_None, "View to which this leader is attached"); LeaderParent.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(WayPoints,(Base::Vector3d()) ,group, App::Prop_None, @@ -94,16 +94,16 @@ DrawLeaderLine::DrawLeaderLine(void) ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()),group,App::Prop_None,"Forces last line segment to be horizontal"); //hide the DrawView properties that don't apply to Leader - ScaleType.setStatus(App::Property::ReadOnly,true); - ScaleType.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::ReadOnly,true); - Scale.setStatus(App::Property::Hidden,true); - Rotation.setStatus(App::Property::ReadOnly,true); - Rotation.setStatus(App::Property::Hidden,true); - Caption.setStatus(App::Property::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::ReadOnly,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); + Scale.setStatus(App::PropertyStatus::ReadOnly,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); + Rotation.setStatus(App::PropertyStatus::ReadOnly,true); + Rotation.setStatus(App::PropertyStatus::Hidden,true); + Caption.setStatus(App::PropertyStatus::Hidden,true); LockPosition.setValue(true); - LockPosition.setStatus(App::Property::Hidden,true); + LockPosition.setStatus(App::PropertyStatus::Hidden,true); } DrawLeaderLine::~DrawLeaderLine() diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index 7d944593e84b..9eadbe9f12d0 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -80,10 +80,10 @@ DrawPage::DrawPage(void) forceRedraw(false); ADD_PROPERTY_TYPE(KeepUpdated, (Preferences::keepPagesUpToDate()), - group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model"); - ADD_PROPERTY_TYPE(Template, (0), group, (App::PropertyType)(App::Prop_None), "Attached Template"); + group, App::Prop_Output, "Keep page in sync with model"); + ADD_PROPERTY_TYPE(Template, (0), group, App::Prop_None, "Attached Template"); Template.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(Views, (0), group, (App::PropertyType)(App::Prop_None), "Attached Views"); + ADD_PROPERTY_TYPE(Views, (0), group,App::Prop_None, "Attached Views"); Views.setScope(App::LinkScope::Global); // Projection Properties @@ -94,9 +94,9 @@ DrawPage::DrawPage(void) GetGroup("BaseApp")->GetGroup("Preferences")-> GetGroup("Mod/TechDraw/General"); double defScale = hGrp->GetFloat("DefaultScale",1.0); - ADD_PROPERTY_TYPE(Scale, (defScale), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page"); + ADD_PROPERTY_TYPE(Scale, (defScale), group,App::Prop_None, "Scale factor for this Page"); - ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, (App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, App::Prop_None, "Auto-numbering for Balloons"); Scale.setConstraints(&scaleRange); diff --git a/src/Mod/TechDraw/App/DrawParametricTemplate.cpp b/src/Mod/TechDraw/App/DrawParametricTemplate.cpp index b4a1c2cce894..f7dc3bea8da5 100644 --- a/src/Mod/TechDraw/App/DrawParametricTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawParametricTemplate.cpp @@ -51,7 +51,7 @@ PROPERTY_SOURCE(TechDraw::DrawParametricTemplate, TechDraw::DrawTemplate) DrawParametricTemplate::DrawParametricTemplate(void) { static const char *group = "Page"; - ADD_PROPERTY_TYPE(Template ,(""),group, (App::PropertyType) App::Prop_None,"Template script"); + ADD_PROPERTY_TYPE(Template ,(""),group, App::Prop_None,"Template script"); } DrawParametricTemplate::~DrawParametricTemplate() diff --git a/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp index f2a2ba7d7a69..0d5d92a8931d 100644 --- a/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp @@ -50,8 +50,7 @@ int DrawParametricTemplatePy::setCustomAttributes(const char* attr, PyObject* ob App::Property *prop = getDrawParametricTemplatePtr()->getPropertyByName(attr); if (prop) { // Read-only attributes must not be set over its Python interface - short Type = getDrawParametricTemplatePtr()->getPropertyType(prop); - if (Type & App::Prop_ReadOnly) { + if (prop->testStatus(App::PropertyStatus::Prop_ReadOnly)) { std::stringstream s; s << "Object attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 9dd37ac7c183..e4894cce7f42 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -71,7 +71,7 @@ DrawProjGroup::DrawProjGroup(void) : Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); bool autoDist = hGrp->GetBool("AutoDist",true); - + ADD_PROPERTY_TYPE(Source, (0), group, App::Prop_None, "Shape to view"); Source.setScope(App::LinkScope::Global); Source.setAllowExternal(true); @@ -88,8 +88,8 @@ DrawProjGroup::DrawProjGroup(void) : App::Prop_None, "Distribute views automatically or manually"); ADD_PROPERTY_TYPE(spacingX, (15), agroup, App::Prop_None, "If AutoDistribute is on, this is the horizontal \nspacing between the borders of views \n(if label width is not wider than the object)"); ADD_PROPERTY_TYPE(spacingY, (15), agroup, App::Prop_None, "If AutoDistribute is on, this is the vertical \nspacing between the borders of views"); - Rotation.setStatus(App::Property::Hidden, true); //DPG does not rotate - Caption.setStatus(App::Property::Hidden, true); + Rotation.setStatus(App::PropertyStatus::Hidden, true); //DPG does not rotate + Caption.setStatus(App::PropertyStatus::Hidden, true); } DrawProjGroup::~DrawProjGroup() @@ -468,7 +468,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) Anchor.purgeTouched(); requestPaint(); //make sure the group object is on the Gui page view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!). - view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked. + view->LockPosition.setStatus(App::PropertyStatus::ReadOnly,true); //Front should stay locked. view->LockPosition.purgeTouched(); } // addView(view); //from DrawViewCollection @@ -570,7 +570,7 @@ std::pair DrawProjGroup::getDirsFromFront(std::st gp_Ax2 newCS; gp_Dir gNewDir; gp_Dir gNewXDir; - + double angle = M_PI / 2.0; //90* if (viewType == "Right") { diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index f51d9669b498..10e5eed10b9f 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -68,11 +68,11 @@ DrawProjGroupItem::DrawProjGroupItem(void) App::Prop_None,"Deprecated. Use XDirection."); //projection group controls these -// Direction.setStatus(App::Property::ReadOnly,true); - RotationVector.setStatus(App::Property::ReadOnly,true); //Use XDirection +// Direction.setStatus(App::PropertyStatus::ReadOnly,true); + RotationVector.setStatus(App::PropertyStatus::ReadOnly,true); //Use XDirection ScaleType.setValue("Custom"); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); } DrawProjGroupItem::~DrawProjGroupItem() @@ -119,9 +119,9 @@ bool DrawProjGroupItem::showLock(void) const } if (isAnchor() && //don't show lock for Front if DPG is not locked - !parentLock) { + !parentLock) { result = false; - } + } return result; } @@ -204,7 +204,7 @@ bool DrawProjGroupItem::isAnchor(void) const /// get a coord system aligned with Direction and Rotation Vector gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt, - const Base::Vector3d& axis, + const Base::Vector3d& axis, const bool flip) const { Base::Console().Message("DPGI::getViewAxis - deprecated. use getProjectionCS\n"); @@ -258,7 +258,7 @@ Base::Vector3d DrawProjGroupItem::getXDirection(void) const prop = getPropertyByName("RotationVector"); if (prop != nullptr) { result = RotationVector.getValue(); - + } else { Base::Console().Message("DPGI::getXDirection - missing RotationVector and XDirection\n"); } diff --git a/src/Mod/TechDraw/App/DrawRichAnno.cpp b/src/Mod/TechDraw/App/DrawRichAnno.cpp index 2a6a7e1a4223..8f7d953d406d 100644 --- a/src/Mod/TechDraw/App/DrawRichAnno.cpp +++ b/src/Mod/TechDraw/App/DrawRichAnno.cpp @@ -47,14 +47,14 @@ DrawRichAnno::DrawRichAnno(void) { static const char *group = "Text Block"; - ADD_PROPERTY_TYPE(AnnoParent,(0),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(AnnoParent,(0),group,App::Prop_None, "Object to which this annontation is attached"); ADD_PROPERTY_TYPE(AnnoText, (""), group, App::Prop_None, "Annotation text"); ADD_PROPERTY_TYPE(ShowFrame, (true), group, App::Prop_None, "Outline rectangle on/off"); ADD_PROPERTY_TYPE(MaxWidth, (-1.0), group, App::Prop_None, "Width limit before auto wrap"); - Caption.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Caption.setStatus(App::PropertyStatus::Hidden,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); } @@ -89,7 +89,7 @@ short DrawRichAnno::mustExecute() const } App::DocumentObjectExecReturn *DrawRichAnno::execute(void) -{ +{ // Base::Console().Message("DRA::execute() - @ (%.3f, %.3f)\n", X.getValue(), Y.getValue()); if (!keepUpdated()) { return App::DocumentObject::StdReturn; diff --git a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp index bb8b0ad59fc8..9fc65beec0bc 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp @@ -73,9 +73,9 @@ DrawSVGTemplate::DrawSVGTemplate() ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_Transient, "Template for the page"); //sb TemplateFileName??? // Width and Height properties shouldn't be set by the user - Height.setStatus(App::Property::ReadOnly,true); - Width.setStatus(App::Property::ReadOnly,true); - Orientation.setStatus(App::Property::ReadOnly,true); + Height.setStatus(App::PropertyStatus::ReadOnly,true); + Width.setStatus(App::PropertyStatus::ReadOnly,true); + Orientation.setStatus(App::PropertyStatus::ReadOnly,true); std::string svgFilter("Svg files (*.svg *.SVG);;All files (*)"); Template.setFilter(svgFilter); diff --git a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp index cca9db485aa0..0e1583080df0 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp @@ -47,8 +47,7 @@ int DrawSVGTemplatePy::setCustomAttributes(const char* attr, PyObject* obj) App::Property *prop = getDrawSVGTemplatePtr()->getPropertyByName(attr); if (prop) { // Read-only attributes must not be set over its Python interface - short Type = getDrawSVGTemplatePtr()->getPropertyType(prop); - if (Type & App::Prop_ReadOnly) { + if (prop->testStatus(App::PropertyStatus::Prop_ReadOnly)) { std::stringstream s; s << "Object attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index 0b980085db28..51e37816b2e1 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -60,11 +60,11 @@ DrawTemplate::DrawTemplate(void) ADD_PROPERTY(Orientation, ((long)0)); // Physical Properties inherent to every template class - ADD_PROPERTY_TYPE(Width, (0), group, (App::PropertyType)(App::Prop_None), "Width of page"); - ADD_PROPERTY_TYPE(Height, (0), group, (App::PropertyType)(App::Prop_None), "Height of page"); + ADD_PROPERTY_TYPE(Width, (0), group, App::Prop_None, "Width of page"); + ADD_PROPERTY_TYPE(Height, (0), group, App::Prop_None, "Height of page"); //ADD_PROPERTY_TYPE(PaperSize, (""), group, (App::PropertyType)(App::Prop_None), "Paper Format"); //obs? - ADD_PROPERTY_TYPE(EditableTexts, (), group, (App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(EditableTexts, (), group, App::Prop_None, "Editable strings in the template"); } diff --git a/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp index e3a0e5384436..69d6814fad51 100644 --- a/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawTemplatePyImp.cpp @@ -50,8 +50,7 @@ int DrawTemplatePy::setCustomAttributes(const char* attr, PyObject* obj) App::Property *prop = getDrawTemplatePtr()->getPropertyByName(attr); if (prop) { // Read-only attributes must not be set over its Python interface - short Type = getDrawTemplatePtr()->getPropertyType(prop); - if (Type & App::Prop_ReadOnly) { + if (prop->testStatus(App::PropertyStatus::Prop_ReadOnly)) { std::stringstream s; s << "Object attribute '" << attr << "' is read-only"; throw Py::AttributeError(s.str()); diff --git a/src/Mod/TechDraw/App/DrawTile.cpp b/src/Mod/TechDraw/App/DrawTile.cpp index e31e6f0e34a2..d9b8982af487 100644 --- a/src/Mod/TechDraw/App/DrawTile.cpp +++ b/src/Mod/TechDraw/App/DrawTile.cpp @@ -47,13 +47,13 @@ DrawTile::DrawTile(void) { static const char *group = "Tile"; - ADD_PROPERTY_TYPE(TileParent,(0),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TileParent,(0),group,App::Prop_None, "Object to which this tile is attached"); ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent object\n 0 for arrow side, -1 for other side"); ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent object"); // there is currently only one column, this don't allow to edit - TileColumn.setStatus(App::Property::ReadOnly, true); + TileColumn.setStatus(App::PropertyStatus::ReadOnly, true); // the row can only have the value 0 or -1 // allow its editing because this way the tiles can be flipped TileRowConstraints.LowerBound = -1; diff --git a/src/Mod/TechDraw/App/DrawTileWeld.cpp b/src/Mod/TechDraw/App/DrawTileWeld.cpp index 8d737d002e3a..91b0cae79b02 100644 --- a/src/Mod/TechDraw/App/DrawTileWeld.cpp +++ b/src/Mod/TechDraw/App/DrawTileWeld.cpp @@ -52,7 +52,7 @@ DrawTileWeld::DrawTileWeld(void) { static const char *group = "TileWeld"; - ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(LeftText,(""),group,App::Prop_None, "Text before symbol"); ADD_PROPERTY_TYPE(RightText, (0), group, App::Prop_None, "Text after symbol"); ADD_PROPERTY_TYPE(CenterText, (0), group, App::Prop_None, "Text above/below symbol"); @@ -94,7 +94,7 @@ short DrawTileWeld::mustExecute() const } App::DocumentObjectExecReturn *DrawTileWeld::execute(void) -{ +{ // Base::Console().Message("DTW::execute()\n"); return DrawTile::execute(); } @@ -111,7 +111,7 @@ void DrawTileWeld::replaceSymbolIncluded(std::string newSymbolFile) } } -void DrawTileWeld::onDocumentRestored() +void DrawTileWeld::onDocumentRestored() { // Base::Console().Message("DTW::onDocumentRestored()\n"); if (SymbolIncluded.isEmpty()) { diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index 827a2cc1daef..d158287557d5 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -76,8 +76,8 @@ DrawView::DrawView(void): mouseMove(false) { static const char *group = "Base"; - ADD_PROPERTY_TYPE(X, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "X position"); - ADD_PROPERTY_TYPE(Y, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "Y position"); + ADD_PROPERTY_TYPE(X, (0.0), group, App::Prop_Output+App::Prop_NoRecompute, "X position"); + ADD_PROPERTY_TYPE(Y, (0.0), group, App::Prop_Output+App::Prop_NoRecompute, "Y position"); ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_Output, "Lock View position to parent Page or Group"); ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_Output, "Rotation in degrees counterclockwise"); @@ -131,7 +131,7 @@ void DrawView::onChanged(const App::Property* prop) if (prop == &ScaleType) { auto page = findParentPage(); if (ScaleType.isValue("Page")) { - Scale.setStatus(App::Property::ReadOnly,true); + Scale.setStatus(App::PropertyStatus::ReadOnly,true); if (page != nullptr) { if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) { Scale.setValue(page->Scale.getValue()); @@ -140,9 +140,9 @@ void DrawView::onChanged(const App::Property* prop) } } else if ( ScaleType.isValue("Custom") ) { //don't change Scale - Scale.setStatus(App::Property::ReadOnly,false); + Scale.setStatus(App::PropertyStatus::ReadOnly,false); } else if ( ScaleType.isValue("Automatic") ) { - Scale.setStatus(App::Property::ReadOnly,true); + Scale.setStatus(App::PropertyStatus::ReadOnly,true); if (!checkFit(page)) { double newScale = autoScale(page->getPageWidth(),page->getPageHeight()); if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop @@ -181,21 +181,21 @@ bool DrawView::showLock(void) const void DrawView::handleXYLock(void) { if (isLocked()) { - if (!X.testStatus(App::Property::ReadOnly)) { - X.setStatus(App::Property::ReadOnly,true); + if (!X.testStatus(App::PropertyStatus::ReadOnly)) { + X.setStatus(App::PropertyStatus::ReadOnly,true); X.purgeTouched(); } - if (!Y.testStatus(App::Property::ReadOnly)) { - Y.setStatus(App::Property::ReadOnly,true); + if (!Y.testStatus(App::PropertyStatus::ReadOnly)) { + Y.setStatus(App::PropertyStatus::ReadOnly,true); Y.purgeTouched(); } } else { - if (X.testStatus(App::Property::ReadOnly)) { - X.setStatus(App::Property::ReadOnly,false); + if (X.testStatus(App::PropertyStatus::ReadOnly)) { + X.setStatus(App::PropertyStatus::ReadOnly,false); X.purgeTouched(); } - if (Y.testStatus(App::Property::ReadOnly)) { - Y.setStatus(App::Property::ReadOnly,false); + if (Y.testStatus(App::PropertyStatus::ReadOnly)) { + Y.setStatus(App::PropertyStatus::ReadOnly,false); Y.purgeTouched(); } } @@ -391,7 +391,7 @@ void DrawView::handleChangedPropertyType( } } else if (prop->isDerivedFrom(App::PropertyLinkList::getClassTypeId()) - && strcmp(prop->getName(), "Source") == 0) { + && prop->getName() == "Source") { App::PropertyLinkGlobal glink; App::PropertyLink link; if (strcmp(glink.getTypeId().getName(), TypeName) == 0) { //property in file is plg diff --git a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp index 6e194d37e2a7..7a86baf1287a 100644 --- a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp +++ b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp @@ -71,8 +71,8 @@ DrawViewAnnotation::DrawViewAnnotation(void) TextStyle.setEnums(TextStyleEnums); ADD_PROPERTY_TYPE(TextStyle,((long)0),vgroup,App::Prop_None,"Text style"); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); } DrawViewAnnotation::~DrawViewAnnotation() @@ -100,7 +100,7 @@ void DrawViewAnnotation::handleChangedPropertyType(Base::XMLReader &reader, cons { // also check for changed properties of the base class DrawView::handleChangedPropertyType(reader, TypeName, prop); - + // property LineSpace had the App::PropertyInteger and was changed to App::PropertyPercent if (prop == &LineSpace && strcmp(TypeName, "App::PropertyInteger") == 0) { App::PropertyInteger LineSpaceProperty; diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.cpp b/src/Mod/TechDraw/App/DrawViewBalloon.cpp index 684cbc934b2b..6956f4015694 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.cpp +++ b/src/Mod/TechDraw/App/DrawViewBalloon.cpp @@ -92,30 +92,30 @@ const char* DrawViewBalloon::balloonTypeEnums[]= {"Circular", DrawViewBalloon::DrawViewBalloon(void) { ADD_PROPERTY_TYPE(Text, (""), "", App::Prop_None, "The text to be displayed"); - ADD_PROPERTY_TYPE(SourceView, (0), "", (App::PropertyType)(App::Prop_None), "Source view for balloon"); - ADD_PROPERTY_TYPE(OriginX, (0), "", (App::PropertyType)(App::Prop_None), "Balloon origin x"); - ADD_PROPERTY_TYPE(OriginY, (0), "", (App::PropertyType)(App::Prop_None), "Balloon origin y"); + ADD_PROPERTY_TYPE(SourceView, (0), "", App::Prop_None, "Source view for balloon"); + ADD_PROPERTY_TYPE(OriginX, (0), "", App::Prop_None, "Balloon origin x"); + ADD_PROPERTY_TYPE(OriginY, (0), "", App::Prop_None, "Balloon origin y"); EndType.setEnums(ArrowPropEnum::ArrowTypeEnums); - ADD_PROPERTY_TYPE(EndType, (prefEnd()), "", (App::PropertyType)(App::Prop_None), "End symbol for the balloon line"); + ADD_PROPERTY_TYPE(EndType, (prefEnd()), "", App::Prop_None, "End symbol for the balloon line"); - ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None),"End symbol scale factor"); + ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", App::Prop_None,"End symbol scale factor"); EndTypeScale.setConstraints(&SymbolScaleRange); BubbleShape.setEnums(balloonTypeEnums); - ADD_PROPERTY_TYPE(BubbleShape, (prefShape()), "", (App::PropertyType)(App::Prop_None), "Shape of the balloon bubble"); + ADD_PROPERTY_TYPE(BubbleShape, (prefShape()), "", App::Prop_None, "Shape of the balloon bubble"); - ADD_PROPERTY_TYPE(ShapeScale, (1.0), "", (App::PropertyType)(App::Prop_None), "Balloon shape scale"); + ADD_PROPERTY_TYPE(ShapeScale, (1.0), "", App::Prop_None, "Balloon shape scale"); ShapeScale.setConstraints(&SymbolScaleRange); - ADD_PROPERTY_TYPE(TextWrapLen, (-1), "", (App::PropertyType)(App::Prop_None), "Text wrap length; -1 means no wrap"); + ADD_PROPERTY_TYPE(TextWrapLen, (-1), "", App::Prop_None, "Text wrap length; -1 means no wrap"); - ADD_PROPERTY_TYPE(KinkLength, (prefKinkLength()), "", (App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(KinkLength, (prefKinkLength()), "", App::Prop_None, "Distance from symbol to leader kink"); SourceView.setScope(App::LinkScope::Global); - Rotation.setStatus(App::Property::Hidden,true); - Caption.setStatus(App::Property::Hidden,true); + Rotation.setStatus(App::PropertyStatus::Hidden,true); + Caption.setStatus(App::PropertyStatus::Hidden,true); } DrawViewBalloon::~DrawViewBalloon() @@ -167,13 +167,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c DrawView::handleChangedPropertyType(reader, TypeName, prop); // property OriginX had the App::PropertyFloat and was changed to App::PropertyDistance - if ( (prop == &OriginX) && + if ( (prop == &OriginX) && (strcmp(TypeName, "App::PropertyFloat") == 0) ) { App::PropertyFloat OriginXProperty; // restore the PropertyFloat to be able to set its value OriginXProperty.Restore(reader); OriginX.setValue(OriginXProperty.getValue()); - } else if ( (prop == &OriginX) && + } else if ( (prop == &OriginX) && (strcmp(TypeName, "App::PropertyLength") == 0) ) { App::PropertyLength OriginXProperty; // restore the PropertyFloat to be able to set its value @@ -181,13 +181,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c OriginX.setValue(OriginXProperty.getValue()); // property OriginY had the App::PropertyFloat and was changed to App::PropertyDistance - } else if ( (prop == &OriginY) && + } else if ( (prop == &OriginY) && (strcmp(TypeName, "App::PropertyFloat") == 0) ) { App::PropertyFloat OriginYProperty; // restore the PropertyFloat to be able to set its value OriginYProperty.Restore(reader); OriginY.setValue(OriginYProperty.getValue()); - } else if ( (prop == &OriginY) && + } else if ( (prop == &OriginY) && (strcmp(TypeName, "App::PropertyLength") == 0) ) { App::PropertyLength OriginYProperty; // restore the PropertyLength to be able to set its value @@ -220,21 +220,21 @@ short DrawViewBalloon::mustExecute() const void DrawViewBalloon::handleXYLock(void) { if (isLocked()) { - if (!OriginX.testStatus(App::Property::ReadOnly)) { - OriginX.setStatus(App::Property::ReadOnly, true); + if (!OriginX.testStatus(App::PropertyStatus::ReadOnly)) { + OriginX.setStatus(App::PropertyStatus::ReadOnly, true); OriginX.purgeTouched(); } - if (!OriginY.testStatus(App::Property::ReadOnly)) { - OriginY.setStatus(App::Property::ReadOnly, true); + if (!OriginY.testStatus(App::PropertyStatus::ReadOnly)) { + OriginY.setStatus(App::PropertyStatus::ReadOnly, true); OriginY.purgeTouched(); } } else { - if (OriginX.testStatus(App::Property::ReadOnly)) { - OriginX.setStatus(App::Property::ReadOnly, false); + if (OriginX.testStatus(App::PropertyStatus::ReadOnly)) { + OriginX.setStatus(App::PropertyStatus::ReadOnly, false); OriginX.purgeTouched(); } - if (OriginY.testStatus(App::Property::ReadOnly)) { - OriginY.setStatus(App::Property::ReadOnly, false); + if (OriginY.testStatus(App::PropertyStatus::ReadOnly)) { + OriginY.setStatus(App::PropertyStatus::ReadOnly, false); OriginY.purgeTouched(); } } @@ -276,7 +276,7 @@ int DrawViewBalloon::prefShape(void) const { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); - int result = hGrp->GetInt("BalloonShape", 0); + int result = hGrp->GetInt("BalloonShape", 0); return result; } diff --git a/src/Mod/TechDraw/App/DrawViewClip.cpp b/src/Mod/TechDraw/App/DrawViewClip.cpp index 1e44c9418e4b..5d0d2767e848 100644 --- a/src/Mod/TechDraw/App/DrawViewClip.cpp +++ b/src/Mod/TechDraw/App/DrawViewClip.cpp @@ -57,10 +57,10 @@ DrawViewClip::DrawViewClip(void) Views.setScope(App::LinkScope::Global); // hide N/A properties - ScaleType.setStatus(App::Property::ReadOnly,true); - ScaleType.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::ReadOnly,true); - Scale.setStatus(App::Property::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::ReadOnly,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); + Scale.setStatus(App::PropertyStatus::ReadOnly,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); } DrawViewClip::~DrawViewClip() diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 3ea133b2895b..d6535d144e46 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -115,8 +115,8 @@ DrawViewDetail::DrawViewDetail() m_fudge = 1.01; //hide Properties not relevant to DVDetail - Direction.setStatus(App::Property::ReadOnly,true); //Should be same as BaseView - Rotation.setStatus(App::Property::ReadOnly,true); //same as BaseView + Direction.setStatus(App::PropertyStatus::ReadOnly,true); //Should be same as BaseView + Rotation.setStatus(App::PropertyStatus::ReadOnly,true); //same as BaseView ScaleType.setValue("Custom"); //dvd uses scale from BaseView } @@ -160,7 +160,7 @@ void DrawViewDetail::onChanged(const App::Property* prop) auto page = findParentPage(); // if ScaleType is "Page", the user cannot change it if (ScaleType.isValue("Page")) { - Scale.setStatus(App::Property::ReadOnly, true); + Scale.setStatus(App::PropertyStatus::ReadOnly, true); // apply the page-wide Scale if (page != nullptr) { if (std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) { @@ -171,10 +171,10 @@ void DrawViewDetail::onChanged(const App::Property* prop) } else if (ScaleType.isValue("Custom")) { // allow the change Scale - Scale.setStatus(App::Property::ReadOnly, false); + Scale.setStatus(App::PropertyStatus::ReadOnly, false); } else if (ScaleType.isValue("Automatic")) { - Scale.setStatus(App::Property::ReadOnly, true); + Scale.setStatus(App::PropertyStatus::ReadOnly, true); // apply a Scale if (!checkFit(page)) { double newScale = autoScale(page->getPageWidth(), page->getPageHeight()); @@ -401,7 +401,7 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape, m_saveCentroid += centroid; //center of massaged shape Base::Vector3d stdOrg(0.0,0.0,0.0); - gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); //sb same CS as base view. + gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); //sb same CS as base view. //center shape on origin // TopoDS_Shape centeredShape = TechDraw::moveShape(detail, diff --git a/src/Mod/TechDraw/App/DrawViewDimExtent.cpp b/src/Mod/TechDraw/App/DrawViewDimExtent.cpp index 77b8c8410d46..6cbaf9934aa8 100644 --- a/src/Mod/TechDraw/App/DrawViewDimExtent.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimExtent.cpp @@ -68,16 +68,16 @@ DrawViewDimExtent::DrawViewDimExtent(void) //Cosmetic End points are stored in DVD::References2d App::PropertyLinkSubList Source3d; //Part::Feature & SubElements TBI - ADD_PROPERTY_TYPE(Source,(0,0),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension"); + ADD_PROPERTY_TYPE(Source,(0,0),"", App::Prop_Output,"View (Edges) to dimension"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(Source3d,(0,0),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension"); //TBI + ADD_PROPERTY_TYPE(Source3d,(0,0),"",App::Prop_Output,"View (Edges) to dimension"); //TBI Source3d.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(DirExtent ,(0),"",App::Prop_Output,"Horizontal / Vertical"); ADD_PROPERTY_TYPE(CosmeticTags ,(""),"",App::Prop_Output,"Id of cosmetic endpoints"); //hide the properties the user can't edit in the property editor - Source3d.setStatus(App::Property::Hidden,true); //TBI + Source3d.setStatus(App::PropertyStatus::Hidden,true); //TBI } diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index d0f25e58ee5f..a7b930fd9479 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -132,18 +132,18 @@ DrawViewDimension::DrawViewDimension(void) ADD_PROPERTY_TYPE(Inverted, (false), "", App::Prop_Output, "The dimensional value is displayed inverted"); // hide the DrawView properties that don't apply to Dimensions - ScaleType.setStatus(App::Property::ReadOnly, true); - ScaleType.setStatus(App::Property::Hidden, true); - Scale.setStatus(App::Property::ReadOnly, true); - Scale.setStatus(App::Property::Hidden, true); - Rotation.setStatus(App::Property::ReadOnly, true); - Rotation.setStatus(App::Property::Hidden, true); - Caption.setStatus(App::Property::Hidden, true); - LockPosition.setStatus(App::Property::Hidden, true); + ScaleType.setStatus(App::PropertyStatus::ReadOnly, true); + ScaleType.setStatus(App::PropertyStatus::Hidden, true); + Scale.setStatus(App::PropertyStatus::ReadOnly, true); + Scale.setStatus(App::PropertyStatus::Hidden, true); + Rotation.setStatus(App::PropertyStatus::ReadOnly, true); + Rotation.setStatus(App::PropertyStatus::Hidden, true); + Caption.setStatus(App::PropertyStatus::Hidden, true); + LockPosition.setStatus(App::PropertyStatus::Hidden, true); // by default EqualTolerance is true, thus make UnderTolerance read-only - UnderTolerance.setStatus(App::Property::ReadOnly, true); - FormatSpecUnderTolerance.setStatus(App::Property::ReadOnly, true); + UnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); + FormatSpecUnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); measurement = new Measure::Measurement(); //TODO: should have better initial datumLabel position than (0,0) in the DVP?? something closer to the object being measured? @@ -212,20 +212,20 @@ void DrawViewDimension::onChanged(const App::Property* prop) if (TheoreticalExact.getValue()) { OverTolerance.setValue(0.0); UnderTolerance.setValue(0.0); - OverTolerance.setReadOnly(true); - UnderTolerance.setReadOnly(true); - FormatSpecOverTolerance.setReadOnly(true); - FormatSpecUnderTolerance.setReadOnly(true); + OverTolerance.setStatus(App::PropertyStatus::ReadOnly, true); + UnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); + FormatSpecOverTolerance.setStatus(App::PropertyStatus::ReadOnly, true); + FormatSpecUnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); ArbitraryTolerances.setValue(false); - ArbitraryTolerances.setReadOnly(true); + ArbitraryTolerances.setStatus(App::PropertyStatus::ReadOnly, true); } else { - OverTolerance.setReadOnly(false); - FormatSpecOverTolerance.setReadOnly(false); - ArbitraryTolerances.setReadOnly(false); + OverTolerance.setStatus(App::PropertyStatus::ReadOnly, false); + FormatSpecOverTolerance.setStatus(App::PropertyStatus::ReadOnly, false); + ArbitraryTolerances.setStatus(App::PropertyStatus::ReadOnly, false); if (!EqualTolerance.getValue()) { - UnderTolerance.setReadOnly(false); - FormatSpecUnderTolerance.setReadOnly(false); + UnderTolerance.setStatus(App::PropertyStatus::ReadOnly, false); + FormatSpecUnderTolerance.setStatus(App::PropertyStatus::ReadOnly, false); } } requestPaint(); @@ -241,19 +241,19 @@ void DrawViewDimension::onChanged(const App::Property* prop) OverTolerance.setConstraints(&PositiveConstraint); UnderTolerance.setValue(-1.0 * OverTolerance.getValue()); UnderTolerance.setUnit(OverTolerance.getUnit()); - UnderTolerance.setReadOnly(true); + UnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); FormatSpecUnderTolerance.setValue(FormatSpecOverTolerance.getValue()); - FormatSpecUnderTolerance.setReadOnly(true); + FormatSpecUnderTolerance.setStatus(App::PropertyStatus::ReadOnly, true); } else { OverTolerance.setConstraints(&ToleranceConstraint); if (!TheoreticalExact.getValue()) { - UnderTolerance.setReadOnly(false); - FormatSpecUnderTolerance.setReadOnly(false); + UnderTolerance.setStatus(App::PropertyStatus::ReadOnly, false); + FormatSpecUnderTolerance.setStatus(App::PropertyStatus::ReadOnly, false); } } requestPaint(); - } + } else if (prop == &OverTolerance) { // if EqualTolerance set negated overtolerance for untertolerance if (EqualTolerance.getValue()) { @@ -798,7 +798,7 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int if ((pos = rxUnits.indexIn(qUserString, 0)) != -1) { qUserStringUnits = rxUnits.cap(0); // entire capture - non numerics at end of qUserString } - + // get value in the base unit with default decimals // for the conversion we use the same method as in DlgUnitsCalculator::valueChanged // get the conversion factor for the unit diff --git a/src/Mod/TechDraw/App/DrawViewMulti.cpp b/src/Mod/TechDraw/App/DrawViewMulti.cpp index 2eecd5d0b19c..84bfc16e2524 100644 --- a/src/Mod/TechDraw/App/DrawViewMulti.cpp +++ b/src/Mod/TechDraw/App/DrawViewMulti.cpp @@ -82,8 +82,8 @@ DrawViewMulti::DrawViewMulti() ADD_PROPERTY_TYPE(Sources ,(0),group,App::Prop_None,"3D Shapes to view"); Sources.setScope(App::LinkScope::Global); //Source is replaced by Sources in Multi - Source.setStatus(App::Property::ReadOnly,true); - Source.setStatus(App::Property::Hidden,true); + Source.setStatus(App::PropertyStatus::ReadOnly,true); + Source.setStatus(App::PropertyStatus::Hidden,true); geometryObject = nullptr; } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 6c77bfe76095..1598930fb341 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -151,8 +151,8 @@ DrawViewSection::DrawViewSection() hatchFilter = ("PAT files (*.pat *.PAT);;All files (*)"); FileGeomPattern.setFilter(hatchFilter); - SvgIncluded.setStatus(App::Property::ReadOnly,true); - PatIncluded.setStatus(App::Property::ReadOnly,true); + SvgIncluded.setStatus(App::PropertyStatus::ReadOnly,true); + PatIncluded.setStatus(App::PropertyStatus::ReadOnly,true); } DrawViewSection::~DrawViewSection() @@ -179,7 +179,7 @@ void DrawViewSection::onChanged(const App::Property* prop) { App::Document* doc = getDocument(); // bool docRestoring = getDocument()->testStatus(App::Document::Status::Restoring); -// Base::Console().Message("DVS::onChanged(%s) - obj restoring: %d\n", +// Base::Console().Message("DVS::onChanged(%s) - obj restoring: %d\n", // prop->getName(), isRestoring()); if (!isRestoring()) { @@ -229,7 +229,7 @@ void DrawViewSection::onChanged(const App::Property* prop) DrawView::onChanged(prop); } -void DrawViewSection::makeLineSets(void) +void DrawViewSection::makeLineSets(void) { // Base::Console().Message("DVS::makeLineSets()\n"); if (!PatIncluded.isEmpty()) { @@ -243,7 +243,7 @@ void DrawViewSection::makeLineSets(void) (ext == "PAT") ) { if ((!fileSpec.empty()) && (!NameGeomPattern.isEmpty())) { - std::vector specs = + std::vector specs = DrawGeomHatch::getDecodedSpecsFromFile(fileSpec, NameGeomPattern.getValue()); m_lineSets.clear(); @@ -301,14 +301,14 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) } else { dvp = static_cast(base); } - + TopoDS_Shape baseShape; if (FuseBeforeCut.getValue()) { baseShape = dvp->getSourceShapeFused(); } else { baseShape = dvp->getSourceShape(); } - + if (baseShape.IsNull()) { bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); if (isRestoring) { @@ -670,7 +670,7 @@ Base::Vector3d DrawViewSection::getXDirection(void) const return result; } -void DrawViewSection::setCSFromBase(const std::string sectionName) +void DrawViewSection::setCSFromBase(const std::string sectionName) { // Base::Console().Message("DVS::setCSFromBase(%s)\n", sectionName.c_str()); gp_Ax2 CS = getCSFromBase(sectionName); @@ -696,7 +696,7 @@ gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const Base::Vector3d sectOrigin = SectionOrigin.getValue(); gp_Ax2 dvpCS = getBaseDVP()->getProjectionCS(sectOrigin); - + if (debugSection()) { DrawUtil::dumpCS("DVS::getCSFromBase - dvp CS", dvpCS); } @@ -757,7 +757,7 @@ gp_Ax2 DrawViewSection::getSectionCS(void) const gp_Ax2 sectionCS(gOrigin, gNormal); try { - sectionCS = gp_Ax2(gOrigin, + sectionCS = gp_Ax2(gOrigin, gNormal, gXDir); } @@ -877,7 +877,7 @@ bool DrawViewSection::showSectionEdges(void) } -void DrawViewSection::onDocumentRestored() +void DrawViewSection::onDocumentRestored() { // Base::Console().Message("DVS::onDocumentRestored()\n"); if (SvgIncluded.isEmpty()) { @@ -921,7 +921,7 @@ void DrawViewSection::setupSvgIncluded(void) special += "SvgHatch.svg"; std::string dir = doc->TransientDir.getValue(); std::string svgName = dir + special; - + //first time std::string svgInclude = SvgIncluded.getValue(); if (svgInclude.empty()) { diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index eb1007a83648..6015623832a4 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -71,7 +71,7 @@ DrawViewSpreadsheet::DrawViewSpreadsheet(void) ADD_PROPERTY_TYPE(TextSize,(12.0),vgroup,App::Prop_None,"The size of the text"); ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the cell lines"); - EditableTexts.setStatus(App::Property::Hidden,true); + EditableTexts.setStatus(App::PropertyStatus::Hidden,true); } diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.cpp b/src/Mod/TechDraw/App/DrawViewSymbol.cpp index 3671a6c83ff9..7639005a6551 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawViewSymbol.cpp @@ -66,7 +66,7 @@ DrawViewSymbol::DrawViewSymbol(void) ADD_PROPERTY_TYPE(Symbol,(""),vgroup,App::Prop_None,"The SVG code defining this symbol"); ADD_PROPERTY_TYPE(EditableTexts,(""),vgroup,App::Prop_None,"Substitution values for the editable strings in this symbol"); ScaleType.setValue("Custom"); - Symbol.setStatus(App::Property::Hidden,true); + Symbol.setStatus(App::PropertyStatus::Hidden,true); } DrawViewSymbol::~DrawViewSymbol() diff --git a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp index 26ed21e04686..3502920050cd 100644 --- a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp @@ -53,16 +53,16 @@ DrawWeldSymbol::DrawWeldSymbol(void) { static const char *group = "Weld Symbol"; - ADD_PROPERTY_TYPE(Leader,(0),group,(App::PropertyType)(App::Prop_None), "Parent Leader"); + ADD_PROPERTY_TYPE(Leader,(0),group,App::Prop_None, "Parent Leader"); ADD_PROPERTY_TYPE(AllAround, (false), group, App::Prop_None, "All Around Symbol on/off"); ADD_PROPERTY_TYPE(FieldWeld, (false), group, App::Prop_None, "Field Weld Symbol on/off"); ADD_PROPERTY_TYPE(AlternatingWeld, (false), group, App::Prop_None, "Alternating Weld true/false"); ADD_PROPERTY_TYPE(TailText, (""), group, App::Prop_None, "Text at tail of symbol"); - Caption.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); - Rotation.setStatus(App::Property::Hidden, true); + Caption.setStatus(App::PropertyStatus::Hidden,true); + Scale.setStatus(App::PropertyStatus::Hidden,true); + ScaleType.setStatus(App::PropertyStatus::Hidden,true); + Rotation.setStatus(App::PropertyStatus::Hidden, true); } DrawWeldSymbol::~DrawWeldSymbol() diff --git a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp index 28450ce2664c..5d92b25f3980 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp @@ -71,13 +71,13 @@ ViewProviderBalloon::ViewProviderBalloon() ADD_PROPERTY_TYPE(Font, (Preferences::labelFont().c_str()), group, App::Prop_None, "The name of the font to use"); ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), - group, (App::PropertyType)(App::Prop_None), "Balloon text size in units"); + group, App::Prop_None, "Balloon text size in units"); int lgNumber = Preferences::lineGroup(); auto lg = TechDraw::LineGroup::lineGroupFactory(lgNumber); double weight = lg->getWeight("Thin"); delete lg; //Coverity CID 174670 - ADD_PROPERTY_TYPE(LineWidth, (weight), group, (App::PropertyType)(App::Prop_None), "Leader line width"); - ADD_PROPERTY_TYPE(LineVisible, (true), group, (App::PropertyType)(App::Prop_None), "Balloon line visible or hidden"); + ADD_PROPERTY_TYPE(LineWidth, (weight), group, App::Prop_None, "Leader line width"); + ADD_PROPERTY_TYPE(LineVisible, (true), group, App::Prop_None, "Balloon line visible or hidden"); ADD_PROPERTY_TYPE(Color, (PreferencesGui::dimColor()), group, App::Prop_None, "Color of the balloon"); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 4ab084793f07..324e72511de2 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -74,13 +74,10 @@ ViewProviderDimension::ViewProviderDimension() ADD_PROPERTY_TYPE(Font, (Preferences::labelFont().c_str()), group, App::Prop_None, "The name of the font to use"); - ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), - group, (App::PropertyType)(App::Prop_None), - "Dimension text size in units"); - ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, (App::PropertyType)(App::Prop_None), - "Dimension line width"); + ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), group,App::Prop_None, "Dimension text size in units"); + ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, App::Prop_None, "Dimension line width"); ADD_PROPERTY_TYPE(Color, (prefColor()), group, App::Prop_None, "Color of the dimension"); - ADD_PROPERTY_TYPE(StandardAndStyle, (prefStandardAndStyle()), group, App::Prop_None, + ADD_PROPERTY_TYPE(StandardAndStyle, (prefStandardAndStyle()), group, App::Prop_None, "Standard and style according to which dimension is drawn"); StandardAndStyle.setEnums(StandardAndStyleEnums); diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp index c43049cd1fe0..ddda7852cb88 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp @@ -70,7 +70,7 @@ ViewProviderDrawingView::ViewProviderDrawingView() // Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we // don't use coin. - DisplayMode.setStatus(App::Property::Hidden,true); + DisplayMode.setStatus(App::PropertyStatus::Hidden,true); m_docReady = true; } @@ -97,7 +97,7 @@ void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat) // TechDraw::DrawView* view = static_cast(pcFeat); // TechDraw::DrawPage* page = view->findParentPage(); // TechDraw::DrawPage* page = feature->findParentPage(); -// Base::Console().Message("VPDV::attach(%X) - parent: %X\n", +// Base::Console().Message("VPDV::attach(%X) - parent: %X\n", // pcFeat, page); // pcFeat->getNameInDocument(), page->getNameInDocument()); } @@ -267,7 +267,7 @@ Gui::MDIView *ViewProviderDrawingView::getMDIView() const return getMDIViewPage(); } -void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv) +void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv) { // Base::Console().Message("VPDV::onGuiRepaint(%s)\n", dv->getNameInDocument()); if (dv == getViewObject()) { diff --git a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp index 434e89a18937..1dab51a2ab44 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp @@ -84,9 +84,9 @@ ViewProviderLeader::ViewProviderLeader() static const char *group = "Line Format"; - ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()),group,(App::PropertyType)(App::Prop_None),"Line width"); + ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()),group,App::Prop_None,"Line width"); LineStyle.setEnums(LineStyleEnums); - ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Line style"); + ADD_PROPERTY_TYPE(LineStyle,(1),group,App::Prop_None,"Line style"); ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"Color of the Markup"); } @@ -180,7 +180,7 @@ std::vector ViewProviderLeader::claimChildren(void) const } } return temp; - } + } catch (...) { std::vector tmp; return tmp; @@ -249,7 +249,7 @@ bool ViewProviderLeader::onDelete(const std::vector &) if (!childs.empty()) { QString bodyMessage; - QTextStream bodyMessageStream(&bodyMessage); + QTextStream bodyMessageStream(&bodyMessage); bodyMessageStream << qApp->translate("Std_Delete", "You cannot delete this leader line because\nit has a weld symbol that would become broken."); QMessageBox::warning(Gui::getMainWindow(), diff --git a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp index 09263fa21632..2841ca171d02 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp @@ -95,9 +95,9 @@ ViewProviderPage::ViewProviderPage() ADD_PROPERTY_TYPE(ShowFrames ,(true),group,App::Prop_None,"NonGui! Show or hide View frames and Labels on this Page"); - ShowFrames.setStatus(App::Property::Hidden,true); - Visibility.setStatus(App::Property::Hidden,true); - DisplayMode.setStatus(App::Property::Hidden,true); + ShowFrames.setStatus(App::PropertyStatus::Hidden,true); + Visibility.setStatus(App::PropertyStatus::Hidden,true); + DisplayMode.setStatus(App::PropertyStatus::Hidden,true); } ViewProviderPage::~ViewProviderPage() diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp index 63e4ea828dff..df610cbb0fe0 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp @@ -79,9 +79,9 @@ ViewProviderRichAnno::ViewProviderRichAnno() static const char *group = "Frame Format"; - ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group,(App::PropertyType)(App::Prop_None), "Frame line width"); + ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group,App::Prop_None, "Frame line width"); LineStyle.setEnums(LineStyleEnums); - ADD_PROPERTY_TYPE(LineStyle, (1), group, (App::PropertyType)(App::Prop_None), "Frame line style"); + ADD_PROPERTY_TYPE(LineStyle, (1), group, App::Prop_None, "Frame line style"); ADD_PROPERTY_TYPE(LineColor, (getDefLineColor()), group, App::Prop_None, "The color of the frame"); } @@ -134,14 +134,14 @@ void ViewProviderRichAnno::updateData(const App::Property* p) // only if there is a frame we can enable the frame line parameters if (getViewObject() != nullptr) { if (getViewObject()->ShowFrame.getValue()) { - LineWidth.setStatus(App::Property::ReadOnly, false); - LineStyle.setStatus(App::Property::ReadOnly, false); - LineColor.setStatus(App::Property::ReadOnly, false); + LineWidth.setStatus(App::PropertyStatus::ReadOnly, false); + LineStyle.setStatus(App::PropertyStatus::ReadOnly, false); + LineColor.setStatus(App::PropertyStatus::ReadOnly, false); } else { - LineWidth.setStatus(App::Property::ReadOnly, true); - LineStyle.setStatus(App::Property::ReadOnly, true); - LineColor.setStatus(App::Property::ReadOnly, true); + LineWidth.setStatus(App::PropertyStatus::ReadOnly, true); + LineStyle.setStatus(App::PropertyStatus::ReadOnly, true); + LineColor.setStatus(App::PropertyStatus::ReadOnly, true); } } ViewProviderDrawingView::updateData(p); diff --git a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp index db7abe0bbb59..ee2dde928d05 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp @@ -68,7 +68,7 @@ ViewProviderTemplate::ViewProviderTemplate() { sPixmap = "TechDraw_Tree_PageTemplate"; - DisplayMode.setStatus(App::Property::Hidden,true); + DisplayMode.setStatus(App::PropertyStatus::Hidden,true); } ViewProviderTemplate::~ViewProviderTemplate() @@ -124,7 +124,7 @@ void ViewProviderTemplate::onChanged(const App::Property *prop) hide(); } } - + Gui::ViewProviderDocumentObject::onChanged(prop); } @@ -144,7 +144,7 @@ void ViewProviderTemplate::hide(void) if (qTemplate != nullptr) { qTemplate->hide(); } - + ViewProviderDocumentObject::hide(); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp index cc8f1f4ae5a6..cc8b1e5a35ba 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp @@ -50,7 +50,7 @@ ViewProviderViewClip::ViewProviderViewClip() // Do not show in property editor //DisplayMode.StatusBits.set(3, true); - DisplayMode.setStatus(App::Property::ReadOnly,true); + DisplayMode.setStatus(App::PropertyStatus::ReadOnly,true); } ViewProviderViewClip::~ViewProviderViewClip() diff --git a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp index 89baae927454..0c2d725e6150 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp @@ -64,9 +64,9 @@ ViewProviderWeld::ViewProviderWeld() ADD_PROPERTY_TYPE(Font, (prefFontName().c_str()),group,App::Prop_None, "The name of the font to use"); ADD_PROPERTY_TYPE(FontSize, (prefFontSize()), group, - (App::PropertyType)(App::Prop_None),"Tail text size"); + App::Prop_None,"Tail text size"); ADD_PROPERTY_TYPE(TileFontSize, (prefFontSize() * prefTileTextAdjust()), group, - (App::PropertyType)(App::Prop_None),"Text size on individual symbol tiles"); + App::Prop_None,"Text size on individual symbol tiles"); } ViewProviderWeld::~ViewProviderWeld() diff --git a/src/Mod/Test/Document.py b/src/Mod/Test/Document.py index e41375cb4f5a..e4017b25f627 100644 --- a/src/Mod/Test/Document.py +++ b/src/Mod/Test/Document.py @@ -1794,6 +1794,14 @@ def testObject(self): self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) + #Test two signals for a change in ReadOnly and in Hidden Status + pyobj.setEditorMode('Prop', [ 'Hidden']) + for i in range(2): + self.failUnless(self.Obs.signal.pop() == 'ObjChangePropEdit') + self.failUnless(self.Obs.parameter.pop() is pyobj) + self.failUnless(self.Obs.parameter2.pop() == 'Prop') + self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) + pyobj.removeProperty('Prop') self.failUnless(self.Obs.signal.pop() == 'ObjRemoveDynProp') self.failUnless(self.Obs.parameter.pop() is pyobj)