3
3
from PyQt5 .QtCore import pyqtSlot , pyqtSignal
4
4
from PyQt5 .QtGui import QIcon
5
5
6
- from OCP .Graphic3d import Graphic3d_Camera , Graphic3d_StereoMode , Graphic3d_NOM_JADE ,\
7
- Graphic3d_MaterialAspect
6
+ from OCP .Graphic3d import Graphic3d_Camera , Graphic3d_ClipPlane , Graphic3d_StereoMode , Graphic3d_NOM_JADE ,\
7
+ Graphic3d_MaterialAspect , Graphic3d_Texture2Dplane
8
8
from OCP .AIS import AIS_Shaded ,AIS_WireFrame , AIS_ColoredShape , AIS_Axis
9
- from OCP .Aspect import Aspect_GDM_Lines , Aspect_GT_Rectangular
10
- from OCP .Quantity import Quantity_NOC_BLACK as BLACK , Quantity_TOC_RGB as TOC_RGB ,\
9
+ from OCP .Aspect import Aspect_GDM_Lines , Aspect_GT_Rectangular , Aspect_HS_GRID
10
+ from OCP .TCollection import TCollection_AsciiString
11
+ from OCP .Quantity import Quantity_NOC_BLACK as BLACK , Quantity_NOC_WHITE as WHITE , Quantity_TOC_RGB as TOC_RGB ,\
11
12
Quantity_Color
12
13
from OCP .Geom import Geom_Axis1Placement
13
- from OCP .gp import gp_Ax3 , gp_Dir , gp_Pnt , gp_Ax1
14
+ from OCP .gp import gp_Ax3 , gp_Dir , gp_Pnt , gp_Ax1 , gp_Pln
14
15
15
16
from ..utils import layout , get_save_filename
16
17
from ..mixins import ComponentMixin
@@ -56,6 +57,14 @@ def __init__(self,parent=None):
56
57
self .canvas = OCCTWidget ()
57
58
self .canvas .sigObjectSelected .connect (self .handle_selection )
58
59
60
+
61
+ self .x_clipping_plane = self .setup_clipping_plane (gp_Pln (- 1 , 0.0 , 0.0 , 100 ))
62
+ self .y_clipping_plane = self .setup_clipping_plane (gp_Pln (0.0 , - 1 , 0.0 , 100 ))
63
+ self .z_clipping_plane = self .setup_clipping_plane (gp_Pln (0.0 , 0.0 , - 1 , 100 ))
64
+ self .canvas .view .AddClipPlane (self .x_clipping_plane )
65
+ self .canvas .view .AddClipPlane (self .y_clipping_plane )
66
+ self .canvas .view .AddClipPlane (self .z_clipping_plane )
67
+
59
68
self .create_actions (self )
60
69
61
70
self .layout_ = layout (self ,
@@ -66,6 +75,16 @@ def __init__(self,parent=None):
66
75
self .setup_default_drawer ()
67
76
self .updatePreferences ()
68
77
78
+ def setup_clipping_plane (self , eq ):
79
+ cp = Graphic3d_ClipPlane ()
80
+ cp .SetEquation (eq )
81
+ cp .SetCapping (True )
82
+ cp .SetUseObjectMaterial (True )
83
+ # cp.SetCappingTexture(Graphic3d_Texture2Dplane(TCollection_AsciiString("./clip-texture.png")))
84
+ cp .SetOn (False )
85
+
86
+ return cp
87
+
69
88
def setup_default_drawer (self ):
70
89
71
90
# set the default color and material
@@ -369,6 +388,19 @@ def set_selected(self,ais):
369
388
370
389
self .redraw ()
371
390
391
+ @pyqtSlot (str ,bool ,int ,bool )
392
+ def update_clipping_plane (self ,plane ,enabled ,val ,inverted ):
393
+ if plane == "X" :
394
+ self .x_clipping_plane .SetEquation (gp_Pln (1 if inverted else - 1 , 0.0 , 0.0 , val ))
395
+ self .x_clipping_plane .SetOn (enabled )
396
+ elif plane == "Y" :
397
+ self .y_clipping_plane .SetEquation (gp_Pln (0.0 , 1 if inverted else - 1 , 0.0 , val ))
398
+ self .y_clipping_plane .SetOn (enabled )
399
+ elif plane == "Z" :
400
+ self .z_clipping_plane .SetEquation (gp_Pln (0.0 , 0.0 , 1 if inverted else - 1 , val ))
401
+ self .z_clipping_plane .SetOn (enabled )
402
+
403
+ self .redraw ()
372
404
373
405
if __name__ == "__main__" :
374
406
0 commit comments