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 | |
---|
10 | /*draw window size*/ |
---|
11 | setMinimumSize(600,600); |
---|
12 | |
---|
13 | if(paint){ |
---|
14 | |
---|
15 | painter.begin(this); |
---|
16 | painter.setPen(Qt::blue); |
---|
17 | painter.drawRect(MARGEX,MARGEY,MARGEX+450,MARGEY+450); |
---|
18 | cpt_ports = 0; |
---|
19 | |
---|
20 | for(QList<Port>::iterator it=port_east.begin(); it!=port_east.end(); ++it){ |
---|
21 | portX = it->get_x(); |
---|
22 | portY = it->get_y(); |
---|
23 | drawPort(portX + MARGEX,portY + MARGEY ,EAST,it->getDirection()); |
---|
24 | cpt_ports++; |
---|
25 | } |
---|
26 | |
---|
27 | for(QList<Port>::iterator it=port_west.begin(); it!=port_west.end(); ++it){ |
---|
28 | portX = it->get_x() ; |
---|
29 | portY = it->get_y() ; |
---|
30 | drawPort(portX + MARGEX,portY + MARGEY, WEST, it->getDirection()); |
---|
31 | cpt_ports++; |
---|
32 | } |
---|
33 | |
---|
34 | for(QList<Port>::iterator it=port_north.begin(); it!=port_north.end(); ++it){ |
---|
35 | portX = it->get_x() ; |
---|
36 | portY = it->get_y() ; |
---|
37 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it->getDirection()); |
---|
38 | cpt_ports++; |
---|
39 | } |
---|
40 | |
---|
41 | for(QList<Port>::iterator it=port_south.begin(); it!=port_south.end(); ++it){ |
---|
42 | portX = it->get_x() ; |
---|
43 | portY = it->get_y() ; |
---|
44 | drawPort(portX + MARGEX,portY+MARGEY,SOUTH,it->getDirection()); |
---|
45 | cpt_ports++; |
---|
46 | } |
---|
47 | |
---|
48 | current = "Top Level"; |
---|
49 | father = " "; |
---|
50 | if(p.getArchitecture()!=NULL){ |
---|
51 | compo = p.getComponent(); |
---|
52 | for(QList<Component>::iterator it=compo->begin();it!=compo->end();++it){ |
---|
53 | Coord *co = it->get_Position(); |
---|
54 | posX = co->get_hg_x()+MARGEX; |
---|
55 | posY = co->get_hg_y()+MARGEY; |
---|
56 | tailleX = co->get_size_x(); |
---|
57 | tailleY = co->get_size_y(); |
---|
58 | painter.drawRect(posX,posY,tailleX,tailleY); |
---|
59 | if (componentName){ |
---|
60 | QString compo_name = QString::fromStdString(it->getName()); |
---|
61 | painter.drawText(posX , posY + tailleY/2,compo_name); |
---|
62 | } |
---|
63 | Coord *co2=new Coord( co->get_hg_x() + tailleX/2, co->get_hg_y() + tailleY/2,tailleX/2,tailleY/2); |
---|
64 | |
---|
65 | QList<Port> ports2=(it->getPortEast(co2)); |
---|
66 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
67 | { |
---|
68 | |
---|
69 | portX =it2->get_x(); |
---|
70 | portY =it2->get_y(); |
---|
71 | drawPort(portX + MARGEX,portY+MARGEY , EAST,it2->getDirection()); |
---|
72 | } |
---|
73 | ports2=(it->getPortWest(co)); |
---|
74 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
75 | { |
---|
76 | |
---|
77 | portX =it2->get_x(); |
---|
78 | portY =it2->get_y(); |
---|
79 | drawPort(portX + MARGEX ,portY+MARGEY ,WEST,it2->getDirection()); |
---|
80 | } |
---|
81 | ports2=(it->getPortNorth(co)); |
---|
82 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
83 | { |
---|
84 | |
---|
85 | portX =it2->get_x(); |
---|
86 | portY =it2->get_y(); |
---|
87 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it2->getDirection()); |
---|
88 | |
---|
89 | } |
---|
90 | ports2=(it->getPortSouth(co)); |
---|
91 | for (QList<Port>::iterator it2=ports2.begin();it2!=ports2.end();++it2) |
---|
92 | { |
---|
93 | |
---|
94 | portX =it2->get_x(); |
---|
95 | portY =it2->get_y(); |
---|
96 | drawPort(portX + MARGEX ,portY+MARGEY,SOUTH,it2->getDirection()); |
---|
97 | |
---|
98 | } |
---|
99 | painter.setPen(Qt::red); |
---|
100 | QList<PortMap> *pm=it->getPortMap(); |
---|
101 | |
---|
102 | for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) |
---|
103 | { |
---|
104 | Signal *s=base->getSignal(it->getType(),new PortMap(*it3)); |
---|
105 | painter.drawLine(s->get_src_x()+MARGEX,s->get_src_y()+MARGEY,s->get_dest_x()+MARGEX,s->get_dest_y()+MARGEY); |
---|
106 | |
---|
107 | if(signalName){ |
---|
108 | QString signal_name = QString::fromStdString(it3->getName()); |
---|
109 | if(s->get_src_x() > s->get_dest_x()) |
---|
110 | painter.drawText(s->get_dest_x() + MARGEX - 40 ,s->get_dest_y() + MARGEY-10, signal_name); |
---|
111 | if(s->get_src_x() < s->get_dest_x()) |
---|
112 | painter.drawText(s->get_dest_x() + MARGEX - 40 ,s->get_dest_y() + MARGEY-10, signal_name); |
---|
113 | } |
---|
114 | |
---|
115 | } |
---|
116 | if(charg_open){ |
---|
117 | charg_open = false; |
---|
118 | mess_charg->close(); |
---|
119 | } |
---|
120 | painter.setPen(Qt::blue); |
---|
121 | } |
---|
122 | } |
---|
123 | painter.end(); |
---|
124 | } |
---|
125 | if(mess_open){ |
---|
126 | mess_open = false; |
---|
127 | mess->close(); |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | void Window::repaint(){ |
---|
132 | } |
---|
133 | |
---|