RtmLineUtil.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # @file RtmLineUtil.py
5 # @brief rtc-link line management classes
6 # @date $Date: 2005-05-12 09:06:19 $
7 # @author Tsuyoshi Tanabe, Noriaki Ando <n-ando@aist.go.jp>
8 #
9 # Copyright (C) 2004-2005
10 # Task-intelligence Research Group,
11 # Intelligent Systems Research Institute,
12 # National Institute of
13 # Advanced Industrial Science and Technology (AIST), Japan
14 # All rights reserved.
15 #
16 # $Id: RtmLineUtil.py 775 2008-07-28 16:14:45Z n-ando $
17 #
18 
19 import sys
20 import string
21 
22 BLANK = 25
23 
24 class LineUtil:
25  def __init__(self, parent, g_inp, g_outp, startx, starty, endx, endy):
26  self.g_inp = g_inp # GRtcIn
27  self.g_outp = g_outp # GRtcOut
28  self.startx = startx
29  self.starty = starty
30  self.endx = endx
31  self.endy = endy
32  self.coordT = None
33  self.parent = parent
34 
35  def drawLineP1(self) :
36  #print "drawLineP1:"
37  width = self.startx - self.endx
38  hight = self.starty - self.endy
39  inp = self.g_inp.getConfig('position')
40  if inp == 'Left' or inp == 'Right' :
41  if abs(width) <= abs(hight) :
42  self.coordT = [(self.startx, self.starty),
43  (self.endx + width/2, self.starty),
44  (self.endx + width/2, self.endy),
45  (self.endx, self.endy)]
46  else :
47  self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
48  if inp == 'Top' or inp == 'Bottom' :
49  if abs(width) >= abs(hight) :
50  self.coordT = [(self.startx, self.starty),
51  (self.startx, self.endy + hight/2),
52  (self.endx, self.endy + hight/2),
53  (self.endx, self.endy)]
54  else :
55  self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
56 
57  def drawLineP2(self, inpBox, outpBox) :
58  #print "drawLineP2:"
59  inp = self.g_inp.getConfig('position')
60  outp = self.g_outp.getConfig('position')
61  if inp == 'Left' and outp == 'Right' :
62  self.coordT = [(self.startx, self.starty),
63  (self.startx-BLANK, self.starty),
64  (self.startx-BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
65  (self.endx+BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
66  (self.endx+BLANK, self.endy),
67  (self.endx, self.endy)]
68  elif inp == 'Right' and outp == 'Left' :
69  self.coordT = [(self.startx, self.starty),
70  (self.startx+BLANK, self.starty),
71  (self.startx+BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
72  (self.endx-BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
73  (self.endx-BLANK, self.endy),
74  (self.endx, self.endy)]
75  elif inp == 'Top' and outp == 'Bottom' :
76  self.coordT = [(self.startx, self.starty),
77  (self.startx, self.starty-BLANK),
78  (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.starty-BLANK),
79  (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.endy+BLANK),
80  (self.endx, self.endy+BLANK),
81  (self.endx, self.endy)]
82  elif inp == 'Bottom' and outp == 'Top' :
83  self.coordT = [(self.startx, self.starty),
84  (self.startx, self.starty+BLANK),
85  (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.starty+BLANK),
86  (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.endy-BLANK),
87  (self.endx, self.endy-BLANK),
88  (self.endx, self.endy)]
89 
90  def drawLineP3(self, inpBox, outpBox) :
91  #print "drawLineP3:"
92  inp = self.g_inp.getConfig('position')
93  outp = self.g_outp.getConfig('position')
94  if inp == 'Left' and outp == 'Right' :
95  self.coordT = [(self.startx, self.starty),
96  (self.startx-BLANK, self.starty),
97  (self.startx-BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
98  (self.endx+BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
99  (self.endx+BLANK, self.endy),
100  (self.endx, self.endy)]
101  elif inp == 'Right' and outp == 'Left' :
102  self.coordT = [(self.startx, self.starty),
103  (self.startx+BLANK, self.starty),
104  (self.startx+BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
105  (self.endx-BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
106  (self.endx-BLANK, self.endy),
107  (self.endx, self.endy)]
108  elif inp == 'Top' and outp == 'Bottom' :
109  self.coordT = [(self.startx, self.starty),
110  (self.startx, self.starty-BLANK),
111  (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.starty-BLANK),
112  (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.endy+BLANK),
113  (self.endx, self.endy+BLANK),
114  (self.endx, self.endy)]
115  elif inp == 'Bottom' and outp == 'Top' :
116  self.coordT = [(self.startx, self.starty),
117  (self.startx, self.starty+BLANK),
118  (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.starty+BLANK),
119  (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.endy-BLANK),
120  (self.endx, self.endy-BLANK),
121  (self.endx, self.endy)]
122 
123  def drawLineP4(self, inpBox, outpBox) :
124  #print "drawLineP4:"
125  inp = self.g_inp.getConfig('position')
126  outp = self.g_outp.getConfig('position')
127 
128  if inp == 'Left' or inp == 'Right' :
129  if inpBox[3] >= outpBox[3] :
130  hight = inpBox[3]+BLANK
131  else :
132  hight = outpBox[3]+BLANK
133  elif inp == 'Top' or inp == 'Bottom' :
134  if inpBox[2] >= outpBox[2] :
135  width = inpBox[2]+BLANK
136  else :
137  width = outpBox[2]+BLANK
138 
139  if inp == 'Left' and outp == 'Right' :
140  self.coordT = [(self.startx, self.starty),
141  (self.startx-BLANK, self.starty),
142  (self.startx-BLANK, hight),
143  (self.endx+BLANK, hight),
144  (self.endx+BLANK, self.endy),
145  (self.endx, self.endy)]
146  elif inp == 'Right' and outp == 'Left' :
147  self.coordT = [(self.startx, self.starty),
148  (self.startx+BLANK, self.starty),
149  (self.startx+BLANK, hight),
150  (self.endx-BLANK, hight),
151  (self.endx-BLANK, self.endy),
152  (self.endx, self.endy)]
153  elif inp == 'Top' and outp == 'Bottom' :
154  self.coordT = [(self.startx, self.starty),
155  (self.startx, self.starty-BLANK),
156  (width, self.starty-BLANK),
157  (width, self.endy+BLANK),
158  (self.endx, self.endy+BLANK),
159  (self.endx, self.endy)]
160  elif inp == 'Bottom' and outp == 'Top' :
161  self.coordT = [(self.startx, self.starty),
162  (self.startx, self.starty+BLANK),
163  (width, self.starty+BLANK),
164  (width, self.endy-BLANK),
165  (self.endx, self.endy-BLANK),
166  (self.endx, self.endy)]
167 
168  def drawLineP5(self, inpBox, outpBox) :
169  #print "drawLineP5:"
170  inp = self.g_inp.getConfig('position')
171  outp = self.g_outp.getConfig('position')
172  if inp == 'Left' and outp == 'Left' :
173  if self.endx - (self.startx-BLANK) < BLANK :
174  pos_x = self.endx-BLANK
175  else :
176  pos_x = self.startx-BLANK
177  self.coordT = [(self.startx, self.starty),
178  (pos_x, self.starty),
179  (pos_x, self.endy),
180  (self.endx, self.endy)]
181  elif inp == 'Right' and outp == 'Right' :
182  if (self.startx+BLANK) - self.endx < BLANK :
183  pos_x = self.endx+BLANK
184  else :
185  pos_x = self.startx+BLANK
186  self.coordT = [(self.startx, self.starty),
187  (pos_x, self.starty),
188  (pos_x, self.endy),
189  (self.endx, self.endy)]
190  elif inp == 'Top' and outp == 'Top' :
191  if self.endy - (self.starty-BLANK) < BLANK :
192  pos_y = self.endy-BLANK
193  else :
194  pos_y = self.starty-BLANK
195  self.coordT = [(self.startx, self.starty),
196  (self.startx, pos_y),
197  (self.endx, pos_y),
198  (self.endx, self.endy)]
199  elif inp == 'Bottom' and outp == 'Bottom' :
200  if (self.starty+BLANK) - self.endy < BLANK :
201  pos_y = self.endy+BLANK
202  else :
203  pos_y = self.starty+BLANK
204  self.coordT = [(self.startx, self.starty),
205  (self.startx, pos_y),
206  (self.endx, pos_y),
207  (self.endx, self.endy)]
208 
209  def drawLineP6(self, inpBox, outpBox) :
210  #print "drawLineP6:"
211  inp = self.g_inp.getConfig('position')
212  outp = self.g_outp.getConfig('position')
213 
214  if inp == 'Left' or inp == 'Right' :
215  if inpBox[3] >= outpBox[3] :
216  hight = inpBox[3]+BLANK
217  else :
218  hight = outpBox[3]+BLANK
219  elif inp == 'Top' or inp == 'Bottom' :
220  if inpBox[2] >= outpBox[2] :
221  width = inpBox[2]+BLANK
222  else :
223  width = outpBox[2]+BLANK
224 
225  if inp == 'Left' and outp == 'Left' :
226  self.coordT = [(self.startx, self.starty),
227  (self.startx-BLANK, self.starty),
228  (self.startx-BLANK, hight),
229  (self.endx-BLANK, hight),
230  (self.endx-BLANK, self.endy),
231  (self.endx, self.endy)]
232  elif inp == 'Right' and outp == 'Right' :
233  self.coordT = [(self.startx, self.starty),
234  (self.startx+BLANK, self.starty),
235  (self.startx+BLANK, hight),
236  (self.endx+BLANK, hight),
237  (self.endx+BLANK, self.endy),
238  (self.endx, self.endy)]
239  elif inp == 'Top' and outp == 'Top' :
240  self.coordT = [(self.startx, self.starty),
241  (self.startx, self.starty-BLANK),
242  (width, self.starty-BLANK),
243  (width, self.endy-BLANK),
244  (self.endx, self.endy-BLANK),
245  (self.endx, self.endy)]
246  elif inp == 'Bottom' and outp == 'Bottom' :
247  self.coordT = [(self.startx, self.starty),
248  (self.startx, self.starty+BLANK),
249  (width, self.starty+BLANK),
250  (width, self.endy+BLANK),
251  (self.endx, self.endy+BLANK),
252  (self.endx, self.endy)]
253 
254  def drawLineP7(self, inpBox, outpBox) :
255  #print "drawLineP7:"
256  inp = self.g_inp.getConfig('position')
257  outp = self.g_outp.getConfig('position')
258  if (inp == 'Top' and (outp == 'Left' or outp == 'Right')) or \
259  (inp == 'Bottom' and (outp == 'Left' or outp == 'Right')) :
260  if (inp == 'Top' and self.starty-self.endy >= BLANK) or \
261  (inp == 'Bottom' and self.endy-self.starty >= BLANK) :
262  self.coordT = [(self.startx, self.starty),
263  (self.startx, self.endy),
264  (self.endx, self.endy)]
265  else :
266  self.drawLineP8(inpBox, outpBox)
267  elif (inp == 'Left' and (outp == 'Top' or outp == 'Bottom')) or \
268  (inp == 'Right' and (outp == 'Top' or outp == 'Bottom')) :
269  if (inp == 'Left' and self.startx-self.endx >= BLANK) or \
270  (inp == 'Right' and self.endx-self.startx >= BLANK) :
271  self.coordT = [(self.startx, self.starty),
272  (self.endx, self.starty),
273  (self.endx, self.endy)]
274  else :
275  self.drawLineP8(inpBox, outpBox)
276 
277  def drawLineP8(self, inpBox, outpBox) :
278  #print "drawLineP8:"
279  inp = self.g_inp.getConfig('position')
280  outp = self.g_outp.getConfig('position')
281  if inp == 'Top' and outp == 'Left' :
282  self.coordT = [(self.startx, self.starty),
283  (self.startx, self.starty-BLANK),
284  (self.endx-BLANK, self.starty-BLANK),
285  (self.endx-BLANK, self.endy),
286  (self.endx, self.endy)]
287  elif inp == 'Top' and outp == 'Right' :
288  self.coordT = [(self.startx, self.starty),
289  (self.startx, self.starty-BLANK),
290  (self.endx+BLANK, self.starty-BLANK),
291  (self.endx+BLANK, self.endy),
292  (self.endx, self.endy)]
293  elif inp == 'Bottom' and outp == 'Left' :
294  self.coordT = [(self.startx, self.starty),
295  (self.startx, self.starty+BLANK),
296  (self.endx-BLANK, self.starty+BLANK),
297  (self.endx-BLANK, self.endy),
298  (self.endx, self.endy)]
299  elif inp == 'Bottom' and outp == 'Right' :
300  self.coordT = [(self.startx, self.starty),
301  (self.startx, self.starty+BLANK),
302  (self.endx+BLANK, self.starty+BLANK),
303  (self.endx+BLANK, self.endy),
304  (self.endx, self.endy)]
305  elif inp == 'Left' and outp == 'Top' :
306  self.coordT = [(self.startx, self.starty),
307  (self.startx-BLANK, self.starty),
308  (self.startx-BLANK, self.endy-BLANK),
309  (self.endx, self.endy-BLANK),
310  (self.endx, self.endy)]
311  elif inp == 'Left' and outp == 'Bottom' :
312  self.coordT = [(self.startx, self.starty),
313  (self.startx-BLANK, self.starty),
314  (self.startx-BLANK, self.endy+BLANK),
315  (self.endx, self.endy+BLANK),
316  (self.endx, self.endy)]
317  elif inp == 'Right' and outp == 'Top' :
318  self.coordT = [(self.startx, self.starty),
319  (self.startx+BLANK, self.starty),
320  (self.startx+BLANK, self.endy-BLANK),
321  (self.endx, self.endy-BLANK),
322  (self.endx, self.endy)]
323  elif inp == 'Right' and outp == 'Bottom' :
324  self.coordT = [(self.startx, self.starty),
325  (self.startx+BLANK, self.starty),
326  (self.startx+BLANK, self.endy+BLANK),
327  (self.endx, self.endy+BLANK),
328  (self.endx, self.endy)]
329 
330 # #print "test 1:"
331  w1 = abs(self.coordT[2][0] - self.coordT[3][0])
332  h1 = abs(self.coordT[2][1] - self.coordT[3][1])
333  if w1 == 0:
334  tmp = h1/20
335  wadd = 0
336  hadd = 20
337  else:
338  tmp = w1/20
339  wadd = 20
340  hadd = 0
341 
342  canvas = self.parent.parent.body.GetCanvas()
343 
344  cur = []
345  for n in range(int(tmp)):
346  shape = canvas.FindShape(self.coordT[2][0]+wadd*n,self.coordT[2][1]+hadd*n)
347  if shape != 0:
348  cur.append(shape[0])
349 
350  for obj in cur :
351  tags = obj.parent.tag
352  if 'body' in tags :
353  self.drawLineP11(inpBox, outpBox)
354  break
355 
356  def drawLineP9(self, inpBox, outpBox) :
357  #print "drawLineP9:"
358  inp = self.g_inp.getConfig('position')
359  outp = self.g_outp.getConfig('position')
360 
361  if inp == 'Top' :
362  if inpBox[1] <= outpBox[1] :
363  hight = inpBox[1]-BLANK
364  else :
365  hight = outpBox[1]-BLANK
366  elif inp == 'Bottom' :
367  if inpBox[3] >= outpBox[3] :
368  hight = inpBox[3]+BLANK
369  else :
370  hight = outpBox[3]+BLANK
371  elif inp == 'Left' :
372  if inpBox[0] <= outpBox[0] :
373  width = inpBox[0]-BLANK
374  else :
375  width = outpBox[0]-BLANK
376  elif inp == 'Right' :
377  if inpBox[2] >= outpBox[2] :
378  width = inpBox[2]+BLANK
379  else :
380  width = outpBox[2]+BLANK
381 
382  if (inp == 'Top' or inp == 'Bottom') and outp == 'Right' :
383  self.coordT = [(self.startx, self.starty),
384  (self.startx, hight),
385  (self.endx+BLANK, hight),
386  (self.endx+BLANK, self.endy),
387  (self.endx, self.endy)]
388  elif (inp == 'Top' or inp == 'Bottom') and outp == 'Left' :
389  self.coordT = [(self.startx, self.starty),
390  (self.startx, hight),
391  (self.endx-BLANK, hight),
392  (self.endx-BLANK, self.endy),
393  (self.endx, self.endy)]
394  elif (inp == 'Left' or inp == 'Right') and outp == 'Top' :
395  self.coordT = [(self.startx, self.starty),
396  (width, self.starty),
397  (width, self.endy-BLANK),
398  (self.endx, self.endy-BLANK),
399  (self.endx, self.endy)]
400  elif (inp == 'Left' or inp == 'Right') and outp == 'Bottom' :
401  self.coordT = [(self.startx, self.starty),
402  (width, self.starty),
403  (width, self.endy+BLANK),
404  (self.endx, self.endy+BLANK),
405  (self.endx, self.endy)]
406 
407 # #print "test 2:"
408  w1 = abs(self.coordT[2][0] - self.coordT[3][0])
409  h1 = abs(self.coordT[2][1] - self.coordT[3][1])
410  if w1 == 0:
411  tmp = h1/20
412  wadd = 0
413  hadd = 20
414  else:
415  tmp = w1/20
416  wadd = 20
417  hadd = 0
418 
419  canvas = self.parent.parent.body.GetCanvas()
420 
421  cur = []
422  for n in range(int(tmp)):
423  shape = canvas.FindShape(self.coordT[2][0]+wadd*n,self.coordT[2][1]+hadd*n)
424  if shape != 0:
425  cur.append(shape[0])
426 
427  for obj in cur :
428  tags = obj.parent.tag
429  if 'body' in tags :
430  self.drawLineP11(inpBox, outpBox)
431  break
432 
433  def drawLineP10(self, inpBox, outpBox) :
434  #print "drawLineP10:"
435  inp = self.g_inp.getConfig('position')
436  outp = self.g_outp.getConfig('position')
437  if inp == 'Top' and outp == 'Left' :
438  self.coordT = [(self.startx, self.starty),
439  (self.startx, self.starty-BLANK),
440  (self.endx-BLANK, self.starty-BLANK),
441  (self.endx-BLANK, self.endy),
442  (self.endx, self.endy)]
443  elif inp == 'Top' and outp == 'Right' :
444  self.coordT = [(self.startx, self.starty),
445  (self.startx, self.starty-BLANK),
446  (self.endx+BLANK, self.starty-BLANK),
447  (self.endx+BLANK, self.endy),
448  (self.endx, self.endy)]
449  elif inp == 'Bottom' and outp == 'Left' :
450  self.coordT = [(self.startx, self.starty),
451  (self.startx, self.starty+BLANK),
452  (self.endx-BLANK, self.starty+BLANK),
453  (self.endx-BLANK, self.endy),
454  (self.endx, self.endy)]
455  elif inp == 'Bottom' and outp == 'Right' :
456  self.coordT = [(self.startx, self.starty),
457  (self.startx, self.starty+BLANK),
458  (self.endx+BLANK, self.starty+BLANK),
459  (self.endx+BLANK, self.endy),
460  (self.endx, self.endy)]
461  elif inp == 'Left' and outp == 'Top' :
462  self.coordT = [(self.startx, self.starty),
463  (self.startx-BLANK, self.starty),
464  (self.startx-BLANK, self.endy-BLANK),
465  (self.endx, self.endy-BLANK),
466  (self.endx, self.endy)]
467  elif inp == 'Left' and outp == 'Bottom' :
468  self.coordT = [(self.startx, self.starty),
469  (self.startx-BLANK, self.starty),
470  (self.startx-BLANK, self.endy+BLANK),
471  (self.endx, self.endy+BLANK),
472  (self.endx, self.endy)]
473  elif inp == 'Right' and outp == 'Top' :
474  self.coordT = [(self.startx, self.starty),
475  (self.startx+BLANK, self.starty),
476  (self.startx+BLANK, self.endy-BLANK),
477  (self.endx, self.endy-BLANK),
478  (self.endx, self.endy)]
479  elif inp == 'Right' and outp == 'Bottom' :
480  self.coordT = [(self.startx, self.starty),
481  (self.startx+BLANK, self.starty),
482  (self.startx+BLANK, self.endy+BLANK),
483  (self.endx, self.endy+BLANK),
484  (self.endx, self.endy)]
485 
486  def drawLineP11(self, inpBox, outpBox) :
487  #print "drawLineP11:"
488  inp = self.g_inp.getConfig('position')
489  outp = self.g_outp.getConfig('position')
490  if inp == 'Top' and outp == 'Right':
491  self.coordT = [(self.startx, self.starty),
492  (self.startx, self.starty-BLANK),
493  (inpBox[2]+BLANK, self.starty-BLANK),
494  (inpBox[2]+BLANK, self.endy),
495  (self.endx, self.endy)]
496  elif inp == 'Bottom' and outp == 'Right':
497  self.coordT = [(self.startx, self.starty),
498  (self.startx, self.starty+BLANK),
499  (inpBox[2]+BLANK, self.starty+BLANK),
500  (inpBox[2]+BLANK, self.endy),
501  (self.endx, self.endy)]
502  elif inp == 'Top' and outp == 'Left' :
503  self.coordT = [(self.startx, self.starty),
504  (self.startx, self.starty-BLANK),
505  (inpBox[0]-BLANK, self.starty-BLANK),
506  (inpBox[0]-BLANK, self.endy),
507  (self.endx, self.endy)]
508  elif inp == 'Bottom' and outp == 'Left' :
509  self.coordT = [(self.startx, self.starty),
510  (self.startx, self.starty+BLANK),
511  (inpBox[0]-BLANK, self.starty+BLANK),
512  (inpBox[0]-BLANK, self.endy),
513  (self.endx, self.endy)]
514  elif inp == 'Left' and outp == 'Bottom' :
515  self.coordT = [(self.startx, self.starty),
516  (self.startx-BLANK, self.starty),
517  (self.startx-BLANK, inpBox[3]+BLANK),
518  (self.endx, inpBox[3]+BLANK),
519  (self.endx, self.endy)]
520  elif inp == 'Right' and outp == 'Bottom' :
521  self.coordT = [(self.startx, self.starty),
522  (self.startx+BLANK, self.starty),
523  (self.startx+BLANK, inpBox[3]+BLANK),
524  (self.endx, inpBox[3]+BLANK),
525  (self.endx, self.endy)]
526  elif inp == 'Left' and outp == 'Top' :
527  self.coordT = [(self.startx, self.starty),
528  (self.startx-BLANK, self.starty),
529  (self.startx-BLANK, inpBox[0]-BLANK),
530  (self.endx, inpBox[0]-BLANK),
531  (self.endx, self.endy)]
532  elif inp == 'Right' and outp == 'Top' :
533  self.coordT = [(self.startx, self.starty),
534  (self.startx+BLANK, self.starty),
535  (self.startx+BLANK, inpBox[0]-BLANK),
536  (self.endx, inpBox[0]-BLANK),
537  (self.endx, self.endy)]
538 
539  def drawLinePetc(self) :
540  self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
541 
542  #######################################################
543  # drawing line
544  #######################################################
545  def drawLine(self) :
546  inp = self.g_inp
547  outp = self.g_outp
548  if outp == None or inp == None:
549  self.drawLinePetc()
550  else :
551  inpPos = inp.getConfig('position')
552  outpPos = outp.getConfig('position')
553  inpBox = [0,0,0,0]
554  inpBox[2],inpBox[3] = inp.parent.baseBox.GetBoundingBoxMin()
555 # inpBox[2],inpBox[3] = inp.parent.body.GetBoundingBoxMin()
556  inpBox[0] = inp.parent.body.GetX() - inpBox[2]/2
557  inpBox[1] = inp.parent.body.GetY() - inpBox[3]/2
558  inpBox[2] = inpBox[0] + inpBox[2]
559  inpBox[3] = inpBox[1] + inpBox[3]
560  outpBox = [0,0,0,0]
561  outpBox[2],outpBox[3] = outp.parent.baseBox.GetBoundingBoxMin()
562 # outpBox[2],outpBox[3] = outp.parent.body.GetBoundingBoxMin()
563  outpBox[0] = outp.parent.body.GetX() - outpBox[2]/2
564  outpBox[1] = outp.parent.body.GetY() - outpBox[3]/2
565  outpBox[2] = outpBox[0] + outpBox[2]
566  outpBox[3] = outpBox[1] + outpBox[3]
567  if (inpBox[2] < outpBox[0] and outpPos == 'Left' and inpPos == 'Right') or \
568  (outpBox[3] < inpBox[1] and outpPos == 'Bottom' and inpPos == 'Top') or \
569  (inpBox[0] > outpBox[2] and outpPos == 'Right' and inpPos == 'Left') or \
570  (inpBox[3] < outpBox[1] and outpPos == 'Top' and inpPos == 'Bottom') :
571  self.drawLineP1()
572  elif ((inpBox[1] > outpBox[3]) and ((outpPos == 'Right' and inpPos == 'Left') or \
573  (outpPos == 'Left' and inpPos == 'Right'))) or \
574  ((inpBox[0] > outpBox[2]) and ((outpPos == 'Bottom' and inpPos == 'Top') or \
575  (outpPos == 'Top' and inpPos == 'Bottom'))) :
576  self.drawLineP2(inpBox, outpBox)
577  elif ((inpBox[3] < outpBox[1]) and ((outpPos == 'Right' and inpPos == 'Left') or \
578  (outpPos == 'Left' and inpPos == 'Right'))) or \
579  ((inpBox[2] < outpBox[0]) and ((outpPos == 'Bottom' and inpPos == 'Top') or \
580  (outpPos == 'Top' and inpPos == 'Bottom'))) :
581  self.drawLineP3(inpBox, outpBox)
582  elif ((inpBox[2] < outpBox[0]) and (outpPos == 'Right' and inpPos == 'Left')) or \
583  ((inpBox[0] > outpBox[2]) and (outpPos == 'Left' and inpPos == 'Right')) or \
584  ((inpBox[3] < outpBox[1]) and (outpPos == 'Bottom' and inpPos == 'Top')) or \
585  ((inpBox[1] > outpBox[3]) and (outpPos == 'Top' and inpPos == 'Bottom')) :
586  self.drawLineP4(inpBox, outpBox)
587  elif ((outpPos == 'Left' and inpPos == 'Left') or (outpPos == 'Right' and inpPos == 'Right')) and \
588  ((inpBox[1] > outpBox[3]) or (inpBox[3] < outpBox[1])) :
589  self.drawLineP5(inpBox, outpBox)
590  elif ((outpPos == 'Top' and inpPos == 'Top') or (outpPos == 'Bottom' and inpPos == 'Bottom')) and \
591  ((inpBox[2] < outpBox[0]) or (inpBox[0] > outpBox[2])) :
592  self.drawLineP5(inpBox, outpBox)
593  elif ((outpPos == 'Left' and inpPos == 'Left') or (outpPos == 'Right' and inpPos == 'Right')) and \
594  ((inpBox[1] <= outpBox[3]) and (inpBox[3] >= outpBox[1])) :
595  self.drawLineP6(inpBox, outpBox)
596  elif ((outpPos == 'Top' and inpPos == 'Top') or (outpPos == 'Bottom' and inpPos == 'Bottom')) and \
597  ((inpBox[2] >= outpBox[0]) and (inpBox[0] <= outpBox[2])) :
598  self.drawLineP6(inpBox, outpBox)
599  elif ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Left' and inpBox[2] < outpBox[0]) or \
600  ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Right' and inpBox[0] > outpBox[2]) :
601  self.drawLineP7(inpBox, outpBox)
602  elif ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Top' and inpBox[3] < outpBox[1]) or \
603  ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Bottom' and inpBox[1] > outpBox[3]) :
604  self.drawLineP7(inpBox, outpBox)
605  elif ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Left' and inpBox[0] > outpBox[2]) or \
606  ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Right' and inpBox[2] < outpBox[0]) :
607  self.drawLineP9(inpBox, outpBox)
608  elif ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Top' and inpBox[1] > outpBox[3]) or \
609  ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Bottom' and inpBox[3] < outpBox[1]) :
610  self.drawLineP9(inpBox, outpBox)
611  elif (inpPos == 'Left' and outpPos == 'Top' and inpBox[0] <= outpBox[0] and inpBox[3] >= outpBox[1]) or \
612  (inpPos == 'Right' and outpPos == 'Top' and inpBox[2] >= outpBox[2] and inpBox[3] >= outpBox[1])or \
613  (inpPos == 'Left' and outpPos == 'Bottom' and inpBox[0] <= outpBox[0] and inpBox[1] <= outpBox[3]) or \
614  (inpPos == 'Right' and outpPos == 'Bottom' and inpBox[2] >= outpBox[2] and inpBox[1] <= outpBox[3]) :
615  self.drawLineP9(inpBox, outpBox)
616  elif (inpPos == 'Top' and outpPos == 'Left' and inpBox[1] <= outpBox[1] and inpBox[2] >= outpBox[0]) or \
617  (inpPos == 'Bottom' and outpPos == 'Left' and inpBox[3] >= outpBox[3] and inpBox[2] >= outpBox[0]) or \
618  (inpPos == 'Top' and outpPos == 'Right' and inpBox[1] <= outpBox[1] and inpBox[0] <= outpBox[2]) or \
619  (inpPos == 'Bottom' and outpPos == 'Right' and inpBox[3] >= outpBox[3] and inpBox[0] <= outpBox[2]) :
620  self.drawLineP9(inpBox, outpBox)
621  elif (inpPos == 'Top' and (outpPos == 'Left' or outpPos == 'Right')) and (inpBox[0] <= outpBox[2] and inpBox[2] >= outpBox[0]) and \
622  (inpBox[1] >= outpBox[3]) :
623  self.drawLineP10(inpBox, outpBox)
624  elif (inpPos == 'Bottom' and (outpPos == 'Left' or outpPos == 'Right')) and (inpBox[0] <= outpBox[2] and inpBox[2] >= outpBox[0]) and \
625  (inpBox[3] <= outpBox[1]) :
626  self.drawLineP10(inpBox, outpBox)
627  elif (inpPos == 'Left' and (outpPos == 'Top' or outpPos == 'Bottom')) and (inpBox[1] <= outpBox[3] and inpBox[3] >= outpBox[1]) and \
628  (inpBox[0] >= outpBox[2]) :
629  self.drawLineP10(inpBox, outpBox)
630  elif (inpPos == 'Right' and (outpPos == 'Top' or outpPos == 'Bottom')) and (inpBox[1] <= outpBox[3] and inpBox[3] >= outpBox[1]) and \
631  (inpBox[2] <= outpBox[0]) :
632  self.drawLineP10(inpBox, outpBox)
633  else : # at once, it joins inport and outport
634  self.drawLinePetc()
635  #self.parent.draw.coords(self.body, self.coordT) # redraw line
636 # paraT = ()
637 # paraT = (self.body,) + self.coordT
638 # apply(self.parent.draw.coords, paraT) # redraw line ( for python v1.5 )
639  return self.coordT
640 
def __init__(self, parent, g_inp, g_outp, startx, starty, endx, endy)
Definition: RtmLineUtil.py:25
def drawLinePetc(self)
Definition: RtmLineUtil.py:539
def drawLineP11(self, inpBox, outpBox)
Definition: RtmLineUtil.py:486
def drawLineP3(self, inpBox, outpBox)
Definition: RtmLineUtil.py:90
def drawLine(self)
drawing line
Definition: RtmLineUtil.py:545
def drawLineP7(self, inpBox, outpBox)
Definition: RtmLineUtil.py:254
def drawLineP9(self, inpBox, outpBox)
Definition: RtmLineUtil.py:356
def drawLineP6(self, inpBox, outpBox)
Definition: RtmLineUtil.py:209
def drawLineP5(self, inpBox, outpBox)
Definition: RtmLineUtil.py:168
def drawLineP8(self, inpBox, outpBox)
Definition: RtmLineUtil.py:277
def drawLineP1(self)
Definition: RtmLineUtil.py:35
def drawLineP10(self, inpBox, outpBox)
Definition: RtmLineUtil.py:433
def drawLineP2(self, inpBox, outpBox)
Definition: RtmLineUtil.py:57
def drawLineP4(self, inpBox, outpBox)
Definition: RtmLineUtil.py:123


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00