33from PyQt5 .QtCore import pyqtSlot , pyqtSignal
44from PyQt5 .QtGui import QIcon
55
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
88from 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 ,\
1112 Quantity_Color
1213from 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
1415
1516from ..utils import layout , get_save_filename
1617from ..mixins import ComponentMixin
@@ -56,6 +57,14 @@ def __init__(self,parent=None):
5657 self .canvas = OCCTWidget ()
5758 self .canvas .sigObjectSelected .connect (self .handle_selection )
5859
60+
61+ self .x_clipping_plane = self .setup_clipping_plane ('red' , gp_Pln (- 1 , 0.0 , 0.0 , 100 ))
62+ self .y_clipping_plane = self .setup_clipping_plane ('lawngreen' , gp_Pln (0.0 , - 1 , 0.0 , 100 ))
63+ self .z_clipping_plane = self .setup_clipping_plane ('blue' , 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+
5968 self .create_actions (self )
6069
6170 self .layout_ = layout (self ,
@@ -66,6 +75,16 @@ def __init__(self,parent=None):
6675 self .setup_default_drawer ()
6776 self .updatePreferences ()
6877
78+ def setup_clipping_plane (self , color , eq ):
79+ cp = Graphic3d_ClipPlane ()
80+ cp .SetEquation (eq )
81+ cp .SetCapping (True )
82+ cp .SetCappingColor (to_occ_color (color ))
83+ # cp.SetCappingTexture(Graphic3d_Texture2Dplane(TCollection_AsciiString("./clip-texture.png")))
84+ cp .SetOn (False )
85+
86+ return cp
87+
6988 def setup_default_drawer (self ):
7089
7190 # set the default color and material
@@ -369,6 +388,19 @@ def set_selected(self,ais):
369388
370389 self .redraw ()
371390
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 ()
372404
373405if __name__ == "__main__" :
374406
0 commit comments