Пример #1
0
/*recursive add blocks in graphic*/
void RS_ActionBlocksSave::addBlock(RS_Insert* in, RS_Graphic* g) {

	for(auto e: *in){

        if (e->rtti() == RS2::EntityInsert) {
            addBlock((RS_Insert *)e,g);
            RS_Insert *in = (RS_Insert *)e;
            g->addBlock(in->getBlockForInsert());
        }
    }
}
Пример #2
0
void RS_ActionBlocksSave::trigger() {
    RS_DEBUG->print("save block to file");
    QC_ApplicationWindow* appWindow = QC_ApplicationWindow::getAppWindow();
    if(!appWindow) {
        finish(false);
        return;
    }
    RS_BlockList* bList = appWindow->getBlockWidget() -> getBlockList();
    if (bList) {
        auto b=bList->getActive();
        if(b) {
            RS_Graphic g(nullptr);
            g.setOwner(false);

            g.clearLayers();
//           g.addLayer(b->getLayer());
            for (RS_Entity* e=b->firstEntity(RS2::ResolveNone);
                    e;
                    e = b->nextEntity(RS2::ResolveNone)) {
                g.addEntity(e);
                if (e->rtti() == RS2::EntityInsert) {
                    RS_Insert *in = static_cast<RS_Insert *>(e);
                    g.addBlock(in->getBlockForInsert());
                    addBlock(in,&g);
                }
//           std::cout<<__FILE__<<" : "<<__func__<<" : line: "<<__LINE__<<" : "<<e->rtti()<<std::endl;
//                g.addLayer(e->getLayer());
//           std::cout<<__FILE__<<" : "<<__func__<<" : line: "<<__LINE__<<" : "<<e->rtti()<<std::endl;
            }
//           std::cout<<__FILE__<<" : "<<__func__<<" : line: "<<__LINE__<<std::endl;
//           std::cout<<"add layer name="<<qPrintable(b->getLayer()->getName())<<std::endl;

            RS2::FormatType t = RS2::FormatDXFRW;

            QG_FileDialog dlg(appWindow->getMDIWindow(),0, QG_FileDialog::BlockFile);
            QString const& fn = dlg.getSaveFile(&t);
            QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
//            g.setModified(true);
            g.saveAs(fn, t);
            QApplication::restoreOverrideCursor();
        } else {
            if (RS_DIALOGFACTORY) {
                RS_DIALOGFACTORY->commandMessage(tr("No block activated to save"));
            }
        }
    } else {
        RS_DEBUG->print(RS_Debug::D_WARNING,
                        "RS_ActionBlocksSave::trigger():  blockList is NULL");
    }
    finish(false);
}