コード例 #1
0
ファイル: gears.py プロジェクト: yihongfa/bokeh
def classical_gear(module, large_teeth, small_teeth):
    xdr = Range1d(start=-300, end=150)
    ydr = Range1d(start=-100, end=100)

    plot = Plot(title=None,
                x_range=xdr,
                y_range=ydr,
                plot_width=800,
                plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

    radius = pitch_radius(module, large_teeth)
    angle = 0
    glyph = Gear(x=-radius,
                 y=0,
                 module=module,
                 teeth=large_teeth,
                 angle=angle,
                 fill_color=fill_color[0],
                 line_color=line_color)
    plot.add_glyph(glyph)

    radius = pitch_radius(module, small_teeth)
    angle = half_tooth(small_teeth)
    glyph = Gear(x=radius,
                 y=0,
                 module=module,
                 teeth=small_teeth,
                 angle=angle,
                 fill_color=fill_color[1],
                 line_color=line_color)
    plot.add_glyph(glyph)

    return plot
コード例 #2
0
def epicyclic_gear(module, sun_teeth, planet_teeth):
    xdr = Range1d(start=-150, end=150)
    ydr = Range1d(start=-150, end=150)

    plot = Plot(title=None,
                x_range=xdr,
                y_range=ydr,
                plot_width=300,
                plot_height=300,
                h_symmetry=False,
                v_symmetry=False,
                min_border=0,
                toolbar_location=None)

    annulus_teeth = sun_teeth + 2 * planet_teeth

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=annulus_teeth,
                 angle=0,
                 fill_color=fill_color[0],
                 line_color=line_color,
                 internal=True)
    plot.add_glyph(glyph)

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=sun_teeth,
                 angle=0,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(glyph)

    sun_radius = pitch_radius(module, sun_teeth)
    planet_radius = pitch_radius(module, planet_teeth)

    radius = sun_radius + planet_radius
    angle = half_tooth(planet_teeth)

    for i, j in [(+1, 0), (0, +1), (-1, 0), (0, -1)]:
        glyph = Gear(x=radius * i,
                     y=radius * j,
                     module=module,
                     teeth=planet_teeth,
                     angle=angle,
                     fill_color=fill_color[1],
                     line_color=line_color)
        plot.add_glyph(glyph)

    return plot
コード例 #3
0
ファイル: gears.py プロジェクト: xuexianwu/bokeh
def epicyclic_gear(module, sun_teeth, planet_teeth):
    xdr = Range1d(start=-150, end=150)
    ydr = Range1d(start=-150, end=150)

    source = ColumnDataSource(data=dict(dummy=[0]))
    plot = Plot(title=None,
                x_range=xdr,
                y_range=ydr,
                plot_width=800,
                plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

    annulus_teeth = sun_teeth + 2 * planet_teeth

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=annulus_teeth,
                 angle=0,
                 fill_color=fill_color[0],
                 line_color=line_color,
                 internal=True)
    plot.add_glyph(source, glyph)

    glyph = Gear(x=0,
                 y=0,
                 module=module,
                 teeth=sun_teeth,
                 angle=0,
                 fill_color=fill_color[2],
                 line_color=line_color)
    plot.add_glyph(source, glyph)

    sun_radius = pitch_radius(module, sun_teeth)
    planet_radius = pitch_radius(module, planet_teeth)

    radius = sun_radius + planet_radius
    angle = half_tooth(planet_teeth)

    for i, j in [(+1, 0), (0, +1), (-1, 0), (0, -1)]:
        glyph = Gear(x=radius * i,
                     y=radius * j,
                     module=module,
                     teeth=planet_teeth,
                     angle=angle,
                     fill_color=fill_color[1],
                     line_color=line_color)
        plot.add_glyph(source, glyph)

    return plot
コード例 #4
0
ファイル: gears.py プロジェクト: tommycarpi/py-tracy
def sample_gear():
    xdr = Range1d(start=-30, end=30)
    ydr = Range1d(start=-30, end=30)

    plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=800, plot_height=800)
    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

    glyph = Gear(x=0, y=0, module=5, teeth=8, angle=0, shaft_size=0.2, fill_color=fill_color[2], line_color=line_color)
    plot.add_glyph(glyph)

    return plot
コード例 #5
0
def test_Gear():
    glyph = Gear()
    assert glyph.x == "x"
    assert glyph.y == "y"
    assert glyph.angle == 0
    assert glyph.module == "module"
    assert glyph.teeth == "teeth"
    assert glyph.pressure_angle == 20
    assert glyph.shaft_size == 0.3
    assert glyph.internal == False
    yield check_fill, glyph
    yield check_line, glyph
    yield check_props, glyph, [
        "x", "y", "angle", "module", "teeth", "pressure_angle", "shaft_size",
        "internal"
    ], FILL, LINE
コード例 #6
0
def test_Gear():
    glyph = Gear()
    assert glyph.x is None
    assert glyph.y is None
    assert glyph.angle == 0
    assert glyph.module is None
    assert glyph.teeth is None
    assert glyph.pressure_angle == 20
    assert glyph.shaft_size == 0.3
    assert glyph.internal == False
    yield check_fill_properties, glyph
    yield check_line_properties, glyph
    yield (check_properties_existence, glyph, [
        "x",
        "y",
        "angle",
        "angle_units",
        "module",
        "teeth",
        "pressure_angle",
        "shaft_size",
        "internal",
    ], FILL, LINE, GLYPH)
コード例 #7
0
ファイル: glyphs.py プロジェクト: PhilWa/bokeh-1
 ("bezier",
  Bezier(x0="x",
         y0="y",
         x1="xp02",
         y1="y",
         cx0="xp01",
         cy0="yp01",
         cx1="xm01",
         cy1="ym01",
         line_color="#D95F02",
         line_width=2)),
 ("gear",
  Gear(x="x",
       y="y",
       module=0.1,
       teeth=8,
       angle=0,
       shaft_size=0.02,
       fill_color="#FDF6E3",
       line_color="#D95F02")),
 ("image_url",
  ImageURL(
      x="x",
      y="y",
      w=0.4,
      h=0.4,
      url=dict(
          value="http://bokeh.pydata.org/en/latest/_static/images/logo.png"
      ),
      anchor="center")),
 ("line", Line(x="x", y="y", line_color="#F46D43")),
 ("multi_line",