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

Private GIT Repository
modif in VHDLConverter
[blast.git] / GroupScene.cpp
index 531f62bdab84101009ce86c819f2dece0b578be5..778a0b04a3a7614a8416508c30d6d10915686a62 100644 (file)
@@ -38,6 +38,17 @@ GroupScene::~GroupScene() {
   groupItem = NULL;
 }
 
+/*
+void GroupScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+
+  //QGraphicsScene::mouseMoveEvent(event);
+  
+  QPointF p = event->scenePos();
+  cout << p.x() << "," << p.y() << endl;
+
+}
+*/
+
 void GroupScene::setSelectedInterface(int id, InterfaceItem* iface) {
   if ((id < 1)|| (id > 2)) return;
   selectedInterfaces[id-1] = iface;
@@ -61,6 +72,11 @@ QList<BoxItem *> GroupScene::getSelectedBlocks() {
 int GroupScene::setItemsId(int countInit) {
   int counter = countInit;
   groupItem->setId(counter++);
+  if (isTopScene()) {
+    foreach(SourceItem *item, sourceItems){
+      item->setId(counter++);
+    } 
+  }
   foreach(BoxItem *item, boxItems){
     item->setId(counter++);
   }
@@ -72,6 +88,13 @@ int GroupScene::setInterfacesId(int countInit) {
   foreach(InterfaceItem* inter, groupItem->getInterfaces()){
     inter->setId(counter++);
   }
+  if (isTopScene()) {
+    foreach(SourceItem *item, sourceItems){
+      foreach(InterfaceItem* inter, item->getInterfaces()){
+        inter->setId(counter++);
+      }
+    } 
+  }
   foreach(BoxItem *item, boxItems){
     foreach(InterfaceItem* inter, item->getInterfaces()){
       inter->setId(counter++);
@@ -129,6 +152,9 @@ SourceItem *GroupScene::createSourceItem(AbstractBlock *block) {
 }
 
 void GroupScene::addSourceItem(SourceItem* item) {  
+  // adding item to the scene
+  addItem(item);
+  item->setZValue(1);  
   // add item from the QList
   sourceItems.append(item);  
 }
@@ -166,6 +192,13 @@ void GroupScene::addConnectionItem(ConnectionItem* item) {
 }
 
 void GroupScene::removeConnectionItem(ConnectionItem* item) {
+  
+  // remove connection from/to InterfaceItem
+  InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
+  InterfaceItem* toIfaceItem = item->getToInterfaceItem();
+  fromIfaceItem->removeConnectionItem(item);
+  toIfaceItem->removeConnectionItem(item);
+  
   // remove item from the viewport
   removeItem(item);
   // remove item from the QList
@@ -189,11 +222,11 @@ void GroupScene::unselecteInterfaces() {
 
   if (selectedInterfaces[0] != NULL) {
     selectedInterfaces[0]->selected = false;
-    selectedInterfaces[0] == NULL;
+    selectedInterfaces[0] = NULL;
   }
   if (selectedInterfaces[1] != NULL) {
     selectedInterfaces[1]->selected = false;
-    selectedInterfaces[1] == NULL;
+    selectedInterfaces[1] = NULL;
   }
 }