Hans Petter Langtangen 13 роки тому
батько
коміт
b54df4331f

+ 9 - 5
doc/src/sketcher/src-sketcher/beam2.py

@@ -15,9 +15,13 @@ drawing_tool.set_linecolor('blue')
 
 fontsize=16
 A = point(xpos,ypos)
-main = Rectangle(A, L, H)
+
+beam = Rectangle(A, L, H)
+
 h = L/16  # size of support, clamped wall etc
-clamped = Rectangle(A - point(h,0) - point(0,2*h), h, 6*h).set_filled_curves(pattern='/')
+
+clamped = Rectangle(A - point(h,0) - point(0,2*h), h,
+                    6*h).set_filled_curves(pattern='/')
 
 load = ConstantBeamLoad(A + point(0,H), L, H)
 load.set_linewidth(1).set_linecolor('black')
@@ -61,8 +65,8 @@ axes = Compose({'x axis': x_axis, 'y axis': y_axis})
 
 annotations = Compose({'dims': dims, 'symbols': symbols,
                 'axes': axes})
-beam = Compose({'main': main, 'support': support,
-                'clamped end': clamped, 'load': load})
+fig = Compose({'main': main, 'support': support,
+               'clamped end': clamped, 'load': load})
 
 def deflection(x, a, b, w):
     import numpy as np
@@ -80,7 +84,7 @@ y += ypos + H/2
 
 elastic_line = Curve(x, y).set_linecolor('red').set_linestyle('dashed').set_linewidth(3)
 
-beam.draw()
+fig.draw()
 drawing_tool.display()
 drawing_tool.savefig('tmp_beam2_1.png')
 

+ 6 - 6
doc/src/sketcher/src-sketcher/flow_over_gaussian.py

@@ -20,7 +20,7 @@ def gaussian(x):
 x = linspace(0, W+L)
 y = gaussian(x)
 wall = Wall(x, y, thickness=-0.3, pattern='|').set_linecolor('brown')
-
+wall['eraser'].set_linecolor('white')
 def velprofile(y):
     return [2*y*(2*H-y)/H**2, 0]
 
@@ -42,11 +42,11 @@ fig.draw()  # send all figures to plotting backend
 
 vx, vy = velprofile(H/2.)
 symbols = {
-    'alpha': Distance_wSymbol((W,0), (W,alpha), r'$\alpha$'),
-    'W': Distance_wSymbol((0,-0.5), (W,-0.5), r'$W$',
-                          symbol_spacing=-1./30),
-    'L': Distance_wSymbol((W,-0.5), (W+L,-0.5), r'$L$',
-                          symbol_spacing=-1./30),
+    'alpha': Distance_wText((W,0), (W,alpha), r'$\alpha$'),
+    'W': Distance_wText((0,-0.5), (W,-0.5), r'$W$',
+                          text_spacing=-1./30),
+    'L': Distance_wText((W,-0.5), (W+L,-0.5), r'$L$',
+                          text_spacing=-1./30),
     'v(y)': Text('$v(y)$', (H/2., vx)),
     'dashed line': Line((W-2.5*sigma,0), (W+2.5*sigma,0)).\
                    set_linestyle('dotted').set_linecolor('black'),

+ 8 - 1
pysketcher/shapes.py

@@ -765,7 +765,14 @@ class Wall(Shape):
         y = concatenate((y1, y2[-1::-1]))
         wall = Curve(x, y)
         wall.set_filled_curves(color='white', pattern=pattern)
-        self.shapes = {'wall': wall}
+        x = [x1[-1]] + x2[-1::-1].tolist() + [x1[0]]
+        y = [y1[-1]] + y2[-1::-1].tolist() + [y1[0]]
+        white_eraser = Curve(x, y)
+        white_eraser.set_linecolor('white')
+        from collections import OrderedDict
+        self.shapes = OrderedDict()
+        self.shapes['wall'] = wall
+        self.shapes['eraser'] = white_eraser
 
 
 class VelocityProfile(Shape):