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