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


C++ Document::getName方法代码示例

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


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

示例1: drop

void ViewProviderDocumentObjectGroup::drop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos)
{
        // Open command
        App::DocumentObjectGroup* grp = static_cast<App::DocumentObjectGroup*>(getObject());
        App::Document* doc = grp->getDocument();
        Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
        gui->openCommand("Move object");
        for( std::vector<const App::DocumentObject*>::const_iterator it = objList.begin();it!=objList.end();++it) {
            // get document object
            const App::DocumentObject* obj = *it;
            const App::DocumentObjectGroup* par = App::DocumentObjectGroup::getGroupOfObject(obj);
            if (par) {
                // allow an object to be in one group only
                QString cmd;
                cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
                                  "App.getDocument(\"%1\").getObject(\"%3\"))")
                                  .arg(QString::fromLatin1(doc->getName()))
                                  .arg(QString::fromLatin1(par->getNameInDocument()))
                                  .arg(QString::fromLatin1(obj->getNameInDocument()));
                Gui::Application::Instance->runPythonCode(cmd.toUtf8());
            }

            // 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::Application::Instance->runPythonCode(cmd.toUtf8());
        }
        gui->commitCommand();

}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:35,代码来源:ViewProviderDocumentObjectGroup.cpp

示例2: toggleCheckState

void DlgFilletEdges::toggleCheckState(const QModelIndex& index)
{
    if (!d->object)
        return;
    QVariant check = index.data(Qt::CheckStateRole);
    int id = index.data(Qt::UserRole).toInt();
    QString name = QString::fromAscii("Edge%1").arg(id);
    Qt::CheckState checkState = static_cast<Qt::CheckState>(check.toInt());

    bool block = this->blockConnection(false);

    // is item checked
    if (checkState & Qt::Checked) {
        App::Document* doc = d->object->getDocument();
        Gui::Selection().addSelection(doc->getName(),
            d->object->getNameInDocument(),
            (const char*)name.toAscii());
    }
    else {
        App::Document* doc = d->object->getDocument();
        Gui::Selection().rmvSelection(doc->getName(),
            d->object->getNameInDocument(),
            (const char*)name.toAscii());
    }

    this->blockConnection(block);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:27,代码来源:DlgFilletEdges.cpp

示例3: activated

void CmdPartExport::activated(int iMsg)
{
    QStringList filter;
    filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
    filter << QObject::tr("STEP (*.stp *.step)");
    filter << QObject::tr("IGES (*.igs *.iges)");
    filter << QObject::tr("BREP (*.brp *.brep)");
    filter << QObject::tr("All Files (*.*)");

    QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
    if (!fn.isEmpty()) {
        App::Document* pDoc = getDocument();
        if (!pDoc) return; // no document
        openCommand("Import Part");
        QString ext = QFileInfo(fn).suffix().toLower();
        if (ext == QLatin1String("step") || 
            ext == QLatin1String("stp")  ||
            ext == QLatin1String("iges") ||
            ext == QLatin1String("igs")) {
            Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");
        }
        else {
            Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"Part");
        }
        commitCommand();
    }
}
开发者ID:msocorcim,项目名称:FreeCAD,代码行数:27,代码来源:Command.cpp

示例4: onSelectionChanged

void FaceColors::onSelectionChanged(const Gui::SelectionChanges& msg)
{
    // no object selected in the combobox or no sub-element was selected
    if (!msg.pSubName)
        return;
    bool selection_changed = false;
    if (msg.Type == Gui::SelectionChanges::AddSelection) {
        // when adding a sub-element to the selection check
        // whether this is the currently handled object
        App::Document* doc = d->obj->getDocument();
        std::string docname = doc->getName();
        std::string objname = d->obj->getNameInDocument();
        if (docname==msg.pDocName && objname==msg.pObjectName) {
            int index = std::atoi(msg.pSubName+4)-1;
            d->index.insert(index);
            const App::Color& c = d->perface[index];
            QColor color;
            color.setRgbF(c.r,c.g,c.b);
            d->ui->colorButton->setColor(color);
            selection_changed = true;
        }
    }
    else if (msg.Type == Gui::SelectionChanges::RmvSelection) {
        App::Document* doc = d->obj->getDocument();
        std::string docname = doc->getName();
        std::string objname = d->obj->getNameInDocument();
        if (docname==msg.pDocName && objname==msg.pObjectName) {
            int index = std::atoi(msg.pSubName+4)-1;
            d->index.remove(index);
            selection_changed = true;
        }
    }
    else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
        d->index.clear();
        selection_changed = true;
    }

    if (selection_changed) {
        QString faces = QString::fromLatin1("[");
        int size = d->index.size();
        for (QSet<int>::iterator it = d->index.begin(); it != d->index.end(); ++it) {
            faces += QString::number(*it + 1);
            if (--size > 0)
                faces += QString::fromLatin1(",");
        }
        faces += QString::fromLatin1("]");
        d->ui->labelElement->setText(faces);
        d->ui->colorButton->setDisabled(d->index.isEmpty());
    }
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:50,代码来源:TaskFaceColors.cpp

示例5: findShapes

void Mirroring::findShapes()
{
    App::Document* activeDoc = App::GetApplication().getActiveDocument();
    if (!activeDoc) return;
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
    if (!activeGui) return;

    this->document = QString::fromLatin1(activeDoc->getName());
    std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType
        (Part::Feature::getClassTypeId());

    for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
        const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
        if (!shape.IsNull()) {
            QString label = QString::fromUtf8((*it)->Label.getValue());
            QString name = QString::fromLatin1((*it)->getNameInDocument());
            
            QTreeWidgetItem* child = new QTreeWidgetItem();
            child->setText(0, label);
            child->setToolTip(0, label);
            child->setData(0, Qt::UserRole, name);
            Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
            if (vp) child->setIcon(0, vp->getIcon());
            ui->shapes->addTopLevelItem(child);
        }
    }
}
开发者ID:AllenBootung,项目名称:FreeCAD,代码行数:27,代码来源:Mirroring.cpp

示例6: clearSelection

void SelectionSingleton::clearSelection(const char* pDocName)
{
    App::Document* pDoc;
    pDoc = getDocument(pDocName);

    // the document 'pDocName' has already been removed
    if (!pDoc && !pDocName) {
        clearCompleteSelection();
    }
    else {
        std::string docName;
        if (pDocName)
            docName = pDocName;
        else
            docName = pDoc->getName(); // active document
        std::list<_SelObj> selList;
        for (std::list<_SelObj>::iterator it = _SelList.begin(); it != _SelList.end(); ++it) {
            if (it->DocName != docName)
                selList.push_back(*it);
        }

        _SelList = selList;

        SelectionChanges Chng;
        Chng.Type = SelectionChanges::ClrSelection;
        Chng.pDocName = docName.c_str();
        Chng.pObjectName = "";
        Chng.pSubName = "";

        Notify(Chng);
        signalSelectionChanged(Chng);

        Base::Console().Log("Sel : Clear selection\n");
    }
}
开发者ID:asosarma,项目名称:FreeCAD_sf_master,代码行数:35,代码来源:Selection.cpp

示例7: activated

void CmdPartImport::activated(int iMsg)
{
    QStringList filter;
    filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
    filter << QObject::tr("STEP (*.stp *.step)");
    filter << QObject::tr("IGES (*.igs *.iges)");
    filter << QObject::tr("BREP (*.brp *.brep)");
    filter << QObject::tr("All Files (*.*)");

    QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
    if (!fn.isEmpty()) {
        Gui::WaitCursor wc;
        App::Document* pDoc = getDocument();
        if (!pDoc) return; // no document
        openCommand("Import Part");
        QString ext = QFileInfo(fn).suffix().toLower();
        if (ext == QLatin1String("step") || 
            ext == QLatin1String("stp")  ||
            ext == QLatin1String("iges") ||
            ext == QLatin1String("igs")) {
            doCommand(Doc, "import ImportGui");
            doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
        }
        else {
            doCommand(Doc, "import Part");
            doCommand(Doc, "Part.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
        }
        commitCommand();

        std::list<Gui::MDIView*> views = getActiveGuiDocument()->getMDIViewsOfType(Gui::View3DInventor::getClassTypeId());
        for (std::list<Gui::MDIView*>::iterator it = views.begin(); it != views.end(); ++it) {
            (*it)->viewAll();
        }
    }
}
开发者ID:mythma,项目名称:FreeCAD_sf_master,代码行数:35,代码来源:Command.cpp

示例8: activated

void StdCmdSelectAll::activated(int iMsg)
{
    SelectionSingleton& rSel = Selection();
    App::Document* doc = App::GetApplication().getActiveDocument();
    std::vector<App::DocumentObject*> objs = doc->getObjectsOfType(App::DocumentObject::getClassTypeId());
    rSel.setSelection(doc->getName(), objs);
}
开发者ID:pedrocalderon,项目名称:FreeCAD_sf_master,代码行数:7,代码来源:CommandDoc.cpp

示例9: findShapes

void SweepWidget::findShapes()
{
    App::Document* activeDoc = App::GetApplication().getActiveDocument();
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
    if (!activeGui) return;
    d->document = activeDoc->getName();

    std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

    for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
        const TopoDS_Shape& shape = (*it)->Shape.getValue();
        if (shape.IsNull()) continue;

        if (shape.ShapeType() == TopAbs_FACE ||
            shape.ShapeType() == TopAbs_WIRE ||
            shape.ShapeType() == TopAbs_EDGE ||
            shape.ShapeType() == TopAbs_VERTEX) {
            QString label = QString::fromUtf8((*it)->Label.getValue());
            QString name = QString::fromAscii((*it)->getNameInDocument());
            
            QTreeWidgetItem* child = new QTreeWidgetItem();
            child->setText(0, label);
            child->setToolTip(0, label);
            child->setData(0, Qt::UserRole, name);
            Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
            if (vp) child->setIcon(0, vp->getIcon());
            d->ui.selector->availableTreeWidget()->addTopLevelItem(child);
        }
    }
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:30,代码来源:TaskSweep.cpp

示例10: findShapes

void Tessellation::findShapes()
{
    App::Document* activeDoc = App::GetApplication().getActiveDocument();
    if (!activeDoc) return;
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
    if (!activeGui) return;

    this->document = QString::fromAscii(activeDoc->getName());
    std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

    for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
        const TopoDS_Shape& shape = (*it)->Shape.getValue();
        if (shape.IsNull()) continue;
        bool hasfaces = false;
        TopExp_Explorer xp(shape,TopAbs_FACE);
        while (xp.More()) {
            hasfaces = true;
            break;
        }

        if (hasfaces) {
            QString label = QString::fromUtf8((*it)->Label.getValue());
            QString name = QString::fromAscii((*it)->getNameInDocument());
            
            QTreeWidgetItem* child = new QTreeWidgetItem();
            child->setText(0, label);
            child->setToolTip(0, label);
            child->setData(0, Qt::UserRole, name);
            Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
            if (vp) child->setIcon(0, vp->getIcon());
            ui->treeWidget->addTopLevelItem(child);
        }
    }
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:34,代码来源:Tessellation.cpp

示例11: fi

static PyObject * open(PyObject *self, PyObject *args)
{
    char* Name;
    if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
        return NULL;
    std::string EncodedName = std::string(Name);
    PyMem_Free(Name);
    Base::FileInfo fi(EncodedName);
    if (!fi.exists())
        Py_Error(Base::BaseExceptionFreeCADError, "File not found");
    Gui::WaitCursor wc;
    wc.restoreCursor();

    PY_TRY {
        std::string path = App::GetApplication().getHomePath();
        path += "Mod/Path/PathScripts/";
        QDir dir1(QString::fromUtf8(path.c_str()), QString::fromAscii("*_pre.py"));
        std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
            ->GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str());
        QDir dir2(QString::fromUtf8(cMacroPath.c_str()), QString::fromAscii("*_pre.py"));
        QFileInfoList list = dir1.entryInfoList();
        list << dir2.entryInfoList();
        std::vector<std::string> scripts;
        for (int i = 0; i < list.size(); ++i) {
            QFileInfo fileInfo = list.at(i);
            scripts.push_back(fileInfo.baseName().toStdString());
        }
        std::string selected;
        PathGui::DlgProcessorChooser Dlg(scripts);
        if (Dlg.exec() != QDialog::Accepted) {
            Py_Return;
        }
        selected = Dlg.getSelected();
    
        std::ostringstream pre;
        std::ostringstream cmd;
        if (selected.empty()) {
            App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
            Gui::Command::runCommand(Gui::Command::Gui,"import Path");
            cmd << "Path.read(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")";
            Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
        } else {
            for (int i = 0; i < list.size(); ++i) {
                QFileInfo fileInfo = list.at(i);
                if (fileInfo.baseName().toStdString() == selected) {
                    if (fileInfo.absoluteFilePath().contains(QString::fromAscii("PathScripts"))) {
                        pre << "from PathScripts import " << selected;
                    } else {
                        pre << "import " << selected;
                    }
                    Gui::Command::runCommand(Gui::Command::Gui,pre.str().c_str());
                    cmd << selected << ".open(\"" << EncodedName << "\")";
                    Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
                }
            }
        }
    } PY_CATCH;
    Py_Return;
}
开发者ID:Fat-Zer,项目名称:FreeCAD_sf_master,代码行数:59,代码来源:AppPathGuiPy.cpp

示例12: 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

示例13: addFacesToSelection

    void addFacesToSelection(Gui::View3DInventorViewer* /*viewer*/,
                             const Gui::ViewVolumeProjection& proj,
                             const Base::Polygon2d& polygon,
                             const TopoDS_Shape& shape)
    {
        try {
            TopTools_IndexedMapOfShape M;

            TopExp_Explorer xp_face(shape,TopAbs_FACE);
            while (xp_face.More()) {
                M.Add(xp_face.Current());
                xp_face.Next();
            }

            App::Document* appdoc = doc->getDocument();
            for (Standard_Integer k = 1; k <= M.Extent(); k++) {
                const TopoDS_Shape& face = M(k);

                TopExp_Explorer xp_vertex(face,TopAbs_VERTEX);
                while (xp_vertex.More()) {
                    gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(xp_vertex.Current()));
                    Base::Vector3d pt2d;
                    pt2d = proj(Base::Vector3d(p.X(), p.Y(), p.Z()));
                    if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
#if 0
                        // TODO
                        if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer))
#endif
                        {
                            std::stringstream str;
                            str << "Face" << k;
                            Gui::Selection().addSelection(appdoc->getName(), obj->getNameInDocument(), str.str().c_str());
                            break;
                        }
                    }
                    xp_vertex.Next();
                }

                //GProp_GProps props;
                //BRepGProp::SurfaceProperties(face, props);
                //gp_Pnt c = props.CentreOfMass();
                //Base::Vector3d pt2d;
                //pt2d = proj(Base::Vector3d(c.X(), c.Y(), c.Z()));
                //if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
                //    if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer)) {
                //        std::stringstream str;
                //        str << "Face" << k;
                //        Gui::Selection().addSelection(appdoc->getName(), obj->getNameInDocument(), str.str().c_str());
                //    }
                //}
            }
        }
        catch (...) {
        }
    }
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:55,代码来源:TaskFaceColors.cpp

示例14: slotDeleteDocument

void AutoSaver::slotDeleteDocument(const App::Document& Doc)
{
    std::string name = Doc.getName();
    std::map<std::string, AutoSaveProperty*>::iterator it = saverMap.find(name);
    if (it != saverMap.end()) {
        if (it->second->timerId > 0)
            killTimer(it->second->timerId);
        delete it->second;
        saverMap.erase(it);
    }
}
开发者ID:skidzo,项目名称:FreeCAD,代码行数:11,代码来源:AutoSaver.cpp

示例15: activated

void CmdPartShapeFromMesh::activated(int iMsg)
{
    Q_UNUSED(iMsg);
    bool ok;
    double tol = QInputDialog::getDouble(Gui::getMainWindow(), QObject::tr("Sewing Tolerance"),
        QObject::tr("Enter tolerance for sewing shape:"), 0.1, 0.01,10.0,2,&ok);
    if (!ok)
        return;
    Base::Type meshid = Base::Type::fromName("Mesh::Feature");
    std::vector<App::DocumentObject*> meshes;
    meshes = Gui::Selection().getObjectsOfType(meshid);
    Gui::WaitCursor wc;
    std::vector<App::DocumentObject*>::iterator it;
    openCommand("Convert mesh");
    for (it = meshes.begin(); it != meshes.end(); ++it) {
        App::Document* doc = (*it)->getDocument();
        std::string mesh = (*it)->getNameInDocument();
        std::string name = doc->getUniqueObjectName(mesh.c_str());
        doCommand(Doc,"import Part");
        doCommand(Doc,"FreeCAD.getDocument(\"%s\").addObject(\"Part::Feature\",\"%s\")"
                     ,doc->getName()
                     ,name.c_str());
        doCommand(Doc,"__shape__=Part.Shape()");
        doCommand(Doc,"__shape__.makeShapeFromMesh("
                      "FreeCAD.getDocument(\"%s\").getObject(\"%s\").Mesh.Topology,%f"
                      ")"
                     ,doc->getName()
                     ,mesh.c_str()
                     ,tol);
        doCommand(Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Shape=__shape__"
                     ,doc->getName()
                     ,name.c_str());
        doCommand(Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").purgeTouched()"
                     ,doc->getName()
                     ,name.c_str());
        doCommand(Doc,"del __shape__");
    }

    commitCommand();
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:40,代码来源:CommandSimple.cpp


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