Back to index

salome-smesh  6.5.0
SMESH_Actor.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH OBJECT : interactive object for SMESH visualization
00024 //  File   : SMESH_Actor.cxx
00025 //  Author : Nicolas REJNERI
00026 //  Module : SMESH
00027 //
00028 #include "SMESH_ActorDef.h"
00029 #include "SMESH_ActorUtils.h"
00030 #include "SMESH_DeviceActor.h"
00031 #include "SMESH_NodeLabelActor.h"
00032 #include "SMESH_CellLabelActor.h"
00033 #include "SMESH_ObjectDef.h"
00034 #include "SMESH_ControlsDef.hxx"
00035 #include "SMDS_UnstructuredGrid.hxx"
00036 #include "SMESH_ScalarBarActor.h"
00037 #include "VTKViewer_ExtractUnstructuredGrid.h"
00038 #include "VTKViewer_FramedTextActor.h"
00039 #include "SALOME_InteractiveObject.hxx"
00040 
00041 #include "SUIT_Session.h"
00042 #include "SUIT_ResourceMgr.h"
00043 
00044 #include <Qtx.h>
00045 
00046 #ifndef DISABLE_PLOT2DVIEWER
00047 #include <SPlot2d_Histogram.h>
00048 #endif
00049 
00050 #include <vtkProperty.h>
00051 #include <vtkTimeStamp.h>
00052 #include <vtkObjectFactory.h>
00053 #include <vtkShrinkPolyData.h>
00054 #include <vtkMergeFilter.h>
00055 
00056 #include <vtkMatrix4x4.h>
00057 #include <vtkUnstructuredGrid.h>
00058 #include <vtkPointData.h>
00059 #include <vtkCellData.h>
00060 
00061 #include <vtkMapper.h>
00062 #include <vtkRenderer.h>
00063 
00064 #include <vtkCell.h>
00065 #include <vtkIdList.h>
00066 #include <vtkIntArray.h>
00067 
00068 #include <vtkActor2D.h>
00069 #include <vtkProperty2D.h>
00070 #include <vtkPolyData.h>
00071 #include <vtkTextProperty.h>
00072 
00073 #include <vtkLookupTable.h>
00074 
00075 #include <vtkMath.h>
00076 #include <vtkPlane.h>
00077 #include <vtkImplicitBoolean.h>
00078 #include <vtkImplicitFunctionCollection.h>
00079 
00080 #include <vtkConfigure.h>
00081 #if !defined(VTK_XVERSION)
00082 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
00083 #endif
00084 
00085 #include "utilities.h"
00086 
00087 #ifdef _DEBUG_
00088 static int MYDEBUG = 1;
00089 #else
00090 static int MYDEBUG = 1;
00091 #endif
00092 
00093 static int aLineWidthInc = 2;
00094 
00095 
00096 SMESH_ActorDef* SMESH_ActorDef::New(){
00097   return new SMESH_ActorDef();
00098 }
00099 
00100 
00101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, 
00102                               const char* theEntry, 
00103                               const char* theName,
00104                               int theIsClear)
00105 {
00106   SMESH_ActorDef* anActor = NULL;
00107   if(theVisualObj->IsValid() ) {
00108     anActor = SMESH_ActorDef::New();
00109     if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
00110       anActor->Delete();
00111       anActor = NULL;
00112     }
00113     if( anActor )
00114       anActor->UpdateScalarBar();
00115   }
00116   return anActor;
00117 }
00118 
00119 
00120 SMESH_ActorDef::SMESH_ActorDef()
00121 {
00122   if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);  
00123   myBaseActor = SMESH_DeviceActor::New();
00124 
00125   myTimeStamp = vtkTimeStamp::New();
00126 
00127   myIsPointsVisible = false;
00128   myIsEntityModeCache = false;
00129 
00130   myIsShrinkable = false;
00131   myIsShrunk = false;
00132 
00133   myIsFacesOriented = false;
00134 
00135   myControlsPrecision = -1;
00136   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
00137 
00138   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
00139     myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
00140 
00141   vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
00142   vtkFloatingPointType aLineWidth  = SMESH::GetFloat("SMESH:element_width",1);
00143 
00144   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
00145   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
00146 
00147   //Definition 2D and 3D devices of the actor
00148   //-----------------------------------------
00149   vtkFloatingPointType anRGB[3] = {1,1,1};
00150   mySurfaceProp = vtkProperty::New();
00151   QColor ffc, bfc;
00152   int delta;
00153   SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
00154   mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
00155   myDeltaBrightness = delta;
00156 
00157   myBackSurfaceProp = vtkProperty::New();
00158   bfc = Qtx::mainColorToSecondary(ffc, delta);
00159   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
00160 
00161   my2DActor = SMESH_CellLabelActor::New();
00162   my2DActor->SetStoreGemetryMapping(true);
00163   my2DActor->SetUserMatrix(aMatrix);
00164   my2DActor->PickableOff();
00165   my2DActor->SetProperty(mySurfaceProp);
00166   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
00167   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00168   aFilter = my2DActor->GetExtractUnstructuredGrid();
00169   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00170   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
00171   aFilter->RegisterCellsWithType(VTK_POLYGON);
00172   aFilter->RegisterCellsWithType(VTK_QUAD);
00173   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
00174   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
00175   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
00176 
00177   my2DExtProp = vtkProperty::New();
00178   my2DExtProp->DeepCopy(mySurfaceProp);
00179   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00180   anRGB[0] = 1 - anRGB[0];
00181   anRGB[1] = 1 - anRGB[1];
00182   anRGB[2] = 1 - anRGB[2];
00183   my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00184 
00185   my2DExtActor = SMESH_DeviceActor::New();
00186   my2DExtActor->SetUserMatrix(aMatrix);
00187   my2DExtActor->PickableOff();
00188   my2DExtActor->SetProperty(my2DExtProp);
00189   my2DExtActor->SetBackfaceProperty(my2DExtProp);
00190   my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
00191   aFilter = my2DExtActor->GetExtractUnstructuredGrid();
00192   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
00193   aFilter->RegisterCellsWithType(VTK_POLYGON);
00194   aFilter->RegisterCellsWithType(VTK_QUAD);
00195   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
00196   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
00197   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
00198 
00199   my3DActor = SMESH_CellLabelActor::New();
00200   my3DActor->SetStoreGemetryMapping(true);
00201   my3DActor->SetUserMatrix(aMatrix);
00202   my3DActor->PickableOff();
00203   my3DActor->SetProperty(mySurfaceProp);
00204   my3DActor->SetBackfaceProperty(myBackSurfaceProp);
00205   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00206   my3DActor->SetCoincident3DAllowed(true);
00207   aFilter = my3DActor->GetExtractUnstructuredGrid();
00208   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00209   aFilter->RegisterCellsWithType(VTK_TETRA);
00210   aFilter->RegisterCellsWithType(VTK_VOXEL);
00211   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
00212   aFilter->RegisterCellsWithType(VTK_WEDGE);
00213   aFilter->RegisterCellsWithType(VTK_PYRAMID);
00214   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
00215   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
00216   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
00217   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
00218   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
00219   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
00220   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
00221 //#ifdef VTK_HAVE_POLYHEDRON
00222   MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
00223   aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
00224 //#endif
00225 
00226   my3DExtActor = SMESH_DeviceActor::New();
00227   my3DExtActor->SetUserMatrix(aMatrix);
00228   my3DExtActor->PickableOff();
00229   my3DExtActor->SetProperty(my2DExtProp);
00230   my3DExtActor->SetBackfaceProperty(my2DExtProp);
00231   my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00232   my3DExtActor->SetCoincident3DAllowed(true);
00233   aFilter = my3DExtActor->GetExtractUnstructuredGrid();
00234   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00235   aFilter->RegisterCellsWithType(VTK_TETRA);
00236   aFilter->RegisterCellsWithType(VTK_VOXEL);
00237   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
00238   aFilter->RegisterCellsWithType(VTK_WEDGE);
00239   aFilter->RegisterCellsWithType(VTK_PYRAMID);
00240   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
00241   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
00242   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
00243   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
00244   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
00245   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
00246   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
00247   aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
00248 
00249   //Definition 1D device of the actor
00250   //---------------------------------
00251   myEdgeProp = vtkProperty::New();
00252   myEdgeProp->SetAmbient(1.0);
00253   myEdgeProp->SetDiffuse(0.0);
00254   myEdgeProp->SetSpecular(0.0);
00255   SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00256   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00257   myEdgeProp->SetLineWidth(aLineWidth);
00258 
00259   my1DActor = SMESH_CellLabelActor::New();
00260   my1DActor->SetStoreGemetryMapping(true);
00261   my1DActor->SetUserMatrix(aMatrix);
00262   my1DActor->PickableOff();
00263   my1DActor->SetHighlited(true);
00264   my1DActor->SetProperty(myEdgeProp);
00265   my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00266   aFilter = my1DActor->GetExtractUnstructuredGrid();
00267   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00268   aFilter->RegisterCellsWithType(VTK_LINE);
00269   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
00270 
00271   my1DProp = vtkProperty::New();
00272   my1DProp->DeepCopy(myEdgeProp);
00273   my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
00274   my1DProp->SetPointSize(aElem0DSize);
00275   
00276   my1DExtProp = vtkProperty::New();
00277   my1DExtProp->DeepCopy(myEdgeProp);
00278   anRGB[0] = 1 - anRGB[0];
00279   anRGB[1] = 1 - anRGB[1];
00280   anRGB[2] = 1 - anRGB[2];
00281   my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00282   my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
00283   my1DExtProp->SetPointSize(aElem0DSize);
00284 
00285   my1DExtActor = SMESH_DeviceActor::New();
00286   my1DExtActor->SetUserMatrix(aMatrix);
00287   my1DExtActor->PickableOff();
00288   my1DExtActor->SetHighlited(true);
00289   my1DExtActor->SetVisibility(false);
00290   my1DExtActor->SetProperty(my1DExtProp);
00291   my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
00292   aFilter = my1DExtActor->GetExtractUnstructuredGrid();
00293   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00294   aFilter->RegisterCellsWithType(VTK_LINE);
00295   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
00296 
00297 
00298   //Definition 0D device of the actor (0d elements)
00299   //-----------------------------------------------
00300   my0DProp = vtkProperty::New();
00301   SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
00302   my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00303   my0DProp->SetPointSize(aElem0DSize);
00304 
00305   my0DActor = SMESH_CellLabelActor::New();
00306   my0DActor->SetUserMatrix(aMatrix);
00307   my0DActor->SetStoreGemetryMapping(true);
00308   my0DActor->PickableOff();
00309   my0DActor->SetVisibility(false);
00310   my0DActor->SetProperty(my0DProp);
00311   my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00312   aFilter = my0DActor->GetExtractUnstructuredGrid();
00313   //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
00314   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00315   aFilter->RegisterCellsWithType(VTK_VERTEX);
00316   
00317   //my0DExtProp = vtkProperty::New();
00318   //my0DExtProp->DeepCopy(my0DProp);
00319   //anRGB[0] = 1 - anRGB[0];
00320   //anRGB[1] = 1 - anRGB[1];
00321   //anRGB[2] = 1 - anRGB[2];
00322   //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00323   //my0DExtProp->SetPointSize(aElem0DSize);
00324   //
00325   //my0DExtActor = SMESH_DeviceActor::New();
00326   //my0DExtActor->SetUserMatrix(aMatrix);
00327   //my0DExtActor->SetStoreClippingMapping(true);
00328   //my0DExtActor->PickableOff();
00329   //my0DExtActor->SetHighlited(true);
00330   //my0DExtActor->SetVisibility(false);
00331   //my0DExtActor->SetProperty(my0DExtProp);
00332   //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
00333   //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
00335   //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00336   //aFilter->RegisterCellsWithType(VTK_VERTEX);
00337 
00338 
00339   //Definition 0D device of the actor (nodes)
00340   //-----------------------------------------
00341   myNodeProp = vtkProperty::New();
00342   SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
00343   myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00344 
00345   myNodeActor = SMESH_NodeLabelActor::New();
00346   myNodeActor->SetUserMatrix(aMatrix);
00347   myNodeActor->SetStoreClippingMapping(true);
00348   myNodeActor->PickableOff();
00349   myNodeActor->SetVisibility(false);
00350   myNodeActor->SetProperty(myNodeProp);
00351   myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
00352   aFilter = myNodeActor->GetExtractUnstructuredGrid();
00353   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
00354   
00355   myNodeExtProp = vtkProperty::New();
00356   myNodeExtProp->DeepCopy(myNodeProp);
00357   anRGB[0] = 1 - anRGB[0];
00358   anRGB[1] = 1 - anRGB[1];
00359   anRGB[2] = 1 - anRGB[2];
00360   myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00361 
00362   myNodeExtActor = SMESH_DeviceActor::New();
00363   myNodeExtActor->SetUserMatrix(aMatrix);
00364   myNodeExtActor->SetStoreClippingMapping(true);
00365   myNodeExtActor->PickableOff();
00366   myNodeExtActor->SetHighlited(true);
00367   myNodeExtActor->SetVisibility(false);
00368   myNodeExtActor->SetProperty(myNodeExtProp);
00369   myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
00370   aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
00371   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
00372   aFilter->RegisterCellsWithType(VTK_VERTEX);
00373 
00374   //Definition of Pickable and Highlitable engines
00375   //----------------------------------------------
00376 
00377   myBaseActor->SetUserMatrix(aMatrix);
00378   myBaseActor->SetStoreGemetryMapping(true);
00379   myBaseActor->GetProperty()->SetOpacity(0.0);
00380   myPickableActor = myBaseActor;
00381   
00382   myHighlightProp = vtkProperty::New();
00383   myHighlightProp->SetAmbient(1.0);
00384   myHighlightProp->SetDiffuse(0.0);
00385   myHighlightProp->SetSpecular(0.0);
00386   SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
00387   myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00388   myHighlightProp->SetPointSize(aElem0DSize); // ??
00389   myHighlightProp->SetLineWidth(aLineWidth);
00390   myHighlightProp->SetRepresentation(1);
00391 
00392   myOutLineProp = vtkProperty::New();
00393   myOutLineProp->SetAmbient(1.0);
00394   myOutLineProp->SetDiffuse(0.0);
00395   myOutLineProp->SetSpecular(0.0);
00396   SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
00397   myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00398   myOutLineProp->SetPointSize(aElem0DSize); // ??
00399   myOutLineProp->SetLineWidth(aLineWidth);
00400   myOutLineProp->SetRepresentation(1);
00401 
00402   myPreselectProp = vtkProperty::New();
00403   myPreselectProp->SetAmbient(1.0);
00404   myPreselectProp->SetDiffuse(0.0);
00405   myPreselectProp->SetSpecular(0.0);
00406   SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
00407   myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00408   myPreselectProp->SetPointSize(aElem0DSize); // ??
00409   myPreselectProp->SetLineWidth(aLineWidth);
00410   myPreselectProp->SetRepresentation(1);
00411 
00412   myHighlitableActor = SMESH_DeviceActor::New();
00413   myHighlitableActor->SetUserMatrix(aMatrix);
00414   myHighlitableActor->PickableOff();
00415   myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
00416   myHighlitableActor->SetCoincident3DAllowed(true);
00417 
00418   aMatrix->Delete();
00419 
00420   myName = "";
00421   myIO = NULL;
00422 
00423   myControlMode = eNone;
00424   myControlActor = my2DActor;
00425 
00426   //Definition of myScalarBarActor
00427   //------------------------------
00428   myLookupTable = vtkLookupTable::New();
00429   //Fix for Bug PAL5195 - SMESH764: 
00430   //Controls - Aspect Ratio: incorrect colors of the best and worst values
00431   myLookupTable->SetHueRange(0.667,0.0);
00432 
00433   myScalarBarActor = SMESH_ScalarBarActor::New();
00434   myScalarBarActor->SetVisibility(false);
00435   myScalarBarActor->SetLookupTable(myLookupTable);
00436 
00437   //Fix for Bug 13314:
00438   //Incorrect "Min value" in Scalar Bar in Mesh:
00439   //  myScalarBarActor->SetLabelFormat("%.4g");
00440   // changes was commented because of regression bug IPAL 19981
00441 
00442   mgr = SUIT_Session::session()->resourceMgr();
00443   if( !mgr )
00444     return;
00445 
00446   myEntityMode = eAllEntity;
00447   myEntityModeCache = eAllEntity;
00448   
00449   // Clipping planes
00450   myImplicitBoolean = vtkImplicitBoolean::New();
00451   myImplicitBoolean->SetOperationTypeToIntersection();
00452   
00453   //Quadratic 2D elements representation
00454   //-----------------------------------------------------------------------------
00455   int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
00456   if(aQuadratic2DMode == 0){
00457     myHighlitableActor->SetQuadraticArcMode(false);
00458     my2DActor->SetQuadraticArcMode(false);
00459     my1DActor->SetQuadraticArcMode(false);
00460   }
00461   else if(aQuadratic2DMode == 1){
00462     myHighlitableActor->SetQuadraticArcMode(true);
00463     my2DActor->SetQuadraticArcMode(true);
00464     my1DActor->SetQuadraticArcMode(true);
00465   }
00466   
00467   int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
00468   myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
00469   my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
00470   
00471   // Set colors of the name actor
00472   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00473   myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
00474   SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
00475   myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
00476 
00477 #ifndef DISABLE_PLOT2DVIEWER
00478   my2dHistogram = 0;
00479 #endif
00480 
00481 }
00482 
00483 
00484 SMESH_ActorDef::~SMESH_ActorDef()
00485 {
00486   if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
00487 
00488 #ifndef DISABLE_PLOT2DVIEWER
00489   if(my2dHistogram) {
00490     SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
00491     delete my2dHistogram;
00492   }
00493 #endif
00494 
00495   myScalarBarActor->Delete();
00496   myLookupTable->Delete();
00497 
00498   mySurfaceProp->Delete();
00499   myBackSurfaceProp->Delete();
00500   myOutLineProp->Delete();
00501 
00502   myEdgeProp->Delete();
00503   myHighlightProp->Delete();
00504   myPreselectProp->Delete();
00505 
00506   myNodeProp->Delete();
00507   myNodeExtProp->Delete();
00508  
00509   my0DProp->Delete();
00510   my0DActor->Delete();
00511 
00512   //my0DExtProp->Delete();
00513   //my0DExtActor->Delete();
00514  
00515   my1DProp->Delete();
00516   my1DActor->Delete();
00517 
00518   my1DExtProp->Delete();
00519   my1DExtActor->Delete();
00520 
00521   my2DActor->Delete();
00522   my2DExtProp->Delete();
00523   my2DExtActor->Delete();
00524   my3DActor->Delete();
00525   my3DExtActor->Delete();
00526 
00527   myNodeActor->Delete();
00528   myBaseActor->Delete();
00529 
00530   myNodeExtActor->Delete();  
00531   myHighlitableActor->Delete();
00532 
00533   myImplicitBoolean->Delete();
00534 
00535   myTimeStamp->Delete();
00536 }
00537 
00538 void SMESH_ActorDef::Delete()
00539 {
00540   // This is just to guarantee that the DeleteActorEvent (which was previously invoked
00541   // from the actor's destructor) will be thrown before removing the actor's observers,
00542   // that is done inside the Superclass::Delete() method but before the destructor itself
00543   // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
00544   // The event is caught by SMESHGUI::ProcessEvents() static method.
00545   this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
00546 
00547   Superclass::Delete();
00548 }
00549 
00550 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
00551 {    
00552   if(myNodeActor) {
00553     myNodeActor->SetPointsLabeled(theIsPointsLabeled);
00554     SetRepresentation(GetRepresentation());
00555     myTimeStamp->Modified();
00556   }
00557 }
00558 
00559 bool SMESH_ActorDef::GetPointsLabeled() {
00560   return myNodeActor && myNodeActor->GetPointsLabeled();
00561 }
00562 
00563 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
00564 {
00565   if(my3DActor)
00566     my3DActor->SetCellsLabeled(theIsCellsLabeled);
00567 
00568   if(my2DActor)
00569     my2DActor->SetCellsLabeled(theIsCellsLabeled);
00570 
00571   if(my1DActor)
00572     my1DActor->SetCellsLabeled(theIsCellsLabeled);
00573 
00574   if(my0DActor)
00575     my0DActor->SetCellsLabeled(theIsCellsLabeled);
00576   
00577   myTimeStamp->Modified();
00578 }
00579 
00580 
00581 bool SMESH_ActorDef::GetCellsLabeled() {
00582   bool result = false;
00583   if(my3DActor)
00584     result = result || my3DActor->GetCellsLabeled();
00585 
00586   if(my2DActor)
00587     result = result || my2DActor->GetCellsLabeled();
00588 
00589   if(my1DActor)
00590     result = result || my1DActor->GetCellsLabeled();
00591 
00592   if(my0DActor)
00593     result = result || my0DActor->GetCellsLabeled();
00594 
00595   return result;
00596 }
00597 
00598 
00599 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
00600 {
00601   myIsFacesOriented = theIsFacesOriented;
00602 
00603   my2DActor->SetFacesOriented(theIsFacesOriented);
00604   my3DActor->SetFacesOriented(theIsFacesOriented);
00605 
00606   myTimeStamp->Modified();
00607 }
00608 
00609 bool SMESH_ActorDef::GetFacesOriented()
00610 {
00611   return myIsFacesOriented;
00612 }
00613 
00614 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
00615 {
00616   my2DActor->SetFacesOrientationColor( theColor );
00617   my3DActor->SetFacesOrientationColor( theColor );
00618 }
00619 
00620 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
00621 {
00622   my3DActor->GetFacesOrientationColor( theColor );
00623 }
00624 
00625 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
00626 {
00627   my2DActor->SetFacesOrientationScale( theScale );
00628   my3DActor->SetFacesOrientationScale( theScale );
00629 }
00630 
00631 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
00632 {
00633   return my3DActor->GetFacesOrientationScale();
00634 }
00635 
00636 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
00637 {
00638   my2DActor->SetFacesOrientation3DVectors( theState );
00639   my3DActor->SetFacesOrientation3DVectors( theState );
00640 }
00641 
00642 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
00643 {
00644   return my3DActor->GetFacesOrientation3DVectors();
00645 }
00646 
00647 
00648 void 
00649 SMESH_ActorDef::
00650 SetControlMode(eControl theMode)
00651 {
00652   SetControlMode(theMode,true);
00653 }
00654 
00655 
00656 void 
00657 SMESH_ActorDef::
00658 SetControlMode(eControl theMode,
00659                bool theCheckEntityMode)
00660 {
00661   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();  
00662   if( !mgr )
00663     return;
00664 
00665   myControlMode = eNone;
00666   theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
00667 
00668   my0DActor->GetMapper()->SetScalarVisibility(false);
00669   my1DActor->GetMapper()->SetScalarVisibility(false);
00670   my2DActor->GetMapper()->SetScalarVisibility(false);
00671   my3DActor->GetMapper()->SetScalarVisibility(false);
00672   myScalarBarActor->SetVisibility(false);
00673 
00674   bool anIsScalarVisible = theMode > eNone;
00675 
00676   if(anIsScalarVisible) {
00677     switch(theMode) {
00678     case eLength:
00679     {
00680       SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
00681       aControl->SetPrecision( myControlsPrecision );
00682       myFunctor.reset( aControl );
00683       myControlActor = my1DActor;
00684       break;
00685     }
00686     case eLength2D:
00687     {
00688       myFunctor.reset(new SMESH::Controls::Length2D());
00689       myControlActor = my2DActor;
00690       break;
00691     }
00692     case eFreeBorders:
00693       myFunctor.reset(new SMESH::Controls::FreeBorders());
00694       myControlActor = my1DActor;
00695       break;
00696     case eFreeEdges:
00697       myFunctor.reset(new SMESH::Controls::FreeEdges());
00698       myControlActor = my2DActor;
00699       break;
00700     case eFreeNodes:
00701       myFunctor.reset(new SMESH::Controls::FreeNodes());
00702       myControlActor = myNodeActor;
00703       break;
00704     case eFreeFaces:
00705       myFunctor.reset(new SMESH::Controls::FreeFaces());
00706       myControlActor = my2DActor;
00707       break;
00708     case eCoincidentNodes:
00709       {
00710         SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
00711         double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
00712         cn->SetTolerance( tol );
00713         myFunctor.reset(cn);
00714         myControlActor = myNodeActor;
00715         break;
00716       }
00717     case eCoincidentElems1D:
00718       myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
00719       myControlActor = my1DActor;
00720       break;
00721     case eCoincidentElems2D:
00722       myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
00723       myControlActor = my2DActor;
00724       break;
00725     case eCoincidentElems3D:
00726       myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
00727       myControlActor = my3DActor;
00728       break;
00729     case eBareBorderFace:
00730       myFunctor.reset(new SMESH::Controls::BareBorderFace());
00731       myControlActor = my2DActor;
00732       break;
00733     case eOverConstrainedFace:
00734       myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
00735       myControlActor = my2DActor;
00736       break;
00737     case eMultiConnection:
00738       myFunctor.reset(new SMESH::Controls::MultiConnection());
00739       myControlActor = my1DActor;
00740       break;
00741     case eMultiConnection2D:
00742       myFunctor.reset(new SMESH::Controls::MultiConnection2D());
00743       myControlActor = my2DActor;
00744       break;
00745     case eArea:
00746     {
00747       SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
00748       aControl->SetPrecision( myControlsPrecision );
00749       myFunctor.reset( aControl );
00750       myControlActor = my2DActor;
00751       break;
00752     }
00753     case eTaper:
00754     {
00755       SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
00756       aControl->SetPrecision( myControlsPrecision );
00757       myFunctor.reset( aControl );
00758       myControlActor = my2DActor;
00759       break;
00760     }
00761     case eAspectRatio:
00762     {
00763       SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
00764       aControl->SetPrecision( myControlsPrecision );
00765       myFunctor.reset( aControl );
00766       myControlActor = my2DActor;
00767       break;
00768     }
00769     case eAspectRatio3D:
00770     {
00771       SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
00772       aControl->SetPrecision( myControlsPrecision );
00773       myFunctor.reset( aControl );
00774       myControlActor = my3DActor;
00775       break;
00776     }
00777     case eVolume3D:
00778     {
00779       SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
00780       aControl->SetPrecision( myControlsPrecision );
00781       myFunctor.reset( aControl );
00782       myControlActor = my3DActor;
00783       break;
00784     }
00785     case eMaxElementLength2D:
00786     {
00787       SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
00788       aControl->SetPrecision( myControlsPrecision );
00789       myFunctor.reset( aControl );
00790       myControlActor = my2DActor;
00791       break;
00792     }
00793     case eMaxElementLength3D:
00794     {
00795       SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
00796       aControl->SetPrecision( myControlsPrecision );
00797       myFunctor.reset( aControl );
00798       myControlActor = my3DActor;
00799       break;
00800     }
00801     case eBareBorderVolume:
00802     {
00803       myFunctor.reset(new SMESH::Controls::BareBorderVolume());
00804       myControlActor = my3DActor;
00805       break;
00806     }
00807     case eOverConstrainedVolume:
00808     {
00809       myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
00810       myControlActor = my3DActor;
00811       break;
00812     }
00813     case eMinimumAngle:
00814     {
00815       SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
00816       aControl->SetPrecision( myControlsPrecision );
00817       myFunctor.reset( aControl );
00818       myControlActor = my2DActor;
00819       break;
00820     }
00821     case eWarping:
00822     {
00823       SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
00824       aControl->SetPrecision( myControlsPrecision );
00825       myFunctor.reset( aControl );
00826       myControlActor = my2DActor;
00827       break;
00828     }
00829     case eSkew:
00830     {
00831       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
00832       aControl->SetPrecision( myControlsPrecision );
00833       myFunctor.reset( aControl );
00834       myControlActor = my2DActor;
00835       break;
00836     }
00837     default:
00838       return;
00839     }
00840 
00841     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
00842     vtkIdType aNbCells = aGrid->GetNumberOfCells();
00843     if(aNbCells){
00844       myControlMode = theMode;
00845       switch(myControlMode){
00846       case eFreeNodes:
00847       case eCoincidentNodes:
00848         myNodeExtActor->SetExtControlMode(myFunctor);
00849         break;
00850       case eFreeEdges:
00851       case eFreeBorders:
00852       case eCoincidentElems1D:
00853         my1DExtActor->SetExtControlMode(myFunctor);
00854         break;
00855       case eFreeFaces:
00856       case eBareBorderFace:
00857       case eOverConstrainedFace:
00858       case eCoincidentElems2D:
00859         my2DExtActor->SetExtControlMode(myFunctor);
00860         break;
00861       case eBareBorderVolume:
00862       case eOverConstrainedVolume:
00863       case eCoincidentElems3D:
00864         my3DExtActor->SetExtControlMode(myFunctor);
00865         break;
00866       case eLength2D:
00867       case eMultiConnection2D:
00868         my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
00869         UpdateDistribution();
00870         break;
00871       default:
00872         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
00873         UpdateDistribution();
00874       }
00875     }
00876 
00877     if(theCheckEntityMode) {
00878       if(myControlActor == my1DActor) {
00879         if (!myIsEntityModeCache){
00880           myEntityModeCache = GetEntityMode();
00881           myIsEntityModeCache=true;
00882         } 
00883         SetEntityMode(eEdges);
00884       }
00885       else if(myControlActor == my2DActor) {
00886         switch(myControlMode) {
00887         case eLength2D:
00888         case eFreeEdges:
00889         case eFreeFaces:
00890         case eMultiConnection2D:
00891           if (!myIsEntityModeCache){
00892             myEntityModeCache = GetEntityMode();
00893             myIsEntityModeCache=true;
00894           } 
00895           SetEntityMode(eFaces);
00896           break;
00897         default:
00898           if (!myIsEntityModeCache){
00899             myEntityModeCache = GetEntityMode();
00900             myIsEntityModeCache=true;
00901           }
00902           SetEntityMode(eFaces);
00903         }
00904       }else if(myControlActor == my3DActor) {
00905         if (!myIsEntityModeCache){
00906             myEntityModeCache = GetEntityMode();
00907             myIsEntityModeCache=true;
00908         } 
00909         SetEntityMode(eVolumes);
00910     }
00911     }
00912 
00913   }
00914   else {
00915     if(theCheckEntityMode){
00916       myEntityMode = myEntityModeCache;
00917       myIsEntityModeCache = false;
00918     }
00919     myFunctor.reset();
00920   }
00921 
00922   SetRepresentation(GetRepresentation());
00923 
00924   myTimeStamp->Modified();
00925   Modified();
00926   Update();
00927 }
00928 
00929 
00930 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
00931   theRenderer->AddActor(myBaseActor);  
00932   theRenderer->AddActor(myNodeExtActor);
00933   theRenderer->AddActor(my1DExtActor);
00934 
00935   my3DActor->AddToRender(theRenderer);
00936   my3DExtActor->AddToRender(theRenderer);
00937   my2DActor->AddToRender(theRenderer);
00938   my2DExtActor->AddToRender(theRenderer);
00939   myNodeActor->AddToRender(theRenderer);
00940   my1DActor->AddToRender(theRenderer);
00941   my0DActor->AddToRender(theRenderer);
00942   //theRenderer->AddActor(my0DExtActor);
00943 
00944   theRenderer->AddActor(myHighlitableActor);
00945   
00946   theRenderer->AddActor2D(myScalarBarActor);
00947 
00948   // the superclass' method should be called at the end
00949   // (in particular, for correct work of selection)
00950   SALOME_Actor::AddToRender(theRenderer);
00951 }
00952 
00953 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
00954   SALOME_Actor::RemoveFromRender(theRenderer);
00955 
00956   theRenderer->RemoveActor(myBaseActor);
00957 
00958   theRenderer->RemoveActor(myNodeExtActor);
00959 
00960   theRenderer->RemoveActor(myHighlitableActor);
00961 
00962   //theRenderer->RemoveActor(my0DExtActor);
00963 
00964   theRenderer->RemoveActor(my1DExtActor);
00965 
00966   my2DActor->RemoveFromRender(theRenderer);
00967   my2DExtActor->RemoveFromRender(theRenderer);
00968   my3DActor->RemoveFromRender(theRenderer);
00969   my3DExtActor->RemoveFromRender(theRenderer);
00970   myNodeActor->RemoveFromRender(theRenderer);
00971   my0DActor->RemoveFromRender(theRenderer);
00972   my1DActor->RemoveFromRender(theRenderer);
00973 
00974   theRenderer->RemoveActor(myScalarBarActor);
00975 }
00976 
00977 
00978 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, 
00979                           const char* theEntry, 
00980                           const char* theName,
00981                           int theIsClear)
00982 {
00983   Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
00984   setIO(anIO);
00985   setName(theName);
00986 
00987   myVisualObj = theVisualObj;
00988   myVisualObj->Update(theIsClear);
00989 
00990   myNodeActor->Init(myVisualObj,myImplicitBoolean);
00991   myBaseActor->Init(myVisualObj,myImplicitBoolean);
00992 
00993   myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
00994 
00995   myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
00996   
00997   my0DActor->Init(myVisualObj,myImplicitBoolean);
00998   //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
00999   
01000   my1DActor->Init(myVisualObj,myImplicitBoolean);
01001   my1DExtActor->Init(myVisualObj,myImplicitBoolean);
01002   
01003   my2DActor->Init(myVisualObj,myImplicitBoolean);
01004   my2DExtActor->Init(myVisualObj,myImplicitBoolean);
01005   my3DActor->Init(myVisualObj,myImplicitBoolean);
01006   my3DExtActor->Init(myVisualObj,myImplicitBoolean);
01007   
01008   my0DActor->GetMapper()->SetLookupTable(myLookupTable);
01009   //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01010   
01011   my1DActor->GetMapper()->SetLookupTable(myLookupTable);
01012   my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01013 
01014   my2DActor->GetMapper()->SetLookupTable(myLookupTable);
01015   my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01016   my3DActor->GetMapper()->SetLookupTable(myLookupTable);
01017   my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01018     
01019   vtkFloatingPointType aFactor, aUnits;
01020   my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
01021   my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
01022   my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
01023 
01024   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
01025   if( !mgr )
01026     return false;
01027 
01028   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
01029   SetIsShrunkable(true);
01030 
01031   SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
01032 
01033   int aMode = mgr->integerValue( "SMESH", "display_mode" );
01034   SetRepresentation(-1);
01035   
01036   if(aMode == 0){
01037     SetRepresentation(eEdge);
01038   }else if(aMode == 1){
01039     SetRepresentation(eSurface);
01040   }else if(aMode == 2){
01041     SetRepresentation(ePoint);
01042   }
01043   
01044   if(aMode == 3){
01045     SetShrink();
01046   }
01047 
01048   if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01049     SetIsDisplayNameActor( true );
01050 
01051   int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
01052   int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 );  // 5 pixels
01053   SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
01054 
01055   myTimeStamp->Modified();
01056   Modified();
01057   return true;
01058 }
01059 
01060 
01061 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
01062   return myNodeActor->GetBounds();
01063 }
01064 
01065 
01066 vtkDataSet* SMESH_ActorDef::GetInput(){
01067   return GetUnstructuredGrid();
01068 }
01069 
01070 
01071 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
01072   Superclass::SetTransform(theTransform);
01073 
01074   myNodeActor->SetTransform(theTransform);
01075   myBaseActor->SetTransform(theTransform);
01076   
01077   myHighlitableActor->SetTransform(theTransform);
01078 
01079   myNodeExtActor->SetTransform(theTransform);
01080 
01081   my0DActor->SetTransform(theTransform);
01082   //my0DExtActor->SetTransform(theTransform);
01083 
01084   my1DActor->SetTransform(theTransform);
01085   my1DExtActor->SetTransform(theTransform);
01086 
01087   my2DActor->SetTransform(theTransform);
01088   my2DExtActor->SetTransform(theTransform);
01089   my3DActor->SetTransform(theTransform);
01090   my3DExtActor->SetTransform(theTransform);
01091 
01092   Modified();
01093 }
01094 
01095 
01096 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
01097   vtkLODActor::SetMapper(theMapper);
01098 }
01099 
01100 
01101 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
01102   SALOME_Actor::ShallowCopy(prop);
01103 }
01104 
01105 
01106 vtkMapper* SMESH_ActorDef::GetMapper(){
01107   return myPickableActor->GetMapper();
01108 }
01109 
01110 
01111 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){ 
01112   return myVisualObj->GetUnstructuredGrid();
01113 }
01114 
01115 
01116 bool SMESH_ActorDef::IsInfinitive(){
01117   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
01118   aDataSet->Update();
01119   myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
01120     ( aDataSet->GetNumberOfCells() == 1 && 
01121     aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
01122   return SALOME_Actor::IsInfinitive();
01123 }
01124 
01125 
01126 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
01127   if ( myIsShrinkable == theShrunkable )
01128     return;
01129   myIsShrinkable = theShrunkable;
01130   Modified();
01131 }
01132 
01133 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
01134   return myBaseActor->GetShrinkFactor();
01135 }
01136 
01137 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
01138   myBaseActor->SetShrinkFactor(theValue);
01139 
01140   my1DActor->SetShrinkFactor(theValue);
01141   my1DExtActor->SetShrinkFactor(theValue);
01142 
01143   my2DActor->SetShrinkFactor(theValue);
01144   my2DExtActor->SetShrinkFactor(theValue);
01145   my3DActor->SetShrinkFactor(theValue);
01146   my3DExtActor->SetShrinkFactor(theValue);
01147   my3DExtActor->SetShrinkFactor(theValue);
01148   myHighlitableActor->SetShrinkFactor(theValue);
01149 
01150   Modified();
01151 }
01152 
01153 void SMESH_ActorDef::SetShrink(){
01154   if(!myIsShrinkable) return;
01155 
01156   myBaseActor->SetShrink();
01157 
01158   my1DActor->SetShrink();
01159   my1DExtActor->SetShrink();
01160 
01161   my2DActor->SetShrink();
01162   my2DExtActor->SetShrink();
01163   my3DActor->SetShrink();
01164   my3DExtActor->SetShrink();
01165   myHighlitableActor->SetShrink();
01166 
01167   myIsShrunk = true;
01168   Modified();
01169 }
01170 
01171 void SMESH_ActorDef::UnShrink(){
01172   if(!myIsShrunk) return;
01173 
01174   myBaseActor->UnShrink();
01175 
01176   my1DActor->UnShrink();
01177   my1DExtActor->UnShrink();
01178 
01179   my2DActor->UnShrink();
01180   my2DExtActor->UnShrink();
01181   my3DActor->UnShrink();
01182   my3DExtActor->UnShrink();
01183   myHighlitableActor->UnShrink();
01184 
01185   myIsShrunk = false;
01186   Modified();
01187 }
01188 
01189 
01190 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
01191   return myPickableActor->GetNodeObjId(theVtkID);
01192 }
01193 
01194 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
01195   return myPickableActor->GetNodeCoord(theObjID);
01196 }
01197 
01198 
01199 int SMESH_ActorDef::GetElemObjId(int theVtkID){
01200   return myPickableActor->GetElemObjId(theVtkID);
01201 }
01202 
01203 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
01204   return myPickableActor->GetElemCell(theObjID);
01205 }
01206 
01207 
01208 void SMESH_ActorDef::SetVisibility(int theMode){
01209   SetVisibility(theMode,true);
01210 }
01211 
01212 
01213 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
01214   SALOME_Actor::SetVisibility(theMode);
01215 
01216   myNodeActor->VisibilityOff();
01217   myBaseActor->VisibilityOff();
01218   
01219   myNodeExtActor->VisibilityOff();
01220 
01221   my0DActor->VisibilityOff();
01222   //my0DExtActor->VisibilityOff();
01223 
01224   my1DActor->VisibilityOff();
01225   my1DExtActor->VisibilityOff();
01226   
01227   my2DActor->VisibilityOff();
01228   my2DExtActor->VisibilityOff();
01229   my3DActor->VisibilityOff();
01230   my3DExtActor->VisibilityOff();
01231   
01232   myScalarBarActor->VisibilityOff();
01233   
01234   if(GetVisibility()){
01235     if(theIsUpdateRepersentation)
01236       SetRepresentation(GetRepresentation());
01237     
01238     if(myControlMode != eNone){
01239       switch(myControlMode){
01240       case eFreeNodes:
01241       case eCoincidentNodes:
01242         myNodeExtActor->VisibilityOn();
01243         break;
01244       case eFreeEdges:
01245       case eFreeBorders:
01246       case eCoincidentElems1D:
01247         my1DExtActor->VisibilityOn();
01248         break;
01249       case eFreeFaces:
01250       case eBareBorderFace:
01251       case eOverConstrainedFace:
01252       case eCoincidentElems2D:
01253         my2DExtActor->VisibilityOn();
01254         break;
01255       case eBareBorderVolume:
01256       case eOverConstrainedVolume:
01257       case eCoincidentElems3D:
01258         my3DExtActor->VisibilityOn();
01259         break;
01260       case eLength2D:
01261       case eMultiConnection2D:
01262         my1DExtActor->VisibilityOn();
01263       default:
01264         if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
01265           myScalarBarActor->VisibilityOn();
01266       }
01267     }
01268 
01269     if(myRepresentation != ePoint)
01270       myPickableActor->VisibilityOn();
01271     else {
01272       myNodeActor->VisibilityOn();
01273     }
01274 
01275     if(myEntityMode & e0DElements){
01276       my0DActor->VisibilityOn();
01277     }
01278 
01279     if(myEntityMode & eEdges && GetRepresentation() != ePoint){
01280       my1DActor->VisibilityOn();
01281     }
01282     
01283     if(myEntityMode & eFaces && GetRepresentation() != ePoint){
01284       my2DActor->VisibilityOn();
01285     }
01286     
01287     if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
01288       my3DActor->VisibilityOn();
01289     }
01290     
01291     if(myNodeActor->GetPointsLabeled()){ 
01292       myNodeActor->VisibilityOn();
01293     }
01294 
01295     if(my0DActor)
01296       my0DActor->UpdateLabels();
01297     
01298     if(my1DActor)
01299       my1DActor->UpdateLabels();
01300     
01301     if(my2DActor)
01302       my2DActor->UpdateLabels();
01303     
01304     if(my3DActor)
01305       my3DActor->UpdateLabels();    
01306   } 
01307 #ifndef DISABLE_PLOT2DVIEWER
01308   else
01309     SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
01310 #endif
01311   UpdateHighlight();
01312   Modified();
01313 }
01314 
01315 
01316 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
01317 {
01318   myEntityState = eAllEntity;
01319 
01320   if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
01321     myEntityState &= ~e0DElements;
01322     theMode &= ~e0DElements;
01323   }
01324 
01325   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
01326     myEntityState &= ~eEdges;
01327     theMode &= ~eEdges;
01328   }
01329 
01330   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
01331     myEntityState &= ~eFaces;
01332     theMode &= ~eFaces;
01333   }
01334 
01335   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
01336     myEntityState &= ~eVolumes;
01337     theMode &= ~eVolumes;
01338   }
01339 
01340   if (!theMode) {
01341     if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
01342       theMode |= e0DElements;
01343 
01344     if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
01345       theMode |= eEdges;
01346 
01347     if(myVisualObj->GetNbEntities(SMDSAbs_Face))
01348       theMode |= eFaces;
01349 
01350     if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
01351       theMode |= eVolumes;
01352   }
01353 
01354   myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
01355 
01356   myEntityMode = theMode;
01357   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
01358   aFilter = myBaseActor->GetExtractUnstructuredGrid();
01359   aFilter->ClearRegisteredCellsWithType();
01360   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
01361 
01362   VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
01363   aHightFilter->ClearRegisteredCellsWithType();
01364   aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
01365 
01366   if (myEntityMode & e0DElements) {
01367     if (MYDEBUG) MESSAGE("0D ELEMENTS");
01368     aFilter->RegisterCellsWithType(VTK_VERTEX);
01369     aHightFilter->RegisterCellsWithType(VTK_VERTEX);
01370   }
01371 
01372   if (myEntityMode & eEdges) {
01373     if (MYDEBUG) MESSAGE("EDGES");
01374     aFilter->RegisterCellsWithType(VTK_LINE);
01375     aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
01376 
01377     aHightFilter->RegisterCellsWithType(VTK_LINE);
01378     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
01379   }
01380 
01381   if (myEntityMode & eFaces) {
01382     if (MYDEBUG) MESSAGE("FACES");
01383     aFilter->RegisterCellsWithType(VTK_TRIANGLE);
01384     aFilter->RegisterCellsWithType(VTK_POLYGON);
01385     aFilter->RegisterCellsWithType(VTK_QUAD);
01386     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
01387     aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
01388     aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
01389 
01390     aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
01391     aHightFilter->RegisterCellsWithType(VTK_POLYGON);
01392     aHightFilter->RegisterCellsWithType(VTK_QUAD);
01393     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
01394     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
01395     aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
01396   }
01397 
01398   if (myEntityMode & eVolumes) {
01399     if (MYDEBUG) MESSAGE("VOLUMES");
01400     aFilter->RegisterCellsWithType(VTK_TETRA);
01401     aFilter->RegisterCellsWithType(VTK_VOXEL);
01402     aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
01403     aFilter->RegisterCellsWithType(VTK_WEDGE);
01404     aFilter->RegisterCellsWithType(VTK_PYRAMID);
01405     aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
01406     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
01407     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
01408     aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
01409     aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
01410     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
01411 //#ifdef VTK_HAVE_POLYHEDRON
01412     aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
01413 //#endif
01414     
01415     aHightFilter->RegisterCellsWithType(VTK_TETRA);
01416     aHightFilter->RegisterCellsWithType(VTK_VOXEL);
01417     aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
01418     aHightFilter->RegisterCellsWithType(VTK_WEDGE);
01419     aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
01420     aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
01421     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
01422     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
01423     aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
01424     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
01425     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
01426     aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
01427 //#ifdef VTK_HAVE_POLYHEDRON
01428     aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
01429 //#endif
01430   }
01431   aFilter->Update();
01432   if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
01433   SetVisibility(GetVisibility(),false);
01434 }
01435 
01436 void SMESH_ActorDef::SetRepresentation (int theMode)
01437 { 
01438   int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
01439   int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
01440   int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
01441 
01442   if (theMode < 0) {
01443     myRepresentation = eSurface;
01444     if (!aNbFaces && !aNbVolumes && aNbEdges) {
01445       myRepresentation = eEdge;
01446     } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
01447       myRepresentation = ePoint;
01448     }
01449   } else {
01450     switch (theMode) {
01451     case eEdge:
01452       if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
01453       break;
01454     case eSurface:
01455       if (!aNbFaces && !aNbVolumes) return;
01456       break;
01457     }    
01458     myRepresentation = theMode;
01459   }
01460 
01461   if (!GetUnstructuredGrid()->GetNumberOfCells())
01462     myRepresentation = ePoint;
01463 
01464   if (myIsShrunk) {
01465     if (myRepresentation == ePoint) {
01466       UnShrink();
01467       myIsShrunk = true;
01468     } else {
01469       SetShrink();
01470     }      
01471   }
01472 
01473   myPickableActor = myBaseActor;
01474   myNodeActor->SetVisibility(false);
01475   myNodeExtActor->SetVisibility(false);
01476   vtkProperty *aProp = NULL, *aBackProp = NULL;
01477   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
01478   SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
01479   switch (myRepresentation) {
01480   case ePoint:
01481     myPickableActor = myNodeActor;
01482     myNodeActor->SetVisibility(true);
01483     aQuadraticMode = SMESH_Actor::eLines;
01484     aProp = aBackProp = myNodeProp;
01485     aReperesent = SMESH_DeviceActor::ePoint;
01486     break;
01487   case eEdge:
01488     aProp = aBackProp = myEdgeProp;
01489     aReperesent = SMESH_DeviceActor::eInsideframe;
01490     break;
01491   case eSurface:
01492     aProp = mySurfaceProp;
01493     aBackProp = myBackSurfaceProp;
01494     aReperesent = SMESH_DeviceActor::eSurface;
01495     break;
01496   }
01497 
01498   my2DActor->SetProperty(aProp);
01499   my2DActor->SetBackfaceProperty(aBackProp);
01500   my2DActor->SetRepresentation(aReperesent);
01501 
01502   if(aQuadraticMode == SMESH_Actor::eLines)
01503     my2DActor->SetQuadraticArcMode(false);
01504   else if(aQuadraticMode == SMESH_Actor::eArcs)
01505     my2DActor->SetQuadraticArcMode(true);
01506 
01507   my2DExtActor->SetRepresentation(aReperesent);
01508   
01509   my3DActor->SetProperty(aProp);
01510   my3DActor->SetBackfaceProperty(aBackProp);
01511   my3DActor->SetRepresentation(aReperesent);
01512 
01513   //my0DExtActor->SetVisibility(false);
01514   my1DExtActor->SetVisibility(false);
01515   my2DExtActor->SetVisibility(false);
01516   my3DExtActor->SetVisibility(false);
01517 
01518   // ???
01519   //my0DActor->SetProperty(aProp);
01520   //my0DActor->SetBackfaceProperty(aBackProp);
01521   my0DActor->SetRepresentation(aReperesent);
01522   //my0DExtActor->SetRepresentation(aReperesent);
01523 
01524   switch(myControlMode){
01525   case eLength:
01526   case eMultiConnection:
01527     aProp = aBackProp = my1DProp;
01528     if(myRepresentation != ePoint)
01529       aReperesent = SMESH_DeviceActor::eInsideframe;
01530     break;
01531   }
01532   
01533   if(aQuadraticMode == SMESH_Actor::eLines)
01534     my1DActor->SetQuadraticArcMode(false);
01535   else if(aQuadraticMode == SMESH_Actor::eArcs)
01536     my1DActor->SetQuadraticArcMode(true);
01537 
01538   my1DActor->SetProperty(aProp);
01539   my1DActor->SetBackfaceProperty(aBackProp);
01540   my1DActor->SetRepresentation(aReperesent);
01541 
01542   my1DExtActor->SetRepresentation(aReperesent);
01543 
01544   if(myIsPointsVisible)
01545     myPickableActor = myNodeActor;
01546   if(GetPointRepresentation())
01547     myNodeActor->SetVisibility(true);
01548 
01549   SetMapper(myPickableActor->GetMapper());
01550 
01551   SetVisibility(GetVisibility(),false);
01552 
01553   Modified();
01554 }
01555 
01556 
01557 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
01558   if ( myIsPointsVisible == theIsPointsVisible )
01559     return;
01560   myIsPointsVisible = theIsPointsVisible;
01561   SetRepresentation(GetRepresentation());
01562 }
01563 
01564 bool SMESH_ActorDef::GetPointRepresentation(){ 
01565   return myIsPointsVisible || myNodeActor->GetPointsLabeled();
01566 }
01567 
01568 
01569 void SMESH_ActorDef::UpdateHighlight(){
01570   myHighlitableActor->SetHighlited(false);
01571   myHighlitableActor->SetVisibility(false);
01572 
01573   bool anIsVisible = GetVisibility();
01574 
01575   switch(myRepresentation){
01576   case SMESH_DeviceActor::eSurface:
01577   case SMESH_DeviceActor::eWireframe:
01578     {
01579       if(myIsHighlighted) {
01580         myHighlitableActor->SetProperty(myHighlightProp);
01581       }else if(myIsPreselected){
01582         myHighlitableActor->SetProperty(myPreselectProp);
01583       } else if(anIsVisible){
01584         (myRepresentation == eSurface) ? 
01585           myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
01586       }
01587       if(GetUnstructuredGrid()->GetNumberOfCells()) {
01588         myHighlitableActor->SetHighlited(anIsVisible);
01589         myHighlitableActor->GetExtractUnstructuredGrid()->
01590           SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
01591         myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
01592       }
01593       myHighlitableActor->SetVisibility(anIsVisible);
01594       break;
01595     }
01596   case SMESH_DeviceActor::ePoint:
01597     {
01598       if(myIsHighlighted) {
01599         myNodeActor->SetProperty(myHighlightProp);
01600       }else if(myIsPreselected) {
01601         myNodeActor->SetProperty(myPreselectProp);
01602       } else if(anIsVisible) {
01603         myNodeActor->SetProperty(myNodeProp);
01604       }
01605       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
01606       myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
01607       break;
01608     }
01609   }
01610 }
01611 
01612 
01613 void SMESH_ActorDef::highlight(bool theHighlight){
01614   if ( myIsHighlighted == theHighlight )
01615     return;
01616   myIsHighlighted = theHighlight;
01617   UpdateHighlight();
01618 }
01619 
01620 
01621 void SMESH_ActorDef::SetPreSelected(bool thePreselect){ 
01622   if ( myIsPreselected == thePreselect )
01623     return;
01624   myIsPreselected = thePreselect; 
01625   UpdateHighlight();
01626 }
01627 
01628 
01629 // From vtkFollower
01630 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
01631 {
01632   if (myPickableActor->GetIsOpaque())
01633     {
01634     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
01635     this->Render(ren);
01636     return 1;
01637     }
01638   return 0;
01639 }
01640 
01641 
01642 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
01643 {
01644   if (!myPickableActor->GetIsOpaque())
01645     {
01646     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
01647     this->Render(ren);
01648     return 1;
01649     }
01650   return 0;
01651 }
01652 
01653 
01654 void SMESH_ActorDef::Render(vtkRenderer *ren){
01655   unsigned long aTime = myTimeStamp->GetMTime();
01656   unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
01657   unsigned long aClippingTime = myImplicitBoolean->GetMTime();
01658   if(anObjTime > aTime || aClippingTime > aTime)
01659     Update();
01660 }
01661 
01662 
01663 void SMESH_ActorDef::Update(){
01664   if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
01665 
01666   if(GetControlMode() != eNone) {
01667     unsigned long aTime = myTimeStamp->GetMTime();
01668     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
01669     if (anObjTime > aTime)
01670       SetControlMode(GetControlMode(),false);
01671   }
01672 
01673   if(myNodeActor)
01674     myNodeActor->UpdateLabels();
01675 
01676   if(my0DActor)
01677     my0DActor->UpdateLabels();
01678   
01679   if(my1DActor)
01680     my1DActor->UpdateLabels();
01681   
01682   if(my2DActor)
01683     my2DActor->UpdateLabels();
01684 
01685   if(my3DActor)
01686     my3DActor->UpdateLabels();
01687   
01688   if(myIsFacesOriented){
01689     SetFacesOriented(myIsFacesOriented);
01690   }
01691     
01692   if(myVisualObj->GetEntitiesFlag()) {
01693     myEntityMode |= myVisualObj->GetEntitiesState();
01694   }
01695   
01696   SetEntityMode(GetEntityMode());
01697   SetVisibility(GetVisibility());
01698   
01699   myTimeStamp->Modified();
01700   Modified();
01701 }
01702 
01703 
01704 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
01705   SALOME_Actor::ReleaseGraphicsResources(renWin);
01706 
01707   myPickableActor->ReleaseGraphicsResources(renWin);
01708 }
01709 
01710 
01711 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01712   vtkFloatingPointType* aColor = theProperty->GetColor();
01713   r = aColor[0];
01714   g = aColor[1];
01715   b = aColor[2];
01716 }
01717 
01718 
01719 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
01720   mySurfaceProp->SetOpacity(theValue);
01721   myBackSurfaceProp->SetOpacity(theValue);
01722   myEdgeProp->SetOpacity(theValue);
01723   myNodeProp->SetOpacity(theValue);
01724 
01725   my1DProp->SetOpacity(theValue);
01726 }
01727 
01728 
01729 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
01730   return mySurfaceProp->GetOpacity();
01731 }
01732 
01733 
01734 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
01735   mySurfaceProp->SetColor(r,g,b);
01736   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01737     if( aGroupObj->GetElementType() == SMDSAbs_Face ||
01738         aGroupObj->GetElementType() == SMDSAbs_Volume )
01739       myNameActor->SetBackgroundColor(r,g,b);
01740   
01741   myDeltaBrightness = delta;
01742   QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
01743   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
01744   Modified();
01745 }
01746 
01747 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
01748   ::GetColor(mySurfaceProp,r,g,b);
01749   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01750   delta = myDeltaBrightness;
01751 }
01752 
01753 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01754   myEdgeProp->SetColor(r,g,b);
01755   my1DProp->SetColor(r,g,b);
01756   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01757   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01758     if( aGroupObj->GetElementType() == SMDSAbs_Edge )
01759       myNameActor->SetBackgroundColor(r,g,b);
01760   Modified();
01761 }
01762 
01763 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01764   ::GetColor(myEdgeProp,r,g,b);
01765 }
01766 
01767 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01768   myOutLineProp->SetColor(r,g,b);
01769   Modified();
01770 }
01771 
01772 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01773   ::GetColor(myOutLineProp,r,g,b);
01774 }
01775 
01776 
01777 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
01778   myNodeProp->SetColor(r,g,b);
01779   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01780   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01781     if( aGroupObj->GetElementType() == SMDSAbs_Node )
01782       myNameActor->SetBackgroundColor(r,g,b);
01783   Modified();
01784 }
01785 
01786 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
01787   ::GetColor(myNodeProp,r,g,b);
01788 }
01789 
01790 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
01791   my0DProp->SetColor(r,g,b);
01792   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01793     if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
01794       myNameActor->SetBackgroundColor(r,g,b);
01795   Modified();
01796 }
01797 
01798 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
01799   ::GetColor(my0DProp,r,g,b);
01800 }
01801 
01802 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
01803   myHighlightProp->SetColor(r,g,b);
01804   Modified();
01805 }
01806 
01807 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
01808   ::GetColor(myHighlightProp,r,g,b);
01809 }
01810 
01811 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
01812   myPreselectProp->SetColor(r,g,b);
01813   Modified();
01814 }
01815 
01816 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
01817   ::GetColor(myPreselectProp,r,g,b);
01818 }
01819 
01820 
01821 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
01822   return myEdgeProp->GetLineWidth();
01823 }
01824 
01825 
01826 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
01827   myEdgeProp->SetLineWidth(theVal);
01828 
01829   my1DProp->SetLineWidth(theVal + aLineWidthInc);
01830   my1DExtProp->SetLineWidth(theVal + aLineWidthInc);    
01831   my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
01832   myOutLineProp->SetLineWidth(theVal);
01833   myHighlightProp->SetLineWidth(theVal);
01834   myPreselectProp->SetLineWidth(theVal);
01835   Modified();
01836 }
01837 
01838 
01839 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
01840   my0DProp->SetPointSize(theVal);
01841   Modified();
01842 }
01843 
01844 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
01845   return my0DProp->GetPointSize();
01846 }
01847 
01848 int SMESH_ActorDef::GetObjDimension( const int theObjId )
01849 {
01850   return myVisualObj->GetElemDimension( theObjId );
01851 }
01852 
01853 bool
01854 SMESH_ActorDef::
01855 IsImplicitFunctionUsed() const
01856 {
01857   return myBaseActor->IsImplicitFunctionUsed();
01858 }
01859 
01860 void
01861 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
01862 {
01863   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01864   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01865 
01866   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01867 
01868   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01869 
01870   my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01871   //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01872 
01873   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01874   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01875 
01876   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01877   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01878   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01879   my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01880 }
01881 
01882 vtkIdType 
01883 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
01884 {
01885   if(thePlane){
01886     myImplicitBoolean->GetFunction()->AddItem(thePlane);
01887     myCippingPlaneCont.push_back(thePlane);
01888     if(!IsImplicitFunctionUsed())
01889       SetImplicitFunctionUsed(true);
01890     myNodeActor->UpdateLabels();
01891   }
01892   return myCippingPlaneCont.size();
01893 }
01894 
01895 void
01896 SMESH_ActorDef::
01897 RemoveAllClippingPlanes()
01898 {
01899   myImplicitBoolean->GetFunction()->RemoveAllItems();
01900   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
01901   myCippingPlaneCont.clear();
01902   SetImplicitFunctionUsed(false);
01903   myNodeActor->UpdateLabels();
01904 }
01905 
01906 vtkIdType
01907 SMESH_ActorDef::
01908 GetNumberOfClippingPlanes()
01909 {
01910   return myCippingPlaneCont.size();
01911 }
01912 
01913 vtkPlane* 
01914 SMESH_ActorDef::
01915 GetClippingPlane(vtkIdType theID)
01916 {
01917   if(theID >= myCippingPlaneCont.size())
01918     return NULL;
01919   return myCippingPlaneCont[theID].Get();
01920 }
01921 
01922 void SMESH_ActorDef::UpdateScalarBar()
01923 {
01924   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
01925   if( !mgr )
01926     return;
01927 
01928   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
01929 
01930   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
01931   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
01932 
01933   aScalarBarTitleProp->SetFontFamilyToArial();
01934 
01935   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
01936   {
01937     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
01938     if ( f.family() == "Arial" )
01939       aScalarBarTitleProp->SetFontFamilyToArial();
01940     else if ( f.family() == "Courier" )
01941       aScalarBarTitleProp->SetFontFamilyToCourier();
01942     else if ( f.family() == "Times" )
01943       aScalarBarTitleProp->SetFontFamilyToTimes();
01944 
01945     if ( f.bold() )
01946       aScalarBarTitleProp->BoldOn();
01947     else
01948       aScalarBarTitleProp->BoldOff();
01949 
01950     if ( f.italic() )
01951       aScalarBarTitleProp->ItalicOn();
01952     else
01953      aScalarBarTitleProp->ItalicOff();
01954 
01955     if ( f.overline() )
01956       aScalarBarTitleProp->ShadowOn();
01957     else
01958       aScalarBarTitleProp->ShadowOff();
01959   }
01960 
01961   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
01962   aScalarBarTitleProp->Delete();
01963 
01964   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
01965 
01966   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
01967   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
01968 
01969   aScalarBarLabelProp->SetFontFamilyToArial();
01970   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
01971   {
01972     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
01973     if( f.family() == "Arial" )
01974       aScalarBarLabelProp->SetFontFamilyToArial();
01975     else if( f.family() == "Courier" )
01976       aScalarBarLabelProp->SetFontFamilyToCourier();
01977     else if( f.family() == "Times" )
01978       aScalarBarLabelProp->SetFontFamilyToTimes();
01979 
01980     if ( f.bold() )
01981       aScalarBarLabelProp->BoldOn();
01982     else
01983       aScalarBarLabelProp->BoldOff();
01984 
01985     if ( f.italic() )
01986       aScalarBarLabelProp->ItalicOn();
01987     else
01988       aScalarBarLabelProp->ItalicOff();
01989 
01990     if( f.overline() )
01991       aScalarBarLabelProp->ShadowOn();
01992     else
01993       aScalarBarLabelProp->ShadowOff();
01994   }
01995 
01996   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
01997   aScalarBarLabelProp->Delete();
01998 
01999   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
02000   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
02001   if( horiz )
02002     myScalarBarActor->SetOrientationToHorizontal();
02003   else
02004     myScalarBarActor->SetOrientationToVertical();
02005 
02006 
02007   vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
02008   if( mgr->hasValue( "SMESH", name + "x" ) )
02009     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
02010 
02011   vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
02012   if( mgr->hasValue( "SMESH", name + "y" ) )
02013     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
02014   myScalarBarActor->SetPosition( aXVal, aYVal );
02015 
02016   vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
02017   if( mgr->hasValue( "SMESH", name + "width" ) )
02018     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
02019   myScalarBarActor->SetWidth( aWVal );
02020 
02021   vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
02022   if( mgr->hasValue( "SMESH", name + "height" ) )
02023     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
02024   myScalarBarActor->SetHeight( aHVal );
02025 
02026   int anIntVal = 5;
02027   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
02028     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
02029   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
02030 
02031   anIntVal = 64;
02032   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
02033     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
02034   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
02035 
02036   bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
02037   myScalarBarActor->SetDistributionVisibility(distributionVisibility);
02038 
02039   int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
02040   myScalarBarActor->SetDistributionColoringType(coloringType);
02041   
02042   QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
02043                                              QColor(255, 255, 255));
02044   double rgb[3];
02045   rgb[0]= distributionColor.red()/255.;
02046   rgb[1]= distributionColor.green()/255.;
02047   rgb[2]= distributionColor.blue()/255.;
02048   myScalarBarActor->SetDistributionColor(rgb);
02049 
02050   
02051 }
02052 
02053 void SMESH_ActorDef::UpdateDistribution()
02054 {
02055   if(SMESH::Controls::NumericalFunctor* fun =
02056      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
02057   {
02058     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
02059     std::vector<int> nbEvents;
02060     std::vector<double> funValues;
02061     SMESH_VisualObjDef::TEntityList elems;
02062     if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
02063       dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
02064     std::vector<int> elemIds;
02065     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
02066       elemIds.push_back( (*e)->GetID());
02067     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
02068     double * range = lookupTable->GetRange();
02069     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
02070     myScalarBarActor->SetDistribution(nbEvents);
02071   }
02072 }
02073 
02074 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
02075 {
02076   switch(theMode) {
02077   case SMESH_Actor::eLines :
02078     myHighlitableActor->SetQuadraticArcMode(false);
02079     my2DActor->SetQuadraticArcMode(false);
02080     my1DActor->SetQuadraticArcMode(false);
02081     break;
02082   case SMESH_Actor::eArcs :
02083     myHighlitableActor->SetQuadraticArcMode(true);
02084     if(GetRepresentation() != SMESH_Actor::ePoint) {
02085       my2DActor->SetQuadraticArcMode(true);
02086       my1DActor->SetQuadraticArcMode(true);
02087     }
02088     break;
02089   default:
02090     break;
02091   }
02092 }
02093 
02094 
02095 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
02096 {
02097   if(myHighlitableActor->GetQuadraticArcMode())
02098     return SMESH_Actor::eArcs;
02099   else
02100     return SMESH_Actor::eLines;
02101 }
02102 
02103 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
02104 {
02105   SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
02106   myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
02107   myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
02108 }
02109 
02110 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
02111 {
02112   SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
02113   myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
02114   myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
02115   myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
02116 }
02117 
02118 #ifndef DISABLE_PLOT2DVIEWER
02119 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
02120 
02121   if(my2dHistogram)
02122     my2dHistogram->clearAllPoints();
02123   
02124   if(SMESH::Controls::NumericalFunctor* fun =
02125      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
02126   {
02127     
02128     if(!my2dHistogram) {
02129       my2dHistogram = new SPlot2d_Histogram();
02130       Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
02131       my2dHistogram->setIO(anIO);
02132     }
02133     
02134     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
02135     std::vector<int> nbEvents;
02136     std::vector<double> funValues;
02137     SMESH_VisualObjDef::TEntityList elems;
02138     if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
02139       dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
02140     std::vector<int> elemIds;
02141     
02142     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
02143       elemIds.push_back( (*e)->GetID());
02144 
02145     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
02146     double * range = lookupTable->GetRange();
02147     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
02148 
02149     for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) 
02150       my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
02151 
02152     if(funValues.size() >= 2)
02153       my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
02154 
02155   }
02156   
02157   //Color of the histogram
02158   if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
02159     my2dHistogram->setAutoAssign(true);
02160   else {
02161     double rgb[3];
02162     myScalarBarActor->GetDistributionColor(rgb);
02163     QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
02164     my2dHistogram->setColor(aColor);
02165 
02166   }
02167       
02168   return my2dHistogram;
02169 }
02170 #endif