App: Fix header uniformity, trailing whitespace, and doxygen headers

This commit is contained in:
luz paz
2020-11-18 15:17:49 -05:00
committed by wwmayer
parent ad8d83a71b
commit 84553bf191
57 changed files with 886 additions and 850 deletions

View File

@@ -802,9 +802,9 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
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<std::string> &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));
}

View File

@@ -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<Document*> openDocuments(const std::vector<std::string> &filenames,
std::vector<Document*> openDocuments(const std::vector<std::string> &filenames,
const std::vector<std::string> *paths=0,
const std::vector<std::string> *labels=0,
std::vector<std::string> *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<void (const App::Document&, const App::Property&)> 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]
/*!

View File

@@ -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<DocumentObjectPy*>(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;i<ret.size();++i)
for(size_t i=0;i<ret.size();++i)
tuple.setItem(i,Py::Object(ret[i]->getPyObject(),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;

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2019 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* 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)

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2019 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* 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);

View File

@@ -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

View File

@@ -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);

View File

@@ -141,5 +141,5 @@ PyObject *ComplexGeoDataPy::getCustomAttributes(const char* /*attr*/) const
int ComplexGeoDataPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -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<DocumentObject*,Vertex> VertexObjectList;
std::map<Vertex,DocumentObject*> vertexMap;
#endif //USE_OLD_DAG
std::multimap<const App::DocumentObject*,
std::multimap<const App::DocumentObject*,
std::unique_ptr<App::DocumentObjectExecReturn> > _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<App::DocumentObject*>& 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<App::DocumentObject*>& 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<std::string,bool> &objs,
const std::unordered_map<std::string,DepInfo> &deps)
static void _loadDeps(const std::string &name,
std::unordered_map<std::string,bool> &objs,
const std::unordered_map<std::string,DepInfo> &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<DocumentObject *> &objArray, bool checkPartial)
bool Document::afterRestore(const std::vector<DocumentObject *> &objArray, bool checkPartial)
{
checkPartial = checkPartial && testStatus(Document::PartialDoc);
if(checkPartial && d->touchedObjs.size())
@@ -2797,7 +2797,7 @@ bool Document::afterRestore(const std::vector<DocumentObject *> &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<DocumentObject *> &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<int>(d->objectArray.size());
}
void Document::getLinksTo(std::set<DocumentObject*> &links,
void Document::getLinksTo(std::set<DocumentObject*> &links,
const DocumentObject *obj, int options, int maxCount,
const std::vector<DocumentObject*> &objs) const
const std::vector<DocumentObject*> &objs) const
{
std::map<const App::DocumentObject*, std::vector<App::DocumentObject*> > linkMap;
@@ -2968,7 +2968,7 @@ void Document::getLinksTo(std::set<DocumentObject*> &links,
linked = o->getLinkedObject(false);
else {
auto ext = o->getExtensionByType<LinkBaseExtension>(true);
if(ext)
if(ext)
linked = ext->getTrueLinkedObject(false,0,0,true);
else
linked = o->getLinkedObject(false);
@@ -3052,8 +3052,8 @@ std::vector<App::DocumentObject*> Document::getInList(const DocumentObject* me)
// external object.
//
static void _buildDependencyList(const std::vector<App::DocumentObject*> &objectArray,
int options, std::vector<App::DocumentObject*> *depObjs,
DependencyList *depList, std::map<DocumentObject*,Vertex> *objectMap,
int options, std::vector<App::DocumentObject*> *depObjs,
DependencyList *depList, std::map<DocumentObject*,Vertex> *objectMap,
bool *touchCheck = 0)
{
std::map<DocumentObject*, std::vector<DocumentObject*> > outLists;
@@ -3132,7 +3132,7 @@ std::vector<App::DocumentObject*> Document::getDependencyList(
std::map<int,std::vector<Vertex> > 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<c.size();++i)
for(size_t i=0;i<c.size();++i)
components[c[i]].push_back(i);
FC_ERR("Dependency cycles: ");
@@ -3184,7 +3184,7 @@ std::vector<App::Document*> Document::getDependentDocuments(bool sort) {
}
std::vector<App::Document*> Document::getDependentDocuments(
std::vector<App::Document*> pending, bool sort)
std::vector<App::Document*> pending, bool sort)
{
DependencyList depList;
std::map<Document*,Vertex> docMap;
@@ -3409,7 +3409,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
#else //ifdef USE_OLD_DAG
int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool force, bool *hasError, int options)
int Document::recompute(const std::vector<App::DocumentObject*> &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<App::DocumentObject*> &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<App::DocumentObject*> &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<App::DocumentObject*> &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;i<topoSortedObjects.size();++i) {
auto obj = topoSortedObjects[i];
obj->setStatus(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::BaseClass*>(Base::Type::createInstanceByName(sType,true));
@@ -4331,7 +4331,7 @@ std::vector<DocumentObject*> Document::copyObject(
return result;
}
std::vector<App::DocumentObject*>
std::vector<App::DocumentObject*>
Document::importLinks(const std::vector<App::DocumentObject*> &objArray)
{
std::set<App::DocumentObject*> links;
@@ -4395,7 +4395,7 @@ Document::importLinks(const std::vector<App::DocumentObject*> &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<App::DocumentObject*> 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.

View File

@@ -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<std::string> &objNames={});
void afterRestore(bool checkPartial=false);
bool afterRestore(const std::vector<App::DocumentObject *> &, 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<App::DocumentObject*> 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<DocumentObject*> &links,
void getLinksTo(std::set<DocumentObject*> &links,
const DocumentObject *obj, int options, int maxCount=0,
const std::vector<DocumentObject*> &objs = {}) const;

View File

@@ -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<App::DocumentObject*> &inSet,
void getInListEx(std::set<App::DocumentObject*> &inSet,
bool recursive, std::vector<App::DocumentObject*> *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<std::pair<App::DocumentObject*,std::string> > 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

View File

@@ -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<const DocumentObject*>(getExtendedContainer());
}
DocumentObject* DocumentObjectExtension::getExtendedObject() {
assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId()));
assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId()));
return static_cast<DocumentObject*>(getExtendedContainer());
}
bool DocumentObjectExtension::extensionGetSubObject(DocumentObject *&,
bool DocumentObjectExtension::extensionGetSubObject(DocumentObject *&,
const char *, PyObject **, Base::Matrix4D *, bool, int) const
{
return false;

View File

@@ -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

View File

@@ -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");
}

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;
};

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;i<ret.size();++i)
for (size_t i=0;i<ret.size();++i)
tuple.setItem(i,Py::Object(ret[i]->getPyObject(),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<DocumentObjectPy*>(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;i<ret.size();++i)
for (size_t i=0;i<ret.size();++i)
tuple.setItem(i,Py::Object(ret[i]->getPyObject(),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<DocumentObject*>::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<Base::Type> 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<DocumentObject*> 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

View File

@@ -85,7 +85,7 @@ std::vector<std::string> DynamicProperty::getDynamicPropertyNames() const
std::vector<std::string> 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::BaseClass*>(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<Property*>(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;

View File

@@ -1,6 +1,6 @@
/****************************************************************************
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* Copyright (c) 2019 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* 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<Expression *> _args = std::vector<Expression*>());
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<ObjectIdentifier,ObjectIdentifier> &,
virtual bool _renameObjectIdentifier(const std::map<ObjectIdentifier,ObjectIdentifier> &,
const ObjectIdentifier &, ExpressionVisitor &) override;
virtual void _collectReplacement(std::map<ObjectIdentifier,ObjectIdentifier> &,
const App::DocumentObject *parent, App::DocumentObject *oldObj,
virtual void _collectReplacement(std::map<ObjectIdentifier,ObjectIdentifier> &,
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<ObjectIdentifier,ObjectIdentifier> &,
virtual bool _renameObjectIdentifier(const std::map<ObjectIdentifier,ObjectIdentifier> &,
const ObjectIdentifier &, ExpressionVisitor &) override;
virtual void _moveCells(const CellAddress &, int, int, ExpressionVisitor &) override;
virtual void _offsetCells(int, int, ExpressionVisitor &) override;

View File

@@ -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 <FreeCAD@juergen-riegel.net> *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* 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<std::string, FunctionExpression::Function>::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;
}

View File

@@ -1,2 +1,3 @@
# Description for bash script
flex -olex.ExpressionParser.c < ExpressionParser.l
bison -oExpressionParser.tab.c ExpressionParser.y

View File

@@ -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 <FreeCAD@juergen-riegel.net> *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* 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

View File

@@ -34,9 +34,9 @@
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <ExtensionPy.h>
/* 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<Property*> 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() );

View File

@@ -31,7 +31,7 @@
#include <CXX/Objects.hxx>
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<MyExtension> 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<typename ExtensionT> 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<MyExtensionPythonT<MyExtension>> 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<App::Extension> 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<App::Extension> ExtensionPython;
Base::PyException e;\
e.ReportException();\
}
#define EXTENSION_PROXY_NOARG(function)\
EXTENSION_PROXY_FIRST(function) \
Py::Tuple args;\
@@ -401,13 +401,13 @@ typedef ExtensionPythonT<App::Extension> 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

View File

@@ -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_)

View File

@@ -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<Base::MatrixPy*>(seq.getItem(1).ptr())->getMatrixPtr();
if(pyObj) {
if(seq.length()>2)
@@ -315,7 +315,7 @@ bool FeaturePythonImp::getSubObjects(std::vector<std::string> &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<Base::MatrixPy*>(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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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 <juergen.riegel@web.de> *
#* Copyright (c) 2001,2002 Jürgen Riegel <juergen.riegel@web.de> *
#* *
#* 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)

View File

@@ -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 <juergen.riegel@web.de> *
#* *
@@ -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")

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2017 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2017 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* 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 = "<null>";
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<std::string> &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<Data::ComplexGeoDataPy*>(*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<const LinkElement*>(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.size();++i) {
auto element = freecad_dynamic_cast<LinkElement>(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<PropertyXLink>(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<std::string> &subElements)
void LinkBaseExtension::setLink(int index, DocumentObject *obj,
const char *subname, const std::vector<std::string> &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;
}

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2017 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2017 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* 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<std::string>&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<std::string> mySubElements;
mutable std::string mySubName;
std::unordered_map<const App::DocumentObject*,
std::unordered_map<const App::DocumentObject*,
boost::signals2::scoped_connection> 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);

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2017 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* Copyright (c) 2017 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -43,8 +43,8 @@ std::string LinkBaseExtensionPy::representation(void) const
typedef std::map<std::string, std::pair<int,Property*> > PropTmpMap;
typedef std::map<std::string, Property*> 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<seq.size();++i)
for(size_t i=0;i<seq.size();++i)
parseLink(ext,i,seq[i].ptr());
}else
parseLink(ext,-1,_args);

View File

@@ -34,7 +34,7 @@ using namespace App;
PROPERTY_SOURCE(App::MaterialObject, App::DocumentObject)
MaterialObject::MaterialObject()
MaterialObject::MaterialObject()
{
ADD_PROPERTY_TYPE(Material,(),"Material",Prop_None,"Material key/value map");

View File

@@ -33,7 +33,7 @@ using namespace App;
PROPERTY_SOURCE(App::MeasureDistance, App::DocumentObject)
MeasureDistance::MeasureDistance()
MeasureDistance::MeasureDistance()
{
ADD_PROPERTY_TYPE(P1,(Base::Vector3d()),"Measurement",Prop_None,"First point of measurement");
ADD_PROPERTY_TYPE(P2,(Base::Vector3d()),"Measurement",Prop_None,"Second point of measurement");

View File

@@ -82,11 +82,11 @@ public:
// Constructor
String(const std::string & s = "", bool _isRealString = false, bool _forceIdentifier = false)
: str(s), isString(_isRealString), forceIdentifier(_forceIdentifier)
: str(s), isString(_isRealString), forceIdentifier(_forceIdentifier)
{ }
String(std::string &&s, bool _isRealString = false, bool _forceIdentifier = false)
: str(std::move(s)), isString(_isRealString), forceIdentifier(_forceIdentifier)
: str(std::move(s)), isString(_isRealString), forceIdentifier(_forceIdentifier)
{ }
FC_DEFAULT_CTORS(String) {
@@ -125,7 +125,7 @@ public:
bool operator>(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<std::string> 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<App::ObjectIdentifier> {
typedef App::ObjectIdentifier argument_type;
typedef std::size_t result_type;

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tr<EFBFBD>ger <stefantroeger@gmx.net> *
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *

View File

@@ -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<OriginGroupExtension*>(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<App::PropertyLink*>(prop);
if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId()))
continue;
p->setValue(getOrigin()->getOriginFeature(static_cast<OriginFeature*>(p->getValue())->Role.getValue()));
}
}
else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
auto p = static_cast<App::PropertyLinkList*>(prop);
auto vec = p->getValues();
@@ -205,7 +205,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
auto p = static_cast<App::PropertyLinkSub*>(prop);
if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId()))
continue;
std::vector<std::string> subValues = p->getSubValues();
p->setValue(getOrigin()->getOriginFeature(static_cast<OriginFeature*>(p->getValue())->Role.getValue()), subValues);
}

View File

@@ -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<DocumentObject*> addObjects(std::vector<DocumentObject*> obj) override;
virtual bool hasObject(const DocumentObject* obj, bool recursive = false) const override;

View File

@@ -50,7 +50,7 @@ PyObject *OriginGroupExtensionPy::getCustomAttributes(const char* /*attr*/) cons
int OriginGroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -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()))

View File

@@ -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);

View File

@@ -49,7 +49,6 @@ PyObject *PartPy::getCustomAttributes(const char* /*attr*/) const
int PartPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -34,7 +34,7 @@ namespace App
/** Base class of all geometric document objects.
*/
class AppExport Path
class AppExport Path
{
protected:
std::vector<Base::Persistence *> _PathVector;

View File

@@ -21,14 +21,12 @@
***************************************************************************/
#ifndef _AppPlacement_h_
#define _AppPlacement_h_
#include <Base/Placement.h>
#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<App::Placement> PlacementPython;
typedef App::FeaturePythonT<App::Placement> PlacementPython;
@@ -76,4 +74,4 @@ typedef App::FeaturePythonT<App::Placement> PlacementPython;
#endif
#endif

View File

@@ -63,7 +63,7 @@
#include <iostream>
#include <sstream>
// STL
// STL
#include <string>
#include <list>
#include <map>

View File

@@ -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<<PropDynamic)
|(1<<PropNoRecompute)
|(1<<PropReadOnly)
@@ -287,13 +287,13 @@ void PropertyListsBase::_setPyObject(PyObject *value) {
const auto &item = *it;
PyObject *key = item.first.ptr();
#if PY_MAJOR_VERSION < 3
if(!PyInt_Check(key))
if(!PyInt_Check(key))
#else
if(!PyLong_Check(key))
#endif
throw Base::TypeError("expect key type to be integer");
long idx = PyLong_AsLong(key);
if(idx<-1 || idx>listSize)
if(idx<-1 || idx>listSize)
throw Base::ValueError("index out of bound");
if(idx==-1 || idx==listSize) {
idx = listSize;

View File

@@ -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;} \

View File

@@ -1,4 +1,3 @@
/***************************************************************************
* Copyright (c) 2007 Jürgen Riegel <juergen.riegel@web.de> *
* *
@@ -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<PropertyContainerPy*>(this)));
auto res = PyObject_CallObject(_getShape, args.ptr());
if(!res)
if(!res)
PyErr_Clear();
else {
Py::Object pyres(res,true);

File diff suppressed because it is too large Load Diff

View File

@@ -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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *subs=0, bool newStyle=true) const = 0;
/** Called to reset this link property
@@ -203,8 +203,8 @@ public:
*/
virtual bool adjustLink(const std::set<App::DocumentObject *> &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<App::DocumentObject*, std::vector<std::string> > &elements,
bool newStyle=true, bool all=true) const
void getLinkedElements(std::map<App::DocumentObject*, std::vector<std::string> > &elements,
bool newStyle=true, bool all=true) const
{
std::vector<App::DocumentObject*> ret;
std::vector<std::string> subs;
@@ -279,8 +279,8 @@ public:
}
/// Helper function to return a map of linked object and its subname references
std::map<App::DocumentObject*, std::vector<std::string> >
linkedElements(bool newStyle=true, bool all=true) const
std::map<App::DocumentObject*, std::vector<std::string> >
linkedElements(bool newStyle=true, bool all=true) const
{
std::map<App::DocumentObject*, std::vector<std::string> > ret;
getLinkedElements(ret,newStyle,all);
@@ -320,8 +320,8 @@ public:
* and correct any link sub reference.
*/
static std::pair<App::DocumentObject*,std::string> 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<App::DocumentObject*, std::vector<std::string> >
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<std::string> &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<std::string,std::string> &nameMap);
static std::string tryImportSubName(const App::DocumentObject *obj, const char *sub,
const App::Document *doc, const std::map<std::string,std::string> &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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *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<DocumentObject*,std::vector<DocumentObject*>, 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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *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<std::string>& getSubValues(void) const;
/// return the list of sub elements with mapped names
@@ -809,7 +809,7 @@ public:
std::vector<std::string> 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<std::string> 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<std::string,std::string> &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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *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<std::string,std::string> &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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *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<std::string> &&SubList,
std::vector<ShadowSub> &&ShadowSubList = {});
void setValue(App::DocumentObject *,const std::vector<std::string> &SubList,
void setValue(App::DocumentObject *,const std::vector<std::string> &SubList,
std::vector<ShadowSub > &&ShadowSubList={});
void setSubValues(std::vector<std::string> &&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<std::string,std::string> &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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *subs=0, bool newStyle=true) const override;
virtual bool adjustLink(const std::set<App::DocumentObject *> &inList) override;
@@ -1260,7 +1260,7 @@ public:
virtual Property *CopyOnImportExternal(const std::map<std::string,std::string> &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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *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<App::DocumentObject *> &objs,
virtual void getLinks(std::vector<App::DocumentObject *> &objs,
bool all=false, std::vector<std::string> *subs=0, bool newStyle=true) const override;
bool isLinkedToDocument(const App::Document &doc) const;
protected:

View File

@@ -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<long> 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<long> 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<long> 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() <<"</FloatList>" << endl ;
}
else {
writer.Stream() << writer.ind() << "<FloatList file=\"" <<
writer.Stream() << writer.ind() << "<FloatList file=\"" <<
(getSize()?writer.addFile(getName(), this):"") << "\"/>" << 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<DocumentObject*>(getContainer());
writer.Stream() << writer.ind() << "<String ";
bool exported = false;
if(obj && obj->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<getSize(); i++)
for(int i = 0;i<getSize(); i++)
size += _lValueList[i].size();
return static_cast<unsigned int>(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<std::string,std::string>& 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<std::string,std::string>::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() << "<PropertyColor value=\""
writer.Stream() << writer.ind() << "<PropertyColor value=\""
<< _cCol.getPackedValue() <<"\"/>" << 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() << "<ColorList file=\"" <<
writer.Stream() << writer.ind() << "<ColorList file=\"" <<
(getSize()?writer.addFile(getName(), this):"") << "\"/>" << 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() << "<PropertyMaterial ambientColor=\""
<< _cMat.ambientColor.getPackedValue()
<< "\" diffuseColor=\"" << _cMat.diffuseColor.getPackedValue()
writer.Stream() << writer.ind() << "<PropertyMaterial ambientColor=\""
<< _cMat.ambientColor.getPackedValue()
<< "\" diffuseColor=\"" << _cMat.diffuseColor.getPackedValue()
<< "\" specularColor=\"" << _cMat.specularColor.getPackedValue()
<< "\" emissiveColor=\"" << _cMat.emissiveColor.getPackedValue()
<< "\" shininess=\"" << _cMat.shininess << "\" transparency=\""
<< _cMat.transparency << "\"/>" << 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() << "<MaterialList file=\"" <<
writer.Stream() << writer.ind() << "<MaterialList file=\"" <<
(getSize()?writer.addFile(getName(), this):"") << "\"/>" << std::endl;
}
}

View File

@@ -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<std::string> &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<long>
{
@@ -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<long>& 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<std::string,std::string>&);
/// 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<std::string,std::string> &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<std::string,std::string> _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<std::string>
typedef PropertyListsT<std::string> 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<std::string>&);
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<bool,boost::dynamic_bitset<> >
{
@@ -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<Color>
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;

View File

@@ -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);