QStringList Doc_plugin_interface::getAllLayer(){ QStringList listName; RS_LayerList* listLay = doc->getLayerList(); for (unsigned int i = 0; i < listLay->count(); ++i) { listName << listLay->at(i)->getName(); } return listName; }
/*TODO RLZ: add undo support in the remaining methods*/ void Doc_plugin_interface::setLayer(QString name){ RS_LayerList* listLay = doc->getLayerList(); RS_Layer *lay = listLay->find(name); if (lay == NULL) { lay = new RS_Layer(name); doc->addLayer(lay); } listLay->activate(lay, true); }
void LC_MakerCamSVG::writeLayers(RS_Document* document) { RS_DEBUG->print("RS_MakerCamSVG::writeLayers: Writing layers ..."); RS_LayerList* layerlist = document->getLayerList(); for (unsigned int i = 0; i < layerlist->count(); i++) { writeLayer(document, layerlist->at(i)); } }
QString Doc_plugin_interface::addBlockfromFromdisk(QString fullName){ if (fullName.isEmpty() || doc==NULL) return NULL; RS_BlockList* blockList = doc->getBlockList(); if (blockList==NULL) return NULL; QFileInfo fi(fullName); QString s = fi.completeBaseName(); QString name = s; if(blockList->find(name)){ for (int i=0; i<1e5; ++i) { name = QString("%1-%2").arg(s).arg(i); if (blockList->find(name)==NULL) { break; } } } if (fi.isReadable()) { RS_BlockData d(name, RS_Vector(0,0), false); RS_Block *b = new RS_Block(doc, d); RS_Graphic g; if (!g.open(fi.absoluteFilePath(), RS2::FormatUnknown)) { RS_DEBUG->print(RS_Debug::D_WARNING, "Doc_plugin_interface::addBlockfromFromdisk: Cannot open file: %s"); delete b; return NULL; } RS_LayerList* ll = g.getLayerList(); for (int i = 0; i<ll->count(); i++){ RS_Layer* nl = ll->at(i)->clone(); doc->addLayer(nl); } RS_BlockList* bl = g.getBlockList(); for (int i = 0; i<bl->count(); i++){ RS_Block* nb = (RS_Block*)bl->at(i)->clone(); doc->addBlock(nb); } for (int i = 0; i<g.count(); i++){ RS_Entity* e = g.entityAt(i)->clone(); e->reparent(b); b->addEntity(e); } doc->addBlock(b); return name; } else { return NULL; } }
/** * Initialisation (called manually only once). * * @param layerList Layer list which provides the layer names that are * available. * @param showByBlock true: Show attribute ByBlock. */ void QG_LayerBox::init(RS_LayerList& layerList, bool showByBlock, bool showUnchanged) { this->showByBlock = showByBlock; this->showUnchanged = showUnchanged; this->layerList = &layerList; if (showUnchanged) { addItem(tr("- Unchanged -")); } for (unsigned i=0; i<layerList.count(); ++i) { RS_Layer* lay = layerList.at(i); if (lay!=NULL && (lay->getName()!="ByBlock" || showByBlock)) { addItem(lay->getName()); } } connect(this, SIGNAL(activated(int)), this, SLOT(slotLayerChanged(int))); setCurrentIndex(0); slotLayerChanged(currentIndex()); }