Ignore:
Timestamp:
May 30, 2007, 12:08:56 PM (17 years ago)
Author:
chou
Message:

Morpheo Viewer Release 5.0
Réalisation des étapes 3 (fin) et 4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_mouseEvent.cpp

    r30 r32  
    66using namespace morpheo::tools::viewer::graphics;
    77
     8/*mouse press event handler*/
    89void Window::mousePressEvent (QMouseEvent *e){
    910  if(paint && (p.getArchitecture() != NULL)){
     
    1617    mouseY = mouseEvent->y();
    1718   
    18     bool bc = false;
     19    bool bc,b3 = false;
    1920    int cx,cy,tx,ty;
    20     string cc,nc,type;
     21    string s2,cc,nc,type,comm;
    2122    bool found = false;
    2223
     24    /*search the component under the mouse focus*/
    2325    for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
    2426      Coord *co = it->get_Position();
     
    2830      int tailley = co->get_size_y();
    2931      QString t=QString::fromStdString(it->getType()).toLower();
     32      /*go to the next level if comoponent doubleclicked*/
    3033      if(e->type() == QMouseEvent::MouseButtonDblClick && e->button() == Qt::LeftButton){
    3134       
     
    6669        paint = true;
    6770        repaint();
    68         write_name("");
    69         write_comment("");
    70         write_type("");
    71         ln->setText("");
    72         lt->setText("");
    73         comment->hide();
     71        erase_line(lt,ltype);
     72        erase_line(ln,lname);
     73        erase_comment();
    7474        found = false;
    7575        this->setDisabled(false);
    7676        component_clicked = false;
    7777      }
    78      
     78      /*search and display the informations of the component clicked*/
    7979      if(e->type() == QMouseEvent::MouseButtonPress && e->button() == Qt::LeftButton){
    8080        if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
     
    8888          BaseP tp = base->get_BasePos(t.toStdString());
    8989          if(&tp != NULL)
    90                 cc=tp.getComment();
     90            cc=tp.getComment();
    9191          component_clicked = true;
     92        }
     93       
     94        for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
     95          portX = it->get_x();
     96          portY = it->get_y();
     97          if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
     98            b3 = true;
     99            s2 = it->getName();
     100            comm = it->getComment();
     101            type = it->getDirection();
     102          }
     103        }
     104   
     105        for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
     106          portX = it->get_x() ;
     107          portY = it->get_y() ;
     108          if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
     109            b3 = true;
     110            s2 = it->getName();
     111            comm = it->getComment();
     112            type = it->getDirection();
     113          }
     114        }
     115   
     116        for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
     117          portX = it->get_x() ;
     118          portY = it->get_y() ;
     119          if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
     120            b3 = true;
     121            s2 = it->getName();
     122            type = it->getDirection();
     123            comm = it->getComment();
     124          }
     125        }
     126   
     127        for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
     128          portX = it->get_x() ;
     129          portY = it->get_y() ;
     130          if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
     131            b3 = true;
     132            s2 = it->getName();
     133            comm = it->getComment();
     134            type = it->getDirection();
     135          }
    92136        }
    93137      }
    94138    }
    95139    if(bc){
    96       write_name(nc);
     140      write_name("component",nc);
    97141      write_type(type);
    98       ln->setText("component");
    99       lt->setText("type");
    100142      write_comment(cc);
     143    }
     144    if(b3){
     145      write_name("signal",s2);
     146      write_type(type);
     147      write_comment(comm);
     148      component_clicked = true;
    101149    }
    102150  }
    103151}
    104152
    105 
     153/*mouse move event handler*/
    106154void Window::mouseMoveEvent(QMouseEvent *e){
    107155  bool b  = false;
     
    110158  int px,py,taillex,tailley,ppx,ppy;
    111159  string s,s2,c,type;
    112 
    113    if(paint && (p.getArchitecture() != NULL) && !component_clicked){
    114 
    115     compo = p.getComponent();
    116    
    117     QMouseEvent *mouseEvent = (QMouseEvent *) e;
    118 
    119     mouseX = mouseEvent->x();
    120     mouseY = mouseEvent->y();
    121    
    122     for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
    123       Coord *co = it->get_Position();
    124       px = co->get_hg_x();
    125       py = co->get_hg_y();
    126       taillex = co->get_size_x();
    127       tailley = co->get_size_y();
    128       QString t=QString::fromStdString(it->getType()).toLower();
    129       QList<PortMap> *pm=it->getPortMap();
    130 
    131       if(e->type() == QMouseEvent::MouseMove){
    132         if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
    133           b = true;
    134           s = it->getName();
    135           type = it->getType();
    136           BaseP tp=base->get_BasePos(t.toStdString());
    137           if(&tp!=NULL)
    138             c=tp.getComment();
    139           ppx = px;
    140           ppy = py;
    141           break;
    142         }
    143         else{
    144           for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) {
    145                 Signal *sig=base->getSignal(&p,it->getName(),new PortMap(*it3));
    146                 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){
    147                   b2 = true;
    148                   s = it3->getName();
    149                   break;
    150                 }
    151           }
    152         }   
    153       }
    154     }
    155    
    156     if(b){
    157       write_name(s);
    158       write_type(type);
    159       ln->setText("component");
    160       write_comment(c);
    161       lt->setText("type");
    162       b3 = false;
    163       b2 = false;
    164     }
    165    
    166     if(b2){
    167       write_name(s);
    168       write_type("");
    169       lt->setText("");
    170       write_comment("");
    171       ln->setText("signal");
    172       comment->hide();
    173       b3 = false;
    174       b = false;
    175     }
    176 
    177     if(!b && !b2){
    178       write_name("");
    179       write_type("");
    180       ln->setText("");
    181       lt->setText("");
    182       write_comment("");
    183       comment->hide();
    184     }
     160  string comm;
     161
     162   if(paint && !component_clicked){
     163     if(p.getArchitecture() != NULL){
     164
     165       compo = p.getComponent();
     166       
     167       QMouseEvent *mouseEvent = (QMouseEvent *) e;
     168       
     169       mouseX = mouseEvent->x();
     170       mouseY = mouseEvent->y();
     171       
     172       /*display the component under the mouse focus*/
     173       for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){
     174         Coord *co = it->get_Position();
     175         px = co->get_hg_x();
     176         py = co->get_hg_y();
     177         taillex = co->get_size_x();
     178         tailley = co->get_size_y();
     179         QString t=QString::fromStdString(it->getType()).toLower();
     180         QList<PortMap> *pm=it->getPortMap();
     181         
     182         if(e->type() == QMouseEvent::MouseMove){
     183           if(mouseX >= px + MARGEX  && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX  && mouseY <= py+tailley + MARGEY) {
     184             b = true;
     185             s = it->getName();
     186             type = it->getType();
     187             BaseP tp=base->get_BasePos(t.toStdString());
     188             if(&tp!=NULL)
     189               c=tp.getComment();
     190             ppx = px;
     191             ppy = py;
     192             break;
     193           }
     194           else{
     195             for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) {
     196               Signal *sig=base->getSignal(&p,it->getName(),new PortMap(*it3));
     197               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){
     198                 b2 = true;
     199                 s = it3->getName();
     200                 break;
     201               }
     202             }
     203           }   
     204         }
     205       }
     206       
     207       if(b){
     208         write_name("component",s);
     209         write_type(type);
     210         write_comment(c);
     211         b3 = false;
     212         b2 = false;
     213       }
     214     
     215       if(b2){
     216         write_name("signal",s);
     217         erase_line(lt,ltype);
     218         erase_comment();
     219         b3 = false;
     220         b = false;
     221       }
     222     
     223       if(!b && !b2){
     224         erase_line(lt,ltype);
     225         erase_line(ln,lname);
     226         erase_comment();
     227       }
     228     }
     229   
     230     p=base->get_BasePos(current.toStdString());
     231     Entity *ent = p.getEntity();
     232     Coord *c = new Coord(250,250,250,250);
     233     port_east = ent->getPortEast(c);
     234     port_west = ent->getPortWest(c);
     235     port_north = ent->getPortNorth(c);
     236     port_south = ent->getPortSouth(c);
     237
     238     /*display the signal under the mouse focus*/
     239     for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
     240       portX = it->get_x();
     241       portY = it->get_y();
     242       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
     243         b3 = true;
     244         s2 = it->getName();
     245         comm = it->getComment();
     246         type = it->getDirection();
     247       }
     248     }
     249   
     250     for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
     251       portX = it->get_x() ;
     252       portY = it->get_y() ;
     253       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
     254         b3 = true;
     255         s2 = it->getName();
     256         comm = it->getComment();
     257         type = it->getDirection();
     258       }
     259     }
     260   
     261     for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
     262       portX = it->get_x() ;
     263       portY = it->get_y() ;
     264       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
     265         b3 = true;
     266         s2 = it->getName();
     267         comm = it->getComment();
     268         type = it->getDirection();
     269       }
     270     }
     271   
     272     for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
     273       portX = it->get_x() ;
     274       portY = it->get_y() ;
     275       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
     276         b3 = true;
     277         s2 = it->getName();
     278         comm = it->getComment();
     279         type = it->getDirection();
     280       }
     281     }
     282     if(b3){
     283       b = false;
     284       erase_line(ln,lname);
     285       write_type(type);
     286       erase_comment();
     287       write_comment(comm);
     288       write_name("signal",s2);
     289     }
    185290   }
    186  
    187  
    188    for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
    189       portX = it->get_x();
    190       portY = it->get_y();
    191       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
    192         b3 = true;
    193         s2 = it->getName();
    194       }
    195    }
    196    
    197    for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){
    198      portX = it->get_x() ;
    199      portY = it->get_y() ;
    200      if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 + MARGEY){
    201        b3 = true;
    202        s2 = it->getName();
    203      }
    204    }
    205    
    206    for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){
    207      portX = it->get_x() ;
    208      portY = it->get_y() ;
    209      if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 +MARGEY && mouseX <= portX + 15 + MARGEX && mouseY <= portY + 15 +MARGEY){
    210         b3 = true;
    211         s2 = it->getName();
    212      }
    213    }
    214    
    215     for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){
    216       portX = it->get_x() ;
    217       portY = it->get_y() ;
    218       if(mouseX >= portX - 15 + MARGEX && mouseY >= portY - 15 + MARGEY && mouseX <= portX + 15 +MARGEX && mouseY <= portY + 15 + MARGEY){
    219         b3 = true;
    220         s2 = it->getName();
    221       }
    222     }
    223     if(b3){
    224       b = false;
    225       write_name("");
    226       write_name(s2);
    227       write_type(type);
    228       ln->setText("signal");
    229       lt->setText("");
    230       write_comment("");
    231       comment->hide();
    232     }
    233291}
    234292
    235293
    236    
    237  
     294/*return to the previous level if back button has been clicked*/
    238295void Window::_back(){
    239296  if(cpt_level==0){
Note: See TracChangeset for help on using the changeset viewer.