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

Private GIT Repository
modifying pattern methods to throw exceptions
[blast.git] / BoxItem.cpp
index a654718ed91877e2fdc3b509e47c3d74293cdc39..c473e6f70060a91d81ad889bde201e6552c1dc29 100644 (file)
@@ -33,9 +33,9 @@ BoxItem::BoxItem(AbstractBlock *_refBlock,
   setZValue(100);
   setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
 
   setZValue(100);
   setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
 
-  initInterfaces();
+  initInterfaceItems();
   updateGeometry(InterfaceMove);
   updateGeometry(InterfaceMove);
-  resetInterfacesPosition();
+  resetInterfaceItemsPosition();
   QPointF initPos = QPointF(0.0,0.0) - originPoint;
   setPos(initPos);
   //cout << "total size of block: " << totalWidth << "," << totalHeight << endl;
   QPointF initPos = QPointF(0.0,0.0) - originPoint;
   setPos(initPos);
   //cout << "total size of block: " << totalWidth << "," << totalHeight << endl;
@@ -173,7 +173,7 @@ bool BoxItem::updateGeometry(ChangeType type) {
     }
   }
   if (boxSizeChanged) {
     }
   }
   if (boxSizeChanged) {
-    updateInterfacesAndConnections();
+    updateInterfaceAndConnectionItems();
   }
 
 
   }
 
 
@@ -207,6 +207,20 @@ bool BoxItem::updateGeometry(ChangeType type) {
   return false;
 }
 
   return false;
 }
 
+void BoxItem::nameChanged() {
+  
+  QFontMetrics fmId(params->defaultBlockFont);
+  nameWidth = fmId.width(refBlock->getName());
+  nameHeight = fmId.height();
+  
+  if (updateGeometry(InterfaceMove)) {
+    //cout << "must recompute group item geometry" << endl;
+    (getScene()->getGroupItem())->updateShape();
+  }
+  // force the update in case of size has not changed
+  update();
+}
+
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditBlockMove) {
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditBlockMove) {
@@ -279,10 +293,10 @@ void BoxItem::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
     if (updateGeometry(InterfaceMove)) {
     // recompute the geometry of the block
     if (updateGeometry(InterfaceMove)) {
-      cout << "must recompute group item geometry" << endl;
+      //cout << "must recompute group item geometry" << endl;
       (getScene()->getGroupItem())->updateShape();
     }
     // update connection from/to the selected interface
       (getScene()->getGroupItem())->updateShape();
     }
     // update connection from/to the selected interface
@@ -309,7 +323,7 @@ void BoxItem::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) {
@@ -328,9 +342,9 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
     }
   }
   else if (mode == GroupScene::ItemEdition) {
     }
   }
   else if (mode == GroupScene::ItemEdition) {
-    setZValue(zValue()+100);
+    //setZValue(zValue()+100);
     if (params->cursorState == Parameters::CursorOnInterface) {
     if (params->cursorState == Parameters::CursorOnInterface) {
-      InterfaceItem *inter = getInterfaceFromCursor(x,y);
+      InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
       if (inter != NULL) {
         if (inter == currentInterface) {
            params->setEditState(Parameters::EditInterfaceDeselect);
       if (inter != NULL) {
         if (inter == currentInterface) {
            params->setEditState(Parameters::EditInterfaceDeselect);
@@ -359,7 +373,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
 
 void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent  *event) {
 
 
 void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent  *event) {
 
-  setZValue(zValue()-100);
+  //setZValue(zValue()-100);
 
   int mode = getScene()->getEditionMode();
 
 
   int mode = getScene()->getEditionMode();
 
@@ -380,10 +394,12 @@ void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent  *event) {
     else if (params->editState == Parameters::EditCloseConnection) {
       InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
       InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
     else if (params->editState == Parameters::EditCloseConnection) {
       InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
       InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
-      bool ok = dispatcher->connect(iface1,iface2);
+      bool ok = dispatcher->createConnection(iface1,iface2);
       if (ok) {
         iface1->selected = false;
       if (ok) {
         iface1->selected = false;
-        // no update needed since the whole scene will be repainted
+        update(iface1->boundingRect());
+        iface2->selected = false;
+        update(iface2->boundingRect());        
         getScene()->setSelectedInterface(1,NULL);
         getScene()->setSelectedInterface(2,NULL);
         params->setEditState(Parameters::EditNoOperation);
         getScene()->setSelectedInterface(1,NULL);
         getScene()->setSelectedInterface(2,NULL);
         params->setEditState(Parameters::EditNoOperation);
@@ -413,7 +429,7 @@ void BoxItem::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);
@@ -427,7 +443,7 @@ void BoxItem::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);
@@ -469,26 +485,28 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) {
       }
     }
   }
       }
     }
   }
-  QGraphicsItem::hoverMoveEvent(event);
+  //QGraphicsItem::hoverMoveEvent(event);
+  event->ignore();
 }
 
 
 }
 
 
-void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
-
+void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {  
+  
   QMenu menu;
   QAction* titleAction = NULL;
   QAction* removeAction = NULL;
   QAction* duplicateAction = NULL;
   QAction* renameAction = NULL;
   QMenu menu;
   QAction* titleAction = NULL;
   QAction* removeAction = NULL;
   QAction* duplicateAction = NULL;
   QAction* renameAction = NULL;
-  QAction* connectToGroup = NULL;
-  QAction* disconnectFromGroup = NULL;
+  QAction* connectToGroup = NULL;  
   QAction* showProperties = NULL;
   QAction* cloneInterface = NULL;
   QAction* openWindow = NULL;
   QAction* showProperties = NULL;
   QAction* cloneInterface = NULL;
   QAction* openWindow = NULL;
-  QAction* showRstClkInter = NULL;
+  QAction* showRstClkIface = NULL;
+  QAction* showWishboneIface = NULL;
   QAction* showParameters = NULL;
   QAction* showParameters = NULL;
+  QAction* showPatterns = 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){
 
@@ -504,7 +522,6 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     ConnectedInterface* ifaceGroup = NULL;
     bool canRemove = true;
 
     ConnectedInterface* ifaceGroup = NULL;
     bool canRemove = true;
 
-
     if ((iface->getDirection() == AbstractInterface::Input) && (iface->getConnectedFrom() == NULL)) {
         connectToGroup = menu.addAction("Connect to group input");
     }
     if ((iface->getDirection() == AbstractInterface::Input) && (iface->getConnectedFrom() == NULL)) {
         connectToGroup = menu.addAction("Connect to group input");
     }
@@ -512,22 +529,14 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
       connectToGroup = menu.addAction("Connect to group output");
     }
     else if (iface->getConnectionFromParentGroup() != NULL) {
       connectToGroup = menu.addAction("Connect to group output");
     }
     else if (iface->getConnectionFromParentGroup() != NULL) {
-      ifaceGroup = iface->getConnectionFromParentGroup();
-      //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) {
-      if (!ifaceGroup->isConnectedFrom()) {
-        disconnectFromGroup = menu.addAction("Disconnect from group");
-      }
-      else {
+      ifaceGroup = iface->getConnectionFromParentGroup();     
+      if (ifaceGroup->isConnectedFrom()) {        
         canRemove = false;
       }
     }
     else if (iface->getConnectionToParentGroup() != NULL) {
         canRemove = false;
       }
     }
     else if (iface->getConnectionToParentGroup() != NULL) {
-      ifaceGroup = iface->getConnectionToParentGroup();
-      //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) {
-      if (!ifaceGroup->isConnectedTo()) {
-        disconnectFromGroup = menu.addAction("Disconnect from group");
-      }
-      else {
+      ifaceGroup = iface->getConnectionToParentGroup();      
+      if (ifaceGroup->isConnectedTo()) {
         canRemove = false;
       }
     }
         canRemove = false;
       }
     }
@@ -542,6 +551,9 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
         }
       }      
     }
         }
       }      
     }
+    if ((iface->getAssociatedIface() != NULL) && (iface->getDirection() == AbstractInterface::Output)) {
+      showPatterns = menu.addAction("Show patterns");
+    }
   }
   // menu for blocks (group or func)
   else {
   }
   // menu for blocks (group or func)
   else {
@@ -559,9 +571,12 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     }
     else {
       duplicateAction = menu.addAction("Duplicate");
     }
     else {
       duplicateAction = menu.addAction("Duplicate");
-      showRstClkInter = menu.addAction("Show reset/clock interfaces");
-      showRstClkInter->setCheckable(true);
-      showRstClkInter->setChecked(rstClkVisible);
+      showRstClkIface = menu.addAction("Show reset/clock interfaces");
+      showRstClkIface->setCheckable(true);
+      showRstClkIface->setChecked(rstClkVisible);
+      showWishboneIface = menu.addAction("Show wishbone interfaces");
+      showWishboneIface->setCheckable(true);
+      showWishboneIface->setChecked(wishboneVisible);
     }
     removeAction = menu.addAction("Remove");
   }
     }
     removeAction = menu.addAction("Remove");
   }
@@ -573,20 +588,27 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
 
   if (selectedAction == removeAction) {
     if(ifaceItem != NULL) {
 
   if (selectedAction == removeAction) {
     if(ifaceItem != NULL) {
-     dispatcher->removeBlockInterface(ifaceItem);
+     dispatcher->removeFunctionalInterface(ifaceItem);
     }
     else {
     }
     else {
-      dispatcher->removeBlock(this);
+      dispatcher->removeBoxItem(this);
     }
   }
   else if (selectedAction == duplicateAction) {
     }
   }
   else if (selectedAction == duplicateAction) {
-    dispatcher->duplicateBlock(this);
+    dispatcher->duplicateBoxItem(this);
   }
   else if(selectedAction == renameAction){
   }
   else if(selectedAction == renameAction){
-    if(ifaceItem != NULL)
+    if(ifaceItem != NULL) {
       dispatcher->renameInterface(ifaceItem);
       dispatcher->renameInterface(ifaceItem);
-    else
-      dispatcher->renameBlockOrGroup(this);
+    }
+    else {
+      if (refBlock->isFunctionalBlock()) {          
+        dispatcher->renameFunctionalBlock(this);
+      }
+      else if (refBlock->isGroupBlock()) {        
+        dispatcher->renameGroupBlock(childGroupItem);
+      }
+    }   
   }
   else if(selectedAction == showProperties){
     dispatcher->showProperties(ifaceItem);
   }
   else if(selectedAction == showProperties){
     dispatcher->showProperties(ifaceItem);
@@ -594,22 +616,26 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   else if (selectedAction == connectToGroup){
     dispatcher->connectInterToGroup(ifaceItem);
   }
   else if (selectedAction == connectToGroup){
     dispatcher->connectInterToGroup(ifaceItem);
   }
-  else if (selectedAction == disconnectFromGroup) {
-    dispatcher->disconnectInterFromGroup(ifaceItem);
-  }
   else if (selectedAction == cloneInterface){
   else if (selectedAction == cloneInterface){
-    dispatcher->duplicateInterface(ifaceItem);
+    dispatcher->duplicateInterfaceItem(ifaceItem);
   }
   else if (selectedAction == openWindow){
     dispatcher->showRaiseWindow(this);
   }
   }
   else if (selectedAction == openWindow){
     dispatcher->showRaiseWindow(this);
   }
-  else if(selectedAction == showRstClkInter){
-    dispatcher->showRstClkInter(this);
+  else if(selectedAction == showRstClkIface) {
+    dispatcher->showRstClkIface(this);
+  }
+  else if(selectedAction == showWishboneIface) {
+    dispatcher->showWishboneIface(this);
   }
   }
-  else if(selectedAction == showParameters){
+  else if(selectedAction == showParameters) {    
     new ParametersWindow(refBlock, params, NULL);
   }
     new ParametersWindow(refBlock, params, NULL);
   }
+  else if(selectedAction == showPatterns) {    
+    dispatcher->showPatterns(ifaceItem);
+  }
 }
 }
+
 void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
 
   bool ok = false;
 void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
 
   bool ok = false;
@@ -641,7 +667,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   int dimY = dimensionStr.at(1).toInt(&ok);
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   int dimY = dimensionStr.at(1).toInt(&ok);
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
-
+  
   ReferenceBlock *referenceMd5 = NULL;
   ReferenceBlock *referenceXml = NULL;
   ReferenceBlock *reference = NULL;
   ReferenceBlock *referenceMd5 = NULL;
   ReferenceBlock *referenceXml = NULL;
   ReferenceBlock *reference = NULL;
@@ -660,8 +686,9 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   else {
     reference = referenceMd5;
   }
   else {
     reference = referenceMd5;
   }
+  
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
-  FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
+  FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference);
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
     reading bif_iface tags. Thus interface are all removed.
   */
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
     reading bif_iface tags. Thus interface are all removed.
   */
@@ -688,9 +715,9 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     blockParam = functionalBlock->getParameterFromName(name);
     if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
     blockParam->setValue(value);
     blockParam = functionalBlock->getParameterFromName(name);
     if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
     blockParam->setValue(value);
-  }
+  }  
 
 
-  // recreate all interface because of some may have a multiplicity>1 with several examplars
+  // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars
   functionalBlock->removeAllInterfaces();
   QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
   // setting interfaces (user name, and for multiplicity>1 may be create some new ones)
   functionalBlock->removeAllInterfaces();
   QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
   // setting interfaces (user name, and for multiplicity>1 may be create some new ones)
@@ -705,12 +732,28 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
     if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
+    cout << "creating iface from reference named " << qPrintable(refName) << endl;
     FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
     functionalInterface->setName(name);
     functionalBlock->addInterface(functionalInterface);
     FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
     functionalInterface->setName(name);
     functionalBlock->addInterface(functionalInterface);
+    
+    // searching for control interface
+    QString ctlRefName = refName+"_enb";
+    ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName));
+    
+    if (ctlRefIface != NULL) {
+      cout << "found a control iface:" << qPrintable(ctlRefName) << endl;
+      FunctionalInterface *ctlIface = new FunctionalInterface(functionalBlock,ctlRefIface);      
+      if (! ctlIface->setAssociatedIface(functionalInterface)) {
+        throw(Exception(PROJECTFILE_CORRUPTED));
+      }      
+      ctlIface->setName(name+"_enb");
+      functionalBlock->addInterface(ctlIface);
+    }    
   }
   }
+  
   // creating InterfaceItem
   // creating InterfaceItem
-  initInterfaces();
+  initInterfaceItems();
   // setting them with saved values
   for(int i=0; i<interfaceNodes.length(); i++){
 
   // setting them with saved values
   for(int i=0; i<interfaceNodes.length(); i++){
 
@@ -729,7 +772,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) 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));
 
-    InterfaceItem *interfaceItem = searchInterfaceByName(name);
+    InterfaceItem *interfaceItem = searchInterfaceItemByName(name);
     interfaceItem->setId(id);
     interfaceItem->setOrientation(orientation);
     interfaceItem->setPositionRatio(position);
     interfaceItem->setId(id);
     interfaceItem->setOrientation(orientation);
     interfaceItem->setPositionRatio(position);
@@ -745,7 +788,7 @@ void BoxItem::save(QXmlStreamWriter &writer) {
     writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
     writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
     writer.writeAttribute("name",refBlock->getName());
     writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
     writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
     writer.writeAttribute("name",refBlock->getName());
-    QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+    QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);
@@ -786,7 +829,7 @@ void BoxItem::save(QXmlStreamWriter &writer) {
 
     writer.writeAttribute("id",QString::number(id));
     writer.writeAttribute("inside_group",QString::number(childGroupItem->getId()));
 
     writer.writeAttribute("id",QString::number(id));
     writer.writeAttribute("inside_group",QString::number(childGroupItem->getId()));
-    QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+    QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);