本文整理汇总了C++中DocumentObject类的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject类的具体用法?C++ DocumentObject怎么用?C++ DocumentObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocumentObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v
void PropertyExpressionEngine::slotObjectRenamed(const DocumentObject &obj)
{
#ifdef FC_PROPERTYEXPRESSIONENGINE_LOG
std::clog << "Object " << obj.getOldLabel() << " renamed to " << obj.Label.getValue() << std::endl;
#endif
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
/* In a document object, and on undo stack? */
if (!docObj || docObj->getNameInDocument() == 0)
return;
RelabelDocumentObjectExpressionVisitor v(boost::bind( &PropertyExpressionEngine::aboutToSetValue, this),
boost::bind( &PropertyExpressionEngine::hasSetValue, this),
obj.getOldLabel(), obj.Label.getStrValue());
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
int changed = v.getChanged();
it->second.expression->visit(v);
if (changed != v.getChanged())
expressionChanged(it->first);
}
}
示例2: assert
void PropertyLink::Restore(Base::XMLReader &reader)
{
// read my element
reader.readElement("Link");
// get the value of my attribute
std::string name = reader.getAttribute("value");
// Property not in a DocumentObject!
assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) );
if (name != "") {
DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
App::Document* document = parent->getDocument();
DocumentObject* object = document ? document->getObject(name.c_str()) : 0;
if (!object) {
if (reader.isVerbose()) {
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
}
}
else if (parent == object) {
if (reader.isVerbose()) {
Base::Console().Warning("Object '%s' links to itself, nullify it\n",name.c_str());
}
object = 0;
}
setValue(object);
}
else {
setValue(0);
}
}
示例3: getDocumentPtr
Py::Object DocumentPy::getActiveObject(void) const
{
DocumentObject *pcFtr = getDocumentPtr()->getActiveObject();
if(pcFtr)
return Py::Object(pcFtr->getPyObject(), true);
return Py::None();
}
示例4: Restore
void PropertyLinkSubList::Restore(Base::XMLReader &reader)
{
// read my element
reader.readElement("LinkSubList");
// get the value of my attribute
int count = reader.getAttributeAsInteger("count");
std::vector<DocumentObject*> values;
values.reserve(count);
std::vector<std::string> SubNames;
SubNames.reserve(count);
for (int i = 0; i < count; i++) {
reader.readElement("Link");
std::string name = reader.getAttribute("obj");
// In order to do copy/paste it must be allowed to have defined some
// referenced objects in XML which do not exist anymore in the new
// document. Thus, we should silently ignore this.
// Property not in an object!
DocumentObject* father = static_cast<DocumentObject*>(getContainer());
App::Document* document = father->getDocument();
DocumentObject* child = document ? document->getObject(name.c_str()) : 0;
if (child)
values.push_back(child);
else if (reader.isVerbose())
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
std::string subName = reader.getAttribute("sub");
SubNames.push_back(subName);
}
reader.readEndElement("LinkSubList");
// assignment
setValues(values,SubNames);
}
示例5: representation
// returns a string which represent the object e.g. when printed in python
std::string DocumentObjectPy::representation(void) const
{
DocumentObject* object = this->getDocumentObjectPtr();
std::stringstream str;
str << "<" << object->getTypeId().getName() << " object>";
return str.str();
}
示例6:
boost::shared_ptr<App::Expression> ExpressionBinding::getExpression() const
{
DocumentObject * docObj = path.getDocumentObject();
Q_ASSERT(isBound() && docObj != 0);
return docObj->getExpression(path).expression;
}
示例7: getName
Py::String DocumentObjectPy::getName(void) const
{
DocumentObject* object = this->getDocumentObjectPtr();
const char* internal = object->getNameInDocument();
if (!internal) {
throw Py::RuntimeError(std::string("This object is currently not part of a document"));
}
return Py::String(std::string(internal));
}
示例8: getExtendedObject
DocumentObject* GroupExtension::addObject(const char* sType, const char* pObjectName)
{
DocumentObject* obj = getExtendedObject()->getDocument()->addObject(sType, pObjectName);
if(!allowObject(obj)) {
getExtendedObject()->getDocument()->remObject(obj->getNameInDocument());
return nullptr;
}
if (obj) addObject(obj);
return obj;
}
示例9: getDocument
Py::Object DocumentObjectPy::getDocument(void) const
{
DocumentObject* object = this->getDocumentObjectPtr();
Document* doc = object->getDocument();
if (!doc) {
return Py::None();
}
else {
return Py::Object(doc->getPyObject(), true);
}
}
示例10: getDocumentObjectGroupPtr
PyObject* DocumentObjectGroupPy::getObject(PyObject *args)
{
char* pcName;
if (!PyArg_ParseTuple(args, "s", &pcName)) // convert args: Python->C
return NULL; // NULL triggers exception
DocumentObject* obj = getDocumentObjectGroupPtr()->getObject(pcName);
if ( obj ) {
return obj->getPyObject();
} else {
Py_Return;
}
}
示例11: getSize
void PropertyLinkList::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<LinkList count=\"" << getSize() << "\">" << endl;
writer.incInd();
for (int i = 0; i<getSize(); i++) {
DocumentObject* obj = _lValueList[i];
if (obj)
writer.Stream() << writer.ind() << "<Link value=\"" << obj->getNameInDocument() << "\"/>" << endl;
else
writer.Stream() << writer.ind() << "<Link value=\"\"/>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</LinkList>" << endl;
}
示例12: v
void PropertyExpressionEngine::slotObjectRenamed(const DocumentObject &obj)
{
#ifdef FC_PROPERTYEXPRESSIONENGINE_LOG
std::clog << "Object " << obj.getOldLabel() << " renamed to " << obj.Label.getValue() << std::endl;
#endif
RelabelDocumentObjectExpressionVisitor v(obj.getOldLabel(), obj.Label.getStrValue());
aboutToSetValue();
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it)
it->second.expression->visit(v);
hasSetValue();
}
示例13: getDocumentPtr
PyObject* DocumentPy::copyObject(PyObject *args)
{
PyObject *obj, *rec=0;
if (!PyArg_ParseTuple(args, "O!|O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec))
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(), rec==Py_True);
if (copy) {
return copy->getPyObject();
}
else {
std::string str("Failed to copy the object");
throw Py::Exception(PyExc_Exception,str);
}
}
示例14: getState
Py::List DocumentObjectPy::getState(void) const
{
DocumentObject* object = this->getDocumentObjectPtr();
Py::List list;
bool uptodate = true;
if (object->isTouched()) {
uptodate = false;
list.append(Py::String("Touched"));
}
if (object->isError()) {
uptodate = false;
list.append(Py::String("Invalid"));
}
if (uptodate) {
list.append(Py::String("Up-to-date"));
}
return list;
}
示例15: slotObjectDeleted
void PropertyExpressionEngine::slotObjectDeleted(const DocumentObject &obj)
{
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
/* In a document object, and on undo stack? */
if (!docObj || docObj->getNameInDocument() == 0)
return;
ObjectDeletedExpressionVisitor v(&obj);
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
it->second.expression->visit(v);
if (v.isFound()) {
touch(); // Touch to force recompute; that will trigger a proper error
return;
}
}
}