]> AND Private Git Repository - blast.git/blobdiff - GroupItem.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
added admittance computation
[blast.git] / GroupItem.cpp
index 27f539cdf9ad11264cc07fb5d14f26834c7b40af..3286c14a9ae5e9d74863cab1c4f6e92ea7e05d40 100644 (file)
@@ -22,7 +22,7 @@ GroupItem::GroupItem(BoxItem *_parentItem,
 
   parentItem = _parentItem;
   if (parentItem != NULL) {
 
   parentItem = _parentItem;
   if (parentItem != NULL) {
-    parentItem->setChildGroupItem(this);
+    parentItem->setChildGroupItem(this);    
   }
 
   /*
   }
 
   /*
@@ -212,7 +212,7 @@ bool GroupItem::updateGeometry(ChangeType type) {
   }
 
   if (boxSizeChanged) {
   }
 
   if (boxSizeChanged) {
-    updateInterfacesAndConnections();
+    updateInterfaceAndConnectionItems();
   }
 
 
   }
 
 
@@ -359,7 +359,7 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
   }
   else if(params->editState == Parameters::EditInterfaceMove) {
     prepareGeometryChange();
   }
   else if(params->editState == Parameters::EditInterfaceMove) {
     prepareGeometryChange();
-    moveInterfaceTo(event->pos());
+    moveInterfaceItemTo(event->pos());
     // recompute the geometry of the block
     updateGeometry(InterfaceMove);
     // update connection from/to the selected interface
     // recompute the geometry of the block
     updateGeometry(InterfaceMove);
     // update connection from/to the selected interface
@@ -387,7 +387,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
   dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
 
   if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
   dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
 
   if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
-    InterfaceItem *inter = getInterfaceFromCursor(x,y);
+    InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
     if (inter != NULL) {
 
       if (params->editState == Parameters::EditNoOperation) {
     if (inter != NULL) {
 
       if (params->editState == Parameters::EditNoOperation) {
@@ -408,7 +408,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
   else if (mode == GroupScene::ItemEdition) {
 
     if (params->cursorState == Parameters::CursorOnInterface) {
   else if (mode == GroupScene::ItemEdition) {
 
     if (params->cursorState == Parameters::CursorOnInterface) {
-      InterfaceItem *inter = getInterfaceFromCursor(x,y);
+      InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
       if (inter != NULL) {
         currentInterface = inter;
         params->setEditState(Parameters::EditInterfaceMove);
       if (inter != NULL) {
         currentInterface = inter;
         params->setEditState(Parameters::EditInterfaceMove);
@@ -481,7 +481,7 @@ void GroupItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
   int mode = getScene()->getEditionMode();
 
   if (mode == GroupScene::AddConnection) {
   int mode = getScene()->getEditionMode();
 
   if (mode == GroupScene::AddConnection) {
-    InterfaceItem* iface = getInterfaceFromCursor(x,y);
+    InterfaceItem* iface = getInterfaceItemFromCursor(x,y);
     if (iface != NULL) {
       params->cursorState = Parameters::CursorOnInterface;
       setCursor(Qt::PointingHandCursor);
     if (iface != NULL) {
       params->cursorState = Parameters::CursorOnInterface;
       setCursor(Qt::PointingHandCursor);
@@ -495,7 +495,7 @@ void GroupItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
     int marginE = 5;
     int marginS = 5;
 
     int marginE = 5;
     int marginS = 5;
 
-    InterfaceItem* iface = getInterfaceFromCursor(x,y);
+    InterfaceItem* iface = getInterfaceItemFromCursor(x,y);
     if (iface != NULL) {
       params->cursorState = Parameters::CursorOnInterface;
       setCursor(Qt::PointingHandCursor);
     if (iface != NULL) {
       params->cursorState = Parameters::CursorOnInterface;
       setCursor(Qt::PointingHandCursor);
@@ -549,7 +549,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
 
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
 
-  InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y());
+  InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
 
   // menu for interface
   if( ifaceItem != NULL) {
 
   // menu for interface
   if( ifaceItem != 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(!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));
 
   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 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 directionStr = currentInterfaceNode.attribute("direction","none");
     int direction = AbstractInterface::getIntDirection(directionStr);
     if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));
@@ -661,14 +665,17 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
 
     double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
     if(!ok) 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);
+    
+    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);
 
     interfaceItem->setId(id);
 
-    groupBlock->addInterface(groupInterface);
-    addInterface(interfaceItem, false);
+    groupBlock->addInterface(groupIface);
+    groupBlock->addInterface(groupCtlIface);
+    addInterfaceItem(interfaceItem, false);
     cout << "interface add to " << groupBlock->getName().toStdString() << endl;
   }
 
     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("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()));
     writer.writeAttribute("direction",QString(item->refInter->getDirectionString()));
     writer.writeAttribute("orientation",item->getStrOrientation());
     writer.writeAttribute("position",QString::number(item->getPositionRatio()));