X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/cfe8322b50c9ef08ffbc3e52b0849bca4cd1d0bf..1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b:/GroupItem.cpp diff --git a/GroupItem.cpp b/GroupItem.cpp index 38d70eb..ebef87c 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -22,7 +22,7 @@ GroupItem::GroupItem(BoxItem *_parentItem, parentItem = _parentItem; if (parentItem != NULL) { - parentItem->setChildGroupItem(this); + parentItem->setChildGroupItem(this); } /* @@ -384,7 +384,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget()); if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceItemFromCursor(x,y); @@ -448,7 +448,7 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->createConnection(iface1,iface2); + bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -585,15 +585,15 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if(selectedAction == renameAction){ if(ifaceItem != NULL) - dispatcher->renameInterface(ifaceItem); + dispatcher->renameInterface(Dispatcher::Design, ifaceItem); else - dispatcher->renameGroupBlock(this); + dispatcher->renameGroupBlock(Dispatcher::Design, this); } else if(selectedAction == showProperties){ - dispatcher->showProperties(ifaceItem); + dispatcher->showProperties(Dispatcher::Design, ifaceItem); } else if (selectedAction == removeAction) { - dispatcher->removeGroupInterface(ifaceItem); + dispatcher->removeGroupInterface(Dispatcher::Design, ifaceItem); } else if(selectedAction == showParameters) { new ParametersWindow(refBlock, params, NULL); @@ -618,7 +618,7 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); QString nameStr = groupElement.attribute("name","none"); - if(nameStr == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + if(nameStr == "none") throw(Exception(PROJECTFILE_CORRUPTED)); QStringList positionStr = groupElement.attribute("position","none").split(","); if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED)); @@ -651,6 +651,10 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { QString name = currentInterfaceNode.attribute("name","none"); if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + QString purposeStr = currentInterfaceNode.attribute("purpose","none"); + int purpose = AbstractInterface::getIntPurpose(purposeStr); + if(purpose == -1) throw(Exception(PROJECTFILE_CORRUPTED)); + QString directionStr = currentInterfaceNode.attribute("direction","none"); int direction = AbstractInterface::getIntDirection(directionStr); if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED)); @@ -661,13 +665,16 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { double position = currentInterfaceNode.attribute("position","none").toDouble(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - - GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,AbstractInterface::Data); - - InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params); + + GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose); + GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control); + groupCtlIface->setAssociatedIface(groupIface); + + InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params); interfaceItem->setId(id); - groupBlock->addInterface(groupInterface); + groupBlock->addInterface(groupIface); + groupBlock->addInterface(groupCtlIface); addInterfaceItem(interfaceItem, false); cout << "interface add to " << groupBlock->getName().toStdString() << endl; } @@ -703,6 +710,7 @@ void GroupItem::save(QXmlStreamWriter &writer) { writer.writeAttribute("id",QString::number(item->getId())); writer.writeAttribute("name",item->getName()); + writer.writeAttribute("purpose",QString(item->refInter->getPurposeString())); writer.writeAttribute("direction",QString(item->refInter->getDirectionString())); writer.writeAttribute("orientation",item->getStrOrientation()); writer.writeAttribute("position",QString::number(item->getPositionRatio()));