Salome HOME
bos #18935 [CEA 18933] Clipping color
authorvsr <vsr@opencascade.com>
Fri, 3 Apr 2020 12:50:16 +0000 (15:50 +0300)
committervsr <vsr@opencascade.com>
Fri, 3 Apr 2020 12:50:16 +0000 (15:50 +0300)
src/OCCViewer/OCCViewer_ViewModel.cxx

index 9750c695d742a6c63ba8ba38ea41aa7ce971bc19..c54b5f327ac49385f91bcd25e06cae7a4d20b8cd 100644 (file)
 
 #include <Basics_OCCTVersion.hxx>
 
+namespace
+{
+  void setCappingColor(const Handle(Graphic3d_ClipPlane)& plane, const QColor& color)
+  {
+    Quantity_Color qcolor( color.redF(), color.greenF(), color.blueF(), Quantity_TOC_RGB );
+#if OCC_VERSION_LARGE < 0x07040000
+    Graphic3d_MaterialAspect aspect;
+    aspect.SetColor( qcolor );
+    plane->SetCappingMaterial( aspect );
+#else
+    plane->SetCappingColor( qcolor );
+#endif
+  }
+}
+
 /*!
   Get data for supported background modes: gradient types, identifiers and supported image formats
 */
@@ -919,16 +934,9 @@ void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
   if( myInternalClipPlanes.IsEmpty() )
     return;
 
-  Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
-  aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
-                                            theColor.blueF(), Quantity_TOC_RGB ) );
-#if OCC_VERSION_LARGE <= 0x07030000
-  for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
-    myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
-#else
   for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
-    aPlaneIt.Value()->SetCappingMaterial( aMaterialAspect );
-#endif
+    setCappingColor( aPlaneIt.Value(), theColor );
+
   update();
 }
 
@@ -1582,10 +1590,7 @@ Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& theP
   aGraphic3dPlane->SetCapping( Standard_True );
 
   // set capping color
-  Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
-  aMaterialAspect.SetColor( Quantity_Color( myClippingColor.redF(), myClippingColor.greenF(),
-                                            myClippingColor.blueF(), Quantity_TOC_RGB ) );
-  aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
+  setCappingColor( aGraphic3dPlane, myClippingColor );
 
   // set capping texture
   aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,