[20] | 1 | #include "window.h" |
---|
| 2 | |
---|
| 3 | using namespace morpheo::tools::viewer::parser; |
---|
| 4 | using namespace morpheo::tools::viewer::bdd; |
---|
| 5 | using namespace morpheo::tools::viewer::graphics; |
---|
| 6 | |
---|
| 7 | void Window::paintEvent( QPaintEvent * ) |
---|
| 8 | { |
---|
| 9 | /*draw window size*/ |
---|
| 10 | setMinimumSize(600,600); |
---|
[30] | 11 | |
---|
| 12 | int schema; |
---|
| 13 | QString t; |
---|
| 14 | |
---|
[20] | 15 | if(paint){ |
---|
| 16 | painter.begin(this); |
---|
| 17 | painter.setPen(Qt::blue); |
---|
[21] | 18 | painter.drawRect(MARGEX,MARGEY,MARGEX+450,MARGEY+450); |
---|
[26] | 19 | |
---|
[20] | 20 | |
---|
| 21 | for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){ |
---|
| 22 | portX = it->get_x(); |
---|
| 23 | portY = it->get_y(); |
---|
[21] | 24 | drawPort(portX + MARGEX,portY + MARGEY ,EAST,it->getDirection()); |
---|
[26] | 25 | |
---|
[20] | 26 | } |
---|
| 27 | |
---|
| 28 | for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){ |
---|
| 29 | portX = it->get_x() ; |
---|
| 30 | portY = it->get_y() ; |
---|
[21] | 31 | drawPort(portX + MARGEX,portY + MARGEY, WEST, it->getDirection()); |
---|
[26] | 32 | |
---|
[20] | 33 | } |
---|
| 34 | |
---|
| 35 | for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){ |
---|
| 36 | portX = it->get_x() ; |
---|
| 37 | portY = it->get_y() ; |
---|
[21] | 38 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it->getDirection()); |
---|
[26] | 39 | |
---|
[20] | 40 | } |
---|
| 41 | |
---|
| 42 | for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){ |
---|
| 43 | portX = it->get_x() ; |
---|
| 44 | portY = it->get_y() ; |
---|
[21] | 45 | drawPort(portX + MARGEX,portY+MARGEY,SOUTH,it->getDirection()); |
---|
[26] | 46 | |
---|
[20] | 47 | } |
---|
[21] | 48 | |
---|
[20] | 49 | if(p.getArchitecture()!=NULL){ |
---|
| 50 | compo = p.getComponent(); |
---|
| 51 | for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){ |
---|
| 52 | Coord *co = it->get_Position(); |
---|
[21] | 53 | posX = co->get_hg_x()+MARGEX; |
---|
| 54 | posY = co->get_hg_y()+MARGEY; |
---|
[20] | 55 | tailleX = co->get_size_x(); |
---|
| 56 | tailleY = co->get_size_y(); |
---|
[30] | 57 | |
---|
| 58 | t=QString::fromStdString(it->getType()).toLower(); |
---|
| 59 | BaseP tp = base->get_BasePos(t.toStdString()); |
---|
| 60 | if(&tp != NULL){ |
---|
| 61 | schema=tp.getSchema(); |
---|
| 62 | switch(schema){ |
---|
| 63 | case 0: |
---|
| 64 | painter.drawRect(posX,posY,tailleX,tailleY); |
---|
| 65 | break; |
---|
| 66 | case 1: |
---|
| 67 | painter.drawEllipse(posX,posY,tailleX,tailleY); |
---|
| 68 | break; |
---|
| 69 | case 2: |
---|
| 70 | painter.drawRect(posX,posY,tailleX,tailleY); |
---|
| 71 | painter.drawLine(posX+tailleX/4,posY+tailleY,posX+tailleX/4,posY); |
---|
| 72 | painter.drawLine(posX+tailleX/2,posY+tailleY,posX+tailleX/2,posY); |
---|
| 73 | painter.drawLine(posX+3*tailleX/4,posY+tailleY,posX+3*tailleX/4,posY); |
---|
| 74 | break; |
---|
| 75 | case 3: |
---|
| 76 | painter.drawRect(posX,posY,tailleX,tailleY); |
---|
| 77 | painter.drawLine(posX,posY+tailleY,posX+tailleX/2,posY+tailleY/2); |
---|
| 78 | painter.drawLine(posX+tailleX,posY+tailleY,posX+tailleX/2,posY+tailleY/2); |
---|
| 79 | break; |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
[21] | 83 | if (componentName){ |
---|
| 84 | QString compo_name = QString::fromStdString(it->getName()); |
---|
| 85 | painter.drawText(posX , posY + tailleY/2,compo_name); |
---|
| 86 | } |
---|
[20] | 87 | Coord *co2=new Coord( co->get_hg_x() + tailleX/2, co->get_hg_y() + tailleY/2,tailleX/2,tailleY/2); |
---|
[21] | 88 | |
---|
[20] | 89 | QList<Port> ports2=(it->getPortEast(co2)); |
---|
| 90 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
| 91 | { |
---|
| 92 | |
---|
| 93 | portX =it2->get_x(); |
---|
| 94 | portY =it2->get_y(); |
---|
[21] | 95 | drawPort(portX + MARGEX,portY+MARGEY , EAST,it2->getDirection()); |
---|
[20] | 96 | } |
---|
| 97 | ports2=(it->getPortWest(co)); |
---|
| 98 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
| 99 | { |
---|
| 100 | |
---|
| 101 | portX =it2->get_x(); |
---|
| 102 | portY =it2->get_y(); |
---|
[21] | 103 | drawPort(portX + MARGEX ,portY+MARGEY ,WEST,it2->getDirection()); |
---|
[20] | 104 | } |
---|
| 105 | ports2=(it->getPortNorth(co)); |
---|
| 106 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
| 107 | { |
---|
| 108 | |
---|
| 109 | portX =it2->get_x(); |
---|
| 110 | portY =it2->get_y(); |
---|
[21] | 111 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it2->getDirection()); |
---|
[20] | 112 | |
---|
| 113 | } |
---|
| 114 | ports2=(it->getPortSouth(co)); |
---|
| 115 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
| 116 | { |
---|
| 117 | |
---|
| 118 | portX =it2->get_x(); |
---|
| 119 | portY =it2->get_y(); |
---|
[21] | 120 | drawPort(portX + MARGEX ,portY+MARGEY,SOUTH,it2->getDirection()); |
---|
[20] | 121 | |
---|
| 122 | } |
---|
| 123 | painter.setPen(Qt::red); |
---|
| 124 | QList<PortMap> *pm=it->getPortMap(); |
---|
[21] | 125 | |
---|
[20] | 126 | for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) |
---|
| 127 | { |
---|
[26] | 128 | Signal *s=base->getSignal(&p,it->getName(),new PortMap(*it3)); |
---|
[21] | 129 | painter.drawLine(s->get_src_x()+MARGEX,s->get_src_y()+MARGEY,s->get_dest_x()+MARGEX,s->get_dest_y()+MARGEY); |
---|
| 130 | |
---|
| 131 | if(signalName){ |
---|
| 132 | QString signal_name = QString::fromStdString(it3->getName()); |
---|
| 133 | if(s->get_src_x() > s->get_dest_x()) |
---|
| 134 | painter.drawText(s->get_dest_x() + MARGEX - 40 ,s->get_dest_y() + MARGEY-10, signal_name); |
---|
| 135 | if(s->get_src_x() < s->get_dest_x()) |
---|
| 136 | painter.drawText(s->get_dest_x() + MARGEX - 40 ,s->get_dest_y() + MARGEY-10, signal_name); |
---|
| 137 | } |
---|
| 138 | |
---|
[20] | 139 | } |
---|
[26] | 140 | if(charg_open){ |
---|
[21] | 141 | charg_open = false; |
---|
| 142 | mess_charg->close(); |
---|
| 143 | } |
---|
[20] | 144 | painter.setPen(Qt::blue); |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | painter.end(); |
---|
| 148 | } |
---|
[21] | 149 | if(mess_open){ |
---|
| 150 | mess_open = false; |
---|
| 151 | mess->close(); |
---|
| 152 | } |
---|
[20] | 153 | } |
---|
| 154 | |
---|
| 155 | void Window::repaint(){ |
---|
| 156 | } |
---|
| 157 | |
---|