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); |
---|
11 | |
---|
12 | int schema; |
---|
13 | QString t; |
---|
14 | |
---|
15 | if(paint){ |
---|
16 | painter.begin(this); |
---|
17 | painter.setPen(Qt::blue); |
---|
18 | painter.drawRect(MARGEX,MARGEY,MARGEX+450,MARGEY+450); |
---|
19 | |
---|
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(); |
---|
24 | drawPort(portX + MARGEX,portY + MARGEY ,EAST,it->getDirection()); |
---|
25 | |
---|
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() ; |
---|
31 | drawPort(portX + MARGEX,portY + MARGEY, WEST, it->getDirection()); |
---|
32 | |
---|
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() ; |
---|
38 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it->getDirection()); |
---|
39 | |
---|
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() ; |
---|
45 | drawPort(portX + MARGEX,portY+MARGEY,SOUTH,it->getDirection()); |
---|
46 | |
---|
47 | } |
---|
48 | |
---|
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(); |
---|
53 | posX = co->get_hg_x()+MARGEX; |
---|
54 | posY = co->get_hg_y()+MARGEY; |
---|
55 | tailleX = co->get_size_x(); |
---|
56 | tailleY = co->get_size_y(); |
---|
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 | |
---|
83 | if (componentName){ |
---|
84 | QString compo_name = QString::fromStdString(it->getName()); |
---|
85 | painter.drawText(posX , posY + tailleY/2,compo_name); |
---|
86 | } |
---|
87 | Coord *co2=new Coord( co->get_hg_x() + tailleX/2, co->get_hg_y() + tailleY/2,tailleX/2,tailleY/2); |
---|
88 | |
---|
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(); |
---|
95 | drawPort(portX + MARGEX,portY+MARGEY , EAST,it2->getDirection()); |
---|
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(); |
---|
103 | drawPort(portX + MARGEX ,portY+MARGEY ,WEST,it2->getDirection()); |
---|
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(); |
---|
111 | drawPort(portX + MARGEX ,portY+MARGEY,NORTH,it2->getDirection()); |
---|
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(); |
---|
120 | drawPort(portX + MARGEX ,portY+MARGEY,SOUTH,it2->getDirection()); |
---|
121 | |
---|
122 | } |
---|
123 | painter.setPen(Qt::red); |
---|
124 | QList<PortMap> *pm=it->getPortMap(); |
---|
125 | |
---|
126 | for (QList<PortMap>::iterator it3=pm->begin();it3!=pm->end();++it3) |
---|
127 | { |
---|
128 | Signal *s=base->getSignal(&p,it->getName(),new PortMap(*it3)); |
---|
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 | |
---|
139 | } |
---|
140 | if(charg_open){ |
---|
141 | charg_open = false; |
---|
142 | mess_charg->close(); |
---|
143 | } |
---|
144 | painter.setPen(Qt::blue); |
---|
145 | } |
---|
146 | } |
---|
147 | painter.end(); |
---|
148 | } |
---|
149 | if(mess_open){ |
---|
150 | mess_open = false; |
---|
151 | mess->close(); |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | void Window::repaint(){ |
---|
156 | } |
---|
157 | |
---|