+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 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 *groupInterface = new GroupInterface(groupBlock,name,direction,AbstractInterface::Data);
+
+ InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params);
+ interfaceItem->setId(id);
+
+ groupBlock->addInterface(groupInterface);
+ addInterface(interfaceItem, false);
+ cout << "interface add to " << groupBlock->getName().toStdString() << endl;
+ }
+
+}
+