Index: trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_mouseEvent.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_mouseEvent.cpp	(revision 30)
+++ trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_mouseEvent.cpp	(revision 32)
@@ -6,4 +6,5 @@
 using namespace morpheo::tools::viewer::graphics;
 
+/*mouse press event handler*/
 void Window::mousePressEvent (QMouseEvent *e){
   if(paint && (p.getArchitecture() != NULL)){
@@ -16,9 +17,10 @@
     mouseY = mouseEvent->y();
     
-    bool bc = false;
+    bool bc,b3 = false;
     int cx,cy,tx,ty;
-    string cc,nc,type;
+    string s2,cc,nc,type,comm;
     bool found = false;
 
+    /*search the component under the mouse focus*/
     for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
       Coord *co = it->get_Position();
@@ -28,4 +30,5 @@
       int tailley = co->get_size_y();
       QString t=QString::fromStdString(it->getType()).toLower();
+      /*go to the next level if comoponent doubleclicked*/
       if(e->type() == QMouseEvent::MouseButtonDblClick && e->button() == Qt::LeftButton){
 	
@@ -66,15 +69,12 @@
 	paint = true;
 	repaint();
-	write_name("");
-	write_comment("");
-	write_type("");
-	ln->setText("");
-	lt->setText("");
-	comment->hide();
+     	erase_line(lt,ltype);
+	erase_line(ln,lname);
+	erase_comment();
 	found = false;
 	this->setDisabled(false);
 	component_clicked = false;
       }
-      
+      /*search and display the informations of the component clicked*/
       if(e->type() == QMouseEvent::MouseButtonPress && e->button() == Qt::LeftButton){
 	if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
@@ -88,20 +88,68 @@
 	  BaseP tp = base->get_BasePos(t.toStdString());
 	  if(&tp != NULL)
-		cc=tp.getComment();
+	    cc=tp.getComment();
 	  component_clicked = true;
+	}
+	
+	for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
+	  portX = it->get_x();
+	  portY = it->get_y();
+	  if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
+	    b3 = true;
+	    s2 = it->getName();
+	    comm = it->getComment();
+	    type = it->getDirection();
+	  }
+	} 
+   
+	for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
+	  portX = it->get_x() ;
+	  portY = it->get_y() ;
+	  if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
+	    b3 = true;
+	    s2 = it->getName();
+	    comm = it->getComment();
+	    type = it->getDirection();
+	  }
+	}
+   
+	for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
+	  portX = it->get_x() ;
+	  portY = it->get_y() ;
+	  if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
+	    b3 = true;
+	    s2 = it->getName();
+	    type = it->getDirection();
+	    comm = it->getComment();
+	  }
+	}
+   
+	for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
+	  portX = it->get_x() ;
+	  portY = it->get_y() ;
+	  if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
+	    b3 = true;
+	    s2 = it->getName();
+	    comm = it->getComment();
+	    type = it->getDirection();
+	  }
 	}
       }
     }
     if(bc){
-      write_name(nc);
+      write_name("component",nc);
       write_type(type);
-      ln->setText("component");
-      lt->setText("type");
       write_comment(cc);
+    }
+    if(b3){
+      write_name("signal",s2);
+      write_type(type);
+      write_comment(comm);
+      component_clicked = true;
     }
   }
 }
 
-
+/*mouse move event handler*/
 void Window::mouseMoveEvent(QMouseEvent *e){
   bool b  = false;
@@ -110,130 +158,139 @@
   int px,py,taillex,tailley,ppx,ppy;
   string s,s2,c,type;
-
-   if(paint && (p.getArchitecture() != NULL) && !component_clicked){
-
-    compo = p.getComponent();
-    
-    QMouseEvent *mouseEvent = (QMouseEvent *) e;
-
-    mouseX = mouseEvent->x();
-    mouseY = mouseEvent->y();
-    
-    for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
-      Coord *co = it->get_Position();
-      px = co->get_hg_x();
-      py = co->get_hg_y();
-      taillex = co->get_size_x();
-      tailley = co->get_size_y();
-      QString t=QString::fromStdString(it->getType()).toLower();
-      QList<PortMap> *pm=it->getPortMap();
-
-      if(e->type() == QMouseEvent::MouseMove){
-	if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
-	  b = true;
-	  s = it->getName();
-	  type = it->getType();
-	  BaseP tp=base->get_BasePos(t.toStdString());
-	  if(&tp!=NULL)
-	    c=tp.getComment();
-	  ppx = px;
-	  ppy = py;
-	  break;
-	}
-	else{
-	  for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) {
-	  	Signal *sig=base->getSignal(&p,it->getName(),new PortMap(*it3));
-	  	if(mouseX >= sig->get_src_x() - 15  + MARGEX  && mouseY >= sig->get_src_y() - 15 + MARGEY && mouseX <= sig->get_src_x() + 15  + MARGEX  && mouseY <= sig->get_src_y() + 15 +MARGEY){
-		  b2 = true;
-	  	  s = it3->getName();
-		  break;
-	  	}
-	  }
-	}   
-      }
-    }
-    
-    if(b){
-      write_name(s);
-      write_type(type);
-      ln->setText("component");
-      write_comment(c);
-      lt->setText("type");
-      b3 = false;
-      b2 = false;
-    }
-    
-    if(b2){
-      write_name(s);
-      write_type("");
-      lt->setText("");
-      write_comment("");
-      ln->setText("signal");
-      comment->hide();
-      b3 = false;
-      b = false;
-    }
-
-    if(!b && !b2){
-      write_name("");
-      write_type("");
-      ln->setText("");
-      lt->setText("");
-      write_comment("");
-      comment->hide();
-    }
+  string comm;
+
+   if(paint && !component_clicked){
+     if(p.getArchitecture() != NULL){
+
+       compo = p.getComponent();
+       
+       QMouseEvent *mouseEvent = (QMouseEvent *) e;
+       
+       mouseX = mouseEvent->x();
+       mouseY = mouseEvent->y();
+       
+       /*display the component under the mouse focus*/
+       for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
+	 Coord *co = it->get_Position();
+	 px = co->get_hg_x();
+	 py = co->get_hg_y();
+	 taillex = co->get_size_x();
+	 tailley = co->get_size_y();
+	 QString t=QString::fromStdString(it->getType()).toLower();
+	 QList<PortMap> *pm=it->getPortMap();
+	 
+	 if(e->type() == QMouseEvent::MouseMove){
+	   if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
+	     b = true;
+	     s = it->getName();
+	     type = it->getType();
+	     BaseP tp=base->get_BasePos(t.toStdString());
+	     if(&tp!=NULL)
+	       c=tp.getComment();
+	     ppx = px;
+	     ppy = py;
+	     break;
+	   }
+	   else{
+	     for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) {
+	       Signal *sig=base->getSignal(&p,it->getName(),new PortMap(*it3));
+	       if(mouseX >= sig->get_src_x() - 15  + MARGEX  && mouseY >= sig->get_src_y() - 15 + MARGEY && mouseX <= sig->get_src_x() + 15  + MARGEX  && mouseY <= sig->get_src_y() + 15 +MARGEY){
+		 b2 = true;
+		 s = it3->getName();
+		 break;
+	       }
+	     }
+	   }   
+	 }
+       }
+       
+       if(b){
+	 write_name("component",s);
+	 write_type(type);
+	 write_comment(c);
+	 b3 = false;
+	 b2 = false;
+       }
+     
+       if(b2){
+	 write_name("signal",s);
+	 erase_line(lt,ltype);
+	 erase_comment();
+	 b3 = false;
+	 b = false;
+       }
+     
+       if(!b && !b2){
+	 erase_line(lt,ltype);
+	 erase_line(ln,lname);
+	 erase_comment();
+       }
+     }
+   
+     p=base->get_BasePos(current.toStdString());
+     Entity *ent = p.getEntity();
+     Coord *c = new Coord(250,250,250,250);
+     port_east = ent->getPortEast(c);
+     port_west = ent->getPortWest(c);
+     port_north = ent->getPortNorth(c);
+     port_south = ent->getPortSouth(c);
+
+     /*display the signal under the mouse focus*/
+     for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
+       portX = it->get_x();
+       portY = it->get_y();
+       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
+	 b3 = true;
+	 s2 = it->getName();
+	 comm = it->getComment();
+	 type = it->getDirection();
+       }
+     } 
+   
+     for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
+       portX = it->get_x() ;
+       portY = it->get_y() ;
+       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
+	 b3 = true;
+	 s2 = it->getName();
+	 comm = it->getComment();
+	 type = it->getDirection();
+       }
+     }
+   
+     for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
+       portX = it->get_x() ;
+       portY = it->get_y() ;
+       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
+	 b3 = true;
+	 s2 = it->getName();
+	 comm = it->getComment();
+	 type = it->getDirection();
+       }
+     }
+   
+     for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
+       portX = it->get_x() ;
+       portY = it->get_y() ;
+       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
+	 b3 = true;
+	 s2 = it->getName();
+	 comm = it->getComment();
+	 type = it->getDirection();
+       }
+     }
+     if(b3){
+       b = false;
+       erase_line(ln,lname);
+       write_type(type);
+       erase_comment();
+       write_comment(comm);
+       write_name("signal",s2);
+     }
    }
-  
-  
-   for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
-      portX = it->get_x();
-      portY = it->get_y();
-      if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
-	b3 = true;
-	s2 = it->getName();
-      }
-   } 
-   
-   for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
-     portX = it->get_x() ;
-     portY = it->get_y() ;
-     if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
-       b3 = true;
-       s2 = it->getName();
-     }
-   }
-   
-   for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
-     portX = it->get_x() ;
-     portY = it->get_y() ;
-     if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
-	b3 = true;
-	s2 = it->getName();
-     }
-   }
-   
-    for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
-      portX = it->get_x() ;
-      portY = it->get_y() ;
-      if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
-	b3 = true;
-	s2 = it->getName();
-      }
-    }
-    if(b3){
-      b = false;
-      write_name("");
-      write_name(s2);
-      write_type(type);
-      ln->setText("signal");
-      lt->setText("");
-      write_comment("");
-      comment->hide();
-    }
 }
 
 
-   
- 
+/*return to the previous level if back button has been clicked*/
 void Window::_back(){
   if(cpt_level==0){
