RtmSystemDraw.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*- 
00003 #
00004 #  @file RtmSystemDraw.py
00005 #  @brief rtc-link component block diagram system draw management class
00006 #  @date $Date: 2005-05-27 15:51:31 $
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: RtmSystemDraw.py 775 2008-07-28 16:14:45Z n-ando $
00017 #
00018 # RtmSystemDraw.py                    Created on: 2004/09/13
00019 #                            Author    : Tsuyoshi Tanabe
00020 
00021 """
00022     wxPython, OGL ���Ѥ�������ݡ��ͥ�ȿ޷�ɽ������
00023 """
00024 
00025 
00026 import time
00027 import  wx
00028 import wx.lib.colourdb
00029 import  wx.ogl  as  ogl
00030 import RtmLineUtil as lu
00031 import string
00032 import sys,os
00033 import copy
00034 import RtmParser
00035 from RtmDialog import *
00036 
00037 import RTM
00038 
00039 
00040 ##wx.Trap()
00041 
00042 # ��������ǻ��Ѥ���ǥե�����
00043 # ��̾�Τϡ�wx �� colourdb �ѥå�������Τ�Τ����
00044 SELECTED_COLOR = "LIGHT BLUE"
00045 UNLOADED_COLOR = "black"
00046 INACTIVE_COLOR = "blue"
00047 ACTIVE_COLOR = "green"
00048 ERROR_COLOR = "red"
00049 TEXT_COLOR = "red"
00050 #BACK_COLOR = "LightYellow"
00051 BACK_COLOR = "WHITE"
00052 MARK_COLOR = "red"
00053 OUTLINE_COLOR = "red"
00054 VIRTUAL_COLOR = "WHITE"
00055 
00056 TRUE = 1
00057 FALSE = 0
00058 DUP_CONNECT = -1 # Duplication connection
00059 
00060 BOX_WIDTH = 50
00061 POLYGON_SIZE = 12
00062 
00063 USE_BUFFERED_DC = 1
00064 
00065 # �Хå������ɾ�ǤΥ���ƥ����ȥ�˥塼��ʸ����
00066 strDEL_SELECT = "Delete Selected Item"
00067 strREFRESH    = "Refresh"
00068 strOPEN       = "Open System"
00069 strSAVE       = "Save System"
00070 strSAVE_AS    = "Save System As"
00071 strDEL_SYS    = "Current System is Deleted when OPEN.\nDelete It?"
00072 
00073 # ����ݡ��ͥ�Ⱦ�ǤΥ���ƥ����ȥ�˥塼��ʸ����
00074 strSTART   = "Start"
00075 strSTOP    = "Stop"
00076 strRESET   = "Reset"
00077 strEXIT    = "Exit"
00078 strKILL    = "Kill"
00079 strDELITEM = "Delete Item"
00080 
00081 # ������֥ꡦ�ɤ߹��߸�Υ���ƥ����ȥ�˥塼
00082 strASM_CONNECT = "Connect"
00083 strASM_DELETE  = "Delete"
00084 
00085 # ����³�����γ�ǧ������������ʸ����
00086 strASKMESSAGE = "Old Connection Information was found.\nDelete it and reconnect?"
00087 # ���� �Ť���³���󤬥���ݡ��ͥ�Ⱦ�˸��Ĥ���ޤ������Ť���³�Ϻ������ޤ�������³���ޤ�����
00088 
00089 # Save File As �����������Υ����ȥ� 
00090 strSAVE_AS_TITLE = "Save file as ..."
00091 # Open FIle �����������Υ����ȥ� 
00092 strOPEN_TITLE = "Open a file"
00093 
00094 #----------------------------------------------------------------------
00095 class MyTextDropTarget(wx.TextDropTarget):
00096     """�ɥ�å����ɥ��åס�����ݡ��ͥ�ȤΥĥ꡼���̤���ƥ����ȥǡ����������륯�饹"""
00097     def __init__(self, parent, log):
00098         """���饹�ν������TextDropTarget�κ�����
00099 
00100         [����]
00101         parent -- �ƥ��饹
00102         log    -- ���������ѥ��饹��wx.LogMessage�Υ�åѡ���
00103 
00104         [�����]
00105         void
00106         """
00107         wx.TextDropTarget.__init__(self)
00108         self.parent = parent
00109         self.log = log
00110 
00111     def OnDropText(self, x, y, text):
00112         """�ɥ��å׵�ǽ�Υ��٥�ȥϥ�ɥ�
00113         �̥�����ɥ�����Υɥ��å�����ʸ�����������
00114 
00115         [����]
00116         x      -- �ޥ�����������Σ���ɸ
00117         y      -- �ޥ�����������Σ���ɸ
00118         text   -- �ɥ��åפ��줿ʸ����ʸ������ϥ���ݡ��ͥ��̾��
00119 
00120         [�����]
00121         void
00122         """
00123         self.log.WriteText("(%d, %d)\n%s\n" % (x, y, text))
00124         canvas = self.parent.diagram.GetCanvas()
00125         dc = wx.ClientDC(self.parent)
00126         canvas.PrepareDC(dc)
00127         self.parent.PrepareDC(dc)
00128 
00129         # NameService Tree����ɥ��åפ��줿̾�Τ���Ͽ
00130         if text not in self.parent.rtc_dict.keys():
00131 
00132 #            print "drag text:",text , " kind:",check
00133             ref = self.parent.frame.myDict.GetObjRefToFullpath(text)
00134             kind = self.parent.frame.myDict.GetKindToFullpath(text)
00135             if ref != None and kind == 'rtc':
00136                 self.parent.rtc_dict[text] = GRtc(self.parent, text, x, y)
00137                 self.parent.rtc_list.append(text)
00138                 self.parent.rtc_dict[text].refresh()
00139                 self.parent.remakeLines()
00140             else:
00141                 print "error: Drag Item does not obj-ref!"
00142 
00143         self.parent.Redraw(dc)
00144 
00145     def OnDragOver(self, x, y, d):
00146         """�ɥ�å����Ρ����٥�ȥϥ�ɥ�
00147         �ޥ����������뤬�������åȾ���褿��ƤӽФ����
00148 
00149         [����]
00150         x      -- �ޥ�����������Σ���ɸ
00151         y      -- �ޥ�����������Σ���ɸ
00152         d      -- SHIFT or CONTROL �������Υե饰
00153 
00154         [�����]
00155         wxDragResult -- �ɥ�å��ξ��֤�ʥ����ƥ�ˡ������Τ���
00156         """
00157         return wx.DragCopy
00158 
00159 #----------------------------------------------------------------------
00160 def getBufferedDC(canvas):
00161     """����DC��BufferedDC�ˤ����ꡢ��������ؿ�
00162 
00163     [����]
00164     canvas      -- ������
00165 
00166     [�����]
00167     dc         -- BufferedDC
00168     """
00169     cdc = wx.ClientDC(canvas)
00170     canvas.PrepareDC(cdc)
00171     bufSize = wx.Size(1000, 1000)
00172     dc = wx.BufferedDC(cdc, bufSize)
00173     canvas.PrepareDC(dc)
00174     dc.SetBackground(wx.Brush(canvas.GetBackgroundColour()))
00175     dc.Clear()
00176     return dc
00177 #----------------------------------------------------------------------
00178 def setBodyColor(shape, colorFlag):
00179     """����ݡ��ͥ�Ȥξ��֤ǿ޷��ο����ѹ�����ؿ�
00180 
00181     [����]
00182     shape      -- �޷�(Shape)���֥�������
00183     colorFlag  -- ����ݡ��ͥ�Ȥξ��֤򼨤�ʸ����
00184                   select, unloaded, inactive, active, error, virtual
00185 
00186     [�����]
00187     void
00188     """
00189     if colorFlag == 'select':
00190         shape.SetBrush(wx.Brush(wx.NamedColor(SELECTED_COLOR)))
00191     elif colorFlag == 'unloaded':
00192         shape.SetBrush(wx.Brush(wx.NamedColor(UNLOADED_COLOR)))
00193     elif colorFlag == 'inactive':
00194         shape.SetBrush(wx.Brush(wx.NamedColor(INACTIVE_COLOR)))
00195     elif colorFlag == 'active':
00196         shape.SetBrush(wx.Brush(wx.NamedColor(ACTIVE_COLOR)))
00197     elif colorFlag == 'error':
00198         shape.SetBrush(wx.Brush(wx.NamedColor(ERROR_COLOR)))
00199     elif colorFlag == 'virtual':
00200         shape.SetBrush(wx.Brush(wx.NamedColor(VIRTUAL_COLOR)))
00201     else:
00202         shape.SetBrush(wx.Brush(colorFlag))
00203 
00204     shape.Flash()
00205 
00206 #----------------------------------------------------------------------
00207 class makeCompositeShape(ogl.CompositeShape):
00208     """CompositeShape�Υ�åѡ����饹"""
00209     def __init__(self, parent):
00210         """���饹�ν������CompositeShape�κ�����
00211 
00212         [����]
00213         parent -- �ƥ��饹�����
00214 
00215         [�����]
00216         void
00217         """
00218         ogl.CompositeShape.__init__(self)
00219         self.parent = parent
00220 
00221 #----------------------------------------------------------------------
00222 class makeLineShape(ogl.LineShape):
00223     """�����֤��������褹���åѡ����饹"""
00224     def __init__(self, parent, canvas ):
00225         """���饹�ν������LineShape�κ�����
00226 
00227         [����]
00228         parent -- �ƥ��饹�����
00229         canvas -- ShapeCanvas���֥������Ȥ���ꡣ
00230 
00231         [�����]
00232         void
00233         """
00234         ogl.LineShape.__init__(self)
00235         self.parent = parent
00236         self.SetCanvas(canvas)
00237         self.SetPen(wx.Pen(wx.BLUE, 1))
00238         setBodyColor(self, 'inactive')
00239         self.MakeLineControlPoints(2)
00240         diagram = canvas.GetDiagram()
00241         diagram.AddShape(self)
00242 
00243     def setPoints(self, startX,startY, endX, endY):
00244         """���ϡ���λ��ɸ����ꤷ�����������
00245 
00246         [����]
00247         startX -- �������賫�Ϥ������ɸ
00248         startY -- �������賫�Ϥ������ɸ
00249         endX   -- �������轪λ�������ɸ
00250         endY   -- �������轪λ�������ɸ
00251 
00252         [�����]
00253         void
00254         """
00255         self.SetEnds(startX, startY, endX, endY)
00256 
00257 #----------------------------------------------------------------------
00258 class makeRectangle(ogl.RectangleShape):
00259     """�ͳѷ������褹���åѡ����饹"""
00260     def __init__(self, parent, width, height):
00261         """���饹�ν������Rectangle������
00262 
00263         [����]
00264         parent -- �ƥ��饹�����
00265         width  -- �ͳѷ�����
00266         height -- �ͳѷ��ι⤵
00267 
00268         [�����]
00269         void
00270         """
00271         ogl.RectangleShape.__init__(self,width, height)
00272         self.parent = parent
00273         # lastx,lasty �ϡ����٥�ȡʰ�ư���������˸�κ�ɸ���Ǽ����ư�̤������Ψ�ǻ���
00274         self.lastx = 0
00275         self.lasty = 0
00276 
00277 #----------------------------------------------------------------------
00278 class makeInportPolygon(ogl.PolygonShape):
00279     """����ݡ��ȿ޷�(polygon)�����ѥ��饹"""
00280     def __init__(self, parent, points):
00281         """���饹�ν����(PolygonShape�κ�����
00282 
00283         [����]
00284         parent -- �ƥ��饹�����
00285         points -- ���ץ��Ϣ³����(x,��)��ɸ(wxPoints���ˤ����
00286 
00287         [�����]
00288         void
00289         """
00290         ogl.PolygonShape.__init__(self)
00291         self.parent = parent
00292 
00293         self.Create(points)
00294         self.CalculatePolygonCentre()
00295 
00296     def updateInportPolygon(self, points):
00297         """����ݡ��ȿ޷�(polygon)�κ�����ʺ�ɸ�ƻ����
00298 
00299         [����]
00300         points -- ���ץ��Ϣ³����(x,��)��ɸ(wxPoints���ˤ����
00301 
00302         [�����]
00303         void
00304         """
00305         self.Create(points)
00306         self.UpdateOriginalPoints()
00307         self.CalculatePolygonCentre()
00308 
00309 #----------------------------------------------------------------------
00310 class makeOutportPolygon(ogl.PolygonShape):
00311     """�����ȥݡ��ȿ޷�(polygon)�����ѥ��饹"""
00312     def __init__(self, parent, points):
00313         """���饹�ν����(PolygonShape�κ�����
00314 
00315         [����]
00316         parent -- �ƥ��饹�����
00317         points -- ���ץ��Ϣ³����(x,��)��ɸ(wxPoints���ˤ����
00318 
00319         [�����]
00320         void
00321         """
00322         ogl.PolygonShape.__init__(self)
00323         self.parent = parent
00324 
00325         self.Create(points)
00326         self.CalculatePolygonCentre()
00327 
00328     def updateOutportPolygon(self, points):
00329         """�����ȥݡ��ȿ޷�(polygon)�κ�����ʺ�ɸ�ƻ����
00330 
00331         [����]
00332         points -- ���ץ��Ϣ³����(x,��)��ɸ(wxPoints���ˤ����
00333 
00334         [�����]
00335         void
00336         """
00337         self.Create(points)
00338         self.UpdateOriginalPoints()
00339         self.CalculatePolygonCentre()
00340 
00341 #----------------------------------------------------------------------
00342 class makeRectOval(ogl.EllipseShape):
00343     """�ʱ߿޷����������륯�饹"""
00344     def __init__(self, parent, pos_x, pos_y, width, height):
00345         """���饹�ν����(EllipseShape�κ�����
00346 
00347         [����]
00348         parent -- �ƥ��饹�����
00349         pos_x  -- ���褹�����ɸ
00350         pos_y  -- ���褹�����ɸ
00351         width  -- �ʱߤ���
00352         height -- �ʱߤι⤵
00353 
00354         [�����]
00355         void
00356         """
00357         ogl.EllipseShape.__init__(self, width, height)
00358         self.parent = parent
00359         self.pos_x = pos_x
00360         self.pos_y = pos_y
00361         self.lastx = pos_x
00362         self.lasty = pos_y
00363         self.SetX(pos_x)
00364         self.SetY(pos_y)
00365         self.SetPen(wx.Pen(wx.BLACK, 1))
00366         self.SetBrush(wx.Brush('red'))
00367 
00368 #----------------------------------------------------------------------
00369 class makeTextShape(ogl.TextShape):
00370     """�ƥ����Ȥ��������륯�饹"""
00371     def __init__(self, parent, width, height):
00372         """���饹�ν������TextShape�κ�����
00373 
00374         [����]
00375         parent -- �ƥ��饹����ꤹ��
00376         width  -- �ƥ��������襨�ꥢ����
00377         height -- �ƥ��������襨�ꥢ�ι⤵
00378 
00379         [�����]
00380         void
00381         """
00382         ogl.TextShape.__init__(self,width, height)
00383         self.parent = parent
00384 
00385 #----------------------------------------------------------------------
00386 class makeToolTip(ogl.Shape):
00387     """�ġ�����åסʥХ롼��إ�ס˿޷����������륯�饹"""
00388     def __init__(self,parent,pt,dc):
00389         """���饹�ν�����ʥġ�����åפκ�����
00390 
00391         [����]
00392         parent -- �ƥ��饹����ꤹ��
00393         pt     -- �ġ�����åפ�ɽ�������ɸ��x,y�ˤΥ��ץ�ǻ���
00394         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00395 
00396         [�����]
00397         void
00398         """
00399         self.parent = parent
00400         self.body = None
00401         self.x_size = 0
00402         self.y_size = 0
00403         self.color = BACK_COLOR
00404 
00405         # ɽ��ʸ���������
00406         if parent.tag == 'in':
00407             string1 = parent.inport['name']
00408             string2 = parent.inport['port_type']
00409         else:
00410             string1 = parent.outport['name']
00411             string2 = parent.outport['port_type']
00412         atr = '%s\n%s'%(string1, string2)
00413 
00414         tmp = max(len(string1), len(string2))
00415         # �����ȤΥե���ȥ�����������Width��ʿ���ͤʤΤ�����
00416         charW = dc.GetCharWidth()
00417         charH = dc.GetCharHeight()
00418         self.x_size = charW * tmp 
00419         self.y_size = charH * 2.5
00420         # Rectangle��ʸ�����ɽ�������ġ�����åפ����ѤȤ���
00421         self.body = makeRectangle(self, self.x_size, self.y_size)
00422         self.body.AddText(atr)
00423 #        self.body.SetFormatMode(ogl.FORMAT_NONE,0)
00424         self.body.FormatText(dc,atr,0)
00425         self.body.SetDraggable(False, False)
00426         # ɽ�����֤ϡ��ͳѷ��κ�����ĺ����ޥ�����������ΰ��֤�����
00427         self.body.SetX(pt[0]+self.x_size/2)
00428         self.body.SetY(pt[1]-self.y_size/2)
00429         self.body.SetPen(wx.Pen(wx.RED, 1))
00430         self.body.SetBrush(wx.Brush(wx.NamedColor(BACK_COLOR)))
00431 
00432     def removeWidget(self,dc):
00433         """�ġ�����å׿޷��򥭥��Х���DC�夫����
00434 
00435         [����]
00436         dc     -- ���褵��Ƥ���ǥХ���������ƥ����Ȥ����
00437 
00438         [�����]
00439         void
00440         """
00441         canvas = self.body.GetCanvas()
00442         self.body.Erase(dc)
00443         self.body.RemoveFromCanvas(canvas)
00444 
00445 #----------------------------------------------------------------------
00446 class GRectOval(ogl.Shape):
00447     """���ΰ�ư�Ѥαߤ��������륯�饹"""
00448     def __init__(self,parent,tag,pos_x, pos_y):
00449         """���饹�ν�����ʱߤ������
00450 
00451         [����]
00452         parent -- �ƥ��饹����ꤹ��
00453         tag    -- ���̻ҡ�Ϣ��,���Ȥδط���ɽ���ե饰�ˤ����
00454                   ��Ϣ�֤ϡ������Ǽ���������ź������Ϣ�����Ƥ���
00455         pos_x  -- ɽ���������ɸ�����
00456         pos_y  -- ɽ���������ɸ�����
00457 
00458         [�����]
00459         void
00460         """
00461         self.parent = parent
00462         self.pos_x = pos_x
00463         self.pos_y = pos_y
00464         self.tag = tag
00465         self.createWidget()
00466 
00467     def createWidget(self):
00468         """�ߤ�����
00469 
00470         [����]
00471         �ʤ�
00472 
00473         [�����]
00474         void
00475         """
00476         self.body = makeRectOval(self, self.pos_x, self.pos_y, 8, 8)
00477 
00478     def removeWidget(self, dc):
00479         """�ߤ򥭥��Х���DC�夫����
00480 
00481         [����]
00482         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00483 
00484         [�����]
00485         void
00486         """
00487         canvas = self.body.GetCanvas()
00488         self.body.Erase(dc)
00489         self.body.RemoveFromCanvas(canvas)
00490 
00491     def dmove(self, dc, d_x, d_y):
00492         """�ߵڤ����ΰ�ư
00493 
00494         [����]
00495         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00496         d_x    -- ����ɸ�����а�ư�� (endPoint.x - startPoint.x ���͡�
00497         d_y    -- ����ɸ�����а�ư�� (endPoint.y - startPoint.y ���͡�
00498 
00499         [�����]
00500         void
00501         """
00502         canvas = self.body.GetCanvas()
00503 
00504         line = self.parent
00505         oval_tag = self.getTag()
00506         oval_id = oval_tag[0]
00507 
00508         # ��ư���ο޷���DC�夫����
00509         self.body.Erase(dc)
00510 
00511         # ��ư��κ�ɸ����
00512         if oval_tag[1] == 'oval_width_pos':
00513             self.pos_x = self.body.GetX() + d_x
00514             self.pos_y = self.body.GetY()
00515         else:
00516             self.pos_x = self.body.GetX()
00517             self.pos_y = self.body.GetY() + d_y
00518 
00519         # ��������ɸ�����κƺ���
00520         line.lines[oval_id].Move(dc, self.pos_x, self.pos_y)
00521         x1,y1,x2,y2 = line.lines[oval_id].GetEnds()
00522         line.changeCoordT(oval_id, (x1, y1), (x2, y2) )
00523 
00524         self.body.Move(dc, self.pos_x, self.pos_y)
00525 
00526         # �ߤΰ�ư�ʺ�ɸ�κƷ׻���
00527         for x in range(1,len(line.oval_dict)+1):
00528             tag = line.oval_dict[x].getTag()
00529             if oval_id != tag[0]:
00530                 line_pos_0 = line.coordT[x]
00531                 line_pos_1 = line.coordT[x+1]
00532 
00533                 if tag[1] == 'oval_width_pos':
00534                     hight = line_pos_0[1] - line_pos_1[1]
00535                     pos_y = line_pos_1[1] + (hight/2)
00536                     pos_x = line_pos_0[0]
00537                 else:
00538                     width = line_pos_0[0] - line_pos_1[0]
00539                     pos_x = line_pos_1[0] + (width/2)
00540                     pos_y = line_pos_1[1]
00541 
00542                 line.oval_dict[x].body.Move(dc, pos_x, pos_y)
00543 
00544     def getTag(self):
00545         """�������
00546 
00547         [����]
00548         �ʤ�
00549 
00550         [�����]
00551         tag    -- ���̻ҡ�Ϣ��,���Ȥδط���ɽ���ե饰�ˤ��ֵ�
00552                   ��Ϣ�֤ϡ������Ǽ���������ź������Ϣ�����Ƥ���
00553         """
00554         return self.tag
00555 
00556 #----------------------------------------------------------------------
00557 class GRtcLine(ogl.Shape):
00558     """�����������륯�饹"""
00559     def __init__(self, canvas, parent):
00560         """���饹�ν����
00561 
00562         [����]
00563         canvas -- ���褹�륭���Х������
00564         parent -- �ƥ��饹����ꤹ��
00565 
00566         [�����]
00567         void
00568         """
00569         self.canvas = canvas
00570         self.parent = parent
00571         self.startx = 0
00572         self.starty = 0
00573         self.endx = 0
00574         self.endy = 0
00575         self.coordT = None
00576         self.g_inp = None
00577         self.g_outp = None
00578         self.idx = 'L' + `canvas.line_idx`
00579         self.curOvalObj = None    # Value is setup GWorld.leftDown()
00580         self.oval_dict  = {}
00581         self.tag = 'line'
00582         self.lines = []
00583         self.subscription_type = RTM.OPS_NEW
00584         self.profile = None
00585 
00586     def refresh(self):
00587         """��ե�å������
00588         ���ڤӰ�ư�Ѥαߤ���������֤ˤ���
00589 
00590         [����]
00591         �ʤ�
00592 
00593         [�����]
00594         void
00595         """
00596         canvas = self.body.GetCanvas()
00597         dc = wx.ClientDC(canvas)
00598         canvas.PrepareDC(dc)
00599         self.unselected(dc)
00600 
00601     def remove(self, dc, canvas):
00602         """������Ӱ�ư�Ѥαߤ򥭥��Х���DC�夫��������
00603 
00604         [����]
00605         dc     -- ���褵��Ƥ���ǥХ���������ƥ����Ȥ����
00606         canvas -- ���褵��Ƥ��륭���Х������
00607 
00608         [�����]
00609         void
00610         """
00611         for x in range(len(self.lines)):
00612             self.lines[x].Unlink()
00613             self.lines[x].Erase(dc)
00614             self.lines[x].DeleteControlPoints()
00615             self.lines[x].RemoveFromCanvas(canvas)
00616 
00617         for x in range(len(self.oval_dict)):
00618             self.oval_dict[x+1].removeWidget(dc)
00619 
00620     def removeWidget(self, dc):
00621         """����
00622         ��Ϣ����Inport/Outport�ξ���(����unsubscribe)�ι���������ƤӽФ�
00623 
00624         [����]
00625         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00626 
00627         [�����]
00628         void
00629         """
00630         if self.g_inp:
00631             if len(self.g_inp.line_idx) == 1:
00632                 setBodyColor(self.g_inp.body, 'inactive')
00633         if self.g_outp:
00634             if len(self.g_outp.line_idx) == 1:
00635                 setBodyColor(self.g_outp.body, 'inactive')
00636         canvas = self.lines[0].GetCanvas()
00637         if self.g_outp != None:
00638             self.g_outp.disconnect(self.idx)
00639             self.g_outp = None
00640         if self.g_inp != None:
00641             self.g_inp.disconnect(self.idx)
00642             self.g_inp = None
00643         self.remove(dc, canvas)
00644 
00645 
00646     def createWidget(self):
00647         """��������
00648 
00649         [����]
00650         �ʤ�
00651 
00652         [�����]
00653         void
00654         """
00655         num = len(self.coordT)
00656         if num < 2:
00657             return
00658 
00659         if num == 2: # �����֤���
00660             self.lines.append(makeLineShape(self, self.canvas))
00661             self.lines[0].setPoints(self.startx, self.starty, self.endx, self.endy)
00662         else:        # ������ĺ�������İʾ��
00663             for cnt in range(num-1):
00664             
00665                 self.lines.append(makeLineShape(self, self.canvas))
00666                 self.lines[cnt].setPoints(self.coordT[cnt][0], self.coordT[cnt][1], self.coordT[cnt+1][0], self.coordT[cnt+1][1])
00667 
00668 
00669         # ���٥�ȳ���
00670         for x in range(len(self.lines)):
00671             setBodyColor(self.lines[x], 'inactive')
00672             evthandler2 = MyEvtHandlerLine()
00673             evthandler2.SetShape(self.lines[x])
00674             evthandler2.SetPreviousHandler(self.lines[x].GetEventHandler())
00675             self.lines[x].SetEventHandler(evthandler2)
00676 
00677     def setPoints(self, startX,startY, endX, endY):
00678         """���κ�ɸ����
00679 
00680         [����]
00681         startX -- ���賫�ϰ��֤Σ���ɸ
00682         startY -- ���賫�ϰ��֤Σ���ɸ
00683         endtX  -- ���轪λ���֤Σ���ɸ
00684         endtY  -- ���轪λ���֤Σ���ɸ
00685 
00686         [�����]
00687         void
00688         """
00689 
00690         lineUtil = lu.LineUtil(self, self.g_inp, self.g_outp, startX, startY, endX, endY)
00691         self.coordT = lineUtil.drawLine()
00692 
00693         self.startx = startX
00694         self.starty = startY
00695         self.endx = endX
00696         self.endy = endY
00697 
00698         self.createWidget()
00699 
00700 
00701     def setStartPoint(self, dc, movex,movey):
00702         """���γ������������ʳ������ΰ�ư��
00703 
00704         [����]
00705         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00706         movex  -- ����������ɸ�����а�ư��
00707         movey  -- ����������ɸ�����а�ư��
00708 
00709         [�����]
00710         void
00711         """
00712         canvas = self.lines[0].GetCanvas()
00713         # �޷��򥭥��Х���DC�夫����
00714         for x in range(len(self.lines)):
00715             self.lines[x].Erase(dc)
00716             self.lines[x].RemoveFromCanvas(canvas)
00717         for x in range(len(self.oval_dict)):
00718             self.oval_dict[x+1].removeWidget(dc)
00719 
00720         # ��ɸ������ꤷ��������
00721         self.lines = []
00722         self.startx = self.startx + movex
00723         self.starty = self.starty + movey
00724         self.setPoints(self.startx, self.starty, self.endx, self.endy)
00725         for x in range(len(self.lines)):
00726             self.lines[x].Show(True)
00727 
00728     def setEndPoint(self, dc, shape, movex,movey):
00729         """���ν�λ���������ʽ�λ���ΰ�ư��
00730 
00731         [����]
00732         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00733         movex  -- ��λ������ɸ�����а�ư��
00734         movey  -- ��λ������ɸ�����а�ư��
00735 
00736         [�����]
00737         void
00738         """
00739         canvas = self.lines[0].GetCanvas()
00740         # �޷��򥭥��Х���DC�夫����
00741         for x in range(len(self.lines)):
00742             self.lines[x].Erase(dc)
00743             self.lines[x].RemoveFromCanvas(canvas)
00744         for x in range(len(self.oval_dict)):
00745             self.oval_dict[x+1].removeWidget(dc)
00746 
00747         # ��ɸ������ꤷ��������
00748         self.lines = []
00749         self.endx = self.endx + movex
00750         self.endy = self.endy + movey
00751         self.setPoints(self.startx, self.starty, self.endx, self.endy)
00752         for x in range(len(self.lines)):
00753             self.lines[x].Show(True)
00754 
00755     def selected(self):
00756         """������������ʿ����ѹ���
00757 
00758         [����]
00759         �ʤ�
00760 
00761         [�����]
00762         void
00763         """
00764         for x in range(len(self.lines)):
00765             self.lines[x].SetBrush(wx.Brush(wx.NamedColor(SELECTED_COLOR)))
00766             self.lines[x].SetPen(wx.Pen(SELECTED_COLOR, 1))
00767             self.lines[x].Flash()
00768 
00769     def unselected(self,dc):
00770         """���������������ʿ����ѹ�����ư�Ѥαߤ�����
00771 
00772         [����]
00773         �ʤ�
00774 
00775         [�����]
00776         void
00777         """
00778         for x in range(len(self.lines)):
00779             self.lines[x].SetPen(wx.Pen(INACTIVE_COLOR, 1))
00780             self.lines[x].SetBrush(wx.Brush(wx.NamedColor(INACTIVE_COLOR)))
00781             self.lines[x].Flash()
00782         for x in range(len(self.oval_dict)):
00783             self.oval_dict[x+1].removeWidget(dc)
00784 
00785     def dmove(self, dc, movex, movey):
00786         """��ư�����Υ��ߡ��롼����
00787 
00788         [����]
00789         dc    -- DC�����
00790         movex -- ��ư�������е�Υ
00791         movey -- ��ư�������е�Υ
00792 
00793         [�����]
00794         void
00795         """
00796         pass
00797 
00798     def setLine2port(self, canvas, dc ):
00799         """��������
00800         ����������ĤΥݡ��Ȥ򤢤餫������ꤷ�ܥ᥽�åɤ�ƤӽФ���
00801         canvas.lineTo, canvas.lineFrom �˥ݡ��Ȥ����ꤷ�Ƥ�����
00802 
00803         [����]
00804         canvas -- �������褹�륭���Х������
00805         dc     -- �������褹��DC�����
00806 
00807         [�����]
00808         void
00809         """
00810         # ���֥������ȥ�ե���󥹤γ�ǧ
00811         ref = canvas.lineTo.parent.ns_dict.GetObjRefToFullpath(canvas.lineTo.parent.fullpath)
00812         if not ref:
00813             return
00814         if canvas.lineFrom.parent.tag == 'in':
00815             self.g_inp = canvas.lineFrom.parent
00816             self.g_outp = canvas.lineTo.parent
00817         else:
00818             self.g_inp = canvas.lineTo.parent
00819             self.g_outp = canvas.lineFrom.parent
00820         # ���������ȥ��٥�Ȥγ���
00821         self.setPoints(self.g_inp.body.GetX(), self.g_inp.body.GetY(), self.g_outp.body.GetX(), self.g_outp.body.GetY())
00822         for x in range(len(self.lines)):
00823             evthandler2 = MyEvtHandlerLine()
00824             evthandler2.SetShape(self.lines[x])
00825             evthandler2.SetPreviousHandler(self.lines[x].GetEventHandler())
00826             self.lines[x].SetEventHandler(evthandler2)
00827 
00828         # �����Х��إ饤�����Ͽ�ڤӥ饤�󥫥��󥿡��Υ��å�
00829         canvas.line[self.idx] = self
00830         self.g_inp.connect(self.idx)
00831         canvas.line_idx = canvas.line_idx + 1
00832         for x in range(len(self.lines)):
00833             self.lines[x].Show(True)
00834         # Inport/Outport �ο����ѹ�
00835         self.g_inp.body.Move(dc, self.g_inp.body.GetX(), self.g_inp.body.GetY())
00836         self.g_outp.body.Move(dc, self.g_outp.body.GetX(), self.g_outp.body.GetY())
00837         setBodyColor(self.g_inp.body, 'active')
00838         setBodyColor(self.g_outp.body, 'active')
00839 
00840     def changeCoordT(self, id, new_p1, new_p2):
00841         """����ư���˰�ư�������κ�ɸ�������
00842 
00843         [����]
00844         id     -- ��ɸ������ꤹ�볫�ϥ���ǥå�����ź������
00845         new_p1 -- ��������ɸ��x,y�ˤγ������򥿥ץ�ǻ���
00846         new_p2 -- ��������ɸ��x,y�ˤν�λ���򥿥ץ�ǻ���
00847 
00848         [�����]
00849         void
00850         """
00851         self.coordT[id] = new_p1
00852         self.coordT[id+1] = new_p2
00853 
00854         num = len(self.coordT)
00855         for cnt in range(num-1):
00856             self.lines[cnt].setPoints(self.coordT[cnt][0], self.coordT[cnt][1], self.coordT[cnt+1][0], self.coordT[cnt+1][1])
00857 
00858     def childMove(self, dc, pos_new):
00859         """���ΰ�ư
00860 
00861         [����]
00862         dc      -- ���褹��ǥХ���������ƥ����Ȥ����
00863         pos_new -- ��ư��κ�ɸ�ꥹ��
00864 
00865         [�����]
00866         void
00867         """
00868 #        canvas = self.body.GetCanvas()
00869 
00870         max_num = len(pos_new)
00871         if max_num <= 2:
00872             return
00873 
00874         self.coordT = pos_new
00875         for cnt in range(max_num-1):
00876             self.lines[cnt].setPoints(self.coordT[cnt][0], self.coordT[cnt][1], self.coordT[cnt+1][0], self.coordT[cnt+1][1])
00877 
00878 #----------------------------------------------------------------------
00879 class GRtcIn(ogl.Shape):
00880     """����ݡ��ȿ޷���������륯�饹"""
00881     def __init__(self, parent, ns_dict, fullpath, inp, pos_x, pos_y):
00882         """���饹�ν�����ʥ���ݡ��ȿ޷��κ�����
00883 
00884         [����]
00885         parent     -- �ƥ��饹����ꤹ��
00886         ns_data -- ����ݡ��ͥ�ȤΥǥ�������ʥ꡼
00887         inp        -- ����ݡ��ȤΥǥ�������ʥ꡼(in_list[n])
00888         pos_x      -- ����ݡ��ȿ޷��Σ���ɸ
00889         pos_y      -- ����ݡ��ȿ޷��Σ���ɸ
00890 
00891         [�����]
00892         void
00893         """
00894         ogl.Shape.__init__(self)
00895         self.parent = parent
00896         self.ns_dict = ns_dict
00897         self.fullpath = fullpath
00898         self.inport = inp
00899         self.x = pos_x
00900         self.y = pos_y
00901         self.x_size = POLYGON_SIZE
00902         self.y_size = POLYGON_SIZE
00903         self.line = []
00904         self.line_idx = []         # Lxx line index
00905         self.position = 'Left'     # current position on compornent widget Left/Right/Top/Bottom
00906         self.textwin = 'non'
00907         self.tag = 'in'
00908         self.points = []
00909         self.createWidget()
00910 
00911     def getConfig(self, name) :
00912         """x,y��ɸ�⤷����position���������
00913 
00914         [����]
00915         name -- �����������ͤΥե饰����ꤹ��
00916                 �ե饰��'x', 'y', 'position'
00917 
00918         [�����]
00919         void
00920         """
00921         if name == 'x' :
00922             return self.x      
00923         elif name == 'y' :
00924             return self.y  
00925         elif name == 'position' :
00926             return self.position  
00927         else :    
00928             return None
00929 
00930     def removeWidget(self, dc, rot=0):
00931         """����ݡ��ȿ޷��򥭥��Х���DC�夫��������
00932 
00933         [����]
00934         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00935         rot    -- ���κ�����ݤ���ꤹ�롣�ʲ�ž�������ǻ��ѡ�
00936                   0:������  /  1:���������ʤ�
00937 
00938         [�����]
00939         void
00940         """
00941         canvas = self.body.GetCanvas()
00942         self.body.Erase(dc)
00943         self.body.RemoveFromCanvas(canvas)
00944 
00945         # line
00946         if rot == 0:
00947             line_list = copy.deepcopy(self.line_idx)
00948             for idx in line_list:
00949                 canvas.line[idx].removeWidget(dc)
00950                 if idx in canvas.line.keys():
00951                     del canvas.line[idx]
00952             self.line_idx = []
00953 
00954     def createWidget(self):
00955         """����ݡ��ȿ޷�����������
00956 
00957         [����]
00958         �ʤ�
00959 
00960         [�����]
00961         void
00962         """
00963         self.color = INACTIVE_COLOR
00964         # ��ɸ������
00965         self.dcoords()
00966         # �޷�������
00967         self.body = makeInportPolygon(self, self.points)
00968         # ���٥�Ȥ�޷��γ���
00969         self.parent.parent.MyAddShape(
00970             self.body, self.x+POLYGON_SIZE/2-1, self.y+POLYGON_SIZE/2-1, wx.Pen(OUTLINE_COLOR, 1), wx.Brush(self.color, wx.SOLID), "" , 1)
00971 
00972     def dmove(self, dc, movex, movey):
00973         """����ݡ��ȿ޷��ΰ�ư
00974         ����ݡ��Ȥ˳���դ����Ƥ�������Ʊ���˰�ư������
00975 
00976         [����]
00977         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
00978         movex  -- ����ɸ�����а�ư�̤����
00979         movey  -- ����ɸ�����а�ư�̤����
00980 
00981         [�����]
00982         void
00983         """
00984         canvas = self.body.GetCanvas()
00985         canvas.PrepareDC(dc)
00986 
00987         self.body.Erase(dc)
00988         self.x = self.body.GetX() + movex
00989         self.y = self.body.GetY() + movey
00990         self.body.Move(dc, self.x, self.y)
00991 
00992         # line
00993         for line_index in self.line_idx:
00994             canvas.line[line_index].setStartPoint(dc, movex, movey)
00995 
00996     def delLineIdx(self,idx):
00997         """����ݡ��Ȥ˳���դ������Υ���ǥå�����������
00998 
00999         [����]
01000         idx   -- ���Υ���ǥå���
01001 
01002         [�����]
01003         void
01004         """
01005         if idx in self.line_idx:
01006             tmp = self.line_idx.index(idx)
01007             del self.line_idx[tmp]
01008 
01009     def selected(self):
01010         """����ݡ��Ȥ�������֤ˤ���
01011 
01012         [����]
01013         �ʤ�
01014 
01015         [�����]
01016         void
01017         """
01018         self.body.SetBrush(wx.Brush(wx.NamedColor(SELECTED_COLOR)))
01019         self.body.Flash()
01020 
01021     def unselected(self,dc):
01022         """����ݡ��Ȥ���������֤ˤ���
01023 
01024         [����]
01025         �ʤ�
01026 
01027         [�����]
01028         void
01029         """
01030         self.body.SetBrush(wx.Brush(wx.NamedColor(self.color)))
01031         self.body.Flash()
01032 
01033     def updatePolygonSize(self, x, y, ratioW, ratioH):
01034         """����ݡ��ȿ޷��Υ������ѹ�
01035 
01036         [����]
01037         x      -- �������ѹ���Σ���ɸ�����
01038         y      -- �������ѹ���Σ���ɸ�����
01039         ratioW -- �������ѹ���Ԥ�Width�Υ�������Ψ
01040         ratioH -- �������ѹ���Ԥ�Height�Υ�������Ψ
01041 
01042         [�����]
01043         void
01044         """
01045         movex = x - self.body.GetX()
01046         movey = y - self.body.GetY()
01047         self.x = x
01048         self.y = y
01049         # �޷���ž���width,height�������ؤ���
01050         if self.parent.xy_swap == 1:
01051             self.y_size, self.x_size = self.body.GetBoundingBoxMin()
01052             self.parent.py_size, self.parent.px_size = self.parent.px_size, self.parent.py_size
01053         else:
01054             self.x_size, self.y_size = self.body.GetBoundingBoxMin()
01055 
01056         # �ݥꥴ�󥵥����κƷ׻�
01057         self.parent.px_size = self.x_size
01058         self.parent.py_size = self.y_size
01059         canvas = self.body.GetCanvas()
01060         dc = wx.ClientDC(canvas)
01061         canvas.PrepareDC(dc)
01062         brush = self.body.GetBrush()
01063         # �޷��򥭥��Х���DC�夫��������
01064         self.body.Erase(dc)
01065         self.body.RemoveFromCanvas(canvas)
01066         # ��ɸ�κ�����
01067         self.dcoords()
01068         self.body.updateInportPolygon(self.points)
01069         # �������޷��˥��٥�Ȥ����
01070         self.parent.parent.MyAddShape(
01071             self.body, self.x , self.y,
01072             wx.Pen(OUTLINE_COLOR, 1), brush, "" , 1)
01073 
01074         # ���������ʥ���ݡ��Ȥΰ��֤˹�碌��ư��
01075         for line_index in self.line_idx:
01076             canvas.line[line_index].setStartPoint(dc, movex, movey)
01077 
01078     def connect(self, line_idx):
01079         """���ͥ��Ƚ���(���Υ���ǥå������Ǽ��
01080 
01081         [����]
01082         line_idx   -- ����ݡ��Ȥ���³�������Υ���ǥå���
01083 
01084         [�����]
01085         ���ݥե饰 -- 0:���顼(���֥������ȥ�ե����̵���� / 1:����
01086         """
01087         ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
01088         if not ref:
01089             return 0
01090         else:
01091             self.line_idx.append(line_idx)
01092             return 1
01093 
01094     def disconnect(self, line_idx):
01095         """�ǥ������ͥ��Ƚ���(���Υ���ǥå���������
01096 
01097         [����]
01098         line_idx   -- ����ݡ��Ȥ���³���Ƥ������Υ���ǥå���
01099 
01100         [�����]
01101         ���ݥե饰 -- 0:���顼 / 1:����
01102         """
01103         if line_idx in self.line_idx:
01104             self.delLineIdx(line_idx)
01105             return 1
01106         else:
01107             return 0
01108 
01109     def dcoords(self):
01110         """����ݡ��ȿ޷��κ�ɸ����
01111         ���ߤ�position�򸫤ƿ޷��θ�������ꤹ��
01112         ��ĺ����(x,y)�Υ��ץ����
01113 
01114         [����]
01115         �ʤ�
01116 
01117         [�����]
01118         void
01119         """
01120         if self.position == 'Left':
01121             self.points = [ (self.x + self.x_size/2-1, self.y + self.y_size/2),
01122                             (self.x,  self.y),
01123                             (self.x + self.x_size ,    self.y),
01124                             (self.x + self.x_size ,    self.y + self.y_size ),
01125                             (self.x ,    self.y + self.y_size ),
01126                             (self.x + self.x_size/2-1,    self.y + self.y_size/2)
01127                           ]
01128         elif self.position == 'Right' :
01129             self.points = [ (self.x+self.x_size/2+1, self.y+self.y_size/2),
01130                             (self.x+self.x_size, self.y+self.y_size),
01131                             (self.x, self.y+self.y_size),
01132                             (self.x, self.y),
01133                             (self.x+self.x_size, self.y),
01134                             (self.x+self.x_size/2+1, self.y+self.y_size/2)
01135                           ]
01136         elif self.position == 'Top' :
01137             self.points = [ (self.x+self.x_size/2, self.y+self.y_size/2-1),
01138                             (self.x+self.x_size, self.y),
01139                             (self.x+self.x_size, self.y+self.y_size),
01140                             (self.x, self.y+self.y_size),
01141                             (self.x, self.y),
01142                             (self.x+self.x_size/2, self.y+self.y_size/2-1)
01143                           ]
01144         elif self.position == 'Bottom' :    
01145             self.points = [ (self.x+self.x_size/2, self.y+self.y_size/2+1),
01146                             (self.x, self.y+self.y_size),
01147                             (self.x, self.y),
01148                             (self.x+self.x_size, self.y),
01149                             (self.x+self.x_size, self.y+self.y_size),
01150                             (self.x+self.x_size/2, self.y+self.y_size/2+1)
01151                           ]
01152 
01153 #----------------------------------------------------------------------
01154 class GRtcOut(ogl.Shape):
01155     """�����ȥݡ��ȿ޷���������륯�饹"""
01156     def __init__(self, parent, ns_dict, fullpath, outp, pos_x, pos_y) :
01157         """���饹�ν�����ʥ����ȥݡ��ȿ޷��κ�����
01158 
01159         [����]
01160         parent     -- �ƥ��饹����ꤹ��
01161         ns_data -- ����ݡ��ͥ�ȤΥǥ�������ʥ꡼
01162         inp        -- ����ݡ��ȤΥǥ�������ʥ꡼(in_list[n])
01163         pos_x      -- ����ݡ��ȿ޷��Σ���ɸ
01164         pos_y      -- ����ݡ��ȿ޷��Σ���ɸ
01165 
01166         [�����]
01167         void
01168         """
01169         ogl.Shape.__init__(self)
01170         self.parent = parent
01171         self.ns_dict = ns_dict
01172         self.fullpath = fullpath
01173         self.outport = outp
01174         self.x = pos_x
01175         self.y = pos_y
01176         self.x_size = POLYGON_SIZE
01177         self.y_size = POLYGON_SIZE
01178         self.line = []
01179         self.line_idx = []         # Lxx line index
01180         self.position = 'Right'     # current position on compornent widget Left/Right/Top/Bottom
01181         self.textwin = 'non'
01182         self.isInactive = 0
01183         self.tag = 'out'
01184         self.uuid = {}
01185         self.subscription_type = RTM.OPS_NEW
01186         self.createWidget()
01187 
01188     def refresh(self):
01189         """��ե�å������
01190         ���ߤ���³������Inport�Υ��֥������ȥ�ե���󥹤�¸�ߤ��뤫���ˤ�
01191         �����å�������³���֤��³�⤷����unsubscribe��¹Ԥ���
01192 
01193         [����]
01194         �ʤ�
01195 
01196         [�����]
01197         void
01198         """
01199         canvas = self.body.GetCanvas()
01200         if canvas.viewMode == True:
01201             return
01202 
01203         dc = wx.ClientDC(canvas)
01204         canvas.PrepareDC(dc)
01205         for idx in self.line_idx:
01206             # for line 
01207             try:
01208                 # g_inp update
01209                 # state get ??
01210                 for inp in self.parent.in_list :
01211                     if inp['name'] == canvas.line[idx].g_inp.inport['name']:
01212                         canvas.line[idx].g_inp.inport = inp
01213                         break
01214 
01215                 ref = canvas.line[idx].g_inp.inport['ref']
01216                 ref = ref._narrow(RTM.InPort)
01217             except :
01218                 except_mess('inport object-ref failure:%s\n'%inp['name'])
01219                 setBodyColor(canvas.line[idx].g_inp.body, 'inactive')
01220                 try :  
01221                     ref = self.outport['ref']
01222                     ref = ref._narrow(RTM.OutPort)
01223                     rslt = ref.unsubscribe(self.uuid[idx])
01224                     print "refresh:unsubscribe:",rslt
01225                     if rslt != 0:
01226                         print 'unsubscribe failure: rslt=',rslt
01227                 except :
01228                     except_mess('unsubscribe failure:')
01229 
01230     def getConfig(self, name) :
01231         """x,y��ɸ�⤷����position���������
01232 
01233         [����]
01234         name -- �����������ͤΥե饰����ꤹ��
01235                 �ե饰��'x', 'y', 'position'
01236 
01237         [�����]
01238         void
01239         """
01240         if name == 'x' :
01241             return self.x      
01242         elif name == 'y' :
01243             return self.y  
01244         elif name == 'position' :
01245             return self.position  
01246         else :    
01247             return None
01248 
01249     def removeWidget(self, dc, rot=0):
01250         """�����ȥݡ��ȿ޷���������
01251 
01252         [����]
01253         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
01254         rot    -- ���κ�����ݤ���ꤹ�롣�ʲ�ž�������ǻ��ѡ�
01255                   0:������  /  1:���������ʤ�
01256 
01257         [�����]
01258         void
01259         """
01260         canvas = self.body.GetCanvas()
01261         self.body.Erase(dc)
01262         self.body.RemoveFromCanvas(canvas)
01263 
01264         # line
01265         if rot == 0:
01266             line_list = copy.deepcopy(self.line_idx)
01267             for idx in line_list:
01268                 canvas.line[idx].removeWidget(dc)
01269                 if idx in canvas.line.keys():
01270                     del canvas.line[idx]
01271             self.line_idx = []
01272 
01273     def createWidget(self):
01274         """�����ȥݡ��ȿ޷����������
01275 
01276         [����]
01277         �ʤ�
01278 
01279         [�����]
01280         void
01281         """
01282         self.color = INACTIVE_COLOR
01283         # ��ɸ������
01284         self.dcoords()
01285         # �޷�������
01286         self.body = makeOutportPolygon(self, self.points)
01287         # ���٥�Ȥ�޷��γ���
01288         self.parent.parent.MyAddShape(
01289             self.body, self.x+POLYGON_SIZE/2-1, self.y+POLYGON_SIZE/2-1, wx.Pen(OUTLINE_COLOR, 1), wx.Brush(self.color, wx.SOLID), "",1)
01290 
01291     def dmove(self, dc, movex, movey):
01292         """�����ȥݡ��ȿ޷��ΰ�ư
01293         �����ȥݡ��Ȥ˳���դ����Ƥ�������Ʊ���˰�ư������
01294 
01295         [����]
01296         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
01297         movex  -- ����ɸ�����а�ư�̤����
01298         movey  -- ����ɸ�����а�ư�̤����
01299 
01300         [�����]
01301         void
01302         """
01303         canvas = self.body.GetCanvas()
01304         canvas.PrepareDC(dc)
01305 
01306         self.x = self.body.GetX() + movex
01307         self.y = self.body.GetY() + movey
01308         self.body.Erase(dc)
01309         self.body.Move(dc, self.x, self.y)
01310 
01311         # line
01312         num = 0
01313         for line_index in self.line_idx:
01314             canvas.line[line_index].setEndPoint(dc, self.body,movex, movey)
01315             num = num+1
01316 
01317     def delLineIdx(self, idx):
01318         """�����ȥݡ��Ȥ˳���դ������Υ���ǥå�����������
01319 
01320         [����]
01321         idx    -- ���Υ���ǥå���
01322 
01323         [�����]
01324         void
01325         """
01326         if idx in self.line_idx:
01327             tmp = self.line_idx.index(idx)
01328             del self.line_idx[tmp]
01329 
01330     def selected(self):
01331         """�����ȥݡ��Ȥ�������֤ˤ���
01332 
01333         [����]
01334         �ʤ�
01335 
01336         [�����]
01337         void
01338         """
01339         self.body.SetBrush(wx.Brush(wx.NamedColor(SELECTED_COLOR)))
01340         self.body.Flash()
01341 
01342     def unselected(self,dc):
01343         """�����ȥݡ��Ȥ���������֤ˤ���
01344 
01345         [����]
01346         �ʤ�
01347 
01348         [�����]
01349         void
01350         """
01351         self.body.SetBrush(wx.Brush(wx.NamedColor(self.color)))
01352         self.body.Flash()
01353 
01354     def updatePolygonSize(self, x, y, ratioW, ratioH):
01355         """�����ȥݡ��ȿ޷��Υ������ѹ�
01356 
01357         [����]
01358         x      -- �������ѹ���Σ���ɸ�����
01359         y      -- �������ѹ���Σ���ɸ�����
01360         ratioW -- �ѹ���Ԥ�Width�Υ�������Ψ
01361         ratioH -- �ѹ���Ԥ�Height�Υ�������Ψ
01362 
01363         [�����]
01364         void
01365         """
01366         movex =  x - self.body.GetX()
01367         movey =  y - self.body.GetY()
01368         self.x = x
01369         self.y = y
01370         # �޷���ž���width,height�������ؤ���
01371         if self.parent.xy_swap == 1:
01372             self.y_size, self.x_size = self.body.GetBoundingBoxMin()
01373             self.parent.py_size, self.parent.px_size = self.parent.px_size, self.parent.py_size
01374         else:
01375             self.x_size, self.y_size = self.body.GetBoundingBoxMin()
01376         # �ݥꥴ�󥵥����κƷ׻�
01377         self.parent.px_size = self.x_size
01378         self.parent.py_size = self.y_size
01379         canvas = self.body.GetCanvas()
01380         dc = wx.ClientDC(canvas)
01381         canvas.PrepareDC(dc)
01382         brush = self.body.GetBrush()
01383         # �޷��򥭥��Х���DC�夫��������
01384         self.body.Erase(dc)
01385         self.body.RemoveFromCanvas(canvas)
01386         # ��ɸ�κ�����
01387         self.dcoords()
01388         self.body.updateOutportPolygon(self.points)
01389         # �������޷��˥��٥�Ȥ����
01390         self.parent.parent.MyAddShape(
01391             self.body, self.x , self.y,
01392             wx.Pen(OUTLINE_COLOR, 1), brush, "" , 1)
01393 
01394         # ���������ʥ����ȥݡ��Ȥΰ��֤˹�碌��ư��
01395         for line_index in self.line_idx:
01396             canvas.line[line_index].setEndPoint(dc, self.body,movex, movey)
01397 
01398     def connect2(self, line_idx, subscription_type):
01399         """���ͥ��Ƚ���(subscribe��ȯ�ԡ�
01400 
01401         [����]
01402         line_idx   -- ����ݡ��Ȥ���³�������Υ���ǥå���
01403         subscription_type -- ���֥�����ץ���󡦥����פ����ʸ���̤���ѡ�
01404 
01405         [�����]
01406         ���ݥե饰 -- 0:���顼(���֥������ȥ�ե����̵��,subscribe���ԡ� / 1:����
01407         """
01408         canvas = self.body.GetCanvas()
01409 
01410         # get outport-object-ref
01411         ref = self.outport['ref']
01412         if ref == None :
01413             return 0  
01414         try:
01415             ref = ref._narrow(RTM.OutPort)
01416         except:
01417             except_mess('outport obj-ref failure:')
01418             return 0
01419 
01420         # get inport-object-ref
01421         inp_ref = canvas.line[line_idx].g_inp.inport['ref']
01422         try:
01423             inp_ref = inp_ref._narrow(RTM.InPort)
01424         except:
01425             except_mess('inport obj-ref failure:')
01426             return 0
01427 
01428         # get subscription-list
01429         subscription_list = []
01430         try:
01431             subscription_list = ref._get_subscriptions()
01432             if subscription_list == None:
01433                 print "get subscriptions failure: return value is None."
01434                 return 0
01435         except:
01436             except_mess('get subscriptions failure:')
01437             return 0
01438 
01439         connect_num = self.checkConnect(inp_ref, subscription_list)
01440 
01441         if canvas.viewMode == False:
01442             if connect_num == -1:
01443                 try:
01444                     canvas.line[line_idx].subscription_type = subscription_type
01445                     canvas.line[line_idx].profile = RTM.SubscriptionProfile(subscription_type,"",None,None,False,[])
01446                     canvas.line[line_idx].profile.out_port = ref
01447                     canvas.line[line_idx].profile.in_port = inp_ref
01448                     rslt, canvas.line[line_idx].profile = ref.subscribe(canvas.line[line_idx].profile)
01449                     self.uuid[line_idx] = canvas.line[line_idx].profile.id
01450 
01451                     if rslt != 0:
01452                         print "subscribe failure!"
01453                 except:
01454                     except_mess('subscribe failure:')
01455                 print "connect2 subscribe :",self.uuid[line_idx]
01456             else:
01457                 rslt = 0
01458                 # get uuid
01459                 self.uuid[line_idx] = subscription_list[connect_num].id
01460         return 1
01461 
01462     def connect(self, line_idx, subscription_type):
01463         """���ͥ��Ƚ���(���Υ���ǥå������Ǽ��subscribe��ȯ�ԡ�
01464 
01465         [����]
01466         line_idx   -- ����ݡ��Ȥ���³�������Υ���ǥå���
01467         subscription_type -- ���֥�����ץ���󡦥����פ����ʸ���̤���ѡ�
01468 
01469         [�����]
01470         ���ݥե饰 -- 0:���顼(���֥������ȥ�ե����̵��,subscribe���ԡ� / 1:����
01471         """
01472         canvas = self.body.GetCanvas()
01473         n = 0
01474         for n in range(2):    # for retry
01475             try:
01476                 ref = self.outport['ref']
01477                 if ref == None :
01478                     return 0  
01479                 ref = ref._narrow(RTM.OutPort)
01480                 break
01481             except:
01482                 except_mess('outport obj-ref failure:')
01483                 self.parent.refresh()
01484         if n == 2:
01485             print "error retry"
01486             return 0
01487 
01488 
01489         inp_ref = canvas.line[line_idx].g_inp.inport['ref']
01490         try:
01491             inp_ref = inp_ref._narrow(RTM.InPort)
01492         except:
01493             except_mess('inport obj-ref failure:')
01494             return 0
01495 
01496         # get subscription-list
01497         subscription_list = []
01498         try:
01499             subscription_list = ref._get_subscriptions()
01500             if subscription_list == None:
01501                 print "get subscriptions failure: return value is None."
01502                 return 0
01503         except:
01504             except_mess('get subscriptions failure:')
01505             return 0
01506 
01507         canvas.line[line_idx].subscription_type = subscription_type
01508         canvas.line[line_idx].profile = RTM.SubscriptionProfile(subscription_type,"",None,None,False,[])
01509 
01510 
01511         connect_num = self.checkConnect(inp_ref, subscription_list)
01512 #assembly dummy
01513 #        connect_num = -1
01514 #assembly dummy
01515 
01516         rslt = 0
01517         if canvas.viewMode == False:
01518             if connect_num == -1:
01519                 try:
01520                     canvas.line[line_idx].profile.out_port = ref
01521                     canvas.line[line_idx].profile.in_port = inp_ref
01522                     (rslt, canvas.line[line_idx].profile) = ref.subscribe(canvas.line[line_idx].profile)
01523                     if rslt != 0:
01524                         print "subscribe failuer! :rslt=",rslt
01525                     self.uuid[line_idx] = canvas.line[line_idx].profile.id
01526                     print "connect subscribe :",self.uuid[line_idx]
01527                 except:
01528                     err_mess =  'subscribe failure! :'
01529                     except_mess(err_mess)
01530             else:
01531                 rslt = 0
01532                 # get uuid
01533                 self.uuid[line_idx] = subscription_list[connect_num].id
01534 
01535         if rslt :
01536             print "subsrcibe-rslt:",rslt
01537             return 0
01538         else :
01539             self.line_idx.append(line_idx)
01540             self.isInactive = self.isInactive + 1
01541             return 1
01542 
01543     def disconnect(self, line_idx):
01544         """�ǥ������ͥ��Ƚ���(���Υ���ǥå���������unsubscribe��ȯ�ԡ�
01545 
01546         [����]
01547         line_idx   -- �����ȥݡ��Ȥ���³���Ƥ������Υ���ǥå���
01548 
01549         [�����]
01550         ���ݥե饰 -- 0:���顼 / 1:����
01551         """
01552         if self.isInactive == 1 :
01553             setBodyColor(self.body, 'inactive')
01554 
01555         canvas = self.body.GetCanvas()
01556 
01557         n = 0
01558         for n in range(2):    # for retry
01559             ref = self.outport['ref']
01560             try:
01561                 ref = ref._narrow(RTM.OutPort)
01562 
01563                 inp_obj = canvas.line[line_idx].g_inp.inport['ref']
01564 
01565                 # get subscription-list
01566                 subscription_list = []
01567                 subscription_list = ref._get_subscriptions()
01568                 if subscription_list == None:
01569                     print "get subscriptions failure: return value is None."
01570                     return 0
01571 
01572                 connect_num = self.checkConnect(inp_obj, subscription_list)
01573 #assembly dummy
01574 #                connect_num = 0
01575 #assembly dummy
01576                 break
01577             except:
01578                 err_mess =  'outport disconnect failure:'
01579                 except_mess(err_mess)
01580                 connect_num = -1
01581                 self.parent.refresh()
01582 
01583         if n == 2: # bad connect
01584             return 0
01585 
01586         if ref != None and canvas.viewMode == False and connect_num != -1:
01587             try :
01588                 print "unsubscribe :",self.uuid[line_idx]
01589                 rslt = ref.unsubscribe(self.uuid[line_idx])
01590                 if rslt != 0:
01591                     print 'unsubscribe failure: rslt=',rslt
01592             except :
01593                 err_mess = 'unsubscribe failure:'
01594                 except_mess(err_mess)
01595 
01596         self.isInactive = self.isInactive - 1
01597 
01598         if line_idx in self.line_idx:
01599             self.delLineIdx(line_idx)
01600             return 1
01601         else :
01602             return 0
01603 
01604     def remakeLines(self):
01605         """����³����
01606         ���֥������Ⱦ������¸�ߤ�����³����(subscribe)�򸡺����������
01607 
01608         [����]
01609         �ʤ�
01610 
01611         [�����]
01612         void
01613         """
01614 # assembly dummy process
01615 #        return
01616 # assembly dummy process
01617 
01618         canvas = self.body.GetCanvas()
01619         dc = wx.ClientDC(canvas)
01620         canvas.PrepareDC(dc)
01621 
01622         ref = self.outport['ref']
01623         try:
01624             ref = ref._narrow(RTM.OutPort)
01625         except:
01626             err_mess =  'outport obj-ref failure:'
01627             except_mess(err_mess)
01628             return
01629 
01630         # get subscription-list
01631         subscription_list = []
01632         subscr_list_tmp = []
01633         try:
01634             subscription_list = ref._get_subscriptions()
01635             subscr_list_tmp = copy.deepcopy(subscription_list)
01636             if subscription_list == None:
01637                 print "get subscriptions failure: return value is None."
01638                 return
01639         except:
01640             except_mess('get subscriptions failure:')
01641             return
01642 
01643         for line_idx in self.line_idx:
01644             line = canvas.line[line_idx]
01645             (ret2,subscr_list_tmp) = self.checkConnect2(line,subscr_list_tmp)
01646 
01647         rtc_list = self.parent.parent.rtc_list
01648         rtc_dict = self.parent.parent.rtc_dict
01649         ret_name = []
01650         ret_obj = []
01651         ret_ref = []
01652 
01653         for subscr in subscr_list_tmp:
01654             inp_ref = subscr.in_port
01655             for fullname in rtc_list:
01656                 in_list = rtc_dict[fullname].in_list
01657                 in_dict = rtc_dict[fullname].in_dict
01658 
01659                 for inp in in_list:
01660                     if inp['name'] in in_dict.keys():
01661                         ref = in_dict[inp['name']].inport['ref']
01662                         if inp_ref._is_equivalent(ref):
01663                             print "_is_equivalent is OK!!!"
01664                             ret_name.append( inp['name'] )
01665                             ret_obj.append( in_dict[inp['name']] )
01666                             ret_ref.append(inp_ref)
01667 
01668         for num in range(len(ret_name)):
01669             canvas.lineFrom = self.body
01670             canvas.lineTo = ret_obj[num].body
01671             line = GRtcLine(canvas,self)
01672             line.setLine2port(canvas, dc)
01673 
01674             self.line_idx.append(line.idx)
01675             self.isInactive = self.isInactive + 1
01676             connect_num = self.checkConnect(ret_ref[num], subscription_list)
01677             # get uuid
01678             self.uuid[line.idx] = subscription_list[connect_num].id
01679 
01680         canvas.lineFrom = None
01681         canvas.lineTo = None
01682         canvas.Redraw(dc)
01683 
01684 
01685     def checkOtherConnect(self):
01686         """�Ť���³���󤬤��뤫�����å�����
01687         ���̾�����ʳ�����³�����֥������Ⱦ�ˤ��뤫�����å�����
01688 
01689         [����]
01690         �ʤ�
01691 
01692         [�����]
01693         ret  ---  True:���� / False:�ʤ�
01694         """
01695         ret = False
01696         canvas = self.body.GetCanvas()
01697         ref = self.outport['ref']
01698         try:
01699             ref = ref._narrow(RTM.OutPort)
01700         except:
01701             err_mess = 'outport obj-ref failure:'
01702             except_mess(err_mess)
01703             return ret
01704 
01705         # get subscription-list
01706         subscription_list = []
01707         try:
01708             subscription_list = ref._get_subscriptions()
01709             if subscription_list == None:
01710                 print "get subscriptions failure: return value is None."
01711                 return ret
01712         except:
01713             except_mess('get subscriptions failure:')
01714             return ret
01715 
01716         for line_idx in self.line_idx:
01717             line = canvas.line[line_idx]
01718             (ret2,subscription_list) = self.checkConnect2(line,subscription_list)
01719         if len(subscription_list) > 0:
01720             ret = True
01721         return ret
01722 
01723     def checkConnect(self, inp_obj, subscr_list):
01724         """��³�����å�
01725         ���ꤷ����³���inport�ˤΥ�ե���󥹤����뤫�����å�����
01726 
01727         [����]
01728         inp_obj  ---  ����ݡ��ȤΥ��֥������ȡ���ե����
01729         ref_list ---  ����ݡ��ȤΥ�ե���󥹡��ꥹ��
01730 
01731         [�����]
01732         ret_num --- subScription_list ��ź����/�ʤ�����-1
01733         """
01734         ret = False
01735         ret_num = 0
01736         for subscr in subscr_list:
01737             ref_inp = subscr.in_port
01738             if ref_inp._is_equivalent(inp_obj):
01739                 print "checkConnect: _is_equivalent is OK!!!"
01740                 ret = True
01741                 break
01742             ret_num = ret_num + 1
01743         if ret == False:
01744             ret_num = -1
01745         return ret_num
01746 
01747     def checkConnect2(self, line, subscr_list):
01748         """��³�����å�
01749         �����å��оݤ���³�����ä����ϡ��ꥹ�Ⱦ夫���������ֵѤ���
01750         �Ť����󤬤��뤫Ĵ�٤�٤˸ƤФ��
01751 
01752         [����]
01753         line      ---  ���Υ��֥�������
01754         ref_list  ---  ��³���inport�ˤΥ��֥������ȥ�ե���󥹡��ꥹ��
01755 
01756         [�����]
01757         (ret, ref_list) --- ret 0:�ʤ� / 1:���� , ref_list: �Ĥ�Υ�ե���󥹥ꥹ��
01758         """
01759 
01760         inp_obj = line.g_inp.inport['ref']
01761 
01762         cnt = 0
01763         ret = 0
01764         for subscr in subscr_list:
01765             ref_inp = subscr.in_port
01766             if ref_inp._is_equivalent(inp_obj):
01767 #                print "checkConnect2: _is_equivalent is OK!!!"
01768                 ret = 1
01769                 break
01770             cnt = cnt + 1
01771         if ret == 1:
01772             del subscr_list[cnt]
01773 
01774         return (ret, subscr_list)
01775 
01776     def disconnectToObjref(self,subscr_list):
01777         """����ݡ��ͥ�Ⱦ����³�����subscribe�ˤ�������
01778 
01779         [����]
01780         inp_list  ---  ��³���subscriptionProfile�ˤΥꥹ��
01781 
01782         [�����]
01783         void
01784         """
01785 #assembly: for debug:
01786 #        print "disconnectToObjref : it's dummy for debug!"
01787 #        return      # for debug
01788 #for debug:
01789 
01790         canvas = self.body.GetCanvas()
01791         ref = self.outport['ref']
01792         ref = ref._narrow(RTM.OutPort)
01793 
01794         for subscr in subscr_list:
01795             inp = subscr.in_port
01796 #            print "test:",dir(inp)
01797             #get uuid
01798             connect_num = self.checkConnect(inp, subscr_list)
01799             uuid = subscr_list[connect_num].id
01800 
01801             if ref != None and canvas.viewMode == False:
01802                 try :
01803                     print "unsubscribe2 :",uuid
01804                     rslt = ref.unsubscribe(uuid)
01805                     if rslt != 0:
01806                         print 'unsubscribe2 failure: rslt=',rslt
01807                 except :
01808                     err_mess = 'unsubscribe failure:'
01809                     except_mess(err_mess)
01810 
01811 
01812     def reConnectLine(self):
01813         """����³����
01814 
01815         [����]
01816         �ʤ�
01817 
01818         [�����]
01819         void
01820         """
01821 #assembly dummy
01822 #        return
01823 #assembly dummy
01824 
01825         canvas = self.body.GetCanvas()
01826         ref = self.outport['ref']
01827         try:
01828             ref = ref._narrow(RTM.OutPort)
01829         except:
01830             err_mess = 'outport obj-ref failure:'
01831             except_mess(err_mess)
01832             return
01833 
01834         # get subscription-list
01835         subscription_list = []
01836         subscr_list_tmp = []
01837         try:
01838             subscription_list = ref._get_subscriptions()
01839             subscr_list_tmp = copy.deepcopy(subscription_list)
01840             if subscription_list == None:
01841                 print "get subscriptions failure: return value is None."
01842                 return
01843         except:
01844             except_mess('get subscriptions failure:')
01845             return
01846 
01847         for line_idx in self.line_idx:
01848             line = canvas.line[line_idx]
01849             (ret,subscr_list_tmp) = self.checkConnect2(line,subscr_list_tmp)
01850             if ret == 0:
01851                 self.connect2(line_idx,line.subscription_type)
01852             else:
01853                 # get uuid
01854                 inp_ref = canvas.line[line_idx].g_inp.inport['ref']
01855                 connect_num = self.checkConnect(inp_ref, subscription_list)
01856                 self.uuid[line_idx] = subscription_list[connect_num].id
01857 
01858                 # ����³��������ϳ�줿subscribe�θ��С������naming-service��Υ��ߡ�
01859         for line_idx in self.line_idx:
01860             line = canvas.line[line_idx]
01861             (ret,subscr_list_tmp) = self.checkConnect2(line,subscr_list_tmp)
01862             if ret == 0:
01863                 self.connect2(line_idx,line.subscription_type)
01864         if len(subscr_list_tmp) > 0:
01865 #            print "reconnect "
01866             self.disconnectToObjref(subscr_list_tmp)
01867 
01868     def dcoords(self):
01869         """�����ȥݡ��ȿ޷��κ�ɸ����
01870         ���ߤ�position�򸫤ƿ޷��θ�������ꤹ��
01871         ��ĺ����(x,y)�Υ��ץ����
01872 
01873         [����]
01874         �ʤ�
01875 
01876         [�����]
01877         void
01878         """
01879         if self.position == 'Left':
01880             self.points = [ (self.x, self.y+self.y_size/2),
01881                             ( self.x+self.x_size/2, self.y),
01882                             ( self.x+self.x_size, self.y),
01883                             ( self.x+self.x_size, self.y+self.y_size),
01884                             ( self.x+self.x_size/2, self.y+self.y_size),
01885                             ( self.x, self.y+self.y_size/2) ]
01886         elif self.position == 'Right' :
01887             self.points = [ ( self.x+self.x_size, self.y+self.y_size/2 ),
01888                             ( self.x+self.x_size/2, self.y+self.y_size ),
01889                             ( self.x, self.y+self.y_size ),
01890                             ( self.x, self.y ),
01891                             ( self.x+self.x_size/2, self.y ),
01892                             ( self.x+self.x_size, self.y+self.y_size/2) ]
01893         elif self.position == 'Top' :
01894             self.points = [ ( self.x+self.x_size/2, self.y ),
01895                             ( self.x+self.x_size, self.y+self.y_size/2 ),
01896                             ( self.x+self.x_size, self.y+self.y_size ),
01897                             ( self.x, self.y+self.y_size ),
01898                             ( self.x, self.y+self.y_size/2 ),
01899                             ( self.x+self.x_size/2, self.y ) ]
01900         elif self.position == 'Bottom' :
01901             self.points = [ ( self.x+self.x_size/2, self.y+self.y_size ),
01902                             ( self.x, self.y+self.y_size/2 ),
01903                             ( self.x, self.y ),
01904                             ( self.x+self.x_size, self.y ),
01905                             ( self.x+self.x_size, self.y+self.y_size/2 ),
01906                             ( self.x+self.x_size/2, self.y+self.y_size ) ]
01907 
01908 #----------------------------------------------------------------------
01909 class GRtc(ogl.Shape):
01910     """����ݡ��ͥ�ȿ޷������Τ�������륯�饹"""
01911     def __init__(self, parent, fullpath, pos_x, pos_y):
01912         """���饹�ν�����ʥ���ݡ��ͥ�ȿ޷��κ�����
01913 
01914         [����]
01915         parent     -- �ƥ��饹����ꤹ��
01916         fullpath   -- ����ݡ��ͥ�ȤΥ��󥰥͡���
01917         pos_x      -- ����ݡ��ͥ�ȿ޷��Σ���ɸ
01918         pos_y      -- ����ݡ��ͥ�ȿ޷��Σ���ɸ
01919 
01920         [�����]
01921         void
01922         """
01923         ogl.Shape.__init__(self)
01924         self.parent = parent
01925         self.fullpath = fullpath
01926         self.ns_dict = self.parent.frame.myDict
01927 #        print "check cur_dict:",cur_dict[0]
01928         self.name = self.ns_dict.GetCompName(fullpath)
01929         self.in_list = self.ns_dict.GetInPortToRef(fullpath)
01930         self.out_list = self.ns_dict.GetOutPortToRef(fullpath)
01931 
01932         self.x = pos_x
01933         self.y = pos_y
01934         self.color = INACTIVE_COLOR
01935         self.state = 'inactive'
01936         self.x_size = BOX_WIDTH
01937         self.y_size = BOX_WIDTH
01938         self.ratioW = 1.0
01939         self.ratioH = 1.0
01940         self.rotTogle = 0
01941         self.revTogle = 1
01942         self.lastRot = 'LR'   # LR(Left/Right) or TB(Top/Bottom)
01943         self.xy_swap = 0
01944         self.mark = None
01945         self.tag = 'body'
01946         self.text = None
01947         self.lastBBoxWidth = 0
01948         self.lastBBoxHeight = 0
01949         self.text_x = 0
01950         self.text_y = 0
01951         self.px_size = POLYGON_SIZE
01952         self.py_size = POLYGON_SIZE
01953         tmp = max(len(self.in_list), len(self.out_list))
01954         self.minWidth = self.x_size
01955         self.minHeight = 2 * POLYGON_SIZE * tmp
01956 #        self.blink = blinkTimer()
01957         self.createWidget(0)
01958 
01959     def remakeLines(self):
01960 # assembly dummy process
01961 #        return
01962 # assembly dummy process
01963         for outp in self.out_list :
01964             if outp['name'] in self.out_dict.keys():
01965                 self.out_dict[outp['name']].remakeLines()
01966 
01967     def checkOtherConnect(self):
01968         """�Ť���³����ʲ��̾��ɽ������Ƥ��ʤ�subscribe����ˤ�����å�����
01969 
01970         [����]
01971         �ʤ�
01972 
01973         [�����]
01974         ret   ---  True:�Ť����󤢤� / False:�Ť�����ʤ�
01975         """
01976         ret = False
01977         for outp in self.out_list :
01978             if outp['name'] in self.out_dict.keys():
01979                 ret = self.out_dict[outp['name']].checkOtherConnect()
01980                 if ret == True:
01981                     break
01982         return ret
01983 
01984     def reConnectLine(self):
01985         """����³����
01986         ����ݡ��ͥ�ȤΥ����ȥݡ��Ȥκ���³������ƤӽФ�
01987 
01988         [����]
01989         �ʤ�
01990 
01991         [�����]
01992         void
01993         """
01994         for outp in self.out_list :
01995             if outp['name'] in self.out_dict.keys():
01996                 self.out_dict[outp['name']].reConnectLine()
01997 
01998     def portToFlash(self):
01999         """�ݡ���(Shape)��Flash�ʺ����衩�ˤ�ƤӽФ�
02000         ����ݡ��ͥ�Ȥγ��β��˥ݡ��Ȥγ����⤰����ॱ�����λ��˸ƤӽФ��Ƥ��롣�ʲ������
02001         ¾���ɤ�����������С������������ѹ�����
02002 
02003         [����]
02004         �ʤ�
02005 
02006         [�����]
02007         void
02008         """
02009         for inp in self.in_list :
02010             if inp['name'] in self.in_dict.keys():
02011                 self.in_dict[inp['name']].body.Flash()
02012         for outp in self.out_list :
02013             if outp['name'] in self.out_dict.keys():
02014                 self.out_dict[outp['name']].body.Flash()
02015 
02016     def checkCompState(self):
02017         """����ݡ��ͥ�ȤΥ��ơ�����������å�����
02018 
02019         [����]
02020         �ʤ�
02021 
02022         [�����]
02023         void
02024         """
02025         state = 'inactive'
02026 
02027         canvas = self.body.GetCanvas()
02028         tmp = self.ns_dict.GetCompState(self.fullpath)
02029         if tmp == RTM.RTComponent.RTC_STARTING or tmp == RTM.RTComponent.RTC_ACTIVE:
02030             state = 'active'
02031         elif tmp == RTM.RTComponent.RTC_READY or tmp == RTM.RTComponent.RTC_STOPPING:
02032             state = 'inactive'
02033         elif tmp >= RTM.RTComponent.RTC_ABORTING :
02034             state = 'error'
02035         else:   # unknown , born?, initializing
02036             state = 'unloaded'
02037         if canvas.viewMode == True and state != 'unloaded':
02038             state = 'virtual'
02039 
02040         self.state = state
02041 
02042     def ref_start(self):
02043         """����ݡ��ͥ�Ȥ�start̿���ȯ��
02044 
02045         [����]
02046         �ʤ�
02047 
02048         [�����]
02049         void
02050         """
02051         try:
02052             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02053             ref = ref._narrow(RTM.RTCBase)
02054             ref.rtc_start()
02055         except :
02056             err_mess = 'rtc_start error:%s\n'%self.fullpath
02057             except_mess(err_mess)
02058         self.checkCompState()
02059 #        setBodyColor(self.baseBox, self.state)
02060 #        setBodyColor(self.baseBox, 'active')
02061         self.ns_dict.setCompBodyColor(self.fullpath, 'active')
02062         self.state = 'active'
02063         self.portToFlash()
02064 
02065     def ref_stop(self):
02066         """����ݡ��ͥ�Ȥ�stop̿���ȯ��
02067 
02068         [����]
02069         �ʤ�
02070 
02071         [�����]
02072         void
02073         """
02074         try:
02075             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02076             ref = ref._narrow(RTM.RTCBase)
02077             ref.rtc_stop()
02078         except :
02079             err_mess = 'rtc_stop error:%s\n'%self.fullpath
02080             except_mess(err_mess)
02081         self.checkCompState()
02082 #        setBodyColor(self.baseBox, self.state)
02083 #        setBodyColor(self.baseBox, 'inactive')
02084         self.ns_dict.setCompBodyColor(self.fullpath, 'inactive')
02085         self.state = 'inactive'
02086         self.portToFlash()
02087 
02088     def ref_reset(self):
02089         """����ݡ��ͥ�Ȥ�reset̿���ȯ��
02090 
02091         [����]
02092         �ʤ�
02093 
02094         [�����]
02095         void
02096         """
02097         try:
02098             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02099             ref = ref._narrow(RTM.RTCBase)
02100             ref.rtc_reset()
02101         except :
02102             err_mess = 'rtc_reset error:%s\n'%self.fullpath
02103             except_mess(err_mess)
02104 #        self.checkCompState()
02105 #        setBodyColor(self.baseBox, self.state)
02106         self.ns_dict.setCompBodyColor(self.fullpath, self.state)
02107         self.portToFlash()
02108 
02109     def ref_kill(self):
02110         """����ݡ��ͥ�Ȥ�kill̿���ȯ��
02111 
02112         [����]
02113         �ʤ�
02114 
02115         [�����]
02116         void
02117         """
02118         try:
02119             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02120             ref = ref._narrow(RTM.RTCBase)
02121             ref.rtc_kill()
02122         except :
02123             err_mess = 'rtc_kill error:%s\n'%self.fullpath
02124             except_mess(err_mess)
02125         self.checkCompState()
02126 #        setBodyColor(self.baseBox, self.state)
02127 #        setBodyColor(self.baseBox, 'inactive')
02128         self.ns_dict.setCompBodyColor(self.fullpath, 'unloaded')
02129         self.state = 'inactive'
02130         self.portToFlash()
02131 
02132     def ref_exit(self):
02133         """����ݡ��ͥ�Ȥ�exit̿���ȯ��
02134 
02135         [����]
02136         �ʤ�
02137 
02138         [�����]
02139         void
02140         """
02141         try:
02142             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02143             ref = ref._narrow(RTM.RTCBase)
02144             ref.rtc_exit()
02145         except :
02146             err_mess = 'rtc_exit error:%s\n'%self.fullpath
02147             except_mess(err_mess)
02148         self.checkCompState()
02149 #        setBodyColor(self.baseBox, self.state)
02150 #        setBodyColor(self.baseBox, 'unloaded')
02151         self.ns_dict.setCompBodyColor(self.fullpath, 'unloaded')
02152         self.state = 'unloaded'
02153         self.portToFlash()
02154 
02155     def changeBodyColor(self,state):
02156         """���ơ������ˤ�ꥳ��ݡ��ͥ�Ȥο������ꤹ��
02157 
02158         [����]
02159         state  ---  ����ݡ��ͥ�Ȥξ��֤���ꤹ��
02160                     'active','inactive','error',unloaded','virtual'
02161 
02162         [�����]
02163         void
02164         """
02165         if state == 'unloaded':
02166             self.state = 'unloaded'
02167             self.color = UNLOADED_COLOR
02168         elif state == 'active' :
02169             self.state = 'active'
02170             self.color = ACTIVE_COLOR
02171         elif state == 'inactive':
02172             self.state = 'inactive'
02173             self.color = INACTIVE_COLOR
02174         elif state == 'error' :
02175             self.state = 'error'
02176             self.color = ERROR_COLOR
02177 #        canvas = self.body.GetCanvas()
02178         canvas = self.parent.diagram.GetCanvas()
02179         dc = wx.ClientDC(canvas)
02180         canvas.PrepareDC(dc)
02181         if canvas.viewMode == True and self.state != 'unloaded':
02182             self.state = 'virtual'
02183             self.color = VIRTUAL_COLOR
02184         setBodyColor(self.baseBox, self.state)
02185         self.portToFlash()
02186         canvas.Redraw(dc)
02187 
02188     def refresh_outp(self):
02189         """�����ȥݡ��Ȥ�refresh
02190 
02191         [����]
02192         �ʤ�
02193 
02194         [�����]
02195         void
02196         """
02197         for outp in self.out_list :
02198             if outp['name'] in self.out_dict.keys():
02199                 self.out_dict[outp['name']].refresh()
02200 
02201     def refresh(self):
02202         """��ե�å������
02203         ����ݡ��ͥ�Ȥ�state�ե饰�Ǹ��ߤξ��֡�active,error,inactive���ˤ�����
02204 
02205         [����]
02206         �ʤ�
02207 
02208         [�����]
02209         void
02210         """
02211         old_state = self.state
02212         canvas = self.body.GetCanvas()
02213         dc = wx.ClientDC(canvas)
02214         canvas.PrepareDC(dc)
02215         try :  
02216             ref = self.ns_dict.GetObjRefToFullpath(self.fullpath)
02217             ref = ref._narrow(RTM.RTCBase)
02218             tmp_port = ref._get_rtc_state()
02219             tmp_port = tmp_port._narrow(RTM.OutPort)
02220             tmp = tmp_port.get()
02221             tmp = tmp.value()
02222             tmp = tmp.data
02223             print "refresh state:",tmp
02224         except :
02225             except_mess("except error:")
02226             ref = None
02227 
02228         if not ref:
02229             self.state = 'unloaded'
02230             self.color = UNLOADED_COLOR
02231         else:
02232             self.name = self.ns_dict.GetCompName(self.fullpath)
02233             self.in_list = self.ns_dict.GetInPortToRef(self.fullpath)
02234             self.out_list = self.ns_dict.GetOutPortToRef(self.fullpath)
02235 
02236             for outp in self.out_list :
02237                 if outp['name'] in self.out_dict.keys():
02238                     self.out_dict[outp['name']].outport = outp
02239             for inp in self.in_list :
02240                 if inp['name'] in self.in_dict.keys():
02241                     self.in_dict[inp['name']].inport = inp
02242 
02243 
02244             if tmp == RTM.RTComponent.RTC_STARTING or tmp == RTM.RTComponent.RTC_ACTIVE:
02245                 self.state = 'active'
02246                 self.color = ACTIVE_COLOR
02247             elif tmp == RTM.RTComponent.RTC_STOPPING or tmp == RTM.RTComponent.RTC_READY:
02248                 self.state = 'inactive'
02249                 self.color = INACTIVE_COLOR
02250             elif tmp >= RTM.RTComponent.RTC_ABORTING :
02251                 self.state = 'error'
02252                 self.color = ERROR_COLOR
02253             else :
02254                 self.state = 'unloaded'
02255                 self.color = UNLOADED_COLOR
02256 
02257 #            if old_state == 'unloaded' and self.state != 'unloaded':
02258             if len(self.out_dict.keys()) != len(self.out_list):
02259                 self.removeWidget(dc,0)
02260 
02261                 old_rot = self.rotTogle
02262                 old_rev = self.revTogle
02263                 old_lastrot = self.lastRot
02264                 self.rotTogle = 0
02265                 self.revTogle = 1
02266                 self.lastRot = 'LR'   # LR(Left/Right) or TB(Top/Bottom)
02267                 self.x_size = BOX_WIDTH
02268                 self.x = self.x - self.x_size/2
02269                 self.y = self.y - self.y_size/2
02270                 self.ratioW = 1.0
02271                 self.ratioH = 1.0
02272                 self.createWidget(0)
02273                 if old_lastrot == 'LR':
02274                     if old_rev == 0:
02275                         self.reversesBody()
02276                 else:
02277                     if old_rot == 1:
02278                         self.rotatesBody()
02279                     else:
02280                         self.rotatesBody()
02281                         self.rotatesBody()
02282 
02283 #        setBodyColor(self.baseBox, self.state)
02284         self.ns_dict.setCompBodyColor(self.fullpath, self.state)
02285         self.portToFlash()
02286         canvas.Redraw(dc)
02287 
02288     def removeWidget(self, dc, rot=0):
02289         """����ݡ��ͥ�ȿ޷���������
02290         ����ݡ��ȿ޷��������ȥݡ��ȿ޷�����Ϣ��������������
02291 
02292         [����]
02293         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
02294         rot    -- ���κ�����ݤ���ꤹ�롣�ʲ�ž�������ǻ��ѡ�
02295                   0:������  /  1:���������ʤ�
02296 
02297         [�����]
02298         void
02299         """
02300         # ���ο޷��򥭥��Х���DC�夫��������
02301         canvas = self.body.GetCanvas()
02302         self.body.Erase(dc)
02303         self.body.RemoveFromCanvas(canvas)
02304 
02305         # �ӥåȥޥåפκ��
02306         if self.bmp:
02307             self.bmp.Erase(dc)
02308             self.bmp.RemoveFromCanvas(canvas)
02309 
02310         # ����ݡ��ͥ��̾�Τκ��
02311         self.text.Erase(dc)
02312         self.text.RemoveFromCanvas(canvas)
02313 
02314         # ����ݡ��ȡ������ȥݡ��Ȥκ��
02315         for inp in self.in_list:
02316             if inp['name'] in self.in_dict.keys():
02317                 self.in_dict[inp['name']].removeWidget(dc,rot)
02318         for outp in self.out_list:
02319             if outp['name'] in self.out_dict.keys():
02320                 self.out_dict[outp['name']].removeWidget(dc,rot)
02321 
02322 
02323     def createWidget(self, rot):
02324         """����ݡ��ͥ�ȿ޷��κ���
02325 
02326         [����]
02327         rot     -- �޷��β�ž������Ԥ��ե饰
02328                    0:��ž�ʤ��ʺ�ɸ��׻��ǵ���� 1:��ž����(��¸�κ�ɸ����ѡ�
02329 
02330         [�����]
02331         void
02332         """
02333         if rot == 0:
02334             tmp = max(len(self.in_list), len(self.out_list))
02335             if tmp == 0:
02336                 tmp = 1
02337             self.y_size = 2 * POLYGON_SIZE * self.ratioH * tmp
02338             pos_x = self.x + (BOX_WIDTH * self.ratioW)/2
02339             pos_y = self.y + self.y_size/2
02340         else:
02341             pos_x = self.x
02342             pos_y = self.y
02343 
02344         # ����ݡ��ͥ��̾��(TextShape)�κ���
02345         canvas = self.parent.diagram.GetCanvas()
02346         dc = wx.ClientDC(canvas)
02347         canvas.PrepareDC(dc)
02348         cnt = len(self.name)
02349         charW = dc.GetCharWidth()
02350         charH = dc.GetCharHeight()
02351         tmpW = charW * (cnt*1.2)
02352         tmpH = charH * 1.4
02353         self.text_x = pos_x + (self.x_size/2)
02354         self.text_y = self.y + self.y_size + POLYGON_SIZE
02355 
02356         self.text = makeTextShape(self,tmpW, tmpH)
02357         self.text.AddText(self.name)
02358         self.parent.MyAddText(self.text, self.text_x, self.text_y,wx.BLACK_PEN)
02359 ###
02360         # �ӥåȥޥåפκ���
02361         self.bmp = ogl.BitmapShape()
02362 #        if self.rtc.icon_path != None or self.rtc.icon_path != "":
02363 #        if self.rtc.icon_path != "":
02364 #            bitmap = wx.Bitmap(self.rtc.icon_path)
02365 #        else:
02366 #            bitmap = wx.NullBitmap
02367 #            self.bmp.SetSize(10,10,False)
02368         bitmap = wx.NullBitmap
02369         self.bmp.SetSize(10,10,False)
02370 #
02371         self.bmp.SetBitmap(bitmap)
02372         self.bmp.parent = self
02373         self.parent.MyAddBmp( self.bmp, pos_x, pos_y, wx.BLACK_PEN )
02374 
02375         # ���Τλͳѷ������
02376         self.baseBox = makeRectangle(self, self.x_size, self.y_size)
02377         self.parent.MyAddShape(self.baseBox, pos_x, pos_y, wx.BLACK_PEN, wx.Brush(self.color, wx.SOLID), "" ,0)
02378         # ���ҤΥѡ��ķ���CompositeShape�Ȥ��ơ��ƻҹ�¤�ˤ���
02379         self.body = makeCompositeShape(self)
02380         self.body.AddChild(self.baseBox)
02381         self.body.AddChild(self.bmp)
02382         self.body.AddChild(self.text)
02383 #
02384         self.constraint = ogl.OGLConstraint(ogl.gyCONSTRAINT_ALIGNED_TOP, self.baseBox, [self.bmp])
02385         self.body.AddConstraint(self.constraint)
02386         self.constraint2 = ogl.OGLConstraint(ogl.gyCONSTRAINT_CENTRED_HORIZONTALLY, self.bmp, [self.text])
02387         self.body.AddConstraint(self.constraint2)
02388 #        self.constraint = ogl.OGLConstraint(ogl.gyCONSTRAINT_CENTRED_HORIZONTALLY, self.baseBox, [self.text])
02389 #        self.body.AddConstraint(self.constraint)
02390         self.body.Recompute()
02391         self.body.CalculateSize()
02392 ###
02393         self.parent.MyAddShape(
02394             self.body, pos_x, pos_y, wx.BLACK_PEN, wx.Brush(self.color, wx.SOLID), "" ,0)
02395         # ��Ψ�׻��ѤκǸ�κ�ɸ����ӳ���̾��ѤκǸ�Υ�����
02396         self.baseBox.lastx = self.body.GetX()
02397         self.baseBox.lasty = self.body.GetY()
02398         self.lastBBoxWidth, self.lastBBoxHeight = self.baseBox.GetBoundingBoxMin()
02399 
02400         if rot == 0:
02401             # ����ݡ��Ȥκ����ʲ�ž�������ϹԤ�ʤ���
02402             self.in_dict = {}
02403             port_x = self.x - (POLYGON_SIZE*self.ratioW)*2/3
02404             port_y = self.y + (POLYGON_SIZE*self.ratioH)/2
02405             for inp in self.in_list :
02406                 self.in_dict[inp['name']] = GRtcIn(self, self.ns_dict, self.fullpath,
02407                                             inp,
02408                                             port_x, port_y)
02409                 port_y = port_y + (POLYGON_SIZE*self.ratioH)*2
02410 #
02411             # �����ȥݡ��Ȥκ����ʲ�ž�������ϹԤ�ʤ���
02412             port_x = self.x + (BOX_WIDTH*self.ratioW) - (POLYGON_SIZE*self.ratioW)/3
02413             port_y = self.y + (POLYGON_SIZE*self.ratioH)/2
02414             self.out_dict = {}
02415             for outp in self.out_list :
02416                 self.out_dict[outp['name']] = GRtcOut(self, self.ns_dict, self.fullpath,
02417                                          outp, 
02418                                          port_x, port_y)
02419                 port_y = port_y + (POLYGON_SIZE*self.ratioH)*2
02420 
02421         self.portToFlash()
02422 
02423 
02424     def dmove(self, dc, movex, movey):
02425         """����ݡ��ͥ�ȿ޷��ΰ�ư����
02426         ����ݡ��ȡ������ȥݡ��ȿ޷�����Ӵ�Ϣ���������ư
02427 
02428         [����]
02429         dc     -- ���褹��ǥХ���������ƥ����Ȥ����
02430         movex  -- ����ɸ�����а�ư�̤����
02431         movey  -- ����ɸ�����а�ư�̤����
02432 
02433         [�����]
02434         void
02435         """
02436         canvas = self.body.GetCanvas()
02437 
02438         self.x = self.body.GetX() + movex
02439         self.y = self.body.GetY() + movey
02440         self.body.Erase(dc)
02441         self.body.Move(dc, self.x, self.y)
02442         # ����ݡ��ȡ������ȥݡ��ȿ޷��ΰ�ư
02443         for inp in self.in_list:
02444             if inp['name'] in self.in_dict.keys():
02445                 self.in_dict[inp['name']].dmove(dc, movex, movey)
02446         for outp in self.out_list:
02447             if outp['name'] in self.out_dict.keys():
02448                 self.out_dict[outp['name']].dmove(dc, movex, movey)
02449 
02450 
02451     def selected(self):
02452         """����ݡ��ͥ�ȿ޷�����������ʿ����ѹ���
02453 
02454         [����]
02455         �ʤ�
02456 
02457         [�����]
02458         void
02459         """
02460         self.baseBox.SetBrush(wx.Brush(wx.NamedColor(SELECTED_COLOR)))
02461         self.body.Flash()
02462         # ����ݡ��ȡ������ȥݡ��ȿ޷���ե�å���ʺ�����ˤ��޷�������̤�ɽ��
02463         self.portToFlash()
02464         
02465     def unselected(self,dc):
02466         """����ݡ��ͥ�ȿ޷�������������ʿ����ѹ���
02467 
02468         [����]
02469         dc     -- ���褷�Ƥ����ǥХ���������ƥ����Ȥ����
02470 
02471         [�����]
02472         void
02473         """
02474         self.checkCompState()
02475         setBodyColor(self.baseBox, self.state)
02476         # ����ݡ��ȡ������ȥݡ��ȿ޷���ե�å���ʺ�����ˤ��޷�������̤�ɽ��
02477         self.portToFlash()
02478 
02479     def updatePolygonSize(self, x, y, ratioW, ratioH):
02480         """����ݡ��ͥ�ȿ޷��ʥ���ݡ��ȡ������ȥݡ��ȡˤΥ������ѹ�����
02481         ����ݡ��ͥ�ȿ޷����ΤΥ������ѹ��ϥǥե���ȡʥ����ƥ�¦�ˤǹԤ���
02482 
02483         [����]
02484         x      -- ���褹�����ɸ�����
02485         y      -- ���褹�����ɸ�����
02486         ratioW -- �������ѹ�����Width����Ψ�����
02487         ratioH -- �������ѹ�����Height����Ψ�����
02488 
02489         [�����]
02490         void
02491         """
02492         self.x = x
02493         self.y = y
02494         self.ratioW = ratioW
02495         self.ratioH = ratioH
02496         self.x_size, self.y_size = self.baseBox.GetBoundingBoxMin()
02497 
02498         canvas = self.body.GetCanvas()
02499         dc = wx.ClientDC(canvas)
02500         canvas.PrepareDC(dc)
02501 
02502         # �Ǿ��������Υ����å��������������꾮�����ä��������������ѹ�
02503         if self.lastRot == 'TB':
02504             minW, minH = self.minHeight, self.minWidth
02505         else:
02506             minH, minW = self.minHeight, self.minWidth
02507         if minW > self.x_size or minH > self.y_size:
02508             self.ratioW = 1.0
02509             self.ratioH = 1.0
02510             self.x_size = minW
02511             self.y_size = minH
02512             # ���ٿ޷����������嵭�����ꤷ���������Ǻƺ���
02513             self.body.Select(False, dc)
02514             tmp = canvas.selected.index(self.baseBox)
02515             del canvas.selected[tmp]
02516             self.removeWidget(dc,1)
02517             self.createWidget(1)
02518             self.baseBox.Select(True, dc)
02519             canvas.selected.append(self.baseBox)
02520 
02521 
02522         x_size = self.px_size 
02523         y_size = self.py_size 
02524         # ����ݡ��Ȥ�¸�ߤ����������ݡ��ȤΥ��������ѹ�����
02525         if len(self.in_dict) > 0:
02526             in_pos = self.in_dict[self.in_list[0]['name']].position
02527 
02528             port_x = self.x - self.x_size/2 + x_size -1
02529             port_y = self.y - self.y_size/2 + y_size -1
02530             # �ݡ��Ȥ�position�ˤ�����Ĵ��
02531             if in_pos == 'Right':
02532                 port_x = self.x + self.x_size/2 + x_size/6
02533             elif in_pos == 'Left':
02534                 port_x = self.x - self.x_size/2 - x_size/6
02535             elif in_pos == 'Top':
02536                 port_y = self.y - self.y_size/2 - y_size/6
02537             elif in_pos == 'Bottom':
02538                 port_y = self.y + self.y_size/2 + y_size/6
02539 
02540             for inp in self.in_list:
02541                 if inp['name'] in self.in_dict.keys():
02542                     self.in_dict[inp['name']].updatePolygonSize(port_x, port_y, ratioW, ratioH)
02543                     # �ݡ��Ȥ�position�ˤ�����Ĵ��
02544                     if in_pos == 'Right' or in_pos == 'Left':
02545                         port_y = port_y + y_size*2
02546                     else:
02547                         port_x = port_x + x_size*2
02548 #
02549 
02550         # �����ȥݡ��Ȥ�¸�ߤ�����������ȥݡ��ȤΥ��������ѹ�����
02551         if len(self.out_dict) > 0:
02552             out_pos = self.out_dict[self.out_list[0]['name']].position
02553 
02554             port_x = self.x - self.x_size/2 + x_size -1
02555             port_y = self.y - self.y_size/2 + y_size -1
02556             # �ݡ��Ȥ�position�ˤ�����Ĵ��
02557             if out_pos == 'Right':
02558                 port_x = self.x + self.x_size/2 + x_size/6
02559             elif out_pos == 'Left':
02560                 port_x = self.x - self.x_size/2 - x_size/6
02561             elif out_pos == 'Top':
02562                 port_y = self.y - self.y_size/2 - y_size/6
02563             elif out_pos == 'Bottom':
02564                 port_y = self.y + self.y_size/2 + y_size/6
02565 
02566             for outp in self.out_list:
02567                 if outp['name'] in self.out_dict.keys():
02568                     self.out_dict[outp['name']].updatePolygonSize(port_x, port_y, ratioW, ratioH)
02569                     # �ݡ��Ȥ�position�ˤ�����Ĵ��
02570                     if out_pos == 'Right' or out_pos == 'Left':
02571                         port_y = port_y + y_size*2
02572                     else:
02573                         port_x = port_x + x_size*self.ratioW*2
02574 
02575         # ����ݡ��ͥ��̾�Τ�ɽ������Ĵ��
02576         if self.lastRot == 'LR':
02577             self.text_y = self.y + self.y_size/2 + POLYGON_SIZE
02578         else:
02579             self.text_y = self.y + self.y_size/2 + self.py_size
02580         self.text.Erase(dc)
02581         self.text.SetY(self.text_y)
02582         self.text.Flash()
02583 
02584         # �ӥåȥޥåפ�ɽ������Ĵ��
02585         tmpw, tmph = self.bmp.GetBoundingBoxMin()
02586         pos_y = self.y - self.y_size/2 + tmph/2
02587         if self.lastRot != 'LR':
02588             pos_y = pos_y + self.py_size/2
02589         self.bmp.Erase(dc)
02590         self.bmp.SetY(pos_y)
02591         self.bmp.Flash()
02592 
02593         self.selected()
02594         self.portToFlash()
02595 
02596     def reversesBody(self):
02597         """����ȿž�ʲ�ž�˽���
02598 
02599         [����]
02600         �ʤ�
02601 
02602         [�����]
02603         void
02604         """
02605         # �����ȥ���ե饰�ι���
02606         self.revTogle = self.revTogle + 1
02607         if self.revTogle % 2 == 0 :
02608             self.revTogle = 0
02609         
02610         self.x = self.baseBox.GetX()
02611         self.y = self.baseBox.GetY()
02612         tmp = max(len(self.in_list), len(self.out_list))
02613         center_x = self.baseBox.GetX()
02614         center_y = self.baseBox.GetY()
02615         # �Ǹ�˺������岼�ɤ���β�ž�������Ԥ�줿����Width/Height�������ؤ�
02616         if self.lastRot == 'LR':
02617             self.x_size, self.y_size = self.baseBox.GetBoundingBoxMin()
02618             self.xy_swap = 0
02619         else:
02620             self.y_size, self.x_size = self.baseBox.GetBoundingBoxMin()
02621             self.xy_swap = 1
02622 
02623         canvas = self.body.GetCanvas()
02624         dc = wx.ClientDC(canvas)
02625         canvas.PrepareDC(dc)
02626         # ���ٿ޷����������嵭�����ꤷ���������Ǻƺ���
02627         self.removeWidget(dc,1)
02628         self.createWidget(1)
02629 
02630         # ʣ���ݡ��Ȥ�ɽ����ɸ��������POLYGON_SIZE�ˤ����
02631         if self.xy_swap == 1:
02632             p_size = self.px_size
02633         else:
02634             p_size = self.py_size
02635         if self.revTogle == 1:  # inport is right side of body
02636             port_x = self.x - self.x_size/2 - p_size/6
02637             port_y = self.y - self.y_size/2 + p_size-1
02638             for inp in self.in_list:
02639                 if inp['name'] in self.in_dict.keys():
02640                     self.in_dict[inp['name']].position = 'Left'
02641                     self.in_dict[inp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02642                     port_y = port_y + p_size*2
02643 #
02644             port_x = self.x + self.x_size/2 + p_size/6
02645             port_y = self.y - self.y_size/2 + p_size-1
02646             for outp in self.out_list:
02647                 if outp['name'] in self.out_dict.keys():
02648                     self.out_dict[outp['name']].position = 'Right'
02649                     self.out_dict[outp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02650                     port_y = port_y + p_size*2
02651 
02652         else :                  # inport is left side of body
02653             port_x = self.x + self.x_size/2 + p_size/6
02654             port_y = self.y - self.y_size/2 + p_size-1
02655             for inp in self.in_list:
02656                 if inp['name'] in self.in_dict.keys():
02657                     self.in_dict[inp['name']].position = 'Right'
02658                     self.in_dict[inp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02659                     port_y = port_y + p_size*2
02660 #
02661             port_x = self.x - self.x_size/2 - p_size/6
02662             port_y = self.y - self.y_size/2 + p_size-1
02663             for outp in self.out_list:
02664                 if outp['name'] in self.out_dict.keys():
02665                     self.out_dict[outp['name']].position = 'Left'
02666                     self.out_dict[outp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02667                     port_y = port_y + p_size*2
02668 
02669         # �ƥ����Ȥ�ɽ�����֤�Ʒ׻�
02670         self.text_y = self.y + self.y_size/2 + POLYGON_SIZE
02671         self.text.Erase(dc)
02672         self.text.SetY(self.text_y)
02673         self.text.Flash()
02674 
02675         self.lastRot = 'LR'
02676         self.xy_swap = 0
02677 
02678 
02679     def rotatesBody(self):   ## +-90 degrees
02680         """�岼��ž����
02681 
02682         [����]
02683         �ʤ�
02684 
02685         [�����]
02686         void
02687         """
02688         tmp = max(len(self.in_list), len(self.out_list))
02689         self.x = center_x = self.baseBox.GetX()
02690         self.y = center_y = self.baseBox.GetY()
02691         # �Ǹ�˺������岼�ɤ���β�ž�������Ԥ�줿����Width/Height�������ؤ�
02692         if self.lastRot == 'LR':
02693             self.y_size, self.x_size = self.baseBox.GetBoundingBoxMin()
02694             self.xy_swap = 1
02695         else:
02696             self.x_size, self.y_size = self.baseBox.GetBoundingBoxMin()
02697             self.xy_swap = 0
02698 
02699         canvas = self.body.GetCanvas()
02700         dc = wx.ClientDC(canvas)
02701         canvas.PrepareDC(dc)
02702 
02703         # ���ٿ޷����������嵭�����ꤷ���������Ǻƺ���
02704         self.removeWidget(dc,1)
02705         self.createWidget(1)
02706 
02707 
02708         # �岼�ȥ���ե饰�ι���
02709         self.rotTogle = self.rotTogle + 1
02710         if self.rotTogle % 2 == 0 :
02711             self.rotTogle = 0
02712 
02713         # ʣ���ݡ��Ȥ�ɽ����ɸ��������POLYGON_SIZE�ˤ����
02714         if self.xy_swap == 1:
02715             p_size = self.py_size
02716         else:
02717             p_size = self.px_size
02718         # ����ݡ��ȡ������ȥݡ��ȤΥ������ѹ�
02719         if self.rotTogle == 1:  # inport is top side of body
02720             port_x = self.x - self.x_size/2 + p_size-1
02721             port_y = self.y - self.y_size/2 - p_size/6
02722             for inp in self.in_list:
02723                 if inp['name'] in self.in_dict.keys():
02724                     self.in_dict[inp['name']].position = 'Top'
02725                     self.in_dict[inp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02726                     port_x = port_x + p_size*2
02727 #
02728             port_x = self.x - self.x_size/2 + p_size-1
02729             port_y = self.y + self.y_size/2 + p_size/6
02730             for outp in self.out_list:
02731                 if outp['name'] in self.out_dict.keys():
02732                     self.out_dict[outp['name']].position = 'Bottom'
02733                     self.out_dict[outp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02734                     port_x = port_x + p_size*2
02735 
02736         else :                  # inport is bottom side of body
02737             port_x = self.x - self.x_size/2 + p_size-1
02738             port_y = self.y + self.y_size/2 + p_size/6
02739             for inp in self.in_list:
02740                 if inp['name'] in self.in_dict.keys():
02741                     self.in_dict[inp['name']].position = 'Bottom'
02742                     self.in_dict[inp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02743                     port_x = port_x + p_size*2
02744 #
02745             port_x = self.x - self.x_size/2 + p_size-1
02746             port_y = self.y - self.y_size/2 - p_size/6
02747             for outp in self.out_list:
02748                 if outp['name'] in self.out_dict.keys():
02749                     self.out_dict[outp['name']].position = 'Top'
02750                     self.out_dict[outp['name']].updatePolygonSize(port_x, port_y, 1, 1)
02751                     port_x = port_x + p_size*2
02752 
02753         # �ƥ����Ȥ�ɽ������Ĵ��
02754         self.text_y = self.y + self.y_size/2 + self.py_size
02755         self.text.Erase(dc)
02756         self.text.SetY(self.text_y)
02757         self.text.Flash()
02758 
02759         # �ӥåȥޥåפ�ɽ������Ĵ��
02760         tmpw, tmph = self.bmp.GetBoundingBoxMin()
02761         pos_y = self.y - self.y_size/2 + tmph/2 + self.py_size/2
02762         self.bmp.Erase(dc)
02763         self.bmp.SetY(pos_y)
02764         self.bmp.Flash()
02765 
02766         self.lastRot = 'TB'
02767         self.xy_swap = 0
02768 
02769 #----------------------------------------------------------------------
02770 class MyEvtHandlerBmp(ogl.ShapeEvtHandler):
02771     """�ӥåȥޥå��ѤΥ��ߡ����٥�ȥ��饹"""
02772     def __init__(self, log, frame):
02773         """���饹�ν����
02774 
02775         [����]
02776         log     -- �������ϥ��饹�Υ��֥�������
02777         frame   -- ���ơ������С��Υ��֥�������
02778         ���嵭�����ϡ�demo�ץ�������̾�ġ������
02779 
02780         [�����]
02781         void
02782         """
02783         ogl.ShapeEvtHandler.__init__(self)
02784         self.log = log
02785         self.statbarFrame = frame
02786 
02787     def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
02788         """�ɥ�å���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
02789         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02790 
02791         [����]
02792         x          -- ���٥�Ȼ��Σ���ɸ
02793         y          -- ���٥�Ȼ��Σ���ɸ
02794         keys       -- �����������֡�SHIFT��CTRL��
02795         attachment -- ���������
02796 
02797         [�����]
02798         void
02799         """
02800         pass
02801 
02802     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
02803         """�ޥ���������å����˸ƤФ�륤�٥�ȥϥ�ɥ�
02804         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02805 
02806         [����]
02807         x          -- ���٥�Ȼ��Σ���ɸ
02808         y          -- ���٥�Ȼ��Σ���ɸ
02809         keys       -- �����������֡�SHIFT��CTRL��
02810         attachment -- ���������
02811 
02812         [�����]
02813         void
02814         """
02815         pass
02816 
02817     def OnSizingEndDragLeft(self, pt, x, y, keys, attch):
02818         """�������ѹ���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
02819         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02820 
02821         [����]
02822         pt         -- ����ȥ�����ݥ����
02823         x          -- ���٥�Ȼ��Σ���ɸ
02824         y          -- ���٥�Ȼ��Σ���ɸ
02825         keys       -- �����������֡�SHIFT��CTRL��
02826         attachment -- ���������
02827 
02828         [�����]
02829         void
02830         """
02831         pass
02832 
02833     def OnBeginDragLeft(self, x, y, keys, attachment):
02834         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
02835         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02836 
02837         [����]
02838         x          -- ���٥�Ȼ��Σ���ɸ
02839         y          -- ���٥�Ȼ��Σ���ɸ
02840         keys       -- �����������֡�SHIFT��CTRL��
02841         attachment -- ���������
02842 
02843         [�����]
02844         void
02845         """
02846         pass
02847 
02848 #----------------------------------------------------------------------
02849 class MyEvtHandlerOval(ogl.ShapeEvtHandler):
02850     """����ư�ѤαߤΥ��٥�ȥ��饹"""
02851     def __init__(self, log, frame):
02852         """���饹�ν������ShapeEvtHandler�κ�����
02853 
02854         [����]
02855         log     -- �������ϥ��饹�Υ��֥�������
02856         frame   -- ���ơ������С��Υ��֥�������
02857         ���嵭�����ϡ�demo�ץ�������̾�ġ������
02858 
02859         [�����]
02860         void
02861         """
02862         ogl.ShapeEvtHandler.__init__(self)
02863         self.log = log
02864         self.statbarFrame = frame
02865 
02866     def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
02867         """�ɥ�å���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
02868         �ɥ�å��ե饰��off�ˤ���
02869 
02870         [����]
02871         x          -- ���٥�Ȼ��Σ���ɸ
02872         y          -- ���٥�Ȼ��Σ���ɸ
02873         keys       -- �����������֡�SHIFT��CTRL��
02874         attachment -- �����å����ȡ�̤���ѡ�
02875 
02876         [�����]
02877         void
02878         """
02879         self.dragOn = 0
02880 
02881     def OnBeginDragLeft(self, x, y, keys=0, attachment=0):
02882         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
02883         �ɥ�å��ե饰��on�ˤ���
02884 
02885         [����]
02886         x          -- ���٥�Ȼ��Σ���ɸ
02887         y          -- ���٥�Ȼ��Σ���ɸ
02888         keys       -- �����������֡�SHIFT��CTRL��
02889         attachment -- �����å����ȡ�̤���ѡ�
02890 
02891         [�����]
02892         void
02893         """
02894         self.dragOn = 1
02895 
02896     def OnDragLeft(self, draw, x, y, keys, attachment):
02897         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
02898         ��ư�Ѥαߤ�ɥ�å��ǰ�ư�ʱߤ�dmove�᥽�å���Ǵ�Ϣ���������ư�������
02899 
02900         [����]
02901         x          -- ���٥�Ȼ��Σ���ɸ
02902         y          -- ���٥�Ȼ��Σ���ɸ
02903         keys       -- �����������֡�SHIFT��CTRL��
02904         attachment -- �����å����ȡ�̤���ѡ�
02905 
02906         [�����]
02907         void
02908         """
02909 #        self.base_OnBeginDragLeft(x, y, keys, attachment)
02910         shape = self.GetShape()
02911 
02912         if self.dragOn == 1:
02913 
02914             # ����DC��BufferedDC)�������������˳���������Redraw��ɽ��ɽ��
02915             canvas = shape.GetCanvas()
02916             dc = getBufferedDC(canvas)
02917             canvas.PrepareDC(dc)
02918 
02919             movex = x - shape.lastx
02920             movey = y - shape.lasty
02921 
02922             shape.parent.dmove(dc,movex,movey)
02923 
02924             shape.lastx = shape.GetX()
02925             shape.lasty = shape.GetY()
02926 
02927             canvas.Redraw(dc)
02928 
02929 #----------------------------------------------------------------------
02930 class MyEvtHandlerDummy(ogl.ShapeEvtHandler):
02931     """���ߡ����٥�ȥϥ�ɥ�"""
02932     def __init__(self, log, frame):
02933         """���饹�ν����
02934 
02935         [����]
02936         log     -- �������ϥ��饹�Υ��֥�������
02937         frame   -- ���ơ������С��Υ��֥�������
02938         ���嵭�����ϡ�demo�ץ�������̾�ġ������
02939 
02940         [�����]
02941         void
02942         """
02943         ogl.ShapeEvtHandler.__init__(self)
02944         self.log = log
02945         ogl.ShapeEvtHandler.__init__(self)
02946         self.log = log
02947         self.statbarFrame = frame
02948 
02949     def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
02950         """�ɥ�å���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
02951         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02952 
02953         [����]
02954         x          -- ���٥�Ȼ��Σ���ɸ
02955         y          -- ���٥�Ȼ��Σ���ɸ
02956         keys       -- �����������֡�SHIFT��CTRL��
02957         attachment -- �����å����ȡ�̤���ѡ�
02958 
02959         [�����]
02960         void
02961         """
02962         pass
02963 
02964     def OnDragLeft(self, draw, x, y, keys=0, attachment=0):
02965         """�ɥ�å����˸ƤФ�륤�٥�ȥϥ�ɥ�
02966         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02967 
02968         [����]
02969         x          -- ���٥�Ȼ��Σ���ɸ
02970         y          -- ���٥�Ȼ��Σ���ɸ
02971         keys       -- �����������֡�SHIFT��CTRL��
02972         attachment -- �����å����ȡ�̤���ѡ�
02973 
02974         [�����]
02975         void
02976         """
02977         pass
02978 
02979     def OnBeginDragLeft(self, x, y, keys, attachment):
02980         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
02981         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02982 
02983         [����]
02984         x          -- ���٥�Ȼ��Σ���ɸ
02985         y          -- ���٥�Ȼ��Σ���ɸ
02986         keys       -- �����������֡�SHIFT��CTRL��
02987         attachment -- �����å����ȡ�̤���ѡ�
02988 
02989         [�����]
02990         void
02991         """
02992         pass
02993 
02994     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
02995         """�ޥ���������å��˸ƤФ�륤�٥�ȥϥ�ɥ�
02996         ������̤������pass�Τߡˤǥ��٥�Ȥ���Ͽ�����ǥե���Ȥ�ư����޻�
02997 
02998         [����]
02999         x          -- ���٥�Ȼ��Σ���ɸ
03000         y          -- ���٥�Ȼ��Σ���ɸ
03001         keys       -- �����������֡�SHIFT��CTRL��
03002         attachment -- �����å����ȡ�̤���ѡ�
03003 
03004         [�����]
03005         void
03006         """
03007         pass
03008 
03009 
03010 #----------------------------------------------------------------------
03011 class MyEvtHandlerLine(ogl.ShapeEvtHandler):
03012     """���Υ��٥�ȥ��饹"""
03013     def __init__(self ):
03014         """���饹�ν����
03015 
03016         [����]
03017         �ʤ�
03018 
03019         [�����]
03020         void
03021         """
03022         ogl.ShapeEvtHandler.__init__(self)
03023 
03024     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
03025         """�ޥ���������å����˸ƤФ�륤�٥�ȥϥ�ɥ�
03026         �������򡿲����Ԥ�
03027         ��������Ǥϡ���ư�Ѥαߤ��������
03028 
03029         [����]
03030         x          -- ���٥�Ȼ��Σ���ɸ
03031         y          -- ���٥�Ȼ��Σ���ɸ
03032         keys       -- �����������֡�SHIFT��CTRL��
03033         attachment -- �����å����ȡ�̤���ѡ�
03034 
03035         [�����]
03036         void
03037         """
03038         shape = self.GetShape()
03039 #        print shape.__class__, shape.GetClassName()
03040         canvas = shape.GetCanvas()
03041         dc = wx.ClientDC(canvas)
03042         canvas.PrepareDC(dc)
03043         # ��������Ѥ�
03044         if shape in canvas.selected:
03045             # ������֤β��
03046             for obj in shape.parent.lines:
03047                 obj.Select(False, dc)
03048             shape.parent.unselected(dc)
03049             for obj in canvas.selected:
03050                 if shape == obj:
03051                     obj.parent.unselected(dc)
03052                     idx = canvas.selected.index(obj)
03053                     del canvas.selected[idx]
03054         # ����̤����
03055         else:
03056             # ������֤˰ܹ�
03057             redraw = False
03058             shapeList = canvas.GetDiagram().GetShapeList()
03059 
03060             if canvas.selected and keys != 1:
03061                 for s in canvas.selected:
03062                     s.Select(False, dc)
03063                     s.parent.unselected(dc)
03064                 canvas.selected = []
03065                 canvas.Redraw(dc)
03066 
03067             shape.parent.selected()
03068 
03069             for obj in shape.parent.lines:
03070                 canvas.selected.append(obj)
03071 
03072             # create oval on line
03073             line = shape.parent
03074             if (line.coordT == None) or (len(line.coordT) == 2):
03075                 return
03076 
03077             # ����ư�Ѥαߤ�����
03078             num = len(line.coordT)
03079             line.oval_dict = {}
03080             for oval_id in range(1,num-2):
03081                 line_pos_0 = line.coordT[oval_id]
03082                 line_pos_1 = line.coordT[oval_id+1]
03083                 if line_pos_0[0] == line_pos_1[0] and line_pos_0[1] != line_pos_1[1]: # width line
03084                     hight = line_pos_0[1] - line_pos_1[1]
03085                     pos_y = line_pos_1[1] + (hight/2)
03086                     pos_x = line_pos_0[0]
03087                     tag = (oval_id, "oval_width_pos")
03088                 elif  line_pos_0[0] != line_pos_1[0] and line_pos_0[1] == line_pos_1[1] : # length line
03089                     width = line_pos_0[0] - line_pos_1[0]
03090                     pos_x = line_pos_1[0] + (width/2)
03091                     pos_y = line_pos_1[1]
03092                     tag = (oval_id, "oval_length_pos")
03093                 line.oval_dict[oval_id] = GRectOval(line, tag, pos_x, pos_y)
03094                 line.parent.parent.parent.MyAddOval(line.oval_dict[oval_id].body, pos_x, pos_y)
03095 
03096         canvas.Redraw(dc)
03097 
03098 #----------------------------------------------------------------------
03099 
03100 class MyEvtHandler(ogl.ShapeEvtHandler):
03101     """����ݡ��ͥ�ȿ޷��ʻͳѷ������ΤΥ��٥�ȥ��饹"""
03102     def __init__(self, log, frame):
03103         """���饹�ν����
03104 
03105         [����]
03106         log     -- �������ϥ��饹�Υ��֥�������
03107         frame   -- ���ơ������С��Υ��֥�������
03108         ���嵭�����ϡ�demo�ץ�������̾�ġ������
03109 
03110         [�����]
03111         void
03112         """
03113         ogl.ShapeEvtHandler.__init__(self)
03114         self.log = log
03115         self.statbarFrame = frame
03116         self.dragOn = 0
03117 
03118     def UpdateStatusBar(self, shape):
03119         """���ơ������С���ɽ���������ι���
03120 
03121         [����]
03122         shape   -- �޷��Υ��֥������Ȥ����
03123 
03124         [�����]
03125         void
03126         """
03127         x,y = shape.GetX(), shape.GetY()
03128         width, height = shape.GetBoundingBoxMax()
03129         self.statbarFrame.SetStatusText("Pos: (%d,%d)  Size: (%d, %d)" %
03130                                         (x, y, width, height))
03131 
03132 
03133     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
03134         """�ޥ���������å����˸ƤФ�륤�٥�ȥϥ�ɥ�
03135         ���Τ����򡿲����Ԥ�
03136 
03137         [����]
03138         x          -- ���٥�Ȼ��Σ���ɸ
03139         y          -- ���٥�Ȼ��Σ���ɸ
03140         keys       -- �����������֡�SHIFT��CTRL��
03141         attachment -- �����å����ȡ�̤���ѡ�
03142 
03143         [�����]
03144         void
03145         """
03146         shape = self.GetShape()
03147 #        print shape.__class__, shape.GetClassName()
03148         canvas = shape.GetCanvas()
03149         dc = wx.ClientDC(canvas)
03150         canvas.PrepareDC(dc)
03151 
03152         # ����å������ץ��ե�����ɽ��
03153         ref = self.statbarFrame.myDict.GetObjRefToFullpath(shape.parent.fullpath)
03154         try:
03155             ref = ref._narrow(RTM.RTCBase)
03156             self.statbarFrame.profilepanel.RefreshProfile(ref._get_profile())
03157         except:
03158             except_mess("obj-ref error:")
03159 
03160         # ���٥�ȤǸƤӽФ��줿�޷�������Ѥߤξ��
03161         if shape in canvas.selected:
03162         #if shape.parent.tag == 'body' or shape.parent.tag == 'line':
03163             # ������
03164             canvas.lineFrom = None
03165             shape.Select(False, dc)
03166             shape.parent.unselected(dc)
03167             for obj in canvas.selected:
03168                 if shape == obj:
03169                     idx = canvas.selected.index(obj)
03170                     del canvas.selected[idx]
03171             canvas.Redraw(dc)
03172         # ���٥�ȤǸƤӽФ��줿�޷���̤����ξ��
03173         else:
03174             # ������֤ذܹ�
03175             canvas.lineFrom = None
03176             redraw = False
03177             shapeList = canvas.GetDiagram().GetShapeList()
03178 
03179             shape.Select(True, dc)
03180             shape.parent.selected()
03181 
03182             if canvas.selected and keys != 1:
03183                 for s in canvas.selected:
03184                     s.Select(False, dc)
03185                     s.parent.unselected(dc)
03186                 canvas.selected = []
03187                 canvas.Redraw(dc)
03188 
03189             canvas.selected.append(shape)
03190 
03191         self.UpdateStatusBar(shape)
03192 
03193 
03194     def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
03195         """�ɥ�å���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
03196         ������֤����޷����ư
03197 
03198         [����]
03199         x          -- ���٥�Ȼ��Σ���ɸ
03200         y          -- ���٥�Ȼ��Σ���ɸ
03201         keys       -- �����������֡�SHIFT��CTRL��
03202         attachment -- �����å����ȡ�̤���ѡ�
03203 
03204         [�����]
03205         void
03206         """
03207         if self.dragOn == 1:
03208             shape = self.GetShape()
03209 #            self.base_OnEndDragLeft(x, y, keys, attachment)
03210 
03211             canvas = shape.GetCanvas()
03212             dc = wx.ClientDC(canvas)
03213             canvas.PrepareDC(dc)
03214 
03215             movex = x - shape.lastx
03216             movey = y - shape.lasty
03217             # ������֤����޷����ư
03218             for obj in canvas.selected:
03219 
03220                 # body/inport/outport
03221                 obj.parent.dmove(dc,movex,movey)
03222 
03223                 obj.lastx = obj.GetX()
03224                 obj.lasty = obj.GetY()
03225 
03226                 if obj.parent.tag != 'line':
03227                     obj.Select(True, dc)
03228 
03229             canvas.Redraw(dc)
03230             self.dragOn = 0
03231 
03232             self.UpdateStatusBar(shape)
03233 
03234     def OnSizingEndDragLeft(self, pt, x, y, keys, attch):
03235         """�������ѹ���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
03236 
03237         [����]
03238         pt         -- ����ȥ�����ݥ����
03239         x          -- ���٥�Ȼ��Σ���ɸ
03240         y          -- ���٥�Ȼ��Σ���ɸ
03241         keys       -- �����������֡�SHIFT��CTRL��
03242         attachment -- �����å����ȡ�̤���ѡ�
03243 
03244         [�����]
03245         void
03246         """
03247         # �ǥե���ȤΥ������ѹ����٥�ȥϥ�ɥ�ƤӽФ�
03248         self.base_OnSizingEndDragLeft(pt, x, y, keys, attch)
03249 
03250         shape = self.GetShape()
03251         canvas = shape.GetCanvas()
03252         dc = wx.ClientDC(canvas)
03253         canvas.PrepareDC(dc)
03254         # �������ѹ�����Width,Height����Ψ����
03255         width, height = shape.GetBoundingBoxMax()
03256         ratioW = width / shape.parent.lastBBoxWidth
03257         ratioH = height / shape.parent.lastBBoxHeight
03258         tmpx,tmpy = shape.GetX(), shape.GetY()
03259         # �������ѹ�
03260         shape.parent.updatePolygonSize(tmpx,tmpy,ratioW,ratioH)
03261         self.UpdateStatusBar(shape)
03262         canvas.Redraw(dc)
03263         shape.parent.lastBBoxWidth, shape.parent.lastBBoxHeight = shape.GetBoundingBoxMax()
03264 
03265     def OnDragLeft(self, draw, x, y, keys, attachment):
03266         """�ɥ�å����˸ƤФ�륤�٥�ȥϥ�ɥ�
03267         ������֤����޷����ư
03268 
03269         [����]
03270         x          -- ���٥�Ȼ��Σ���ɸ
03271         y          -- ���٥�Ȼ��Σ���ɸ
03272         keys       -- �����������֡�SHIFT��CTRL��
03273         attachment -- �����å����ȡ�̤���ѡ�
03274 
03275         [�����]
03276         void
03277         """
03278         shape = self.GetShape()
03279         canvas = shape.GetCanvas()
03280         if self.dragOn == 1:
03281             if shape not in canvas.selected:
03282                 pass
03283             else:
03284                 width, height = shape.GetBoundingBoxMax()
03285                 self.statbarFrame.SetStatusText("Pos: (%d,%d)  Size: (%d, %d)" %
03286                                                 (x, y, width, height))
03287 #                self.base_OnDragLeft(1, x, y, keys, attachment)
03288 
03289                 # ����DC(BufferedDC)�������������˳��������ơ�Redrawde��ɽ��ɽ��
03290                 dc = getBufferedDC(canvas)
03291                 canvas.PrepareDC(dc)
03292 
03293                 # ����Ѥߤο޷����ư
03294                 movex = x - shape.lastx
03295                 movey = y - shape.lasty
03296                 for obj in canvas.selected:
03297                     obj.DeleteControlPoints()
03298                     # inport/outport
03299                     obj.parent.dmove(dc,movex,movey)
03300 
03301                     obj.lastx = obj.GetX()
03302                     obj.lasty = obj.GetY()
03303 
03304                 canvas.Redraw(dc)
03305 
03306     def OnBeginDragLeft(self, x, y, keys, attachment):
03307         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
03308 
03309         [����]
03310         x          -- ���٥�Ȼ��Σ���ɸ
03311         y          -- ���٥�Ȼ��Σ���ɸ
03312         keys       -- �����������֡�SHIFT��CTRL��
03313         attachment -- �����å����ȡ�̤���ѡ�
03314 
03315         [�����]
03316         void
03317         """
03318         shape = self.GetShape()
03319         canvas = shape.GetCanvas()
03320         dc = wx.ClientDC(canvas)
03321         canvas.PrepareDC(dc)
03322         if shape not in canvas.selected:
03323             shape.DeleteControlPoints()
03324 
03325             if canvas.selected and keys != 1:
03326                 for s in canvas.selected:
03327                     s.Select(False, dc)
03328                     s.parent.unselected(dc)
03329                 canvas.selected = []
03330                 canvas.Redraw(dc)
03331 
03332             shape.Select(True, dc)
03333             shape.parent.selected()
03334             canvas.selected.append(shape)
03335 
03336         else:
03337             for s in canvas.selected:
03338                 if s.parent.tag == 'line':
03339                     s.Select(False, dc)
03340                     s.parent.unselected(dc)
03341                     idx = canvas.selected.index(s)
03342                     del canvas.selected[idx]
03343             canvas.Redraw(dc)
03344 
03345             self.log.write("OnBeginDragLeft: %s, %s, %s\n" % (x, y, keys))
03346 #            self.base_OnBeginDragLeft(x, y, keys, attachment)
03347         self.dragOn = 1
03348 
03349 #----------------------------------------------------------------------
03350 
03351 class MyPortEvtHandler(ogl.ShapeEvtHandler):
03352     """�ݡ��ȤΥ��٥�ȥ��饹"""
03353     def __init__(self, log, frame):
03354         """���饹�ν����
03355 
03356         [����]
03357         log     -- �������ϥ��饹�Υ��֥�������
03358         frame   -- ���ơ������С��Υ��֥�������
03359         ���嵭�����ϡ�demo�ץ�������̾�ġ������
03360 
03361         [�����]
03362         void
03363         """
03364         ogl.ShapeEvtHandler.__init__(self)
03365         self.log = log
03366         self.statbarFrame = frame
03367         self.dragOn = 0
03368 
03369     def UpdateStatusBar(self, shape):
03370         """���ơ������С���ɽ���������ι���
03371 
03372         [����]
03373         shape   -- �޷��Υ��֥������Ȥ����
03374 
03375         [�����]
03376         void
03377         """
03378         x,y = shape.GetX(), shape.GetY()
03379         width, height = shape.GetBoundingBoxMax()
03380         self.statbarFrame.SetStatusText("Pos: (%d,%d)  Size: (%d, %d)" %
03381                                         (x, y, width, height))
03382 
03383 
03384     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
03385         """�ޥ���������å����˸ƤФ�륤�٥�ȥϥ�ɥ�
03386         ��������٤Ρ�������or��λ��������
03387         ��λ���������ϡ������֤��������
03388 
03389         [����]
03390         x          -- ���٥�Ȼ��Σ���ɸ
03391         y          -- ���٥�Ȼ��Σ���ɸ
03392         keys       -- �����������֡�SHIFT��CTRL��
03393         attachment -- �����å����ȡ�̤���ѡ�
03394 
03395         [�����]
03396         void
03397         """
03398         shape = self.GetShape()
03399 #        print shape.__class__, shape.GetClassName()
03400         canvas = shape.GetCanvas()
03401         dc = wx.ClientDC(canvas)
03402         canvas.PrepareDC(dc)
03403         ref = shape.parent.ns_dict.GetObjRefToFullpath(shape.parent.fullpath)
03404         try:
03405             ref = ref._narrow(RTM.RTCBase)
03406             tmp = shape.parent.ns_dict.GetCompState(shape.parent.fullpath)
03407             if tmp >= RTM.RTComponent.RTC_ABORTING or tmp == 0:
03408                 ref = None
03409         except :
03410             except_mess("except error:")
03411             ref = None
03412 
03413         if not ref:
03414             return
03415 
03416         if canvas.lineFrom == None:
03417             canvas.lineFrom = shape
03418         elif canvas.lineFrom != shape:
03419             if canvas.lineFrom.parent.tag == 'in':
03420                 checktag = 'out'
03421             else:
03422                 checktag = 'in'
03423             if shape.parent.tag != checktag:
03424                 return
03425             if shape.parent.fullpath == canvas.lineFrom.parent.fullpath:
03426                 return
03427 
03428             canvas.lineTo = shape
03429             line = GRtcLine(canvas,shape.parent)
03430             line.setLine2port(canvas, dc)
03431             line.g_outp.connect(line.idx, line.g_outp.subscription_type)
03432 
03433             canvas.lineFrom = None
03434             canvas.lineTo = None
03435             canvas.Redraw(dc)
03436 
03437         self.UpdateStatusBar(shape)
03438 
03439 
03440     def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
03441         """�ɥ�å���λ���˸ƤФ�륤�٥�ȥϥ�ɥ�
03442         �ݡ��Ⱦ�˥ޥ����������뤬������������
03443 
03444         [����]
03445         x          -- ���٥�Ȼ��Σ���ɸ
03446         y          -- ���٥�Ȼ��Σ���ɸ
03447         keys       -- �����������֡�SHIFT��CTRL��
03448         attachment -- �����å����ȡ�̤���ѡ�
03449 
03450         [�����]
03451         void
03452         """
03453         shape = self.GetShape()
03454         ref = shape.parent.ns_dict.GetObjRefToFullpath(shape.parent.fullpath)
03455         try:
03456             ref = ref._narrow(RTM.RTCBase)
03457             tmp = shape.parent.ns_dict.GetCompState(shape.parent.fullpath)
03458             if tmp >= RTM.RTComponent.RTC_ABORTING or tmp == 0:
03459                 ref = None
03460         except :
03461             except_mess("except error:")
03462             ref = None
03463         if not ref:
03464             return
03465 
03466         if self.dragOn == 1:
03467 #            shape.parent.parent.blink.Stop()
03468             self.dragOn = 0
03469             canvas = shape.GetCanvas()
03470             dc = wx.ClientDC(canvas)
03471             canvas.PrepareDC(dc)
03472             canvas.moveLine.removeWidget(dc)
03473             canvas.Redraw(dc)
03474             tmpShape = canvas.FindShape(x,y)
03475             if tmpShape == 0 or not hasattr(tmpShape[0], "parent") or not hasattr(tmpShape[0].parent, "ns_dict"):
03476                 return
03477             ref = tmpShape[0].parent.ns_dict.GetObjRefToFullpath(tmpShape[0].parent.fullpath)
03478             try:
03479                 ref = ref._narrow(RTM.RTCBase)
03480                 tmp = tmpShape[0].parent.ns_dict.GetCompState(tmpShape[0].parent.fullpath)
03481                 if tmp >= RTM.RTComponent.RTC_ABORTING or tmp == 0:
03482                     ref = None
03483                 if shape.parent.fullpath == tmpShape[0].parent.fullpath:
03484                     ref = None
03485             except :
03486                 except_mess("except error:")
03487                 ref = None
03488             if not ref:
03489                 return
03490 
03491             if canvas.lineFrom.parent.tag == 'in':
03492                 checktag = 'out'
03493             else:
03494                 checktag = 'in'
03495             if tmpShape[0].parent.tag == checktag:
03496                 canvas.lineTo = tmpShape[0]
03497                 line = GRtcLine(canvas,shape.parent)
03498                 line.setLine2port(canvas, dc)
03499                 line.g_outp.connect(line.idx, line.g_outp.subscription_type)
03500 
03501                 canvas.lineFrom = None
03502                 canvas.lineTo = None
03503                 canvas.Redraw(dc)
03504         else:
03505             pass
03506 
03507     def OnDragLeft(self, draw, x, y, keys, attachment):
03508         """�ɥ�å����˸ƤФ�륤�٥�ȥϥ�ɥ�
03509         �ޥ�����������Ȼ����֤��������
03510 
03511         [����]
03512         x          -- ���٥�Ȼ��Σ���ɸ
03513         y          -- ���٥�Ȼ��Σ���ɸ
03514         keys       -- �����������֡�SHIFT��CTRL��
03515         attachment -- �����å����ȡ�̤���ѡ�
03516 
03517         [�����]
03518         void
03519         """
03520         shape = self.GetShape()
03521         if self.dragOn == 1:
03522             canvas = shape.GetCanvas()
03523             dc = getBufferedDC(canvas)
03524             canvas.PrepareDC(dc)
03525 
03526             # create line
03527             canvas.moveLine.setPoints(shape.GetX(), shape.GetY(), x, y)
03528             canvas.moveLine.lines[0].SetPen(wx.Pen(SELECTED_COLOR, 1))
03529             canvas.moveLine.lines[0].Show(True)
03530             canvas.Redraw(dc)
03531         else:
03532             pass
03533 
03534     def OnBeginDragLeft(self, x, y, keys, attachment):
03535         """�ɥ�å����ϻ��˸ƤФ�륤�٥�ȥϥ�ɥ�
03536         �ɥ�å��ˤ�������������γ���(���֥������ȥ�ե���󥹤�¸�ߤ������
03537 
03538         [����]
03539         x          -- ���٥�Ȼ��Σ���ɸ
03540         y          -- ���٥�Ȼ��Σ���ɸ
03541         keys       -- �����������֡�SHIFT��CTRL��
03542         attachment -- �����å����ȡ�̤���ѡ�
03543 
03544         [�����]
03545         void
03546         """
03547         self.log.write("OnBeginDragLeft: %s, %s, %s\n" % (x, y, keys))
03548         self.dragOn = 1
03549         shape = self.GetShape()
03550         ref = shape.parent.ns_dict.GetObjRefToFullpath(shape.parent.fullpath)
03551         try:
03552             ref = ref._narrow(RTM.RTCBase)
03553             tmp = shape.parent.ns_dict.GetCompState(shape.parent.fullpath)
03554             if tmp >= RTM.RTComponent.RTC_ABORTING or tmp == 0:
03555                 ref = None
03556         except :
03557             ref = None
03558             except_mess("except error:")
03559         if ref:
03560             canvas = shape.GetCanvas()
03561             dc = wx.ClientDC(canvas)
03562             canvas.PrepareDC(dc)
03563             canvas.lineFrom = shape
03564             # make line
03565             canvas.moveLine = GRtcLine(canvas, shape.parent)
03566             canvas.moveLine.setPoints(shape.GetX(), shape.GetY(), x, y)
03567             canvas.moveLine.lines[0].SetPen(wx.Pen(SELECTED_COLOR, 1))
03568             canvas.moveLine.lines[0].Show(True)
03569 #            shape.parent.parent.blink.setBlinkState(shape.parent.parent, 'inactive', 'active')
03570 #            shape.parent.parent.blink.Start(500)
03571         else:
03572             self.dragOn = 0
03573 
03574 
03575 #----------------------------------------------------------------------
03576 
03577 class RtdSystemDraw(ogl.ShapeCanvas):
03578     """�޷������ѤΥ����Х��������饹"""
03579     def __init__(self, parent, log, frame):
03580         """���饹�ν����
03581 
03582         [����]
03583         log     -- �������ϥ��饹�Υ��֥�������
03584         frame   -- ���ơ������С��Υ��֥�������
03585         ���嵭�����ϡ�demo�ץ�������̾�ġ������
03586         parent  -- �ƥ�����ɥ������
03587 
03588         [�����]
03589         void
03590         """
03591         ogl.ShapeCanvas.__init__(self, parent)
03592 
03593         maxWidth  = 1000
03594         maxHeight = 1000
03595 #        self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20)
03596 
03597         self.x_size = maxWidth
03598         self.y_size = maxHeight
03599         self.log = log
03600         self.frame = frame
03601         self.SetBackgroundColour(wx.WHITE)
03602         self.diagram = ogl.Diagram()
03603         self.save_gdi = []
03604         self.SetDiagram(self.diagram)
03605         self.diagram.SetCanvas(self)
03606         self.tooltip = None
03607         self.rtc_dict = {}
03608         self.rtc_list = []
03609         canvas = self.diagram.GetCanvas()
03610         canvas.lineFrom = None
03611         canvas.lineTo = None
03612         canvas.line_idx = 0
03613         canvas.line = {}
03614         canvas.moveLine = None
03615         canvas.selected = []
03616         canvas.viewMode = False
03617 
03618         rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID)
03619         dsBrush = wx.Brush("WHITE", wx.SOLID)
03620 
03621         # �ɥ�å����ɥ��åס��ɥ��åץ������åȤ�����
03622         dt = MyTextDropTarget(self, log)
03623         self.SetDropTarget(dt)
03624 
03625         # ���٥�Ȥγ���
03626         self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
03627         self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
03628         self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
03629         self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown)
03630         self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
03631         self.Bind(wx.EVT_RIGHT_UP,   self.OnRightUp)
03632 
03633     def changeCompColor(self, fullname, state) :
03634         """����ݡ��ͥ��ñ�Το����ѹ���rtc_state()���ȡ�
03635 
03636         [����]
03637         fullname   -- ����ݡ��ͥ�ȤΥե�ѥ�̾
03638 
03639         [�����]
03640         void
03641         """
03642         if fullname in self.rtc_list:
03643 #            self.rtc_dict[fullname].refresh()
03644             self.rtc_dict[fullname].changeBodyColor(state)
03645             self.rtc_dict[fullname].state = state
03646 
03647     def search_g_inp(self, inp_ref) :
03648         """����ݡ��Ȥθ���
03649 
03650         [����]
03651         inp_ref   -- ����ݡ��ȤΥ��֥������ȥ�ե����
03652 
03653         [�����]
03654         g_inp -- ����ݡ��ȤΥǥ�������ʥ꡼
03655         """
03656         print "len rtc_list:",len(self.rtc_list)
03657         for rtc_name in self.rtc_list :
03658             g_rtc = self.rtc_dict[rtc_name]
03659             ref = g_rtc.ns_dict.GetObjRefToFullpath(g_rtc.fullpath)
03660             if ref :
03661                 print "len in_list:",len(g_rtc.in_list)
03662                 for inp in g_rtc.in_list :
03663                     print "inp_ref:",inp_ref, " == ", g_rtc.in_dict[inp['name']].inport['ref']
03664                     if inp_ref._is_equivalent(g_rtc.in_dict[inp['name']].inport['ref']) :
03665                         print "_is_equivalent is OK!!!"
03666                         return g_rtc.in_dict[inp['name']]
03667 
03668     def openFileDialog(self):
03669         wildcard = "*.xml |*.xml| *.* |*.*"
03670         dialog = wx.FileDialog( self, strOPEN_TITLE, defaultDir=os.getcwd(),
03671                                 defaultFile="", wildcard=wildcard, style=wx.OPEN)
03672 
03673         if dialog.ShowModal() != wx.ID_OK:
03674             return None
03675 
03676         openFileName = dialog.GetPath()
03677         dialog.Destroy()
03678         return openFileName
03679 
03680     def loadXML(self):
03681         if len(self.rtc_dict) > 0:
03682             ret = self.askDialog(strDEL_SYS)
03683             if ret != wx.ID_OK:
03684                 return
03685 
03686         openFileName = self.openFileDialog()
03687         print "open file is :",openFileName
03688         if openFileName == None:
03689             return
03690 
03691         # delete
03692         self.deleteAllShape()
03693 
03694         rtxml = RtmParser.RtmParser()
03695         dict = rtxml.readXML(openFileName)
03696 
03697         canvas = self.diagram.GetCanvas()
03698         canvas.viewMode = True
03699         self.createGRtc_from_dict(dict)
03700 
03701     def saveFileDialog(self):
03702         wildcard = "*.xml |*.xml| *.* |*.*"
03703         dialog = wx.FileDialog( self, strSAVE_AS_TITLE, defaultDir=os.getcwd(),
03704                                 defaultFile="", wildcard=wildcard, style=wx.SAVE)
03705 
03706         if dialog.ShowModal() != wx.ID_OK:
03707             return None
03708 
03709         saveFileName = dialog.GetPath()
03710         dialog.Destroy()
03711         return saveFileName
03712 
03713     def makeDumpData(self):
03714         canvas = self.diagram.GetCanvas()
03715 
03716         dict = {}
03717         dict['rtc'] = {}
03718         dict['line'] = []
03719         for fullname in self.rtc_list:
03720             comp = self.rtc_dict[fullname]
03721             name = fullname
03722 
03723             x_size, y_size = comp.baseBox.GetBoundingBoxMin()
03724             if comp.lastRot == 'TB':
03725                 y_size, x_size = x_size, y_size
03726 
03727             x = comp.baseBox.GetX() - x_size/2
03728             y = comp.baseBox.GetY() - y_size/2
03729 #            print "Comp name:",name," x=",x," y=",y
03730             dict['rtc'][name] = {}
03731             dict['rtc'][name]['x'] = x
03732             dict['rtc'][name]['y'] = y
03733 
03734             if comp.lastRot == 'LR':
03735                 if comp.revTogle == 1:
03736                     dict['rtc'][name]['rot'] = 'Right'
03737                 else:
03738                     dict['rtc'][name]['rot'] = 'Left'
03739             else:
03740                 if comp.rotTogle == 1:
03741                     dict['rtc'][name]['rot'] = 'Top'
03742                 else:
03743                     dict['rtc'][name]['rot'] = 'Bottom'
03744                   
03745 #            comp.rotTogle  # 1 or 0 # 1 :inport's is top side of body
03746 #            comp.revTogle  # 1 or 0 # 1 :inport's is right side of body
03747 #            comp.lastRot   # LR(Left/Right) or TB(Top/Bottom)
03748 
03749         for line_idx in canvas.line:
03750             out_obj = canvas.line[line_idx].g_outp
03751             in_obj = canvas.line[line_idx].g_inp
03752             tmp = {}
03753 #            tmp['type'] =
03754 
03755             tmp['pos'] = canvas.line[line_idx].coordT
03756             tmp['in-comp'] = in_obj.fullpath
03757             tmp['in-name'] = in_obj.inport['name']
03758             tmp['out-comp'] = out_obj.fullpath
03759             tmp['out-name'] = out_obj.outport['name']
03760             dict['line'].append(tmp)
03761 
03762         return dict
03763 
03764     def saveXML(self, saveFileName):
03765 
03766         dict = {}
03767         dict = self.makeDumpData()
03768 
03769         rtxml = RtmParser.RtmParser()
03770 
03771         rtxml.writeXML(saveFileName, dict)
03772 
03773     def saveAsXML(self):
03774         saveFileName = self.saveFileDialog()
03775         if saveFileName == None:
03776             return
03777 
03778         self.saveXML(saveFileName)
03779 
03780     def refresh(self):
03781         """��ե�å������
03782         ����ݡ��ͥ�ȵڤӡ�ɽ���޷��Υ�ե�å����Ԥ�
03783 
03784         [����]
03785         �ʤ�
03786 
03787         [�����]
03788         void
03789         """
03790         canvas = self.diagram.GetCanvas()
03791         dc = wx.ClientDC(canvas)
03792         canvas.PrepareDC(dc)
03793         for obj in canvas.selected:
03794             obj.Select(False, dc)
03795             obj.parent.unselected(dc)
03796         canvas.selected = []
03797         for rtc_name in self.rtc_list:
03798             self.rtc_dict[rtc_name].refresh()
03799         for rtc_name in self.rtc_list:
03800             self.rtc_dict[rtc_name].refresh_outp()
03801 
03802     def reConnect(self):
03803         """����³����
03804         ���̾�Υ���ݡ��ͥ�Ȥκ���³������ƤӽФ�
03805 
03806         [����]
03807         �ʤ�
03808 
03809         [�����]
03810         void
03811         """
03812 # assembly dummy process
03813 #        return
03814 # assembly dummy process
03815         for rtc_name in self.rtc_list:
03816             self.rtc_dict[rtc_name].reConnectLine()
03817 
03818     def remakeLines(self):
03819 # assembly dummy process
03820 #        return
03821 # assembly dummy process
03822         for rtc_name in self.rtc_list:
03823             self.rtc_dict[rtc_name].remakeLines()
03824 
03825     def createGRtc_from_dict(self,dict):
03826         """�ǥ�������ʥ꡼���饳��ݡ��ͥ�ȿ޷�������
03827 
03828         [����]
03829         dict   -- ������֥�Υǥ�������ʥ꡼
03830 
03831         [�����]
03832         void
03833         """
03834         canvas = self.diagram.GetCanvas()
03835         dc = wx.ClientDC(canvas)
03836         canvas.PrepareDC(dc)
03837 
03838         rtc_list = dict['rtc'].keys()
03839         self.rtc_dict = {}
03840         new_list = []
03841         pos_x = 0
03842         pos_y = 0
03843         for rtc_name in rtc_list:
03844 
03845             # obj-ref error check
03846             try:
03847                 ref = self.frame.myDict.GetObjRefToFullpath(rtc_name)
03848                 if ref == None:
03849                     print 'Component Create error!: %s'%rtc_name
03850                     continue
03851                 ref = ref._narrow(RTM.RTCBase)
03852                 tmp = self.frame.myDict.GetCompState(rtc_name)
03853 #                if tmp >= RTM.RTComponent.RTC_ABORTING or tmp == 0:
03854 #                    ref = None
03855             except:
03856                 err_mess = 'Component Create error:%s\n'%rtc_name
03857                 except_mess(err_mess)
03858                 continue
03859 
03860             new_list.append(rtc_name)
03861 
03862             pos_x = dict['rtc'][rtc_name]['x']
03863             pos_y = dict['rtc'][rtc_name]['y']
03864             comp = GRtc(self, rtc_name, pos_x, pos_y)
03865             comp.changeBodyColor('virtual')
03866             self.rtc_dict[rtc_name] = comp
03867 
03868             if dict['rtc'][rtc_name]['rot'] == 'Left':
03869                 comp.reversesBody()
03870             elif dict['rtc'][rtc_name]['rot'] == 'Top':
03871                 comp.rotatesBody()
03872             elif dict['rtc'][rtc_name]['rot'] == 'Bottom':
03873                 comp.rotatesBody()
03874                 comp.rotatesBody()
03875 
03876             comp.refresh()
03877 
03878         if len(new_list) == 0:
03879             canvas.viewMode = False
03880             return
03881 
03882         self.rtc_list = new_list
03883 
03884         for line_num in range(len(dict['line'])):
03885             line_dict = dict['line'][line_num]
03886             out_comp_name = line_dict['out-comp']
03887             out_name = line_dict['out-name']
03888 
03889             in_comp_name = line_dict['in-comp']
03890             in_name = line_dict['in-name']
03891 
03892             #error check
03893             if not self.rtc_dict.has_key(out_comp_name):
03894                 print 'Assembly Check: Port Connection Error!:',out_comp_name
03895                 continue
03896             if not self.rtc_dict[out_comp_name].out_dict.has_key(out_name):
03897                 print 'Assembly Check: Port Connection Error!: ',out_comp_name,":",out_name
03898                 continue
03899             if not self.rtc_dict.has_key(in_comp_name):
03900                 print 'Assembly Check: Port Connection Error!:',in_comp_name
03901                 continue
03902             if not self.rtc_dict[in_comp_name].in_dict.has_key(in_name):
03903                 print 'Assembly Check: Port Connection Error!: ',in_comp_name,":",in_name
03904                 continue
03905 
03906             outp_obj = self.rtc_dict[out_comp_name].out_dict[out_name]
03907             inp_obj = self.rtc_dict[in_comp_name].in_dict[in_name]
03908 
03909             canvas.lineFrom = outp_obj.body
03910             canvas.lineTo = inp_obj.body
03911             line = GRtcLine(canvas,outp_obj)
03912             line.setLine2port(canvas, dc)
03913             line.g_outp.connect(line.idx, line.g_outp.subscription_type)
03914 
03915             pos = []
03916             pos_list = []
03917             pos_list = string.splitfields(line_dict['pos'],',')
03918             for num in range(len(pos_list)/2):
03919                 pos.append((string.atof(pos_list[num*2]),string.atof(pos_list[num*2+1])))
03920 
03921             #line.move_child
03922             line.childMove(dc, pos)
03923 
03924             canvas.lineFrom = None
03925             canvas.lineTo = None
03926         canvas.Redraw(dc)
03927 
03928     def MyAddBmp(self, shape, x, y, pen):
03929         """�ӥåȥޥå׿޷�����Ͽ
03930         �����Х�������������ࡢ���٥�ȤȤδ�Ϣ�դ�
03931 
03932         [����]
03933         shape   -- �ӥåȥޥå׿޷������
03934         x       -- ɽ���������ɸ
03935         y       -- ɽ���������ɸ
03936         pen     -- �ڥ�ʿ��������ˤ����
03937 
03938         [�����]
03939         shape -- wx.Shape �޷����֥�������
03940         """
03941         shape.SetDraggable(False, False)
03942         shape.SetCanvas(self)
03943         if pen:    shape.SetPen(pen)
03944         shape.SetX(x)
03945         shape.SetY(y)
03946         self.diagram.AddShape(shape)
03947         evthandler = MyEvtHandlerBmp(self.log, self.frame)
03948         evthandler.SetShape(shape)
03949         evthandler.SetPreviousHandler(shape.GetEventHandler())
03950         shape.SetEventHandler(evthandler)
03951 
03952         shape.Show(True)
03953         return shape
03954 
03955     def MyAddOval(self, shape, x, y):
03956         """�߿޷�����Ͽ
03957         �����Х�������������ࡢ���٥�ȤȤδ�Ϣ�դ�
03958 
03959         [����]
03960         shape   -- �ӥåȥޥå׿޷������
03961         x       -- ɽ���������ɸ
03962         y       -- ɽ���������ɸ
03963 
03964         [�����]
03965         shape -- wx.Shape �޷����֥�������
03966         """
03967         shape.SetDraggable(True, False)
03968         shape.SetCanvas(self)
03969         shape.SetX(x)
03970         shape.SetY(y)
03971         self.diagram.AddShape(shape)
03972         evthandler = MyEvtHandlerOval(self.log, self.frame)
03973         evthandler.SetShape(shape)
03974         evthandler.SetPreviousHandler(shape.GetEventHandler())
03975         shape.SetEventHandler(evthandler)
03976 
03977         shape.Show(True)
03978         return shape
03979 
03980     def MyAddText(self, shape, x, y, pen, brush=None ):
03981         """�ƥ����Ȥ���Ͽ
03982         �����Х�������������ࡢ���٥�ȤȤδ�Ϣ�դ�
03983 
03984         [����]
03985         shape   -- �ӥåȥޥå׿޷������
03986         x       -- ɽ���������ɸ
03987         y       -- ɽ���������ɸ
03988         pen     -- �ڥ�ʿ��������ˤ����
03989         burush  -- �֥饷�ʿ��ˤ����
03990 
03991         [�����]
03992         shape -- wx.Shape �޷����֥�������
03993         """
03994         shape.SetDraggable(False, False)
03995         shape.SetCanvas(self)
03996         shape.SetX(x)
03997         shape.SetY(y)
03998         if pen:    shape.SetPen(pen)
03999         if brush:  shape.SetBrush(brush)
04000         self.diagram.AddShape(shape)
04001         evthandler = MyEvtHandlerDummy(self.log, self.frame)
04002         evthandler.SetShape(shape)
04003         evthandler.SetPreviousHandler(shape.GetEventHandler())
04004         shape.SetEventHandler(evthandler)
04005 
04006         shape.Show(True)
04007         return shape
04008 
04009     def MyAddShape(self, shape, x, y, pen, brush, text, inoutPort=0):
04010         """����ݡ��ͥ�ȿ޷����ݡ��ȿ޷�����Ͽ
04011         �����Х�������������ࡢ���٥�ȤȤδ�Ϣ�դ�
04012 
04013         [����]
04014         shape   -- �ӥåȥޥå׿޷������
04015         x       -- ɽ���������ɸ
04016         y       -- ɽ���������ɸ
04017         pen     -- �ڥ�ʿ��������ˤ����
04018         burush  -- �֥饷�ʿ��ˤ����
04019         text    -- �޷���ɽ������ʸ��������
04020         inoutPort -- �ݡ��Ȼ���ե饰
04021                      0:����ݡ��ͥ������ / 1:Inpot,Outport
04022 
04023         [�����]
04024         shape -- wx.Shape �޷����֥�������
04025         """
04026         shape.SetDraggable(True, True)
04027         shape.SetCanvas(self)
04028         shape.SetX(x)
04029         shape.SetY(y)
04030         if pen:    shape.SetPen(pen)
04031         if brush:  shape.SetBrush(brush)
04032         if text:   shape.AddText(text)
04033         self.diagram.AddShape(shape)
04034         shape.Show(True)
04035 
04036         if inoutPort == 1:   # make in/out port event handler
04037             evthandler = MyPortEvtHandler(self.log, self.frame)
04038             evthandler.SetShape(shape)
04039             evthandler.SetPreviousHandler(shape.GetEventHandler())
04040             shape.SetEventHandler(evthandler)
04041         elif inoutPort == 0:                # make body event handler
04042             evthandler = MyEvtHandler(self.log, self.frame)
04043             evthandler.SetShape(shape)
04044             evthandler.SetPreviousHandler(shape.GetEventHandler())
04045             shape.SetEventHandler(evthandler)
04046 
04047         return shape
04048 
04049     def OnDestroy(self, evt):
04050         """������ɥ�������٥�ȥϥ�ɥ�
04051 
04052         [����]
04053         evt     -- ���٥��
04054 
04055         [�����]
04056         void
04057         """
04058         # Do some cleanup
04059         for shape in self.diagram.GetShapeList():
04060             if shape.GetParent() == None:
04061                 shape.SetCanvas(None)
04062                 shape.Destroy()
04063 
04064         self.diagram.Destroy()
04065 
04066     def deleteShape(self,obj):
04067         """�޷���������
04068 
04069         [����]
04070         �����Ԥ�Shape���֥�������
04071 
04072         [�����]
04073         void
04074         """
04075         canvas = self.diagram.GetCanvas()
04076         dc = wx.ClientDC(self)
04077         canvas.PrepareDC(dc)
04078         obj.parent.removeWidget(dc)
04079 
04080         if hasattr(obj, "parent") and obj.parent.tag == 'body':
04081             rtc_name = obj.parent.fullpath
04082             if rtc_name in self.rtc_list:
04083                 tmp = self.rtc_list.index(rtc_name)
04084                 del self.rtc_list[tmp]
04085                 del self.rtc_dict[rtc_name]
04086         if hasattr(obj, "parent") and obj.parent.tag == 'line':
04087             idx = obj.parent.idx
04088             if idx in canvas.line.keys():
04089                 del canvas.line[idx]
04090 
04091         del obj
04092 
04093     def deleteAllShape(self):
04094         """���٤Ƥο޷���������
04095 
04096         [����]
04097         �ʤ�
04098 
04099         [�����]
04100         void
04101         """
04102         canvas = self.diagram.GetCanvas()
04103         dc = wx.ClientDC(self)
04104         canvas.PrepareDC(dc)
04105 
04106         for s in canvas.selected:
04107             s.Select(False, dc)
04108             s.parent.unselected(dc)
04109 
04110         shapeList = canvas.GetDiagram().GetShapeList()
04111         for obj in shapeList:
04112             self.deleteShape(obj)
04113 
04114         canvas.selected = []
04115         canvas.line = {}
04116 
04117         canvas.Redraw(dc)
04118 
04119     def deleteSelectedShape(self):
04120         """������ο޷���������
04121 
04122         [����]
04123         �ʤ�
04124 
04125         [�����]
04126         void
04127         """
04128         canvas = self.diagram.GetCanvas()
04129         dc = wx.ClientDC(self)
04130         canvas.PrepareDC(dc)
04131         for obj in canvas.selected:
04132             self.deleteShape(obj)
04133 
04134         canvas.selected = []
04135         bdc = getBufferedDC(canvas)
04136         canvas.PrepareDC(dc)
04137         canvas.Redraw(dc)
04138 
04139 
04140     def OnKeyDown(self, evt):
04141         """�����������Υ��٥�ȥϥ�ɥ�
04142         ������ο޷���������
04143 
04144         [����]
04145         evt     -- ���٥��
04146 
04147         [�����]
04148         void
04149         """
04150         evtKey = evt.GetKeyCode()
04151         # DELETE �����λ������򤵤�Ƥ���޷�����
04152         if evtKey == wx.WXK_DELETE:
04153             self.deleteSelectedShape()
04154 
04155         canvas = self.diagram.GetCanvas()
04156         dc = wx.ClientDC(self)
04157         canvas.PrepareDC(dc)
04158         bdc = getBufferedDC(canvas)
04159         canvas.PrepareDC(bdc)
04160         canvas.Redraw(bdc)
04161 
04162     def OnPopupStart(self, evt):
04163         """����ݡ��ͥ�����ΤΥ������Ȥ�Ԥ����٥�ȥϥ�ɥ�
04164 
04165         [����]
04166         evt    --  ���٥��(wx.CommandEvent)
04167 
04168         [�����]
04169         void
04170         """
04171         pt = self.pt
04172         tmpShape = self.FindShape(pt[0],pt[1])
04173         if tmpShape != 0:
04174             tmpShape[0].parent.ref_start()
04175 
04176     def OnPopupStop(self, evt):
04177         """����ݡ��ͥ�����ΤΥ��ȥåפ�Ԥ����٥�ȥϥ�ɥ�
04178 
04179         [����]
04180         evt    --  ���٥��(wx.CommandEvent)
04181 
04182         [�����]
04183         void
04184         """
04185         pt = self.pt
04186         tmpShape = self.FindShape(pt[0],pt[1])
04187         if tmpShape != 0:
04188             tmpShape[0].parent.ref_stop()
04189 
04190     def OnPopupReset(self, evt):
04191         pt = self.pt
04192         tmpShape = self.FindShape(pt[0],pt[1])
04193         if tmpShape != 0:
04194             tmpShape[0].parent.ref_reset()
04195 
04196     def OnPopupExit(self, evt):
04197         pt = self.pt
04198         tmpShape = self.FindShape(pt[0],pt[1])
04199         if tmpShape != 0:
04200             tmpShape[0].parent.ref_exit()
04201 
04202     def OnPopupKill(self, evt):
04203         pt = self.pt
04204         tmpShape = self.FindShape(pt[0],pt[1])
04205         if tmpShape != 0:
04206             tmpShape[0].parent.ref_kill()
04207 
04208     def OnPopupDelete(self, evt):
04209         """����ݡ��ͥ�����Τκ����Ԥ����٥�ȥϥ�ɥ�
04210 
04211         [����]
04212         evt    --  ���٥��(wx.CommandEvent)
04213 
04214         [�����]
04215         void
04216         """
04217         canvas = self.diagram.GetCanvas()
04218         dc = wx.ClientDC(self)
04219         canvas.PrepareDC(dc)
04220         pt = self.pt
04221         tmpShape = self.FindShape(pt[0],pt[1])
04222         if tmpShape != 0:
04223             tmpShape[0].parent.removeWidget(dc)
04224 
04225 #            rtc_name = tmpShape[0].parent.rtc.ref_key
04226             rtc_name = tmpShape[0].parent.fullpath
04227             del self.rtc_dict[rtc_name]
04228             tmp = self.rtc_list.index(rtc_name)
04229             del self.rtc_list[tmp]
04230 
04231             for obj in canvas.selected:
04232                 if obj == tmpShape[0]:
04233                     tmp = canvas.selected.index(tmpShape[0])
04234                     del canvas.selected[tmp]
04235         bdc = getBufferedDC(canvas)
04236         canvas.PrepareDC(bdc)
04237 #        canvas.Redraw(bdc)
04238         canvas.Redraw(dc)
04239 
04240     def OnPopupSub(self, evt):
04241         """���֥�˥塼�μ¸��ѥ��ߡ����٥�ȥϥ�ɥ�
04242 
04243         [����]
04244         evt     --  ���٥��(wx.CommandEvent)
04245 
04246         [�����]
04247         void
04248         """
04249         print "OnPopupSub!!!"
04250 
04251     def OnPopupDelSelectItem(self, evt):
04252         """���򤵤줿�����ƥ�κ����Ԥ����٥�ȥϥ�ɥ�
04253 
04254         [����]
04255         evt    --  ���٥��(wx.CommandEvent)
04256 
04257         [�����]
04258         void
04259         """
04260         self.deleteSelectedShape()
04261 
04262     def OnPopupLoadXML(self, evt):
04263         """XML�ե�����(comp_data.xml)���ɤ߹��।�٥�ȥϥ�ɥ�
04264 
04265         [����]
04266         evt    --  ���٥��(wx.CommandEvent)
04267 
04268         [�����]
04269         void
04270         """
04271         self.loadXML()
04272 
04273     def OnPopupSaveDefaultXML(self, evt):
04274         """XML�ե�����(������֥�)��񤭹��।�٥�ȥϥ�ɥ�
04275         �����¸
04276         �ե�����̾:System?.xml  ������ ? �ˤϲ����ֹ椬����
04277 
04278         [����]
04279         evt    --  ���٥��(wx.CommandEvent)
04280 
04281         [�����]
04282         void
04283         """
04284         filename = "System%d.xml" % self.frame.drawCurNum
04285         self.saveXML(filename)
04286 
04287     def OnPopupSaveXML(self, evt):
04288         """XML�ե�����(������֥�)��񤭹��।�٥�ȥϥ�ɥ�
04289         �ե�����̾�ѹ�����¸
04290         �ե�����̾�ϡ������������ǥ桼��Ǥ�ջ���
04291 
04292         [����]
04293         evt    --  ���٥��(wx.CommandEvent)
04294 
04295         [�����]
04296         void
04297         """
04298         self.saveAsXML()
04299 
04300     def OnPopupRefresh(self, evt):
04301         """Refresh������Ԥ����٥�ȥϥ�ɥ�
04302         �Ť���³(����ݡ��ͥ�Ⱦ�ˤ���subuscribe���󤬤��롣���̤�����ɽ������Ƥ��ʤ�����)��
04303         ����Ȥ��ˡ�ok/cancel������������ɽ����������³�Ⱥǿ��Υ��ơ������ǿ����ѹ�����
04304 
04305         [����]
04306         evt    --  ���٥��(wx.CommandEvent)
04307 
04308         [�����]
04309         void
04310         """
04311         canvas = self.diagram.GetCanvas()
04312         # yes/no dialog
04313         val = self.DelOldConnectAskDialog()
04314         if val != wx.ID_OK:
04315             return
04316 
04317         self.refresh()
04318         self.reConnect()
04319 
04320     def checkOtherConnect(self):
04321         ret = False
04322         for rtc_name in self.rtc_list:
04323             ret = self.rtc_dict[rtc_name].checkOtherConnect()
04324             if ret == True:
04325                 break
04326         return ret
04327 
04328     def askDialog(self, str):
04329         """������������ɽ����ǽ
04330         ok/cancel ������������ɽ������
04331 
04332         [����]
04333         str  ---  ������������ɽ�������å�����
04334 
04335         [�����]
04336         val  ---  �����������������(wx.ID_OK/wx.ID_CANCEL)
04337         void
04338         """
04339 
04340         # yes/no dialog
04341         val = wx.ID_OK
04342         dlg = RtmDialog(self, -1, str)
04343         dlg.CenterOnParent()
04344         val = dlg.ShowModal()
04345         dlg.Destroy()
04346 
04347         return val
04348 
04349     def DelOldConnectAskDialog(self):
04350         """������������ɽ����ǽ
04351         �Ť���³(����ݡ��ͥ�Ⱦ��subscribe���󤬤�����̾�ˤ�����ɽ������Ƥ��ʤ�)������С�
04352         ok/cancel ������������ɽ������
04353 
04354         [����]
04355         �ʤ�
04356 
04357         [�����]
04358         val  ---  �����������������(wx.ID_OK/wx.ID_CANCEL)
04359                   �Ť����󤬤ʤ����ϡ�wx.ID_OK���֤�
04360         void
04361         """
04362 # assembly dummy
04363 #        return wx.ID_OK
04364 # assembly dummy
04365         # yes/no dialog
04366         val = wx.ID_OK
04367         connect_flag = self.checkOtherConnect()
04368         if connect_flag == True:
04369             val = askDialog(strASKMESSAGE)
04370         return val
04371 
04372     def OnPopupConnectView(self, evt):
04373         """Connect��˥塼�ν�����Ԥ����٥�ȥϥ�ɥ�
04374         ������֥�ե������ɤ߹��߸����³��subscribe�˽���
04375 
04376         [����]
04377         evt    --  ���٥��(wx.CommandEvent)
04378 
04379         [�����]
04380         void
04381         """
04382         canvas = self.diagram.GetCanvas()
04383         # yes/no dialog
04384         val = self.DelOldConnectAskDialog()
04385         if val != wx.ID_OK:
04386             return
04387 
04388         canvas.viewMode = False
04389         self.refresh()
04390         self.reConnect()
04391 
04392     def OnPopupDeleteView(self, evt):
04393         """Delete��˥塼�ν�����Ԥ����٥�ȥϥ�ɥ�
04394         ������֥�ե������ɤ߹��߸��ɽ�����������������
04395 
04396         [����]
04397         evt    --  ���٥��(wx.CommandEvent)
04398 
04399         [�����]
04400         void
04401         """
04402         self.deleteAllShape()
04403         canvas = self.diagram.GetCanvas()
04404         canvas.viewMode = False
04405 
04406     def makeBodyPopupMenu(self, evt):
04407         """����ݡ��ͥ�Ⱦ�Υݥåץ��åץ�˥塼�ʥ���ƥ����ȥ�˥塼�˺���
04408         ����ݡ��ͥ�ȿ޷����Τ�On/Off��������˥塼ɽ��
04409 
04410         [����]
04411         evt     --  ���٥��(wx.MouseEvent)�����
04412 
04413         [�����]
04414         void
04415         """
04416         # ��˥塼��Ϣ�Υ��٥�Ȥ�CommandEvent�ǡ��ޥ������������ɸ���������ʤ�
04417         # �����Ǥϡ���ɸ��self.pt�˳�Ǽ��ľ��Υ�˥塼���٥�Ȥǻ��Ѥ���
04418         self.pt = evt.GetPosition()
04419         if not hasattr(self, "popupID1"):
04420             self.popupID1 = wx.NewId()         # start menu
04421             self.popupID2 = wx.NewId()         # stop menu
04422             self.popupID3 = wx.NewId()         # delete menu
04423             self.popupID4 = wx.NewId()         # reset menu
04424             self.popupID5 = wx.NewId()         # exit menu
04425             self.popupID6 = wx.NewId()         # kill menu
04426 
04427             self.Bind(wx.EVT_MENU, self.OnPopupStart, id = self.popupID1)
04428             self.Bind(wx.EVT_MENU, self.OnPopupStop, id = self.popupID2)
04429             self.Bind(wx.EVT_MENU, self.OnPopupDelete, id = self.popupID3)
04430             self.Bind(wx.EVT_MENU, self.OnPopupReset, id = self.popupID4)
04431             self.Bind(wx.EVT_MENU, self.OnPopupExit, id = self.popupID5)
04432             self.Bind(wx.EVT_MENU, self.OnPopupKill, id = self.popupID6)
04433 
04434 
04435         menu = wx.Menu()
04436         menu.Append(self.popupID1, strSTART)
04437         menu.Append(self.popupID2, strSTOP)
04438         menu.Append(self.popupID4, strRESET)
04439         menu.Append(self.popupID5, strEXIT)
04440         menu.Append(self.popupID6, strKILL)
04441         menu.AppendSeparator()
04442         menu.Append(self.popupID3, strDELITEM)
04443 
04444         self.PopupMenu(menu, evt.GetPosition())
04445         menu.Destroy()
04446 
04447     def makeBackgroundPopupMenu(self, evt ):
04448         """�Хå������ɾ�Υݥåץ��åץ�˥塼�ʥ���ƥ����ȥ�˥塼�˺���
04449         ����������ɡ������֤Υ�˥塼ɽ��
04450 
04451         [����]
04452         evt     --  ���٥��(wx.MouseEvent)�����
04453 
04454         [�����]
04455         void
04456         """
04457         # ��˥塼��Ϣ�Υ��٥�Ȥ�CommandEvent�ǡ��ޥ������������ɸ���������ʤ�
04458         # �����Ǥϡ���ɸ��self.pt�˳�Ǽ��ľ��Υ�˥塼���٥�Ȥǻ��Ѥ���
04459         self.pt = evt.GetPosition()
04460         if not hasattr(self, "popupIDa"):
04461             self.popupIDa = wx.NewId()         # selected item delete menu
04462             self.popupIDb = wx.NewId()         # refresh menu
04463             self.popupIDc = wx.NewId()         # xml file load menu
04464             self.popupIDd = wx.NewId()         # xml file save menu
04465             self.popupIDe = wx.NewId()         # xml file save as menu
04466 
04467             self.Bind(wx.EVT_MENU, self.OnPopupDelSelectItem,id = self.popupIDa)
04468             self.Bind(wx.EVT_MENU, self.OnPopupRefresh, id = self.popupIDb)
04469             self.Bind(wx.EVT_MENU, self.OnPopupLoadXML, id = self.popupIDc)
04470             self.Bind(wx.EVT_MENU, self.OnPopupSaveDefaultXML, id = self.popupIDd)
04471             self.Bind(wx.EVT_MENU, self.OnPopupSaveXML, id = self.popupIDe)
04472 
04473         menu = wx.Menu()
04474         menu.Append(self.popupIDa, strDEL_SELECT)
04475         menu.AppendSeparator()
04476         menu.Append(self.popupIDb, strREFRESH)
04477         menu.AppendSeparator()
04478         menu.Append(self.popupIDc, strOPEN) 
04479         menu.Append(self.popupIDd, strSAVE) 
04480         menu.Append(self.popupIDe, strSAVE_AS) 
04481 # assembly disable
04482 #        menu.FindItemById(self.popupIDc).Enable(False)
04483 #        menu.FindItemById(self.popupIDd).Enable(False)
04484 #        menu.FindItemById(self.popupIDe).Enable(False)
04485 # assembly disable
04486 
04487 
04488         self.PopupMenu(menu, evt.GetPosition())
04489         menu.Destroy()
04490 
04491     def makeViewModePopupMenu(self, evt ):
04492         """�Хå������ɾ�Υݥåץ��åץ�˥塼�ʥ���ƥ����ȥ�˥塼�˺���
04493         Connect��Delete �Υ�˥塼ɽ��
04494 
04495         [����]
04496         evt     --  ���٥��(wx.MouseEvent)�����
04497 
04498         [�����]
04499         void
04500         """
04501         # ��˥塼��Ϣ�Υ��٥�Ȥ�CommandEvent�ǡ��ޥ������������ɸ���������ʤ�
04502         # �����Ǥϡ���ɸ��self.pt�˳�Ǽ��ľ��Υ�˥塼���٥�Ȥǻ��Ѥ���
04503         self.pt = evt.GetPosition()
04504         if not hasattr(self, "popupID01"):
04505             self.popupID01 = wx.NewId()         # selected item delete menu
04506             self.popupID02 = wx.NewId()         # xml file load menu
04507 
04508             self.Bind(wx.EVT_MENU, self.OnPopupConnectView,id = self.popupID01)
04509             self.Bind(wx.EVT_MENU, self.OnPopupDeleteView, id = self.popupID02)
04510 
04511         menu = wx.Menu()
04512         menu.Append(self.popupID01, strASM_CONNECT)
04513         menu.AppendSeparator()
04514         menu.Append(self.popupID02, strASM_DELETE)
04515 
04516         self.PopupMenu(menu, evt.GetPosition())
04517         menu.Destroy()
04518 
04519     def OnRightDown(self, evt):
04520         """������å���������Υ��٥�ȥϥ�ɥ�
04521         �ޥ����������뤬Inport/Outport����ȡ��ġ�����åסʥХ롼��إ�סˤ�ɽ����Ԥ�
04522         ����ݡ��ͥ�����ξ�Ǥϡ��ݥåץ��åץ�˥塼��ɽ����Ԥ�
04523 
04524         [����]
04525         evt     -- ���٥��
04526 
04527         [�����]
04528         void
04529         """
04530         self.log.write("OnRightDown")
04531         canvas = self.diagram.GetCanvas()
04532         dc = wx.ClientDC(self)
04533         canvas.PrepareDC(dc)
04534         pt = evt.GetPosition()
04535         tmpShape = self.FindShape(pt[0],pt[1])
04536         if tmpShape != 0:
04537             if hasattr(tmpShape[0], 'parent'):
04538                 # Inport/Outport���
04539                 if tmpShape[0].parent.tag == 'in' or tmpShape[0].parent.tag == 'out':
04540                     # �ġ�����åפκ���
04541                     self.tooltip = makeToolTip(tmpShape[0].parent,pt,dc)
04542 
04543                     self.tooltip.body.SetCanvas(canvas)
04544                     self.diagram.AddShape(self.tooltip.body)
04545                     self.tooltip.body.Show(True)
04546                 # ����ݡ��ͥ�����Τν���
04547                 elif tmpShape[0].parent.tag == 'body' and canvas.viewMode == False:
04548                     self.makeBodyPopupMenu(evt)
04549         else:
04550             if canvas.viewMode == False:
04551                 self.makeBackgroundPopupMenu(evt)
04552             else:
04553                 self.makeViewModePopupMenu(evt)
04554 
04555         canvas.Redraw(dc)
04556         evt.Skip()
04557 
04558     def OnRightUp(self, evt):
04559         """������å������åפΥ��٥�ȥϥ�ɥ�
04560         �ġ�����åסʥХ롼��إ�סˤκ����Ԥ�
04561 
04562         [����]
04563         evt     -- ���٥��
04564 
04565         [�����]
04566         void
04567         """
04568         self.log.write("OnRightUp")
04569         canvas = self.diagram.GetCanvas()
04570         dc = wx.ClientDC(self)
04571         canvas.PrepareDC(dc)
04572         pt = evt.GetPosition()
04573         if self.tooltip != None:
04574             # �ġ�����åפκ��
04575             self.tooltip.removeWidget(dc)
04576             del self.tooltip
04577             self.tooltip = None
04578         canvas.Redraw(dc)
04579         evt.Skip()
04580 
04581     def OnLeftDown(self, evt):
04582         """������å���������Υ��٥�ȥϥ�ɥ�
04583         �����Х���ο޷����ʤ����֤Ǻ�����å����줿��޷������������
04584 
04585         [����]
04586         evt     -- ���٥��
04587 
04588         [�����]
04589         void
04590         """
04591         pt = evt.GetPosition()
04592         tmpShape = self.FindShape(pt[0],pt[1])
04593         if tmpShape == 0:
04594             canvas = self.diagram.GetCanvas()
04595             dc = wx.ClientDC(self)
04596             canvas.PrepareDC(dc)
04597             for s in canvas.selected:
04598                 s.Select(False, dc)
04599                 s.parent.unselected(dc)
04600             canvas.selected = []
04601             canvas.Redraw(dc)
04602         else:
04603             evt.Skip()
04604 
04605     def OnMiddleDown(self, evt):
04606         """�ޥ�����ܥ��󡦥�����Υ��٥�ȥϥ�ɥ�
04607         ����ݡ��ͥ�ȿ޷������ξ�Dz����줿�顢��ž������Ԥ�
04608 
04609         [����]
04610         evt   -- ���٥��
04611 
04612         [�����]
04613         void
04614         """
04615         pt = evt.GetPosition()
04616         isShift = evt.ShiftDown()
04617         canvas = self.diagram.GetCanvas()
04618         dc = wx.ClientDC(self)
04619         canvas.PrepareDC(dc)
04620         for s in canvas.selected:
04621             s.Select(False, dc)
04622             s.parent.unselected(dc)
04623         canvas.selected = []
04624         canvas.Redraw(dc)
04625 
04626         tmpShape = self.FindShape(pt[0],pt[1])
04627         if tmpShape != 0 and tmpShape[0].parent.tag == 'body' and isShift != True:  ## Middle Button
04628             self.log.write("OnMiddleDown: " )
04629             tmpShape[0].parent.reversesBody()
04630         elif tmpShape != 0 and tmpShape[0].parent.tag == 'body' and isShift == True:  ## Shift Key Down & Middle Button
04631             self.log.write("OnMiddleDown + Shift Key: " )
04632             tmpShape[0].parent.rotatesBody()
04633         else:
04634             evt.Skip()
04635 
04636         canvas.Redraw(dc)
04637         
04638 #----------------------------------------------------------------------
04639 
04640 def runTest(frame, nb, log):
04641     # This creates some pens and brushes that the OGL library uses.
04642     # It should be called after the app object has been created, but
04643     # before OGL is used.
04644     ogl.OGLInitialize()
04645     wx.lib.colourdb.updateColourDB()
04646     win = TestWindow(nb, log, frame)
04647 
04648     return win
04649     
04650 #----------------------------------------------------------------------
04651 
04652 # The OGL library holds some resources that need to be freed before
04653 # the app shuts down.
04654 class __Cleanup:
04655     def __del__(self, cleanup=ogl.OGLCleanUp):
04656         cleanup()
04657 
04658 # When this module gets cleaned up by Python then __cu will be cleaned
04659 # up and it's __dell__ is called, which will then call ogl.OGLCleanUp.
04660 __cu = __Cleanup()
04661 
04662 
04663 overview = """\
04664 The Object Graphics Library is a library supporting the creation and
04665 manipulation of simple and complex graphic images on a canvas.
04666 
04667 """
04668 
04669 if __name__ == '__main__':
04670     import sys,os
04671     import run
04672     run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
04673 


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