[21] | 1 | #include "window.h" |
---|
| 2 | |
---|
| 3 | using namespace std; |
---|
| 4 | using namespace morpheo::tools::viewer::parser; |
---|
| 5 | using namespace morpheo::tools::viewer::bdd; |
---|
| 6 | using namespace morpheo::tools::viewer::graphics; |
---|
| 7 | |
---|
| 8 | void Window::mousePressEvent (QMouseEvent *e){ |
---|
| 9 | |
---|
| 10 | if(paint && (p.getArchitecture() != NULL)){ |
---|
| 11 | |
---|
| 12 | compo = p.getComponent(); |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | QMouseEvent *mouseEvent = (QMouseEvent *) e; |
---|
| 16 | |
---|
| 17 | mouseX = mouseEvent->x(); |
---|
| 18 | mouseY = mouseEvent->y(); |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){ |
---|
| 22 | Coord *co = it->get_Position(); |
---|
| 23 | int px = co->get_hg_x(); |
---|
| 24 | int py = co->get_hg_y(); |
---|
| 25 | int taillex = co->get_size_x(); |
---|
| 26 | int tailley = co->get_size_y(); |
---|
| 27 | |
---|
| 28 | if(e->type() == QMouseEvent::MouseButtonDblClick && e->button() == Qt::LeftButton){ |
---|
| 29 | |
---|
| 30 | if(mouseX >= px + MARGEX && mouseY >= py +MARGEY && mouseX <= px+taillex + MARGEX && mouseY <= py+tailley + MARGEY) { |
---|
| 31 | |
---|
| 32 | paint = false; |
---|
| 33 | 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(); |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | if(e->type() == QMouseEvent::MouseButtonPress && e->button() == Qt::LeftButton){ |
---|
| 61 | 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 | |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 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); |
---|
| 94 | } |
---|
| 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 | } |
---|
| 111 | |
---|