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.

Location:
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/include/window.h

    r30 r32  
    4040#include <qevent.h>
    4141#include <qfiledialog.h>
    42 
     42#include <qscrollarea.h>
     43#include <qcombobox.h>
     44#include <qspinbox.h>
    4345
    4446#include "Tools/Viewer/Parser/include/parser.h"
     
    7274  void _setParse(Parse *p);  //parse the base
    7375  void _init_file();    //search component and port before drawing
     76
    7477 private slots:
    7578   
    7679  void _open(); //open a file
    77  void _open_error();
     80  void _open_error();
    7881
    7982  void _save(); //save a file
     
    9093  void _defautZoom();
    9194
    92   void _level(); 
     95  void _level();
    9396  void _informations(); //show or hide informations window
    9497  void _parameters(); //show or hide parameters window
     
    98101
    99102  void _back();//return to the previous view
    100   void _cancel_selection();
    101   void _apply();
     103  void _cancel_selection();//cancel the selection of a component
     104  void _apply();//apply the parameters changes
     105  void currentIndexChanged(QString s);
     106  void valueChanged(int i);
    102107
    103108 protected :
    104   void mousePressEvent (QMouseEvent *); //mouse handler when mouse pressed
    105   void mouseMoveEvent (QMouseEvent *); //mouse handler in other case
     109   void mousePressEvent (QMouseEvent *); //mouse handler when mouse pressed
     110   void mouseMoveEvent (QMouseEvent *); //mouse handler in other case
    106111 private :
    107112  void wparameters(); // parameters window builder
     
    110115  void repaint(); //repaint the panel with current parameters
    111116  void drawPort(int x,int y,int pos,string dir); //draw the components ports
    112   void write_name(string name); //write the name of the component clicked name in the informations window
     117  void write_name(string type,string name); //write the name of the component clicked name in the informations window
    113118  void write_comment(string comment);
    114119  void write_type(string t);
     120  void erase_line(QLabel *l1, QLabel *l2);//erase a line in the informations window
     121  void erase_comment();//erase and hide the comment line in the informations window
     122  void display_param();//display the parameters
    115123
    116124  QList <Port> port_east; //ports lists
     
    118126  QList <Port> port_north;
    119127  QList <Port> port_south;
    120   QList <Component> *compo;
    121 
    122   QWidget *wparam;//windows widget (informations, parameters, open, save ...)
     128  QList <Component> *compo;//component list
     129  QList <Param> param;//parameters list
     130  QList <Group> *group;//groups list
     131
     132  QWidget *wscroll;
     133  QMainWindow *wparam;//windows widget (informations, parameters, quit, open)
    123134  QWidget *winfo;
    124   QWidget *ws;
    125135  QWidget *wq;
    126136  QWidget *wa;
     
    130140  QBoxLayout *informations; //informations box
    131141  QBoxLayout *parameters; //parameters box
     142  QBoxLayout *pbox;
    132143
    133144  Parse *parse; //the parser
     
    139150  QPainter painter;
    140151
    141   QStatusBar *status;
     152  QStatusBar *status;//status bar
    142153
    143154  QLineEdit *file_name; //retrieve the name user wants to open from the open window
     
    157168  int window_height; //main window size
    158169  int window_width;
    159   int margeX;//size of the marge
    160   int margeY;
    161170  int portX;//port size, position and size of components, used when drawing the architecture
    162171  int portY;
    163   int posX;
     172  int posX;//used to retrieve the position and the size of a component
    164173  int posY;
    165174  int tailleX;
    166175  int tailleY;
    167176
    168   int cpt_level;
    169   QString tab[50];
     177  int cpt_level;//level in the architecture
     178  QString tab[20];//save the father when user change the level
    170179
    171180  QString father;//father name
    172181  QString current;//name of the current architecture visible
    173182
     183  QScrollArea *sc;
     184
    174185  bool save_as;
    175   bool first_save;
    176186  bool info_open; //know if the informations window opened or not
    177187  bool param_open; //know if the parameters window opened or not
     
    187197  bool mess_open;//chargment message box opened or not
    188198  bool component_clicked;//if user clicked on a component to modify its parameters
    189 
    190 
     199  bool apply_display;//if the apply button is displayed
     200  bool scroll_hide;
     201  bool parameter_modify;
    191202};
    192203      };
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_about_actions.cpp

    r21 r32  
    66using namespace morpheo::tools::viewer::graphics;
    77
    8 
     8/*about window constructor*/
    99void Window::_about(){
    1010  QMessageBox *mess = new QMessageBox(this);
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_drawAll.cpp

    r30 r32  
    1313  QString t;
    1414 
     15 
    1516  if(paint){
     17    /*draw the main component*/
    1618    painter.begin(this);
    1719    painter.setPen(Qt::blue);
    1820    painter.drawRect(MARGEX,MARGEY,MARGEX+450,MARGEY+450);
     21   
     22    Entity *e = p.getEntity();
     23    string s;
     24    s.append(e->getName());
     25    s.append(" : ");
     26    s.append(e->getType());
     27    painter.setPen(Qt::black);
     28    painter.drawText(50,10,500,60,Qt::AlignCenter,QString::fromStdString(s));
     29    painter.setPen(Qt::blue);
    1930
    20    
     31    /*draw the ports of the main component*/
    2132    for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){
    2233      portX = it->get_x();
     
    4354      portX = it->get_x() ;
    4455      portY = it->get_y() ;
    45       drawPort(portX + MARGEX,portY+MARGEY,SOUTH,it->getDirection());
     56      drawPort(portX + MARGEX,portY+ MARGEY + 20 ,SOUTH,it->getDirection());
    4657
    4758    }
    4859   
     60    /*draw the components inside the main component*/
    4961    if(p.getArchitecture()!=NULL){
    5062      compo = p.getComponent();
     
    6173          schema=tp.getSchema();
    6274          switch(schema){
    63           case 0:
     75          case 0://a basic element
    6476            painter.drawRect(posX,posY,tailleX,tailleY);
    6577            break;
    66           case 1:
     78          case 1://a combinatoire element
    6779            painter.drawEllipse(posX,posY,tailleX,tailleY);
    6880            break; 
    69           case 2:
     81          case 2://a FIFO
    7082            painter.drawRect(posX,posY,tailleX,tailleY);
    7183            painter.drawLine(posX+tailleX/4,posY+tailleY,posX+tailleX/4,posY);
     
    7385            painter.drawLine(posX+3*tailleX/4,posY+tailleY,posX+3*tailleX/4,posY);
    7486            break;
    75           case 3:
     87          case 3://a register
    7688            painter.drawRect(posX,posY,tailleX,tailleY);
    7789            painter.drawLine(posX,posY+tailleY,posX+tailleX/2,posY+tailleY/2);
     
    8395        if (componentName){
    8496          QString compo_name = QString::fromStdString(it->getName());
    85           painter.drawText(posX , posY + tailleY/2,compo_name);
     97          painter.drawText(posX - compo_name.size()/2 , posY + tailleY/2,compo_name);
    8698        }
     99
     100        /*draw the ports of the inside components*/
    87101        Coord *co2=new Coord( co->get_hg_x() + tailleX/2, co->get_hg_y() + tailleY/2,tailleX/2,tailleY/2);
    88102
     
    124138        QList<PortMap> *pm=it->getPortMap();
    125139       
     140        /*draw the signals*/
    126141        for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3)
    127142          {
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_drawPort.cpp

    r20 r32  
    55using namespace morpheo::tools::viewer::graphics;
    66
     7/*draw the port in rectangular form*/
    78void Window::drawPort(int x,int y,int pos,string dir){
    89    if(pos == NORTH){
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_file_actions.cpp

    r30 r32  
    99/*signals actions implementation*/
    1010
     11/*open function*/
    1112void Window::_open(){
    1213  QString current2;
    1314  if(!file_open && is_save){//if no file open or if the file opened has been saved -> open other file, else -> ask for saving file
    1415    current2 = QFileDialog::getOpenFileName(this,"", "./data");
     16    this->setDisabled(true);
     17    /*if a file has been opened*/
    1518    if(current2!=""){
    16       this->setDisabled(true);
    1719      current_name = current2;
    1820      if(parse->open_file( current_name.toStdString(),0)==-1)
     
    5456}
    5557
     58/*initialize the database when a file has been opened*/
    5659void Window::_init_file(){
    5760  is_save = true;
    5861  base = parse->getBaseV();//parse the base and open the file
    59   #ifdef DEBUG_ALL
     62  //#ifdef DEBUG_ALL
    6063  base->afficheBaseConsole();
    61   #endif
     64  //#endif
    6265  cpt_level = 0;
    6366 
     
    7578  paint = true;
    7679  repaint();
     80  display_param();
    7781  this->setDisabled(false);
    7882  setMouseTracking(true);
    7983}
    8084
     85/*if user entered a wrong file name*/
    8186void Window::_open_error(){
    8287  QMessageBox *error = new QMessageBox(this);
     
    8489  error->addButton("ok",QMessageBox::YesRole);
    8590  error->show(); 
     91  this->setDisabled(false);
    8692
    8793
    88 
     94/*save functions*/
    8995void Window::_save(){
    9096  if(file_open){
    9197    if (wa_open)
    9298      wa->close();
    93     if(save_as || first_save || (current_name==NULL)){//if "save as" or if it's the first time the user click on save (new file) -> save as
     99    if(save_as){//if "save as"
    94100      current_name = QFileDialog::getSaveFileName(this,"","./data");
    95101      save_as = false;
    96       first_save = false;
     102      parse->save_file(current_name.toStdString(),0);
    97103    }
    98104    else {
    99       status->showMessage("file " + current_name + " saved",900);
     105      parse->save_file(current.toStdString(),0);
     106      status->showMessage("file " + current + " saved",900);
    100107      is_save = true;//file saved
    101108    }
     
    133140}
    134141
     142/*close function*/
    135143void Window::_close(){
    136144  paint = false;
     145  repaint();
    137146  parse->closeBaseV();
    138   lname->setText("");
    139   ln->setText("");
    140   lt->setText("");
    141   write_name("");
    142   write_comment("");
    143   comment->hide();
     147  erase_line(ln,lname);
     148  erase_line(lt,ltype);
     149  erase_comment();
    144150  winfo->show();
     151  wscroll->hide();
     152  scroll_hide = true;
     153  wparam->show();
    145154  file_open = false;
    146   repaint();
    147155}
    148156
     157/*quit functions*/
    149158void Window::_quit(){
    150159  //if the file is not saved -> ask to the user if he wants to save it. If yes -> save, else quit.
     
    171180    _quit2();
    172181}
    173  
     182/*close all the windows opened*/
    174183void Window::_quit2(){
    175184  /*test if there are windows (other than the main window) opened*/
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_informations_window.cpp

    r30 r32  
    77using namespace morpheo::tools::viewer::graphics;
    88
     9/*informations window constructor*/
    910void Window::winformations()
    1011{
     
    1213  informations = new QBoxLayout(QBoxLayout::TopToBottom,0);
    1314  winfo->setWindowTitle("informations");
    14   winfo->setFixedSize(350,292);
     15  winfo->setFixedSize(370,180);
    1516  winfo->move(628,50);
     17 
    1618
     19  /*name line*/
    1720  QBoxLayout *bname = new QBoxLayout(QBoxLayout::LeftToRight,0);
    1821  ln = new QLabel();
     
    2326  bname->addWidget(lname);
    2427
     28  /*type line*/
    2529  QBoxLayout *btype = new QBoxLayout(QBoxLayout::LeftToRight,0);
    2630  lt = new QLabel();
     
    3034  btype->addWidget(lt);
    3135  btype->addWidget(ltype);
    32 
     36 
     37  /*comment line*/
    3338  comment = new QLineEdit();
    3439  comment->setText("");
    3540  comment->setReadOnly(true);
    3641
     42  /*buttons*/
    3743  QPushButton *noselect = new QPushButton("cancel selection",wparam);
    3844  QPushButton *back = new QPushButton("back",wparam);
     
    5056}
    5157
     58/*write the comment of the componenet selected*/
    5259void Window::write_comment(string cm){
    5360  QString c = QString::fromStdString(cm);
    5461  comment->setText(c);
     62  comment->setCursorPosition(1);
    5563  comment->show();
    5664}
    5765
    58 void Window::write_name(string name){
    59   QString n = QString::fromStdString(name);
    60   lname->setText(n);
     66void Window::erase_comment(){
     67  comment->setText("");
     68  comment->hide();
     69}
     70/*write the name of the component selected*/
     71void Window::write_name(string type,string name){
     72  QString n = QString::fromStdString(type);
     73  ln->setText(n);
     74  QString n2 = QString::fromStdString(name);
     75  lname->setText(n2);
    6176}
    6277
     78void Window::erase_line(QLabel *l1, QLabel *l2){
     79  l1->setText("");
     80  l2->setText("");
     81}
     82
     83/*write the type of the component selected*/
    6384void Window::write_type(string type){
    6485  lt->setText("type");
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_main.cpp

    r26 r32  
    1616int main (int argc, char* argv[])
    1717{
     18  /*if to many arguments*/
    1819  if(argc>2){
    1920    cout << "error : argument must be a file name or nothing" << endl;
     
    2223  }
    2324
     25  /*construct the base*/
    2426  Parse *par = new Parse();
    2527 
    26  
     28  /*create the window application*/
    2729   QApplication *a=new QApplication (argc,argv); 
    2830   
    29   if(argc == 2){
     31   if(argc == 2){
    3032     if(par->open_file(argv[1],0)==-1){
    3133        cout << "file doesn't exist or is not a valid format" << endl; 
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_main_window.cpp

    r30 r32  
    1616  component_clicked = false;
    1717  cpt_level=0;
    18  
     18  apply_display = false;
     19  scroll_hide = false;
     20  parameter_modify = false;
     21
    1922  /*menu bar*/
    2023  QMenuBar *menu_bar = new QMenuBar(this);
     
    122125
    123126  /*main window title*/
    124   this->setWindowTitle("Viewer");
     127  this->setWindowTitle("Morpheo Viewer");
    125128   
    126129  /*parameters window creation*/
     
    145148  /*file unsaved at init*/
    146149  save_as = false;
    147   first_save = false; //first_save = true for a new file
    148150 
    149151  current_name = name;
  • 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){
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_parameters_window.cpp

    r30 r32  
    77using namespace morpheo::tools::viewer::graphics;
    88
     9/*parameters window constructor*/
    910void Window::wparameters()
    1011{
    11   wparam = new QWidget();
     12  wparam = new QMainWindow();
     13  //  wparam = new QWidget();
    1214  parameters = new QBoxLayout(QBoxLayout::TopToBottom,0);
    1315  wparam->setWindowTitle("parameters");
    14   wparam->setFixedSize(350,300);
    15   wparam->move(628,370);
    16 
    17  
    18   QPushButton *apply = new QPushButton("apply",wparam);
    19   connect(apply,SIGNAL(clicked()),this,SLOT(_apply()));
    20  
    21   parameters->addWidget(apply);
    22 
     16  wparam->setFixedSize(370,415);
     17  wparam->move(628,255);
    2318  wparam->setLayout(parameters);
     19  sc = new QScrollArea(wparam);
     20  wscroll = new QWidget();
     21  sc->setWidgetResizable(false);
     22  sc->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     23  sc->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     24  sc->setGeometry(2,2,365,410);
    2425  wparam->show();
    2526}
    2627
    27 
     28/*display the parameters*/
     29void Window::display_param(){
     30
     31  pbox = new QBoxLayout(QBoxLayout::TopToBottom,0);
     32
     33  string scpu;
     34  string lgroup;
     35  string sparam;
     36  string ecart;
     37 
     38  if(!apply_display){
     39    QPushButton *apply = new QPushButton("apply",wparam);
     40    connect(apply,SIGNAL(clicked()),this,SLOT(_apply()));
     41    apply->setFixedSize(310,25);
     42    pbox->addWidget(apply);
     43    apply_display = true;
     44  }
     45 
     46  /*top level name display*/
     47  QLabel *cpu = new QLabel();
     48  scpu.append("CPU : ");
     49  scpu.append(parse->getTopLevelName());
     50  scpu.append(" \n");
     51  cpu ->setText(QString::fromStdString(scpu));
     52  cpu->setFixedSize(300,50);
     53  pbox->addWidget(cpu);
     54 
     55   /*architecture in tree view display*/
     56   group = base->getGroups();
     57   for(QList<Group>::iterator it=group->begin();it!=group->end();++it){
     58   QLabel *lg = new QLabel();
     59   lgroup = "";
     60   lg->setFixedSize(200,30);
     61   ecart = "";
     62   if(it->getLevel() == 1)
     63     ecart.append("     ");
     64   if(it->getLevel() == 2)
     65     ecart.append("        ");
     66   if(it->getLevel() == 3)
     67     ecart.append("          ");
     68   if(it->getLevel() == 4)
     69     ecart.append("            ");
     70    if(it->getLevel() == 5)
     71      ecart.append("              ");
     72    lgroup.append(ecart);
     73    lgroup.append("<");
     74    lgroup.append(it->getName());
     75    lgroup.append(">");
     76    lg->setText(QString::fromStdString(lgroup));
     77    pbox->addWidget(lg);
     78    param = it->getParam();
     79    for(QList<Param>::iterator it2=param.begin();it2!=param.end();++it2){
     80
     81      if(it2->getName() == "id"){
     82        QBoxLayout *b = new QBoxLayout(QBoxLayout::LeftToRight,0);
     83        QLabel *l = new QLabel();
     84        QString st2 = "   ";
     85        QString st;
     86        st2.append(QString::fromStdString(ecart));
     87        st2.append("nb_");
     88        st2.append(QString::fromStdString(it->getName()));
     89
     90        st.append("nb_");
     91        st.append(QString::fromStdString(it->getName()));
     92        LimitParam lp = base->searchLimitParam(st.toStdString());
     93
     94        QLabel *lab = new QLabel();
     95        QString s = "   ";
     96        s.append(QString::fromStdString(ecart));
     97        s.append(QString::fromStdString(it2->getName()));
     98        s.append(" : ");
     99        stringstream out;
     100        string str;
     101        out << it2->getValue();
     102        str = out.str();
     103        s.append(QString::fromStdString(str));
     104        lab->setText(s);
     105        pbox->addWidget(lab);
     106        l->setText(st2);
     107        QSpinBox *spin = new QSpinBox();
     108        int min = lp.getMin();
     109        int max = lp.getMax();
     110        QString step = QString::fromStdString(lp.getStep());
     111       
     112        spin->setValue(base->nbGroup(it->getName()));
     113       
     114        if(step.contains("+")){
     115          step = step.right(step.length()-1);
     116          int pas = step.toInt(0,10);
     117          spin->setMinimum(min);
     118          spin->setMaximum(max);
     119          spin->setSingleStep(pas);
     120        }
     121     
     122        if(step.contains("*")){
     123          step = step.right(step.length()-1);
     124          int pas = step.toInt(0,10);
     125          spin->setMinimum(min);
     126          spin->setMaximum(max);
     127          spin->setSingleStep(pas);
     128        }
     129        spin->setFixedSize(60,30);
     130
     131        QString name_obj = (QString::fromStdString(it->getName()));
     132        spin->setObjectName(name_obj);
     133
     134        b->addWidget(l);
     135        b->addWidget(spin);
     136        pbox->addLayout(b);
     137
     138        connect(spin,SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
     139
     140      }
     141      else{
     142        QBoxLayout *b = new QBoxLayout(QBoxLayout::LeftToRight,0);
     143        QLabel *l = new QLabel();
     144        sparam ="   ";
     145        sparam.append(ecart);
     146        sparam.append(it2->getName());
     147        sparam.append(" : ");
     148        stringstream out;
     149        string str;
     150        out << it2->getValue();
     151        str = out.str();
     152        sparam.append(str);
     153        l->setText(QString::fromStdString(sparam));
     154        l->setFixedSize(200,30);
     155        parameters->addWidget(l);
     156        QComboBox *cb = new QComboBox();
     157        LimitParam lp = base->searchLimitParam(it2->getName());
     158        int min = lp.getMin();
     159        int max = lp.getMax();
     160        QString step = QString::fromStdString(lp.getStep());
     161        int value = min;
     162        if(step.contains("+")){
     163          step = step.right(step.length()-1);
     164          int pas = step.toInt(0,10);
     165          while(value!=max+pas){
     166            stringstream out2;
     167            string str2;
     168            out2 << value;
     169            str2 = out2.str();
     170            cb->addItem(QString::fromStdString(str2));
     171            value = value+pas;
     172          }
     173        }
     174        if(step.contains("*")){
     175          step = step.right(step.length()-1);
     176          int pas = step.toInt(0,10);
     177          while(value!=max*pas){
     178            stringstream out2;
     179            string str2;
     180            out2 << value;
     181            str2 = out2.str();
     182            cb->addItem(QString::fromStdString(str2));
     183            value = value*pas;
     184          }
     185        }
     186        stringstream out3;
     187        string str3;
     188        out3 << it2->getValue();
     189        str3 = out3.str();
     190        int index = cb->findText(QString::fromStdString(str3));
     191        cb->setCurrentIndex(index);
     192        cb->setFixedSize(60,30);
     193        //QPushButton *pb = new QPushButton();
     194        //pb->setText("change");
     195        QString name_obj = (QString::fromStdString(it->getName()));
     196        name_obj.append(":");
     197        name_obj.append( QString::fromStdString(it2->getName()));
     198        name_obj.append(":");
     199        name_obj.append(cb->currentText());
     200        cb->setObjectName(name_obj);
     201        //cb->setFixedSize(60,30);
     202        QString new_value = cb->currentText();
     203        connect(cb,SIGNAL(currentIndexChanged(QString)),this,SLOT(currentIndexChanged(QString)));
     204        //connect(pb,SIGNAL(clicked()),this,SLOT(_change_value()));
     205        b->addWidget(l);
     206        b->addWidget(cb);
     207        //b->addWidget(pb);
     208        pbox->addLayout(b);
     209      }
     210    }
     211   }
     212 
     213  wscroll->setLayout(pbox);
     214  parameters->addWidget(wscroll);
     215  sc->setWidget(wscroll);
     216  if(scroll_hide){
     217    scroll_hide = false;
     218    wscroll->show();
     219  }
     220}
     221
     222void Window::currentIndexChanged(QString value2){
     223  //cout << QObject::sender()->objectName().toStdString() << endl;
     224 
     225  QString obj = QObject::sender()->objectName();
     226 
     227  int i,j,v;
     228  QString param,group,value;
     229  i = obj.indexOf(":");
     230  group = obj.left(i);
     231  //cout << "group : " << group.toStdString() << endl;
     232  j = obj.indexOf(":",i+1);
     233  value = obj.right(obj.size() - j - 1);
     234  v = value2.toInt(0,10);
     235  cout << "value : " << v << endl;
     236  param = obj.section(":",1,1);
     237  //cout << "param : " << param.toStdString() << endl;
     238
     239  base->modifyValue(group.toStdString(),param.toStdString(),v);
     240  wparam->close();
     241  apply_display = false;
     242  wparameters();
     243  display_param();
     244  parameter_modify = true;
     245}
     246
     247
     248void Window::valueChanged(int i){
     249
     250  //cout << QObject::sender()->objectName().toStdString() << endl;
     251
     252  QString obj = QObject::sender()->objectName();
     253  int v,j;
     254  //cout << "name : " << obj.toStdString() << endl;
     255  v = i;
     256  //cout << "value : " << v << endl;
     257 
     258  j = base->nbGroup(obj.toStdString());
     259  v = v - j;
     260  cout << "value : " << v << " " << j<< endl;
     261  if(base->modifyGroup(obj.toStdString(),v)==-1){
     262    cout << "error" << endl;
     263    exit(1);
     264  }
     265  wparam->close();
     266  apply_display = false;
     267  wparameters();
     268  parameter_modify = true;
     269  display_param();
     270  //  base->afficheParamConsole();
     271}
     272
     273/*apply the parameters changes*/
    28274void Window::_apply(){
    29   cout << "apply\n";
    30 }
     275  if(!parameter_modify){
     276    QMessageBox *m = new QMessageBox(wparam);
     277    m->setText("no parameter changed");
     278    m->addButton("ok",QMessageBox::YesRole);
     279    m->show();
     280  }
     281  else{
     282    parameter_modify = false;
     283    cout << "apply\n";
     284  }
     285}
  • trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_tools_actions.cpp

    r21 r32  
    66using namespace morpheo::tools::viewer::graphics;
    77
     8/*zoom functions*/
    89void Window::_zoomIn(){
    910  cout << "zoom in" << endl;
     
    2223}
    2324
     25/*open or close the informations window*/
    2426void Window::_informations(){
    2527  if(!info_open){//if the informations window is not open, open it,else close it
     
    3335}
    3436
     37/*open or close the parameters window*/
    3538void Window::_parameters(){//if the parameteres  window is not open, open it,else close it
    3639  if(!param_open){
    3740    this->wparameters();
    3841    param_open = true;
     42    if(info_open){
     43      apply_display = false;
     44      display_param();
     45    }
    3946  }
    4047  else{
     
    4451}
    4552
     53/*display or hide the components name*/
    4654void Window::_component_name(){
    4755
     
    5462}
    5563
     64/*display or hide the signals name*/
    5665void Window::_signal_name(){
    5766
Note: See TracChangeset for help on using the changeset viewer.