RtmLineUtil.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 #
00004 #  @file RtmLineUtil.py
00005 #  @brief rtc-link line management classes
00006 #  @date $Date: 2005-05-12 09:06:19 $
00007 #  @author Tsuyoshi Tanabe, Noriaki Ando <n-ando@aist.go.jp>
00008 # 
00009 #  Copyright (C) 2004-2005
00010 #      Task-intelligence Research Group,
00011 #      Intelligent Systems Research Institute,
00012 #      National Institute of
00013 #          Advanced Industrial Science and Technology (AIST), Japan
00014 #      All rights reserved.
00015 # 
00016 #  $Id: RtmLineUtil.py 775 2008-07-28 16:14:45Z n-ando $
00017 # 
00018 
00019 import sys
00020 import string
00021 
00022 BLANK = 25
00023 
00024 class LineUtil:
00025   def __init__(self, parent, g_inp, g_outp, startx, starty, endx, endy):
00026     self.g_inp  = g_inp   # GRtcIn
00027     self.g_outp  = g_outp   # GRtcOut
00028     self.startx = startx
00029     self.starty = starty
00030     self.endx   = endx
00031     self.endy   = endy
00032     self.coordT = None
00033     self.parent = parent
00034 
00035   def drawLineP1(self) :
00036     #print "drawLineP1:"
00037     width = self.startx - self.endx
00038     hight = self.starty - self.endy
00039     inp = self.g_inp.getConfig('position')
00040     if inp == 'Left' or inp == 'Right' :
00041       if abs(width) <= abs(hight) :
00042         self.coordT = [(self.startx, self.starty),
00043                        (self.endx + width/2, self.starty),
00044                        (self.endx + width/2, self.endy),
00045                        (self.endx, self.endy)]
00046       else :
00047         self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
00048     if inp == 'Top' or inp == 'Bottom' :
00049       if abs(width) >= abs(hight) :
00050         self.coordT = [(self.startx, self.starty),
00051                        (self.startx, self.endy + hight/2),
00052                        (self.endx, self.endy + hight/2),
00053                        (self.endx, self.endy)]
00054       else :
00055         self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
00056 
00057   def drawLineP2(self, inpBox, outpBox) :
00058     #print "drawLineP2:"
00059     inp = self.g_inp.getConfig('position')
00060     outp = self.g_outp.getConfig('position')
00061     if inp == 'Left' and outp == 'Right' :
00062       self.coordT = [(self.startx, self.starty),
00063                      (self.startx-BLANK, self.starty),
00064                      (self.startx-BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
00065                      (self.endx+BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
00066                      (self.endx+BLANK, self.endy),
00067                      (self.endx, self.endy)]
00068     elif inp == 'Right' and outp == 'Left' :
00069       self.coordT = [(self.startx, self.starty),
00070                      (self.startx+BLANK, self.starty),
00071                      (self.startx+BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
00072                      (self.endx-BLANK, outpBox[3]+((inpBox[1]-outpBox[3])/2)),
00073                      (self.endx-BLANK, self.endy),
00074                      (self.endx, self.endy)]
00075     elif inp == 'Top' and outp == 'Bottom' :
00076       self.coordT = [(self.startx, self.starty),
00077                      (self.startx, self.starty-BLANK),
00078                      (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.starty-BLANK),
00079                      (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.endy+BLANK),
00080                      (self.endx, self.endy+BLANK),
00081                      (self.endx, self.endy)]
00082     elif inp == 'Bottom' and outp == 'Top' :
00083       self.coordT = [(self.startx, self.starty),
00084                      (self.startx, self.starty+BLANK),
00085                      (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.starty+BLANK),
00086                      (outpBox[2]+((inpBox[0]-outpBox[2])/2), self.endy-BLANK),
00087                      (self.endx, self.endy-BLANK),
00088                      (self.endx, self.endy)]
00089 
00090   def drawLineP3(self, inpBox, outpBox) :
00091     #print "drawLineP3:"
00092     inp = self.g_inp.getConfig('position')
00093     outp = self.g_outp.getConfig('position')
00094     if inp == 'Left' and outp == 'Right' :
00095       self.coordT = [(self.startx, self.starty),
00096                      (self.startx-BLANK, self.starty),
00097                      (self.startx-BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
00098                      (self.endx+BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
00099                      (self.endx+BLANK, self.endy),
00100                      (self.endx, self.endy)]
00101     elif inp == 'Right' and outp == 'Left' :
00102       self.coordT = [(self.startx, self.starty),
00103                      (self.startx+BLANK, self.starty),
00104                      (self.startx+BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
00105                      (self.endx-BLANK, inpBox[3]+((outpBox[1]-inpBox[3])/2)),
00106                      (self.endx-BLANK, self.endy),
00107                      (self.endx, self.endy)]
00108     elif inp == 'Top' and outp == 'Bottom' :
00109       self.coordT = [(self.startx, self.starty),
00110                      (self.startx, self.starty-BLANK),
00111                      (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.starty-BLANK),
00112                      (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.endy+BLANK),
00113                      (self.endx, self.endy+BLANK),
00114                      (self.endx, self.endy)]
00115     elif inp == 'Bottom' and outp == 'Top' :
00116       self.coordT = [(self.startx, self.starty),
00117                      (self.startx, self.starty+BLANK),
00118                      (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.starty+BLANK),
00119                      (inpBox[2]+((outpBox[0]-inpBox[2])/2), self.endy-BLANK),
00120                      (self.endx, self.endy-BLANK),
00121                      (self.endx, self.endy)]
00122 
00123   def drawLineP4(self, inpBox, outpBox) :
00124     #print "drawLineP4:"
00125     inp = self.g_inp.getConfig('position')
00126     outp = self.g_outp.getConfig('position')
00127 
00128     if inp == 'Left' or inp == 'Right' :
00129       if inpBox[3] >= outpBox[3] :
00130         hight = inpBox[3]+BLANK
00131       else :
00132         hight = outpBox[3]+BLANK
00133     elif inp == 'Top' or inp == 'Bottom' :
00134       if inpBox[2] >= outpBox[2] :
00135         width = inpBox[2]+BLANK
00136       else :
00137         width = outpBox[2]+BLANK  
00138 
00139     if inp == 'Left' and outp == 'Right' :  
00140       self.coordT = [(self.startx, self.starty),
00141                      (self.startx-BLANK, self.starty),
00142                      (self.startx-BLANK, hight),
00143                      (self.endx+BLANK, hight),
00144                      (self.endx+BLANK, self.endy),
00145                      (self.endx, self.endy)]
00146     elif inp == 'Right' and outp == 'Left' :
00147       self.coordT = [(self.startx, self.starty),
00148                      (self.startx+BLANK, self.starty),
00149                      (self.startx+BLANK, hight),
00150                      (self.endx-BLANK, hight),
00151                      (self.endx-BLANK, self.endy),
00152                      (self.endx, self.endy)]
00153     elif inp == 'Top' and outp == 'Bottom' :
00154       self.coordT = [(self.startx, self.starty),
00155                      (self.startx, self.starty-BLANK),
00156                      (width, self.starty-BLANK),
00157                      (width, self.endy+BLANK),
00158                      (self.endx, self.endy+BLANK),
00159                      (self.endx, self.endy)]
00160     elif inp == 'Bottom' and outp == 'Top' :
00161       self.coordT = [(self.startx, self.starty),
00162                      (self.startx, self.starty+BLANK),
00163                      (width, self.starty+BLANK),
00164                      (width, self.endy-BLANK),
00165                      (self.endx, self.endy-BLANK),
00166                      (self.endx, self.endy)]
00167 
00168   def drawLineP5(self, inpBox, outpBox) :    
00169     #print "drawLineP5:"
00170     inp = self.g_inp.getConfig('position')
00171     outp = self.g_outp.getConfig('position')
00172     if inp == 'Left' and outp == 'Left' :
00173       if self.endx - (self.startx-BLANK) < BLANK :
00174         pos_x = self.endx-BLANK
00175       else :
00176         pos_x = self.startx-BLANK
00177       self.coordT = [(self.startx, self.starty),
00178                      (pos_x, self.starty),
00179                      (pos_x, self.endy),
00180                      (self.endx, self.endy)]
00181     elif inp == 'Right' and outp == 'Right' :
00182       if (self.startx+BLANK) - self.endx < BLANK :
00183         pos_x = self.endx+BLANK
00184       else :
00185         pos_x = self.startx+BLANK  
00186       self.coordT = [(self.startx, self.starty),
00187                      (pos_x, self.starty),
00188                      (pos_x, self.endy),
00189                      (self.endx, self.endy)]
00190     elif inp == 'Top' and outp == 'Top' :
00191       if self.endy - (self.starty-BLANK) < BLANK :
00192         pos_y = self.endy-BLANK
00193       else :
00194         pos_y = self.starty-BLANK
00195       self.coordT = [(self.startx, self.starty),
00196                      (self.startx, pos_y),
00197                      (self.endx, pos_y),
00198                      (self.endx, self.endy)]
00199     elif inp == 'Bottom' and outp == 'Bottom' :
00200       if (self.starty+BLANK) - self.endy < BLANK :
00201         pos_y = self.endy+BLANK
00202       else :
00203         pos_y = self.starty+BLANK
00204       self.coordT = [(self.startx, self.starty),
00205                      (self.startx, pos_y),
00206                      (self.endx, pos_y),
00207                      (self.endx, self.endy)]
00208 
00209   def drawLineP6(self, inpBox, outpBox) :    
00210     #print "drawLineP6:"
00211     inp = self.g_inp.getConfig('position')
00212     outp = self.g_outp.getConfig('position')
00213 
00214     if inp == 'Left' or inp == 'Right' :
00215       if inpBox[3] >= outpBox[3] :
00216         hight = inpBox[3]+BLANK
00217       else :
00218         hight = outpBox[3]+BLANK
00219     elif inp == 'Top' or inp == 'Bottom' :
00220       if inpBox[2] >= outpBox[2] :
00221         width = inpBox[2]+BLANK
00222       else :
00223         width = outpBox[2]+BLANK  
00224 
00225     if inp == 'Left' and outp == 'Left' :
00226       self.coordT = [(self.startx, self.starty),
00227                      (self.startx-BLANK, self.starty),
00228                      (self.startx-BLANK, hight),
00229                      (self.endx-BLANK, hight),
00230                      (self.endx-BLANK, self.endy),
00231                      (self.endx, self.endy)]
00232     elif inp == 'Right' and outp == 'Right' :
00233       self.coordT = [(self.startx, self.starty),
00234                      (self.startx+BLANK, self.starty),
00235                      (self.startx+BLANK, hight),
00236                      (self.endx+BLANK, hight),
00237                      (self.endx+BLANK, self.endy),
00238                      (self.endx, self.endy)]
00239     elif inp == 'Top' and outp == 'Top' :
00240       self.coordT = [(self.startx, self.starty),
00241                      (self.startx, self.starty-BLANK),
00242                      (width, self.starty-BLANK),
00243                      (width, self.endy-BLANK),
00244                      (self.endx, self.endy-BLANK),
00245                      (self.endx, self.endy)]
00246     elif inp == 'Bottom' and outp == 'Bottom' :    
00247       self.coordT = [(self.startx, self.starty),
00248                      (self.startx, self.starty+BLANK),
00249                      (width, self.starty+BLANK),
00250                      (width, self.endy+BLANK),
00251                      (self.endx, self.endy+BLANK),
00252                      (self.endx, self.endy)]
00253 
00254   def drawLineP7(self, inpBox, outpBox) :    
00255     #print "drawLineP7:"
00256     inp = self.g_inp.getConfig('position')
00257     outp = self.g_outp.getConfig('position')
00258     if (inp == 'Top' and (outp == 'Left' or outp == 'Right')) or \
00259        (inp == 'Bottom' and (outp == 'Left' or outp == 'Right')) :
00260       if (inp == 'Top' and self.starty-self.endy >= BLANK) or \
00261          (inp == 'Bottom' and self.endy-self.starty >= BLANK) :
00262         self.coordT = [(self.startx, self.starty),
00263                        (self.startx, self.endy),
00264                        (self.endx, self.endy)]
00265       else :
00266         self.drawLineP8(inpBox, outpBox)  
00267     elif (inp == 'Left' and (outp == 'Top' or outp == 'Bottom')) or \
00268          (inp == 'Right' and (outp == 'Top' or outp == 'Bottom')) :
00269       if (inp == 'Left' and self.startx-self.endx >= BLANK) or \
00270          (inp == 'Right' and self.endx-self.startx >= BLANK) : 
00271         self.coordT = [(self.startx, self.starty),
00272                        (self.endx, self.starty),
00273                        (self.endx, self.endy)]
00274       else :
00275         self.drawLineP8(inpBox, outpBox)    
00276 
00277   def drawLineP8(self, inpBox, outpBox) :    
00278     #print "drawLineP8:"
00279     inp = self.g_inp.getConfig('position')
00280     outp = self.g_outp.getConfig('position')
00281     if inp == 'Top' and outp == 'Left' :
00282       self.coordT = [(self.startx, self.starty),
00283                      (self.startx, self.starty-BLANK),
00284                      (self.endx-BLANK, self.starty-BLANK),
00285                      (self.endx-BLANK, self.endy),
00286                      (self.endx, self.endy)]
00287     elif inp == 'Top' and outp == 'Right' :
00288       self.coordT = [(self.startx, self.starty),
00289                      (self.startx, self.starty-BLANK),
00290                      (self.endx+BLANK, self.starty-BLANK),
00291                      (self.endx+BLANK, self.endy),
00292                      (self.endx, self.endy)]
00293     elif inp == 'Bottom' and outp == 'Left' :
00294       self.coordT = [(self.startx, self.starty),
00295                      (self.startx, self.starty+BLANK),
00296                      (self.endx-BLANK, self.starty+BLANK),
00297                      (self.endx-BLANK, self.endy),
00298                      (self.endx, self.endy)]
00299     elif inp == 'Bottom' and outp == 'Right' :
00300       self.coordT = [(self.startx, self.starty),
00301                      (self.startx, self.starty+BLANK),
00302                      (self.endx+BLANK, self.starty+BLANK),
00303                      (self.endx+BLANK, self.endy),
00304                      (self.endx, self.endy)]
00305     elif inp == 'Left' and outp == 'Top' :
00306       self.coordT = [(self.startx, self.starty),
00307                      (self.startx-BLANK, self.starty),
00308                      (self.startx-BLANK, self.endy-BLANK),
00309                      (self.endx, self.endy-BLANK),
00310                      (self.endx, self.endy)]
00311     elif inp == 'Left' and outp == 'Bottom' :
00312       self.coordT = [(self.startx, self.starty),
00313                      (self.startx-BLANK, self.starty),
00314                      (self.startx-BLANK, self.endy+BLANK),
00315                      (self.endx, self.endy+BLANK),
00316                      (self.endx, self.endy)]
00317     elif inp == 'Right' and outp == 'Top' :
00318       self.coordT = [(self.startx, self.starty),
00319                      (self.startx+BLANK, self.starty),
00320                      (self.startx+BLANK, self.endy-BLANK),
00321                      (self.endx, self.endy-BLANK),
00322                      (self.endx, self.endy)]
00323     elif inp == 'Right' and outp == 'Bottom' :
00324       self.coordT = [(self.startx, self.starty),
00325                      (self.startx+BLANK, self.starty),
00326                      (self.startx+BLANK, self.endy+BLANK),
00327                      (self.endx, self.endy+BLANK),
00328                      (self.endx, self.endy)]
00329 
00330 #    #print "test 1:"
00331     w1 = abs(self.coordT[2][0] - self.coordT[3][0])
00332     h1 = abs(self.coordT[2][1] - self.coordT[3][1])
00333     if w1 == 0:
00334       tmp = h1/20
00335       wadd = 0
00336       hadd = 20
00337     else:
00338       tmp = w1/20
00339       wadd = 20
00340       hadd = 0
00341 
00342     canvas = self.parent.parent.body.GetCanvas()
00343 
00344     cur = []
00345     for n in range(int(tmp)):
00346       shape = canvas.FindShape(self.coordT[2][0]+wadd*n,self.coordT[2][1]+hadd*n)
00347       if shape != 0:
00348           cur.append(shape[0])
00349 
00350     for obj in cur :
00351       tags = obj.parent.tag
00352       if 'body' in tags :
00353         self.drawLineP11(inpBox, outpBox)  
00354         break
00355 
00356   def drawLineP9(self, inpBox, outpBox) :    
00357     #print "drawLineP9:"
00358     inp = self.g_inp.getConfig('position')
00359     outp = self.g_outp.getConfig('position')
00360     
00361     if inp == 'Top' :
00362       if inpBox[1] <= outpBox[1] :
00363         hight = inpBox[1]-BLANK
00364       else :
00365         hight = outpBox[1]-BLANK
00366     elif inp == 'Bottom' :
00367       if inpBox[3] >= outpBox[3] :
00368         hight = inpBox[3]+BLANK 
00369       else :
00370         hight = outpBox[3]+BLANK
00371     elif inp == 'Left' :
00372       if inpBox[0] <= outpBox[0] :
00373         width = inpBox[0]-BLANK
00374       else :
00375         width = outpBox[0]-BLANK
00376     elif inp == 'Right' :
00377       if inpBox[2] >= outpBox[2] :
00378         width = inpBox[2]+BLANK
00379       else :
00380         width = outpBox[2]+BLANK
00381     
00382     if (inp == 'Top' or inp == 'Bottom') and outp == 'Right' :
00383       self.coordT = [(self.startx, self.starty),
00384                      (self.startx, hight),
00385                      (self.endx+BLANK, hight),
00386                      (self.endx+BLANK, self.endy),
00387                      (self.endx, self.endy)]
00388     elif (inp == 'Top' or inp == 'Bottom') and outp == 'Left' :
00389       self.coordT = [(self.startx, self.starty),
00390                      (self.startx, hight),
00391                      (self.endx-BLANK, hight),
00392                      (self.endx-BLANK, self.endy),
00393                      (self.endx, self.endy)]
00394     elif (inp == 'Left' or inp == 'Right') and outp == 'Top' :
00395       self.coordT = [(self.startx, self.starty),
00396                      (width, self.starty),
00397                      (width, self.endy-BLANK),
00398                      (self.endx, self.endy-BLANK),
00399                      (self.endx, self.endy)]
00400     elif (inp == 'Left' or inp == 'Right') and outp == 'Bottom' :
00401       self.coordT = [(self.startx, self.starty),
00402                      (width, self.starty),
00403                      (width, self.endy+BLANK),
00404                      (self.endx, self.endy+BLANK),
00405                      (self.endx, self.endy)]
00406 
00407 #    #print "test 2:"
00408     w1 = abs(self.coordT[2][0] - self.coordT[3][0])
00409     h1 = abs(self.coordT[2][1] - self.coordT[3][1])
00410     if w1 == 0:
00411       tmp = h1/20
00412       wadd = 0
00413       hadd = 20
00414     else:
00415       tmp = w1/20
00416       wadd = 20
00417       hadd = 0
00418 
00419     canvas = self.parent.parent.body.GetCanvas()
00420 
00421     cur = []
00422     for n in range(int(tmp)):
00423       shape = canvas.FindShape(self.coordT[2][0]+wadd*n,self.coordT[2][1]+hadd*n)
00424       if shape != 0:
00425         cur.append(shape[0])
00426 
00427     for obj in cur :
00428       tags = obj.parent.tag
00429       if 'body' in tags :
00430         self.drawLineP11(inpBox, outpBox)  
00431         break
00432     
00433   def drawLineP10(self, inpBox, outpBox) :    
00434     #print "drawLineP10:"
00435     inp = self.g_inp.getConfig('position')
00436     outp = self.g_outp.getConfig('position')
00437     if inp == 'Top' and outp == 'Left' :
00438       self.coordT = [(self.startx, self.starty),
00439                      (self.startx, self.starty-BLANK),
00440                      (self.endx-BLANK, self.starty-BLANK),
00441                      (self.endx-BLANK, self.endy),
00442                      (self.endx, self.endy)]
00443     elif inp == 'Top' and outp == 'Right' :
00444       self.coordT = [(self.startx, self.starty),
00445                      (self.startx, self.starty-BLANK),
00446                      (self.endx+BLANK, self.starty-BLANK),
00447                      (self.endx+BLANK, self.endy),
00448                      (self.endx, self.endy)]
00449     elif inp == 'Bottom' and outp == 'Left' :
00450       self.coordT = [(self.startx, self.starty),
00451                      (self.startx, self.starty+BLANK),
00452                      (self.endx-BLANK, self.starty+BLANK),
00453                      (self.endx-BLANK, self.endy),
00454                      (self.endx, self.endy)]
00455     elif inp == 'Bottom' and outp == 'Right' :
00456       self.coordT = [(self.startx, self.starty),
00457                      (self.startx, self.starty+BLANK),
00458                      (self.endx+BLANK, self.starty+BLANK),
00459                      (self.endx+BLANK, self.endy),
00460                      (self.endx, self.endy)]
00461     elif inp == 'Left' and outp == 'Top' :
00462       self.coordT = [(self.startx, self.starty),
00463                      (self.startx-BLANK, self.starty),
00464                      (self.startx-BLANK, self.endy-BLANK),
00465                      (self.endx, self.endy-BLANK),
00466                      (self.endx, self.endy)]
00467     elif inp == 'Left' and outp == 'Bottom' :
00468       self.coordT = [(self.startx, self.starty),
00469                      (self.startx-BLANK, self.starty),
00470                      (self.startx-BLANK, self.endy+BLANK),
00471                      (self.endx, self.endy+BLANK),
00472                      (self.endx, self.endy)]
00473     elif inp == 'Right' and outp == 'Top' : 
00474       self.coordT = [(self.startx, self.starty),
00475                      (self.startx+BLANK, self.starty),
00476                      (self.startx+BLANK, self.endy-BLANK),
00477                      (self.endx, self.endy-BLANK),
00478                      (self.endx, self.endy)]
00479     elif inp == 'Right' and outp == 'Bottom' : 
00480       self.coordT = [(self.startx, self.starty),
00481                      (self.startx+BLANK, self.starty),
00482                      (self.startx+BLANK, self.endy+BLANK),
00483                      (self.endx, self.endy+BLANK),
00484                      (self.endx, self.endy)]
00485 
00486   def drawLineP11(self, inpBox, outpBox) :    
00487     #print "drawLineP11:"
00488     inp = self.g_inp.getConfig('position')
00489     outp = self.g_outp.getConfig('position')
00490     if inp == 'Top' and outp == 'Right':
00491       self.coordT = [(self.startx, self.starty),
00492                      (self.startx, self.starty-BLANK),
00493                      (inpBox[2]+BLANK, self.starty-BLANK),
00494                      (inpBox[2]+BLANK, self.endy),
00495                      (self.endx, self.endy)]
00496     elif inp == 'Bottom' and outp == 'Right':
00497       self.coordT = [(self.startx, self.starty),
00498                      (self.startx, self.starty+BLANK),
00499                      (inpBox[2]+BLANK, self.starty+BLANK),
00500                      (inpBox[2]+BLANK, self.endy),
00501                      (self.endx, self.endy)]
00502     elif inp == 'Top' and outp == 'Left' :
00503       self.coordT = [(self.startx, self.starty),
00504                      (self.startx, self.starty-BLANK),
00505                      (inpBox[0]-BLANK, self.starty-BLANK),
00506                      (inpBox[0]-BLANK, self.endy),
00507                      (self.endx, self.endy)]
00508     elif inp == 'Bottom' and outp == 'Left' :
00509       self.coordT = [(self.startx, self.starty),
00510                      (self.startx, self.starty+BLANK),
00511                      (inpBox[0]-BLANK, self.starty+BLANK),
00512                      (inpBox[0]-BLANK, self.endy),
00513                      (self.endx, self.endy)]  
00514     elif inp == 'Left' and outp == 'Bottom' :  
00515       self.coordT = [(self.startx, self.starty),
00516                      (self.startx-BLANK, self.starty),
00517                      (self.startx-BLANK, inpBox[3]+BLANK),
00518                      (self.endx, inpBox[3]+BLANK),
00519                      (self.endx, self.endy)]
00520     elif inp == 'Right' and outp == 'Bottom' : 
00521       self.coordT = [(self.startx, self.starty),
00522                      (self.startx+BLANK, self.starty),
00523                      (self.startx+BLANK, inpBox[3]+BLANK),
00524                      (self.endx, inpBox[3]+BLANK),
00525                      (self.endx, self.endy)]  
00526     elif inp == 'Left' and outp == 'Top' :
00527       self.coordT = [(self.startx, self.starty),
00528                      (self.startx-BLANK, self.starty),
00529                      (self.startx-BLANK, inpBox[0]-BLANK),
00530                      (self.endx, inpBox[0]-BLANK),
00531                      (self.endx, self.endy)]
00532     elif inp == 'Right' and outp == 'Top' :
00533       self.coordT = [(self.startx, self.starty),
00534                      (self.startx+BLANK, self.starty),
00535                      (self.startx+BLANK, inpBox[0]-BLANK),
00536                      (self.endx, inpBox[0]-BLANK),
00537                      (self.endx, self.endy)]
00538 
00539   def drawLinePetc(self) :
00540     self.coordT = [(self.startx, self.starty), (self.endx, self.endy)]
00541     
00542   #######################################################
00543   # drawing line
00544   #######################################################                  
00545   def drawLine(self) :
00546     inp = self.g_inp
00547     outp = self.g_outp
00548     if outp == None or inp == None:  
00549       self.drawLinePetc()  
00550     else :
00551       inpPos = inp.getConfig('position')
00552       outpPos = outp.getConfig('position')
00553       inpBox = [0,0,0,0]
00554       inpBox[2],inpBox[3] = inp.parent.baseBox.GetBoundingBoxMin()
00555 #      inpBox[2],inpBox[3] = inp.parent.body.GetBoundingBoxMin()
00556       inpBox[0] = inp.parent.body.GetX() - inpBox[2]/2
00557       inpBox[1] = inp.parent.body.GetY() - inpBox[3]/2
00558       inpBox[2] = inpBox[0] + inpBox[2]
00559       inpBox[3] = inpBox[1] + inpBox[3]
00560       outpBox = [0,0,0,0]
00561       outpBox[2],outpBox[3] =  outp.parent.baseBox.GetBoundingBoxMin()
00562 #      outpBox[2],outpBox[3] =  outp.parent.body.GetBoundingBoxMin()
00563       outpBox[0] = outp.parent.body.GetX() - outpBox[2]/2
00564       outpBox[1] = outp.parent.body.GetY() - outpBox[3]/2
00565       outpBox[2] = outpBox[0] + outpBox[2]
00566       outpBox[3] = outpBox[1] + outpBox[3]
00567       if (inpBox[2] < outpBox[0] and outpPos == 'Left' and inpPos == 'Right') or \
00568          (outpBox[3] < inpBox[1] and outpPos == 'Bottom' and inpPos == 'Top') or \
00569          (inpBox[0] > outpBox[2] and outpPos == 'Right' and inpPos == 'Left') or \
00570          (inpBox[3] < outpBox[1] and outpPos == 'Top' and inpPos == 'Bottom') : 
00571         self.drawLineP1()
00572       elif ((inpBox[1] > outpBox[3]) and ((outpPos == 'Right' and inpPos == 'Left') or \
00573            (outpPos == 'Left' and inpPos == 'Right'))) or \
00574            ((inpBox[0] > outpBox[2]) and ((outpPos == 'Bottom' and inpPos == 'Top') or \
00575            (outpPos == 'Top' and inpPos == 'Bottom'))) :
00576         self.drawLineP2(inpBox, outpBox)
00577       elif ((inpBox[3] < outpBox[1]) and ((outpPos == 'Right' and inpPos == 'Left') or \
00578            (outpPos == 'Left' and inpPos == 'Right'))) or \
00579            ((inpBox[2] < outpBox[0]) and ((outpPos == 'Bottom' and inpPos == 'Top') or \
00580            (outpPos == 'Top' and inpPos == 'Bottom'))) :
00581         self.drawLineP3(inpBox, outpBox)
00582       elif ((inpBox[2] < outpBox[0]) and (outpPos == 'Right' and inpPos == 'Left')) or \
00583            ((inpBox[0] > outpBox[2]) and (outpPos == 'Left' and inpPos == 'Right')) or \
00584            ((inpBox[3] < outpBox[1]) and (outpPos == 'Bottom' and inpPos == 'Top')) or \
00585            ((inpBox[1] > outpBox[3]) and (outpPos == 'Top' and inpPos == 'Bottom')) :
00586         self.drawLineP4(inpBox, outpBox)
00587       elif ((outpPos == 'Left' and inpPos == 'Left') or (outpPos == 'Right' and inpPos == 'Right')) and \
00588            ((inpBox[1] > outpBox[3]) or (inpBox[3] < outpBox[1])) :
00589         self.drawLineP5(inpBox, outpBox)
00590       elif ((outpPos == 'Top' and inpPos == 'Top') or (outpPos == 'Bottom' and inpPos == 'Bottom')) and \
00591            ((inpBox[2] < outpBox[0]) or (inpBox[0] > outpBox[2])) :
00592         self.drawLineP5(inpBox, outpBox)
00593       elif ((outpPos == 'Left' and inpPos == 'Left') or (outpPos == 'Right' and inpPos == 'Right')) and \
00594            ((inpBox[1] <= outpBox[3]) and (inpBox[3] >= outpBox[1])) :
00595         self.drawLineP6(inpBox, outpBox)
00596       elif ((outpPos == 'Top' and inpPos == 'Top') or (outpPos == 'Bottom' and inpPos == 'Bottom')) and \
00597            ((inpBox[2] >= outpBox[0]) and (inpBox[0] <= outpBox[2])) :
00598         self.drawLineP6(inpBox, outpBox)
00599       elif ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Left' and inpBox[2] < outpBox[0]) or \
00600            ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Right' and inpBox[0] > outpBox[2]) :
00601         self.drawLineP7(inpBox, outpBox)
00602       elif ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Top' and inpBox[3] < outpBox[1]) or \
00603            ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Bottom' and inpBox[1] > outpBox[3]) :
00604         self.drawLineP7(inpBox, outpBox)
00605       elif ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Left' and inpBox[0] > outpBox[2]) or \
00606            ((inpPos == 'Top' or inpPos == 'Bottom') and outpPos == 'Right' and inpBox[2] < outpBox[0]) :
00607         self.drawLineP9(inpBox, outpBox)
00608       elif ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Top' and inpBox[1] > outpBox[3]) or \
00609            ((inpPos == 'Left' or inpPos == 'Right') and outpPos == 'Bottom' and inpBox[3] < outpBox[1]) :
00610         self.drawLineP9(inpBox, outpBox)
00611       elif (inpPos == 'Left' and outpPos == 'Top' and inpBox[0] <= outpBox[0] and inpBox[3] >= outpBox[1]) or \
00612            (inpPos == 'Right' and outpPos == 'Top' and inpBox[2] >= outpBox[2] and inpBox[3] >= outpBox[1])or \
00613            (inpPos == 'Left' and outpPos == 'Bottom' and inpBox[0] <= outpBox[0] and inpBox[1] <= outpBox[3]) or \
00614            (inpPos == 'Right' and outpPos == 'Bottom' and inpBox[2] >= outpBox[2] and inpBox[1] <= outpBox[3]) :
00615         self.drawLineP9(inpBox, outpBox)
00616       elif (inpPos == 'Top' and outpPos == 'Left' and inpBox[1] <= outpBox[1] and inpBox[2] >= outpBox[0]) or \
00617            (inpPos == 'Bottom' and outpPos == 'Left' and inpBox[3] >= outpBox[3] and inpBox[2] >= outpBox[0]) or \
00618            (inpPos == 'Top' and outpPos == 'Right' and inpBox[1] <= outpBox[1] and inpBox[0] <= outpBox[2]) or \
00619            (inpPos == 'Bottom' and outpPos == 'Right' and inpBox[3] >= outpBox[3] and inpBox[0] <= outpBox[2]) :
00620         self.drawLineP9(inpBox, outpBox)
00621       elif (inpPos == 'Top' and (outpPos == 'Left' or outpPos == 'Right')) and (inpBox[0] <= outpBox[2] and inpBox[2] >= outpBox[0]) and \
00622            (inpBox[1] >= outpBox[3]) :   
00623         self.drawLineP10(inpBox, outpBox)
00624       elif (inpPos == 'Bottom' and (outpPos == 'Left' or outpPos == 'Right')) and (inpBox[0] <= outpBox[2] and inpBox[2] >= outpBox[0]) and \
00625            (inpBox[3] <= outpBox[1]) :   
00626         self.drawLineP10(inpBox, outpBox)
00627       elif (inpPos == 'Left' and (outpPos == 'Top' or outpPos == 'Bottom'))  and (inpBox[1] <= outpBox[3] and inpBox[3] >= outpBox[1]) and \
00628            (inpBox[0] >= outpBox[2]) :  
00629         self.drawLineP10(inpBox, outpBox)
00630       elif (inpPos == 'Right' and (outpPos == 'Top' or outpPos == 'Bottom'))  and (inpBox[1] <= outpBox[3] and inpBox[3] >= outpBox[1]) and \
00631            (inpBox[2] <= outpBox[0]) :
00632         self.drawLineP10(inpBox, outpBox)
00633       else : # at once, it joins inport and outport
00634         self.drawLinePetc()  
00635     #self.parent.draw.coords(self.body, self.coordT) # redraw line  
00636 #    paraT = ()
00637 #    paraT = (self.body,) + self.coordT
00638 #    apply(self.parent.draw.coords, paraT) # redraw line ( for python v1.5 )
00639     return self.coordT
00640 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:06