Skip to content

Commit c5a4f70

Browse files
committed
Cleaned up Display examples
1 parent 552ea0a commit c5a4f70

File tree

10 files changed

+84
-112
lines changed

10 files changed

+84
-112
lines changed

src/examples/Display/customize_linewidth.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -18,11 +18,10 @@
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

2020

21-
from OCC.Display.SimpleGui import *
22-
display, start_display, add_menu, add_function_to_menu = init_display()
23-
24-
from OCC.AIS import *
21+
from OCC.AIS import AIS_Shape
2522
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
23+
from OCC.Display.SimpleGui import init_display
24+
display, start_display, add_menu, add_function_to_menu = init_display()
2625

2726
#
2827
# Create a box
@@ -45,4 +44,3 @@
4544
display.View_Iso()
4645
display.FitAll()
4746
start_display()
48-

src/examples/Display/customize_prs3d.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -21,12 +21,10 @@
2121
# This sample shows howto set display quality (higher or lower).
2222
# Be carful that improving quality results in higher memory consumption
2323
#
24-
from OCC.Display.SimpleGui import *
25-
display, start_display, add_menu, add_function_to_menu = init_display()
2624

27-
from OCC.AIS import *
28-
from OCC.Prs3d import *
29-
from OCC.BRepPrimAPI import *
25+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder
26+
from OCC.Display.SimpleGui import init_display
27+
display, start_display, add_menu, add_function_to_menu = init_display()
3028

3129
#
3230
# Get Context
@@ -37,9 +35,9 @@
3735
#
3836
drawer_handle = ais_context.DefaultDrawer()
3937
drawer = drawer_handle.GetObject()
40-
print drawer.IsoOnPlane()
38+
# print drawer.IsoOnPlane()
4139
drawer.SetIsoOnPlane(True)
42-
#
40+
4341
la = drawer.LineAspect().GetObject()
4442
la.SetWidth(4)
4543
# increase line width in the current viewer
@@ -52,12 +50,11 @@
5250
#
5351
# Displays a cylinder
5452
#
55-
s = BRepPrimAPI_MakeCylinder(50, 50).Shape()
53+
s = BRepPrimAPI_MakeCylinder(50., 50.).Shape()
5654
display.DisplayShape(s)
5755
#
5856
# Display settings and display loop
5957
#
6058
display.View_Iso()
6159
display.FitAll()
6260
start_display()
63-

src/examples/Display/display_quality.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -21,11 +21,11 @@
2121
# This sample shows howto set display quality (higher or lower).
2222
# Be carful that improving quality results in higher memory consumption
2323
#
24-
from OCC.Display.SimpleGui import *
24+
25+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder
26+
from OCC.Display.SimpleGui import init_display
2527
display, start_display, add_menu, add_function_to_menu = init_display()
2628

27-
from OCC.AIS import *
28-
from OCC.BRepPrimAPI import *
2929

3030
#
3131
# Get Context
@@ -38,10 +38,10 @@
3838
da = ais_context.DeviationAngle()
3939
da_hlr = ais_context.HLRAngle()
4040
print "Default display quality settings:"
41-
print "Deviation Coefficient: %f"%dc
42-
print "Deviation Coefficient Hidden Line Removal: %f"%dc_hlr
43-
print "Deviation Angle: %f"%da
44-
print "Deviation Angle Hidden Line Removal: %f"%da_hlr
41+
print "Deviation Coefficient: %f" % dc
42+
print "Deviation Coefficient Hidden Line Removal: %f" % dc_hlr
43+
print "Deviation Angle: %f" % da
44+
print "Deviation Angle Hidden Line Removal: %f" % da_hlr
4545
#
4646
# Improve quality by a factor 10
4747
#
@@ -54,12 +54,11 @@
5454
#
5555
# Displays a cylinder
5656
#
57-
s = BRepPrimAPI_MakeCylinder(50, 50).Shape()
57+
s = BRepPrimAPI_MakeCylinder(50., 50.).Shape()
5858
display.DisplayShape(s)
5959
#
6060
# Display settings and display loop
6161
#
6262
display.View_Iso()
6363
display.FitAll()
6464
start_display()
65-

src/examples/Display/enviroment_mapping.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com) & Jelle Feringa (jelleferinga@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com) & Jelle Feringa (jelleferinga@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -24,34 +24,29 @@
2424
2525
'''
2626

27-
from OCC.BRepPrimAPI import *
28-
from OCC.Display.SimpleGui import *
27+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus
28+
from OCC.Graphic3d import *
29+
from OCC.Aspect import Aspect_TOFM_FRONT_SIDE
30+
from OCC.Display.SimpleGui import init_display
31+
2932
display, start_display, add_menu, add_function_to_menu = init_display()
3033

31-
from OCC.AIS import *
32-
from OCC.Visual3d import *
33-
from OCC.Graphic3d import *
34-
from OCC.Aspect import *
3534

36-
# construct a primitive
37-
box = BRepPrimAPI_MakeBox(1,1,1).Shape()
38-
#===============================================================================
35+
box = BRepPrimAPI_MakeTorus(10., 3.).Shape()
36+
#
3937
# This is how to set the spherical dynamic texcoord generation in the view
40-
#===============================================================================
38+
#
4139
view = display.View.View().GetObject()
4240
vw_mng = view.ViewManager()
4341

4442
# build enviroment texture
45-
texture = Graphic3d_TextureEnv(vw_mng,
46-
Graphic3d_NOT_ENV_CLOUDS
47-
)
43+
texture = Graphic3d_TextureEnv(vw_mng, Graphic3d_NOT_ENV_CLOUDS)
4844

4945
display.View.SetTextureEnv(texture.GetHandle())
5046
display.View.Redraw()
51-
#===============================================================================
52-
# And this is hot to enable spherical dynamic texture to an object
53-
#===============================================================================
54-
47+
#
48+
# And this is hot to enable spherical dynamic texture to an object
49+
#
5550
mat_asp = Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER)
5651
mat_asp.SetEnvReflexion(1)
5752
mat_asp.SetReflectionModeOn(True)
Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -17,55 +17,42 @@
1717
##You should have received a copy of the GNU Lesser General Public License
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

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
3024

25+
from OCC.Display.SimpleGui import init_display
26+
display, start_display, add_menu, add_function_to_menu = init_display()
3127
#
3228
# Get viewer
3329
#
3430
viewer_handle = display.GetViewer()
3531
viewer = viewer_handle.GetObject()
36-
37-
3832
#
3933
# First remove all lights from current viewer
4034
#
4135
viewer.InitActiveLights()
4236
active_light = viewer.ActiveLight()
4337
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)
5038
# 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)
5240
viewer.SetLightOn(ambient_light.GetHandle())
5341
# 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.)
5644
spot_light1.SetColor(Quantity_NOC_GREEN)
5745
viewer.SetLightOn(spot_light1.GetHandle())
5846
#
5947
# Displays a simple box with material
6048
#
61-
s = BRepPrimAPI_MakeCylinder(50, 50).Shape()
49+
s = BRepPrimAPI_MakeCylinder(50., 50.).Shape()
6250
# Display shapes
6351
material = Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER)
64-
display.DisplayShape(s,material)
52+
display.DisplayShape(s, material)
6553
#
6654
# Display settings and display loop
6755
#
6856
display.View_Iso()
6957
display.FitAll()
7058
start_display()
71-
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -17,37 +17,33 @@
1717
##You should have received a copy of the GNU Lesser General Public License
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

20-
from OCC.Display.SimpleGui import *
21-
display, start_display, add_menu, add_function_to_menu = init_display()
22-
2320
from OCC.Graphic3d import *
24-
from OCC.BRepPrimAPI import *
21+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
2522
from OCC.Utils.Topology import Topo
23+
from OCC.Display.SimpleGui import init_display
24+
display, start_display, add_menu, add_function_to_menu = init_display()
2625

2726
#
2827
# Create a list of 6 materials (1 material for each face)
2928
#
30-
material_list = [Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER),
29+
material_list = [Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER),
3130
Graphic3d_MaterialAspect(Graphic3d_NOM_BRONZE),
3231
Graphic3d_MaterialAspect(Graphic3d_NOM_PLASTIC),
3332
Graphic3d_MaterialAspect(Graphic3d_NOM_GOLD),
3433
Graphic3d_MaterialAspect(Graphic3d_NOM_COPPER),
3534
Graphic3d_MaterialAspect(Graphic3d_NOM_STONE)]
3635
material_iterator = iter(material_list)
37-
3836
#
3937
# Create a box
4038
#
41-
s = BRepPrimAPI_MakeBox(200, 100, 50).Shape()
42-
39+
s = BRepPrimAPI_MakeBox(200., 100., 50.).Shape()
4340
#
4441
# Display faces
4542
#
4643
faces = Topo(s).faces()
47-
for face in faces:
48-
display.DisplayShape(face,material_iterator.next(), update=True)
44+
for face in faces:
45+
display.DisplayShape(face, material_iterator.next(), update=True)
4946

5047
display.View_Iso()
5148
display.FitAll()
5249
start_display()
53-

src/examples/Display/material_shape.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -17,19 +17,18 @@
1717
##You should have received a copy of the GNU Lesser General Public License
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

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.gp import *
20+
from OCC.Graphic3d import Graphic3d_NOM_SILVER, Graphic3d_MaterialAspect
21+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder
22+
from OCC.gp import gp_Ax2, gp_Pnt, gp_Dir
2623

24+
from OCC.Display.SimpleGui import init_display
25+
display, start_display, add_menu, add_function_to_menu = init_display()
2726
#
2827
# Displays a cylinder with a material
2928
#
3029
material = Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER)
31-
s = BRepPrimAPI_MakeCylinder(60, 200)
32-
display.DisplayShape(s.Shape(),material)
30+
s = BRepPrimAPI_MakeCylinder(60., 200.)
31+
display.DisplayShape(s.Shape(), material)
3332
#
3433
# Displays a cylinder with a material and a texture
3534
#
@@ -40,4 +39,3 @@
4039
display.View_Iso()
4140
display.FitAll()
4241
start_display()
43-

src/examples/Display/qt_demo.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
##Copyright 2009-2011 Thomas Paviot (tpaviot@gmail.com)
3+
##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com)
44
##
55
##This file is part of pythonOCC.
66
##
@@ -17,22 +17,24 @@
1717
##You should have received a copy of the GNU Lesser General Public License
1818
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1919

20-
from OCC.BRepPrimAPI import *
21-
from OCC.Display.SimpleGui import *
20+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder
21+
from OCC.Display.SimpleGui import init_display
22+
23+
display, start_display, add_menu, add_function_to_menu = init_display('qt')
2224

23-
display, start_display, add_menu, add_function_to_menu = init_display('pyqt4')
2425

2526
def simple_test(event=None):
2627
display.Test()
2728

29+
2830
def simple_cylinder(event=None):
29-
s = BRepPrimAPI_MakeCylinder(60, 200)
31+
s = BRepPrimAPI_MakeCylinder(60., 200.)
3032
display.DisplayShape(s.Shape(), update=True)
3133

3234
# set up menus
3335
add_menu('qt tests')
34-
add_function_to_menu('qt tests',simple_test)
35-
add_function_to_menu('qt tests',simple_cylinder)
36+
add_function_to_menu('qt tests', simple_test)
37+
add_function_to_menu('qt tests', simple_cylinder)
3638

3739
#
3840
# Display settings

0 commit comments

Comments
 (0)