Ejemplo n.º 1
0
    def update(self):
        if self.cameoType in (self.normal, self.connection):
            if self.cameoType == self.normal:
                xsandys = self.parent.xsandys
            else:
                xsandys = self.parent.xsandys()

            self.canvas.coords(
                self.handle, DiagMaths.constrain(xsandys,
                                                     self.parentDrawing.capsule.outline,
                                                     self.childAvatar.outline))
        elif self.cameoType == self.twolines:
            sx,sy,ex,ey = self.parent.outline
            handleTop,handleBottom = self.handle
            self.canvas.coords(
                handleTop, DiagMaths.constrain((sx,sy,ex,sy),
                                                 self.parentDrawing.capsule.outline,
                                                 self.childAvatar.outline))
            self.canvas.coords(
                handleBottom, DiagMaths.constrain((sx,ey,ex,ey),
                                                 self.parentDrawing.capsule.outline,
                                                 self.childAvatar.outline))
            
        else:
            raise "run time bug : wrong cameo type"
Ejemplo n.º 2
0
 def drawCameoPS(self, canvas, parentDrawing, childAvatar,psfile):
     capOutline=parentDrawing.capsule.outline
     constraints=childAvatar.outline
     outline = DiagMaths.constrain(self.xsandys,capOutline,constraints)
     cx, cy = DiagMaths.middle(outline)
     xr = cx - outline[0]
     yr = cy - outline[1]
     ovality = float(yr) / xr
     psfile.write("%s %s %s %s oval\n" % (ovality, xr, cx, cy))
Ejemplo n.º 3
0
    def drawCameoPS(self, canvas, parentDrawing, childAvatar,psfile):
        sx,sy,ex,ey = self.outline        
        capOutline=parentDrawing.capsule.outline
        constraints=childAvatar.outline

        psfile.write("newpath %s %s moveto %s %s lineto stroke\n" % tuple(
            DiagMaths.constrain((sx,sy,ex,sy),capOutline,constraints)))

        psfile.write("newpath %s %s moveto %s %s lineto stroke\n" % tuple(
            DiagMaths.constrain((sx,ey,ex,ey),capOutline,constraints)))
Ejemplo n.º 4
0
 def calcAdditionalShift(self,dx,dy, endAvatar, adx, ady):
     if endAvatar == self.fromPort:
         startAvatar = self.toPort
     else:
         startAvatar = self.fromPort
     samx,samy = startAvatar.middle()
     eamx,eamy = endAvatar.middle()
     # return how much the middle has moved by
     nmx,nmy = DiagMaths.middle((samx,samy,eamx,eamy))
     omx,omy = DiagMaths.middle((samx,samy,eamx-adx,eamy-ady))
     return nmx-omx,nmy-omy
Ejemplo n.º 5
0
 def drawCameo(self, canvas, parentDrawing, childAvatar,cameos):
     sx,sy,ex,ey = self.outline        
     capOutline=parentDrawing.capsule.outline
     constraints=childAvatar.outline
     cameos.append(Cameo(canvas,self,
                         parentDrawing, childAvatar,                            
                         (canvas.create_line(
         DiagMaths.constrain((sx,sy,ex,sy),capOutline,constraints)),
                          canvas.create_line(
         DiagMaths.constrain((sx,ey,ex,ey),capOutline,constraints))),
                         cameoType=Cameo.twolines))
Ejemplo n.º 6
0
 def shapeEdge(self, point):
     x,y = point
     sx,sy,ex,ey = self.outline
     cx, cy =  self.middle()
     rx = ex - cx
     ry = ey - cy
     return  DiagMaths.findEdgeOval(cx,cy,rx,ry,x,y)
Ejemplo n.º 7
0
 def arrowCoords(self):
     mx,my = self.middle()
     vx,vy = DiagMaths.Vector(self.toPort, self.fromPort)
     xoff = connLabelArrowLen*vx
     yoff = connLabelArrowLen*vy        
     sx,sy = self.shapeEdge((mx+xoff, my+yoff))
     return (sx,sy,sx+xoff,sy+yoff)
Ejemplo n.º 8
0
 def drawCameoPS(self, canvas, parentDrawing, childAvatar,psfile):
     capOutline=parentDrawing.capsule.outline
     constraints=childAvatar.outline
     outline = DiagMaths.constrain(self.xsandys,capOutline,constraints)
     psfile.write("gsave %s setrgbcolor\n" % PSUtils.makeColor(self.avatarColor()))
     psfile.write("%s %s %s %s square\n" % tuple(outline))
     psfile.write("grestore\n")        
Ejemplo n.º 9
0
 def drawCameo(self, canvas, parentDrawing, childAvatar,cameos):
     capOutline=parentDrawing.capsule.outline
     constraints=childAvatar.outline
     cameos.append(Cameo(canvas, self,
                         parentDrawing, childAvatar,
                         canvas.create_rectangle(DiagMaths.constrain(self.xsandys,capOutline,constraints),
                                                 outline=self.avatarColor())))
Ejemplo n.º 10
0
 def drawCameo(self, canvas, parentDrawing, childAvatar,cameos):
     capOutline=parentDrawing.capsule.outline
     constraints=childAvatar.outline
     cameos.append(Cameo(canvas, self,
                         parentDrawing, childAvatar,
                         canvas.create_polygon(DiagMaths.constrain(
         self.xsandys,capOutline,constraints),smooth=1,fill="white",outline="black")))
Ejemplo n.º 11
0
def createCameoConnectionsPS(drawing, parentDrawing, childAvatar, psfile):
    capOutline = parentDrawing.capsule.outline
    constraints = childAvatar.outline
    for connection in parentDrawing.connections:
        outline = DiagMaths.constrain(connection.xsandys(), capOutline,
                                      constraints)
        psfile.write(
            "gsave %s setrgbcolor newpath %s 1 5 7 arrow stroke grestore\n" %
            (connection.setPSColor(), PSUtils.arrayAsString(outline)))
Ejemplo n.º 12
0
 def getHotSpot(self,x,y):
     sx,sy,ex,ey = self.outline
     hc = hotCorner
     for section, coords in (("TOPLEFT", (sx,sy,sx+hc,sy+hc)),
                             ("TOPRIGHT", (ex-hc,sy,ex,sy+hc)),
                             ("BOTTOMLEFT", (sx,ey-hc,sx+hc,ey)),
                             ("BOTTOMRIGHT", (ex-hc,ey-hc,ex,ey))):
         if DiagMaths.isUnder(x,y,coords):
             return section,coords # tbd maybe return a polygon outline to light up
     return None,None
Ejemplo n.º 13
0
 def addLabel(self, connLabels):
     import Avatars
     x, y = DiagMaths.middle(self.xsandys())
     cl = Avatars.ConnLabel(
         "*SendsMessageLabel*" + self.start.name + "*" + self.end.name +
         "*" + self.message, None)
     cl.create(x, y)
     cl.setPorts(self.start, self.end)
     cl.setWords([self.message])
     connLabels.append(cl)
     self.labels.append(cl)
Ejemplo n.º 14
0
 def arrowCoords(self):
     mx,my = self.middle()
     vx,vy = DiagMaths.Vector(self, self.port)
     xoff = connLabelArrowLen*vx*self.dir
     yoff = connLabelArrowLen*vy*self.dir
     if(abs(xoff)) > (abs(yoff)):
         yoff = 0
     else:
         xoff = 0
     sx,sy = self.shapeEdge((mx+xoff, my+yoff))
     return (sx,sy,sx+xoff,sy+yoff)
Ejemplo n.º 15
0
 def HighlightValue(self,newValue):
     global highlightValueMaxLen
     if not self.visited:
         self.visited = self.canvas.create_rectangle(DiagMaths.inset(self.outline,-5),outline=Colors.visited, width=2)
     if self.debugValue:
         self.canvas.delete(self.debugValue)
     mx, my = self.middleUpper()
     highlightValueMaxLen = Options.options.highlightValueMaxLen or highlightValueMaxLen
     if len(newValue) > highlightValueMaxLen:
         newValue = newValue[0:highlightValueMaxLen-3] + "..."
     self.debugValue = self.canvas.create_text(mx,my,newValue,("times",15))
Ejemplo n.º 16
0
    def addLabel(self, connLabels):
        import Avatars
        # one for each direction
        x, y = DiagMaths.middle(self.xsandys())
        for a, b in ((self.start, self.end), (self.end, self.start)):
            cl = Avatars.ConnLabel("*ConLabel" + a.name + "*" + b.name, None)
            cl.create(x, y)
            cl.setPorts(a, b)

            cl.setWords(a.getMessagesFor(b))
            connLabels.append(cl)
            self.labels.append(cl)
Ejemplo n.º 17
0
 def addLabel(self, connLabels):
     import Avatars
     if self.end.avatarType() in ["Port", "ChildPort"]:
         cl = Avatars.ConnLabel(
             "*CallLabel*" + self.start.name + "*" +
             string.join(self.message, "."), None)
         x, y = DiagMaths.middle(self.xsandys())
         cl.create(x, y)
         cl.setPorts(self.start, self.end)
         cl.setWords([self.message[-1]])
         connLabels.append(cl)
         self.labels.append(cl)
Ejemplo n.º 18
0
 def draw(self):
     self.drawTitle()
     sx,sy,ex,ey = self.canvas.bbox(self.title)
     bb = self.canvas.bbox(self.title)
     width = ex - sx
     #print "set width to ", width
     #self.xsandys = bb
     self.setOutline(DiagMaths.fattenUp(bb,10))
     #self.xsandys[2] = ex
     self.canvas.delete(self.title)
     self.shapeDraw(fill=Colors.cancolor,outline=self.avatarColor())
     self.drawTitle()
Ejemplo n.º 19
0
 def addLabel(self, connLabels):
     import Avatars
     x, y = DiagMaths.middle(self.xsandys())
     cl = Avatars.ConnLabel(
         "*MsgMsgLabel*" + self.startMessage + "*" + self.endMessage, None)
     cl.create(x, y)
     cl.setPorts(self.start, self.end)
     if self.end.avatarType() in ["Port", "ChildPort"]:
         end = " -> %s" % self.endMessage
     else:
         end = ""
     cl.setWords(["%s%s" % (self.startMessage, end)])
     connLabels.append(cl)
     self.labels.append(cl)
Ejemplo n.º 20
0
def createCameoConnections(drawing, parentDrawing, childAvatar):
    import Avatars
    cameos = []
    capOutline = parentDrawing.capsule.outline
    constraints = childAvatar.outline
    for connection in parentDrawing.connections:
        if connection.__class__.__name__ == "ConnectPortConnection":
            arrows = connection.calcArrow()
        else:
            arrows = "last"
        cameos.append(
            Avatars.Cameo(drawing,
                          connection,
                          parentDrawing,
                          childAvatar,
                          drawing.create_line(DiagMaths.constrain(
                              connection.xsandys(), capOutline, constraints),
                                              arrow=arrows,
                                              fill=connection.getColor()),
                          cameoType=Avatars.Cameo.connection))
    return cameos
Ejemplo n.º 21
0
 def getPov(self, povFile):
     povFile.write('Transition (%s, %s, %s, %s, "%s")\n' % tuple(DiagMaths.flipYCoords(self.outline) + [self.name]))
Ejemplo n.º 22
0
 def getPov(self,f):
     cx,cy = self.middle()
     r = cx - self.outline[0]
     f.write('State(%d,%d,%d,"%s")\n' % (cx,DiagMaths.flipYCoord(cy),r,self.name))
Ejemplo n.º 23
0
 def clockHands(self,clockFace):
     clockMiddlex,clockMiddley = DiagMaths.middle(clockFace)
     twelveOclockx, twelveOclocky = clockMiddlex,clockFace[1] 
     threeOclockx, threeOclocky = clockFace[2] - 4,clockMiddley
     return clockMiddlex, clockMiddley, twelveOclockx, twelveOclocky, threeOclockx, threeOclocky 
Ejemplo n.º 24
0
 def moveAmp(self):
     mx,my = DiagMaths.middle(self.topRightCorner())
     self.canvas.coords(self.amp,(mx,my))
Ejemplo n.º 25
0
 def getPov(self, povFile):
     povFile.write("Port(%s, %s, %s, %s)\n" % tuple(DiagMaths.flipYCoords(self.outline)))
Ejemplo n.º 26
0
 def isInside(self,selectCoords):
     return DiagMaths.isInside(self.outline, selectCoords)
Ejemplo n.º 27
0
 def getPov(self,f):
     cx,cy = self.middle()
     r = cx - self.outline[0]
     f.write("Start(%d,%d,%d)\n" % (cx,DiagMaths.flipYCoord(cy),r))
Ejemplo n.º 28
0
 def getPostscriptAmp(self,psfile):
     mx,my = DiagMaths.middle(self.topRightCorner())
     psfile.write("%s %s moveto (@) showmiddle\n" % (mx,my))         # TBD make the size better
Ejemplo n.º 29
0
 def getPov(self, povFile):
     povFile.write("TransitionProxy(%s, %s, %s, %s)\n" % tuple(DiagMaths.flipYCoords(self.outline)))    
Ejemplo n.º 30
0
 def drawAmp(self):
     mx,my = DiagMaths.middle(self.topRightCorner())
     self.amp = self.canvas.create_text(mx,my,"@",("times", 20))