X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/6a0ffdb10d7344d99e04c5518fca2b8295df94be..e0eaffd44fc9733bc230a803c80d8d5efd0faca6:/BoxItem.cpp diff --git a/BoxItem.cpp b/BoxItem.cpp index deee2cc..f3bc8eb 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -207,6 +207,9 @@ BoxItem::~BoxItem() { } void BoxItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + + if (!visible) return; + QPen pen(Qt::black, 3); if(selected) pen.setColor(Qt::red); @@ -406,13 +409,19 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { //cout << "block abs. pos: " << absPos.x() << "," << absPos.y() << " | "; //cout << "block current. pos: " << currentPosition.x() << "," << currentPosition.y() << " | "; - if ((gapX < 0) && (absPos.x() == marginConn)) { + if ((position == Left) || (position == Right)) { + gapX = 0; + } + else if ((gapX < 0) && (absPos.x() == marginConn)) { gapX = 0; } else if (absPos.x()+gapX < marginConn) { gapX = marginConn-absPos.x(); } - if ((gapY < 0) && (absPos.y() == marginConn)) { + if ((position == Top) || (position == Bottom)) { + gapY = 0; + } + else if ((gapY < 0) && (absPos.y() == marginConn)) { gapY = 0; } else if (absPos.y()+gapY < marginConn) { @@ -900,6 +909,12 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); int dimY = dimensionStr.at(1).toInt(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + + QString visStr = funcElement.attribute("visible","none"); + bool showItem = true; + if (visStr == "false") { + showItem = false; + } ReferenceBlock *referenceMd5 = NULL; ReferenceBlock *referenceXml = NULL; @@ -921,7 +936,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { } GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock()); - FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference); + FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference, false); /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when reading bif_iface tags. Thus interface are all removed. */ @@ -952,7 +967,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { } // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars - functionalBlock->removeAllInterfaces(); + //functionalBlock->removeAllInterfaces(); QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface"); // setting interfaces (user name, and for multiplicity>1 may be create some new ones) for(int i=0; iaddInterface(ctlIface); } } - // connect clk and rst to group clk/rst or to clkrstgen - if ((name != "clkrstgen") && (parentGroupBlock != NULL)) { - try { - functionalBlock->connectClkReset(); - } - catch(Exception e) { - AbstractBlock* source = (AbstractBlock *)(e.getSource()); - cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl; - throw(e); - } - } // creating InterfaceItem createInterfaceItems(); @@ -1022,6 +1026,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { interfaceItem->setOrientation(orientation); interfaceItem->setPositionRatio(position); } + setVisible(showItem); updateGeometry(Resize); } @@ -1037,6 +1042,9 @@ void BoxItem::save(QXmlStreamWriter &writer) { writer.writeAttribute("position",attrPos); QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight())); writer.writeAttribute("dimension",attrDim); + if (!isVisible()) { + writer.writeAttribute("visible","false"); + } writer.writeStartElement("bif_parameters"); foreach(BlockParameter *param,refBlock->getParameters()){ @@ -1059,7 +1067,7 @@ void BoxItem::save(QXmlStreamWriter &writer) { writer.writeAttribute("id",QString::number(inter->getId())); writer.writeAttribute("name",inter->getName()); - writer.writeAttribute("ref_name",inter->refInter->getName()); + writer.writeAttribute("ref_name",inter->getReferenceName()); writer.writeAttribute("orientation",inter->getStrOrientation()); writer.writeAttribute("position",QString::number(inter->getPositionRatio()));