Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH OBJECT : interactive object for SMESH visualization
23 //  File   : SMESH_Actor.cxx
24 //  Author : Nicolas REJNERI
25 //  Module : SMESH
26
27
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_ControlsDef.hxx"
32 #include "VTKViewer_ExtractUnstructuredGrid.h"
33 #include "SALOME_InteractiveObject.hxx"
34
35 #include "SUIT_Session.h"
36 #include "SUIT_ResourceMgr.h"
37
38 #include <vtkProperty.h>
39 #include <vtkTimeStamp.h>
40 #include <vtkObjectFactory.h>
41 #include <vtkShrinkPolyData.h>
42 #include <vtkMergeFilter.h>
43
44 #include <vtkMatrix4x4.h>
45 #include <vtkUnstructuredGrid.h>
46 #include <vtkPointData.h>
47 #include <vtkCellData.h>
48
49 #include <vtkMapper.h>
50 #include <vtkRenderer.h>
51
52 #include <vtkCell.h>
53 #include <vtkIdList.h>
54 #include <vtkIntArray.h>
55
56 #include <vtkActor2D.h>
57 #include <vtkProperty2D.h>
58 #include <vtkPolyData.h>
59 #include <vtkMaskPoints.h>
60 #include <vtkCellCenters.h>
61 #include <vtkTextProperty.h>
62 #include <vtkLabeledDataMapper.h>
63 #include <vtkSelectVisiblePoints.h>
64
65 #include <vtkScalarBarActor.h>
66 #include <vtkLookupTable.h>
67
68 #include <vtkMath.h>
69 #include <vtkPlane.h>
70 #include <vtkImplicitBoolean.h>
71 #include <vtkImplicitFunctionCollection.h>
72
73 #include "utilities.h"
74
75 #ifdef _DEBUG_
76 static int MYDEBUG = 1;
77 #else
78 static int MYDEBUG = 0;
79 #endif
80
81 static int aLineWidthInc = 2;
82 static int aPointSizeInc = 2;
83
84
85 SMESH_ActorDef* SMESH_ActorDef::New(){
86   return new SMESH_ActorDef();
87 }
88
89
90 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, 
91                               const char* theEntry, 
92                               const char* theName,
93                               int theIsClear)
94 {
95   SMESH_ActorDef* anActor = SMESH_ActorDef::New();
96   if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
97     anActor->Delete();
98     anActor = NULL;
99   }
100   if( anActor )
101     anActor->UpdateScalarBar();
102   return anActor;
103 }
104
105
106 SMESH_ActorDef::SMESH_ActorDef()
107 {
108   if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
109
110   myTimeStamp = vtkTimeStamp::New();
111
112   myIsPointsVisible = false;
113
114   myIsShrinkable = false;
115   myIsShrunk = false;
116
117   myIsFacesOriented = false;
118
119   myControlsPrecision = -1;
120   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
121   
122   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
123     myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
124
125   vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
126   vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
127
128   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
129   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
130
131   //Definition 2D and 3D divices of the actor
132   //-----------------------------------------
133   vtkFloatingPointType anRGB[3] = {1,1,1};
134   mySurfaceProp = vtkProperty::New();
135   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
136   mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
137
138   myBackSurfaceProp = vtkProperty::New();
139   SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
140   myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
141
142   my2DActor = SMESH_DeviceActor::New();
143   my2DActor->SetUserMatrix(aMatrix);
144   my2DActor->PickableOff();
145   my2DActor->SetProperty(mySurfaceProp);
146   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
147   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
148   aFilter = my2DActor->GetExtractUnstructuredGrid();
149   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
150   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
151   aFilter->RegisterCellsWithType(VTK_POLYGON);
152   aFilter->RegisterCellsWithType(VTK_QUAD);
153   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
154   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
155
156   my2DExtProp = vtkProperty::New();
157   my2DExtProp->DeepCopy(mySurfaceProp);
158   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
159   anRGB[0] = 1 - anRGB[0];
160   anRGB[1] = 1 - anRGB[1];
161   anRGB[2] = 1 - anRGB[2];
162   my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
163
164   my2DExtActor = SMESH_DeviceActor::New();
165   my2DExtActor->SetUserMatrix(aMatrix);
166   my2DExtActor->PickableOff();
167   my2DExtActor->SetProperty(my2DExtProp);
168   my2DExtActor->SetBackfaceProperty(my2DExtProp);
169   my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
170   aFilter = my2DExtActor->GetExtractUnstructuredGrid();
171   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
172   aFilter->RegisterCellsWithType(VTK_POLYGON);
173   aFilter->RegisterCellsWithType(VTK_QUAD);
174   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
175   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
176
177   my3DActor = SMESH_DeviceActor::New();
178   my3DActor->SetUserMatrix(aMatrix);
179   my3DActor->PickableOff();
180   my3DActor->SetProperty(mySurfaceProp);
181   my3DActor->SetBackfaceProperty(myBackSurfaceProp);
182   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
183   aFilter = my3DActor->GetExtractUnstructuredGrid();
184   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
185   aFilter->RegisterCellsWithType(VTK_TETRA);
186   aFilter->RegisterCellsWithType(VTK_VOXEL);
187   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
188   aFilter->RegisterCellsWithType(VTK_WEDGE);
189   aFilter->RegisterCellsWithType(VTK_PYRAMID);
190   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
191   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
192   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
193   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
194
195   //Definition 1D divice of the actor
196   //---------------------------------
197   myEdgeProp = vtkProperty::New();
198   myEdgeProp->SetAmbient(1.0);
199   myEdgeProp->SetDiffuse(0.0);
200   myEdgeProp->SetSpecular(0.0);
201   SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
202   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
203   myEdgeProp->SetLineWidth(aLineWidth);
204
205   my1DActor = SMESH_DeviceActor::New();
206   my1DActor->SetUserMatrix(aMatrix);
207   my1DActor->PickableOff();
208   my1DActor->SetHighlited(true);
209   my1DActor->SetProperty(myEdgeProp);
210   my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
211   aFilter = my1DActor->GetExtractUnstructuredGrid();
212   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
213   aFilter->RegisterCellsWithType(VTK_LINE);
214   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
215
216   my1DProp = vtkProperty::New();
217   my1DProp->DeepCopy(myEdgeProp);
218   my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
219   my1DProp->SetPointSize(aPointSize);
220   
221   my1DExtProp = vtkProperty::New();
222   my1DExtProp->DeepCopy(myEdgeProp);
223   anRGB[0] = 1 - anRGB[0];
224   anRGB[1] = 1 - anRGB[1];
225   anRGB[2] = 1 - anRGB[2];
226   my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
227   my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
228   my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
229
230   my1DExtActor = SMESH_DeviceActor::New();
231   my1DExtActor->SetUserMatrix(aMatrix);
232   my1DExtActor->PickableOff();
233   my1DExtActor->SetHighlited(true);
234   my1DExtActor->SetVisibility(false);
235   my1DExtActor->SetProperty(my1DExtProp);
236   my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
237   aFilter = my1DExtActor->GetExtractUnstructuredGrid();
238   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
239   aFilter->RegisterCellsWithType(VTK_LINE);
240   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
241
242
243   //Definition 0D divice of the actor
244   //---------------------------------
245   myNodeProp = vtkProperty::New();
246   SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
247   myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
248   myNodeProp->SetPointSize(aPointSize);
249
250   myNodeActor = SMESH_DeviceActor::New();
251   myNodeActor->SetUserMatrix(aMatrix);
252   myNodeActor->SetStoreClippingMapping(true);
253   myNodeActor->PickableOff();
254   myNodeActor->SetVisibility(false);
255   myNodeActor->SetProperty(myNodeProp);
256   myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
257   aFilter = myNodeActor->GetExtractUnstructuredGrid();
258   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
259   
260   myNodeExtProp = vtkProperty::New();
261   myNodeExtProp->DeepCopy(myNodeProp);
262   anRGB[0] = 1 - anRGB[0];
263   anRGB[1] = 1 - anRGB[1];
264   anRGB[2] = 1 - anRGB[2];
265   myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
266   myNodeExtProp->SetPointSize(aPointSize);
267
268   myNodeExtActor = SMESH_DeviceActor::New();
269   myNodeExtActor->SetUserMatrix(aMatrix);
270   myNodeExtActor->SetStoreClippingMapping(true);
271   myNodeExtActor->PickableOff();
272   myNodeExtActor->SetHighlited(true);
273   myNodeExtActor->SetVisibility(false);
274   myNodeExtActor->SetProperty(myNodeExtProp);
275   myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
276   aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
277   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
278   aFilter->RegisterCellsWithType(VTK_VERTEX);
279
280   //Definition of Pickable and Highlitable engines
281   //----------------------------------------------
282
283   myBaseActor = SMESH_DeviceActor::New();
284   myBaseActor->SetUserMatrix(aMatrix);
285   myBaseActor->SetStoreGemetryMapping(true);
286   myBaseActor->GetProperty()->SetOpacity(0.0);
287
288   myPickableActor = myBaseActor;
289   
290   myHighlightProp = vtkProperty::New();
291   myHighlightProp->SetAmbient(1.0);
292   myHighlightProp->SetDiffuse(0.0);
293   myHighlightProp->SetSpecular(0.0);
294   SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
295   myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
296   myHighlightProp->SetPointSize(aPointSize);
297   myHighlightProp->SetRepresentation(1);
298  
299   myPreselectProp = vtkProperty::New();
300   myPreselectProp->SetAmbient(1.0);
301   myPreselectProp->SetDiffuse(0.0);
302   myPreselectProp->SetSpecular(0.0);
303   SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
304   myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
305   myPreselectProp->SetPointSize(aPointSize);
306   myPreselectProp->SetRepresentation(1);
307
308   myHighlitableActor = SMESH_DeviceActor::New();
309   myHighlitableActor->SetUserMatrix(aMatrix);
310   myHighlitableActor->PickableOff();
311   myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
312
313   myName = "";
314   myIO = NULL;
315
316   myControlMode = eNone;
317   myControlActor = my2DActor;
318
319   //Definition of myScalarBarActor
320   //------------------------------
321   myLookupTable = vtkLookupTable::New();
322   //Fix for Bug PAL5195 - SMESH764: 
323   //Controls - Aspect Ratio: incorrect colors of the best and worst values
324   myLookupTable->SetHueRange(0.667,0.0);
325
326   myScalarBarActor = vtkScalarBarActor::New();
327   myScalarBarActor->SetVisibility(false);
328   myScalarBarActor->SetLookupTable(myLookupTable);
329
330   //Fix for Bug 13314:
331   //Incorrect "Min value" in Scalar Bar in Mesh:
332   //  myScalarBarActor->SetLabelFormat("%.4g");
333   // changes was commented because of regression bug IPAL 19981
334
335   mgr = SUIT_Session::session()->resourceMgr();
336   if( !mgr )
337     return;
338
339   //Definition of points numbering pipeline
340   //---------------------------------------
341   myPointsNumDataSet = vtkUnstructuredGrid::New();
342
343   myPtsMaskPoints = vtkMaskPoints::New();
344   myPtsMaskPoints->SetInput(myPointsNumDataSet);
345   myPtsMaskPoints->SetOnRatio(1);
346
347   myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
348   myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
349   myPtsSelectVisiblePoints->SelectInvisibleOff();
350   myPtsSelectVisiblePoints->SetTolerance(0.1);
351     
352   myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
353   myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
354   myPtsLabeledDataMapper->SetLabelFormat("%g");
355   myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
356     
357   vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
358   aPtsTextProp->SetFontFamilyToTimes();
359   static int aPointsFontSize = 10;
360   aPtsTextProp->SetFontSize(aPointsFontSize);
361   aPtsTextProp->SetBold(1);
362   aPtsTextProp->SetItalic(0);
363   aPtsTextProp->SetShadow(0);
364   myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
365   aPtsTextProp->Delete();
366   
367   myEntityMode = eAllEntity;
368
369   myIsPointsLabeled = false;
370
371   myPointLabels = vtkActor2D::New();
372   myPointLabels->SetMapper(myPtsLabeledDataMapper);
373   myPointLabels->GetProperty()->SetColor(1,1,1);
374   myPointLabels->SetVisibility(myIsPointsLabeled);
375
376
377   //Definition of cells numbering pipeline
378   //---------------------------------------
379   myCellsNumDataSet = vtkUnstructuredGrid::New();
380
381   myCellCenters = vtkCellCenters::New();
382   myCellCenters->SetInput(myCellsNumDataSet);
383
384   myClsMaskPoints = vtkMaskPoints::New();
385   myClsMaskPoints->SetInput(myCellCenters->GetOutput());
386   myClsMaskPoints->SetOnRatio(1);
387     
388   myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
389   myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
390   myClsSelectVisiblePoints->SelectInvisibleOff();
391   myClsSelectVisiblePoints->SetTolerance(0.1);
392     
393   myClsLabeledDataMapper = vtkLabeledDataMapper::New();
394   myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
395   myClsLabeledDataMapper->SetLabelFormat("%g");
396   myClsLabeledDataMapper->SetLabelModeToLabelScalars();
397     
398   vtkTextProperty* aClsTextProp = vtkTextProperty::New();
399   aClsTextProp->SetFontFamilyToTimes();
400   static int aCellsFontSize = 12;
401   aClsTextProp->SetFontSize(aCellsFontSize);
402   aClsTextProp->SetBold(1);
403   aClsTextProp->SetItalic(0);
404   aClsTextProp->SetShadow(0);
405   myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
406   aClsTextProp->Delete();
407     
408   myIsCellsLabeled = false;
409
410   myCellsLabels = vtkActor2D::New();
411   myCellsLabels->SetMapper(myClsLabeledDataMapper);
412   myCellsLabels->GetProperty()->SetColor(0,1,0);
413   myCellsLabels->SetVisibility(myIsCellsLabeled);
414
415   // Clipping planes
416   myImplicitBoolean = vtkImplicitBoolean::New();
417   myImplicitBoolean->SetOperationTypeToIntersection();
418 }
419
420
421 SMESH_ActorDef::~SMESH_ActorDef()
422 {
423   if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
424
425   myScalarBarActor->Delete();
426   myLookupTable->Delete();
427
428   mySurfaceProp->Delete();
429   myBackSurfaceProp->Delete();
430
431   myEdgeProp->Delete();
432   myHighlightProp->Delete();
433   myPreselectProp->Delete();
434
435   myNodeProp->Delete();
436   myNodeExtProp->Delete();
437  
438   my1DProp->Delete();
439   my1DActor->Delete();
440
441   my1DExtProp->Delete();
442   my1DExtActor->Delete();
443
444   my2DActor->Delete();
445   my2DExtProp->Delete();
446   my2DExtActor->Delete();
447   my3DActor->Delete();
448
449   myNodeActor->Delete();
450   myBaseActor->Delete();
451
452   myNodeExtActor->Delete();
453   
454   myHighlitableActor->Delete();
455
456   //Deleting of pints numbering pipeline
457   //---------------------------------------
458   myPointsNumDataSet->Delete();
459
460   // commented: porting to vtk 5.0
461   //  myPtsLabeledDataMapper->RemoveAllInputs();
462   myPtsLabeledDataMapper->Delete();
463
464   // commented: porting to vtk 5.0
465   //  myPtsSelectVisiblePoints->UnRegisterAllOutputs();
466   myPtsSelectVisiblePoints->Delete();
467
468   // commented: porting to vtk 5.0
469   //  myPtsMaskPoints->UnRegisterAllOutputs();
470   myPtsMaskPoints->Delete();
471
472   myPointLabels->Delete();
473
474
475   //Deleting of cells numbering pipeline
476   //---------------------------------------
477   myCellsNumDataSet->Delete();
478
479   myClsLabeledDataMapper->RemoveAllInputs();
480   myClsLabeledDataMapper->Delete();
481
482   // commented: porting to vtk 5.0
483   //  myClsSelectVisiblePoints->UnRegisterAllOutputs();
484   myClsSelectVisiblePoints->Delete();
485
486   // commented: porting to vtk 5.0
487   //  myClsMaskPoints->UnRegisterAllOutputs();
488   myClsMaskPoints->Delete();
489
490   // commented: porting to vtk 5.0
491   //  myCellCenters->UnRegisterAllOutputs();
492   myCellCenters->Delete();
493
494   myCellsLabels->Delete();
495
496   myImplicitBoolean->Delete();
497
498   myTimeStamp->Delete();
499 }
500
501
502 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
503 {
504   vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
505   myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
506
507   if ( myIsPointsLabeled )
508   {
509     myPointsNumDataSet->ShallowCopy(aGrid);
510     vtkDataSet *aDataSet = myPointsNumDataSet;
511     
512     int aNbElem = aDataSet->GetNumberOfPoints();
513     
514     vtkIntArray *anArray = vtkIntArray::New();
515     anArray->SetNumberOfValues( aNbElem );
516     
517     for ( int anId = 0; anId < aNbElem; anId++ )
518     {
519       int aSMDSId = myVisualObj->GetNodeObjId( anId );
520       anArray->SetValue( anId, aSMDSId );
521     }
522     
523     aDataSet->GetPointData()->SetScalars( anArray );
524     anArray->Delete();
525     myPtsMaskPoints->SetInput( aDataSet );
526     myPointLabels->SetVisibility( GetVisibility() );
527   }
528   else
529   {
530     myPointLabels->SetVisibility( false );
531   }
532   SetRepresentation(GetRepresentation());
533   myTimeStamp->Modified();
534 }
535
536
537 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
538 {
539   vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
540   myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
541   if(myIsCellsLabeled){
542     myCellsNumDataSet->ShallowCopy(aGrid);
543     vtkDataSet *aDataSet = myCellsNumDataSet;
544     int aNbElem = aDataSet->GetNumberOfCells();
545     vtkIntArray *anArray = vtkIntArray::New();
546     anArray->SetNumberOfValues(aNbElem);
547     for(int anId = 0; anId < aNbElem; anId++){
548       int aSMDSId = myVisualObj->GetElemObjId(anId);
549       anArray->SetValue(anId,aSMDSId);
550     }
551     aDataSet->GetCellData()->SetScalars(anArray);
552     myCellCenters->SetInput(aDataSet);
553     myCellsLabels->SetVisibility(GetVisibility());
554   }else{
555     myCellsLabels->SetVisibility(false);
556   }
557   myTimeStamp->Modified();
558 }
559
560
561 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
562 {
563   myIsFacesOriented = theIsFacesOriented;
564
565   my2DActor->SetFacesOriented(theIsFacesOriented);
566   my3DActor->SetFacesOriented(theIsFacesOriented);
567
568   myTimeStamp->Modified();
569 }
570
571 bool SMESH_ActorDef::GetFacesOriented()
572 {
573   return myIsFacesOriented;
574 }
575
576
577 void 
578 SMESH_ActorDef::
579 SetControlMode(eControl theMode)
580 {
581   SetControlMode(theMode,true);
582 }
583
584
585 void 
586 SMESH_ActorDef::
587 SetControlMode(eControl theMode,
588                bool theCheckEntityMode)
589 {
590   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();  
591   if( !mgr )
592     return;
593
594   myControlMode = eNone;
595   theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
596
597   my1DActor->GetMapper()->SetScalarVisibility(false);
598   my2DActor->GetMapper()->SetScalarVisibility(false);
599   my3DActor->GetMapper()->SetScalarVisibility(false);
600   myScalarBarActor->SetVisibility(false);
601
602   bool anIsScalarVisible = theMode > eNone;
603
604   if(anIsScalarVisible){
605     SMESH::Controls::FunctorPtr aFunctor;
606     switch(theMode){
607     case eLength:
608     {
609       SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
610       aControl->SetPrecision( myControlsPrecision );
611       aFunctor.reset( aControl );
612       myControlActor = my1DActor;
613       break;
614     }
615     case eLength2D:
616     {
617       aFunctor.reset(new SMESH::Controls::Length2D());
618       myControlActor = my2DActor;
619       break;
620     }
621     case eFreeBorders:
622       aFunctor.reset(new SMESH::Controls::FreeBorders());
623       myControlActor = my1DActor;
624       break;
625     case eFreeEdges:
626       aFunctor.reset(new SMESH::Controls::FreeEdges());
627       myControlActor = my2DActor;
628       break;
629     case eFreeNodes:
630       aFunctor.reset(new SMESH::Controls::FreeNodes());
631       myControlActor = myNodeActor;
632       break;
633     case eFreeFaces:
634       aFunctor.reset(new SMESH::Controls::FreeFaces());
635       myControlActor = my2DActor;
636       break;
637     case eMultiConnection:
638       aFunctor.reset(new SMESH::Controls::MultiConnection());
639       myControlActor = my1DActor;
640       break;
641     case eMultiConnection2D:
642       aFunctor.reset(new SMESH::Controls::MultiConnection2D());
643       myControlActor = my2DActor;
644       break;
645     case eArea:
646     {
647       SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
648       aControl->SetPrecision( myControlsPrecision );
649       aFunctor.reset( aControl );
650       myControlActor = my2DActor;
651       break;
652     }
653     case eTaper:
654     {
655       SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
656       aControl->SetPrecision( myControlsPrecision );
657       aFunctor.reset( aControl );
658       myControlActor = my2DActor;
659       break;
660     }
661     case eAspectRatio:
662     {
663       SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
664       aControl->SetPrecision( myControlsPrecision );
665       aFunctor.reset( aControl );
666       myControlActor = my2DActor;
667       break;
668     }
669     case eAspectRatio3D:
670     {
671       SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
672       aControl->SetPrecision( myControlsPrecision );
673       aFunctor.reset( aControl );
674       myControlActor = my3DActor;
675       break;
676     }
677     case eVolume3D:
678     {
679       SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
680       aControl->SetPrecision( myControlsPrecision );
681       aFunctor.reset( aControl );
682       myControlActor = my3DActor;
683       break;
684     }
685     case eMinimumAngle:
686     {
687       SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
688       aControl->SetPrecision( myControlsPrecision );
689       aFunctor.reset( aControl );
690       myControlActor = my2DActor;
691       break;
692     }
693     case eWarping:
694     {
695       SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
696       aControl->SetPrecision( myControlsPrecision );
697       aFunctor.reset( aControl );
698       myControlActor = my2DActor;
699       break;
700     }
701     case eSkew:
702     {
703       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
704       aControl->SetPrecision( myControlsPrecision );
705       aFunctor.reset( aControl );
706       myControlActor = my2DActor;
707       break;
708     }
709     default:
710       return;
711     }
712
713     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
714     vtkIdType aNbCells = aGrid->GetNumberOfCells();
715     if(aNbCells){
716       myControlMode = theMode;
717       switch(myControlMode){
718       case eFreeNodes:
719         myNodeExtActor->SetExtControlMode(aFunctor);
720         break;
721       case eFreeEdges:
722       case eFreeBorders:
723         my1DExtActor->SetExtControlMode(aFunctor);
724         break;
725       case eFreeFaces:
726         my2DExtActor->SetExtControlMode(aFunctor);
727         break;
728       case eLength2D:
729       case eMultiConnection2D:
730         my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
731         break;
732       default:
733         myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
734       }
735     }
736
737     if(theCheckEntityMode){
738       if(myControlActor == my1DActor)
739         SetEntityMode(eEdges);
740       else if(myControlActor == my2DActor){
741         switch(myControlMode){
742         case eLength2D:
743         case eFreeEdges:
744         case eFreeFaces:
745         case eMultiConnection2D:
746           //SetEntityMode(eEdges);
747           SetEntityMode(eFaces);
748           break;
749         default:
750           SetEntityMode(eFaces);
751         }
752       }else if(myControlActor == my3DActor)
753         SetEntityMode(eVolumes);
754     }
755
756   }else if(theCheckEntityMode){
757     myEntityMode = eAllEntity;
758   }
759
760   SetRepresentation(GetRepresentation());
761
762   myTimeStamp->Modified();
763   Modified();
764 }
765
766
767 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
768   SALOME_Actor::AddToRender(theRenderer);
769
770   theRenderer->AddActor(myNodeActor);
771   theRenderer->AddActor(myBaseActor);
772   
773   theRenderer->AddActor(myNodeExtActor);
774
775   my3DActor->AddToRender(theRenderer);
776   my2DActor->AddToRender(theRenderer);
777   my2DExtActor->AddToRender(theRenderer);
778
779   theRenderer->AddActor(my1DActor);
780   theRenderer->AddActor(my1DExtActor);
781
782   theRenderer->AddActor(myHighlitableActor);
783   
784   theRenderer->AddActor2D(myScalarBarActor);
785
786   myPtsSelectVisiblePoints->SetRenderer(theRenderer);
787   myClsSelectVisiblePoints->SetRenderer(theRenderer);
788
789   theRenderer->AddActor2D(myPointLabels);
790   theRenderer->AddActor2D(myCellsLabels);
791 }
792
793 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
794   SALOME_Actor::RemoveFromRender(theRenderer);
795
796   theRenderer->RemoveActor(myNodeActor);
797   theRenderer->RemoveActor(myBaseActor);
798
799   theRenderer->RemoveActor(myNodeExtActor);
800
801   theRenderer->RemoveActor(myHighlitableActor);
802
803   theRenderer->RemoveActor(my1DActor);
804   theRenderer->RemoveActor(my1DExtActor);
805
806   my2DActor->RemoveFromRender(theRenderer);
807   my2DExtActor->RemoveFromRender(theRenderer);
808   my3DActor->RemoveFromRender(theRenderer);
809
810   theRenderer->RemoveActor(myScalarBarActor);
811   theRenderer->RemoveActor(myPointLabels);
812   theRenderer->RemoveActor(myCellsLabels);
813 }
814
815
816 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, 
817                           const char* theEntry, 
818                           const char* theName,
819                           int theIsClear)
820 {
821   Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
822   setIO(anIO);
823   setName(theName);
824
825   myVisualObj = theVisualObj;
826   myVisualObj->Update(theIsClear);
827
828   myNodeActor->Init(myVisualObj,myImplicitBoolean);
829   myBaseActor->Init(myVisualObj,myImplicitBoolean);
830
831   myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
832
833   myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
834   
835   my1DActor->Init(myVisualObj,myImplicitBoolean);
836   my1DExtActor->Init(myVisualObj,myImplicitBoolean);
837   
838   my2DActor->Init(myVisualObj,myImplicitBoolean);
839   my2DExtActor->Init(myVisualObj,myImplicitBoolean);
840   my3DActor->Init(myVisualObj,myImplicitBoolean);
841   
842   my1DActor->GetMapper()->SetLookupTable(myLookupTable);
843   my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
844
845   my2DActor->GetMapper()->SetLookupTable(myLookupTable);
846   my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
847   my3DActor->GetMapper()->SetLookupTable(myLookupTable);
848     
849   vtkFloatingPointType aFactor, aUnits;
850   my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
851   my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
852   my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
853
854   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
855   if( !mgr )
856     return false;
857
858   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
859   SetIsShrunkable(true);
860
861   SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
862
863   int aMode = mgr->integerValue( "SMESH", "display_mode" );
864   SetRepresentation(-1);
865   
866   if(aMode == 0){
867     SetRepresentation(eEdge);
868   }else if(aMode == 1){
869     SetRepresentation(eSurface);
870   }else if(aMode == 2){
871     SetRepresentation(ePoint);
872   }
873   
874   if(aMode == 3){
875     SetShrink();
876   }
877
878   myTimeStamp->Modified();
879   Modified();
880   return true;
881 }
882
883
884 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
885   return myNodeActor->GetBounds();
886 }
887
888
889 vtkDataSet* SMESH_ActorDef::GetInput(){
890   return GetUnstructuredGrid();
891 }
892
893
894 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
895   Superclass::SetTransform(theTransform);
896
897   myNodeActor->SetTransform(theTransform);
898   myBaseActor->SetTransform(theTransform);
899   
900   myHighlitableActor->SetTransform(theTransform);
901
902   myNodeExtActor->SetTransform(theTransform);
903
904   my1DActor->SetTransform(theTransform);
905   my1DExtActor->SetTransform(theTransform);
906
907   my2DActor->SetTransform(theTransform);
908   my2DExtActor->SetTransform(theTransform);
909   my3DActor->SetTransform(theTransform);
910
911   Modified();
912 }
913
914
915 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
916   vtkLODActor::SetMapper(theMapper);
917 }
918
919
920 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
921   SALOME_Actor::ShallowCopy(prop);
922 }
923
924
925 vtkMapper* SMESH_ActorDef::GetMapper(){
926   return myPickableActor->GetMapper();
927 }
928
929
930 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){ 
931   return myVisualObj->GetUnstructuredGrid();
932 }
933
934
935 bool SMESH_ActorDef::IsInfinitive(){
936   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
937   aDataSet->Update();
938   myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
939     aDataSet->GetNumberOfCells() == 1 && 
940     aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
941   return SALOME_Actor::IsInfinitive();
942 }
943
944
945 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
946   if ( myIsShrinkable == theShrunkable )
947     return;
948   myIsShrinkable = theShrunkable;
949   Modified();
950 }
951
952 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
953   return myBaseActor->GetShrinkFactor();
954 }
955
956 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
957   myBaseActor->SetShrinkFactor(theValue);
958
959   my1DActor->SetShrinkFactor(theValue);
960   my1DExtActor->SetShrinkFactor(theValue);
961
962   my2DActor->SetShrinkFactor(theValue);
963   my2DExtActor->SetShrinkFactor(theValue);
964   my3DActor->SetShrinkFactor(theValue);
965
966   Modified();
967 }
968
969 void SMESH_ActorDef::SetShrink(){
970   if(!myIsShrinkable) return;
971
972   myBaseActor->SetShrink();
973
974   my1DActor->SetShrink();
975   my1DExtActor->SetShrink();
976
977   my2DActor->SetShrink();
978   my2DExtActor->SetShrink();
979   my3DActor->SetShrink();
980
981   myIsShrunk = true;
982   Modified();
983 }
984
985 void SMESH_ActorDef::UnShrink(){
986   if(!myIsShrunk) return;
987
988   myBaseActor->UnShrink();
989
990   my1DActor->UnShrink();
991   my1DExtActor->UnShrink();
992
993   my2DActor->UnShrink();
994   my2DExtActor->UnShrink();
995   my3DActor->UnShrink();
996
997   myIsShrunk = false;
998   Modified();
999 }
1000
1001
1002 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1003   return myPickableActor->GetNodeObjId(theVtkID);
1004 }
1005
1006 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1007   return myPickableActor->GetNodeCoord(theObjID);
1008 }
1009
1010
1011 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1012   return myPickableActor->GetElemObjId(theVtkID);
1013 }
1014
1015 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1016   return myPickableActor->GetElemCell(theObjID);
1017 }
1018
1019
1020 void SMESH_ActorDef::SetVisibility(int theMode){
1021   SetVisibility(theMode,true);
1022 }
1023
1024
1025 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1026   SALOME_Actor::SetVisibility(theMode);
1027
1028   myNodeActor->VisibilityOff();
1029   myBaseActor->VisibilityOff();
1030   
1031   myNodeExtActor->VisibilityOff();
1032
1033   my1DActor->VisibilityOff();
1034   my1DExtActor->VisibilityOff();
1035   
1036   my2DActor->VisibilityOff();
1037   my2DExtActor->VisibilityOff();
1038   my3DActor->VisibilityOff();
1039   
1040   myScalarBarActor->VisibilityOff();
1041   myPointLabels->VisibilityOff();
1042   myCellsLabels->VisibilityOff();
1043   
1044   if(GetVisibility()){
1045     if(theIsUpdateRepersentation)
1046       SetRepresentation(GetRepresentation());
1047     
1048     if(myControlMode != eNone){
1049       switch(myControlMode){
1050       case eFreeNodes:
1051         myNodeExtActor->VisibilityOn();
1052         break;
1053       case eFreeEdges:
1054       case eFreeBorders:
1055         my1DExtActor->VisibilityOn();
1056         break;
1057       case eFreeFaces:
1058         my2DExtActor->VisibilityOn();
1059         break;
1060       case eLength2D:
1061       case eMultiConnection2D:
1062         my1DExtActor->VisibilityOn();
1063       default:
1064         if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1065           myScalarBarActor->VisibilityOn();
1066       }
1067     }
1068
1069     if(myRepresentation != ePoint)
1070       myPickableActor->VisibilityOn();
1071     else {
1072       myNodeActor->VisibilityOn();
1073     }
1074
1075     if(myEntityMode & eEdges){
1076       my1DActor->VisibilityOn();
1077     }
1078     
1079     if(myEntityMode & eFaces){
1080       my2DActor->VisibilityOn();
1081     }
1082     
1083     if(myEntityMode & eVolumes){
1084       my3DActor->VisibilityOn();
1085     }
1086     
1087     if(myIsPointsLabeled){ 
1088       myPointLabels->VisibilityOn();
1089       myNodeActor->VisibilityOn();
1090     }
1091
1092     if(myIsCellsLabeled) 
1093       myCellsLabels->VisibilityOn();
1094   }
1095   UpdateHighlight();
1096   Modified();
1097 }
1098
1099
1100 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1101   myEntityState = eAllEntity;
1102
1103   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
1104     myEntityState &= ~eEdges;
1105     theMode &= ~eEdges;
1106   }
1107
1108   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
1109     myEntityState &= ~eFaces;
1110     theMode &= ~eFaces;
1111   }
1112
1113   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1114     myEntityState &= ~eVolumes;
1115     theMode &= ~eVolumes;
1116   }
1117
1118   if(!theMode){
1119     if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1120       theMode |= eEdges;
1121
1122     if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1123       theMode |= eFaces;
1124
1125     if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1126       theMode |= eVolumes;
1127   }
1128
1129   myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1130
1131   myEntityMode = theMode;
1132   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1133   aFilter = myBaseActor->GetExtractUnstructuredGrid();
1134   aFilter->ClearRegisteredCellsWithType();
1135   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1136   
1137   if(myEntityMode & eEdges){
1138     if (MYDEBUG) MESSAGE("EDGES");
1139     aFilter->RegisterCellsWithType(VTK_LINE);
1140     aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1141   }
1142
1143   if(myEntityMode & eFaces){
1144     if (MYDEBUG) MESSAGE("FACES");
1145     aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1146     aFilter->RegisterCellsWithType(VTK_POLYGON);
1147     aFilter->RegisterCellsWithType(VTK_QUAD);
1148     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1149     aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1150   }
1151
1152   if(myEntityMode & eVolumes){
1153     if (MYDEBUG) MESSAGE("VOLUMES");
1154     aFilter->RegisterCellsWithType(VTK_TETRA);
1155     aFilter->RegisterCellsWithType(VTK_VOXEL);
1156     aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1157     aFilter->RegisterCellsWithType(VTK_WEDGE);
1158     aFilter->RegisterCellsWithType(VTK_PYRAMID);
1159     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1160     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1161     aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1162     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1163   }
1164   aFilter->Update();
1165   if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1166   SetVisibility(GetVisibility(),false);
1167 }
1168
1169 void SMESH_ActorDef::SetRepresentation(int theMode){ 
1170   int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1171   int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1172   int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1173   if(theMode < 0){
1174     myRepresentation = eSurface;
1175     if(!aNbFaces && !aNbVolumes && aNbEdges){
1176       myRepresentation = eEdge;
1177     }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1178       myRepresentation = ePoint;
1179     }
1180   }else{
1181     switch(theMode){
1182     case eEdge:
1183       if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1184       break;
1185     case eSurface:
1186       if(!aNbFaces && !aNbVolumes) return;
1187       break;
1188     }    
1189     myRepresentation = theMode;
1190   }
1191
1192   if(!GetUnstructuredGrid()->GetNumberOfCells())
1193     myRepresentation = ePoint;
1194
1195   if(myIsShrunk){
1196     if(myRepresentation == ePoint){
1197       UnShrink();
1198       myIsShrunk = true;
1199     }else{
1200       SetShrink();
1201     }      
1202   }
1203
1204   myPickableActor = myBaseActor;
1205   myNodeActor->SetVisibility(false);
1206   myNodeExtActor->SetVisibility(false);
1207   vtkProperty *aProp = NULL, *aBackProp = NULL;
1208   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1209   switch(myRepresentation){
1210   case ePoint:
1211     myPickableActor = myNodeActor;
1212     myNodeActor->SetVisibility(true);
1213     
1214     aProp = aBackProp = myNodeProp;
1215     aReperesent = SMESH_DeviceActor::ePoint;
1216     break;
1217   case eEdge:
1218     aProp = aBackProp = myEdgeProp;
1219     aReperesent = SMESH_DeviceActor::eInsideframe;
1220     break;
1221   case eSurface:
1222     aProp = mySurfaceProp;
1223     aBackProp = myBackSurfaceProp;
1224     aReperesent = SMESH_DeviceActor::eSurface;
1225     break;
1226   }    
1227
1228   my2DActor->SetProperty(aProp);
1229   my2DActor->SetBackfaceProperty(aBackProp);
1230   my2DActor->SetRepresentation(aReperesent);
1231
1232   my2DExtActor->SetRepresentation(aReperesent);
1233   
1234   my3DActor->SetProperty(aProp);
1235   my3DActor->SetBackfaceProperty(aBackProp);
1236   my3DActor->SetRepresentation(aReperesent);
1237
1238   my1DExtActor->SetVisibility(false);
1239   my2DExtActor->SetVisibility(false);
1240
1241   switch(myControlMode){
1242   case eLength:
1243   case eMultiConnection:
1244     aProp = aBackProp = my1DProp;
1245     if(myRepresentation != ePoint)
1246       aReperesent = SMESH_DeviceActor::eInsideframe;
1247     break;
1248   }
1249   
1250   my1DActor->SetProperty(aProp);
1251   my1DActor->SetBackfaceProperty(aBackProp);
1252   my1DActor->SetRepresentation(aReperesent);
1253
1254   my1DExtActor->SetRepresentation(aReperesent);
1255   
1256   if(myIsPointsVisible)
1257     myPickableActor = myNodeActor;
1258   if(GetPointRepresentation())
1259     myNodeActor->SetVisibility(true);
1260
1261   SetMapper(myPickableActor->GetMapper());
1262
1263   SetVisibility(GetVisibility(),false);
1264
1265   Modified();
1266 }
1267
1268
1269 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1270   if ( myIsPointsVisible == theIsPointsVisible )
1271     return;
1272   myIsPointsVisible = theIsPointsVisible;
1273   SetRepresentation(GetRepresentation());
1274 }
1275
1276 bool SMESH_ActorDef::GetPointRepresentation(){ 
1277   return myIsPointsVisible || myIsPointsLabeled;
1278 }
1279
1280
1281 void SMESH_ActorDef::UpdateHighlight(){
1282   myHighlitableActor->SetVisibility(false);
1283   myHighlitableActor->SetHighlited(false);
1284
1285   if(myIsHighlighted){
1286     myHighlitableActor->SetProperty(myHighlightProp);
1287   }else if(myIsPreselected){
1288     myHighlitableActor->SetProperty(myPreselectProp);
1289   }
1290
1291   bool anIsVisible = GetVisibility();
1292
1293   if(myIsHighlighted || myIsPreselected){
1294     if(GetUnstructuredGrid()->GetNumberOfCells()){
1295       myHighlitableActor->SetHighlited(anIsVisible);
1296       myHighlitableActor->SetVisibility(anIsVisible);
1297       myHighlitableActor->GetExtractUnstructuredGrid()->
1298         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1299       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1300     }else if(myRepresentation == ePoint || GetPointRepresentation()){
1301       myHighlitableActor->SetHighlited(anIsVisible);
1302       myHighlitableActor->GetExtractUnstructuredGrid()->
1303         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1304       myHighlitableActor->SetVisibility(anIsVisible);
1305       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1306     }
1307   }
1308 }
1309
1310
1311 void SMESH_ActorDef::highlight(bool theHighlight){
1312   if ( myIsHighlighted == theHighlight )
1313     return;
1314   myIsHighlighted = theHighlight;
1315   UpdateHighlight();
1316 }
1317
1318
1319 void SMESH_ActorDef::SetPreSelected(bool thePreselect){ 
1320   if ( myIsPreselected == thePreselect )
1321     return;
1322   myIsPreselected = thePreselect; 
1323   UpdateHighlight();
1324 }
1325
1326
1327 // From vtkFollower
1328 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1329 {
1330   if (myPickableActor->GetIsOpaque())
1331     {
1332     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1333     this->Render(ren);
1334     return 1;
1335     }
1336   return 0;
1337 }
1338
1339
1340 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1341 {
1342   if (!myPickableActor->GetIsOpaque())
1343     {
1344     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1345     this->Render(ren);
1346     return 1;
1347     }
1348   return 0;
1349 }
1350
1351
1352 void SMESH_ActorDef::Render(vtkRenderer *ren){
1353   unsigned long aTime = myTimeStamp->GetMTime();
1354   unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1355   unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1356   if(anObjTime > aTime || aClippingTime > aTime)
1357     Update();
1358 }
1359
1360
1361 void SMESH_ActorDef::Update(){
1362   if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1363
1364   if(GetControlMode() != eNone) {
1365     unsigned long aTime = myTimeStamp->GetMTime();
1366     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1367     if (anObjTime > aTime)
1368       SetControlMode(GetControlMode(),false);
1369   }
1370   if(myIsPointsLabeled){
1371     SetPointsLabeled(myIsPointsLabeled);
1372   }
1373   if(myIsCellsLabeled){
1374     SetCellsLabeled(myIsCellsLabeled);
1375   }
1376   if(myIsFacesOriented){
1377     SetFacesOriented(myIsFacesOriented);
1378   }
1379   SetEntityMode(GetEntityMode());
1380   SetVisibility(GetVisibility());
1381   
1382   myTimeStamp->Modified();
1383   Modified();
1384 }
1385
1386
1387 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1388   SALOME_Actor::ReleaseGraphicsResources(renWin);
1389
1390   myPickableActor->ReleaseGraphicsResources(renWin);
1391 }
1392
1393
1394 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1395   vtkFloatingPointType* aColor = theProperty->GetColor();
1396   r = aColor[0];
1397   g = aColor[1];
1398   b = aColor[2];
1399 }
1400
1401
1402 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1403   mySurfaceProp->SetOpacity(theValue);
1404   myBackSurfaceProp->SetOpacity(theValue);
1405   myEdgeProp->SetOpacity(theValue);
1406   myNodeProp->SetOpacity(theValue);
1407
1408   my1DProp->SetOpacity(theValue);
1409 }
1410
1411
1412 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1413   return mySurfaceProp->GetOpacity();
1414 }
1415
1416
1417 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1418   mySurfaceProp->SetColor(r,g,b);
1419   Modified();
1420 }
1421
1422 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1423   ::GetColor(mySurfaceProp,r,g,b);
1424   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1425 }
1426
1427 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1428   myBackSurfaceProp->SetColor(r,g,b);
1429   Modified();
1430 }
1431
1432 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1433   ::GetColor(myBackSurfaceProp,r,g,b);
1434 }
1435
1436 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1437   myEdgeProp->SetColor(r,g,b);
1438   my1DProp->SetColor(r,g,b);
1439   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1440   Modified();
1441 }
1442
1443 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1444   ::GetColor(myEdgeProp,r,g,b);
1445 }
1446
1447 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1448   myNodeProp->SetColor(r,g,b);
1449   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1450   Modified();
1451 }
1452
1453 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1454   ::GetColor(myNodeProp,r,g,b);
1455 }
1456
1457 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1458   myHighlightProp->SetColor(r,g,b);
1459   Modified();
1460 }
1461
1462 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1463   ::GetColor(myHighlightProp,r,g,b);
1464 }
1465
1466 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1467   myPreselectProp->SetColor(r,g,b);
1468   Modified();
1469 }
1470
1471 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1472   ::GetColor(myPreselectProp,r,g,b);
1473 }
1474
1475
1476 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1477   return myEdgeProp->GetLineWidth();
1478 }
1479
1480
1481 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1482   myEdgeProp->SetLineWidth(theVal);
1483
1484   my1DProp->SetLineWidth(theVal + aLineWidthInc);
1485   my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1486
1487   Modified();
1488 }
1489
1490
1491 void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
1492   myNodeProp->SetPointSize(theVal);
1493   myNodeExtProp->SetPointSize(theVal);
1494   myHighlightProp->SetPointSize(theVal);
1495   myPreselectProp->SetPointSize(theVal);
1496
1497   my1DProp->SetPointSize(theVal + aPointSizeInc);
1498   my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1499
1500   Modified();
1501 }
1502
1503 vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){
1504   return myNodeProp->GetPointSize();
1505 }
1506
1507 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1508 {
1509   return myVisualObj->GetElemDimension( theObjId );
1510 }
1511
1512 bool
1513 SMESH_ActorDef::
1514 IsImplicitFunctionUsed() const
1515 {
1516   return myBaseActor->IsImplicitFunctionUsed();
1517 }
1518
1519 void
1520 SMESH_ActorDef::
1521 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1522 {
1523   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1524   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1525   
1526   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1527
1528   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1529   
1530   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1531   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1532   
1533   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1534   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1535   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1536 }
1537
1538 vtkIdType 
1539 SMESH_ActorDef::
1540 AddClippingPlane(vtkPlane* thePlane)
1541 {
1542   if(thePlane){
1543     myImplicitBoolean->GetFunction()->AddItem(thePlane);
1544     myCippingPlaneCont.push_back(thePlane);
1545     if(!IsImplicitFunctionUsed())
1546       SetImplicitFunctionUsed(true);
1547   }
1548   return myCippingPlaneCont.size();
1549 }
1550
1551 void
1552 SMESH_ActorDef::
1553 RemoveAllClippingPlanes()
1554 {
1555   myImplicitBoolean->GetFunction()->RemoveAllItems();
1556   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1557   myCippingPlaneCont.clear();
1558   SetImplicitFunctionUsed(false);
1559 }
1560
1561 vtkIdType
1562 SMESH_ActorDef::
1563 GetNumberOfClippingPlanes()
1564 {
1565   return myCippingPlaneCont.size();
1566 }
1567
1568 vtkPlane* 
1569 SMESH_ActorDef::
1570 GetClippingPlane(vtkIdType theID)
1571 {
1572   if(theID >= myCippingPlaneCont.size())
1573     return NULL;
1574   return myCippingPlaneCont[theID].Get();
1575 }
1576
1577
1578 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1579                                vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1580                                vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1581 {
1582   vtkFloatingPointType aBounds[6];
1583   theDataSet->GetBounds(aBounds);
1584
1585   //Enlarge bounds in order to avoid conflicts of precision
1586   for(int i = 0; i < 6; i += 2){
1587     static double EPS = 1.0E-3;
1588     vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1589     aBounds[i] -= aDelta;
1590     aBounds[i+1] += aDelta;
1591   }
1592
1593   vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1594                                {aBounds[1],aBounds[2],aBounds[4]},
1595                                {aBounds[0],aBounds[3],aBounds[4]},
1596                                {aBounds[1],aBounds[3],aBounds[4]},
1597                                {aBounds[0],aBounds[2],aBounds[5]},
1598                                {aBounds[1],aBounds[2],aBounds[5]}, 
1599                                {aBounds[0],aBounds[3],aBounds[5]}, 
1600                                {aBounds[1],aBounds[3],aBounds[5]}};
1601
1602   int aMaxId = 0, aMinId = aMaxId;
1603   theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1604   theMinBoundPrj = theMaxBoundPrj;
1605   for(int i = 1; i < 8; i++){
1606     vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1607     if(theMaxBoundPrj < aTmp){
1608       theMaxBoundPrj = aTmp;
1609       aMaxId = i;
1610     }
1611     if(theMinBoundPrj > aTmp){
1612       theMinBoundPrj = aTmp;
1613       aMinId = i;
1614     }
1615   }
1616   vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1617   theMinPnt[0] = aMinPnt[0];
1618   theMinPnt[1] = aMinPnt[1];
1619   theMinPnt[2] = aMinPnt[2];
1620 }
1621
1622
1623 static void DistanceToPosition(vtkDataSet* theDataSet,
1624                                vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1625 {
1626   vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1627   ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1628   vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1629   thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1630   thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1631   thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1632 }
1633
1634
1635 static void PositionToDistance(vtkDataSet* theDataSet, 
1636                                vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1637 {
1638   vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1639   ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1640   vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1641   theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1642 }
1643
1644
1645 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1646 {
1647   thePlane->SetNormal(theDir);
1648   vtkFloatingPointType anOrigin[3];
1649   ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1650   thePlane->SetOrigin(anOrigin);
1651 }
1652
1653
1654 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1655 {
1656   thePlane->GetNormal(theDir);
1657
1658   vtkFloatingPointType anOrigin[3];
1659   thePlane->GetOrigin(anOrigin);
1660   ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1661 }
1662
1663 void SMESH_ActorDef::UpdateScalarBar()
1664 {
1665   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1666   if( !mgr )
1667     return;
1668
1669   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1670
1671   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1672   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1673
1674   aScalarBarTitleProp->SetFontFamilyToArial();
1675
1676   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1677   {
1678     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1679     if ( f.family() == "Arial" )
1680       aScalarBarTitleProp->SetFontFamilyToArial();
1681     else if ( f.family() == "Courier" )
1682       aScalarBarTitleProp->SetFontFamilyToCourier();
1683     else if ( f.family() == "Times" )
1684       aScalarBarTitleProp->SetFontFamilyToTimes();
1685
1686     if ( f.bold() )
1687       aScalarBarTitleProp->BoldOn();
1688     else
1689       aScalarBarTitleProp->BoldOff();
1690
1691     if ( f.italic() )
1692       aScalarBarTitleProp->ItalicOn();
1693     else
1694      aScalarBarTitleProp->ItalicOff();
1695
1696     if ( f.overline() )
1697       aScalarBarTitleProp->ShadowOn();
1698     else
1699       aScalarBarTitleProp->ShadowOff();
1700   }
1701
1702   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1703   aScalarBarTitleProp->Delete();
1704
1705   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1706
1707   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1708   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1709
1710   aScalarBarLabelProp->SetFontFamilyToArial();
1711   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1712   {
1713     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1714     if( f.family() == "Arial" )
1715       aScalarBarLabelProp->SetFontFamilyToArial();
1716     else if( f.family() == "Courier" )
1717       aScalarBarLabelProp->SetFontFamilyToCourier();
1718     else if( f.family() == "Times" )
1719       aScalarBarLabelProp->SetFontFamilyToTimes();
1720
1721     if ( f.bold() )
1722       aScalarBarLabelProp->BoldOn();
1723     else
1724       aScalarBarLabelProp->BoldOff();
1725
1726     if ( f.italic() )
1727       aScalarBarLabelProp->ItalicOn();
1728     else
1729       aScalarBarLabelProp->ItalicOff();
1730
1731     if( f.overline() )
1732       aScalarBarLabelProp->ShadowOn();
1733     else
1734       aScalarBarLabelProp->ShadowOff();
1735   }
1736
1737   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1738   aScalarBarLabelProp->Delete();
1739
1740   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1741   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1742   if( horiz )
1743     myScalarBarActor->SetOrientationToHorizontal();
1744   else
1745     myScalarBarActor->SetOrientationToVertical();
1746
1747
1748   vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1749   if( mgr->hasValue( "SMESH", name + "x" ) )
1750     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1751
1752   vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1753   if( mgr->hasValue( "SMESH", name + "y" ) )
1754     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1755   myScalarBarActor->SetPosition( aXVal, aYVal );
1756
1757   vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1758   if( mgr->hasValue( "SMESH", name + "width" ) )
1759     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1760   myScalarBarActor->SetWidth( aWVal );
1761
1762   vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1763   if( mgr->hasValue( "SMESH", name + "height" ) )
1764     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1765   myScalarBarActor->SetHeight( aHVal );
1766
1767   int anIntVal = 5;
1768   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1769     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1770   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1771
1772   anIntVal = 64;
1773   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1774     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1775   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1776   
1777 }