Exemplo n.º 1
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);
}
Exemplo n.º 2
0
/**
 * Provides a new window for editing the active block.
 */
void QC_DialogFactory::requestEditBlockWindow(RS_BlockList* /*blockList*/) {
    RS_DEBUG->print("QC_DialogFactory::requestEditBlockWindow()");

    QC_ApplicationWindow* appWindow = QC_ApplicationWindow::getAppWindow();
    QC_MDIWindow* parent = appWindow->getMDIWindow();
    if (parent!=NULL) {
        //get blocklist from block widget, bug#3497154
        RS_BlockList* blist = appWindow->getBlockWidget() -> getBlockList();
        if (blist !=NULL) {
            RS_Block* blk = blist->getActive();
//            std::cout<<"QC_DialogFactory::requestEditBlockWindow(): size()="<<((blk==NULL)?0:blk->count() )<<std::endl;
            if (blk!=NULL) {
                QC_MDIWindow* w = appWindow->slotFileNew(blk);
                // the parent needs a pointer to the block window and
                //   vice versa
                parent->addChildWindow(w);
                w->getGraphicView()->zoomAuto(false);
                //update grid settings, bug#3443293
                w->getGraphicView()->getGrid()->updatePointArray();
            }
        }
    }
}