Salome HOME
Update copyright information
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index 53c8758f3a0621d9c2185ff5a4a40e1d5aabd02e..7be22f7c59c4aff4c83d2e4403bd9800ac5ad1e1 100644 (file)
@@ -1,43 +1,40 @@
-//  SMESH OBJECT : interactive object for SMESH visualization
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2003  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 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 
-// 
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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.
 //
+//  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
+//
+//  SMESH OBJECT : interactive object for SMESH visualization
 //  File   : SMESH_Actor.cxx
 //  Author : Nicolas REJNERI
 //  Module : SMESH
 //  $Header$
-
-
+//
 #include "SMESH_ActorDef.h"
 #include "SMESH_ActorUtils.h"
 #include "SMESH_DeviceActor.h"
 #include "SMESH_ControlsDef.hxx"
 #include "VTKViewer_ExtractUnstructuredGrid.h"
+#include "SALOME_InteractiveObject.hxx"
 
 #include "SUIT_Session.h"
 #include "SUIT_ResourceMgr.h"
 
-#include <qstringlist.h>
-
 #include <vtkProperty.h>
 #include <vtkTimeStamp.h>
 #include <vtkObjectFactory.h>
@@ -117,10 +114,13 @@ SMESH_ActorDef::SMESH_ActorDef()
   myIsShrinkable = false;
   myIsShrunk = false;
 
+  myIsFacesOriented = false;
+
   myControlsPrecision = -1;
   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
+  
   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
-    myControlsPrecision = (long)SMESH::GetFloat( "SMESH", "controls_precision", -1 );
+    myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
 
   vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
   vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
@@ -168,6 +168,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   aFilter->RegisterCellsWithType(VTK_PYRAMID);
   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+  aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
 
   //Definition 1D divice of the actor
@@ -286,6 +287,11 @@ SMESH_ActorDef::SMESH_ActorDef()
   myScalarBarActor->SetVisibility(false);
   myScalarBarActor->SetLookupTable(myLookupTable);
 
+  //Fix for Bug 13314:
+  //Incorrect "Min value" in Scalar Bar in Mesh:
+  //  myScalarBarActor->SetLabelFormat("%.4g");
+  // changes was commented because of regression bug IPAL 19981
+
   mgr = SUIT_Session::session()->resourceMgr();
   if( !mgr )
     return;
@@ -406,13 +412,16 @@ SMESH_ActorDef::~SMESH_ActorDef()
   //---------------------------------------
   myPointsNumDataSet->Delete();
 
-  myPtsLabeledDataMapper->RemoveAllInputs();
+  // commented: porting to vtk 5.0
+  //  myPtsLabeledDataMapper->RemoveAllInputs();
   myPtsLabeledDataMapper->Delete();
 
-  myPtsSelectVisiblePoints->UnRegisterAllOutputs();
+  // commented: porting to vtk 5.0
+  //  myPtsSelectVisiblePoints->UnRegisterAllOutputs();
   myPtsSelectVisiblePoints->Delete();
 
-  myPtsMaskPoints->UnRegisterAllOutputs();
+  // commented: porting to vtk 5.0
+  //  myPtsMaskPoints->UnRegisterAllOutputs();
   myPtsMaskPoints->Delete();
 
   myPointLabels->Delete();
@@ -425,13 +434,16 @@ SMESH_ActorDef::~SMESH_ActorDef()
   myClsLabeledDataMapper->RemoveAllInputs();
   myClsLabeledDataMapper->Delete();
 
-  myClsSelectVisiblePoints->UnRegisterAllOutputs();
+  // commented: porting to vtk 5.0
+  //  myClsSelectVisiblePoints->UnRegisterAllOutputs();
   myClsSelectVisiblePoints->Delete();
 
-  myClsMaskPoints->UnRegisterAllOutputs();
+  // commented: porting to vtk 5.0
+  //  myClsMaskPoints->UnRegisterAllOutputs();
   myClsMaskPoints->Delete();
 
-  myCellCenters->UnRegisterAllOutputs();
+  // commented: porting to vtk 5.0
+  //  myCellCenters->UnRegisterAllOutputs();
   myCellCenters->Delete();
 
   myCellsLabels->Delete();
@@ -501,6 +513,22 @@ void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
 }
 
 
+void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
+{
+  myIsFacesOriented = theIsFacesOriented;
+
+  my2DActor->SetFacesOriented(theIsFacesOriented);
+  my3DActor->SetFacesOriented(theIsFacesOriented);
+
+  myTimeStamp->Modified();
+}
+
+bool SMESH_ActorDef::GetFacesOriented()
+{
+  return myIsFacesOriented;
+}
+
+
 void 
 SMESH_ActorDef::
 SetControlMode(eControl theMode)
@@ -682,8 +710,8 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
   theRenderer->AddActor(myNodeActor);
   theRenderer->AddActor(myBaseActor);
 
-  theRenderer->AddActor(my3DActor);
-  theRenderer->AddActor(my2DActor);
+  my3DActor->AddToRender(theRenderer);
+  my2DActor->AddToRender(theRenderer);
 
   theRenderer->AddActor(my1DActor);
   theRenderer->AddActor(my1DExtActor);
@@ -710,8 +738,8 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
   theRenderer->RemoveActor(my1DActor);
   theRenderer->RemoveActor(my1DExtActor);
 
-  theRenderer->RemoveActor(my2DActor);
-  theRenderer->RemoveActor(my3DActor);
+  my2DActor->RemoveFromRender(theRenderer);
+  my3DActor->RemoveFromRender(theRenderer);
 
   theRenderer->RemoveActor(myScalarBarActor);
   theRenderer->RemoveActor(myPointLabels);
@@ -759,7 +787,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
   SetIsShrunkable(true);
 
-  SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 0.75 ) );
+  SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
 
   int aMode = mgr->integerValue( "SMESH", "display_mode" );
   SetRepresentation(-1);
@@ -978,7 +1006,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
     if(myIsCellsLabeled) 
       myCellsLabels->VisibilityOn();
   }
-
+  UpdateHighlight();
   Modified();
 }
 
@@ -1044,6 +1072,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
     aFilter->RegisterCellsWithType(VTK_PYRAMID);
     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+    aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
   }
   aFilter->Update();
@@ -1180,9 +1209,9 @@ void SMESH_ActorDef::UpdateHighlight(){
       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
     }else if(myRepresentation == ePoint || GetPointRepresentation()){
       myHighlitableActor->SetHighlited(anIsVisible);
-      myHighlitableActor->SetVisibility(anIsVisible);
       myHighlitableActor->GetExtractUnstructuredGrid()->
        SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
+      myHighlitableActor->SetVisibility(anIsVisible);
       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
     }
   }
@@ -1254,6 +1283,9 @@ void SMESH_ActorDef::Update(){
   if(myIsCellsLabeled){
     SetCellsLabeled(myIsCellsLabeled);
   }
+  if(myIsFacesOriented){
+    SetFacesOriented(myIsFacesOriented);
+  }
   SetEntityMode(GetEntityMode());
   SetVisibility(GetVisibility());
   
@@ -1582,7 +1614,7 @@ void SMESH_ActorDef::UpdateScalarBar()
   aScalarBarLabelProp->SetFontFamilyToArial();
   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
   {
-    QFont f = mgr->stringValue( "SMESH", "scalar_bar_label_font" );
+    QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
     if( f.family() == "Arial" )
       aScalarBarLabelProp->SetFontFamilyToArial();
     else if( f.family() == "Courier" )