Changeset 26 for trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics
- Timestamp:
- May 22, 2007, 1:09:15 PM (17 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/include/window.h
r21 r26 97 97 void _signal_name(); //show or hide the signals name 98 98 99 void _back(); 99 void _back();//return to the previous view 100 void _cancel_selection(); 101 void _apply(); 100 102 101 103 protected : 102 void mousePressEvent (QMouseEvent *); //mouse handler 103 104 void mousePressEvent (QMouseEvent *); //mouse handler when mouse pressed 105 void mouseMoveEvent (QMouseEvent *); //mouse handler in other case 104 106 private : 105 107 void wparameters(); // parameters window builder … … 111 113 void write_position(int x, int y);//write the position of the position clicked in the informations window 112 114 void write_size(int x, int y);//write the size of the component clicked in the informations window 113 void write_ports(int x);//write the number of the component clicked in the informations window 115 void write_comment(string comment); 116 void erase_position(); 117 void erase_size(); 114 118 115 119 QList <Port> port_east; //ports lists … … 144 148 QString current_name; //name of the current file opened 145 149 146 /*items of the informations window*/ 147 QLabel *lname; //name of the component clicked 150 /*items of the parameters window*/ 148 151 QLineEdit *positionX; //x position 149 152 QLineEdit *positionY;//y position 150 153 QLineEdit *sizeX;//x size 151 154 QLineEdit *sizeY;//y size 152 QLineEdit *nb_ports; 153 154 int cpt_ports;//nb ports of component clicked 155 155 156 /*items of the informations window*/ 157 QLabel *lname;//name of the component clicked 158 QLineEdit *comment;//comment associated with the component clicked 159 int level; //level of architecture 156 160 int mouseX; //mouse position 157 161 int mouseY; … … 167 171 int tailleX; 168 172 int tailleY; 173 174 int cpt_level; 175 QString tab[50]; 169 176 170 177 QString father;//father name … … 188 195 bool charg_open;//back chargement message box opened or not 189 196 bool mess_open;//chargment message box opened or not 197 bool component_clicked;//if user clicked on a component to modify its parameters 198 190 199 191 200 }; -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_drawAll.cpp
r21 r26 12 12 13 13 if(paint){ 14 15 14 painter.begin(this); 16 15 painter.setPen(Qt::blue); 17 16 painter.drawRect(MARGEX,MARGEY,MARGEX+450,MARGEY+450); 18 cpt_ports = 0; 17 19 18 20 19 for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){ … … 22 21 portY = it->get_y(); 23 22 drawPort(portX + MARGEX,portY + MARGEY ,EAST,it->getDirection()); 24 cpt_ports++; 23 25 24 } 26 25 … … 29 28 portY = it->get_y() ; 30 29 drawPort(portX + MARGEX,portY + MARGEY, WEST, it->getDirection()); 31 cpt_ports++; 30 32 31 } 33 32 … … 36 35 portY = it->get_y() ; 37 36 drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it->getDirection()); 38 cpt_ports++; 37 39 38 } 40 39 … … 43 42 portY = it->get_y() ; 44 43 drawPort(portX + MARGEX,portY+MARGEY,SOUTH,it->getDirection()); 45 cpt_ports++; 44 46 45 } 47 46 48 current = "Top Level";49 father = " ";50 47 if(p.getArchitecture()!=NULL){ 51 48 compo = p.getComponent(); … … 102 99 for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) 103 100 { 104 Signal *s=base->getSignal( it->getType(),new PortMap(*it3));101 Signal *s=base->getSignal(&p,it->getName(),new PortMap(*it3)); 105 102 painter.drawLine(s->get_src_x()+MARGEX,s->get_src_y()+MARGEY,s->get_dest_x()+MARGEX,s->get_dest_y()+MARGEY); 106 103 … … 114 111 115 112 } 116 113 if(charg_open){ 117 114 charg_open = false; 118 115 mess_charg->close(); -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_file_actions.cpp
r21 r26 26 26 tree->setRootIndex(dir->index("./data/")); 27 27 file_name = new QLineEdit(wo); 28 file_name->setText("data/");29 28 QPushButton *ok_open = new QPushButton("ok",wo); 30 29 connect(ok_open,SIGNAL(clicked()),this,SLOT(_open_end())); … … 67 66 is_parse=true; 68 67 } 69 if(parse->open_file( current_name.toStdString() )==-1)68 if(parse->open_file( current_name.toStdString(),0)==-1) 70 69 _open_error(); 71 70 else{ … … 79 78 is_save = true; 80 79 base = parse->getBaseV();//parse the base and open the file 81 //base->afficheBaseConsole(); 80 #ifdef DEBUG_ALL 81 base->afficheBaseConsole(); 82 #endif 83 cpt_level = 0; 84 85 tab[cpt_level] = ""; 82 86 file_open = true; 83 87 QList <BaseP> *liste_compo = base->getBaseP(); 84 88 p = liste_compo->at(0); 85 89 entity = p.getEntity(); 90 current = QString::fromStdString(entity->getName()); 86 91 c = new Coord(250,250,250,250); 87 92 port_east = entity->getPortEast(c); … … 91 96 paint = true; 92 97 repaint(); 98 setMouseTracking(true); 93 99 } 94 100 -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_informations_window.cpp
r21 r26 12 12 informations = new QBoxLayout(QBoxLayout::TopToBottom,0); 13 13 winfo->setWindowTitle("informations"); 14 winfo->setFixedSize(250,292); 15 winfo->move(678,50); 14 winfo->setFixedSize(350,292); 15 winfo->move(628,50); 16 lname = new QLabel(); 17 lname->setText(""); 18 comment = new QLineEdit(); 19 comment->setText(""); 20 informations->addWidget(lname); 21 informations->addWidget(comment); 16 22 winfo->setLayout(informations); 17 23 winfo->show(); 18 24 } 19 25 26 void Window::write_comment(string cm){ 27 QString c = QString::fromStdString(cm); 28 comment->setText(c); 29 } 30 31 void Window::write_name(string name){ 32 QString n = QString::fromStdString(name); 33 lname->setText(n); 34 } -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_main.cpp
r20 r26 18 18 if(argc>2){ 19 19 cout << "error : argument must be a file name or nothing" << endl; 20 cout << "usage : Viewer [file]" << endl; 20 21 return 0; 21 22 } 22 23 23 24 Parse *par = new Parse(); 24 25 25 26 26 27 QApplication *a=new QApplication (argc,argv); 27 28 28 29 if(par->open_file(argv[1] )==-1){29 if(argc == 2){ 30 if(par->open_file(argv[1],0)==-1){ 30 31 cout << "file doesn't exist or is not a valid format" << endl; 31 32 exit(1); -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_main_window.cpp
r21 r26 15 15 charg_open = false; 16 16 mess_open = false; 17 17 component_clicked = false; 18 cpt_level=0; 19 18 20 /*menu bar*/ 19 21 QMenuBar *menu_bar = new QMenuBar(this); … … 118 120 119 121 /*defaut position*/ 120 this->move( 50,50);122 this->move(0,50); 121 123 122 124 /*main window title*/ … … 140 142 wa_open = false; 141 143 142 signalName = true; 143 componentName = true; 144 /*signals and components name hidden*/ 145 signalName = false; 146 componentName = false; 144 147 145 148 /*file unsaved at init*/ … … 147 150 first_save = false; //first_save = true for a new file 148 151 149 150 152 current_name = name; 151 153 if(current_name != NULL){ -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_mouseEvent.cpp
r21 r26 18 18 mouseY = mouseEvent->y(); 19 19 20 20 bool bc = false; 21 int cx,cy,tx,ty; 22 string cc,nc; 23 bool found = false; 24 21 25 for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){ 22 26 Coord *co = it->get_Position(); … … 25 29 int taillex = co->get_size_x(); 26 30 int tailley = co->get_size_y(); 27 31 QString t=QString::fromStdString(it->getType()).toLower(); 28 32 if(e->type() == QMouseEvent::MouseButtonDblClick && e->button() == Qt::LeftButton){ 29 33 30 34 if(mouseX >= px + MARGEX && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX && mouseY <= py+tailley + MARGEY) { 31 35 36 bc = false; 32 37 paint = false; 33 38 repaint(); 34 35 mess = new QWidget(); 36 mess->setFixedSize(200,50); 37 mess->move(200,50); 38 QBoxLayout *b = new QBoxLayout(QBoxLayout::TopToBottom,0); 39 QLabel *l = new QLabel(); 40 l->setText("please wait while charging"); 41 b->addWidget(l); 42 mess->setLayout(b); 43 mess->show(); 44 mess_open = true; 45 46 p=base->get_BasePos(it->getType()); 47 entity = p.getEntity(); 48 c = new Coord(250,250,250,250); 49 port_east = entity->getPortEast(c); 50 port_west = entity->getPortWest(c); 51 port_north = entity->getPortNorth(c); 52 port_south = entity->getPortSouth(c); 53 paint = true; 54 father = current; 55 current = QString::fromStdString(it->getName()); 56 repaint(); 39 found=true; 40 this->setDisabled(true); 57 41 } 58 42 } 59 43 if(found){ 44 mess = new QWidget(); 45 mess->setFixedSize(200,50); 46 mess->move(200,50); 47 QBoxLayout *b = new QBoxLayout(QBoxLayout::TopToBottom,0); 48 QLabel *l = new QLabel(); 49 l->setText("please wait while charging"); 50 b->addWidget(l); 51 mess->setLayout(b); 52 mess->show(); 53 mess_open = true; 54 55 p=base->get_BasePos(t.toStdString()); 56 entity = p.getEntity(); 57 c = new Coord(250,250,250,250); 58 port_east = entity->getPortEast(c); 59 port_west = entity->getPortWest(c); 60 port_north = entity->getPortNorth(c); 61 port_south = entity->getPortSouth(c); 62 if(cpt_level!=0) 63 tab[cpt_level]=father; 64 father = current; 65 current = QString::fromStdString(t.toStdString()); 66 cpt_level++; 67 tab[cpt_level] = father; 68 paint = true; 69 this->releaseMouse(); 70 repaint(); 71 write_name(""); 72 write_comment(""); 73 erase_position(); 74 erase_size(); 75 found = false; 76 this->setDisabled(false); 77 } 78 60 79 if(e->type() == QMouseEvent::MouseButtonPress && e->button() == Qt::LeftButton){ 61 80 if(mouseX >= px + MARGEX && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX && mouseY <= py+tailley + MARGEY) { 62 write_name(it->getName()); 63 write_position(px,py); 64 write_size(taillex,tailley); 65 write_ports(cpt_ports); 66 } 67 } 68 81 bc = true; 82 nc = it->getName(); 83 cx = px; 84 cy = py; 85 tx = taillex; 86 ty = tailley; 87 BaseP tp = base->get_BasePos(t.toStdString()); 88 if(&tp != NULL) 89 cc=tp.getComment(); 90 component_clicked = true; 91 } 92 } 93 } 94 if(bc){ 95 write_name(nc); 96 write_position(cx,cy); 97 write_size(tx,ty); 98 write_comment(cc); 69 99 } 70 100 } 71 101 } 72 102 103 104 void Window::mouseMoveEvent(QMouseEvent *e){ 105 106 if(paint && (p.getArchitecture() != NULL) && !component_clicked){ 107 108 compo = p.getComponent(); 109 110 QMouseEvent *mouseEvent = (QMouseEvent *) e; 111 112 mouseX = mouseEvent->x(); 113 mouseY = mouseEvent->y(); 114 115 bool b = false; 116 bool b2 = false; 117 int px,py,taillex,tailley,sx,sy,ppx,ppy; 118 string s,c; 119 120 for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){ 121 Coord *co = it->get_Position(); 122 px = co->get_hg_x(); 123 py = co->get_hg_y(); 124 taillex = co->get_size_x(); 125 tailley = co->get_size_y(); 126 127 if(e->type() == QMouseEvent::MouseMove){ 128 if(mouseX >= px + MARGEX && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX && mouseY <= py+tailley + MARGEY) { 129 b = true; 130 s = it->getName(); 131 BaseP tp=base->get_BasePos(it->getName()); 132 if(&tp!=NULL) 133 c=tp.getComment(); 134 ppx = px; 135 ppy = py; 136 } 137 } 138 139 140 141 // QList<PortMap> *pm=it->getPortMap(); 142 // for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) { 143 // Signal *sig=base->getSignal(it->getType(),new PortMap(*it3)); 144 // if(e->type() == QMouseEvent::MouseMove){ 145 // if(mouseX >= sig->get_dest_x() - 5 + MARGEX && mouseY >= sig->get_dest_x() - 5 +MARGEY && mouseX <= sig->get_dest_x() + 5 + MARGEX && mouseY <= sig->get_dest_x() + 5 +MARGEY) { 146 // b2 = true; 147 // s = it3->getName(); 148 // sx = portX; 149 // sy = portY; 150 // } 151 // } 152 // } 153 } 154 155 if(b){ 156 write_name(s); 157 write_position(ppx,ppy); 158 write_size(taillex,tailley); 159 write_comment(c); 160 } 161 else{ 162 write_name(""); 163 erase_position(); 164 erase_size(); 165 write_comment(""); 166 } 167 168 169 // if(b2){ 170 // write_name(s); 171 // write_position(sx,sy); 172 // } 173 // else{ 174 // write_name(""); 175 // erase_position(); 176 // } 177 // } 178 179 // bool b3; 180 // int sx2,sy2; 181 // string s2; 182 183 // for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){ 184 // portX = it->get_x(); 185 // portY = it->get_y(); 186 // if(mouseX >= portX - 10 && mouseY >= portY - 10 && mouseX <= portX + 10 && mouseY <= portY + 10){ 187 // b3 = true; 188 // s2 = it->getName(); 189 // sx2 = portX; 190 // sy2 = portY; 191 // } 192 // } 193 194 // for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){ 195 // portX = it->get_x() ; 196 // portY = it->get_y() ; 197 // if(mouseX >= portX - 5 && mouseY >= portY - 5 && mouseX <= portX + 5 && mouseY <= portY + 5){ 198 // b3 = true; 199 // s2 = it->getName(); 200 // sx2 = portX; 201 // sy2 = portY; 202 // } 203 // } 204 205 // for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){ 206 // portX = it->get_x() ; 207 // portY = it->get_y() ; 208 // if(mouseX >= portX - 5 && mouseY >= portY - 5 && mouseX <= portX + 5 && mouseY <= portY + 5){ 209 // b3 = true; 210 // s2 = it->getName(); 211 // sx2 = portX; 212 // sy2 = portY; 213 // } 214 // } 215 216 // for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){ 217 // portX = it->get_x() ; 218 // portY = it->get_y() ; 219 // if(mouseX >= portX - 5 && mouseY >= portY - 5 && mouseX <= portX + 5 && mouseY <= portY + 5){ 220 // b3 = true; 221 // s2 = it->getName(); 222 // sx2 = portX; 223 // sy2 = portY; 224 // } 225 // } 226 } 227 } 228 229 230 void Window::_back(){ 231 if(cpt_level==0){ 232 QMessageBox *m = new QMessageBox(this); 233 m->setText("can't go up, you're on the top level !"); 234 m->addButton("ok",QMessageBox::YesRole); 235 m->show(); 236 } 73 237 74 void Window::_back(){ 75 76 paint = false; 77 repaint(); 78 mess_charg = new QWidget(); 79 mess_charg->setFixedSize(200,50); 80 mess_charg->move(200,50); 81 charg_open = true; 82 QBoxLayout *b = new QBoxLayout(QBoxLayout::TopToBottom,0); 83 QLabel *l = new QLabel(); 84 l->setText("please wait while charging"); 85 b->addWidget(l); 86 mess_charg->setLayout(b); 87 mess_charg->show(); 88 89 90 91 if(father==" "){ 92 QList <BaseP> *liste_compo = base->getBaseP(); 93 p = liste_compo->at(0); 238 else{ 239 this->setDisabled(true); 240 paint = false; 241 repaint(); 242 cpt_level--; 243 mess_charg = new QWidget(); 244 mess_charg->setFixedSize(200,50); 245 mess_charg->move(200,50); 246 charg_open = true; 247 QBoxLayout *b = new QBoxLayout(QBoxLayout::TopToBottom,0); 248 QLabel *l = new QLabel(); 249 l->setText("please wait while charging"); 250 b->addWidget(l); 251 mess_charg->setLayout(b); 252 mess_charg->show(); 253 254 p = base->get_BasePos(father.toStdString()); 255 entity = p.getEntity(); 256 c = new Coord(250,250,250,250); 257 port_east = entity->getPortEast(c); 258 port_west = entity->getPortWest(c); 259 port_north = entity->getPortNorth(c); 260 port_south = entity->getPortSouth(c); 261 father = tab[cpt_level]; 262 current = QString::fromStdString(entity->getName()); 263 paint = true; 264 repaint(); 265 this->setDisabled(false); 94 266 } 95 96 else{97 p = base->get_BasePos(father.toStdString());98 }99 100 entity = p.getEntity();101 c = new Coord(250,250,250,250);102 port_east = entity->getPortEast(c);103 port_west = entity->getPortWest(c);104 port_north = entity->getPortNorth(c);105 port_south = entity->getPortSouth(c);106 father = current;107 current = QString::fromStdString(entity->getName());108 paint = true;109 repaint();110 267 } 111 268 -
trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Graphics/src/Graphics_parameters_window.cpp
r21 r26 12 12 parameters = new QBoxLayout(QBoxLayout::TopToBottom,0); 13 13 wparam->setWindowTitle("parameters"); 14 wparam->setFixedSize(250,300); 15 wparam->move(678,370); 16 17 lname = new QLabel(wparam); 18 lname->setText(""); 14 wparam->setFixedSize(350,300); 15 wparam->move(628,370); 19 16 20 17 QBoxLayout *bpos = new QBoxLayout(QBoxLayout::LeftToRight,0); … … 49 46 bsize2->addWidget(sy); 50 47 bsize2->addWidget(sizeY); 51 52 QBoxLayout *bport = new QBoxLayout(QBoxLayout::LeftToRight,0);53 QLabel *lport = new QLabel();54 lport->setText("nb ports : ");55 nb_ports = new QLineEdit();56 nb_ports->setText("");57 bport->addWidget(lport);58 bport->addWidget(nb_ports);59 60 parameters->addWidget(lname);61 48 parameters->addLayout(bpos); 62 49 parameters->addLayout(bpos2); 63 50 parameters->addLayout(bsize); 64 51 parameters->addLayout(bsize2); 65 parameters->addLayout(bport);52 QPushButton *noselect = new QPushButton("cancel selection",wparam); 66 53 QPushButton *back = new QPushButton("back",wparam); 67 54 QPushButton *apply = new QPushButton("apply",wparam); 68 55 connect(back,SIGNAL(clicked()),this,SLOT(_back())); 56 connect(noselect,SIGNAL(clicked()),this,SLOT(_cancel_selection())); 57 connect(apply,SIGNAL(clicked()),this,SLOT(_apply())); 58 59 parameters->addWidget(noselect); 69 60 parameters->addWidget(back); 70 61 parameters->addWidget(apply); … … 72 63 wparam->setLayout(parameters); 73 64 wparam->show(); 74 }75 76 void Window::write_name(string name){77 QString n = QString::fromStdString(name);78 lname->setText(n);79 80 65 } 81 66 … … 91 76 str2 = out2.str(); 92 77 positionY->setText(QString::fromStdString(str2)); 93 78 } 79 80 void Window::erase_position(){ 81 positionX->setText(""); 82 positionY->setText(""); 94 83 } 95 84 … … 107 96 } 108 97 109 void Window::write_ports(int x){ 110 stringstream out; 111 string str; 112 out << x; 113 str = out.str(); 114 nb_ports->setText(QString::fromStdString(str)); 115 wparam->show(); 98 void Window::erase_size(){ 99 sizeX->setText(""); 100 sizeY->setText(""); 116 101 } 117 102 103 void Window::_cancel_selection(){ 104 component_clicked = false; 105 } 118 106 107 void Window::_apply(){ 108 if(positionX->isModified()) 109 cout << "positionX modified : " << positionX->text().toStdString() << endl; 110 if(positionY->isModified()) 111 cout << "positionY modified : " << positionX->text().toStdString() << endl; 112 if(sizeX->isModified()) 113 cout << "sizeX modified : " << sizeX->text().toStdString() << endl; 114 if(sizeY->isModified()) 115 cout << "sizeY modified : " << sizeY->text().toStdString() << endl; 116 }
Note: See TracChangeset
for help on using the changeset viewer.