|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
3 | | -##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com) |
| 3 | +##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com) |
4 | 4 | ## |
5 | 5 | ##This file is part of pythonOCC. |
6 | 6 | ## |
|
17 | 17 | ##You should have received a copy of the GNU Lesser General Public License |
18 | 18 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
|
20 | | -from OCC.Display.SimpleGui import * |
21 | | -display, start_display, add_menu, add_function_to_menu = init_display() |
22 | | - |
23 | | -from OCC.Graphic3d import * |
24 | | -from OCC.BRepPrimAPI import * |
25 | | -from OCC.BRepBuilderAPI import * |
26 | | -from OCC.V3d import * |
27 | | -from OCC.Quantity import * |
28 | | -from OCC.gp import * |
29 | | - |
| 20 | +from OCC.Graphic3d import Graphic3d_MaterialAspect, Graphic3d_NOM_SILVER |
| 21 | +from OCC.V3d import V3d_AmbientLight, V3d_SpotLight |
| 22 | +from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder |
| 23 | +from OCC.Quantity import Quantity_NOC_YELLOW, Quantity_NOC_GREEN |
30 | 24 |
|
| 25 | +from OCC.Display.SimpleGui import init_display |
| 26 | +display, start_display, add_menu, add_function_to_menu = init_display() |
31 | 27 | # |
32 | 28 | # Get viewer |
33 | 29 | # |
34 | 30 | viewer_handle = display.GetViewer() |
35 | 31 | viewer = viewer_handle.GetObject() |
36 | | - |
37 | | - |
38 | 32 | # |
39 | 33 | # First remove all lights from current viewer |
40 | 34 | # |
41 | 35 | viewer.InitActiveLights() |
42 | 36 | active_light = viewer.ActiveLight() |
43 | 37 | viewer.DelLight(active_light) |
44 | | -viewer.NextActiveLights() |
45 | | -active_light = viewer.ActiveLight() |
46 | | -viewer.DelLight(active_light) |
47 | | -viewer.NextActiveLights() |
48 | | -active_light = viewer.ActiveLight() |
49 | | -viewer.DelLight(active_light) |
50 | 38 | # Create a red ambient light |
51 | | -ambient_light = V3d_AmbientLight(viewer_handle,Quantity_NOC_YELLOW) |
| 39 | +ambient_light = V3d_AmbientLight(viewer_handle, Quantity_NOC_YELLOW) |
52 | 40 | viewer.SetLightOn(ambient_light.GetHandle()) |
53 | 41 | # Create a green spot light |
54 | | -spot_light1 = V3d_SpotLight(viewer_handle,100,100,100) |
55 | | -spot_light1.SetTarget(0,0,0) |
| 42 | +spot_light1 = V3d_SpotLight(viewer_handle, 100., 100., 100.) |
| 43 | +spot_light1.SetTarget(0., 0., 0.) |
56 | 44 | spot_light1.SetColor(Quantity_NOC_GREEN) |
57 | 45 | viewer.SetLightOn(spot_light1.GetHandle()) |
58 | 46 | # |
59 | 47 | # Displays a simple box with material |
60 | 48 | # |
61 | | -s = BRepPrimAPI_MakeCylinder(50, 50).Shape() |
| 49 | +s = BRepPrimAPI_MakeCylinder(50., 50.).Shape() |
62 | 50 | # Display shapes |
63 | 51 | material = Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER) |
64 | | -display.DisplayShape(s,material) |
| 52 | +display.DisplayShape(s, material) |
65 | 53 | # |
66 | 54 | # Display settings and display loop |
67 | 55 | # |
68 | 56 | display.View_Iso() |
69 | 57 | display.FitAll() |
70 | 58 | start_display() |
71 | | - |
0 commit comments