Esempio n. 1
0
 def on_layout(self, cvs, system):
     Box.on_layout(self, cvs, system)
     Atom.on_layout(self, cvs, system)
     x0 = self.x_top[0]
     x1 = self.x_top[1]
     system.add(x0 == self.llx + (1. / 4) * self.width, weight=self.weight)
     system.add(x1 == self.llx + (3. / 4) * self.width, weight=self.weight)
     system.add(2 * self.height >= x1 - x0)
Esempio n. 2
0
 def on_render(self, cvs, system):
     Box.on_render(self, cvs, system)
     Atom.on_render(self, cvs, system)
     x = system[self.x]
     y = system[self.y]
     top = system[self.top] + PIP
     bot = system[self.bot] + PIP
     x0 = system[self.x_bot[0]]
     #cvs.stroke(path.line(x0, y-bot, x0, y+top), self.attrs)
     cvs.stroke(path.line(x0, y + top, x0, y - bot), self.attrs)
Esempio n. 3
0
    def on_render(self, cvs, system):
        Box.on_render(self, cvs, system)
        Atom.on_render(self, cvs, system)

        y = system[self.y]
        top = system[self.top] + PIP
        bot = system[self.bot]
        y0 = y + top
        x0 = system[self.x_top[0]]
        x1 = system[self.x_top[1]]
        x2 = 0.5 * (x0 + x1)
        radius = 0.5 * (x1 - x0)
        cvs.stroke(path.arc(x2, y0, radius, pi, 0.))
Esempio n. 4
0
    def on_render(self, cvs, system):
        Box.on_render(self, cvs, system)
        Atom.on_render(self, cvs, system)

        y = system[self.y]
        top = system[self.top]
        bot = system[self.bot] + PIP
        y0 = y - bot
        x0 = system[self.x_bot[0]]
        x1 = system[self.x_bot[1]]
        x2 = 0.5 * (x0 + x1)
        radius = 0.5 * (x1 - x0)
        cvs.stroke(path.arc(x2, y0, radius, 0., pi))
Esempio n. 5
0
    def on_render(self, cvs, system):
        Box.on_render(self, cvs, system)
        Atom.on_render(self, cvs, system)

        n = self.n_top + self.n_bot
        if n == 0:
            return

        y = system[self.y]
        top = system[self.top] + PIP
        bot = system[self.bot] + PIP
        y_top = y + top
        y_bot = y - bot
        x_mid, y_mid = self.get_align("center")
        x0, y0 = system[x_mid], system[y_mid]

        x_top = [system[x] for x in self.x_top]
        x_bot = [system[x] for x in self.x_bot]
        x0 = self._get_pipx(x_top, x_bot)

        conv = lambda x0, x1, t: (1. - t) * x0 + t * x1

        top_attrs = self.top_attrs
        bot_attrs = self.bot_attrs

        trace = self.trace
        trace["top"] = []
        trace["bot"] = []

        y3 = y_top
        for x3, attrs in zip(x_top, top_attrs):
            x2, y2 = x3, conv(y3, y0, 0.3)
            x1, y1 = conv(x0, x3, 0.7), conv(y3, y0, 0.7)
            p = path.curve(x3, y3, x2, y2, x1, y1, x0, y0)
            trace["top"].append(p)
            cvs.stroke(p, attrs)

        y3 = y_bot
        for x3, attrs in zip(x_bot, bot_attrs):
            x2, y2 = x3, conv(y3, y0, 0.3)
            x1, y1 = conv(x0, x3, 0.7), conv(y3, y0, 0.7)
            p = path.curve(x0, y0, x1, y1, x2, y2, x3, y3)
            trace["bot"].append(p)
            cvs.stroke(p, attrs)

        #cvs.fill(path.circle(x0, y0, 0.04))
        if self.pip is not None:
            self.pip.render(cvs, x0, y0)
Esempio n. 6
0
 def __init__(self, *args, **kw):
     Multi.__init__(self, *args, **kw)
     pip = kw.get("pip")
     if pip is not None:
         pip_align = kw.get("pip_align")
         pip = Box.promote(pip, pip_align)
     self.pip = pip
     self.trace = {}
Esempio n. 7
0
    def on_layout(self, cvs, system):
        Box.on_layout(self, cvs, system)
        Atom.on_layout(self, cvs, system)

        width = self.width
        llx = self.llx

        n_top = self.n_top
        x_top = self.x_top
        if n_top > 0:
            dx = width / (2 * n_top)
            x = llx + dx
            for i in range(n_top):
                system.add(x_top[i] == x, weight=self.weight)
                x += 2 * dx

        n_bot = self.n_bot
        x_bot = self.x_bot
        if n_bot > 0:
            dx = width / (2 * n_bot)
            x = llx + dx
            for i in range(n_bot):
                system.add(x_bot[i] == x, weight=self.weight)
                x += 2 * dx
Esempio n. 8
0
 def on_render(self, cvs, system):
     Box.on_render(self, cvs, system)
     Atom.on_render(self, cvs, system)
Esempio n. 9
0
 def on_layout(self, cvs, system):
     Box.on_layout(self, cvs, system)
     Atom.on_layout(self, cvs, system)
     system.add(self.x_bot[0] == self.x_top[0])
     x = 0.5 * (self.llx + self.urx)
     system.add(self.x_bot[0] == x, 1.0)