Salome HOME
Remarks to 19928 issue.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AddMeshElementDlg.cxx
index 415f32f6f50782cd04134fcad40088676bcfe41a..97e393a248d67f7c03253f60609e9dbf81802441 100644 (file)
@@ -1,29 +1,29 @@
-// SMESH SMESHGUI : GUI for SMESH component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// This library is free software; you can redistribute it and/or 
-// modify it under the terms of the GNU Lesser General Public 
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License. 
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
-// This library is distributed in the hope that it will be useful, 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details. 
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public 
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_AddMeshElementDlg.cxx
 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
-//
-
 //  SMESH includes
+//
 #include "SMESHGUI_AddMeshElementDlg.h"
 
 #include "SMESHGUI.h"
@@ -34,6 +34,7 @@
 
 #include <SMESH_Actor.h>
 #include <SMESH_ActorUtils.h>
+#include <SMESH_FaceOrientationFilter.h>
 #include <SMDS_Mesh.hxx>
 
 // SALOME GUI inclues
@@ -59,6 +60,7 @@
 #include <vtkIdList.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 
 // Qt includes
@@ -90,6 +92,10 @@ namespace SMESH
     vtkDataSetMapper* myMapper;
     vtkUnstructuredGrid* myGrid;
 
+    SALOME_Actor* myFaceOrientation;
+    vtkPolyDataMapper* myFaceOrientationDataMapper;
+    SMESH_FaceOrientationFilter* myFaceOrientationFilter;
+
   public:
     TElementSimulation (SalomeApp_Application* theApplication)
     {
@@ -124,6 +130,26 @@ namespace SMESH
       aBackProp->Delete();
 
       myVTKViewWindow->AddActor(myPreviewActor);
+
+      // Orientation of faces
+      myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
+      myFaceOrientationFilter->SetInput(myGrid);
+
+      myFaceOrientationDataMapper = vtkPolyDataMapper::New();
+      myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());
+
+      myFaceOrientation = SALOME_Actor::New();
+      myFaceOrientation->PickableOff();
+      myFaceOrientation->VisibilityOff();
+      myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
+
+      vtkProperty* anOrientationProp = vtkProperty::New();
+      GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
+      anOrientationProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+      myFaceOrientation->SetProperty( anOrientationProp );
+      anOrientationProp->Delete();
+
+      myVTKViewWindow->AddActor(myFaceOrientation);
     }
 
     typedef std::vector<vtkIdType> TVTKIds;
@@ -171,13 +197,14 @@ namespace SMESH
 
       myGrid->Modified();
 
-      SetVisibility(true);
+      SetVisibility(true, theActor->GetFacesOriented());
     }
 
 
-    void SetVisibility (bool theVisibility)
+    void SetVisibility (bool theVisibility, bool theShowOrientation = false)
     {
       myPreviewActor->SetVisibility(theVisibility);
+      myFaceOrientation->SetVisibility(theShowOrientation);
       RepaintCurrentView();
     }
 
@@ -186,12 +213,19 @@ namespace SMESH
     {
       if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
        myVTKViewWindow->RemoveActor(myPreviewActor);
+       myVTKViewWindow->RemoveActor(myFaceOrientation);
       }
       myPreviewActor->Delete();
+      myFaceOrientation->Delete();
 
       myMapper->RemoveAllInputs();
       myMapper->Delete();
 
+      myFaceOrientationFilter->Delete();
+
+      myFaceOrientationDataMapper->RemoveAllInputs();
+      myFaceOrientationDataMapper->Delete();
+
       myGrid->Delete();
     }
   };