Salome HOME
Merge from V5_1_2_BR branch (14 July 2009)
[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   VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1168   aHightFilter->ClearRegisteredCellsWithType();
1169   aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1170
1171   
1172   if(myEntityMode & eEdges){
1173     if (MYDEBUG) MESSAGE("EDGES");
1174     aFilter->RegisterCellsWithType(VTK_LINE);
1175     aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1176
1177     aHightFilter->RegisterCellsWithType(VTK_LINE);
1178     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1179   }
1180
1181   if(myEntityMode & eFaces){
1182     if (MYDEBUG) MESSAGE("FACES");
1183     aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1184     aFilter->RegisterCellsWithType(VTK_POLYGON);
1185     aFilter->RegisterCellsWithType(VTK_QUAD);
1186     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1187     aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1188
1189     aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1190     aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1191     aHightFilter->RegisterCellsWithType(VTK_QUAD);
1192     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1193     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1194   }
1195
1196   if(myEntityMode & eVolumes){
1197     if (MYDEBUG) MESSAGE("VOLUMES");
1198     aFilter->RegisterCellsWithType(VTK_TETRA);
1199     aFilter->RegisterCellsWithType(VTK_VOXEL);
1200     aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1201     aFilter->RegisterCellsWithType(VTK_WEDGE);
1202     aFilter->RegisterCellsWithType(VTK_PYRAMID);
1203     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1204     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1205     aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1206     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1207     
1208     aHightFilter->RegisterCellsWithType(VTK_TETRA);
1209     aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1210     aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1211     aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1212     aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1213     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1214     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1215     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1216     aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1217   }
1218   aFilter->Update();
1219   if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1220   SetVisibility(GetVisibility(),false);
1221 }
1222
1223 void SMESH_ActorDef::SetRepresentation(int theMode){ 
1224   int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1225   int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1226   int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1227   if(theMode < 0){
1228     myRepresentation = eSurface;
1229     if(!aNbFaces && !aNbVolumes && aNbEdges){
1230       myRepresentation = eEdge;
1231     }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1232       myRepresentation = ePoint;
1233     }
1234   }else{
1235     switch(theMode){
1236     case eEdge:
1237       if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1238       break;
1239     case eSurface:
1240       if(!aNbFaces && !aNbVolumes) return;
1241       break;
1242     }    
1243     myRepresentation = theMode;
1244   }
1245
1246   if(!GetUnstructuredGrid()->GetNumberOfCells())
1247     myRepresentation = ePoint;
1248
1249   if(myIsShrunk){
1250     if(myRepresentation == ePoint){
1251       UnShrink();
1252       myIsShrunk = true;
1253     }else{
1254       SetShrink();
1255     }      
1256   }
1257
1258   myPickableActor = myBaseActor;
1259   myNodeActor->SetVisibility(false);
1260   myNodeExtActor->SetVisibility(false);
1261   vtkProperty *aProp = NULL, *aBackProp = NULL;
1262   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1263   SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1264   switch(myRepresentation){
1265   case ePoint:
1266     myPickableActor = myNodeActor;
1267     myNodeActor->SetVisibility(true);
1268     aQuadraticMode = SMESH_Actor::eLines;
1269     aProp = aBackProp = myNodeProp;
1270     aReperesent = SMESH_DeviceActor::ePoint;
1271     break;
1272   case eEdge:
1273     aProp = aBackProp = myEdgeProp;
1274     aReperesent = SMESH_DeviceActor::eInsideframe;
1275     break;
1276   case eSurface:
1277     aProp = mySurfaceProp;
1278     aBackProp = myBackSurfaceProp;
1279     aReperesent = SMESH_DeviceActor::eSurface;
1280     break;
1281   }    
1282
1283   my2DActor->SetProperty(aProp);
1284   my2DActor->SetBackfaceProperty(aBackProp);
1285   my2DActor->SetRepresentation(aReperesent);
1286
1287   if(aQuadraticMode == SMESH_Actor::eLines)
1288     my2DActor->SetQuadraticArcMode(false);
1289   else if(aQuadraticMode == SMESH_Actor::eArcs)
1290     my2DActor->SetQuadraticArcMode(true);
1291
1292   my2DExtActor->SetRepresentation(aReperesent);
1293   
1294   my3DActor->SetProperty(aProp);
1295   my3DActor->SetBackfaceProperty(aBackProp);
1296   my3DActor->SetRepresentation(aReperesent);
1297
1298   my1DExtActor->SetVisibility(false);
1299   my2DExtActor->SetVisibility(false);
1300
1301   switch(myControlMode){
1302   case eLength:
1303   case eMultiConnection:
1304     aProp = aBackProp = my1DProp;
1305     if(myRepresentation != ePoint)
1306       aReperesent = SMESH_DeviceActor::eInsideframe;
1307     break;
1308   }
1309   
1310   if(aQuadraticMode == SMESH_Actor::eLines)
1311     my1DActor->SetQuadraticArcMode(false);
1312   else if(aQuadraticMode == SMESH_Actor::eArcs)
1313     my1DActor->SetQuadraticArcMode(true);
1314   
1315   
1316   my1DActor->SetProperty(aProp);
1317   my1DActor->SetBackfaceProperty(aBackProp);
1318   my1DActor->SetRepresentation(aReperesent);
1319
1320   my1DExtActor->SetRepresentation(aReperesent);
1321   
1322   if(myIsPointsVisible)
1323     myPickableActor = myNodeActor;
1324   if(GetPointRepresentation())
1325     myNodeActor->SetVisibility(true);
1326
1327   SetMapper(myPickableActor->GetMapper());
1328
1329   SetVisibility(GetVisibility(),false);
1330
1331   Modified();
1332 }
1333
1334
1335 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1336   if ( myIsPointsVisible == theIsPointsVisible )
1337     return;
1338   myIsPointsVisible = theIsPointsVisible;
1339   SetRepresentation(GetRepresentation());
1340 }
1341
1342 bool SMESH_ActorDef::GetPointRepresentation(){ 
1343   return myIsPointsVisible || myIsPointsLabeled;
1344 }
1345
1346
1347 void SMESH_ActorDef::UpdateHighlight(){
1348   myHighlitableActor->SetVisibility(false);
1349   myHighlitableActor->SetHighlited(false);
1350
1351   if(myIsHighlighted){
1352     myHighlitableActor->SetProperty(myHighlightProp);
1353   }else if(myIsPreselected){
1354     myHighlitableActor->SetProperty(myPreselectProp);
1355   }
1356
1357   bool anIsVisible = GetVisibility();
1358
1359   if(myIsHighlighted || myIsPreselected){
1360     if(GetUnstructuredGrid()->GetNumberOfCells()){
1361       myHighlitableActor->SetHighlited(anIsVisible);
1362       myHighlitableActor->SetVisibility(anIsVisible);
1363       myHighlitableActor->GetExtractUnstructuredGrid()->
1364         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1365       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1366     }else if(myRepresentation == ePoint || GetPointRepresentation()){
1367       myHighlitableActor->SetHighlited(anIsVisible);
1368       myHighlitableActor->GetExtractUnstructuredGrid()->
1369         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1370       myHighlitableActor->SetVisibility(anIsVisible);
1371       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1372     }
1373   }
1374 }
1375
1376
1377 void SMESH_ActorDef::highlight(bool theHighlight){
1378   if ( myIsHighlighted == theHighlight )
1379     return;
1380   myIsHighlighted = theHighlight;
1381   UpdateHighlight();
1382 }
1383
1384
1385 void SMESH_ActorDef::SetPreSelected(bool thePreselect){ 
1386   if ( myIsPreselected == thePreselect )
1387     return;
1388   myIsPreselected = thePreselect; 
1389   UpdateHighlight();
1390 }
1391
1392
1393 // From vtkFollower
1394 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1395 {
1396   if (myPickableActor->GetIsOpaque())
1397     {
1398     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1399     this->Render(ren);
1400     return 1;
1401     }
1402   return 0;
1403 }
1404
1405
1406 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1407 {
1408   if (!myPickableActor->GetIsOpaque())
1409     {
1410     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1411     this->Render(ren);
1412     return 1;
1413     }
1414   return 0;
1415 }
1416
1417
1418 void SMESH_ActorDef::Render(vtkRenderer *ren){
1419   unsigned long aTime = myTimeStamp->GetMTime();
1420   unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1421   unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1422   if(anObjTime > aTime || aClippingTime > aTime)
1423     Update();
1424 }
1425
1426
1427 void SMESH_ActorDef::Update(){
1428   if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1429
1430   if(GetControlMode() != eNone) {
1431     unsigned long aTime = myTimeStamp->GetMTime();
1432     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1433     if (anObjTime > aTime)
1434       SetControlMode(GetControlMode(),false);
1435   }
1436   if(myIsPointsLabeled){
1437     SetPointsLabeled(myIsPointsLabeled);
1438   }
1439   if(myIsCellsLabeled){
1440     SetCellsLabeled(myIsCellsLabeled);
1441   }
1442   if(myIsFacesOriented){
1443     SetFacesOriented(myIsFacesOriented);
1444   }
1445   SetEntityMode(GetEntityMode());
1446   SetVisibility(GetVisibility());
1447   
1448   myTimeStamp->Modified();
1449   Modified();
1450 }
1451
1452
1453 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1454   SALOME_Actor::ReleaseGraphicsResources(renWin);
1455
1456   myPickableActor->ReleaseGraphicsResources(renWin);
1457 }
1458
1459
1460 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1461   vtkFloatingPointType* aColor = theProperty->GetColor();
1462   r = aColor[0];
1463   g = aColor[1];
1464   b = aColor[2];
1465 }
1466
1467
1468 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1469   mySurfaceProp->SetOpacity(theValue);
1470   myBackSurfaceProp->SetOpacity(theValue);
1471   myEdgeProp->SetOpacity(theValue);
1472   myNodeProp->SetOpacity(theValue);
1473
1474   my1DProp->SetOpacity(theValue);
1475 }
1476
1477
1478 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1479   return mySurfaceProp->GetOpacity();
1480 }
1481
1482
1483 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1484   mySurfaceProp->SetColor(r,g,b);
1485   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1486     if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1487         aGroupObj->GetElementType() == SMDSAbs_Volume )
1488       myNameActor->SetBackgroundColor(r,g,b);
1489   Modified();
1490 }
1491
1492 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1493   ::GetColor(mySurfaceProp,r,g,b);
1494   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1495 }
1496
1497 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1498   myBackSurfaceProp->SetColor(r,g,b);
1499   Modified();
1500 }
1501
1502 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1503   ::GetColor(myBackSurfaceProp,r,g,b);
1504 }
1505
1506 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1507   myEdgeProp->SetColor(r,g,b);
1508   my1DProp->SetColor(r,g,b);
1509   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1510   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1511     if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1512       myNameActor->SetBackgroundColor(r,g,b);
1513   Modified();
1514 }
1515
1516 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1517   ::GetColor(myEdgeProp,r,g,b);
1518 }
1519
1520 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1521   myNodeProp->SetColor(r,g,b);
1522   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1523   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1524     if( aGroupObj->GetElementType() == SMDSAbs_Node )
1525       myNameActor->SetBackgroundColor(r,g,b);
1526   Modified();
1527 }
1528
1529 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1530   ::GetColor(myNodeProp,r,g,b);
1531 }
1532
1533 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1534   myHighlightProp->SetColor(r,g,b);
1535   Modified();
1536 }
1537
1538 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1539   ::GetColor(myHighlightProp,r,g,b);
1540 }
1541
1542 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1543   myPreselectProp->SetColor(r,g,b);
1544   Modified();
1545 }
1546
1547 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1548   ::GetColor(myPreselectProp,r,g,b);
1549 }
1550
1551
1552 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1553   return myEdgeProp->GetLineWidth();
1554 }
1555
1556
1557 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1558   myEdgeProp->SetLineWidth(theVal);
1559
1560   my1DProp->SetLineWidth(theVal + aLineWidthInc);
1561   my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1562
1563   Modified();
1564 }
1565
1566
1567 void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
1568   myNodeProp->SetPointSize(theVal);
1569   myNodeExtProp->SetPointSize(theVal);
1570   myHighlightProp->SetPointSize(theVal);
1571   myPreselectProp->SetPointSize(theVal);
1572
1573   my1DProp->SetPointSize(theVal + aPointSizeInc);
1574   my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1575
1576   Modified();
1577 }
1578
1579 vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){
1580   return myNodeProp->GetPointSize();
1581 }
1582
1583 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1584 {
1585   return myVisualObj->GetElemDimension( theObjId );
1586 }
1587
1588 bool
1589 SMESH_ActorDef::
1590 IsImplicitFunctionUsed() const
1591 {
1592   return myBaseActor->IsImplicitFunctionUsed();
1593 }
1594
1595 void
1596 SMESH_ActorDef::
1597 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1598 {
1599   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1600   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1601   
1602   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1603
1604   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1605   
1606   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1607   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1608   
1609   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1610   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1611   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1612 }
1613
1614 vtkIdType 
1615 SMESH_ActorDef::
1616 AddClippingPlane(vtkPlane* thePlane)
1617 {
1618   if(thePlane){
1619     myImplicitBoolean->GetFunction()->AddItem(thePlane);
1620     myCippingPlaneCont.push_back(thePlane);
1621     if(!IsImplicitFunctionUsed())
1622       SetImplicitFunctionUsed(true);
1623   }
1624   return myCippingPlaneCont.size();
1625 }
1626
1627 void
1628 SMESH_ActorDef::
1629 RemoveAllClippingPlanes()
1630 {
1631   myImplicitBoolean->GetFunction()->RemoveAllItems();
1632   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1633   myCippingPlaneCont.clear();
1634   SetImplicitFunctionUsed(false);
1635 }
1636
1637 vtkIdType
1638 SMESH_ActorDef::
1639 GetNumberOfClippingPlanes()
1640 {
1641   return myCippingPlaneCont.size();
1642 }
1643
1644 vtkPlane* 
1645 SMESH_ActorDef::
1646 GetClippingPlane(vtkIdType theID)
1647 {
1648   if(theID >= myCippingPlaneCont.size())
1649     return NULL;
1650   return myCippingPlaneCont[theID].Get();
1651 }
1652
1653
1654 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1655                                vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1656                                vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1657 {
1658   vtkFloatingPointType aBounds[6];
1659   theDataSet->GetBounds(aBounds);
1660
1661   //Enlarge bounds in order to avoid conflicts of precision
1662   for(int i = 0; i < 6; i += 2){
1663     static double EPS = 1.0E-3;
1664     vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1665     aBounds[i] -= aDelta;
1666     aBounds[i+1] += aDelta;
1667   }
1668
1669   vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1670                                {aBounds[1],aBounds[2],aBounds[4]},
1671                                {aBounds[0],aBounds[3],aBounds[4]},
1672                                {aBounds[1],aBounds[3],aBounds[4]},
1673                                {aBounds[0],aBounds[2],aBounds[5]},
1674                                {aBounds[1],aBounds[2],aBounds[5]}, 
1675                                {aBounds[0],aBounds[3],aBounds[5]}, 
1676                                {aBounds[1],aBounds[3],aBounds[5]}};
1677
1678   int aMaxId = 0, aMinId = aMaxId;
1679   theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1680   theMinBoundPrj = theMaxBoundPrj;
1681   for(int i = 1; i < 8; i++){
1682     vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1683     if(theMaxBoundPrj < aTmp){
1684       theMaxBoundPrj = aTmp;
1685       aMaxId = i;
1686     }
1687     if(theMinBoundPrj > aTmp){
1688       theMinBoundPrj = aTmp;
1689       aMinId = i;
1690     }
1691   }
1692   vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1693   theMinPnt[0] = aMinPnt[0];
1694   theMinPnt[1] = aMinPnt[1];
1695   theMinPnt[2] = aMinPnt[2];
1696 }
1697
1698
1699 static void DistanceToPosition(vtkDataSet* theDataSet,
1700                                vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1701 {
1702   vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1703   ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1704   vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1705   thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1706   thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1707   thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1708 }
1709
1710
1711 static void PositionToDistance(vtkDataSet* theDataSet, 
1712                                vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1713 {
1714   vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1715   ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1716   vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1717   theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1718 }
1719
1720
1721 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1722 {
1723   thePlane->SetNormal(theDir);
1724   vtkFloatingPointType anOrigin[3];
1725   ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1726   thePlane->SetOrigin(anOrigin);
1727 }
1728
1729
1730 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1731 {
1732   thePlane->GetNormal(theDir);
1733
1734   vtkFloatingPointType anOrigin[3];
1735   thePlane->GetOrigin(anOrigin);
1736   ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1737 }
1738
1739 void SMESH_ActorDef::UpdateScalarBar()
1740 {
1741   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1742   if( !mgr )
1743     return;
1744
1745   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1746
1747   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1748   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1749
1750   aScalarBarTitleProp->SetFontFamilyToArial();
1751
1752   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1753   {
1754     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1755     if ( f.family() == "Arial" )
1756       aScalarBarTitleProp->SetFontFamilyToArial();
1757     else if ( f.family() == "Courier" )
1758       aScalarBarTitleProp->SetFontFamilyToCourier();
1759     else if ( f.family() == "Times" )
1760       aScalarBarTitleProp->SetFontFamilyToTimes();
1761
1762     if ( f.bold() )
1763       aScalarBarTitleProp->BoldOn();
1764     else
1765       aScalarBarTitleProp->BoldOff();
1766
1767     if ( f.italic() )
1768       aScalarBarTitleProp->ItalicOn();
1769     else
1770      aScalarBarTitleProp->ItalicOff();
1771
1772     if ( f.overline() )
1773       aScalarBarTitleProp->ShadowOn();
1774     else
1775       aScalarBarTitleProp->ShadowOff();
1776   }
1777
1778   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1779   aScalarBarTitleProp->Delete();
1780
1781   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1782
1783   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1784   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1785
1786   aScalarBarLabelProp->SetFontFamilyToArial();
1787   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1788   {
1789     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1790     if( f.family() == "Arial" )
1791       aScalarBarLabelProp->SetFontFamilyToArial();
1792     else if( f.family() == "Courier" )
1793       aScalarBarLabelProp->SetFontFamilyToCourier();
1794     else if( f.family() == "Times" )
1795       aScalarBarLabelProp->SetFontFamilyToTimes();
1796
1797     if ( f.bold() )
1798       aScalarBarLabelProp->BoldOn();
1799     else
1800       aScalarBarLabelProp->BoldOff();
1801
1802     if ( f.italic() )
1803       aScalarBarLabelProp->ItalicOn();
1804     else
1805       aScalarBarLabelProp->ItalicOff();
1806
1807     if( f.overline() )
1808       aScalarBarLabelProp->ShadowOn();
1809     else
1810       aScalarBarLabelProp->ShadowOff();
1811   }
1812
1813   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1814   aScalarBarLabelProp->Delete();
1815
1816   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1817   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1818   if( horiz )
1819     myScalarBarActor->SetOrientationToHorizontal();
1820   else
1821     myScalarBarActor->SetOrientationToVertical();
1822
1823
1824   vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1825   if( mgr->hasValue( "SMESH", name + "x" ) )
1826     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1827
1828   vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1829   if( mgr->hasValue( "SMESH", name + "y" ) )
1830     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1831   myScalarBarActor->SetPosition( aXVal, aYVal );
1832
1833   vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1834   if( mgr->hasValue( "SMESH", name + "width" ) )
1835     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1836   myScalarBarActor->SetWidth( aWVal );
1837
1838   vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1839   if( mgr->hasValue( "SMESH", name + "height" ) )
1840     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1841   myScalarBarActor->SetHeight( aHVal );
1842
1843   int anIntVal = 5;
1844   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1845     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1846   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1847
1848   anIntVal = 64;
1849   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1850     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1851   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1852   
1853 }
1854
1855 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
1856 {
1857   switch(theMode) {
1858   case SMESH_Actor::eLines :
1859     myHighlitableActor->SetQuadraticArcMode(false);
1860     my2DActor->SetQuadraticArcMode(false);
1861     my1DActor->SetQuadraticArcMode(false);
1862     break;
1863   case SMESH_Actor::eArcs :
1864     myHighlitableActor->SetQuadraticArcMode(true);
1865     if(GetRepresentation() != SMESH_Actor::ePoint) {
1866       my2DActor->SetQuadraticArcMode(true);
1867       my1DActor->SetQuadraticArcMode(true);
1868     }
1869     break;
1870   default:
1871     break;
1872   }
1873 }
1874
1875
1876 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
1877 {
1878   if(myHighlitableActor->GetQuadraticArcMode())
1879     return SMESH_Actor::eArcs;
1880   else
1881     return SMESH_Actor::eLines;
1882 }