diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 51059658c3..e5cb6029fa 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -802,9 +802,9 @@ std::vector Application::openDocuments(const std::vector return res; } -Document* Application::openDocumentPrivate(const char * FileName, +Document* Application::openDocumentPrivate(const char * FileName, const char *propFileName, const char *label, - bool isMainDoc, bool createView, + bool isMainDoc, bool createView, const std::set &objNames) { FileInfo File(FileName); @@ -831,12 +831,12 @@ Document* Application::openDocumentPrivate(const char * FileName, } continue; } - if(it->second->testStatus(App::Document::PartialDoc) + if(it->second->testStatus(App::Document::PartialDoc) || it->second->testStatus(App::Document::PartialRestore)) { // Here means a document is already partially loaded, but the document - // is requested again, either partial or not. We must check if the + // is requested again, either partial or not. We must check if the // document contains the required object - + if(isMainDoc) { // Main document must be open fully, so close and reopen closeDocument(it->first.c_str()); @@ -1039,7 +1039,7 @@ std::string Application::getHelpDir() int Application::checkLinkDepth(int depth, bool no_throw) { if(_objCount<0) { _objCount = 0; - for(auto &v : DocMap) + for(auto &v : DocMap) _objCount += v.second->countObjects(); } if(depth > _objCount+2) { @@ -2127,7 +2127,7 @@ void Application::initApplication(void) catch (const Base::Exception& e) { e.ReportException(); } - + // seed randomizer srand(time(0)); } diff --git a/src/App/Application.h b/src/App/Application.h index 2d0fa041a7..f03dc97f99 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -72,7 +72,7 @@ class AppExport Application public: //--------------------------------------------------------------------- - // exported functions goes here +++++++++++++++++++++++++++++++++++++++ + // exported functions go here +++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------- /** @name methods for document handling */ @@ -111,7 +111,7 @@ public: * * This function will also open any external referenced files. */ - std::vector openDocuments(const std::vector &filenames, + std::vector openDocuments(const std::vector &filenames, const std::vector *paths=0, const std::vector *labels=0, std::vector *errs=0, @@ -136,7 +136,7 @@ public: /// Indicate the application is closing all document bool isClosingAll() const; //@} - + /** @name Application-wide trandaction setting */ //@{ /** Setup a pending application-wide active transaction @@ -263,9 +263,9 @@ public: /// signal on about changing the editor mode of a property boost::signals2::signal signalChangePropertyEditor; //@} - + /** @name Signals of extension changes - * These signals are emitted on dynamic extension addition. Dynamic extensions are the ones added by python (c++ ones are part + * These signals are emitted on dynamic extension addition. Dynamic extensions are the ones added by python (c++ ones are part * of the class definition, hence not dynamic) * The extension in question is provided as parameter. */ @@ -382,7 +382,7 @@ public: /** @name Link handling */ //@{ - + /** Check for link recursion depth * * @param depth: current depth @@ -513,7 +513,7 @@ private: static PyObject *sGetActiveTransaction (PyObject *self,PyObject *args); static PyObject *sCloseActiveTransaction(PyObject *self,PyObject *args); static PyObject *sCheckAbort(PyObject *self,PyObject *args); - static PyMethodDef Methods[]; + static PyMethodDef Methods[]; friend class ApplicationObserver; @@ -526,7 +526,7 @@ private: static Application *_pcSingleton; /// argument helper function static void ParseOptions(int argc, char ** argv); - /// checks if the environment is allreight + /// checks if the environment is alright //static void CheckEnv(void); /// Search for the FreeCAD home path based on argv[0] /*! diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index 0aa2c16b78..2336398bfb 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -174,9 +174,9 @@ PyMethodDef Application::Methods[] = { "active transaction causes any document changes to open a transaction with\n" "the given name and ID."}, {"getActiveTransaction", (PyCFunction) Application::sGetActiveTransaction, METH_VARARGS, - "getActiveTransaction() -> (name,id) return the current active transaction name and ID"}, + "getActiveTransaction() -> (name,id) return the current active transaction name and ID"}, {"closeActiveTransaction", (PyCFunction) Application::sCloseActiveTransaction, METH_VARARGS, - "closeActiveTransaction(abort=False) -- commit or abort current active transaction"}, + "closeActiveTransaction(abort=False) -- commit or abort current active transaction"}, {"isRestoring", (PyCFunction) Application::sIsRestoring, METH_VARARGS, "isRestoring() -> Bool -- Test if the application is opening some document"}, {"checkAbort", (PyCFunction) Application::sCheckAbort, METH_VARARGS, @@ -877,7 +877,7 @@ PyObject *Application::sGetLinksTo(PyObject * /*self*/, PyObject *args) auto links = GetApplication().getLinksTo(obj,options,count); Py::Tuple ret(links.size()); int i=0; - for(auto o : links) + for(auto o : links) ret.setItem(i++,Py::Object(o->getPyObject(),true)); return Py::new_reference_to(ret); }PY_CATCH; @@ -901,7 +901,7 @@ PyObject *Application::sGetDependentObjects(PyObject * /*self*/, PyObject *args) objs.push_back(static_cast(seq[i].ptr())->getDocumentObjectPtr()); } }else if(!PyObject_TypeCheck(obj,&DocumentObjectPy::Type)) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "Expect first argument to be either a document object or sequence of document objects"); return 0; }else @@ -911,7 +911,7 @@ PyObject *Application::sGetDependentObjects(PyObject * /*self*/, PyObject *args) auto ret = App::Document::getDependencyList(objs,options); Py::Tuple tuple(ret.size()); - for(size_t i=0;igetPyObject(),true)); return Py::new_reference_to(tuple); } PY_CATCH; @@ -924,7 +924,7 @@ PyObject *Application::sSetActiveTransaction(PyObject * /*self*/, PyObject *args PyObject *persist = Py_False; if (!PyArg_ParseTuple(args, "s|O", &name,&persist)) return 0; - + PY_TRY { Py::Int ret(GetApplication().setActiveTransaction(name,PyObject_IsTrue(persist))); return Py::new_reference_to(ret); @@ -935,7 +935,7 @@ PyObject *Application::sGetActiveTransaction(PyObject * /*self*/, PyObject *args { if (!PyArg_ParseTuple(args, "")) return 0; - + PY_TRY { int id = 0; const char *name = GetApplication().getActiveTransaction(&id); @@ -954,7 +954,7 @@ PyObject *Application::sCloseActiveTransaction(PyObject * /*self*/, PyObject *ar int id = 0; if (!PyArg_ParseTuple(args, "|Oi", &abort,&id)) return 0; - + PY_TRY { GetApplication().closeActiveTransaction(PyObject_IsTrue(abort),id); Py_Return; diff --git a/src/App/AutoTransaction.cpp b/src/App/AutoTransaction.cpp index 6094ef2070..08fe11a69f 100644 --- a/src/App/AutoTransaction.cpp +++ b/src/App/AutoTransaction.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2019 Zheng, Lei (realthunder) * + * Copyright (c) 2019 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -50,7 +50,7 @@ AutoTransaction::AutoTransaction(const char *name, bool tmpName) { // We use negative transaction guard to disable auto transaction from here // and any stack below. This is to support user setting active transaction // before having any existing AutoTransaction on stack, or 'persist' - // transaction that can out live AutoTransaction. + // transaction that can out live AutoTransaction. if(app._activeTransactionGuard<0) --app._activeTransactionGuard; else if(tid || app._activeTransactionGuard>0) diff --git a/src/App/AutoTransaction.h b/src/App/AutoTransaction.h index e792b41b89..6f75d752b3 100644 --- a/src/App/AutoTransaction.h +++ b/src/App/AutoTransaction.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2019 Zheng, Lei (realthunder) * + * Copyright (c) 2019 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -70,10 +70,10 @@ public: * * Once disabled, any empty temporary named transaction is closed. If there * are non-empty or non-temporary named active transaction, it will not be - * auto closed. + * auto closed. * * This function may be used in, for example, Gui::Document::setEdit() to - * allow a transaction live past any command scope. + * allow a transaction live past any command scope. */ static void setEnable(bool enable); diff --git a/src/App/ColorModel.h b/src/App/ColorModel.h index 535047c7d2..af381d5516 100644 --- a/src/App/ColorModel.h +++ b/src/App/ColorModel.h @@ -197,7 +197,7 @@ public: ColorField (void); ColorField (const ColorField &rclCF); ColorField (const ColorModel &rclModel, float fMin, float fMax, unsigned short usCt); - virtual ~ColorField (); + virtual ~ColorField (); ColorField& operator = (const ColorField &rclCF); @@ -212,7 +212,7 @@ public: void setDirect (unsigned short usInd, Color clCol) { _aclField[usInd] = clCol; } float getMinValue (void) const { return _fMin; } float getMaxValue (void) const { return _fMax; } - + Color getColor (unsigned short usIndex) const { return _aclField[usIndex]; } inline Color getColor (float fVal) const; inline unsigned short getColorIndex (float fVal) const; @@ -281,7 +281,7 @@ public: ColorGradient& operator = (const ColorGradient &rclCR); - void set (float fMin, float fMax, unsigned short usCt, TStyle tS, bool bOG); + void set (float fMin, float fMax, unsigned short usCt, TStyle tS, bool bOG); void setRange (float fMin, float fMax) { set(fMin, fMax, _usCtColors, _tStyle, _bOutsideGrayed); } void getRange (float &rfMin, float &rfMax) const { rfMin = _fMin; rfMax = _fMax; } unsigned short getCountColors (void) const { return _usCtColors; } @@ -305,9 +305,9 @@ protected: TColorModel _tColorModel; TStyle _tStyle; float _fMin, _fMax; - unsigned short _usCtColors; + unsigned short _usCtColors; bool _bOutsideGrayed; - ColorModel _clTotal, _clTop, _clBottom; + ColorModel _clTotal, _clTop, _clBottom; void rebuild (void); void setColorModel (void); @@ -330,7 +330,7 @@ public: bool addMax (const std::string &rclName); bool remove (unsigned long ulPos); void removeFirst (void); - void removeLast (void); + void removeLast (void); Color getColor (unsigned long ulPos) const; uint32_t getPackedColor (unsigned long ulPos) const; @@ -426,10 +426,10 @@ inline Color ColorGradient::getColor (float fVal) const else return _clColFld2.getColor(fVal); } - else + else return _clColFld1.getColor(fVal); } - + default: case FLOW: { @@ -451,10 +451,10 @@ inline unsigned short ColorGradient::getColorIndex (float fVal) const else return (unsigned short)(_clColFld1.getCountColors() + _clColFld2.getColorIndex(fVal)); } - else + else return _clColFld1.getColorIndex(fVal); } - + default: case FLOW: { @@ -464,7 +464,7 @@ inline unsigned short ColorGradient::getColorIndex (float fVal) const } inline const ColorModel& ColorGradient::getColorModel (void) const -{ +{ if ( _tStyle == ZERO_BASED ) { if ( _fMax <= 0.0f ) @@ -482,4 +482,4 @@ inline const ColorModel& ColorGradient::getColorModel (void) const } // namespace App -#endif // APP_COLORMODEL_H +#endif // APP_COLORMODEL_H diff --git a/src/App/ComplexGeoData.h b/src/App/ComplexGeoData.h index 479fd0a572..6244096900 100644 --- a/src/App/ComplexGeoData.h +++ b/src/App/ComplexGeoData.h @@ -58,7 +58,7 @@ public: class AppExport ComplexGeoData: public Base::Persistence, public Base::Handled { TYPESYSTEM_HEADER(); - + public: struct Line {uint32_t I1; uint32_t I2;}; struct Facet {uint32_t I1; uint32_t I2; uint32_t I3;}; @@ -109,11 +109,11 @@ public: * using the setTransform() method. */ void setPlacement(const Base::Placement& rclPlacement); - /** Return the current transformation as placement using + /** Return the current transformation as placement using * getTransform(). */ Base::Placement getPlacement() const; - /** Override the current transformation with the new one. + /** Override the current transformation with the new one. * This method has to be handled by the child classes. * the actual placement and matrix is not part of this class. */ @@ -201,7 +201,7 @@ protected: /// from local to inside inline Base::Vector3f transformToInside(const Base::Vector3d& vec) const { - Base::Matrix4D tmpM(getTransform()); + Base::Matrix4D tmpM(getTransform()); tmpM.inverse(); Base::Vector3d tmp = tmpM * vec; return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z); diff --git a/src/App/ComplexGeoDataPyImp.cpp b/src/App/ComplexGeoDataPyImp.cpp index 79de406cc5..a89e02b29d 100644 --- a/src/App/ComplexGeoDataPyImp.cpp +++ b/src/App/ComplexGeoDataPyImp.cpp @@ -141,5 +141,5 @@ PyObject *ComplexGeoDataPy::getCustomAttributes(const char* /*attr*/) const int ComplexGeoDataPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { - return 0; + return 0; } diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 69988cb034..e985aa1b47 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -26,7 +26,7 @@ \ingroup APP \brief The Base class of the FreeCAD Document -This is (besides the App::Application class) the most important class in FreeCAD. +This (besides the App::Application class) is the most important class in FreeCAD. It contains all the data of the opened, saved, or newly created FreeCAD Document. The App::Document manages the Undo and Redo mechanism and the linking of documents. @@ -189,7 +189,7 @@ struct DocumentP std::map VertexObjectList; std::map vertexMap; #endif //USE_OLD_DAG - std::multimap > _RecomputeLog; DocumentP() { @@ -199,7 +199,7 @@ struct DocumentP // Set some random offset to reduce likelihood of ID collision when // copying shape from other document. It is probably better to randomize // on each object ID. - lastObjectId = _RDIST(_RGEN); + lastObjectId = _RDIST(_RGEN); activeObject = 0; activeUndoTransaction = 0; iTransactionMode = 0; @@ -1047,7 +1047,7 @@ bool Document::redo(int id) void Document::addOrRemovePropertyOfObject(TransactionalObject* obj, Property *prop, bool add) { - if (!prop || !obj || !obj->isAttachedToDocument()) + if (!prop || !obj || !obj->isAttachedToDocument()) return; if(d->iUndoMode && !isPerformingTransaction() && !d->activeUndoTransaction) { if(!testStatus(Restoring) || testStatus(Importing)) { @@ -1128,9 +1128,9 @@ int Document::_openTransaction(const char* name, int id) auto &app = GetApplication(); auto activeDoc = app.getActiveDocument(); - if(activeDoc && - activeDoc!=this && - !activeDoc->hasPendingTransaction()) + if(activeDoc && + activeDoc!=this && + !activeDoc->hasPendingTransaction()) { std::string aname("-> "); aname += d->activeUndoTransaction->Name; @@ -1165,11 +1165,11 @@ void Document::_checkTransaction(DocumentObject* pcDelObj, const Property *What, if(What && What->testStatus(Property::NoModify)) ignore = true; if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) { - if(What) - FC_LOG((ignore?"ignore":"auto") << " transaction (" - << line << ") '" << What->getFullName()); + if(What) + FC_LOG((ignore?"ignore":"auto") << " transaction (" + << line << ") '" << What->getFullName()); else - FC_LOG((ignore?"ignore":"auto") <<" transaction (" + FC_LOG((ignore?"ignore":"auto") <<" transaction (" << line << ") '" << name << "' in " << getName()); } if(!ignore) @@ -1254,7 +1254,7 @@ void Document::abortTransaction() { FC_WARN("Cannot abort transaction while transacting"); return; } - if (d->activeUndoTransaction) + if (d->activeUndoTransaction) GetApplication().closeActiveTransaction(true,d->activeUndoTransaction->getID()); } @@ -1620,7 +1620,7 @@ Document::Document(const char *name) 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(ShowHidden,(false), 0,PropertyType(Prop_None), "Whether to show hidden object items in the tree view"); // this creates and sets 'TransientDir' in onChanged() @@ -1883,7 +1883,7 @@ void Document::writeObjects(const std::vector& obj, for(auto o : obj) { const auto &outList = o->getOutList(DocumentObject::OutListNoHidden | DocumentObject::OutListNoXLinked); - writer.Stream() << writer.ind() + writer.Stream() << writer.ind() << "<" FC_ELEMENT_OBJECT_DEPS " " FC_ATTR_DEP_OBJ_NAME "=\"" << o->getNameInDocument() << "\" " FC_ATTR_DEP_COUNT "=\"" << outList.size(); if(outList.empty()) { @@ -1923,7 +1923,7 @@ void Document::writeObjects(const std::vector& obj, if ((*it)->testStatus(ObjectStatus::Error)) { writer.Stream() << "Invalid=\"1\" "; auto desc = getErrorDescription(*it); - if(desc) + if(desc) writer.Stream() << "Error=\"" << Property::encodeAttribute(desc) << "\" "; } writer.Stream() << "/>" << endl; @@ -1956,9 +1956,9 @@ struct DepInfo { int canLoadPartial = 0; }; -static void _loadDeps(const std::string &name, - std::unordered_map &objs, - const std::unordered_map &deps) +static void _loadDeps(const std::string &name, + std::unordered_map &objs, + const std::unordered_map &deps) { auto it = deps.find(name); if(it == deps.end()) { @@ -2098,7 +2098,7 @@ Document::readObjects(Base::XMLReader& reader) } if (reader.hasAttribute("Invalid")) { obj->setStatus(ObjectStatus::Error, reader.getAttributeAsInteger("Invalid") != 0); - if(obj->isError() && reader.hasAttribute("Error")) + if(obj->isError() && reader.hasAttribute("Error")) d->addRecomputeLog(reader.getAttribute("Error"),obj); } } @@ -2777,7 +2777,7 @@ void Document::afterRestore(bool checkPartial) { setStatus(Document::Restoring, false); } -bool Document::afterRestore(const std::vector &objArray, bool checkPartial) +bool Document::afterRestore(const std::vector &objArray, bool checkPartial) { checkPartial = checkPartial && testStatus(Document::PartialDoc); if(checkPartial && d->touchedObjs.size()) @@ -2797,7 +2797,7 @@ bool Document::afterRestore(const std::vector &objArray, bool try { prop->afterRestore(); } catch (const Base::Exception& e) { - FC_ERR("Failed to restore " << obj->getFullName() + FC_ERR("Failed to restore " << obj->getFullName() << '.' << prop->getName() << ": " << e.what()); } } @@ -2864,7 +2864,7 @@ bool Document::afterRestore(const std::vector &objArray, bool if(checkPartial && d->touchedObjs.size()) { // partial document touched, signal full reload return false; - } else if(!d->touchedObjs.count(obj)) + } else if(!d->touchedObjs.count(obj)) obj->purgeTouched(); signalFinishRestoreObject(*obj); @@ -2955,9 +2955,9 @@ int Document::countObjects(void) const return static_cast(d->objectArray.size()); } -void Document::getLinksTo(std::set &links, +void Document::getLinksTo(std::set &links, const DocumentObject *obj, int options, int maxCount, - const std::vector &objs) const + const std::vector &objs) const { std::map > linkMap; @@ -2968,7 +2968,7 @@ void Document::getLinksTo(std::set &links, linked = o->getLinkedObject(false); else { auto ext = o->getExtensionByType(true); - if(ext) + if(ext) linked = ext->getTrueLinkedObject(false,0,0,true); else linked = o->getLinkedObject(false); @@ -3052,8 +3052,8 @@ std::vector Document::getInList(const DocumentObject* me) // external object. // static void _buildDependencyList(const std::vector &objectArray, - int options, std::vector *depObjs, - DependencyList *depList, std::map *objectMap, + int options, std::vector *depObjs, + DependencyList *depList, std::map *objectMap, bool *touchCheck = 0) { std::map > outLists; @@ -3132,7 +3132,7 @@ std::vector Document::getDependencyList( std::map > components; boost::strong_components(depList,boost::make_iterator_property_map( c.begin(),boost::get(boost::vertex_index,depList),c[0])); - for(size_t i=0;i Document::getDependentDocuments(bool sort) { } std::vector Document::getDependentDocuments( - std::vector pending, bool sort) + std::vector pending, bool sort) { DependencyList depList; std::map docMap; @@ -3409,7 +3409,7 @@ int Document::recompute(const std::vector &objs, bool forc #else //ifdef USE_OLD_DAG -int Document::recompute(const std::vector &objs, bool force, bool *hasError, int options) +int Document::recompute(const std::vector &objs, bool force, bool *hasError, int options) { if (d->undoing || d->rollback) { if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) @@ -3419,7 +3419,7 @@ int Document::recompute(const std::vector &objs, bool forc int objectCount = 0; if (testStatus(Document::PartialDoc)) { - if(mustExecute()) + if(mustExecute()) FC_WARN("Please reload partial document '" << Label.getValue() << "' for recomputation."); return 0; } @@ -3445,7 +3445,7 @@ int Document::recompute(const std::vector &objs, bool forc #if 0 ////////////////////////////////////////////////////////////////////////// - // FIXME Comment by Realthunder: + // FIXME Comment by Realthunder: // the topologicalSrot() below cannot handle partial recompute, haven't got // time to figure out the code yet, simply use back boost::topological_sort // for now, that is, rely on getDependencyList() to do the sorting. The @@ -3515,12 +3515,12 @@ int Document::recompute(const std::vector &objs, bool forc inObjIt->enforceRecompute(); } } - // check if all objects are recomputed but still thouched + // check if all objects are recomputed but still thouched for (size_t i=0;isetStatus(ObjectStatus::Recompute2,false); if(!filter.count(obj) && obj->isTouched()) { - if(passes>0) + if(passes>0) FC_ERR(obj->getFullName() << " still touched after recompute"); else{ FC_LOG(obj->getFullName() << " still touched after recompute"); @@ -3808,7 +3808,7 @@ bool Document::recomputeFeature(DocumentObject* Feat, bool recursive) return false; } -DocumentObject * Document::addObject(const char* sType, const char* pObjectName, +DocumentObject * Document::addObject(const char* sType, const char* pObjectName, bool isNew, const char* viewType, bool isPartial) { Base::BaseClass* base = static_cast(Base::Type::createInstanceByName(sType,true)); @@ -4331,7 +4331,7 @@ std::vector Document::copyObject( return result; } -std::vector +std::vector Document::importLinks(const std::vector &objArray) { std::set links; @@ -4395,7 +4395,7 @@ Document::importLinks(const std::vector &objArray) // properties, e.g. a link sub referring to some sub object of an xlink, If // that sub object is imported with a different name, and xlink is changed // before this link sub, it will break. - for(auto &v : propMap) + for(auto &v : propMap) v.first->Paste(*v.second); return objs; @@ -4422,13 +4422,13 @@ DocumentObject* Document::moveObject(DocumentObject* obj, bool recursive) } std::vector deps; - if(recursive) + if(recursive) deps = getDependencyList({obj},DepNoXLinked|DepSort); else deps.push_back(obj); auto objs = copyObject(deps,false); - if(objs.empty()) + if(objs.empty()) return 0; // Some object may delete its children if deleted, so we collect the IDs // or all depending objects for safety reason. diff --git a/src/App/Document.h b/src/App/Document.h index 4b5e727c4a..33084d221f 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -193,7 +193,7 @@ public: bool saveAs(const char* file); bool saveCopy(const char* file) const; /// Restore the document from the file in Property Path - void restore (const char *filename=0, + void restore (const char *filename=0, bool delaySignal=false, const std::set &objNames={}); void afterRestore(bool checkPartial=false); bool afterRestore(const std::vector &, bool checkPartial=false); @@ -209,7 +209,7 @@ public: * * @param objs: input list of objects. Only objects belonging to this document will * be checked for external links. And all found external linked object will be imported - * to this document. Link type properties of those input objects will be automatically + * to this document. Link type properties of those input objects will be automatically * reassigned to the imported objects. Note that the link properties of other objects * in the document but not included in the input list, will not be affected even if they * point to some object beining imported. To import all objects, simply pass in all objects @@ -228,7 +228,7 @@ public: /// Get program version the project file was created with const char* getProgramVersion() const; /** Returned filename - * + * * For saved document, this will be the content stored in property * 'Filename'. For unsaved temporary file, this will be the content of * property 'TransientDir'. @@ -252,7 +252,7 @@ public: * @param viewType override object's view provider name * @param isPartial indicate if this object is meant to be partially loaded */ - DocumentObject *addObject(const char* sType, const char* pObjectName=0, + DocumentObject *addObject(const char* sType, const char* pObjectName=0, bool isNew=true, const char *viewType=0, bool isPartial=false); /** Add an array of features of the given types and names. * Unicode names are set through the Label property. @@ -356,7 +356,7 @@ public: //@} - /** @name methods for the UNDO REDO and Transaction handling + /** @name methods for the UNDO REDO and Transaction handling * * Introduce a new concept of transaction ID. Each transaction must be * unique inside the document. Multiple transactions from different @@ -447,13 +447,13 @@ public: /// Raise exception on cycles DepNoCycle = 4, }; - /** Get a complete list of all objects the given objects depend on. + /** Get a complete list of all objects the given objects depend on. * * This function is defined as static because it accepts objects from * different documents, and the returned list will contain dependent * objects from all relevant documents * - * @param objs: input objects to query for dependency. + * @param objs: input objects to query for dependency. * @param options: See DependencyOption */ static std::vector getDependencyList( @@ -482,7 +482,7 @@ public: * @param objs: optional objects to search for, if empty, then all objects * of this document are searched. */ - void getLinksTo(std::set &links, + void getLinksTo(std::set &links, const DocumentObject *obj, int options, int maxCount=0, const std::vector &objs = {}) const; diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 8b599356e7..b30a9d70a3 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -183,14 +183,14 @@ public: */ //@{ /** Set sub-element visibility - * + * * For performance reason, \c element must not contain any further * sub-elements, i.e. there should be no '.' inside \c element. * * @return -1 if element visibility is not supported, 0 if element is not * found, 1 if success */ - virtual int setElementVisible(const char *element, bool visible); + virtual int setElementVisible(const char *element, bool visible); /** Get sub-element visibility * @@ -246,7 +246,7 @@ public: * @param inList [in, out]: optional pointer to a vector holding the output * objects, with the furthest linking object ordered last. */ - void getInListEx(std::set &inSet, + void getInListEx(std::set &inSet, bool recursive, std::vector *inList=0) const; /** Return a set of all objects linking to this object, including possible external parent objects * @param recursive [in]: whether to obtain recursive in list @@ -334,10 +334,10 @@ public: * include the transformation applied by the final object reference in \c * subname. For Part::Feature, the transformation is applied to the * TopoShape inside \c pyObj before returning. - * + * * @param transform: if false, then it will not apply the object's own * transformation to \c mat, which lets you override the object's placement - * (and possibly scale). + * (and possibly scale). * * @param depth: depth limitation as hint for cyclic link detection * @@ -345,7 +345,7 @@ public: * then it shall return itself. If subname is invalid, then it shall return * zero. */ - virtual DocumentObject *getSubObject(const char *subname, PyObject **pyObj=0, + virtual DocumentObject *getSubObject(const char *subname, PyObject **pyObj=0, Base::Matrix4D *mat=0, bool transform=true, int depth=0) const; /// Return a list of objects referenced by a given subname including this object @@ -380,13 +380,13 @@ public: std::vector > getParents(int depth=0) const; /** Return the linked object with optional transformation - * + * * @param recurse: If false, return the immediate linked object, or else * recursively call this function to return the final linked object. * * @param mat: If non zero, it is used as the current transformation matrix * on input. And output as the accumulated transformation till the final - * linked object. + * linked object. * * @param transform: if false, then it will not accumulate the object's own * placement into \c mat, which lets you override the object's placement. @@ -394,7 +394,7 @@ public: * @return Return the linked object. This function must return itself if the * it is not a link or the link is invalid. */ - virtual DocumentObject *getLinkedObject(bool recurse=true, + virtual DocumentObject *getLinkedObject(bool recurse=true, Base::Matrix4D *mat=0, bool transform=false, int depth=0) const; /* Return true to cause PropertyView to show linked object's property */ @@ -441,10 +441,10 @@ public: short attr=0, bool ro=false, bool hidden=false) override; /** Resolve the last document object referenced in the subname - * + * * @param subname: dot separated subname * @param parent: return the direct parent of the object - * @param childName: return child name to be passed to is/setElementVisible() + * @param childName: return child name to be passed to is/setElementVisible() * @param subElement: return non-object sub-element name if found. The * pointer is guaranteed to be within the buffer pointed to by 'subname' * @@ -452,7 +452,7 @@ public: * @return Returns the last referenced document object in the subname. If no * such object in subname, return pObject. */ - App::DocumentObject *resolve(const char *subname, App::DocumentObject **parent=0, + App::DocumentObject *resolve(const char *subname, App::DocumentObject **parent=0, std::string *childName=0, const char **subElement=0, PyObject **pyObj=0, Base::Matrix4D *mat=0, bool transform=true, int depth=0) const; @@ -500,7 +500,7 @@ public: * * The common parent 'Group' is removed. */ - App::DocumentObject *resolveRelativeLink(std::string &subname, + App::DocumentObject *resolveRelativeLink(std::string &subname, App::DocumentObject *&link, std::string &linkSub) const; /** Called to adjust link properties to avoid cyclic links @@ -533,7 +533,7 @@ public: /** Allow object to redirect a subname path * * @param ss: input as the current subname path from \a topParent leading - * just before this object, i.e. ends at the parent of this object. This + * just before this object, i.e. ends at the parent of this object. This * function should append its own name to this path, or redirect the * subname to other place. * @param topParent: top parent of this subname path @@ -541,7 +541,7 @@ public: * * This function is called by tree view to generate a subname path when an * item is selected in the tree. Document object can use this function to - * redirect the selection to some other objects. + * redirect the selection to some other objects. */ virtual bool redirectSubName(std::ostringstream &ss, DocumentObject *topParent, DocumentObject *child) const; @@ -628,7 +628,7 @@ private: // unique identifier (among a document) of this object. long _Id; - + private: // Back pointer to all the fathers in a DAG of the document // this is used by the document (via friend) to have a effective DAG handling diff --git a/src/App/DocumentObjectExtension.cpp b/src/App/DocumentObjectExtension.cpp index d1f6e10b0e..7af443a575 100644 --- a/src/App/DocumentObjectExtension.cpp +++ b/src/App/DocumentObjectExtension.cpp @@ -35,7 +35,7 @@ using namespace App; EXTENSION_PROPERTY_SOURCE(App::DocumentObjectExtension, App::Extension) -DocumentObjectExtension::DocumentObjectExtension() +DocumentObjectExtension::DocumentObjectExtension() { initExtensionType(App::DocumentObjectExtension::getExtensionClassTypeId()); } @@ -46,7 +46,7 @@ DocumentObjectExtension::~DocumentObjectExtension() } short int DocumentObjectExtension::extensionMustExecute(void) { - + return 0; } @@ -64,15 +64,15 @@ void DocumentObjectExtension::onExtendedDocumentRestored() { } void DocumentObjectExtension::onExtendedSetupObject() { - + } void DocumentObjectExtension::onExtendedUnsetupObject() { - + } PyObject* DocumentObjectExtension::getExtensionPyObject(void) { - + if (ExtensionPythonObject.is(Py::_None())){ // ref counter is set to 1 ExtensionPythonObject = Py::Object(new DocumentObjectExtensionPy(this),true); @@ -82,17 +82,17 @@ PyObject* DocumentObjectExtension::getExtensionPyObject(void) { const DocumentObject* DocumentObjectExtension::getExtendedObject() const { - assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId())); + assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId())); return static_cast(getExtendedContainer()); } DocumentObject* DocumentObjectExtension::getExtendedObject() { - assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId())); + assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId())); return static_cast(getExtendedContainer()); } -bool DocumentObjectExtension::extensionGetSubObject(DocumentObject *&, +bool DocumentObjectExtension::extensionGetSubObject(DocumentObject *&, const char *, PyObject **, Base::Matrix4D *, bool, int) const { return false; diff --git a/src/App/DocumentObjectExtension.h b/src/App/DocumentObjectExtension.h index cb7c8297ec..66b2d5af96 100644 --- a/src/App/DocumentObjectExtension.h +++ b/src/App/DocumentObjectExtension.h @@ -28,10 +28,10 @@ #include "DocumentObject.h" namespace App { - + /** * @brief Extension with special document object calls - * + * */ class AppExport DocumentObjectExtension : public App::Extension { @@ -47,12 +47,12 @@ public: App::DocumentObject* getExtendedObject(); const App::DocumentObject* getExtendedObject() const; - + //override if execution is necessary virtual short extensionMustExecute(void); virtual App::DocumentObjectExecReturn *extensionExecute(void); - - + + /// get called after setting the document virtual void onExtendedSettingDocument(); /// get called after a document has been fully restored @@ -63,8 +63,8 @@ public: virtual void onExtendedUnsetupObject(); virtual PyObject* getExtensionPyObject(void) override; - - /// returns the type name of the ViewProviderExtension which is automatically attached + + /// returns the type name of the ViewProviderExtension which is automatically attached /// to the viewprovider object when it is initiated virtual const char* getViewProviderExtensionName(void) const {return "";} @@ -73,7 +73,7 @@ public: * * @return Return turn if handled, the sub object is returned in \c ret */ - virtual bool extensionGetSubObject( DocumentObject *&ret, const char *subname, + virtual bool extensionGetSubObject( DocumentObject *&ret, const char *subname, PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const; /** Get name references of all sub objects diff --git a/src/App/DocumentObjectFileIncluded.cpp b/src/App/DocumentObjectFileIncluded.cpp index cba1508e8b..a7e0516141 100644 --- a/src/App/DocumentObjectFileIncluded.cpp +++ b/src/App/DocumentObjectFileIncluded.cpp @@ -34,7 +34,7 @@ using namespace App; PROPERTY_SOURCE(App::DocumentObjectFileIncluded, App::DocumentObject) -DocumentObjectFileIncluded::DocumentObjectFileIncluded() +DocumentObjectFileIncluded::DocumentObjectFileIncluded() { ADD_PROPERTY_TYPE(File,(0),"",(App::PropertyType)(Prop_None),"File to include into Project File"); } diff --git a/src/App/DocumentObjectFileIncluded.h b/src/App/DocumentObjectFileIncluded.h index da2f014965..2c5d4a037a 100644 --- a/src/App/DocumentObjectFileIncluded.h +++ b/src/App/DocumentObjectFileIncluded.h @@ -41,12 +41,12 @@ public: DocumentObjectFileIncluded(void); virtual ~DocumentObjectFileIncluded(); - + /// returns the type name of the ViewProvider virtual const char* getViewProviderName(void) const { return "Gui::ViewProviderDocumentObject"; } - + /// Properties PropertyFileIncluded File; diff --git a/src/App/DocumentObjectGroup.cpp b/src/App/DocumentObjectGroup.cpp index ec94fcd8df..deb985984a 100644 --- a/src/App/DocumentObjectGroup.cpp +++ b/src/App/DocumentObjectGroup.cpp @@ -58,7 +58,7 @@ PyObject *DocumentObjectGroup::getPyObject() // Python feature --------------------------------------------------------- namespace App { - + /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(App::DocumentObjectGroupPython, App::DocumentObjectGroup) template<> const char* App::DocumentObjectGroupPython::getViewProviderName(void) const { diff --git a/src/App/DocumentObjectGroup.h b/src/App/DocumentObjectGroup.h index 5a74078892..c52b0146db 100644 --- a/src/App/DocumentObjectGroup.h +++ b/src/App/DocumentObjectGroup.h @@ -33,21 +33,21 @@ namespace App { - + class AppExport DocumentObjectGroup : public DocumentObject, public GroupExtension { - + PROPERTY_HEADER_WITH_EXTENSIONS(App::DocumentObjectGroup); - + public: /// Constructor DocumentObjectGroup(void); virtual ~DocumentObjectGroup(); - + /// returns the type name of the ViewProvider virtual const char* getViewProviderName(void) const override{ return "Gui::ViewProviderDocumentObjectGroup"; } - + virtual PyObject *getPyObject(void) override; }; diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index 5c4f5a9d1a..f17c59a4a9 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -249,7 +249,7 @@ const std::string &DocumentObjectT::getPropertyName() const { std::string DocumentObjectT::getPropertyPython() const { std::stringstream str; - str << "FreeCAD.getDocument('" << document + str << "FreeCAD.getDocument('" << document << "').getObject('" << object << "')"; if(property.size()) @@ -364,7 +364,7 @@ std::string SubObjectT::getOldElementName(int *index) const { if(!obj) return std::string(); GeoFeature::resolveElement(obj,subname.c_str(),element); - if(!index) + if(!index) return std::move(element.second); std::size_t pos = element.second.find_first_of("0123456789"); if(pos == std::string::npos) diff --git a/src/App/DocumentObserverPython.h b/src/App/DocumentObserverPython.h index 9b94bb5b82..640ade6d7c 100644 --- a/src/App/DocumentObserverPython.h +++ b/src/App/DocumentObserverPython.h @@ -111,7 +111,7 @@ private: void slotBeforeAddingDynamicExtension(const App::ExtensionContainer&, std::string extension); /** Called when an object gets a dynamic extension added*/ void slotAddedDynamicExtension(const App::ExtensionContainer&, std::string extension); - + private: Py::Object inst; diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 6e991a8304..9587aada7a 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -91,8 +91,8 @@ PyObject* DocumentPy::saveAs(PyObject * args) PyObject* DocumentPy::saveCopy(PyObject * args) { char* fn; - if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C + return NULL; // NULL triggers exception PY_TRY { getDocumentPtr()->saveCopy(fn); @@ -127,8 +127,8 @@ PyObject* DocumentPy::load(PyObject * args) PyObject* DocumentPy::restore(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 const char* filename = getDocumentPtr()->FileName.getValue(); if (!filename || *filename == '\0') { PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set"); @@ -151,8 +151,8 @@ PyObject* DocumentPy::restore(PyObject * args) PyObject* DocumentPy::mergeProject(PyObject * args) { char* filename; - if (!PyArg_ParseTuple(args, "s", &filename)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "s", &filename)) // convert args: Python->C + return NULL; // NULL triggers exception PY_TRY { Base::FileInfo fi(filename); @@ -167,8 +167,8 @@ PyObject* DocumentPy::mergeProject(PyObject * args) PyObject* DocumentPy::exportGraphviz(PyObject * args) { char* fn=0; - if (!PyArg_ParseTuple(args, "|s",&fn)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "|s",&fn)) // convert args: Python->C + return NULL; // NULL triggers exception if (fn) { Base::FileInfo fi(fn); Base::ofstream str(fi); @@ -194,9 +194,9 @@ PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd) PyObject* view=0; PyObject *attach=Py_False; static char *kwlist[] = {"type","name","objProxy","viewProxy","attach","viewType",NULL}; - if (!PyArg_ParseTupleAndKeywords(args,kwd,"s|sOOOs", + if (!PyArg_ParseTupleAndKeywords(args,kwd,"s|sOOOs", kwlist, &sType,&sName,&obj,&view,&attach,&sViewType)) - return NULL; + return NULL; DocumentObject *pcFtr = 0; @@ -309,7 +309,7 @@ PyObject* DocumentPy::copyObject(PyObject *args) } } else if (!PyObject_TypeCheck(obj,&DocumentObjectPy::Type)) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "Expect first argument to be either a document object or sequence of document objects"); return 0; } @@ -324,7 +324,7 @@ PyObject* DocumentPy::copyObject(PyObject *args) return ret[0]->getPyObject(); Py::Tuple tuple(ret.size()); - for (size_t i=0;igetPyObject(),true)); return Py::new_reference_to(tuple); } PY_CATCH @@ -351,14 +351,14 @@ PyObject* DocumentPy::importLinks(PyObject *args) // do nothing here } else if (!PyObject_TypeCheck(obj,&DocumentObjectPy::Type)) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "Expect first argument to be either a document object or sequence of document objects"); return 0; } else { objs.push_back(static_cast(obj)->getDocumentObjectPtr()); } - + if (objs.empty()) objs = getDocumentPtr()->getObjects(); @@ -366,7 +366,7 @@ PyObject* DocumentPy::importLinks(PyObject *args) auto ret = getDocumentPtr()->importLinks(objs); Py::Tuple tuple(ret.size()); - for (size_t i=0;igetPyObject(),true)); return Py::new_reference_to(tuple); } PY_CATCH @@ -420,21 +420,21 @@ PyObject* DocumentPy::openTransaction(PyObject *args) } getDocumentPtr()->openTransaction(cmd.c_str()); - Py_Return; + Py_Return; } PyObject* DocumentPy::abortTransaction(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 getDocumentPtr()->abortTransaction(); Py_Return; } PyObject* DocumentPy::commitTransaction(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 getDocumentPtr()->commitTransaction(); Py_Return; } @@ -445,8 +445,8 @@ Py::Boolean DocumentPy::getHasPendingTransaction() const { PyObject* DocumentPy::undo(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 if (getDocumentPtr()->getAvailableUndos()) getDocumentPtr()->undo(); Py_Return; @@ -454,8 +454,8 @@ PyObject* DocumentPy::undo(PyObject * args) PyObject* DocumentPy::redo(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 if (getDocumentPtr()->getAvailableRedos()) getDocumentPtr()->redo(); Py_Return; @@ -463,8 +463,8 @@ PyObject* DocumentPy::redo(PyObject * args) PyObject* DocumentPy::clearUndos(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 getDocumentPtr()->clearUndos(); Py_Return; } @@ -516,9 +516,9 @@ PyObject* DocumentPy::getObject(PyObject *args) { long id = -1; char *sName = 0; - if (!PyArg_ParseTuple(args, "s",&sName)) { // convert args: Python->C + if (!PyArg_ParseTuple(args, "s",&sName)) { // convert args: Python->C if (!PyArg_ParseTuple(args, "l", &id)) - return NULL; // NULL triggers exception + return NULL; // NULL triggers exception } DocumentObject *pcFtr = sName?getDocumentPtr()->getObject(sName):getDocumentPtr()->getObjectByID(id); @@ -531,8 +531,8 @@ PyObject* DocumentPy::getObject(PyObject *args) PyObject* DocumentPy::getObjectsByLabel(PyObject *args) { char *sName; - if (!PyArg_ParseTuple(args, "s",&sName)) // convert args: Python->C - return NULL; // NULL triggers exception + if (!PyArg_ParseTuple(args, "s",&sName)) // convert args: Python->C + return NULL; // NULL triggers exception Py::List list; std::string name = sName; @@ -575,7 +575,7 @@ PyObject* DocumentPy::findObjects(PyObject *args, PyObject *kwds) } Py_ssize_t index=0; - PyObject* list = PyList_New((Py_ssize_t)res.size()); + PyObject* list = PyList_New((Py_ssize_t)res.size()); for (std::vector::const_iterator It = res.begin();It != res.end();++It, index++) PyList_SetItem(list, index, (*It)->getPyObject()); return list; @@ -591,9 +591,9 @@ Py::Object DocumentPy::getActiveObject(void) const PyObject* DocumentPy::supportedTypes(PyObject *args) { - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C + if (!PyArg_ParseTuple(args, "")) // convert args: Python->C return NULL; // NULL triggers exception - + std::vector ary; Base::Type::getAllDerivedFrom(App::DocumentObject::getClassTypeId(), ary); Py::List res; @@ -602,7 +602,7 @@ PyObject* DocumentPy::supportedTypes(PyObject *args) return Py::new_reference_to(res); } -Py::List DocumentPy::getObjects(void) const +Py::List DocumentPy::getObjects(void) const { std::vector objs = getDocumentPtr()->getObjects(); Py::List res; @@ -733,7 +733,7 @@ PyObject* DocumentPy::getTempFileName(PyObject *args) throw Py::TypeError(error); } - // search for a temp file name in the document transient directory + // search for a temp file name in the document transient directory Base::FileInfo fileName(Base::FileInfo::getTempFileName (string.c_str(),getDocumentPtr()->TransientDir.getValue())); // delete the created file, we need only the name... @@ -785,7 +785,7 @@ int DocumentPy::setCustomAttributes(const char* attr, PyObject *) if (obj) { std::stringstream str; - str << "'Document' object attribute '" << attr + str << "'Document' object attribute '" << attr << "' must not be set this way" << std::ends; PyErr_SetString(PyExc_RuntimeError, str.str().c_str()); return -1; @@ -815,7 +815,7 @@ PyObject* DocumentPy::getLinksTo(PyObject *args) getDocumentPtr()->getLinksTo(links,obj,options,count); Py::Tuple ret(links.size()); int i=0; - for (auto o : links) + for (auto o : links) ret.setItem(i++,Py::Object(o->getPyObject(),true)); return Py::new_reference_to(ret); } PY_CATCH diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp index ec545d86eb..9b78d578e5 100644 --- a/src/App/DynamicProperty.cpp +++ b/src/App/DynamicProperty.cpp @@ -85,7 +85,7 @@ std::vector DynamicProperty::getDynamicPropertyNames() const std::vector names; auto &index = props.get<0>(); names.reserve(index.size()); - for(auto &v : index) + for(auto &v : index) names.push_back(v.name); return names; } @@ -146,7 +146,7 @@ const char* DynamicProperty::getPropertyDocumentation(const char *name) const return 0; } -Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const char* type, +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)); @@ -246,7 +246,7 @@ std::string DynamicProperty::getUniquePropertyName(PropertyContainer &pc, const } } -void DynamicProperty::save(const Property *prop, Base::Writer &writer) const +void DynamicProperty::save(const Property *prop, Base::Writer &writer) const { auto &index = props.get<1>(); auto it = index.find(const_cast(prop)); @@ -259,8 +259,8 @@ void DynamicProperty::save(const Property *prop, Base::Writer &writer) const } } -Property *DynamicProperty::restore(PropertyContainer &pc, - const char *PropName, const char *TypeName, Base::XMLReader &reader) +Property *DynamicProperty::restore(PropertyContainer &pc, + const char *PropName, const char *TypeName, Base::XMLReader &reader) { if (!reader.hasAttribute("group")) return 0; diff --git a/src/App/ExpressionParser.h b/src/App/ExpressionParser.h index cbfb369034..ce1d4c2200 100644 --- a/src/App/ExpressionParser.h +++ b/src/App/ExpressionParser.h @@ -1,6 +1,6 @@ /**************************************************************************** * Copyright (c) 2015 Eivind Kvedalen * - * Copyright (c) 2019 Zheng, Lei (realthunder) * + * Copyright (c) 2019 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -127,8 +127,8 @@ protected: class AppExport ConstantExpression : public NumberExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - ConstantExpression(const App::DocumentObject *_owner = 0, - const char *_name = "", + ConstantExpression(const App::DocumentObject *_owner = 0, + const char *_name = "", const Base::Quantity &_quantity = Base::Quantity()); std::string getName() const { return name; } @@ -287,7 +287,7 @@ public: LAST, }; - FunctionExpression(const App::DocumentObject *_owner = 0, Function _f = NONE, + FunctionExpression(const App::DocumentObject *_owner = 0, Function _f = NONE, std::string &&name = std::string(), std::vector _args = std::vector()); virtual ~FunctionExpression(); @@ -352,10 +352,10 @@ protected: virtual void _updateLabelReference(App::DocumentObject *, const std::string &, const char *) override; virtual bool _updateElementReference(App::DocumentObject *,bool,ExpressionVisitor &) override; virtual bool _relabeledDocument(const std::string &, const std::string &, ExpressionVisitor &) override; - virtual bool _renameObjectIdentifier(const std::map &, + virtual bool _renameObjectIdentifier(const std::map &, const ObjectIdentifier &, ExpressionVisitor &) override; - virtual void _collectReplacement(std::map &, - const App::DocumentObject *parent, App::DocumentObject *oldObj, + virtual void _collectReplacement(std::map &, + const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const override; virtual void _moveCells(const CellAddress &, int, int, ExpressionVisitor &) override; virtual void _offsetCells(int, int, ExpressionVisitor &) override; @@ -435,7 +435,7 @@ protected: virtual void _toString(std::ostream &ss, bool persistent, int indent) const override; virtual Py::Object _getPyValue() const override; virtual void _getDeps(ExpressionDeps &) const override; - virtual bool _renameObjectIdentifier(const std::map &, + virtual bool _renameObjectIdentifier(const std::map &, const ObjectIdentifier &, ExpressionVisitor &) override; virtual void _moveCells(const CellAddress &, int, int, ExpressionVisitor &) override; virtual void _offsetCells(int, int, ExpressionVisitor &) override; diff --git a/src/App/ExpressionParser.l b/src/App/ExpressionParser.l index 709723527f..d293e46309 100644 --- a/src/App/ExpressionParser.l +++ b/src/App/ExpressionParser.l @@ -1,8 +1,28 @@ %{ -/* Lexer for the FreeCAD Expression language */ -/* (c) 2010 Jürgen Riegel LGPL */ -/* (c) 2015 Eivind Kvedalen LGPL */ +/*************************************************************************** + * Copyright (c) 2010 Jürgen Riegel * + * Copyright (c) 2015 Eivind Kvedalen * + * * + * 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 * + * * + ***************************************************************************/ +/* Lexer for the FreeCAD Expression language */ /* This disables inclusion of unistd.h, which is not available under Visual C++ * on Win32. The C++ scanner uses STL streams instead. */ @@ -28,7 +48,7 @@ extern int column; /* the manual says "somewhat more optimized" */ %option batch -%option never-interactive +%option never-interactive /* no support for include files is planned */ %option noyywrap nounput @@ -211,7 +231,7 @@ EXPO [eE][-+]?[0-9]+ "yd" COUNTCHARS; yylval.quantity.scaler = Quantity::Yard; yylval.quantity.unitStr = yytext; return UNIT; // yard "mi" COUNTCHARS; yylval.quantity.scaler = Quantity::Mile; yylval.quantity.unitStr = yytext; return UNIT; // mile -"mph" COUNTCHARS; yylval.quantity.scaler = Quantity::MilePerHour; yylval.quantity.unitStr = yytext; return UNIT; // mile per hour +"mph" COUNTCHARS; yylval.quantity.scaler = Quantity::MilePerHour; yylval.quantity.unitStr = yytext; return UNIT; // mile per hour "sqft" COUNTCHARS; yylval.quantity.scaler = Quantity::SquareFoot; yylval.quantity.unitStr = yytext; return UNIT; // square foot "cft" COUNTCHARS; yylval.quantity.scaler = Quantity::CubicFoot; yylval.quantity.unitStr = yytext; return UNIT; // cubic foot @@ -343,7 +363,7 @@ $[A-Za-z]{1,2}{DIGIT}+ COUNTCHARS; yylval.string = yytext; return CELLADDR std::map::const_iterator j = registered_functions.find(s); if (j != registered_functions.end()) yylval.func.first = j->second; - else + else { yylval.func.first = FunctionExpression::NONE; yylval.func.second = std::move(s); } return FUNC; } diff --git a/src/App/ExpressionParser.sh b/src/App/ExpressionParser.sh index 339497c5f7..ba14525792 100755 --- a/src/App/ExpressionParser.sh +++ b/src/App/ExpressionParser.sh @@ -1,2 +1,3 @@ +# Description for bash script flex -olex.ExpressionParser.c < ExpressionParser.l bison -oExpressionParser.tab.c ExpressionParser.y diff --git a/src/App/ExpressionParser.y b/src/App/ExpressionParser.y index 9914833893..e49d9a34e5 100644 --- a/src/App/ExpressionParser.y +++ b/src/App/ExpressionParser.y @@ -1,9 +1,30 @@ -/* Parser for the FreeCAD Units language */ -/* (c) 2010 Jürgen Riegel LGPL */ -/* (c) 2015 Eivind Kvedalen LGPL */ +/*************************************************************************** + * Copyright (c) 2010 Jürgen Riegel * + * Copyright (c) 2015 Eivind Kvedalen * + * * + * 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 * + * * + ***************************************************************************/ +/* Parser for the FreeCAD Units language */ /* Represents the many different ways we can access our data */ + %{ #define YYSTYPE App::ExpressionParser::semantic_type diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp index fe55f97ca9..18e21d5f1e 100644 --- a/src/App/Extension.cpp +++ b/src/App/Extension.cpp @@ -34,9 +34,9 @@ #include #include #include - + /* We do not use a standard property macro for type initiation. The reason is that we have the first - * PropertyData in the extension chain, there is no parent property data. + * PropertyData in the extension chain, there is no parent property data. */ EXTENSION_TYPESYSTEM_SOURCE_P(App::Extension) const App::PropertyData * App::Extension::extensionGetPropertyDataPtr(void){return &propertyData;} @@ -45,15 +45,15 @@ App::PropertyData App::Extension::propertyData; void App::Extension::init(void){ assert(Extension::classTypeId == Base::Type::badType() && "don't init() twice!"); - - /* Set up entry in the type system. */ - Extension::classTypeId = Base::Type::createType(Base::Type::badType(), "App::Extension", - Extension::create); + + /* Set up entry in the type system. */ + Extension::classTypeId = Base::Type::createType(Base::Type::badType(), "App::Extension", + Extension::create); } using namespace App; -Extension::Extension() +Extension::Extension() { } @@ -82,14 +82,14 @@ void Extension::initExtension(ExtensionContainer* obj) { if (m_extensionType.isBad()) throw Base::RuntimeError("Extension: Extension type not set"); - + //all properties are initialised without PropertyContainer father. Now that we know it we can //finally finish the property initialisation std::vector list; extensionGetPropertyData().getPropertyList(this, list); for(Property* prop : list) prop->setContainer(obj); - + m_base = obj; m_base->registerExtension( m_extensionType, this ); } @@ -106,10 +106,10 @@ PyObject* Extension::getExtensionPyObject(void) { } std::string Extension::name() const { - + if (m_extensionType.isBad()) throw Base::RuntimeError("Extension::name: Extension type not set"); - + std::string temp(m_extensionType.getName()); std::string::size_type pos = temp.find_last_of(':'); @@ -122,48 +122,48 @@ std::string Extension::name() const { Property* Extension::extensionGetPropertyByName(const char* 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); } @@ -172,13 +172,13 @@ void Extension::extensionGetPropertyMap(std::map< std::string, Property* >& Map) extensionGetPropertyData().getPropertyMap(this, Map); } -void Extension::initExtensionSubclass(Base::Type& toInit, const char* ClassName, const char* ParentName, +void Extension::initExtensionSubclass(Base::Type& toInit, const char* ClassName, const char* ParentName, Base::Type::instantiationMethod method) { // don't init twice! assert(toInit == Base::Type::badType()); // get the parent class - Base::Type parentType(Base::Type::fromName(ParentName)); + Base::Type parentType(Base::Type::fromName(ParentName)); // forgot init parent! assert(parentType != Base::Type::badType() ); diff --git a/src/App/Extension.h b/src/App/Extension.h index 24de83eace..cf60e0094b 100644 --- a/src/App/Extension.h +++ b/src/App/Extension.h @@ -31,7 +31,7 @@ #include namespace App { - + class ExtensionContainer; /// define Extension types @@ -53,7 +53,7 @@ public: \ static void *create(void);\ private: \ static Base::Type classTypeId - + /// define to implement a subclass of Base::BaseClass #define EXTENSION_TYPESYSTEM_SOURCE_P(_class_) \ Base::Type _class_::getExtensionClassTypeId(void) { return _class_::classTypeId; } \ @@ -122,105 +122,105 @@ template<> void _class_::init(void){\ initExtensionSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \ _class_::propertyData.parentPropertyData = _parentclass_::extensionGetPropertyDataPtr();\ } - + /** * @brief Base class for all extension that can be added to a DocumentObject - * - * For general documentation on why extension system exists and how to use it see the ExtensionContainer - * documentation. Following is a description howto create custom extensions. - * - * Extensions are like every other FreeCAD object and based on properties. All information storage - * and persistence should be achieved by use of those. Additional any number of methods can be + * + * For general documentation on why extension system exists and how to use it see the ExtensionContainer + * documentation. Following is a description howto create custom extensions. + * + * Extensions are like every other FreeCAD object and based on properties. All information storage + * and persistence should be achieved by use of those. Additional any number of methods can be * added to provide functionality around the properties. There are 3 small difference to normal objects: * 1. They must be derived from Extension class * 2. Properties must be handled with special extension macros * 3. Extensions must be initialised - * This works as simple as + * This works as simple as * @code * class MyExtension : public Extension { * EXTENSION_PROPERTY_HEADER(MyExtension); * PropertyInt MyProp; * virtual bool overridableMethod(DocumentObject* obj) {}; * }; - * + * * EXTENSION_PROPERTY_SOURCE(App::MyExtension, App::Extension) * MyExtension::MyExtension() { - * - * EXTENSION_ADD_PROPERTY(MyProp, (0)) * + * + * EXTENSION_ADD_PROPERTY(MyProp, (0)) * * initExtension(MyExtension::getExtensionClassTypeId()); * } * typedef ExtensionPythonT MyExtensionPython; - * @endcode - * - * The special python extension type created above is important, as only those python extensions - * can be added to an object from python. It does not work to add the c++ version directly there. - * - * Note that every method of the extension becomes part of the extended object when added from c++. + * @endcode + * + * The special python extension type created above is important, as only those python extensions + * can be added to an object from python. It does not work to add the c++ version directly there. + * + * Note that every method of the extension becomes part of the extended object when added from c++. * This means one should carefully design the API and make only necessary methods public or protected. * Every internal method should be private. - * - * The automatic availability of methods in the class does not hold for the python interface, only - * for c++ classes. This is like every where else in FreeCAD, there is no automatic creation of python - * API from c++ classes. Hence the extension creator must also create a custom python object of its - * extension, which works exactly like the normal FreeCAD python object workflow. There is nothing - * special at all for extension python objects, the normal xml + imp.cpp approach is used. It must - * only be taken care that the objects father is the correct extension base class. Of course also + * + * The automatic availability of methods in the class does not hold for the python interface, only + * for c++ classes. This is like every where else in FreeCAD, there is no automatic creation of python + * API from c++ classes. Hence the extension creator must also create a custom python object of its + * extension, which works exactly like the normal FreeCAD python object workflow. There is nothing + * special at all for extension python objects, the normal xml + imp.cpp approach is used. It must + * only be taken care that the objects father is the correct extension base class. Of course also * make sure your extension returns the correct python object in its "getPyObject" call. - * Every method you create in the extensions python will be later added to an extended object. This - * happens automatically for both, c++ and python extension, if "getPyObject" returns the correct + * Every method you create in the extensions python will be later added to an extended object. This + * happens automatically for both, c++ and python extension, if "getPyObject" returns the correct * python object. No extra work needs to be done. - * - * A special case that needs to be handled for extensions is the possibility of overridden methods. - * Often it is desired to customise extension behaviour by allowing the user to override methods - * provided by the extension. On c++ side this is trivial, such methods are simply marked as "virtual" + * + * A special case that needs to be handled for extensions is the possibility of overridden methods. + * Often it is desired to customise extension behaviour by allowing the user to override methods + * provided by the extension. On c++ side this is trivial, such methods are simply marked as "virtual" * and can than be overridden in any derived class. This is more involved for the python interface and - * here special care needs to be taken. - * - * As already seen above one needs to create a special ExtensionPythonT<> object for extension from - * python. This is done exactly for the purpose of allowing to have overridable methods. The - * ExtensionPythonT wrapper adds a proxy property which holds a PyObject which itself will contain - * the implementations for the overridden methods. This design is equal to the ObjectPythonT<> design - * of normal document objects. - * As this wrapper inherits the c++ extension class it can also override the virtual functions the - * user designed to be overridden. What it should do at a call of the virtual method is to check if - * this method is implemented in the proxy object and if so call it, and if not call the normal + * here special care needs to be taken. + * + * As already seen above one needs to create a special ExtensionPythonT<> object for extension from + * python. This is done exactly for the purpose of allowing to have overridable methods. The + * ExtensionPythonT wrapper adds a proxy property which holds a PyObject which itself will contain + * the implementations for the overridden methods. This design is equal to the ObjectPythonT<> design + * of normal document objects. + * As this wrapper inherits the c++ extension class it can also override the virtual functions the + * user designed to be overridden. What it should do at a call of the virtual method is to check if + * this method is implemented in the proxy object and if so call it, and if not call the normal * c++ version. It is the extensions creators responsibility to implement this check and call behaviour * for every overridable method. - * This is done by creating a custom wrapper just like ExtensionPythonT<> and overriding all virtual + * This is done by creating a custom wrapper just like ExtensionPythonT<> and overriding all virtual * methods. * @code * template class MyExtensionPythonT : public ExtensionT { * public: - * + * * MyExtensionPythonT() {} * virtual ~MyExtensionPythonT() {} * * virtual bool overridableMethod(DocumentObject* obj) override { * Py::Object pyobj = Py::asObject(obj->getPyObject()); * EXTENSION_PROXY_ONEARG(allowObject, pyobj); - * + * * if(result.isNone()) * ExtensionT::allowObject(obj); - * + * * if(result.isBoolean()) * return result.isTrue(); - * + * * return false; * }; * }; * @endcode - * @Note As seen in the code there are multiple helper macros to ease the repetitive work of querying + * @Note As seen in the code there are multiple helper macros to ease the repetitive work of querying * and calling methods of the proxy object. See the macro documentation for how to use them. - * - * To ensure that your wrapper is used when a extension is created from python the extension type must + * + * To ensure that your wrapper is used when a extension is created from python the extension type must * be exposed as follows: * @code * typedef ExtensionPythonT> MyExtensionPython; * @endcode - * - * This boilerplate is absolutely necessary to allow overridable methods in python and it is the + * + * This boilerplate is absolutely necessary to allow overridable methods in python and it is the * extension creator's responsibility to ensure full implementation. - * + * */ class AppExport Extension { @@ -235,18 +235,18 @@ public: virtual ~Extension(); virtual void initExtension(App::ExtensionContainer* obj); - + App::ExtensionContainer* getExtendedContainer() {return m_base;} const App::ExtensionContainer* getExtendedContainer() const {return m_base;} - + //get extension name without namespace std::string name() const; - + bool isPythonExtension() {return m_isPythonExtension;} - + virtual PyObject* getExtensionPyObject(void); - - + + /** @name Access properties */ //@{ /// find a property by its name @@ -271,36 +271,36 @@ public: /// get the Group of a named Property virtual const char* extensionGetPropertyDocumentation(const char *name) const; //@} - + /** @name Persistence */ //@{ virtual void extensionSave(Base::Writer&) const {} virtual void extensionRestore(Base::XMLReader&) {} //@} - + /** @name TypeHandling */ //@{ bool extensionIsDerivedFrom(const Base::Type type) const {return getExtensionTypeId().isDerivedFrom(type);} protected: - static void initExtensionSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName, + static void initExtensionSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName, Base::Type::instantiationMethod method=0); //@} virtual void extensionOnChanged(const Property* p) {(void)(p);} - + friend class App::ExtensionContainer; -protected: +protected: void initExtensionType(Base::Type type); bool m_isPythonExtension = false; Py::Object ExtensionPythonObject; - + private: Base::Type m_extensionType; App::ExtensionContainer* m_base = nullptr; }; -// Property define +// Property define #define _EXTENSION_ADD_PROPERTY(_name, _prop_, _defaultval_) \ do { \ this->_prop_.setValue _defaultval_;\ @@ -319,7 +319,7 @@ private: #define EXTENSION_ADD_PROPERTY_TYPE(_prop_, _defaultval_, _group_,_type_,_Docu_) \ _EXTENSION_ADD_PROPERTY_TYPE(#_prop_, _prop_, _defaultval_, _group_,_type_,_Docu_) - + /** * Generic Python extension class which allows every extension derived @@ -332,11 +332,11 @@ class ExtensionPythonT : public ExtensionT public: typedef ExtensionT Inherited; - + ExtensionPythonT() { ExtensionT::m_isPythonExtension = true; ExtensionT::initExtensionType(ExtensionPythonT::getExtensionClassTypeId()); - + EXTENSION_ADD_PROPERTY(ExtensionProxy,(Py::Object())); } virtual ~ExtensionPythonT() { @@ -358,16 +358,16 @@ typedef ExtensionPythonT ExtensionPython; if (feature.hasAttr(std::string("function"))) {\ if (feature.hasAttr("__object__")) {\ Py::Callable method(feature.getAttr(std::string("function"))); - - - + + + #define EXTENSION_PROXY_SECOND(function)\ result = method.apply(args);\ }\ else {\ Py::Callable method(feature.getAttr(std::string("function"))); - + #define EXTENSION_PROXY_THIRD()\ result = method.apply(args);\ }\ @@ -378,7 +378,7 @@ typedef ExtensionPythonT ExtensionPython; Base::PyException e;\ e.ReportException();\ } - + #define EXTENSION_PROXY_NOARG(function)\ EXTENSION_PROXY_FIRST(function) \ Py::Tuple args;\ @@ -401,13 +401,13 @@ typedef ExtensionPythonT ExtensionPython; virtual void function() override {\ EXTENSION_PROXY_NOARGS(function)\ }; - + #define EXTENSION_PYTHON_OVERRIDE_OBJECT_NOARGS(function)\ virtual PyObject* function() override {\ EXTENSION_PROXY_NOARGS(function)\ return res.ptr();\ }; - + } //App #endif // APP_EXTENSION_H diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h index cc7de2946e..ec44365462 100644 --- a/src/App/ExtensionContainer.h +++ b/src/App/ExtensionContainer.h @@ -79,7 +79,7 @@ namespace App { * special macros. * 2. The extensions need to be initialised in the constructor * - * Here a working example: + * Here is a working example: * @code * class AppExport Part : public App::DocumentObject, public App::FirstExtension, public App::SecondExtension { * PROPERTY_HEADER_WITH_EXTENSIONS(App::Part); @@ -195,7 +195,7 @@ private: #define PROPERTY_HEADER_WITH_EXTENSIONS(_class_) \ PROPERTY_HEADER_WITH_OVERRIDE(_class) -/// We make sur that the PropertyData of the container is not connected to the one of the extension +/// We make sure that the PropertyData of the container is not connected to the one of the extension #define PROPERTY_SOURCE_WITH_EXTENSIONS(_class_, _parentclass_) \ PROPERTY_SOURCE(_class_, _parentclass_) diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index d44583e9b6..4d6126c232 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -38,7 +38,7 @@ using namespace App; -FeaturePythonImp::FeaturePythonImp(App::DocumentObject* o) +FeaturePythonImp::FeaturePythonImp(App::DocumentObject* o) : object(o), has__object__(false) { } @@ -223,7 +223,7 @@ void FeaturePythonImp::onDocumentRestored() } } -bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, +bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, PyObject **pyObj, Base::Matrix4D *_mat, bool transform, int depth) const { FC_PY_CALL_CHECK(getSubObject); @@ -251,13 +251,13 @@ bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, throw Py::TypeError("getSubObject expects return type of tuple"); Py::Sequence seq(res); if(seq.length() < 2 || - (!seq.getItem(0).isNone() && + (!seq.getItem(0).isNone() && !PyObject_TypeCheck(seq.getItem(0).ptr(),&DocumentObjectPy::Type)) || !PyObject_TypeCheck(seq.getItem(1).ptr(),&Base::MatrixPy::Type)) { throw Py::TypeError("getSubObject expects return type of (obj,matrix,pyobj)"); } - if(_mat) + if(_mat) *_mat = *static_cast(seq.getItem(1).ptr())->getMatrixPtr(); if(pyObj) { if(seq.length()>2) @@ -315,7 +315,7 @@ bool FeaturePythonImp::getSubObjects(std::vector &ret, int reason) } } -bool FeaturePythonImp::getLinkedObject(DocumentObject *&ret, bool recurse, +bool FeaturePythonImp::getLinkedObject(DocumentObject *&ret, bool recurse, Base::Matrix4D *_mat, bool transform, int depth) const { FC_PY_CALL_CHECK(getLinkedObject); @@ -339,13 +339,13 @@ bool FeaturePythonImp::getLinkedObject(DocumentObject *&ret, bool recurse, throw Py::TypeError("getLinkedObject expects return type of (object,matrix)"); Py::Sequence seq(res); if(seq.length() != 2 || - (!seq.getItem(0).isNone() && + (!seq.getItem(0).isNone() && !PyObject_TypeCheck(seq.getItem(0).ptr(),&DocumentObjectPy::Type)) || !PyObject_TypeCheck(seq.getItem(1).ptr(),&Base::MatrixPy::Type)) { throw Py::TypeError("getLinkedObject expects return type of (object,matrix)"); } - if(_mat) + if(_mat) *_mat = *static_cast(seq.getItem(1).ptr())->getMatrixPtr(); if(seq.getItem(0).isNone()) ret = object; @@ -520,7 +520,7 @@ int FeaturePythonImp::canLoadPartial() const { FeaturePythonImp::ValueT FeaturePythonImp::redirectSubName(std::ostringstream &ss, App::DocumentObject *topParent, - App::DocumentObject *child) const + App::DocumentObject *child) const { _FC_PY_CALL_CHECK(redirectSubName,return(NotImplemented)); Base::PyGILStateLocker lock; diff --git a/src/App/FeatureTest.cpp b/src/App/FeatureTest.cpp index 8631b19cf2..6827aaeee4 100644 --- a/src/App/FeatureTest.cpp +++ b/src/App/FeatureTest.cpp @@ -77,7 +77,7 @@ FeatureTest::FeatureTest() ADD_PROPERTY(IntegerList,(4711) ); ADD_PROPERTY(FloatList ,(47.11f) ); - + ADD_PROPERTY(Link ,(0)); ADD_PROPERTY(LinkSub ,(0)); ADD_PROPERTY(LinkList ,(0)); @@ -87,7 +87,7 @@ FeatureTest::FeatureTest() ADD_PROPERTY(VectorList,(3.0,2.0,1.0)); ADD_PROPERTY(Matrix ,(Base::Matrix4D(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0))); ADD_PROPERTY(Placement ,(Base::Placement())); - + // properties for recompute testing static const char* group = "Feature Test"; ADD_PROPERTY_TYPE(Source1 ,(0),group,Prop_None,"Source for testing links"); @@ -96,7 +96,7 @@ FeatureTest::FeatureTest() ADD_PROPERTY_TYPE(ExecResult ,("empty"),group,Prop_None,"Result of the execution"); ADD_PROPERTY_TYPE(ExceptionType ,(0),group,Prop_None,"The type of exception the execution method throws"); ADD_PROPERTY_TYPE(ExecCount ,(0),group,Prop_None,"Number of executions"); - + // properties with types ADD_PROPERTY_TYPE(TypeHidden ,(4711),group,Prop_Hidden,"An example property which has the type 'Hidden'" ); ADD_PROPERTY_TYPE(TypeReadOnly,(4711),group,Prop_ReadOnly ,"An example property which has the type 'ReadOnly'" ); @@ -104,8 +104,8 @@ FeatureTest::FeatureTest() 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 ), - "An example property which has the types 'Output', 'ReadOnly' and 'Hidden'"); - + "An example property which has the types 'Output', 'ReadOnly', and 'Hidden'"); + ADD_PROPERTY(QuantityLength,(1.0)); QuantityLength.setUnit(Base::Unit::Length); ADD_PROPERTY(QuantityOther,(5.0)); @@ -167,11 +167,11 @@ doc.recompute() case 1: throw "Test Exception"; case 2: throw Base::RuntimeError("FeatureTestException::execute(): Testexception"); #if 0 // only allow these error types on purpose - case 3: *i=0;printf("%i",*i);break; // seg-fault - case 4: t = nullptr; break; // seg-fault - case 5: j=0; printf("%i",1/j); break; // int division by zero - case 6: f=0.0; printf("%f",1/f); break; // float division by zero - case 7: s = malloc(3600000000ul); free(s); break; // out-of-memory + case 3: *i=0;printf("%i",*i);break; // seg-fault + case 4: t = nullptr; break; // seg-fault + case 5: j=0; printf("%i",1/j); break; // int division by zero + case 6: f=0.0; printf("%f",1/f); break; // float division by zero + case 7: s = malloc(3600000000ul); free(s); break; // out-of-memory #else default: (void)i; (void)j; (void)f; (void)s; (void)t; break; #endif diff --git a/src/App/FeatureTest.h b/src/App/FeatureTest.h index 27b1634b00..c193fe049b 100644 --- a/src/App/FeatureTest.h +++ b/src/App/FeatureTest.h @@ -66,7 +66,7 @@ public: App::PropertyEnumeration Enum; App::PropertyIntegerConstraint ConstraintInt; App::PropertyFloatConstraint ConstraintFloat; - + // Standard Properties (PrppertyStandard.h) App::PropertyIntegerList IntegerList; App::PropertyFloatList FloatList; @@ -90,7 +90,7 @@ public: App::PropertyString ExecResult; App::PropertyInteger ExceptionType; App::PropertyInteger ExecCount; - + App::PropertyInteger TypeHidden; App::PropertyInteger TypeReadOnly; App::PropertyInteger TypeOutput; diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index 8f1c946934..fbc09cc0fb 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -1,12 +1,5 @@ -# FreeCAD init module -# (c) 2001 Jürgen Riegel -# -# Gathering all the information to start FreeCAD -# This is the second one of three init scripts, the third one -# runs when the gui is up - #*************************************************************************** -#* Copyright (c) 2002 Jürgen Riegel * +#* Copyright (c) 2001,2002 Jürgen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -28,6 +21,11 @@ #* * #***************************************************************************/ +# FreeCAD init module +# +# Gathering all the information to start FreeCAD. +# This is the second of of three init scripts. +# The third one runs when the gui is up, # imports the one and only import FreeCAD @@ -160,8 +158,8 @@ def InitApplications(): # from FreeCAD.Module import package FreeCAD.__path__ = [ModDir] + libpaths + [HomeMod] - # also add these directories to the sys.path to - # not change the old behaviour. once we have moved to + # also add these directories to the sys.path to + # not change the old behaviour. once we have moved to # proper python modules this can eventuelly be removed. sys.path = [ModDir] + libpaths + [ExtDir] + sys.path @@ -265,7 +263,7 @@ if sys.version_info.major < 3: class FCADLogger(object): '''Convenient class for tagged logging. - + Example usage: >>> logger = FreeCAD.Logger('MyModule') >>> logger.info('log test {}',1) @@ -784,7 +782,7 @@ App.Units.AngularSecond = App.Units.Quantity().AngularSecond App.Units.Length = App.Units.Unit(1) App.Units.Area = App.Units.Unit(2) App.Units.Volume = App.Units.Unit(3) -App.Units.Mass = App.Units.Unit(0,1) +App.Units.Mass = App.Units.Unit(0,1) # (length, weight, time, current, temperature, amount of substance, luminous intensity, angle) # Angle @@ -793,13 +791,13 @@ App.Units.AngleOfFriction = App.Units.Unit(0,0,0,0,0,0,0,1) App.Units.Density = App.Units.Unit(-3,1) -App.Units.TimeSpan = App.Units.Unit(0,0,1) +App.Units.TimeSpan = App.Units.Unit(0,0,1) App.Units.Frequency = App.Units.Unit(0,0,-1) -App.Units.Velocity = App.Units.Unit(1,0,-1) -App.Units.Acceleration = App.Units.Unit(1,0,-2) -App.Units.Temperature = App.Units.Unit(0,0,0,0,1) +App.Units.Velocity = App.Units.Unit(1,0,-1) +App.Units.Acceleration = App.Units.Unit(1,0,-2) +App.Units.Temperature = App.Units.Unit(0,0,0,0,1) -App.Units.ElectricCurrent = App.Units.Unit(0,0,0,1) +App.Units.ElectricCurrent = App.Units.Unit(0,0,0,1) App.Units.ElectricPotential = App.Units.Unit(2,1,-3,-1) App.Units.ElectricCharge = App.Units.Unit(0,0,1,1) App.Units.MagneticFluxDensity = App.Units.Unit(0,1,-2,-1) @@ -819,9 +817,9 @@ App.Units.UltimateTensileStrength = App.Units.Unit(-1,1,-2) App.Units.YieldStrength = App.Units.Unit(-1,1,-2) App.Units.YoungsModulus = App.Units.Unit(-1,1,-2) -App.Units.Force = App.Units.Unit(1,1,-2) -App.Units.Work = App.Units.Unit(2,1,-2) -App.Units.Power = App.Units.Unit(2,1,-3) +App.Units.Force = App.Units.Unit(1,1,-2) +App.Units.Work = App.Units.Unit(2,1,-2) +App.Units.Power = App.Units.Unit(2,1,-3) App.Units.SpecificEnergy = App.Units.Unit(2,0,-2) App.Units.ThermalConductivity = App.Units.Unit(1,1,-3,0,-1) diff --git a/src/App/FreeCADTest.py b/src/App/FreeCADTest.py index d76e05402a..e74c5dd559 100644 --- a/src/App/FreeCADTest.py +++ b/src/App/FreeCADTest.py @@ -1,10 +1,3 @@ -# FreeCAD test module -# (c) 2002 Jürgen Riegel -# -# Testing the function of the base system and run -# (if existing) the test function of the modules -# - #*************************************************************************** #* Copyright (c) 2002 Jürgen Riegel * #* * @@ -28,6 +21,12 @@ #* * #***************************************************************************/ +# FreeCAD test module +# +# Testing the function of the base system and run +# (if existing) the test function of the modules + + Log ("FreeCAD test running...\n\n") diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 6702bb4734..de37eeef2d 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2017 Zheng, Lei (realthunder) * + * Copyright (c) 2017 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -55,9 +55,9 @@ LinkBaseExtension::LinkBaseExtension(void) :myOwner(0),enableLabelCache(false),hasOldSubElement(false) { initExtensionType(LinkBaseExtension::getExtensionClassTypeId()); - EXTENSION_ADD_PROPERTY_TYPE(_LinkTouched, (false), " Link", + EXTENSION_ADD_PROPERTY_TYPE(_LinkTouched, (false), " Link", PropertyType(Prop_Hidden|Prop_NoPersist),0); - EXTENSION_ADD_PROPERTY_TYPE(_ChildCache, (), " Link", + EXTENSION_ADD_PROPERTY_TYPE(_ChildCache, (), " Link", PropertyType(Prop_Hidden|Prop_NoPersist|Prop_ReadOnly),0); _ChildCache.setScope(LinkScope::Global); props.resize(PropMax,0); @@ -87,7 +87,7 @@ const LinkBaseExtension::PropInfoMap &LinkBaseExtension::getPropertyInfoMap() co static PropInfoMap PropsMap; if(PropsMap.empty()) { const auto &infos = getPropertyInfo(); - for(const auto &info : infos) + for(const auto &info : infos) PropsMap[info.name] = info; } return PropsMap; @@ -116,12 +116,12 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { props[idx]->setStatus(Property::LockDynamic,false); props[idx] = 0; } - if(!prop) + if(!prop) return; if(!prop->isDerivedFrom(infos[idx].type)) { std::ostringstream str; - str << "App::LinkBaseExtension: expected property type '" << - infos[idx].type.getName() << "', instead of '" << + str << "App::LinkBaseExtension: expected property type '" << + infos[idx].type.getName() << "', instead of '" << prop->getClassTypeId().getName() << "'"; LINK_THROW(Base::TypeError,str.str().c_str()); } @@ -166,13 +166,13 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_TRACE)) { const char *propName; - if(!prop) + if(!prop) propName = ""; else if(prop->getContainer()) propName = prop->getName(); - else + else propName = extensionGetPropertyName(prop); - if(!propName) + if(!propName) propName = "?"; FC_TRACE("set property " << infos[idx].name << ": " << propName); } @@ -303,7 +303,7 @@ int LinkBaseExtension::_getElementCountValue() const { } bool LinkBaseExtension::extensionHasChildElement() const { - if(_getElementListValue().size() + if(_getElementListValue().size() || (_getElementCountValue() && _getShowElementValue())) return true; DocumentObject *linked = getTrueLinkedObject(false); @@ -318,7 +318,7 @@ int LinkBaseExtension::extensionSetElementVisible(const char *element, bool visi int index = _getShowElementValue()?getElementIndex(element):getArrayIndex(element); if(index>=0) { auto propElementVis = getVisibilityListProperty(); - if(!propElementVis || !element || !element[0]) + if(!propElementVis || !element || !element[0]) return -1; if(propElementVis->getSize()<=index) { if(visible) return 1; @@ -381,7 +381,7 @@ DocumentObject *LinkBaseExtension::getLink(int depth) const{ } int LinkBaseExtension::getArrayIndex(const char *subname, const char **psubname) { - if(!subname || Data::ComplexGeoData::isMappedElement(subname)) + if(!subname || Data::ComplexGeoData::isMappedElement(subname)) return -1; const char *dot = strchr(subname,'.'); if(!dot) dot= subname+strlen(subname); @@ -401,7 +401,7 @@ int LinkBaseExtension::getArrayIndex(const char *subname, const char **psubname) } int LinkBaseExtension::getElementIndex(const char *subname, const char **psubname) const { - if(!subname || Data::ComplexGeoData::isMappedElement(subname)) + if(!subname || Data::ComplexGeoData::isMappedElement(subname)) return -1; int idx = -1; const char *dot = strchr(subname,'.'); @@ -414,7 +414,7 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam if(_getElementCountProperty()) { if(idx>=_getElementCountValue()) return -1; - }else if(idx>=(int)_getElementListValue().size()) + }else if(idx>=(int)_getElementListValue().size()) return -1; }else if(!_getShowElementValue() && _getElementCountValue()) { // If elements are collapsed, we check first for LinkElement naming @@ -579,8 +579,8 @@ bool LinkBaseExtension::extensionGetSubObjects(std::vector &ret, in return true; } -bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, - PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const +bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, + PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const { ret = 0; auto obj = getContainer(); @@ -605,8 +605,8 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * _mat = *mat; } - if(pyObj && !_getElementCountValue() - && _getElementListValue().empty() && mySubElements.size()<=1) + if(pyObj && !_getElementCountValue() + && _getElementListValue().empty() && mySubElements.size()<=1) { // Scale will be included here if(getScaleProperty() || getScaleVectorProperty()) { @@ -659,7 +659,7 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * } auto linked = getTrueLinkedObject(false,mat,depth); - if(!linked || linked==obj) + if(!linked || linked==obj) return true; Base::Matrix4D matNext; @@ -692,13 +692,13 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * return true; } -void LinkBaseExtension::checkGeoElementMap(const App::DocumentObject *obj, +void LinkBaseExtension::checkGeoElementMap(const App::DocumentObject *obj, const App::DocumentObject *linked, PyObject **pyObj, const char *postfix) const { if(!pyObj || !*pyObj || (!postfix && obj->getDocument()==linked->getDocument()) || !PyObject_TypeCheck(*pyObj, &Data::ComplexGeoDataPy::Type)) return; - + // auto geoData = static_cast(*pyObj)->getComplexGeoDataPtr(); // geoData->reTagElementMap(obj->getID(),obj->getDocument()->Hasher,postfix); } @@ -708,14 +708,14 @@ void LinkBaseExtension::onExtendedUnsetupObject() { return; auto objs = getElementListValue(); getElementListProperty()->setValue(); - for(auto obj : objs) + for(auto obj : objs) detachElement(obj); } DocumentObject *LinkBaseExtension::getTrueLinkedObject( bool recurse, Base::Matrix4D *mat, int depth, bool noElement) const { - if(noElement && extensionIsDerivedFrom(LinkElement::getExtensionClassTypeId()) + if(noElement && extensionIsDerivedFrom(LinkElement::getExtensionClassTypeId()) && !static_cast(this)->canDelete()) { return 0; @@ -736,10 +736,10 @@ DocumentObject *LinkBaseExtension::getTrueLinkedObject( return ret; } -bool LinkBaseExtension::extensionGetLinkedObject(DocumentObject *&ret, +bool LinkBaseExtension::extensionGetLinkedObject(DocumentObject *&ret, bool recurse, Base::Matrix4D *mat, bool transform, int depth) const { - if(mat) + if(mat) *mat *= getTransform(transform); ret = 0; if(!_getElementCountValue()) @@ -822,7 +822,7 @@ void LinkBaseExtension::updateGroup() { auto group = ext->getExtendedObject(); auto &conn = plainGroupConns[group]; if(!conn.connected()) { - FC_LOG("new group connection " << getExtendedObject()->getFullName() + FC_LOG("new group connection " << getExtendedObject()->getFullName() << " -> " << group->getFullName()); conn = group->signalChanged.connect( boost::bind(&LinkBaseExtension::slotChangedPlainGroup,this,bp::_1,bp::_2)); @@ -836,7 +836,7 @@ void LinkBaseExtension::updateGroup() { groupSet.insert(child); auto &conn = plainGroupConns[child]; if(!conn.connected()) { - FC_LOG("new group connection " << getExtendedObject()->getFullName() + FC_LOG("new group connection " << getExtendedObject()->getFullName() << " -> " << child->getFullName()); conn = child->signalChanged.connect( boost::bind(&LinkBaseExtension::slotChangedPlainGroup,this,bp::_1,bp::_2)); @@ -885,7 +885,7 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop } } }else if(prop == _getShowElementProperty()) { - if(_getShowElementValue()) + if(_getShowElementValue()) update(parent,_getElementCountProperty()); else { auto objs = getElementListValue(); @@ -1001,7 +1001,7 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop obj->Scale.setValue(1); objs.push_back(obj); } - if(getPlacementListProperty()) + if(getPlacementListProperty()) getPlacementListProperty()->setSize(0); if(getScaleListProperty()) getScaleListProperty()->setSize(0); @@ -1074,9 +1074,9 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop } } syncElementList(); - if(_getShowElementValue() - && _getElementCountProperty() - && getElementListProperty() + if(_getShowElementValue() + && _getElementCountProperty() + && getElementListProperty() && getElementCountValue()!=getElementListProperty()->getSize()) { getElementCountProperty()->setValue( @@ -1121,8 +1121,8 @@ void LinkBaseExtension::cacheChildLabel(int enable) const { } bool LinkBaseExtension::linkTransform() const { - if(!getLinkTransformProperty() && - !getLinkPlacementProperty() && + if(!getLinkTransformProperty() && + !getLinkPlacementProperty() && !getPlacementProperty()) return true; return getLinkTransformValue(); @@ -1138,7 +1138,7 @@ void LinkBaseExtension::syncElementList() { auto elements = getElementListValue(); for(size_t i=0;i(elements[i]); - if(!element || (element->myOwner && element->myOwner!=ownerID)) + if(!element || (element->myOwner && element->myOwner!=ownerID)) continue; element->myOwner = ownerID; @@ -1175,12 +1175,12 @@ void LinkBaseExtension::onExtendedDocumentRestored() { // SubElements was stored as a PropertyStringList. It is now migrated to be // stored inside PropertyXLink. auto xlink = freecad_dynamic_cast(getLinkedObjectProperty()); - if(!xlink) + if(!xlink) FC_ERR("Failed to restore SubElements for " << parent->getFullName()); else if(!xlink->getValue()) FC_ERR("Discard SubElements of " << parent->getFullName() << " due to null link"); else if(xlink->getSubValues().size() > 1) - FC_ERR("Failed to restore SubElements for " << parent->getFullName() + FC_ERR("Failed to restore SubElements for " << parent->getFullName() << " due to conflict subnames"); else if(xlink->getSubValues().empty()) { auto subs = xlink->getSubValues(); @@ -1227,8 +1227,8 @@ void LinkBaseExtension::_handleChangedPropertyName( } } -void LinkBaseExtension::setLink(int index, DocumentObject *obj, - const char *subname, const std::vector &subElements) +void LinkBaseExtension::setLink(int index, DocumentObject *obj, + const char *subname, const std::vector &subElements) { auto parent = getContainer(); if(!parent) @@ -1316,7 +1316,7 @@ void LinkBaseExtension::setLink(int index, DocumentObject *obj, auto objs = getElementListValue(); getElementListProperty()->setValue(); - for(auto obj : objs) + for(auto obj : objs) detachElement(obj); return; } diff --git a/src/App/Link.h b/src/App/Link.h index dff79717e0..143c44f573 100644 --- a/src/App/Link.h +++ b/src/App/Link.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2017 Zheng, Lei (realthunder) * + * Copyright (c) 2017 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -54,7 +54,7 @@ namespace App { -class AppExport LinkBaseExtension : public App::DocumentObjectExtension +class AppExport LinkBaseExtension : public App::DocumentObjectExtension { EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::LinkExtension); typedef App::DocumentObjectExtension inherited; @@ -239,7 +239,7 @@ public: bool linkTransform() const; - const char *getSubName() const { + const char *getSubName() const { parseSubName(); return mySubName.size()?mySubName.c_str():0; } @@ -249,12 +249,12 @@ public: return mySubElements; } - bool extensionGetSubObject(DocumentObject *&ret, const char *subname, + bool extensionGetSubObject(DocumentObject *&ret, const char *subname, PyObject **pyObj=0, Base::Matrix4D *mat=0, bool transform=false, int depth=0) const override; bool extensionGetSubObjects(std::vector&ret, int reason) const override; - bool extensionGetLinkedObject(DocumentObject *&ret, + bool extensionGetLinkedObject(DocumentObject *&ret, bool recurse, Base::Matrix4D *mat, bool transform, int depth) const override; virtual App::DocumentObjectExecReturn *extensionExecute(void) override; @@ -293,13 +293,13 @@ public: void cacheChildLabel(int enable=-1) const; protected: - void _handleChangedPropertyName(Base::XMLReader &reader, + void _handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); void parseSubName() const; void update(App::DocumentObject *parent, const Property *prop); void syncElementList(); void detachElement(App::DocumentObject *obj); - void checkGeoElementMap(const App::DocumentObject *obj, + void checkGeoElementMap(const App::DocumentObject *obj, const App::DocumentObject *linked, PyObject **pyObj, const char *postfix) const; void updateGroup(); void slotChangedPlainGroup(const App::DocumentObject &, const App::Property &); @@ -310,7 +310,7 @@ protected: mutable std::vector mySubElements; mutable std::string mySubName; - std::unordered_map plainGroupConns; long myOwner; @@ -336,10 +336,10 @@ public: LinkExtension(); virtual ~LinkExtension(); - /** \name Helpers for defining extended parameter + /** \name Helpers for defining extended parameter * - * extended parameter definition - * (Name, Type, Property_Type, Default, Document, Property_Name, + * extended parameter definition + * (Name, Type, Property_Type, Default, Document, Property_Name, * Derived_Property_Type, App_Property_Type, Group) * * This helper simply reuses Name as Property_Name, Property_Type as @@ -422,7 +422,7 @@ public: #define LINK_PROP_DEFINE(_1,_2,_param) LINK_ETYPE(_param) LINK_ENAME(_param); #define LINK_PROPS_DEFINE(_seq) BOOST_PP_SEQ_FOR_EACH(LINK_PROP_DEFINE,_,_seq) - + // defines the actual properties LINK_PROPS_DEFINE(LINK_PARAMS_EXT) @@ -467,7 +467,7 @@ public: inherited::onDocumentRestored(); } - void handleChangedPropertyName(Base::XMLReader &reader, + void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override { _handleChangedPropertyName(reader,TypeName,PropName); @@ -508,7 +508,7 @@ public: bool canDelete() const; - void handleChangedPropertyName(Base::XMLReader &reader, + void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override { _handleChangedPropertyName(reader,TypeName,PropName); diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp index 90f44f3e46..014404b89e 100644 --- a/src/App/LinkBaseExtensionPyImp.cpp +++ b/src/App/LinkBaseExtensionPyImp.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2017 Zheng, Lei (realthunder) * + * Copyright (c) 2017 Zheng Lei (realthunder) * * * * This file is part of the FreeCAD CAx development system. * * * @@ -43,8 +43,8 @@ std::string LinkBaseExtensionPy::representation(void) const typedef std::map > PropTmpMap; typedef std::map PropMap; -static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap &infoMap, - const PropMap &propMap, PyObject *key, PyObject *value) +static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap &infoMap, + const PropMap &propMap, PyObject *key, PyObject *value) { std::ostringstream str; @@ -69,7 +69,7 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap } const char *valStr = 0; - if(key == value) + if(key == value) valStr = keyStr; else if (value!=Py_None) { #if PY_MAJOR_VERSION < 3 @@ -86,7 +86,7 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap valStr = PyUnicode_AsUTF8(value); #endif } - + App::Property *prop = 0; auto &info = it->second; if(valStr) { @@ -98,8 +98,8 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap } prop = pIt->second; if(!prop->isDerivedFrom(info.type)) { - str << "expect property '" << keyStr << "(" << valStr - << ") to be derived from '" << info.type.getName() + str << "expect property '" << keyStr << "(" << valStr + << ") to be derived from '" << info.type.getName() << "', instead of '" << prop->getTypeId().getName() << "'"; PyErr_SetString(PyExc_TypeError, str.str().c_str()); } @@ -132,7 +132,7 @@ PyObject* LinkBaseExtensionPy::configLinkProperty(PyObject *args, PyObject *keyw return 0; } } - for(auto &v : props) + for(auto &v : props) ext->setProperty(v.second.first,v.second.second); Py_Return; } @@ -182,7 +182,7 @@ PyObject* LinkBaseExtensionPy::getLinkPropertyInfo(PyObject *args) Py::Tuple ret(infos.size()); int i=0; for(const auto &info : infos) { - ret.setItem(i++,Py::TupleN(Py::String(info.name), + ret.setItem(i++,Py::TupleN(Py::String(info.name), Py::String(info.type.getName()),Py::String(info.doc))); } return Py::new_reference_to(ret); @@ -258,7 +258,7 @@ PyObject* LinkBaseExtensionPy::setLink(PyObject *_args) }else if(PySequence_Check(pcObj)) { ext->setLink(-1,0); Py::Sequence seq(pcObj); - for(size_t i=0;i(const String & other) const { return str > other.str; } - void checkImport(const App::DocumentObject *owner, + void checkImport(const App::DocumentObject *owner, const App::DocumentObject *obj=0, String *objName=0); private: @@ -164,9 +164,9 @@ public: return *this; } - Component(const String &_name = String(), typeEnum _type=SIMPLE, + Component(const String &_name = String(), typeEnum _type=SIMPLE, int begin=INT_MAX, int end=INT_MAX, int step=1); - Component(String &&_name, typeEnum _type=SIMPLE, + Component(String &&_name, typeEnum _type=SIMPLE, int begin=INT_MAX, int end=INT_MAX, int step=1); static Component SimpleComponent(const char * _component); @@ -224,16 +224,16 @@ public: }; - static Component SimpleComponent(const char * _component) + static Component SimpleComponent(const char * _component) {return Component::SimpleComponent(_component);} - static Component SimpleComponent(const String & _component) + static Component SimpleComponent(const String & _component) {return Component::SimpleComponent(_component);} - static Component SimpleComponent(String &&_component) + static Component SimpleComponent(String &&_component) {return Component::SimpleComponent(std::move(_component));} - static Component ArrayComponent(int _index) + static Component ArrayComponent(int _index) {return Component::ArrayComponent(_index); } static Component RangeComponent(int _begin, int _end = INT_MAX, int _step=1) @@ -245,7 +245,7 @@ public: static Component MapComponent(String &&_key) {return Component::MapComponent(_key);} - ObjectIdentifier(const App::PropertyContainer * _owner = 0, + ObjectIdentifier(const App::PropertyContainer * _owner = 0, const std::string & property = std::string(), int index=INT_MAX); ObjectIdentifier(const App::PropertyContainer * _owner, bool localProperty); @@ -272,13 +272,13 @@ public: App::DocumentObject *getOwner() const { return owner; } // Components - void addComponent(const Component &c) { + void addComponent(const Component &c) { components.push_back(c); _cache.clear(); } // Components - void addComponent(Component &&c) { + void addComponent(Component &&c) { components.push_back(std::move(c)); _cache.clear(); } @@ -320,10 +320,10 @@ public: String getDocumentName() const; - void setDocumentObjectName(String &&name, bool force = false, + void setDocumentObjectName(String &&name, bool force = false, String &&subname = String(), bool checkImport=false); - void setDocumentObjectName(const App::DocumentObject *obj, bool force = false, + void setDocumentObjectName(const App::DocumentObject *obj, bool force = false, String &&subname = String(), bool checkImport=false); bool hasDocumentObjectName(bool forced=false) const; @@ -347,7 +347,7 @@ public: App::Document *getDocument(String name = String(), bool *ambiguous=0) const; App::DocumentObject *getDocumentObject() const; - + std::vector getStringList() const; App::ObjectIdentifier relativeTo(const App::ObjectIdentifier & other) const; @@ -417,7 +417,7 @@ protected: friend struct ResolveResults; - App::Property *resolveProperty(const App::DocumentObject *obj, + App::Property *resolveProperty(const App::DocumentObject *obj, const char *propertyName, App::DocumentObject *&sobj,int &ptype) const; void getSubPathStr(std::ostream &ss, const ResolveResults &result, bool toPython=false) const; @@ -462,7 +462,7 @@ Py::Object AppExport pyObjectFromAny(const App::any &value); namespace std { -template<> +template<> struct hash { typedef App::ObjectIdentifier argument_type; typedef std::size_t result_type; diff --git a/src/App/Origin.cpp b/src/App/Origin.cpp index 5fba5dff06..ef3bab4073 100644 --- a/src/App/Origin.cpp +++ b/src/App/Origin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2015 Stefan Tr�ger * + * Copyright (c) 2015 Stefan Tröger * * Copyright (c) 2015 Alexander Golubev (Fat-Zer) * * * * This file is part of the FreeCAD CAx development system. * diff --git a/src/App/OriginGroupExtension.cpp b/src/App/OriginGroupExtension.cpp index 08e34d9eac..0e25dd9ba4 100644 --- a/src/App/OriginGroupExtension.cpp +++ b/src/App/OriginGroupExtension.cpp @@ -67,12 +67,12 @@ App::Origin *OriginGroupExtension::getOrigin () const { } bool OriginGroupExtension::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 { App::DocumentObject *originObj = Origin.getValue (); const char *dot; - if(originObj && originObj->getNameInDocument() && - subname && (dot=strchr(subname,'.'))) + if(originObj && originObj->getNameInDocument() && + subname && (dot=strchr(subname,'.'))) { bool found; if(subname[0] == '$') @@ -80,7 +80,7 @@ bool OriginGroupExtension::extensionGetSubObject(DocumentObject *&ret, const cha else found = std::string(subname,dot)==originObj->getNameInDocument(); if(found) { - if(mat && transform) + if(mat && transform) *mat *= const_cast(this)->placement().getValue().toMatrix(); ret = originObj->getSubObject(dot+1,pyObj,mat,true,depth+1); return true; @@ -93,9 +93,9 @@ App::DocumentObject *OriginGroupExtension::getGroupOfObject (const DocumentObjec if(!obj) return nullptr; - + bool isOriginFeature = obj->isDerivedFrom(App::OriginFeature::getClassTypeId()); - + auto list = obj->getInList(); for (auto o : list) { if(o->hasExtension(App::OriginGroupExtension::getExtensionClassTypeId())) @@ -178,13 +178,13 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) obj->getPropertyList(list); for(App::Property* prop : list) { if(prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { - + auto p = static_cast(prop); if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) continue; - + p->setValue(getOrigin()->getOriginFeature(static_cast(p->getValue())->Role.getValue())); - } + } else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { auto p = static_cast(prop); auto vec = p->getValues(); @@ -205,7 +205,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) auto p = static_cast(prop); if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) continue; - + std::vector subValues = p->getSubValues(); p->setValue(getOrigin()->getOriginFeature(static_cast(p->getValue())->Role.getValue()), subValues); } diff --git a/src/App/OriginGroupExtension.h b/src/App/OriginGroupExtension.h index d99b5c1a66..aad7e11547 100644 --- a/src/App/OriginGroupExtension.h +++ b/src/App/OriginGroupExtension.h @@ -35,7 +35,7 @@ class Origin; class AppExport OriginGroupExtension : public App::GeoFeatureGroupExtension { EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::OriginGroupExtension); - + public: OriginGroupExtension (); virtual ~OriginGroupExtension (); @@ -48,22 +48,22 @@ public: return "Gui::ViewProviderOriginGroup"; } - /** + /** * Returns the origin group which contains this object. - * In case this object is not part of any geoFeatureGroup 0 is returned. + * In case this object is not part of any geoFeatureGroup, 0 is returned. * @param obj the object to search for */ static DocumentObject* getGroupOfObject (const DocumentObject* obj); /// Returns true on changing OriginFeature set virtual short extensionMustExecute () override; - + /// Origin linked to the group PropertyLink Origin; - - //changes all links of obj to a origin to point to this groupes origin + + // changes all links of obj to a origin to point to this groups origin void relinkToOrigin(App::DocumentObject* obj); - + virtual std::vector addObjects(std::vector obj) override; virtual bool hasObject(const DocumentObject* obj, bool recursive = false) const override; diff --git a/src/App/OriginGroupExtensionPyImp.cpp b/src/App/OriginGroupExtensionPyImp.cpp index 6d7a1de1ec..2e19512a50 100644 --- a/src/App/OriginGroupExtensionPyImp.cpp +++ b/src/App/OriginGroupExtensionPyImp.cpp @@ -50,7 +50,7 @@ PyObject *OriginGroupExtensionPy::getCustomAttributes(const char* /*attr*/) cons int OriginGroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { - return 0; + return 0; } diff --git a/src/App/Part.cpp b/src/App/Part.cpp index b0fbc3c350..f66a32d0fc 100644 --- a/src/App/Part.cpp +++ b/src/App/Part.cpp @@ -68,9 +68,9 @@ Part::~Part(void) } App::Part *Part::getPartOfObject (const DocumentObject* obj) { - - //as a Part is a geofeaturegroup it must directly link to all objects it contains, even - //if they are in additional groups etc. + + // as a Part is a geofeaturegroup it must directly link to all + // objects it contains, even if they are in additional groups etc. auto list = obj->getInList(); for (auto obj : list) { if(obj->isDerivedFrom(App::Part::getClassTypeId())) diff --git a/src/App/Part.h b/src/App/Part.h index c4d7bc5ad6..bd509d898a 100644 --- a/src/App/Part.h +++ b/src/App/Part.h @@ -44,7 +44,7 @@ public: PropertyString Type; /** @name base properties of all Assembly Items - * This properties corospond mostly to the meta information + * These properties correspond mostly to the meta information * in the App::Document class */ //@{ @@ -86,7 +86,7 @@ public: /** * Returns the part which contains this object. - * In case this object is not belongs to any Part 0 is returned. + * In case this object does not belong to any Part, 0 is returned. * @param obj the object to search for */ static App::Part* getPartOfObject (const DocumentObject* obj); diff --git a/src/App/PartPyImp.cpp b/src/App/PartPyImp.cpp index ca79f68c98..a05ccded17 100644 --- a/src/App/PartPyImp.cpp +++ b/src/App/PartPyImp.cpp @@ -49,7 +49,6 @@ PyObject *PartPy::getCustomAttributes(const char* /*attr*/) const int PartPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { - return 0; + return 0; } - diff --git a/src/App/Path.h b/src/App/Path.h index 6628cbc5e5..716d921d43 100644 --- a/src/App/Path.h +++ b/src/App/Path.h @@ -34,7 +34,7 @@ namespace App /** Base class of all geometric document objects. */ -class AppExport Path +class AppExport Path { protected: std::vector _PathVector; diff --git a/src/App/Placement.h b/src/App/Placement.h index 378d917ce3..e7ae37dcea 100644 --- a/src/App/Placement.h +++ b/src/App/Placement.h @@ -21,14 +21,12 @@ ***************************************************************************/ - - #ifndef _AppPlacement_h_ #define _AppPlacement_h_ #include -#include "FeaturePython.h" +#include "FeaturePython.h" #include "GeoFeature.h" #include "PropertyGeo.h" @@ -59,7 +57,7 @@ public: /// Constructor Placement(void); virtual ~Placement(); - + /// returns the type name of the ViewProvider virtual const char* getViewProviderName(void) const { return "Gui::ViewProviderPlacement"; @@ -67,7 +65,7 @@ public: }; -typedef App::FeaturePythonT PlacementPython; +typedef App::FeaturePythonT PlacementPython; @@ -76,4 +74,4 @@ typedef App::FeaturePythonT PlacementPython; -#endif +#endif diff --git a/src/App/PreCompiled.h b/src/App/PreCompiled.h index 24bedddfca..ef5fe98b67 100644 --- a/src/App/PreCompiled.h +++ b/src/App/PreCompiled.h @@ -63,7 +63,7 @@ #include #include -// STL +// STL #include #include #include diff --git a/src/App/Property.cpp b/src/App/Property.cpp index 201404b497..b0ab46c021 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -228,7 +228,7 @@ void Property::verifyPath(const ObjectIdentifier &p) const p.verify(*this); } -Property *Property::Copy(void) const +Property *Property::Copy(void) const { // have to be reimplemented by a subclass! assert(0); @@ -242,7 +242,7 @@ void Property::Paste(const Property& /*from*/) } void Property::setStatusValue(unsigned long status) { - static const unsigned long mask = + static const unsigned long mask = (1<listSize) + if(idx<-1 || idx>listSize) throw Base::ValueError("index out of bound"); if(idx==-1 || idx==listSize) { idx = listSize; diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index f204babbd1..bb03473cec 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -43,7 +43,7 @@ class PropertyContainer; class DocumentObject; class Extension; -enum PropertyType +enum PropertyType { Prop_None = 0, /*!< No special property type */ Prop_ReadOnly = 1, /*!< Property is read-only in the editor */ @@ -67,16 +67,16 @@ struct AppExport PropertyData :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 - //one function implementation for multiple container types without losing all type safety by + + //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 + //one function implementation for multiple container types without losing all type safety by //accepting void* struct OffsetBase { OffsetBase(const App::PropertyContainer* container) : m_container(container) {} OffsetBase(const App::Extension* container) : m_container(container) {} - + short int getOffsetTo(const App::Property* prop) const { auto *pt = (const char*)prop; auto *base = (const char *)m_container; @@ -85,7 +85,7 @@ struct AppExport PropertyData return (short) (pt-base); }; char* getOffset() const {return (char*) m_container;} - + private: const void* m_container; }; @@ -115,10 +115,10 @@ 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; - + 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; @@ -227,15 +227,15 @@ public: friend class DynamicProperty; -protected: +protected: /// get called by the container when a property has changed virtual void onChanged(const Property* /*prop*/){} /// get called before the value is changed virtual void onBeforeChange(const Property* /*prop*/){} //void hasChanged(Property* prop); - static const PropertyData * getPropertyDataPtr(void); - virtual const PropertyData& getPropertyData(void) const; + static const PropertyData * getPropertyDataPtr(void); + virtual const PropertyData& getPropertyData(void) const; virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop); @@ -248,12 +248,12 @@ private: protected: DynamicProperty dynamicProps; -private: +private: std::string _propertyPrefix; - static PropertyData propertyData; + static PropertyData propertyData; }; -/// Property define +/// Property define #define _ADD_PROPERTY(_name,_prop_, _defaultval_) \ do { \ this->_prop_.setValue _defaultval_;\ @@ -281,7 +281,7 @@ protected: \ static const App::PropertyData * getPropertyDataPtr(void); \ virtual const App::PropertyData &getPropertyData(void) const; \ private: \ - static App::PropertyData propertyData + static App::PropertyData propertyData /// Like PROPERTY_HEADER, but with overridden methods declared as such #define PROPERTY_HEADER_WITH_OVERRIDE(_class_) \ @@ -290,8 +290,8 @@ protected: \ static const App::PropertyData * getPropertyDataPtr(void); \ virtual const App::PropertyData &getPropertyData(void) const override; \ private: \ - static App::PropertyData propertyData -/// + static App::PropertyData propertyData +/// #define PROPERTY_SOURCE(_class_, _parentclass_) \ TYPESYSTEM_SOURCE_P(_class_)\ const App::PropertyData * _class_::getPropertyDataPtr(void){return &propertyData;} \ diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 2f09ab3562..98132fac1e 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -1,4 +1,3 @@ - /*************************************************************************** * Copyright (c) 2007 Jürgen Riegel * * * @@ -295,7 +294,7 @@ PyObject* PropertyContainerPy::getPropertyStatus(PyObject *args) break; } } - if(!found) + if(!found) ret.append(Py::Int((long)i)); } } @@ -396,7 +395,7 @@ PyObject* PropertyContainerPy::dumpPropertyContent(PyObject *args, PyObject *kwd } catch (...) { PyErr_SetString(PyExc_IOError, "Unable parse content into binary representation"); - return NULL; + return NULL; } //build the byte array with correct size @@ -508,7 +507,7 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const } return dict; } else if(Base::streq(attr,"Shape") - && getPropertyContainerPtr()->isDerivedFrom(App::DocumentObject::getClassTypeId())) + && getPropertyContainerPtr()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { // Special treatment of Shape property static PyObject *_getShape = 0; @@ -527,7 +526,7 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const Py::Tuple args(1); args.setItem(0,Py::Object(const_cast(this))); auto res = PyObject_CallObject(_getShape, args.ptr()); - if(!res) + if(!res) PyErr_Clear(); else { Py::Object pyres(res,true); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index dc215c6608..6f47ffbe27 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -87,7 +87,7 @@ void PropertyLinkBase::hasSetValue() { void PropertyLinkBase::unregisterElementReference() { } -void PropertyLinkBase::unregisterLabelReferences() +void PropertyLinkBase::unregisterLabelReferences() { for(auto &label : _LabelRefs) { auto it = _LabelMap.find(label); @@ -131,7 +131,7 @@ void PropertyLinkBase::checkLabelReferences(const std::vector &subs } } -std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *parent, +std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *parent, const char *subname, App::DocumentObject *obj, const std::string &ref, const char *newLabel) { if(!obj || !obj->getNameInDocument() || !parent || !parent->getNameInDocument()) @@ -153,8 +153,8 @@ std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *pa return std::string(); } -std::vector > > -PropertyLinkBase::updateLabelReferences(App::DocumentObject *obj, const char *newLabel) +std::vector > > +PropertyLinkBase::updateLabelReferences(App::DocumentObject *obj, const char *newLabel) { std::vector > > ret; if(!obj || !obj->getNameInDocument()) @@ -222,7 +222,7 @@ public: char v2; }; -void PropertyLinkBase::restoreLabelReference(const DocumentObject *obj, +void PropertyLinkBase::restoreLabelReference(const DocumentObject *obj, std::string &subname, ShadowSub *shadow) { std::ostringstream ss; @@ -236,7 +236,7 @@ void PropertyLinkBase::restoreLabelReference(const DocumentObject *obj, StringGuard guard(dot-1); sobj = obj->getSubObject(subname.c_str()); if(!sobj) { - FC_ERR("Failed to restore label reference " << obj->getFullName() + FC_ERR("Failed to restore label reference " << obj->getFullName() << '.' << ss.str()); return; } @@ -252,15 +252,15 @@ void PropertyLinkBase::restoreLabelReference(const DocumentObject *obj, size_t count = sub-subname.c_str(); const auto &newSub = ss.str(); - if(shadow && shadow->second.size()>=count) + if(shadow && shadow->second.size()>=count) shadow->second = newSub + (shadow->second.c_str()+count); - if(shadow && shadow->first.size()>=count) + if(shadow && shadow->first.size()>=count) shadow->first = newSub + (shadow->first.c_str()+count); subname = newSub + sub; } -bool PropertyLinkBase::_updateElementReference(DocumentObject *feature, - App::DocumentObject *obj, std::string &sub, ShadowSub &shadow, +bool PropertyLinkBase::_updateElementReference(DocumentObject *feature, + App::DocumentObject *obj, std::string &sub, ShadowSub &shadow, bool reverse, bool notify) { (void)feature; @@ -271,8 +271,8 @@ bool PropertyLinkBase::_updateElementReference(DocumentObject *feature, return false; } -std::pair -PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject *obj, +std::pair +PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject *obj, const DocumentObject *parent, DocumentObject *oldObj, DocumentObject *newObj, const char *subname) { std::pair res; @@ -283,7 +283,7 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject // Do not throw on sub object error yet. It's better to let // recompute find out the error and point out the affected objects // to user. -#if 0 +#if 0 if(subname && subname[0] && !newObj->getSubObject(subname)) { FC_THROWM(Base::RuntimeError, "Sub-object '" << newObj->getFullName() @@ -309,7 +309,7 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject sub[pos] = 0; auto sobj = obj->getSubObject(sub.c_str()); sub[pos] = c; - if(!sobj) + if(!sobj) break; if(sobj == oldObj) { if(prev == parent) { @@ -339,8 +339,8 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject } std::pair > -PropertyLinkBase::tryReplaceLinkSubs(const PropertyContainer *owner, - DocumentObject *obj, const DocumentObject *parent, DocumentObject *oldObj, +PropertyLinkBase::tryReplaceLinkSubs(const PropertyContainer *owner, + DocumentObject *obj, const DocumentObject *parent, DocumentObject *oldObj, DocumentObject *newObj, const std::vector &subs) { std::pair > res; @@ -406,10 +406,10 @@ void PropertyLink::resetLink() { //in case this property gets dynamically removed #ifndef USE_OLD_DAG // maintain the back link in the DocumentObject class if it is from a document object - if (_pcScope!=LinkScope::Hidden && - _pcLink && - getContainer() && - getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) + if (_pcScope!=LinkScope::Hidden && + _pcLink && + getContainer() && + getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { App::DocumentObject* parent = static_cast(getContainer()); // before accessing internals make sure the object is not about to be destroyed @@ -536,7 +536,7 @@ void PropertyLink::Paste(const Property &from) setValue(static_cast(from)._pcLink); } -void PropertyLink::getLinks(std::vector &objs, +void PropertyLink::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { (void)newStyle; @@ -588,12 +588,12 @@ PropertyLinkList::PropertyLinkList() PropertyLinkList::~PropertyLinkList() { //in case this property gety dynamically removed -#ifndef USE_OLD_DAG +#ifndef USE_OLD_DAG //maintain the back link in the DocumentObject class - if (_pcScope!=LinkScope::Hidden && - !_lValueList.empty() && - getContainer() && - getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) + if (_pcScope!=LinkScope::Hidden && + !_lValueList.empty() && + getContainer() && + getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { App::DocumentObject* parent = static_cast(getContainer()); // before accessing internals make sure the object is not about to be destroyed @@ -643,13 +643,13 @@ void PropertyLinkList::set1Value(int idx, DocumentObject* const &value) { _nameMap.clear(); -#ifndef USE_OLD_DAG +#ifndef USE_OLD_DAG if (getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { App::DocumentObject* parent = static_cast(getContainer()); // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy) && _pcScope!=LinkScope::Hidden) { - if(obj) + if(obj) obj->_removeBackLink(static_cast(getContainer())); if(value) value->_addBackLink(static_cast(getContainer())); @@ -776,7 +776,7 @@ void PropertyLinkList::Restore(Base::XMLReader &reader) if (child) values.push_back(child); else if (reader.isVerbose()) - FC_WARN("Lost link to " << (document?document->getName():"") << " " << name + FC_WARN("Lost link to " << (document?document->getName():"") << " " << name << " while loading, maybe an object was not loaded correctly"); } @@ -843,7 +843,7 @@ DocumentObject *PropertyLinkList::find(const std::string &name, int *pindex) con _nameMap.clear(); for(int i=0;i<(int)_lValueList.size();++i) { auto obj = _lValueList[i]; - if(obj && obj->getNameInDocument()) + if(obj && obj->getNameInDocument()) _nameMap[obj->getNameInDocument()] = i; } } @@ -854,7 +854,7 @@ DocumentObject *PropertyLinkList::find(const std::string &name, int *pindex) con return _lValueList[it->second]; } -void PropertyLinkList::getLinks(std::vector &objs, +void PropertyLinkList::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { (void)subs; @@ -924,13 +924,13 @@ PropertyLinkSub::~PropertyLinkSub() #endif } -void PropertyLinkSub::setValue(App::DocumentObject * lValue, +void PropertyLinkSub::setValue(App::DocumentObject * lValue, const std::vector &SubList, std::vector &&shadows) { setValue(lValue,std::vector(SubList),std::move(shadows)); } -void PropertyLinkSub::setValue(App::DocumentObject * lValue, +void PropertyLinkSub::setValue(App::DocumentObject * lValue, std::vector &&subs, std::vector &&shadows) { auto parent = Base::freecad_dynamic_cast(getContainer()); @@ -977,9 +977,9 @@ static inline const std::string &getSubNameWithStyle(const std::string &subName, const PropertyLinkBase::ShadowSub &shadow, bool newStyle) { if(!newStyle) { - if(shadow.second.size()) + if(shadow.second.size()) return shadow.second; - }else if(shadow.first.size()) + }else if(shadow.first.size()) return shadow.first; return subName; } @@ -1036,7 +1036,7 @@ void PropertyLinkSub::setPyObject(PyObject *value) Py::Sequence seq(value); if(seq.size() == 0) setValue(NULL); - else if(seq.size()!=2) + else if(seq.size()!=2) throw Base::ValueError("Expect input sequence of size 2"); else if (PyObject_TypeCheck(seq[0].ptr(), &(DocumentObjectPy::Type))) { DocumentObjectPy *pcObj = (DocumentObjectPy*)seq[0].ptr(); @@ -1080,7 +1080,7 @@ void PropertyLinkSub::setPyObject(PyObject *value) } } -static bool updateLinkReference(App::PropertyLinkBase *prop, +static bool updateLinkReference(App::PropertyLinkBase *prop, App::DocumentObject *feature, bool reverse, bool notify, App::DocumentObject *link, std::vector &subs, std::vector &mapped, std::vector &shadows) @@ -1109,7 +1109,7 @@ static bool updateLinkReference(App::PropertyLinkBase *prop, subs[idx] = shadows[idx].first; } mapped.clear(); - if(owner && feature) + if(owner && feature) owner->onUpdateElementReference(prop); return true; } @@ -1163,7 +1163,7 @@ std::string PropertyLinkBase::importSubName(Base::XMLReader &reader, const char } const char *PropertyLinkBase::exportSubName(std::string &output, - const App::DocumentObject *obj, const char *sub, bool first_obj) + const App::DocumentObject *obj, const char *sub, bool first_obj) { std::ostringstream str; const char *res = sub; @@ -1198,7 +1198,7 @@ const char *PropertyLinkBase::exportSubName(std::string &output, str << doc->getName() << '#'; sub = hash+1; } - }else if(!obj || !obj->getNameInDocument()) + }else if(!obj || !obj->getNameInDocument()) return res; for(const char *dot=strchr(sub,'.');dot;sub=dot+1,dot=strchr(sub,'.')) { @@ -1248,10 +1248,10 @@ App::DocumentObject *PropertyLinkBase::tryImport(const App::Document *doc, return const_cast(obj); } -std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, const char *_subname, +std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, const char *_subname, const App::Document *doc, const std::map &nameMap) { - if(!doc || !obj || !obj->getNameInDocument()) + if(!doc || !obj || !obj->getNameInDocument()) return std::string(); std::ostringstream ss; @@ -1276,7 +1276,7 @@ std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, c if(it == nameMap.end()) continue; auto imported = doc->getObject(it->second.c_str()); - if(!imported) + if(!imported) FC_THROWM(RuntimeError, "Failed to find imported object " << it->second); ss.write(sub,next-sub); if(next[0] == '$') @@ -1306,7 +1306,7 @@ void PropertyLinkSub::Save (Base::Writer &writer) const // returns 0 if (_pcLinkSub && _pcLinkSub->getNameInDocument()) internal_name = _pcLinkSub->getExportName(); - writer.Stream() << writer.ind() << "" << std::endl; writer.incInd(); @@ -1361,7 +1361,7 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) pcObject = document ? document->getObject(name.c_str()) : 0; if (!pcObject) { if (reader.isVerbose()) { - FC_WARN("Lost link to " << name + FC_WARN("Lost link to " << name << " while loading, maybe an object was not loaded correctly"); } } @@ -1376,7 +1376,7 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) reader.readElement("Sub"); shadows[i].second = importSubName(reader,reader.getAttribute("value"),restoreLabel); if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) { - values[i] = shadows[i].first = + values[i] = shadows[i].first = importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel); } else { values[i] = shadows[i].second; @@ -1434,7 +1434,7 @@ Property *PropertyLinkSub::CopyOnImportExternal( auto subs = updateLinkSubs(_pcLinkSub,_cSubList, &tryImportSubName,owner->getDocument(),nameMap); auto linked = tryImport(owner->getDocument(),_pcLinkSub,nameMap); - if(subs.empty() && linked==_pcLinkSub) + if(subs.empty() && linked==_pcLinkSub) return 0; PropertyLinkSub *p= new PropertyLinkSub(); @@ -1446,8 +1446,8 @@ Property *PropertyLinkSub::CopyOnImportExternal( return p; } -Property *PropertyLinkSub::CopyOnLabelChange(App::DocumentObject *obj, - const std::string &ref, const char *newLabel) const +Property *PropertyLinkSub::CopyOnLabelChange(App::DocumentObject *obj, + const std::string &ref, const char *newLabel) const { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument()) @@ -1456,7 +1456,7 @@ Property *PropertyLinkSub::CopyOnLabelChange(App::DocumentObject *obj, return 0; auto subs = updateLinkSubs(_pcLinkSub,_cSubList,&updateLabelReference,obj,ref,newLabel); - if(subs.empty()) + if(subs.empty()) return 0; PropertyLinkSub *p= new PropertyLinkSub(); @@ -1494,7 +1494,7 @@ void PropertyLinkSub::Paste(const Property &from) setValue(link._pcLinkSub, link._cSubList); } -void PropertyLinkSub::getLinks(std::vector &objs, +void PropertyLinkSub::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { if(all||_pcScope!=LinkScope::Hidden) { @@ -1521,9 +1521,9 @@ static App::DocumentObject *adjustLinkSubs(App::PropertyLinkBase *prop, size_t pos = sub.find('.'); for(;pos!=std::string::npos;pos=sub.find('.',pos+1)) { auto sobj = link->getSubObject(sub.substr(0,pos+1).c_str()); - if(!sobj || - (!prop->testFlag(PropertyLinkBase::LinkAllowExternal) && - sobj->getDocument()!=link->getDocument())) + if(!sobj || + (!prop->testFlag(PropertyLinkBase::LinkAllowExternal) && + sobj->getDocument()!=link->getDocument())) { pos = std::string::npos; break; @@ -1536,7 +1536,7 @@ static App::DocumentObject *adjustLinkSubs(App::PropertyLinkBase *prop, (*links)[sobj].push_back(sub.substr(pos+1)); else sub = sub.substr(pos+1); - }else if(links) + }else if(links) (*links)[sobj].push_back(sub.substr(pos+1)); else if(sobj == newLink) sub = sub.substr(pos+1); @@ -1635,7 +1635,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName) } } #endif - + if (lValue) { aboutToSetValue(); _lValueList.resize(1); @@ -1666,7 +1666,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list"); #ifndef USE_OLD_DAG - //maintain backlinks. + //maintain backlinks. if(parent) { // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers @@ -1720,9 +1720,9 @@ void PropertyLinkSubList::setValues(std::vector&& lValue, } if (lValue.size() != lSubNames.size()) throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list"); - + #ifndef USE_OLD_DAG - //maintain backlinks. + //maintain backlinks. if(parent) { // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers @@ -1764,7 +1764,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vectorgetDocument()!=lValue->getDocument()) throw Base::ValueError("PropertyLinkSubList does not support external object"); } -#ifndef USE_OLD_DAG +#ifndef USE_OLD_DAG //maintain backlinks. if(parent) { // before accessing internals make sure the object is not about to be destroyed @@ -1820,7 +1820,7 @@ const string PropertyLinkSubList::getPyReprString() const strm << "("; App::DocumentObject* obj = this->_lValueList[i]; if (obj) { - strm << "App.getDocument('" << obj->getDocument()->getName() + strm << "App.getDocument('" << obj->getDocument()->getName() << "').getObject('" << obj->getNameInDocument() << "')"; } else { strm << "None"; @@ -1975,7 +1975,7 @@ void PropertyLinkSubList::setPyObject(PyObject *value) return; }catch(...) {} - static const char *errMsg = + static const char *errMsg = "Expects sequence of items of type DocObj, (DocObj,SubName), or (DocObj, (SubName,...))"; if (!PyTuple_Check(value) && !PyList_Check(value)) @@ -2053,7 +2053,7 @@ void PropertyLinkSubList::updateElementReference(DocumentObject *feature, bool r if(_updateElementReference(feature,obj,sub,_ShadowSubList[i++],reverse,notify&&!touched)) touched = true; } - if(!touched) + if(!touched) return; std::vector mapped; @@ -2067,7 +2067,7 @@ void PropertyLinkSubList::updateElementReference(DocumentObject *feature, bool r } } _mapped.swap(mapped); - if(owner && feature) + if(owner && feature) owner->onUpdateElementReference(this); if(notify) hasSetValue(); @@ -2162,7 +2162,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader) SubNames.push_back(shadow.first); }else{ SubNames.push_back(shadow.second); - if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) + if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) shadow.first = importSubName(reader,reader.getAttribute(ATTR_SHADOW),restoreLabel); } if(reader.hasAttribute(ATTR_MAPPED)) @@ -2215,7 +2215,7 @@ Property *PropertyLinkSubList::CopyOnImportExternal( subs.push_back(sub); } } - if(values.empty()) + if(values.empty()) return 0; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); @@ -2223,8 +2223,8 @@ Property *PropertyLinkSubList::CopyOnImportExternal( return p.release(); } -Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, - const std::string &ref, const char *newLabel) const +Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, + const std::string &ref, const char *newLabel) const { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument()) @@ -2257,7 +2257,7 @@ Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, subs.push_back(sub); } } - if(values.empty()) + if(values.empty()) return 0; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); @@ -2322,7 +2322,7 @@ Property *PropertyLinkSubList::CopyOnLinkReplace(const App::DocumentObject *pare } } } - if(values.empty()) + if(values.empty()) return 0; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); @@ -2363,7 +2363,7 @@ std::vector PropertyLinkSubList::getSubValues(bool newStyle) const return ret; } -void PropertyLinkSubList::getLinks(std::vector &objs, +void PropertyLinkSubList::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { if(all||_pcScope!=LinkScope::Hidden) { @@ -2396,7 +2396,7 @@ void PropertyLinkSubList::breakLink(App::DocumentObject *obj, bool clear) { int i=-1; for(auto o : _lValueList) { ++i; - if(o==obj) + if(o==obj) continue; values.push_back(o); subs.push_back(_lSubList[i]); @@ -2447,12 +2447,12 @@ bool PropertyLinkSubList::adjustLink(const std::set &inLis // Because of possible symbolic links, multiple entry may refer to the same // file. We used to rely on QFileInfo::canonicalFilePath to resolve it, but // has now been changed to simply use the absoluteFilePath(), and rely on user -// to be aware of possible duplicated file location. The reason being that +// to be aware of possible duplicated file location. The reason being that // some user (especially Linux user) use symlink to organize file tree. typedef std::map DocInfoMap; DocInfoMap _DocInfoMap; -class App::DocInfo : +class App::DocInfo : public std::enable_shared_from_this { public: @@ -2468,7 +2468,7 @@ public: std::set links; static std::string getDocPath( - const char *filename, App::Document *pDoc, bool relative, QString *fullPath = 0) + const char *filename, App::Document *pDoc, bool relative, QString *fullPath = 0) { bool absolute; // The path could be an URI, in that case @@ -2493,7 +2493,7 @@ public: const char *docPath = pDoc->getFileName(); if(!docPath || *docPath==0) throw Base::RuntimeError("Owner document not saved"); - + QDir docDir(QFileInfo(QString::fromUtf8(docPath)).absoluteDir()); if(!absolute) { path = QDir::cleanPath(docDir.absoluteFilePath(path)); @@ -2507,8 +2507,8 @@ public: return std::string(path.toUtf8().constData()); } - static DocInfoPtr get(const char *filename, - App::Document *pDoc,PropertyXLink *l, const char *objName) + static DocInfoPtr get(const char *filename, + App::Document *pDoc,PropertyXLink *l, const char *objName) { QString path; l->filePath = getDocPath(filename,pDoc,true,&path); @@ -2521,10 +2521,10 @@ public: info = it->second; if(!info->pcDoc) { QString fullpath(info->getFullPath()); - if(fullpath.size() && + if(fullpath.size() && App::GetApplication().addPendingDocument( fullpath.toUtf8().constData(),objName, - l->testFlag(PropertyLinkBase::LinkAllowPartial))==0) + l->testFlag(PropertyLinkBase::LinkAllowPartial))==0) { for(App::Document *doc : App::GetApplication().getDocuments()) { if(getFullPath(doc->getFileName()) == fullpath) { @@ -2642,8 +2642,8 @@ public: continue; } auto obj = doc->getObject(link->objectName.c_str()); - if(!obj) - FC_WARN("object '" << link->objectName << "' not found in document '" + if(!obj) + FC_WARN("object '" << link->objectName << "' not found in document '" << doc->getName() << "'"); else link->restoreLink(obj); @@ -2653,8 +2653,8 @@ public: v.first->aboutToSetValue(); for(auto link : v.second) { auto obj = doc->getObject(link->objectName.c_str()); - if(!obj) - FC_WARN("object '" << link->objectName << "' not found in document '" + if(!obj) + FC_WARN("object '" << link->objectName << "' not found in document '" << doc->getName() << "'"); else link->restoreLink(obj); @@ -2805,14 +2805,14 @@ public: else link->breakLink(obj,clear); } - for(auto link : parentLinks) + for(auto link : parentLinks) link->breakLink(obj,clear); } } }; -void PropertyLinkBase::breakLinks(App::DocumentObject *link, - const std::vector &objs, bool clear) +void PropertyLinkBase::breakLinks(App::DocumentObject *link, + const std::vector &objs, bool clear) { std::vector props; for(auto obj : objs) { @@ -2878,7 +2878,7 @@ void PropertyXLink::hasSetValue() { PropertyLinkBase::hasSetValue(); } -void PropertyXLink::setSubName(const char *subname) +void PropertyXLink::setSubName(const char *subname) { std::vector subs; if(subname && subname[0]) @@ -2888,12 +2888,12 @@ void PropertyXLink::setSubName(const char *subname) hasSetValue(); } -void PropertyXLink::setSubValues(std::vector &&subs, +void PropertyXLink::setSubValues(std::vector &&subs, std::vector &&shadows) { _SubList = std::move(subs); _ShadowSubList.clear(); - if(shadows.size() == _SubList.size()) + if(shadows.size() == _SubList.size()) _ShadowSubList = std::move(shadows); else updateElementReference(0); @@ -2916,7 +2916,7 @@ void PropertyXLink::restoreLink(App::DocumentObject *lValue) { assert(!_pcLink && lValue && docInfo); auto owner = dynamic_cast(getContainer()); - if(!owner || !owner->getNameInDocument()) + if(!owner || !owner->getNameInDocument()) throw Base::RuntimeError("invalid container"); bool touched = owner->isTouched(); @@ -2932,17 +2932,17 @@ void PropertyXLink::restoreLink(App::DocumentObject *lValue) { hasSetValue(); setFlag(LinkRestoring,false); - if(!touched && - owner->isTouched() && - docInfo && - docInfo->pcDoc && + if(!touched && + owner->isTouched() && + docInfo && + docInfo->pcDoc && stamp==docInfo->pcDoc->LastModifiedDate.getValue()) { owner->purgeTouched(); } } -void PropertyXLink::setValue(App::DocumentObject *lValue, +void PropertyXLink::setValue(App::DocumentObject *lValue, std::vector &&subs, std::vector &&shadows) { if(_pcLink==lValue && _SubList==subs) @@ -2954,7 +2954,7 @@ void PropertyXLink::setValue(App::DocumentObject *lValue, } auto owner = dynamic_cast(getContainer()); - if(!owner || !owner->getNameInDocument()) + if(!owner || !owner->getNameInDocument()) throw Base::RuntimeError("invalid container"); if(lValue == owner) @@ -2970,7 +2970,7 @@ void PropertyXLink::setValue(App::DocumentObject *lValue, if(!docInfo || lValue->getDocument()!=docInfo->pcDoc) { const char *filename = lValue->getDocument()->getFileName(); - if(!filename || *filename==0) + if(!filename || *filename==0) throw Base::RuntimeError("Linked document not saved"); FC_LOG("xlink set to new document " << lValue->getDocument()->getName()); info = DocInfo::get(filename,owner->getDocument(),this,name); @@ -3003,7 +3003,7 @@ void PropertyXLink::setValue(App::DocumentObject *lValue, hasSetValue(); } -void PropertyXLink::setValue(std::string &&filename, std::string &&name, +void PropertyXLink::setValue(std::string &&filename, std::string &&name, std::vector &&subs, std::vector &&shadows) { if(name.empty()) { @@ -3011,7 +3011,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name, return; } auto owner = dynamic_cast(getContainer()); - if(!owner || !owner->getNameInDocument()) + if(!owner || !owner->getNameInDocument()) throw Base::RuntimeError("invalid container"); DocumentObject *pObject=0; @@ -3019,7 +3019,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name, if(filename.size()) { owner->getDocument()->signalLinkXsetValue(filename); info = DocInfo::get(filename.c_str(),owner->getDocument(),this,name.c_str()); - if(info->pcDoc) + if(info->pcDoc) pObject = info->pcDoc->getObject(name.c_str()); }else pObject = owner->getDocument()->getObject(name.c_str()); @@ -3031,7 +3031,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name, setFlag(LinkDetached,false); aboutToSetValue(); #ifndef USE_OLD_DAG - if (_pcLink && !owner->testStatus(ObjectStatus::Destroy) && _pcScope!=LinkScope::Hidden) + if (_pcLink && !owner->testStatus(ObjectStatus::Destroy) && _pcScope!=LinkScope::Hidden) _pcLink->_removeBackLink(owner); #endif _pcLink = 0; @@ -3069,7 +3069,7 @@ const char *PropertyXLink::getObjectName() const { bool PropertyXLink::upgrade(Base::XMLReader &reader, const char *typeName) { if(strcmp(typeName,App::PropertyLinkGlobal::getClassTypeId().getName())==0 || strcmp(typeName,App::PropertyLink::getClassTypeId().getName())==0 || - strcmp(typeName,App::PropertyLinkChild::getClassTypeId().getName())==0) + strcmp(typeName,App::PropertyLinkChild::getClassTypeId().getName())==0) { PropertyLink::Restore(reader); return true; @@ -3095,8 +3095,8 @@ int PropertyXLink::checkRestore(std::string *msg) const { return 0; } if(!_pcLink) { - if(testFlag(LinkAllowPartial) && - (!docInfo->pcDoc || + if(testFlag(LinkAllowPartial) && + (!docInfo->pcDoc || docInfo->pcDoc->testStatus(App::Document::PartialDoc))) { return 0; @@ -3118,7 +3118,7 @@ int PropertyXLink::checkRestore(std::string *msg) const { if(msg) { std::ostringstream ss; - ss << "Time stamp changed on link " + ss << "Time stamp changed on link " << _pcLink->getFullName(); *msg = ss.str(); } @@ -3161,7 +3161,7 @@ void PropertyXLink::Save (Base::Writer &writer) const { auto exporting = owner->isExporting(); if(_pcLink && exporting && _pcLink->isExporting()) { - // this means, we are exporting the owner and the linked object together. + // this means, we are exporting the owner and the linked object together. // Lets save the export name writer.Stream() << writer.ind() << "getExportName(); }else { @@ -3171,7 +3171,7 @@ void PropertyXLink::Save (Base::Writer &writer) const { // Here means we are exporting the owner but not exporting the // linked object. Try to use absolute file path for easy transition // into document at different directory - if(docInfo) + if(docInfo) _path = docInfo->filePath(); else { auto pDoc = owner->getDocument(); @@ -3181,13 +3181,13 @@ void PropertyXLink::Save (Base::Writer &writer) const { _path = DocInfo::getDocPath(filePath.c_str(),pDoc,false); else _path = docPath; - }else + }else FC_WARN("PropertyXLink export without saving the document"); } if(_path.size()) path = _path.c_str(); } - writer.Stream() << writer.ind() + writer.Stream() << writer.ind() << "pcDoc?docInfo->pcDoc->LastModifiedDate.getValue():"") << "\" name=\"" << objectName; @@ -3257,11 +3257,11 @@ void PropertyXLink::Restore(Base::XMLReader &reader) stampAttr = reader.getAttribute("stamp"); if(reader.hasAttribute("file")) file = reader.getAttribute("file"); - setFlag(LinkAllowPartial, - reader.hasAttribute("partial") && + setFlag(LinkAllowPartial, + reader.hasAttribute("partial") && reader.getAttributeAsInteger("partial")); std::string name; - if(file.empty()) + if(file.empty()) name = reader.getName(reader.getAttribute("name")); else name = reader.getAttribute("name"); @@ -3306,8 +3306,8 @@ void PropertyXLink::Restore(Base::XMLReader &reader) for (int i = 0; i < count; i++) { reader.readElement("Sub"); shadows[i].second = importSubName(reader,reader.getAttribute("value"),restoreLabel); - if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) - subs[i] = shadows[i].first = + if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) + subs[i] = shadows[i].first = importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel); else { subs[i] = shadows[i].second; @@ -3344,7 +3344,7 @@ Property *PropertyXLink::CopyOnImportExternal( auto subs = updateLinkSubs(_pcLink,_SubList, &tryImportSubName,owner->getDocument(),nameMap); auto linked = tryImport(owner->getDocument(),_pcLink,nameMap); - if(subs.empty() && linked==_pcLink) + if(subs.empty() && linked==_pcLink) return 0; std::unique_ptr p(new PropertyXLink); @@ -3356,29 +3356,29 @@ Property *PropertyXLink::CopyOnLinkReplace(const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const { auto res = tryReplaceLinkSubs(getContainer(),_pcLink,parent,oldObj,newObj,_SubList); - if(!res.first) + if(!res.first) return 0; std::unique_ptr p(new PropertyXLink); copyTo(*p,res.first,&res.second); return p.release(); } -Property *PropertyXLink::CopyOnLabelChange(App::DocumentObject *obj, - const std::string &ref, const char *newLabel) const +Property *PropertyXLink::CopyOnLabelChange(App::DocumentObject *obj, + const std::string &ref, const char *newLabel) const { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->getNameInDocument()) return 0; auto subs = updateLinkSubs(_pcLink,_SubList,&updateLabelReference,obj,ref,newLabel); - if(subs.empty()) + if(subs.empty()) return 0; std::unique_ptr p(new PropertyXLink); copyTo(*p,_pcLink,&subs); return p.release(); } -void PropertyXLink::copyTo(PropertyXLink &other, - DocumentObject *linked, std::vector *subs) const +void PropertyXLink::copyTo(PropertyXLink &other, + DocumentObject *linked, std::vector *subs) const { if(!linked) linked = _pcLink; @@ -3446,7 +3446,7 @@ bool PropertyXLink::hasXLink(const App::Document *doc) { } bool PropertyXLink::hasXLink( - const std::vector &objs, std::vector *unsaved) + const std::vector &objs, std::vector *unsaved) { std::set docs; bool ret = false; @@ -3468,7 +3468,7 @@ void PropertyXLink::restoreDocument(const App::Document &doc) { DocInfo::restoreDocument(doc); } -std::map > +std::map > PropertyXLink::getDocumentOutList(App::Document *doc) { std::map > ret; for(auto &v : _DocInfoMap) { @@ -3485,7 +3485,7 @@ PropertyXLink::getDocumentOutList(App::Document *doc) { return ret; } -std::map > +std::map > PropertyXLink::getDocumentInList(App::Document *doc) { std::map > ret; for(auto &v : _DocInfoMap) { @@ -3529,7 +3529,7 @@ PyObject *PropertyXLink::getPyObject(void) void PropertyXLink::setPyObject(PyObject *value) { if(PySequence_Check(value)) { Py::Sequence seq(value); - if(seq.size()!=2) + if(seq.size()!=2) throw Base::ValueError("Expect input sequence of size 2"); std::vector subs; Py::Object pyObj(seq[0].ptr()); @@ -3572,7 +3572,7 @@ const char *PropertyXLink::getSubName(bool newStyle) const { return getSubNameWithStyle(_SubList[0],_ShadowSubList[0],newStyle).c_str(); } -void PropertyXLink::getLinks(std::vector &objs, +void PropertyXLink::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { if((all||_pcScope!=LinkScope::Hidden) && _pcLink && _pcLink->getNameInDocument()) { @@ -3588,7 +3588,7 @@ bool PropertyXLink::adjustLink(const std::set &inList) { if(!_pcLink || !_pcLink->getNameInDocument() || !inList.count(_pcLink)) return false; auto subs = _SubList; - auto link = adjustLinkSubs(this,inList,_pcLink,subs); + auto link = adjustLinkSubs(this,inList,_pcLink,subs); if(link) { setValue(link,std::move(subs)); return true; @@ -3623,7 +3623,7 @@ void PropertyXLink::setAllowPartial(bool enable) { auto owner = dynamic_cast(getContainer()); if(!owner) return; - if(!App::GetApplication().isRestoring() && + if(!App::GetApplication().isRestoring() && !owner->getDocument()->isPerformingTransaction() && !_pcLink && docInfo && filePath.size() && objectName.size() && (!docInfo->pcDoc || docInfo->pcDoc->testStatus(Document::PartialDoc))) @@ -3652,7 +3652,7 @@ PropertyXLinkSub::~PropertyXLinkSub() { bool PropertyXLinkSub::upgrade(Base::XMLReader &reader, const char *typeName) { if(strcmp(typeName, PropertyLinkSubGlobal::getClassTypeId().getName())==0 || strcmp(typeName, PropertyLinkSub::getClassTypeId().getName())==0 || - strcmp(typeName, PropertyLinkSubChild::getClassTypeId().getName())==0) + strcmp(typeName, PropertyLinkSubChild::getClassTypeId().getName())==0) { App::PropertyLinkSub linkProp; linkProp.setContainer(getContainer()); @@ -3717,7 +3717,7 @@ void PropertyXLinkSubList::setValue(DocumentObject* lValue,const char* SubName) } void PropertyXLinkSubList::setValues( - const std::vector& lValue, + const std::vector& lValue, const std::vector& lSubNames) { #define CHECK_SUB_SIZE(_l,_r) do{\ @@ -3741,7 +3741,7 @@ void PropertyXLinkSubList::setValues(const std::vector& lValue, CHECK_SUB_SIZE(lValue,lSubNames); std::map > values; int i=0; - for(auto &obj : lValue) + for(auto &obj : lValue) values[obj].push_back(lSubNames[i++]); setValues(std::move(values)); } @@ -3757,19 +3757,19 @@ void PropertyXLinkSubList::setSubListValues(const std::vector > &values) + const std::map > &values) { setValues(std::map >(values)); } void PropertyXLinkSubList::setValues( - std::map > &&values) + std::map > &&values) { for(auto &v : values) { if(!v.first || !v.first->getNameInDocument()) FC_THROWM(Base::ValueError,"invalid document object"); } - + atomic_change guard(*this); for(auto it=_Links.begin(),itNext=it;it!=_Links.end();it=itNext) { @@ -3790,18 +3790,18 @@ void PropertyXLinkSubList::setValues( guard.tryInvoke(); } -void PropertyXLinkSubList::addValue(App::DocumentObject *obj, - const std::vector &subs, bool reset) +void PropertyXLinkSubList::addValue(App::DocumentObject *obj, + const std::vector &subs, bool reset) { addValue(obj,std::vector(subs),reset); } -void PropertyXLinkSubList::addValue(App::DocumentObject *obj, +void PropertyXLinkSubList::addValue(App::DocumentObject *obj, std::vector &&subs, bool reset) { if(!obj || !obj->getNameInDocument()) FC_THROWM(Base::ValueError,"invalid document object"); - + for(auto &l : _Links) { if(l.getValue() == obj) { auto s = l.getSubValues(); @@ -3841,7 +3841,7 @@ void PropertyXLinkSubList::setValues(const std::vector &values) void PropertyXLinkSubList::set1Value(int idx, DocumentObject *value, - const std::vector &SubList) + const std::vector &SubList) { if(idx < -1 || idx > getSize()) throw Base::RuntimeError("index out of bound"); @@ -3874,7 +3874,7 @@ const string PropertyXLinkSubList::getPyReprString() const auto obj = link.getValue(); if(!obj || !obj->getNameInDocument()) continue; - ss << "(App.getDocument('" << obj->getDocument()->getName() + ss << "(App.getDocument('" << obj->getDocument()->getName() << "').getObject('" << obj->getNameInDocument() << "'), ("; const auto &subs = link.getSubValues(); if(subs.empty()) @@ -3968,12 +3968,12 @@ void PropertyXLinkSubList::setPyObject(PyObject *value) } void PropertyXLinkSubList::afterRestore() { - for(auto &l : _Links) + for(auto &l : _Links) l.afterRestore(); } void PropertyXLinkSubList::onContainerRestored() { - for(auto &l : _Links) + for(auto &l : _Links) l.onContainerRestored(); } @@ -4049,8 +4049,8 @@ Property *PropertyXLinkSubList::CopyOnImportExternal( return p.release(); } -Property *PropertyXLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, - const std::string &ref, const char *newLabel) const +Property *PropertyXLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, + const std::string &ref, const char *newLabel) const { std::unique_ptr copy; auto it = _Links.begin(); @@ -4115,8 +4115,8 @@ Property *PropertyXLinkSubList::CopyOnLinkReplace(const App::DocumentObject *par copied->copyTo(p->_Links.back()); copied = &p->_Links.back(); for(++it;it!=_Links.end();++it) { - if((it->getValue()==newObj||it->getValue()==oldObj) - && copied->getValue()==newObj) + if((it->getValue()==newObj||it->getValue()==oldObj) + && copied->getValue()==newObj) { // merge subnames in case new object already exists for(auto &sub : it->getSubValues()) { @@ -4183,7 +4183,7 @@ std::vector PropertyXLinkSubList::getSubValues(App::DocumentObject return {}; } -void PropertyXLinkSubList::getLinks(std::vector &objs, +void PropertyXLinkSubList::getLinks(std::vector &objs, bool all, std::vector *subs, bool newStyle) const { if(all||_pcScope!=LinkScope::Hidden) { @@ -4285,7 +4285,7 @@ int PropertyXLinkSubList::checkRestore(std::string *msg) const { bool PropertyXLinkSubList::upgrade(Base::XMLReader &reader, const char *typeName) { if(strcmp(typeName, PropertyLinkListGlobal::getClassTypeId().getName())==0 || strcmp(typeName, PropertyLinkList::getClassTypeId().getName())==0 || - strcmp(typeName, PropertyLinkListChild::getClassTypeId().getName())==0) + strcmp(typeName, PropertyLinkListChild::getClassTypeId().getName())==0) { PropertyLinkList linkProp; linkProp.setContainer(getContainer()); @@ -4294,7 +4294,7 @@ bool PropertyXLinkSubList::upgrade(Base::XMLReader &reader, const char *typeName return true; } else if (strcmp(typeName, PropertyLinkSubListGlobal::getClassTypeId().getName())==0 || strcmp(typeName, PropertyLinkSubList::getClassTypeId().getName())==0 || - strcmp(typeName, PropertyLinkSubListChild::getClassTypeId().getName())==0) + strcmp(typeName, PropertyLinkSubListChild::getClassTypeId().getName())==0) { PropertyLinkSubList linkProp; linkProp.setContainer(getContainer()); @@ -4366,7 +4366,7 @@ PyObject *PropertyXLinkList::getPyObject(void) auto obj = link.getValue(); if(!obj || !obj->getNameInDocument()) continue; - if(link.hasSubName()) + if(link.hasSubName()) return PropertyXLinkSubList::getPyObject(); } @@ -4497,12 +4497,12 @@ void PropertyXLinkContainer::Save (Base::Writer &writer) const { for(auto &v : docSet) { writer.Stream() << writer.ind() << "getName() - << "\" label=\"" << encodeAttribute(v.first->Label.getValue()) + << "name=\"" << v.first->getName() + << "\" label=\"" << encodeAttribute(v.first->Label.getValue()) << "\" index=\"" << v.second << "\"/>" << std::endl; } - for(auto &v : _XLinks) + for(auto &v : _XLinks) v.second->Save(writer); writer.decInd(); @@ -4556,7 +4556,7 @@ bool PropertyXLinkContainer::isLinkedToDocument(const App::Document &doc) const auto iter = _XLinks.lower_bound(doc.getName()); if(iter != _XLinks.end()) { size_t len = strlen(doc.getName()); - return iter->first.size()>len + return iter->first.size()>len && iter->first[len] == '#' && boost::starts_with(iter->first,doc.getName()); } @@ -4627,7 +4627,7 @@ void PropertyXLinkContainer::clearDeps() { _LinkRestored = false; } -void PropertyXLinkContainer::getLinks(std::vector &objs, +void PropertyXLinkContainer::getLinks(std::vector &objs, bool, std::vector * /*subs*/, bool /*newStyle*/) const { objs.insert(objs.end(),_Deps.begin(),_Deps.end()); diff --git a/src/App/PropertyLinks.h b/src/App/PropertyLinks.h index c291abf9d1..6d5bf6e83c 100644 --- a/src/App/PropertyLinks.h +++ b/src/App/PropertyLinks.h @@ -52,7 +52,7 @@ class PropertyXLink; /** * @brief Defines different scopes for which a link can be valid * The scopes defined in this enum describe the different possibilities of where a link can point to. - * Local: links are valid only within the same GeoFeatureGroup as the linkowner is in or in none. + * Local: links are valid only within the same GeoFeatureGroup as the linkowner is in or in none. * Child: links are valid within the same or any sub GeoFeatureGroup * Global: all possible links are valid * Hidden: links are not included in dependency calculation @@ -67,34 +67,34 @@ enum class LinkScope { /** * @brief Enables scope handling for links * This class is a base for all link properties and enables them to handle scopes of the linked objects. - * The possible scopes are defined by LinkScope enum class. The default value is Local. + * The possible scopes are defined by LinkScope enum class. The default value is Local. * The scope of a property is not saved in the document. It is a value that needs to be fixed when - * the object holding the property is loaded. That is possible with two methods: + * the object holding the property is loaded. That is possible with two methods: * 1. Set the scope value in the constructor of the link property * 2. Use setScope to change the scope in the constructor of the link property - * - * The second option is only available in c++, not in python, as setscope is not exposed. It would + * + * The second option is only available in c++, not in python, as setscope is not exposed. It would * not make sense to expose it there, as restoring python objects does not call the constructor again. - * Hence in python the only way to create a LinkProperty with different scope than local is to use a - * specialized property for that. In c++ existing properties can simply be changed via setScope in the - * objects constructor. + * Hence in python the only way to create a LinkProperty with different scope than local is to use a + * specialized property for that. In c++ existing properties can simply be changed via setScope in the + * objects constructor. */ class AppExport ScopedLink { - + public: /** * @brief Set the links scope - * Allows to define what kind of links are allowed. Only in the Local GeoFeatureGroup, in this and + * Allows to define what kind of links are allowed. Only in the Local GeoFeatureGroup, in this and * all Childs or to all objects within the Glocal scope. */ - void setScope(LinkScope scope) {_pcScope = scope;}; + void setScope(LinkScope scope) {_pcScope = scope;}; /** * @brief Get the links scope - * Retrieve what kind of links are allowed. Only in the Local GeoFeatureGroup, in this and + * Retrieve what kind of links are allowed. Only in the Local GeoFeatureGroup, in this and * all Childs or to all objects within the Glocal scope. */ LinkScope getScope() {return _pcScope;}; - + protected: LinkScope _pcScope = LinkScope::Local; }; @@ -122,7 +122,7 @@ public: * @sa _updateElementReference() */ virtual void updateElementReference(App::DocumentObject *feature, - bool reverse=false, bool notify=false) + bool reverse=false, bool notify=false) { (void)feature; (void)reverse; @@ -178,9 +178,9 @@ public: * this LinkScope. If false, then return only if the LinkScope * is not hidden. * @param sub: if given, then return subname references. - * @param newStyle: whether to return new or old style subname reference + * @param newStyle: whether to return new or old style subname reference */ - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const = 0; /** Called to reset this link property @@ -203,8 +203,8 @@ public: */ virtual bool adjustLink(const std::set &inList) = 0; - /** Return a copy of the property if the link replacement affects this property - * + /** Return a copy of the property if the link replacement affects this property + * * @param owner: the parent object whose link property is to be replace. * Note that The parent may not be the container of this * property. Link sub property can use this opportunity to @@ -218,7 +218,7 @@ public: virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const = 0; - /** Return a copy of the property if any changes caused by importing external linked object + /** Return a copy of the property if any changes caused by importing external linked object * * @param nameMap: a map from the original external object name to the * imported new object name @@ -241,7 +241,7 @@ public: * @return Returns a copy of the property if its link reference is affected. * The copy will later be assgiend to this property by calling its Paste(). */ - virtual Property *CopyOnLabelChange(App::DocumentObject *obj, + virtual Property *CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const { (void)obj; @@ -266,8 +266,8 @@ public: } /// Helper function to return a map of linked object and its subname references - void getLinkedElements(std::map > &elements, - bool newStyle=true, bool all=true) const + void getLinkedElements(std::map > &elements, + bool newStyle=true, bool all=true) const { std::vector ret; std::vector subs; @@ -279,8 +279,8 @@ public: } /// Helper function to return a map of linked object and its subname references - std::map > - linkedElements(bool newStyle=true, bool all=true) const + std::map > + linkedElements(bool newStyle=true, bool all=true) const { std::map > ret; getLinkedElements(ret,newStyle,all); @@ -320,8 +320,8 @@ public: * and correct any link sub reference. */ static std::pair tryReplaceLink( - const App::PropertyContainer *owner, App::DocumentObject *obj, - const App::DocumentObject *parent, App::DocumentObject *oldObj, + const App::PropertyContainer *owner, App::DocumentObject *obj, + const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj, const char *sub=0); /** Helper function to check and replace a link with multiple subname references @@ -340,9 +340,9 @@ public: */ static std::pair > tryReplaceLinkSubs( const App::PropertyContainer *owner, - App::DocumentObject *obj, - const App::DocumentObject *parent, - App::DocumentObject *oldObj, + App::DocumentObject *obj, + const App::DocumentObject *parent, + App::DocumentObject *oldObj, App::DocumentObject *newObj, const std::vector &subs); @@ -367,11 +367,11 @@ public: * geometry element reference change due to geometry model changes. */ bool _updateElementReference(App::DocumentObject *feature, - App::DocumentObject *obj, std::string &sub, ShadowSub &shadow, + App::DocumentObject *obj, std::string &sub, ShadowSub &shadow, bool reverse, bool notify=false); /** Helper function to register geometry element reference - * + * * @param obj: the linked object * @param sub: the subname reference * @param shadow: a pair of new and old style element references to be updated. @@ -406,9 +406,9 @@ public: * the API CopyOnImportExternal(). This function helps to rewrite subname * reference to point to the correct sub objects that are imported. */ - static std::string tryImportSubName(const App::DocumentObject *obj, const char *sub, - const App::Document *doc, const std::map &nameMap); - + static std::string tryImportSubName(const App::DocumentObject *obj, const char *sub, + const App::Document *doc, const std::map &nameMap); + /** Helper function for link import operation * * @param doc: owner document of the imported objects @@ -446,7 +446,7 @@ public: * restoreLabelReference() can be used together to restore the reference * during import. */ - static const char *exportSubName(std::string &output, + static const char *exportSubName(std::string &output, const App::DocumentObject *obj, const char *subname, bool first_obj=false); /** Helper function to import a subname reference @@ -504,7 +504,7 @@ public: * * @param obj: the object that owns the label * @param newLabel: the new label - * + * * @return return a map from the affected property to a copy of it with * updated subname references */ @@ -562,11 +562,11 @@ private: }; /** The general Link Property - * Main Purpose of this property is to Link Objects and Features in a document. Like all links this - * property is scope aware, meaning it does define which objects are allowed to be linked depending + * Main Purpose of this property is to Link Objects and Features in a document. Like all links this + * property is scope aware, meaning it does define which objects are allowed to be linked depending * of the GeoFeatureGroup where it is in. Default is Local. - * - * @note Links that are invalid in respect to the scope of this property is set to are not rejected. + * + * @note Links that are invalid in respect to the scope of this property is set to are not rejected. * They are only detected to be invalid and prevent the feature from recomputing. */ class AppExport PropertyLink : public PropertyLinkBase @@ -622,7 +622,7 @@ public: virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyLinkItem"; } - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -672,7 +672,7 @@ public: } }; -class AppExport PropertyLinkList : +class AppExport PropertyLinkList : public PropertyListsT, PropertyLinkListBase> { TYPESYSTEM_HEADER_WITH_OVERRIDE(); @@ -712,7 +712,7 @@ public: virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyLinkListItem"; } - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -765,7 +765,7 @@ public: /** the Link Property with sub elements * This property links an object and a defined sequence of * sub elements. These subelements (like Edges of a Shape) - * are stored as names, which can be resolved by the + * are stored as names, which can be resolved by the * ComplexGeoDataType interface to concrete sub objects. */ class AppExport PropertyLinkSub : public PropertyLinkBase @@ -799,7 +799,7 @@ public: */ App::DocumentObject * getValue(void) const; - /// return the list of sub elements + /// return the list of sub elements const std::vector& getSubValues(void) const; /// return the list of sub elements with mapped names @@ -809,7 +809,7 @@ public: std::vector getSubValues(bool newStyle) const; - /// return the list of sub elements starts with a special string + /// return the list of sub elements starts with a special string std::vector getSubValuesStartsWith(const char*, bool newStyle=false) const; /** Returns the link type checked @@ -835,10 +835,10 @@ public: virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyLinkItem"; } - /// Return a copy of the property if any changes caused by importing external object + /// Return a copy of the property if any changes caused by importing external object virtual Property *CopyOnImportExternal(const std::map &nameMap) const override; - virtual Property *CopyOnLabelChange(App::DocumentObject *obj, + virtual Property *CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const override; virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, @@ -853,7 +853,7 @@ public: virtual bool referenceChanged() const override; - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -980,10 +980,10 @@ public: virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyLinkListItem"; } - /// Return a copy of the property if any changes caused by importing external object + /// Return a copy of the property if any changes caused by importing external object virtual Property *CopyOnImportExternal(const std::map &nameMap) const override; - virtual Property *CopyOnLabelChange(App::DocumentObject *obj, + virtual Property *CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const override; virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, @@ -996,7 +996,7 @@ public: virtual bool referenceChanged() const override; - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -1065,7 +1065,7 @@ public: void setValue(App::DocumentObject *,std::vector &&SubList, std::vector &&ShadowSubList = {}); - void setValue(App::DocumentObject *,const std::vector &SubList, + void setValue(App::DocumentObject *,const std::vector &SubList, std::vector &&ShadowSubList={}); void setSubValues(std::vector &&SubList, @@ -1073,7 +1073,7 @@ public: const char *getSubName(bool newStyle=true) const; void setSubName(const char *subname); - + bool hasSubName() const {return !_SubList.empty();} App::Document *getDocument() const; @@ -1088,10 +1088,10 @@ public: virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; - /// Return a copy of the property if any changes caused by importing external object + /// Return a copy of the property if any changes caused by importing external object virtual Property *CopyOnImportExternal(const std::map &nameMap) const override; - virtual Property *CopyOnLabelChange(App::DocumentObject *obj, + virtual Property *CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const override; virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, @@ -1114,7 +1114,7 @@ public: virtual bool referenceChanged() const override; - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual bool adjustLink(const std::set &inList) override; @@ -1260,7 +1260,7 @@ public: virtual Property *CopyOnImportExternal(const std::map &nameMap) const override; - virtual Property *CopyOnLabelChange(App::DocumentObject *obj, + virtual Property *CopyOnLabelChange(App::DocumentObject *obj, const std::string &ref, const char *newLabel) const override; virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, @@ -1273,7 +1273,7 @@ public: virtual bool referenceChanged() const override; - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -1327,9 +1327,9 @@ public: virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; - virtual void getLinks(std::vector &objs, + virtual void getLinks(std::vector &objs, bool all=false, std::vector *subs=0, bool newStyle=true) const override; - + bool isLinkedToDocument(const App::Document &doc) const; protected: diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index cd2321c3f3..ac036a7aee 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -100,18 +100,18 @@ PyObject *PropertyInteger::getPyObject(void) } void PropertyInteger::setPyObject(PyObject *value) -{ +{ #if PY_MAJOR_VERSION < 3 if (PyInt_Check(value)) { aboutToSetValue(); _lValue = PyInt_AsLong(value); -#else +#else if (PyLong_Check(value)) { aboutToSetValue(); _lValue = PyLong_AsLong(value); #endif hasSetValue(); - } + } else { std::string error = std::string("type must be int, not "); error += value->ob_type->tp_name; @@ -744,7 +744,7 @@ long PropertyIntegerList::getPyValue(PyObject *item) const { if (PyInt_Check(item)) return PyInt_AsLong(item); #else - if (PyLong_Check(item)) + if (PyLong_Check(item)) return PyLong_AsLong(item); #endif std::string error = std::string("type in list must be int, not "); @@ -768,13 +768,13 @@ void PropertyIntegerList::Restore(Base::XMLReader &reader) reader.readElement("IntegerList"); // get the value of my Attribute int count = reader.getAttributeAsInteger("count"); - + std::vector values(count); for(int i = 0; i < count; i++) { reader.readElement("I"); values[i] = reader.getAttributeAsInteger("v"); } - + reader.readEndElement("IntegerList"); //assignment @@ -854,9 +854,9 @@ PyObject *PropertyIntegerSet::getPyObject(void) } void PropertyIntegerSet::setPyObject(PyObject *value) -{ +{ if (PySequence_Check(value)) { - + Py_ssize_t nSize = PySequence_Length(value); std::set values; @@ -912,13 +912,13 @@ void PropertyIntegerSet::Restore(Base::XMLReader &reader) reader.readElement("IntegerSet"); // get the value of my Attribute int count = reader.getAttributeAsInteger("count"); - + std::set values; for(int i = 0; i < count; i++) { reader.readElement("I"); values.insert(reader.getAttributeAsInteger("v")); } - + reader.readEndElement("IntegerSet"); //assignment @@ -1103,7 +1103,7 @@ const PropertyFloatConstraint::Constraints* PropertyFloatConstraint::getConstra } void PropertyFloatConstraint::setPyObject(PyObject *value) -{ +{ if (PyFloat_Check(value)) { double temp = PyFloat_AsDouble(value); if (_ConstStruct) { @@ -1112,7 +1112,7 @@ void PropertyFloatConstraint::setPyObject(PyObject *value) else if (temp < _ConstStruct->LowerBound) temp = _ConstStruct->LowerBound; } - + aboutToSetValue(); _dValue = temp; hasSetValue(); @@ -1130,7 +1130,7 @@ void PropertyFloatConstraint::setPyObject(PyObject *value) else if (temp < _ConstStruct->LowerBound) temp = _ConstStruct->LowerBound; } - + aboutToSetValue(); _dValue = temp; hasSetValue(); @@ -1261,7 +1261,7 @@ void PropertyFloatList::Save (Base::Writer &writer) const writer.Stream() << writer.ind() <<"" << endl ; } else { - writer.Stream() << writer.ind() << "" << std::endl; } } @@ -1366,8 +1366,8 @@ void PropertyString::setValue(const char* newLabel) if(obj && obj->getNameInDocument() && this==&obj->Label && (!obj->getDocument()->testStatus(App::Document::Restoring)|| - obj->getDocument()->testStatus(App::Document::Importing)) && - !obj->getDocument()->isPerformingTransaction()) + obj->getDocument()->testStatus(App::Document::Importing)) && + !obj->getDocument()->isPerformingTransaction()) { // allow object to control label change @@ -1420,7 +1420,7 @@ void PropertyString::setValue(const char* newLabel) break; } if(*c == 0 && std::find(objectLabels.begin(), objectLabels.end(), - obj->getNameInDocument())==objectLabels.end()) + obj->getNameInDocument())==objectLabels.end()) { label = obj->getNameInDocument(); changed = true; @@ -1441,7 +1441,7 @@ void PropertyString::setValue(const char* newLabel) // importing (which also counts as restoring), it is possible the // new object changes its label. However, we cannot update label // references here, because object restoring is not based on - // dependency order. It can only be done in afterRestore(). + // dependency order. It can only be done in afterRestore(). // // See PropertyLinkBase::restoreLabelReference() for more details. propChanges = PropertyLinkBase::updateLabelReferences(obj,newLabel); @@ -1514,7 +1514,7 @@ void PropertyString::Save (Base::Writer &writer) const auto obj = dynamic_cast(getContainer()); writer.Stream() << writer.ind() << "getNameInDocument() && + if(obj && obj->getNameInDocument() && obj->isExporting() && &obj->Label==this) { if(obj->allowDuplicateLabel()) @@ -1809,7 +1809,7 @@ std::string PropertyStringList::getPyValue(PyObject *item) const unsigned int PropertyStringList::getMemSize (void) const { size_t size=0; - for(int i = 0;i(size); } @@ -1838,7 +1838,7 @@ void PropertyStringList::Restore(Base::XMLReader &reader) reader.readElement("String"); values[i] = reader.getAttribute("value"); } - + reader.readEndElement("StringList"); // assignment @@ -1899,7 +1899,7 @@ void PropertyMap::setValues(const std::map& map) -const std::string& PropertyMap::operator[] (const std::string& key) const +const std::string& PropertyMap::operator[] (const std::string& key) const { static std::string empty; std::map::const_iterator it = _lValueList.find(key); @@ -1907,7 +1907,7 @@ const std::string& PropertyMap::operator[] (const std::string& key) const return it->second; else return empty; -} +} PyObject *PropertyMap::getPyObject(void) @@ -1979,7 +1979,7 @@ void PropertyMap::setPyObject(PyObject *value) throw Base::TypeError(error); } } - + setValues(values); } else { @@ -2024,7 +2024,7 @@ void PropertyMap::Restore(Base::XMLReader &reader) reader.readElement("Item"); values[reader.getAttribute("key")] = reader.getAttribute("value"); } - + reader.readEndElement("Map"); // assignment @@ -2325,7 +2325,7 @@ void PropertyColor::setValue(float r, float g, float b, float a) hasSetValue(); } -const Color& PropertyColor::getValue(void) const +const Color& PropertyColor::getValue(void) const { return _cCol; } @@ -2404,7 +2404,7 @@ void PropertyColor::setPyObject(PyObject *value) void PropertyColor::Save (Base::Writer &writer) const { - writer.Stream() << writer.ind() << "" << endl; } @@ -2484,7 +2484,7 @@ Color PropertyColorList::getPyValue(PyObject *item) const { void PropertyColorList::Save (Base::Writer &writer) const { if (!writer.isForceXML()) { - writer.Stream() << writer.ind() << "" << std::endl; } } @@ -2567,7 +2567,7 @@ void PropertyMaterial::setValue(const Material &mat) hasSetValue(); } -const Material& PropertyMaterial::getValue(void) const +const Material& PropertyMaterial::getValue(void) const { return _cMat; } @@ -2633,13 +2633,14 @@ void PropertyMaterial::setPyObject(PyObject *value) void PropertyMaterial::Save (Base::Writer &writer) const { - writer.Stream() << writer.ind() << "" << endl; + << "\" shininess=\"" << _cMat.shininess + << "\" transparency=\"" << _cMat.transparency + << "\"/>" << endl; } void PropertyMaterial::Restore(Base::XMLReader &reader) @@ -2724,7 +2725,7 @@ Material PropertyMaterialList::getPyValue(PyObject *value) const { void PropertyMaterialList::Save(Base::Writer &writer) const { if (!writer.isForceXML()) { - writer.Stream() << writer.ind() << "" << std::endl; } } diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h index c9a4da3021..73e539e5cb 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -58,7 +58,7 @@ public: PropertyInteger(); virtual ~PropertyInteger(); - /** Sets the property + /** Sets the property */ void setValue(long); @@ -86,22 +86,22 @@ protected: }; /** Path properties - * This properties handling file system paths. + * Properties handling file system paths. */ class AppExport PropertyPath: public Property { TYPESYSTEM_HEADER(); public: - + PropertyPath(); virtual ~PropertyPath(); - /** Sets the property + /** Sets the property */ void setValue(const boost::filesystem::path &); - - /** Sets the property + + /** Sets the property */ void setValue(const char *); @@ -110,16 +110,16 @@ public: boost::filesystem::path getValue(void) const; virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyPathItem"; } - + virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - + virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const; protected: @@ -137,11 +137,11 @@ public: /// Obvious constructor PropertyEnumeration(const Enumeration &e); - + /// destructor virtual ~PropertyEnumeration(); - /// Enumeration methods + /// Enumeration methods /*! * These all function as per documentation in Enumeration */ @@ -153,17 +153,17 @@ public: * \endcode */ void setEnums(const char** plEnums); - + /** setting the enumaration string as vector of strings * This makes the enumeration custom. */ void setEnums(const std::vector &Enums); - + /** set the enum by a string * is slower than setValue(long). Use long if possible */ void setValue(const char* value); - + /** set directly the enum value * In DEBUG checks for boundaries. * Is faster than using setValue(const char*). @@ -199,8 +199,8 @@ public: //@} const char* getEditorName(void) const { return _editorTypeName.c_str(); } - void setEditorName(const char* name) { _editorTypeName = name; } - + void setEditorName(const char* name) { _editorTypeName = name; } + virtual PyObject * getPyObject(void); virtual void setPyObject(PyObject *); @@ -219,7 +219,7 @@ private: }; /** Constraint integer properties - * This property fulfills the need of a constraint integer. It holds basically a + * This property fulfills the need of a constraint integer. It holds basically a * state (integer) and a struct of boundaries. If the boundaries * is not set it acts basically like an IntegerProperty and does no checking. * The constraints struct can be created on the heap or build in. @@ -231,11 +231,11 @@ class AppExport PropertyIntegerConstraint: public PropertyInteger public: /// Standard constructor PropertyIntegerConstraint(); - + /// destructor virtual ~PropertyIntegerConstraint(); - /// Constraint methods + /// Constraint methods //@{ /// the boundary struct struct Constraints { @@ -269,7 +269,7 @@ public: bool candelete; }; /** setting the boundaries - * This sets the constraint struct. It can be dynamically + * This sets the constraint struct. It can be dynamically * allocated or set as a static in the class the property * belongs to: * \code @@ -300,13 +300,13 @@ class AppExport PropertyPercent: public PropertyIntegerConstraint public: /// Standard constructor PropertyPercent(); - + /// destructor virtual ~PropertyPercent(); }; /** Integer list properties - * + * */ class AppExport PropertyIntegerList: public PropertyListsT { @@ -330,10 +330,10 @@ public: { return "Gui::PropertyEditor::PropertyIntegerListItem"; } virtual PyObject *getPyObject(void) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; - + virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; virtual unsigned int getMemSize (void) const override; @@ -343,7 +343,7 @@ protected: }; /** Integer list properties - * + * */ class AppExport PropertyIntegerSet: public Property { @@ -363,11 +363,11 @@ public: */ virtual ~PropertyIntegerSet(); - /** Sets the property + /** Sets the property */ void setValue(long); void setValue(void){;} - + void addValue (long value){_lValueSet.insert(value);} void setValues (const std::set& values); @@ -375,10 +375,10 @@ public: virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - + virtual Property *Copy(void) const; virtual void Paste(const Property &from); virtual unsigned int getMemSize (void) const; @@ -388,7 +388,7 @@ private: }; -/** implements a key/value list as property +/** implements a key/value list as property * The key ought to be ASCII the Value should be treated as UTF8 to be saved. */ class AppExport PropertyMap: public Property @@ -396,13 +396,13 @@ class AppExport PropertyMap: public Property TYPESYSTEM_HEADER(); public: - + /** * A constructor. * A more elaborate description of the constructor. */ PropertyMap(); - + /** * A destructor. * A more elaborate description of the destructor. @@ -410,33 +410,33 @@ public: virtual ~PropertyMap(); virtual int getSize(void) const; - - /** Sets the property + + /** Sets the property */ void setValue(void){} void setValue(const std::string& key,const std::string& value); void setValues(const std::map&); - + /// index operator const std::string& operator[] (const std::string& key) const ; - + void set1Value (const std::string& key, const std::string& value){_lValueList.operator[] (key) = value;} - + const std::map &getValues(void) const{return _lValueList;} - + //virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringListItem"; } - + virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - + virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const; - + private: std::map _lValueList; @@ -446,7 +446,7 @@ private: /** Float properties * This is the father of all properties handling floats. - * Use this type only in rare cases. Mostly you want to + * Use this type only in rare cases. Mostly you want to * use the more specialized types like e.g. PropertyLength. * These properties also fulfill the needs of the unit system. * See PropertyUnits.h for all properties with units. @@ -470,20 +470,20 @@ public: void setValue(double lValue); double getValue(void) const; - + virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyFloatItem"; } - + virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - + virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const{return sizeof(double);} - + void setPathValue(const App::ObjectIdentifier &path, const boost::any &value); const boost::any getPathValue(const App::ObjectIdentifier &path) const; @@ -507,15 +507,15 @@ public: * Construct with explicit Values */ PropertyFloatConstraint(void); - + /** * A destructor. * A more elaborate description of the destructor. */ virtual ~PropertyFloatConstraint(); - - /// Constraint methods + + /// Constraint methods //@{ /// the boundary struct struct Constraints { @@ -549,9 +549,9 @@ public: bool candelete; }; /** setting the boundaries - * This sets the constraint struct. It can be dynamcly + * This sets the constraint struct. It can be dynamically * allocated or set as an static in the class the property - * blongs to: + * belongs to: * \code * const Constraints percent = {0.0,100.0,1.0} * \endcode @@ -598,24 +598,24 @@ public: * A more elaborate description of the constructor. */ PropertyFloatList(); - + /** * A destructor. * A more elaborate description of the destructor. */ virtual ~PropertyFloatList(); - + virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyFloatListItem"; } virtual PyObject *getPyObject(void) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; - + virtual void SaveDocFile (Base::Writer &writer) const override; virtual void RestoreDocFile(Base::Reader &reader) override; - + virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; virtual unsigned int getMemSize (void) const override; @@ -639,7 +639,7 @@ public: * A more elaborate description of the constructor. */ PropertyString(void); - + /** * A destructor. * A more elaborate description of the destructor. @@ -652,11 +652,11 @@ public: const std::string& getStrValue(void) const { return _cValue; } bool isEmpty(void){return _cValue.empty();} - + virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringItem"; } virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); @@ -672,7 +672,7 @@ protected: }; /** UUID properties - * This property handles unique identifieers + * This property handles unique identifieers */ class AppExport PropertyUUID: public Property { @@ -685,7 +685,7 @@ public: * A more elaborate description of the constructor. */ PropertyUUID(void); - + /** * A destructor. * A more elaborate description of the destructor. @@ -698,11 +698,11 @@ public: void setValue(const std::string &sString); const std::string& getValueStr(void) const; const Base::Uuid& getValue(void) const; - + //virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringItem"; } virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); @@ -734,13 +734,13 @@ class AppExport PropertyStringList: public PropertyListsT typedef PropertyListsT inherited; public: - + /** * A constructor. * A more elaborate description of the constructor. */ PropertyStringList(); - + /** * A destructor. * A more elaborate description of the destructor. @@ -749,20 +749,20 @@ public: void setValues(const std::list&); using inherited::setValues; - + virtual const char* getEditorName(void) const override { return "Gui::PropertyEditor::PropertyStringListItem"; } - + virtual PyObject *getPyObject(void) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; - + virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; - + virtual unsigned int getMemSize (void) const override; - + protected: std::string getPyValue(PyObject *item) const override; }; @@ -781,29 +781,29 @@ public: * A more elaborate description of the constructor. */ PropertyBool(void); - + /** * A destructor. * A more elaborate description of the destructor. */ virtual ~PropertyBool(); - + void setValue(bool lValue); bool getValue(void) const; - + virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyBoolItem"; } - + virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const{return sizeof(bool);} - + void setPathValue(const App::ObjectIdentifier &path, const boost::any &value); const boost::any getPathValue(const App::ObjectIdentifier &path) const; @@ -812,7 +812,7 @@ private: }; /** Bool list properties - * + * */ class AppExport PropertyBoolList : public PropertyListsT > { @@ -825,10 +825,10 @@ public: virtual PyObject *getPyObject(void) override; virtual void setPyObject(PyObject *) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; - + virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; virtual unsigned int getMemSize (void) const override; @@ -851,14 +851,14 @@ public: * A more elaborate description of the constructor. */ PropertyColor(); - + /** * A destructor. * A more elaborate description of the destructor. */ virtual ~PropertyColor(); - /** Sets the property + /** Sets the property */ void setValue(const Color &col); void setValue(float r, float g, float b, float a=0.0f); @@ -869,18 +869,18 @@ public: const Color &getValue(void) const; virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyColorItem"; } - + virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - + virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const{return sizeof(Color);} - + private: Color _cCol; @@ -891,7 +891,7 @@ class AppExport PropertyColorList: public PropertyListsT TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - + /** * A constructor. * A more elaborate description of the constructor. @@ -905,13 +905,13 @@ public: virtual ~PropertyColorList(); virtual PyObject *getPyObject(void) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; - + virtual void SaveDocFile (Base::Writer &writer) const override; virtual void RestoreDocFile(Base::Reader &reader) override; - + virtual Property *Copy(void) const override; virtual void Paste(const Property &from) override; virtual unsigned int getMemSize (void) const override; @@ -928,7 +928,7 @@ class AppExport PropertyMaterial : public Property TYPESYSTEM_HEADER(); public: - + /** * A constructor. * A more elaborate description of the constructor. @@ -940,8 +940,8 @@ public: * A more elaborate description of the destructor. */ virtual ~PropertyMaterial(); - - /** Sets the property + + /** Sets the property */ void setValue(const Material &mat); void setAmbientColor(const Color& col); @@ -950,14 +950,14 @@ public: void setEmissiveColor(const Color& col); void setShininess(float); void setTransparency(float); - + /** This method returns a string representation of the property */ const Material &getValue(void) const; virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); - + virtual void Save (Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); @@ -965,9 +965,9 @@ public: virtual Property *Copy(void) const; virtual void Paste(const Property &from); - + virtual unsigned int getMemSize (void) const{return sizeof(_cMat);} - + private: Material _cMat; }; @@ -1022,7 +1022,7 @@ class AppExport PropertyPersistentObject: public PropertyString { public: virtual PyObject *getPyObject(void) override; virtual void setValue(const char* type) override; - + virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; diff --git a/src/App/PropertyUnits.h b/src/App/PropertyUnits.h index 4a5643c7d0..5421c13acc 100644 --- a/src/App/PropertyUnits.h +++ b/src/App/PropertyUnits.h @@ -45,7 +45,7 @@ namespace App { /** Float with Unit property - * This is a property for float with a predefined Unit associated . + * This is a property for float with a predefined Unit associated. */ class AppExport PropertyQuantity : public PropertyFloat { @@ -77,7 +77,7 @@ protected: }; /** Float with Unit property - * This is a property for float with a predefined Unit associated . + * This is a property for float with a predefined Unit associated. */ class AppExport PropertyQuantityConstraint : public PropertyQuantity { @@ -87,16 +87,16 @@ public: PropertyQuantityConstraint(void):_ConstStruct(0){} virtual ~PropertyQuantityConstraint(){} - /// Constraint methods + /// Constraint methods //@{ /// the boundary struct struct Constraints { double LowerBound, UpperBound, StepSize; }; /** setting the boundaries - * This sets the constraint struct. It can be dynamically + * This sets the constraint struct. It can be dynamically * allocated or set as an static in the class the property - * blongs to: + * belongs to: * \code * const Constraints percent = {0.0,100.0,1.0} * \endcode @@ -167,7 +167,7 @@ public: * property. On the Gui it has a quantity like RAD. */ class AppExport PropertyAngle: public PropertyQuantityConstraint -{ +{ TYPESYSTEM_HEADER(); public: PropertyAngle(void);