]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
HYDRO shapes are merged to drawing of Wires and Faces instead of drawing Faces only.
authoradv <adv@opencascade.com>
Fri, 27 Sep 2013 12:23:23 +0000 (12:23 +0000)
committeradv <adv@opencascade.com>
Fri, 27 Sep 2013 12:23:23 +0000 (12:23 +0000)
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/HYDROGUI_ZoneOp.cxx

index 33ceeda2c3519d649e220421644ddfe3e5a1f4c2..1a69cfb938d258afc3380b5f8b98e099f09ba8dd 100644 (file)
@@ -56,7 +56,8 @@ HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext
   myBorderColor( Qt::black ),
   myHighlightColor( Qt::white ),
   myIsToUpdate( false ),
-  myIsVisible( true )
+  myIsVisible( true ),
+  myDisplayMode( AIS_WireFrame )
 {
 }
 
@@ -70,7 +71,7 @@ HYDROGUI_Shape::~HYDROGUI_Shape()
 
 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
 {
-  if ( myContext.IsNull() || myShape.IsNull() )
+  if ( myContext.IsNull() || myShape.IsNull() || !isVisible() )
     return;
 
   myContext->Display( myShape, theIsUpdateViewer );
@@ -118,7 +119,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
     }
   }
 
-  if ( myShape.IsNull() )
+  if ( myShape.IsNull() || !isVisible() )
     return;
 
   myContext->Display( myShape, theIsUpdateViewer );
@@ -163,6 +164,17 @@ bool HYDROGUI_Shape::isHighlighted() const
 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
                               const bool         theToDisplay,
                               const bool         theIsUpdateViewer )
+{
+  myTopoShape = theWire;
+  myDisplayMode = AIS_WireFrame;
+
+  buildShape();
+  updateShape( theToDisplay, theIsUpdateViewer );
+}
+
+void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
+                              const bool         theToDisplay,
+                              const bool         theIsUpdateViewer )
 {
   BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
   aFaceBuilder.Build();
@@ -177,7 +189,9 @@ void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
                               const bool         theToDisplay,
                               const bool         theIsUpdateViewer )
 {
-  myFace = theFace;
+  myTopoShape = theFace;
+  myDisplayMode = AIS_Shaded;
+
   buildShape();
   updateShape( theToDisplay, theIsUpdateViewer );
 }
@@ -223,38 +237,45 @@ void HYDROGUI_Shape::buildShape()
   // Erase previously created shape
   erase();
 
-  if( myFace.IsNull() )
+  if ( myTopoShape.IsNull() )
     return;
 
-  myShape = new AIS_Shape( myFace );
+  myShape = new AIS_Shape( myTopoShape );
 
   if ( !myObject.IsNull() )
     myShape->SetOwner( myObject );
 
   myShape->SetTransparency( 0 );
-  myShape->SetDisplayMode( AIS_Shaded );
+  myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
 
-  // Init default params for shape
+    // Init default params for shape
   const Handle(AIS_Drawer)& anAttributes = myShape->Attributes();
   if ( !anAttributes.IsNull() )
   {
-    Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
-    if ( !anIsoAspect.IsNull() )
-      anIsoAspect->SetNumber( 0 );
-    
-    anIsoAspect = anAttributes->VIsoAspect();
-    if ( !anIsoAspect.IsNull() )
-      anIsoAspect->SetNumber( 0 );
-
-    Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
-    if ( !aShadingAspect.IsNull() )
+    if ( myDisplayMode == AIS_Shaded )
     {
-      Graphic3d_MaterialAspect aMatAspect;
-      aMatAspect.SetAmbient( 1 );
-      aMatAspect.SetDiffuse( 0 );
-
-      aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect );
-      aShadingAspect->Aspect()->SetBackMaterial( aMatAspect );
+      Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
+      if ( !anIsoAspect.IsNull() )
+        anIsoAspect->SetNumber( 0 );
+      
+      anIsoAspect = anAttributes->VIsoAspect();
+      if ( !anIsoAspect.IsNull() )
+        anIsoAspect->SetNumber( 0 );
+
+      Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
+      if ( !aShadingAspect.IsNull() )
+      {
+        Graphic3d_MaterialAspect aMatAspect;
+        aMatAspect.SetAmbient( 1 );
+        aMatAspect.SetDiffuse( 0 );
+
+        aShadingAspect->Aspect()->SetFrontMaterial( aMatAspect );
+        aShadingAspect->Aspect()->SetBackMaterial( aMatAspect );
+      }
+    }
+    else if ( myDisplayMode == AIS_WireFrame )
+    {
+      anAttributes->SetWireDraw( true );
     }
   }
 }
@@ -268,24 +289,30 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay,
   const Handle(AIS_Drawer)& anAttributes = myShape->Attributes();
   if ( !anAttributes.IsNull() )
   {
-    // Coloring face filling
-    Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
-    if ( !aShadingAspect.IsNull() )
+    if ( myDisplayMode == AIS_Shaded )
+    {
+      // Coloring face filling
+      Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
+      if ( !aShadingAspect.IsNull() )
+      {
+        Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
+                                      getQuantityColorVal( myFillingColor.green() ),
+                                      getQuantityColorVal( myFillingColor.blue() ),
+                                      Quantity_TOC_RGB );
+
+        aShadingAspect->SetColor( aFillingColor );
+        aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
+      }
+    }
+    else if ( myDisplayMode == AIS_WireFrame )
     {
-      Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
-                                    getQuantityColorVal( myFillingColor.green() ),
-                                    getQuantityColorVal( myFillingColor.blue() ),
-                                    Quantity_TOC_RGB );
-
-      aShadingAspect->SetColor( aFillingColor );
-      aShadingAspect->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
     }
 
     // Coloring borders
     colorShapeBorder( getActiveColor() );
   }
 
-  if ( !theToDisplay || myContext.IsNull() )
+  if ( !theToDisplay || !isVisible() || myContext.IsNull() )
     return;
   
   myContext->Display( myShape, theIsUpdateViewer );
@@ -310,25 +337,29 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
   if ( anAttributes.IsNull() )
     return;
 
-  if ( theColor.alpha() == 0 )
+  Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
+                               getQuantityColorVal( theColor.green() ),
+                               getQuantityColorVal( theColor.blue() ),
+                               Quantity_TOC_RGB );
+  if ( myDisplayMode == AIS_Shaded )
   {
-    anAttributes->SetFaceBoundaryDraw( false );
-  }
-  else
-  {
-    Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
-                                 getQuantityColorVal( theColor.green() ),
-                                 getQuantityColorVal( theColor.blue() ),
-                                 Quantity_TOC_RGB );
-
-    anAttributes->SetFaceBoundaryDraw( true );
-
-    Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
-    if ( !aBoundaryAspect.IsNull() )
+    if ( theColor.alpha() == 0 )
+    {
+      anAttributes->SetFaceBoundaryDraw( false );
+    }
+    else
     {
-      aBoundaryAspect->SetColor( aBorderColor );
+      anAttributes->SetFaceBoundaryDraw( true );
+
+      Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
+      if ( !aBoundaryAspect.IsNull() )
+        aBoundaryAspect->SetColor( aBorderColor );
     }
   }
+  else if ( myDisplayMode == AIS_WireFrame )
+  {
+    myShape->SetColor( aBorderColor );
+  }
 }
 
 
index 6572c80d5674fcc3798e086aa7941efb2cf9d5e2..7e67eb08bdb4e6bbe59ea687300cad77776f6868 100644 (file)
@@ -62,6 +62,10 @@ public:
                                       const bool         theToDisplay = true,
                                       const bool         theIsUpdateViewer = true );
 
+  virtual void               setFace( const TopoDS_Wire& theWire,
+                                      const bool         theToDisplay = true,
+                                      const bool         theIsUpdateViewer = true );
+
   virtual void               setFace( const TopoDS_Face& theFace,
                                       const bool         theToDisplay = true,
                                       const bool         theIsUpdateViewer = true );
@@ -98,7 +102,8 @@ private:
   bool                           myIsVisible;
 
   bool                           myIsHighlight;
-  TopoDS_Face                    myFace;
+  TopoDS_Shape                   myTopoShape;
+  int                            myDisplayMode;
   
   QColor                         myFillingColor;
   QColor                         myBorderColor;
index 5825105ee3bd00513bb70b92834da0a7c3b03535..216904b6ac93a40038b1ddbc61b3078ef0e9d5e0 100644 (file)
@@ -306,7 +306,7 @@ void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
 
   myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false );
   myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false );
-  myPreviewPrs->setWire( aWire );
+  myPreviewPrs->setFace( aWire );
 }
 
 void HYDROGUI_ZoneOp::onLastViewClosed( SUIT_ViewManager* theViewManager )