+void GroupItem::load(QDomElement groupElement) throw(Exception) {
+
+ GroupBlock* groupBlock = AB_TO_GRP(refBlock);
+
+ bool ok = false;
+
+ int id = groupElement.attribute("id","none").toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ QString nameStr = groupElement.attribute("name","none");
+ if(nameStr == "none") throw(Exception(PROJECTFILE_CORRUPTED));
+
+ QStringList positionStr = groupElement.attribute("position","none").split(",");
+ if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
+ int posX = positionStr.at(0).toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+ int posY = positionStr.at(1).toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ QStringList dimensionStr = groupElement.attribute("dimension","none").split(",");
+ if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
+ int dimX = dimensionStr.at(0).toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+ int dimY = dimensionStr.at(1).toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ setId(id);
+ setPos(posX,posY);
+ setDimension(dimX,dimY);
+ groupBlock->setName(nameStr);
+
+ cout << "group info : \n-id : " << id << "\n-pos : " << posX << ", " << posY << "\n-dim : " << dimX << ", " << dimY << "\n-name : " << nameStr.toStdString() << endl;
+
+ QDomNodeList interfaces = groupElement.elementsByTagName("group_iface");
+ for(int j=0; j<interfaces.length(); j++){
+ QDomElement currentInterfaceNode = interfaces.at(j).toElement();
+
+ int id = currentInterfaceNode.attribute("id","none").toInt(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ 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));
+
+ QString orientationStr = currentInterfaceNode.attribute("orientation","none");
+ int orientation = InterfaceItem::getIntOrientation(orientationStr);
+ if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
+
+ GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
+ groupBlock->addInterface(groupIface);
+ InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params);
+ interfaceItem->setId(id);
+ addInterfaceItem(interfaceItem, false);
+
+ if (purpose == AbstractInterface::Data) {
+ GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
+ groupCtlIface->setAssociatedIface(groupIface);
+ groupBlock->addInterface(groupCtlIface);
+ }
+ cout << "interface add to " << groupBlock->getName().toStdString() << endl;
+ }
+
+}
+