当前位置: 首页>>代码示例>>C++>>正文


C++ DocumentObject::getDocument方法代码示例

本文整理汇总了C++中app::DocumentObject::getDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getDocument方法的具体用法?C++ DocumentObject::getDocument怎么用?C++ DocumentObject::getDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app::DocumentObject的用法示例。


在下文中一共展示了DocumentObject::getDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: list

PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
    PyObject *object;
    char* subname=0;
    float x=0,y=0,z=0;
    if (PyArg_ParseTuple(args, "O!|sfff", &(App::DocumentObjectPy::Type),&object,&subname,&x,&y,&z)) {
        App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
        App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
        if (!docObj || !docObj->getNameInDocument()) {
            PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
            return NULL;
        }

        Selection().addSelection(docObj->getDocument()->getName(),
                                 docObj->getNameInDocument(),
                                 subname,x,y,z);
        Py_Return;
    }

    PyErr_Clear();
    PyObject *sequence;
    if (PyArg_ParseTuple(args, "O!O", &(App::DocumentObjectPy::Type),&object,&sequence)) {
        App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
        App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
        if (!docObj || !docObj->getNameInDocument()) {
            PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
            return NULL;
        }

        try {
            if (PyTuple_Check(sequence) || PyList_Check(sequence)) {
                Py::Sequence list(sequence);
                for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
                    std::string subname = static_cast<std::string>(Py::String(*it));
                    Selection().addSelection(docObj->getDocument()->getName(),
                                             docObj->getNameInDocument(),
                                             subname.c_str());
                }

                Py_Return;
            }
        }
        catch (const Py::Exception&) {
            // do nothing here
        }
    }

    PyErr_SetString(PyExc_ValueError, "type must be 'DocumentObject[,subname[,x,y,z]]' or 'DocumentObject, list or tuple of subnames'");
    return 0;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:50,代码来源:Selection.cpp

示例2: addExternal

PyObject* SketchObjectPy::addExternal(PyObject *args)
{
    char *ObjectName;
    char *SubName;
    if (!PyArg_ParseTuple(args, "ss:Give an object and subelement name", &ObjectName,&SubName))
        return 0;

    // get the target object for the external link
    Sketcher::SketchObject* skObj = this->getSketchObjectPtr();
    App::DocumentObject * Obj = skObj->getDocument()->getObject(ObjectName);
    if (!Obj) {
        std::stringstream str;
        str << ObjectName << " does not exist in the document";
        PyErr_SetString(PyExc_ValueError, str.str().c_str());
        return 0;
    }
    // check if this type of external geometry is allowed
    if (!skObj->isExternalAllowed(Obj->getDocument(), Obj)) {
        std::stringstream str;
        str << ObjectName << " is not allowed as external geometry of this sketch";
        PyErr_SetString(PyExc_ValueError, str.str().c_str());
        return 0;
    }

    // add the external
    if (skObj->addExternal(Obj,SubName) < 0) {
        std::stringstream str;
        str << "Not able to add external shape element";
        PyErr_SetString(PyExc_ValueError, str.str().c_str());
        return 0;
    }

    Py_Return;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:34,代码来源:SketchObjectPyImp.cpp

示例3: getPyReprString

const string PropertyLinkSubList::getPyReprString()
{
    assert(this->_lValueList.size() == this->_lSubList.size());

    if (this->_lValueList.size() == 0)
        return std::string("None");

    std::stringstream strm;
    strm << "[";
    for (std::size_t i = 0; i < this->_lSubList.size(); i++) {
        if (i>0)
            strm << ",(";
        else
            strm << "(";
        App::DocumentObject* obj = this->_lValueList[i];
        if (obj) {
            strm << "App.getDocument('" << obj->getDocument()->getName() << "')." << obj->getNameInDocument();
        } else {
            strm << "None";
        }
        strm << ",";
        strm << "'" << this->_lSubList[i] << "'";
        strm << ")";
    }
    strm << "]";
    return strm.str();
}
开发者ID:ulrich1a,项目名称:FreeCAD_sf_master,代码行数:27,代码来源:PropertyLinks.cpp

示例4:

void Gui::ActiveObjectList::setObject(App::DocumentObject* obj, const char* name, const Gui::HighlightMode& mode)
{
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
    bool autoExpand = hGrp->GetBool("TreeActiveAutoExpand", true);

    if (hasObject(name)) {
        App::DocumentObject* act = getObject<App::DocumentObject*>(name);
        Gui::Document* doc = Application::Instance->getDocument(act->getDocument());
        Gui::ViewProviderDocumentObject* viewProvider = static_cast
                <Gui::ViewProviderDocumentObject*>(doc->getViewProvider(act));
        doc->signalHighlightObject(*viewProvider, mode, false);
        if (autoExpand)
            doc->signalExpandObject(*viewProvider, Gui::Collapse);
    }

    if (obj) {
        Gui::Document* doc = Application::Instance->getDocument(obj->getDocument());
        Gui::ViewProviderDocumentObject* viewProvider = static_cast
                <Gui::ViewProviderDocumentObject*>(doc->getViewProvider(obj));
        doc->signalHighlightObject(*viewProvider, mode, true);
        if (autoExpand)
            doc->signalExpandObject(*viewProvider, Gui::Expand);
        _ObjectMap[name] = obj;
    }
    else {
        if (hasObject(name))
            _ObjectMap.erase(name);
    }
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:29,代码来源:ActiveObjectList.cpp

示例5: onAboutToRemoveProperty

void ViewProviderDocumentObject::onAboutToRemoveProperty(const char* prop)
{
    // transactions of view providers are also managed in App::Document.
    App::DocumentObject* docobject = getObject();
    App::Document* document = docobject ? docobject->getDocument() : nullptr;
    if (document)
        document->removePropertyOfObject(this, prop);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:8,代码来源:ViewProviderDocumentObject.cpp

示例6: unsetupObject

void OriginGroup::unsetupObject () {
    App::DocumentObject *origin = Origin.getValue ();
    if (origin && !origin->isDeleting ()) {
        origin->getDocument ()->remObject (origin->getNameInDocument());
    }

    GeoFeatureGroup::unsetupObject ();
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:8,代码来源:OriginGroup.cpp

示例7: recomputeFeature

void TaskFeatureParameters::recomputeFeature()
{
    if (!blockUpdate) {
        App::DocumentObject* obj = vp->getObject ();
        assert (obj);
        obj->getDocument()->recomputeFeature ( obj );
    }
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:TaskFeatureParameters.cpp

示例8: unsetupObject

void Body::unsetupObject () {
    App::DocumentObject *origin = Origin.getValue ();

    if (origin && !origin->isDeleting ()) {
        origin->getDocument ()->remObject (origin->getNameInDocument());
    }

    Part::BodyBase::unsetupObject ();
}
开发者ID:DeepSOIC,项目名称:FreeCAD-ellipse,代码行数:9,代码来源:Body.cpp

示例9: slotRenamedObject

void SelectionSingleton::slotRenamedObject(const App::DocumentObject& Obj)
{
    // compare internals with the document and change them if needed
    App::Document* pDoc = Obj.getDocument();
    for (std::list<_SelObj>::iterator it = _SelList.begin(); it != _SelList.end(); ++it) {
        if (it->pDoc == pDoc) {
            it->DocName = pDoc->getName();
        }
    }
}
开发者ID:asosarma,项目名称:FreeCAD_sf_master,代码行数:10,代码来源:Selection.cpp

示例10: onBeforeChange

void ViewProviderDocumentObject::onBeforeChange(const App::Property* prop)
{
    if (isAttachedToDocument()) {
        App::DocumentObject* obj = getObject();
        App::Document* doc = obj ? obj->getDocument() : 0;
        if (doc) {
            onBeforeChangeProperty(doc, prop);
        }
    }
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:10,代码来源:ViewProviderDocumentObject.cpp

示例11: getDocument

Gui::Document* AlignmentGroup::getDocument() const
{
    if (this->_views.empty())
        return 0;
    App::DocumentObject* pView = this->_views[0]->getObject();
    if (pView) {
        App::Document* rDoc = pView->getDocument();
        Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc);
        return pDoc;
    }

    return 0;
}
开发者ID:kkoksvik,项目名称:FreeCAD,代码行数:13,代码来源:ManualAlignment.cpp

示例12: getViewProviders

/**
 * Extracts the associated view providers of the objects of the associated object group group. 
 */
void ViewProviderDocumentObjectGroup::getViewProviders(std::vector<ViewProviderDocumentObject*>& vp) const
{
    App::DocumentObject* doc = getObject();
    if (doc->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
        Gui::Document* gd = Application::Instance->getDocument(doc->getDocument());
        App::DocumentObjectGroup* grp = (App::DocumentObjectGroup*)doc;
        std::vector<App::DocumentObject*> obj = grp->getObjects();
        for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
            ViewProvider* v = gd->getViewProvider(*it);
            if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
                vp.push_back((ViewProviderDocumentObject*)v);
        }
    }
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:17,代码来源:ViewProviderDocumentObjectGroup.cpp

示例13: extensionDropObject

void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {

    App::DocumentObject* grp = static_cast<App::DocumentObject*>(getExtendedViewProvider()->getObject());
    App::Document* doc = grp->getDocument();

    // build Python command for execution
    QString cmd;
    cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject("
                        "App.getDocument(\"%1\").getObject(\"%3\"))")
                        .arg(QString::fromLatin1(doc->getName()))
                        .arg(QString::fromLatin1(grp->getNameInDocument()))
                        .arg(QString::fromLatin1(obj->getNameInDocument()));

    Gui::Command::doCommand(Gui::Command::App, cmd.toUtf8());
}
开发者ID:SparkyCola,项目名称:FreeCAD,代码行数:15,代码来源:ViewProviderGroupExtension.cpp

示例14: accept

bool TaskCSysDragger::accept()
{
  lastTranslationIncrement = dragger->translationIncrement.getValue();
  lastRotationIncrement = dragger->rotationIncrement.getValue();

  App::DocumentObject* dObject = vpObject.getObject();
  if (dObject) {
    Gui::Document* document = Gui::Application::Instance->getDocument(dObject->getDocument());
    assert(document);
    document->commitCommand();
    document->resetEdit();
    document->getDocument()->recompute();
  }
  return Gui::TaskView::TaskDialog::accept();
}
开发者ID:WandererFan,项目名称:FreeCAD,代码行数:15,代码来源:TaskCSysDragger.cpp

示例15: getIcon

QIcon ViewProviderInspection::getIcon() const
{
    // Get the icon of the view provider to the associated feature
    QIcon px = inherited::getIcon();
    App::Property* pActual = pcObject->getPropertyByName("Actual");
    if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) {
        App::DocumentObject* docobj = ((App::PropertyLink*)pActual)->getValue();
        if (docobj) {
            Gui::Document* doc = Gui::Application::Instance->getDocument(docobj->getDocument());
            Gui::ViewProvider* view = doc->getViewProvider(docobj);
            px = view->getIcon();
        }
    }

    return px;
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:16,代码来源:ViewProviderInspection.cpp


注:本文中的app::DocumentObject::getDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。