+ //clear current selection in the viewer
+
+ if(!mySelectionEnabled) {
+ myAISContext->ClearSelected( Standard_True );
+ }
+}
+
+
+/*!
+ Applies clipping planes to clippable objects
+*/
+void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
+{
+ // 1. Remove existing clipping planes
+ myClipPlanes.clear();
+ myInternalClipPlanes.Clear();
+
+ // 2. Create new clipping planes
+ ClipPlanesList::iterator inIt = theList.begin();
+ for (;inIt != theList.end(); inIt++ )
+ {
+ OCCViewer_ClipPlane aPlane = *inIt;
+
+ double aDx = 0.0, aDy = 0.0, aDz = 0.0;
+ aPlane.OrientationToXYZ( aDx, aDy, aDz );
+
+ gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
+ gp_Dir aDirection( aDx, aDy, aDz );
+
+ Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( gp_Pln( anOrigin, aDirection ) );
+ aGraphic3dPlane->SetOn( aPlane.IsOn );
+
+ myInternalClipPlanes.Append( aGraphic3dPlane );
+ myClipPlanes.push_back( aPlane );
+ }
+
+ // 3. Apply clipping planes
+ AIS_ListOfInteractive aList;
+ myAISContext->DisplayedObjects (aList);
+ for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
+ Handle(AIS_InteractiveObject) anObj = anIter.Value();
+ Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
+ if (!aShape.IsNull() && aShape->IsClippable()) {
+ aShape->SetClipPlanes(myInternalClipPlanes);
+ }
+ }
+}
+
+/*!
+ Returns the clipping planes applied to the displayed objects.
+*/
+ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
+ return myClipPlanes;
+}
+/*!
+ Applies clipping planes to given object objects
+*/
+void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
+{
+ Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
+ if (!aShape.IsNull() && aShape->IsClippable())
+ {
+ aShape->SetClipPlanes (myInternalClipPlanes);
+ }
+}
+
+/*!
+ Returns the pointer to the clipping dialog box.
+*/
+OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
+ return myClippingDlg;
+}
+
+
+/*!
+ Stores pointer to the clipping dialog box.
+*/
+void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
+ if(myClippingDlg != theDlg) {
+ myClippingDlg = theDlg;
+ }