Salome HOME
933f34c56532b7a6c87455e52e09ea52f93c7967
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
1 // Copyright (C) 2007-2012  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
23 //  SMESH OBJECT : interactive object for SMESH visualization
24 //  File   : SMESH_Actor.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
40 #include "SMESH_SVTKActor.h"
41
42 #include "SUIT_Session.h"
43 #include "SUIT_ResourceMgr.h"
44
45 #include <Qtx.h>
46
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
49 #endif
50
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
56
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
61
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
64
65 #include <vtkCell.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
68
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
73
74 #include <vtkLookupTable.h>
75
76 #include <vtkMath.h>
77 #include <vtkPlane.h>
78 #include <vtkImplicitBoolean.h>
79 #include <vtkImplicitFunctionCollection.h>
80
81 #include <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
84 #endif
85
86 #include "utilities.h"
87
88 #ifdef _DEBUG_
89 static int MYDEBUG = 1;
90 #else
91 static int MYDEBUG = 1;
92 #endif
93
94 static int aLineWidthInc = 2;
95
96
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98   return new SMESH_ActorDef();
99 }
100
101
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, 
103                               const char* theEntry, 
104                               const char* theName,
105                               int theIsClear)
106 {
107   SMESH_ActorDef* anActor = NULL;
108   if(theVisualObj->IsValid() ) {
109     anActor = SMESH_ActorDef::New();
110     if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
111       anActor->Delete();
112       anActor = NULL;
113     }
114     if( anActor )
115       anActor->UpdateScalarBar();
116   }
117   return anActor;
118 }
119
120
121 SMESH_ActorDef::SMESH_ActorDef()
122 {
123   if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);  
124   myBaseActor = SMESH_DeviceActor::New();
125
126   myTimeStamp = vtkTimeStamp::New();
127
128   myIsPointsVisible = false;
129   myIsEntityModeCache = false;
130
131   myHighlightActor = SMESH_SVTKActor::New();
132   myHighlightActor->Delete(); // vtkSmartPointer!
133   myHighlightActor->Initialize();
134
135   myPreHighlightActor = SMESH_SVTKActor::New();
136   myPreHighlightActor->Delete();
137   myPreHighlightActor->Initialize();
138
139   myIsShrinkable = false;
140   myIsShrunk = false;
141
142   myIsFacesOriented = false;
143
144   myControlsPrecision = -1;
145   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
146
147   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
148     myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
149
150   vtkFloatingPointType aElem0DSize   = SMESH::GetFloat("SMESH:elem0d_size",5);
151   vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152   vtkFloatingPointType aLineWidth    = SMESH::GetFloat("SMESH:element_width",1);
153   vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
154
155   SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
156   bool aBoldNd    = true;
157   bool anItalicNd = false;
158   bool aShadowNd  = false;
159   int  aSizeNd    = 10;
160   if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
161     QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
162     if ( f.family()      == "Arial" )   aFamilyNd = SMESH::FntArial;
163     else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
164     else if ( f.family() == "Times" )   aFamilyNd = SMESH::FntTimes;    
165     aBoldNd    = f.bold();    
166     anItalicNd = f.italic();   
167     aShadowNd  = f.overline();   
168     aSizeNd    = f.pointSize();
169   }
170   vtkFloatingPointType anRGBNd[3] = {1,1,1};
171   SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
172
173   SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
174   bool aBoldEl    = true;
175   bool anItalicEl = false;
176   bool aShadowEl  = false;
177   int  aSizeEl    = 12;
178   if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
179     QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
180     if ( f.family()      == "Arial" )   aFamilyEl = SMESH::FntArial;
181     else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
182     else if ( f.family() == "Times" )   aFamilyEl = SMESH::FntTimes;    
183     aBoldEl    = f.bold();
184     anItalicEl = f.italic();
185     aShadowEl  = f.overline();    
186     aSizeEl    = f.pointSize();
187   }
188   vtkFloatingPointType anRGBEl[3] = {0,1,0};
189   SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
190
191   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
192   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
193
194   //Definition 2D and 3D devices of the actor
195   //-----------------------------------------
196   vtkFloatingPointType anRGB[3] = {1,1,1};
197   mySurfaceProp = vtkProperty::New();
198   QColor ffc, bfc;
199   int delta;
200   SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
201   mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
202   myDeltaBrightness = delta;
203
204   myBackSurfaceProp = vtkProperty::New();
205   bfc = Qtx::mainColorToSecondary(ffc, delta);
206   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
207
208   myNormalVProp = vtkProperty::New();
209   SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
210   myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
211   myDeltaVBrightness = delta;
212
213   myReversedVProp = vtkProperty::New();
214   bfc = Qtx::mainColorToSecondary(ffc, delta);
215   myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
216
217   my2DActor = SMESH_CellLabelActor::New();
218   my2DActor->SetStoreGemetryMapping(true);
219   my2DActor->SetUserMatrix(aMatrix);
220   my2DActor->PickableOff();
221   my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); 
222   my2DActor->SetProperty(mySurfaceProp);
223   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
224   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225   aFilter = my2DActor->GetExtractUnstructuredGrid();
226   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
228   aFilter->RegisterCellsWithType(VTK_POLYGON);
229   aFilter->RegisterCellsWithType(VTK_QUAD);
230   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
231   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
232   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
233
234   my2DExtProp = vtkProperty::New();
235   my2DExtProp->DeepCopy(mySurfaceProp);
236   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
237   anRGB[0] = 1 - anRGB[0];
238   anRGB[1] = 1 - anRGB[1];
239   anRGB[2] = 1 - anRGB[2];
240   my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
241
242   my2DExtActor = SMESH_DeviceActor::New();
243   my2DExtActor->SetUserMatrix(aMatrix);
244   my2DExtActor->PickableOff();
245   my2DExtActor->SetProperty(my2DExtProp);
246   my2DExtActor->SetBackfaceProperty(my2DExtProp);
247   my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
248   aFilter = my2DExtActor->GetExtractUnstructuredGrid();
249   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
250   aFilter->RegisterCellsWithType(VTK_POLYGON);
251   aFilter->RegisterCellsWithType(VTK_QUAD);
252   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
253   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
254   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
255
256   my3DActor = SMESH_CellLabelActor::New();
257   my3DActor->SetStoreGemetryMapping(true);
258   my3DActor->SetUserMatrix(aMatrix);
259   my3DActor->PickableOff();
260   my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); 
261   my3DActor->SetProperty(myNormalVProp);
262   my3DActor->SetBackfaceProperty(myReversedVProp);
263   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
264   my3DActor->SetCoincident3DAllowed(true);
265   aFilter = my3DActor->GetExtractUnstructuredGrid();
266   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
267   aFilter->RegisterCellsWithType(VTK_TETRA);
268   aFilter->RegisterCellsWithType(VTK_VOXEL);
269   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
270   aFilter->RegisterCellsWithType(VTK_WEDGE);
271   aFilter->RegisterCellsWithType(VTK_PYRAMID);
272   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
273   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
274   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
275   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
276   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
277   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
278   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
279 //#ifdef VTK_HAVE_POLYHEDRON
280   MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
281   aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
282 //#endif
283
284   my3DExtProp = vtkProperty::New();
285   my3DExtProp->DeepCopy(myNormalVProp);
286   SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
287   anRGB[0] = 1 - anRGB[0];
288   anRGB[1] = 1 - anRGB[1];
289   anRGB[2] = 1 - anRGB[2];
290   my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
291
292   my3DExtActor = SMESH_DeviceActor::New();
293   my3DExtActor->SetUserMatrix(aMatrix);
294   my3DExtActor->PickableOff();
295   my3DExtActor->SetProperty(my3DExtProp);
296   my3DExtActor->SetBackfaceProperty(my3DExtProp);
297   my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
298   my3DExtActor->SetCoincident3DAllowed(true);
299   aFilter = my3DExtActor->GetExtractUnstructuredGrid();
300   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
301   aFilter->RegisterCellsWithType(VTK_TETRA);
302   aFilter->RegisterCellsWithType(VTK_VOXEL);
303   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
304   aFilter->RegisterCellsWithType(VTK_WEDGE);
305   aFilter->RegisterCellsWithType(VTK_PYRAMID);
306   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
307   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
308   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
309   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
310   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
311   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
312   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
313   aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
314
315   //Definition 1D device of the actor
316   //---------------------------------
317   myEdgeProp = vtkProperty::New();
318   myEdgeProp->SetAmbient(1.0);
319   myEdgeProp->SetDiffuse(0.0);
320   myEdgeProp->SetSpecular(0.0);
321   SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
322   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
323   myEdgeProp->SetLineWidth(aLineWidth);
324
325   my1DActor = SMESH_CellLabelActor::New();
326   my1DActor->SetStoreGemetryMapping(true);
327   my1DActor->SetUserMatrix(aMatrix);
328   my1DActor->PickableOff();
329   my1DActor->SetHighlited(true);
330   my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
331   my1DActor->SetProperty(myEdgeProp);
332   my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
333   aFilter = my1DActor->GetExtractUnstructuredGrid();
334   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
335   aFilter->RegisterCellsWithType(VTK_LINE);
336   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
337
338   my1DProp = vtkProperty::New();
339   my1DProp->DeepCopy(myEdgeProp);
340   my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
341   my1DProp->SetPointSize(aElem0DSize);
342   
343   my1DExtProp = vtkProperty::New();
344   my1DExtProp->DeepCopy(myEdgeProp);
345   anRGB[0] = 1 - anRGB[0];
346   anRGB[1] = 1 - anRGB[1];
347   anRGB[2] = 1 - anRGB[2];
348   my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
349   my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
350   my1DExtProp->SetPointSize(aElem0DSize);
351
352   my1DExtActor = SMESH_DeviceActor::New();
353   my1DExtActor->SetUserMatrix(aMatrix);
354   my1DExtActor->PickableOff();
355   my1DExtActor->SetHighlited(true);
356   my1DExtActor->SetVisibility(false);
357   my1DExtActor->SetProperty(my1DExtProp);
358   my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
359   aFilter = my1DExtActor->GetExtractUnstructuredGrid();
360   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
361   aFilter->RegisterCellsWithType(VTK_LINE);
362   aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
363
364
365   //Definition 0D device of the actor (0d elements)
366   //-----------------------------------------------
367   my0DProp = vtkProperty::New();
368   SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
369   my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
370   my0DProp->SetPointSize(aElem0DSize);
371
372   my0DActor = SMESH_CellLabelActor::New();
373   my0DActor->SetUserMatrix(aMatrix);
374   my0DActor->SetStoreGemetryMapping(true);
375   my0DActor->PickableOff();
376   my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
377   my0DActor->SetVisibility(false);
378   my0DActor->SetProperty(my0DProp);
379   my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
380   aFilter = my0DActor->GetExtractUnstructuredGrid();
381   //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
382   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
383   aFilter->RegisterCellsWithType(VTK_VERTEX);
384   
385   //Definition 0D device of the actor (ball elements)
386   //-----------------------------------------------
387   myBallProp = vtkProperty::New();
388   SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
389   myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
390   myBallProp->SetPointSize(aBallElemSize);
391
392   myBallActor = SMESH_CellLabelActor::New();
393   myBallActor->SetUserMatrix(aMatrix);
394   myBallActor->SetStoreGemetryMapping(true);
395   myBallActor->PickableOff();
396   myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );  
397   myBallActor->SetVisibility(false);
398   myBallActor->SetProperty(myBallProp);
399   myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
400   aFilter = myBallActor->GetExtractUnstructuredGrid();
401   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
402   aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
403   
404   //my0DExtProp = vtkProperty::New();
405   //my0DExtProp->DeepCopy(my0DProp);
406   //anRGB[0] = 1 - anRGB[0];
407   //anRGB[1] = 1 - anRGB[1];
408   //anRGB[2] = 1 - anRGB[2];
409   //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
410   //my0DExtProp->SetPointSize(aElem0DSize);
411   //
412   //my0DExtActor = SMESH_DeviceActor::New();
413   //my0DExtActor->SetUserMatrix(aMatrix);
414   //my0DExtActor->SetStoreClippingMapping(true);
415   //my0DExtActor->PickableOff();
416   //my0DExtActor->SetHighlited(true);
417   //my0DExtActor->SetVisibility(false);
418   //my0DExtActor->SetProperty(my0DExtProp);
419   //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
420   //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
421   ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
422   //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
423   //aFilter->RegisterCellsWithType(VTK_VERTEX);
424
425
426   //Definition 0D device of the actor (nodes)
427   //-----------------------------------------
428   myNodeProp = vtkProperty::New();
429   SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
430   myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
431
432   myNodeActor = SMESH_NodeLabelActor::New();
433   myNodeActor->SetUserMatrix(aMatrix);
434   myNodeActor->SetStoreClippingMapping(true);
435   myNodeActor->PickableOff();
436   myNodeActor->SetVisibility(false);
437   myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );  
438   myNodeActor->SetProperty(myNodeProp);
439   myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
440   aFilter = myNodeActor->GetExtractUnstructuredGrid();
441   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
442   
443   myNodeExtProp = vtkProperty::New();
444   myNodeExtProp->DeepCopy(myNodeProp);
445   anRGB[0] = 1 - anRGB[0];
446   anRGB[1] = 1 - anRGB[1];
447   anRGB[2] = 1 - anRGB[2];
448   myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
449
450   myNodeExtActor = SMESH_DeviceActor::New();
451   myNodeExtActor->SetUserMatrix(aMatrix);
452   myNodeExtActor->SetStoreClippingMapping(true);
453   myNodeExtActor->PickableOff();
454   myNodeExtActor->SetHighlited(true);
455   myNodeExtActor->SetVisibility(false);
456   myNodeExtActor->SetProperty(myNodeExtProp);
457   myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
458   aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
459   aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
460   aFilter->RegisterCellsWithType(VTK_VERTEX);
461
462   //Definition of Pickable and Highlitable engines
463   //----------------------------------------------
464
465   myBaseActor->SetUserMatrix(aMatrix);
466   myBaseActor->SetStoreGemetryMapping(true);
467   myBaseActor->GetProperty()->SetOpacity(0.0);
468   myPickableActor = myBaseActor;
469   
470   myHighlightProp = vtkProperty::New();
471   myHighlightProp->SetAmbient(1.0);
472   myHighlightProp->SetDiffuse(0.0);
473   myHighlightProp->SetSpecular(0.0);
474   SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
475   myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
476   myHighlightProp->SetPointSize(aElem0DSize); // ??
477   myHighlightProp->SetLineWidth(aLineWidth);
478   myHighlightProp->SetRepresentation(1);
479
480   myBallHighlightProp = vtkProperty::New();
481   myBallHighlightProp->DeepCopy(myHighlightProp);
482   myBallHighlightProp->SetPointSize(aBallElemSize);
483   
484
485   myOutLineProp = vtkProperty::New();
486   myOutLineProp->SetAmbient(1.0);
487   myOutLineProp->SetDiffuse(0.0);
488   myOutLineProp->SetSpecular(0.0);
489   SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
490   myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
491   myOutLineProp->SetLineWidth(aOutlineWidth);
492   myOutLineProp->SetRepresentation(1);
493
494   myPreselectProp = vtkProperty::New();
495   myPreselectProp->SetAmbient(1.0);
496   myPreselectProp->SetDiffuse(0.0);
497   myPreselectProp->SetSpecular(0.0);
498   SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
499   myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
500   myPreselectProp->SetPointSize(aElem0DSize); // ??
501   myPreselectProp->SetLineWidth(aLineWidth);
502   myPreselectProp->SetRepresentation(1);
503
504   myBallPreselectProp = vtkProperty::New();
505   myBallPreselectProp->DeepCopy(myPreselectProp);
506   myBallPreselectProp->SetPointSize(aBallElemSize);
507
508   myHighlitableActor = SMESH_DeviceActor::New();
509   myHighlitableActor->SetUserMatrix(aMatrix);
510   myHighlitableActor->PickableOff();
511   myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
512   myHighlitableActor->SetCoincident3DAllowed(true);
513
514   aMatrix->Delete();
515
516   myName = "";
517   myIO = NULL;
518
519   myControlMode = eNone;
520   myControlActor = my2DActor;
521
522   //Definition of myScalarBarActor
523   //------------------------------
524   myLookupTable = vtkLookupTable::New();
525   //Fix for Bug PAL5195 - SMESH764: 
526   //Controls - Aspect Ratio: incorrect colors of the best and worst values
527   myLookupTable->SetHueRange(0.667,0.0);
528
529   myScalarBarActor = SMESH_ScalarBarActor::New();
530   myScalarBarActor->SetVisibility(false);
531   myScalarBarActor->SetLookupTable(myLookupTable);
532
533   //Fix for Bug 13314:
534   //Incorrect "Min value" in Scalar Bar in Mesh:
535   //  myScalarBarActor->SetLabelFormat("%.4g");
536   // changes was commented because of regression bug IPAL 19981
537
538   mgr = SUIT_Session::session()->resourceMgr();
539   if( !mgr )
540     return;
541
542   myEntityMode = eAllEntity;
543   myEntityModeCache = eAllEntity;
544   
545   // Clipping planes
546   myImplicitBoolean = vtkImplicitBoolean::New();
547   myImplicitBoolean->SetOperationTypeToIntersection();
548   
549   //Quadratic 2D elements representation
550   //-----------------------------------------------------------------------------
551   int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
552   if(aQuadratic2DMode == 0){
553     myHighlitableActor->SetQuadraticArcMode(false);
554     my2DActor->SetQuadraticArcMode(false);
555     my1DActor->SetQuadraticArcMode(false);
556   }
557   else if(aQuadratic2DMode == 1){
558     myHighlitableActor->SetQuadraticArcMode(true);
559     my2DActor->SetQuadraticArcMode(true);
560     my1DActor->SetQuadraticArcMode(true);
561   }
562   
563   int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
564   myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
565   my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
566   
567   // Set colors of the name actor
568   SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
569   myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
570   SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
571   myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
572
573 #ifndef DISABLE_PLOT2DVIEWER
574   my2dHistogram = 0;
575 #endif
576
577   SetBallSize(aBallElemSize);
578   Set0DSize(aElem0DSize);
579 }
580
581
582 SMESH_ActorDef::~SMESH_ActorDef()
583 {
584   if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
585
586   // Please keep the order same as one in the header file
587
588   myTimeStamp->Delete();
589
590   myScalarBarActor->Delete();
591   myLookupTable->Delete();
592
593   mySurfaceProp->Delete();
594   myBackSurfaceProp->Delete();
595   myNormalVProp->Delete();
596   myReversedVProp->Delete();
597   myEdgeProp->Delete();
598   myNodeProp->Delete();
599
600   myNodeActor->Delete();
601   myBaseActor->Delete();
602   //myPickableActor->Delete(); myPickableActor == myBaseActor
603
604   myHighlightProp->Delete();
605   myOutLineProp->Delete();
606   myPreselectProp->Delete();
607
608   myBallHighlightProp->Delete();
609   myBallPreselectProp->Delete();
610
611   myHighlitableActor->Delete();
612
613   my2DExtProp->Delete();
614   my3DExtProp->Delete();
615   my2DActor->Delete();
616   my2DExtActor->Delete();
617   my3DActor->Delete();
618   my3DExtActor->Delete();
619   // myControlActor->Delete(); myControlActor == my2DActor
620
621   myNodeExtProp->Delete();
622   myNodeExtActor->Delete();  
623  
624   my1DProp->Delete();
625   my1DActor->Delete();
626   my1DExtProp->Delete();
627   my1DExtActor->Delete();
628
629   my0DProp->Delete();
630   my0DActor->Delete();
631   myBallProp->Delete();
632   myBallActor->Delete();
633   //my0DExtProp->Delete();
634   //my0DExtActor->Delete();
635  
636   myImplicitBoolean->Delete();         
637
638 #ifndef DISABLE_PLOT2DVIEWER
639   if(my2dHistogram) {
640     SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
641     delete my2dHistogram;
642   }
643 #endif
644 }
645
646 void SMESH_ActorDef::Delete()
647 {
648   // This is just to guarantee that the DeleteActorEvent (which was previously invoked
649   // from the actor's destructor) will be thrown before removing the actor's observers,
650   // that is done inside the Superclass::Delete() method but before the destructor itself
651   // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
652   // The event is caught by SMESHGUI::ProcessEvents() static method.
653   this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
654
655   Superclass::Delete();
656 }
657
658 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
659 {    
660   if(myNodeActor) {
661     myNodeActor->SetPointsLabeled(theIsPointsLabeled);
662     SetRepresentation(GetRepresentation());
663     myTimeStamp->Modified();
664   }
665 }
666
667 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
668                                               bool theBold, bool theItalic, bool theShadow,
669                                               vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
670 {    
671   if(myNodeActor) {
672     myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
673     SetRepresentation( GetRepresentation() );
674     myTimeStamp->Modified();
675   }
676 }
677
678 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
679                                              bool theBold, bool theItalic, bool theShadow,
680                                              vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
681 {    
682   if(my3DActor) {
683     my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
684     SetRepresentation( GetRepresentation() );
685     myTimeStamp->Modified();
686   }
687   if(my2DActor) {
688     my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
689     SetRepresentation( GetRepresentation() );
690     myTimeStamp->Modified();
691   }
692   if(my1DActor) {
693     my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
694     SetRepresentation( GetRepresentation() );
695     myTimeStamp->Modified();
696   }
697   if(my0DActor) {
698     my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
699     SetRepresentation( GetRepresentation() );
700     myTimeStamp->Modified();
701   }
702   if(myBallActor) {
703     myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
704     SetRepresentation( GetRepresentation() );
705     myTimeStamp->Modified();
706   }
707 }
708
709 bool SMESH_ActorDef::GetPointsLabeled() {
710   return myNodeActor && myNodeActor->GetPointsLabeled();
711 }
712
713 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
714 {
715   if(my3DActor)
716     my3DActor->SetCellsLabeled(theIsCellsLabeled);
717
718   if(my2DActor)
719     my2DActor->SetCellsLabeled(theIsCellsLabeled);
720
721   if(my1DActor)
722     my1DActor->SetCellsLabeled(theIsCellsLabeled);
723
724   if(my0DActor)
725     my0DActor->SetCellsLabeled(theIsCellsLabeled);
726   
727   if(myBallActor)
728     myBallActor->SetCellsLabeled(theIsCellsLabeled);
729   
730   myTimeStamp->Modified();
731 }
732
733
734 bool SMESH_ActorDef::GetCellsLabeled() {
735   bool result = false;
736   if(my3DActor)
737     result = result || my3DActor->GetCellsLabeled();
738
739   if(my2DActor)
740     result = result || my2DActor->GetCellsLabeled();
741
742   if(my1DActor)
743     result = result || my1DActor->GetCellsLabeled();
744
745   if(my0DActor)
746     result = result || my0DActor->GetCellsLabeled();
747
748   if(myBallActor)
749     result = result || myBallActor->GetCellsLabeled();
750
751   return result;
752 }
753
754
755 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
756 {
757   myIsFacesOriented = theIsFacesOriented;
758
759   my2DActor->SetFacesOriented(theIsFacesOriented);
760   my3DActor->SetFacesOriented(theIsFacesOriented);
761
762   myTimeStamp->Modified();
763 }
764
765 bool SMESH_ActorDef::GetFacesOriented()
766 {
767   return myIsFacesOriented;
768 }
769
770 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
771 {
772   my2DActor->SetFacesOrientationColor( r, g, b );
773   my3DActor->SetFacesOrientationColor( r, g, b );
774 }
775
776 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
777 {
778   my3DActor->GetFacesOrientationColor( r, g, b );
779 }
780
781 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
782 {
783   my2DActor->SetFacesOrientationScale( theScale );
784   my3DActor->SetFacesOrientationScale( theScale );
785 }
786
787 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
788 {
789   return my3DActor->GetFacesOrientationScale();
790 }
791
792 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
793 {
794   my2DActor->SetFacesOrientation3DVectors( theState );
795   my3DActor->SetFacesOrientation3DVectors( theState );
796 }
797
798 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
799 {
800   return my3DActor->GetFacesOrientation3DVectors();
801 }
802
803
804 void 
805 SMESH_ActorDef::
806 SetControlMode(eControl theMode)
807 {
808   SetControlMode(theMode,true);
809 }
810
811
812 void 
813 SMESH_ActorDef::
814 SetControlMode(eControl theMode,
815                bool theCheckEntityMode)
816 {
817   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();  
818   if( !mgr )
819     return;
820
821   myControlMode = eNone;
822   theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
823
824   my0DActor->GetMapper()->SetScalarVisibility(false);
825   my1DActor->GetMapper()->SetScalarVisibility(false);
826   my2DActor->GetMapper()->SetScalarVisibility(false);
827   my3DActor->GetMapper()->SetScalarVisibility(false);
828   myBallActor->GetMapper()->SetScalarVisibility(false);
829   myScalarBarActor->SetVisibility(false);
830
831   bool anIsScalarVisible = theMode > eNone;
832
833   if(anIsScalarVisible) {
834     switch(theMode) {
835     case eLength:
836     {
837       SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
838       aControl->SetPrecision( myControlsPrecision );
839       myFunctor.reset( aControl );
840       myControlActor = my1DActor;
841       break;
842     }
843     case eLength2D:
844     {
845       myFunctor.reset(new SMESH::Controls::Length2D());
846       myControlActor = my2DActor;
847       break;
848     }
849     case eFreeBorders:
850       myFunctor.reset(new SMESH::Controls::FreeBorders());
851       myControlActor = my1DActor;
852       break;
853     case eFreeEdges:
854       myFunctor.reset(new SMESH::Controls::FreeEdges());
855       myControlActor = my2DActor;
856       break;
857     case eFreeNodes:
858       myFunctor.reset(new SMESH::Controls::FreeNodes());
859       myControlActor = myNodeActor;
860       break;
861     case eFreeFaces:
862       myFunctor.reset(new SMESH::Controls::FreeFaces());
863       myControlActor = my2DActor;
864       break;
865     case eCoincidentNodes:
866       {
867         SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
868         double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
869         cn->SetTolerance( tol );
870         myFunctor.reset(cn);
871         myControlActor = myNodeActor;
872         break;
873       }
874     case eCoincidentElems1D:
875       myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
876       myControlActor = my1DActor;
877       break;
878     case eCoincidentElems2D:
879       myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
880       myControlActor = my2DActor;
881       break;
882     case eCoincidentElems3D:
883       myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
884       myControlActor = my3DActor;
885       break;
886     case eBareBorderFace:
887       myFunctor.reset(new SMESH::Controls::BareBorderFace());
888       myControlActor = my2DActor;
889       break;
890     case eOverConstrainedFace:
891       myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
892       myControlActor = my2DActor;
893       break;
894     case eMultiConnection:
895       myFunctor.reset(new SMESH::Controls::MultiConnection());
896       myControlActor = my1DActor;
897       break;
898     case eMultiConnection2D:
899       myFunctor.reset(new SMESH::Controls::MultiConnection2D());
900       myControlActor = my2DActor;
901       break;
902     case eArea:
903     {
904       SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
905       aControl->SetPrecision( myControlsPrecision );
906       myFunctor.reset( aControl );
907       myControlActor = my2DActor;
908       break;
909     }
910     case eTaper:
911     {
912       SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
913       aControl->SetPrecision( myControlsPrecision );
914       myFunctor.reset( aControl );
915       myControlActor = my2DActor;
916       break;
917     }
918     case eAspectRatio:
919     {
920       SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
921       aControl->SetPrecision( myControlsPrecision );
922       myFunctor.reset( aControl );
923       myControlActor = my2DActor;
924       break;
925     }
926     case eAspectRatio3D:
927     {
928       SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
929       aControl->SetPrecision( myControlsPrecision );
930       myFunctor.reset( aControl );
931       myControlActor = my3DActor;
932       break;
933     }
934     case eVolume3D:
935     {
936       SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
937       aControl->SetPrecision( myControlsPrecision );
938       myFunctor.reset( aControl );
939       myControlActor = my3DActor;
940       break;
941     }
942     case eMaxElementLength2D:
943     {
944       SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
945       aControl->SetPrecision( myControlsPrecision );
946       myFunctor.reset( aControl );
947       myControlActor = my2DActor;
948       break;
949     }
950     case eMaxElementLength3D:
951     {
952       SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
953       aControl->SetPrecision( myControlsPrecision );
954       myFunctor.reset( aControl );
955       myControlActor = my3DActor;
956       break;
957     }
958     case eBareBorderVolume:
959     {
960       myFunctor.reset(new SMESH::Controls::BareBorderVolume());
961       myControlActor = my3DActor;
962       break;
963     }
964     case eOverConstrainedVolume:
965     {
966       myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
967       myControlActor = my3DActor;
968       break;
969     }
970     case eMinimumAngle:
971     {
972       SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
973       aControl->SetPrecision( myControlsPrecision );
974       myFunctor.reset( aControl );
975       myControlActor = my2DActor;
976       break;
977     }
978     case eWarping:
979     {
980       SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
981       aControl->SetPrecision( myControlsPrecision );
982       myFunctor.reset( aControl );
983       myControlActor = my2DActor;
984       break;
985     }
986     case eSkew:
987     {
988       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
989       aControl->SetPrecision( myControlsPrecision );
990       myFunctor.reset( aControl );
991       myControlActor = my2DActor;
992       break;
993     }
994     default:
995       return;
996     }
997
998     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
999     vtkIdType aNbCells = aGrid->GetNumberOfCells();
1000     if(aNbCells){
1001       myControlMode = theMode;
1002       switch(myControlMode){
1003       case eFreeNodes:
1004       case eCoincidentNodes:
1005         myNodeExtActor->SetExtControlMode(myFunctor);
1006         break;
1007       case eFreeEdges:
1008       case eFreeBorders:
1009       case eCoincidentElems1D:
1010         my1DExtActor->SetExtControlMode(myFunctor);
1011         break;
1012       case eFreeFaces:
1013       case eBareBorderFace:
1014       case eOverConstrainedFace:
1015       case eCoincidentElems2D:
1016         my2DExtActor->SetExtControlMode(myFunctor);
1017         break;
1018       case eBareBorderVolume:
1019       case eOverConstrainedVolume:
1020       case eCoincidentElems3D:
1021         my3DExtActor->SetExtControlMode(myFunctor);
1022         break;
1023       case eLength2D:
1024       case eMultiConnection2D:
1025         my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1026         UpdateDistribution();
1027         break;
1028       default:
1029         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1030         UpdateDistribution();
1031       }
1032     }
1033
1034     if(theCheckEntityMode) {
1035       if(myControlActor == my1DActor) {
1036         if (!myIsEntityModeCache){
1037           myEntityModeCache = GetEntityMode();
1038           myIsEntityModeCache=true;
1039         } 
1040         SetEntityMode(eEdges);
1041       }
1042       else if(myControlActor == my2DActor) {
1043         switch(myControlMode) {
1044         case eLength2D:
1045         case eFreeEdges:
1046         case eFreeFaces:
1047         case eMultiConnection2D:
1048           if (!myIsEntityModeCache){
1049             myEntityModeCache = GetEntityMode();
1050             myIsEntityModeCache=true;
1051           } 
1052           SetEntityMode(eFaces);
1053           break;
1054         default:
1055           if (!myIsEntityModeCache){
1056             myEntityModeCache = GetEntityMode();
1057             myIsEntityModeCache=true;
1058           }
1059           SetEntityMode(eFaces);
1060         }
1061       }else if(myControlActor == my3DActor) {
1062         if (!myIsEntityModeCache){
1063             myEntityModeCache = GetEntityMode();
1064             myIsEntityModeCache=true;
1065         } 
1066         SetEntityMode(eVolumes);
1067     }
1068     }
1069
1070   }
1071   else {
1072     if(theCheckEntityMode){
1073       myEntityMode = myEntityModeCache;
1074       myIsEntityModeCache = false;
1075     }
1076     myFunctor.reset();
1077   }
1078
1079   SetRepresentation(GetRepresentation());
1080
1081   myTimeStamp->Modified();
1082   Modified();
1083   Update();
1084 }
1085
1086
1087 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1088   
1089   //myHighlightActor->AddToRender(theRenderer);
1090
1091   theRenderer->AddActor(myBaseActor);  
1092   theRenderer->AddActor(myNodeExtActor);
1093   theRenderer->AddActor(my1DExtActor);
1094
1095   my3DActor   ->AddToRender(theRenderer);
1096   my3DExtActor->AddToRender(theRenderer);
1097   my2DActor   ->AddToRender(theRenderer);
1098   my2DExtActor->AddToRender(theRenderer);
1099   myNodeActor ->AddToRender(theRenderer);
1100   my1DActor   ->AddToRender(theRenderer);
1101   my0DActor   ->AddToRender(theRenderer);
1102   myBallActor ->AddToRender(theRenderer);
1103   //theRenderer->AddActor(my0DExtActor);
1104
1105   theRenderer->AddActor(myHighlitableActor);
1106   
1107   theRenderer->AddActor2D(myScalarBarActor);
1108
1109   // the superclass' method should be called at the end
1110   // (in particular, for correct work of selection)
1111   SALOME_Actor::AddToRender(theRenderer);
1112 }
1113
1114 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1115   SALOME_Actor::RemoveFromRender(theRenderer);
1116
1117   theRenderer->RemoveActor(myBaseActor);
1118
1119   theRenderer->RemoveActor(myNodeExtActor);
1120
1121   theRenderer->RemoveActor(myHighlitableActor);
1122
1123   //theRenderer->RemoveActor(my0DExtActor);
1124
1125   theRenderer->RemoveActor(my1DExtActor);
1126
1127   my2DActor->RemoveFromRender(theRenderer);
1128   my2DExtActor->RemoveFromRender(theRenderer);
1129   my3DActor->RemoveFromRender(theRenderer);
1130   my3DExtActor->RemoveFromRender(theRenderer);
1131   myNodeActor->RemoveFromRender(theRenderer);
1132   my0DActor->RemoveFromRender(theRenderer);
1133   myBallActor->RemoveFromRender(theRenderer);
1134   my1DActor->RemoveFromRender(theRenderer);
1135
1136   theRenderer->RemoveActor(myScalarBarActor);
1137 }
1138
1139
1140 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, 
1141                           const char* theEntry, 
1142                           const char* theName,
1143                           int theIsClear)
1144 {
1145   Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1146   setIO(anIO);
1147   setName(theName);
1148
1149   myVisualObj = theVisualObj;
1150   myVisualObj->Update(theIsClear);
1151
1152   myNodeActor->Init(myVisualObj,myImplicitBoolean);
1153   myBaseActor->Init(myVisualObj,myImplicitBoolean);
1154
1155   myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1156
1157   myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1158   
1159   my0DActor->Init(myVisualObj,myImplicitBoolean);
1160   myBallActor->Init(myVisualObj,myImplicitBoolean);
1161   //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1162   
1163   my1DActor->Init(myVisualObj,myImplicitBoolean);
1164   my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1165   
1166   my2DActor->Init(myVisualObj,myImplicitBoolean);
1167   my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1168   my3DActor->Init(myVisualObj,myImplicitBoolean);
1169   my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1170   
1171   my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1172   myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1173   //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1174   
1175   my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1176   my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1177
1178   my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1179   my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1180   my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1181   my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1182     
1183   vtkFloatingPointType aFactor, aUnits;
1184   my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1185   my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1186   my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1187   my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1188
1189   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1190   if( !mgr )
1191     return false;
1192
1193   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1194   SetIsShrunkable(true);
1195
1196   SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1197
1198   int aMode = mgr->integerValue( "SMESH", "display_mode" );
1199   SetRepresentation(-1);
1200   
1201   if(aMode == 0){
1202     SetRepresentation(eEdge);
1203   }else if(aMode == 1){
1204     SetRepresentation(eSurface);
1205   }else if(aMode == 2){
1206     SetRepresentation(ePoint);
1207   }
1208   
1209   if(aMode == 3){
1210     SetShrink();
1211   }
1212
1213   if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1214     SetIsDisplayNameActor( true );
1215
1216   int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1217   int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 );  // 5 pixels
1218   SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1219
1220   myTimeStamp->Modified();
1221   Modified();
1222   return true;
1223 }
1224
1225
1226 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1227   return myNodeActor->GetBounds();
1228 }
1229
1230
1231 vtkDataSet* SMESH_ActorDef::GetInput(){
1232   return GetUnstructuredGrid();
1233 }
1234
1235
1236 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1237   Superclass::SetTransform(theTransform);
1238
1239   myNodeActor->SetTransform(theTransform);
1240   myBaseActor->SetTransform(theTransform);
1241   
1242   myHighlitableActor->SetTransform(theTransform);
1243
1244   myNodeExtActor->SetTransform(theTransform);
1245
1246   my0DActor->SetTransform(theTransform);
1247   myBallActor->SetTransform(theTransform);
1248   //my0DExtActor->SetTransform(theTransform);
1249
1250   my1DActor->SetTransform(theTransform);
1251   my1DExtActor->SetTransform(theTransform);
1252
1253   my2DActor->SetTransform(theTransform);
1254   my2DExtActor->SetTransform(theTransform);
1255   my3DActor->SetTransform(theTransform);
1256   my3DExtActor->SetTransform(theTransform);
1257
1258   Modified();
1259 }
1260
1261
1262 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1263   vtkLODActor::SetMapper(theMapper);
1264 }
1265
1266
1267 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1268   SALOME_Actor::ShallowCopy(prop);
1269 }
1270
1271
1272 vtkMapper* SMESH_ActorDef::GetMapper(){
1273   return myPickableActor->GetMapper();
1274 }
1275
1276
1277 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){ 
1278   return myVisualObj->GetUnstructuredGrid();
1279 }
1280
1281
1282 bool SMESH_ActorDef::IsInfinitive(){
1283   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1284   aDataSet->Update();
1285   myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1286     ( aDataSet->GetNumberOfCells() == 1 && 
1287     aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1288   return SALOME_Actor::IsInfinitive();
1289 }
1290
1291
1292 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1293   if ( myIsShrinkable == theShrunkable )
1294     return;
1295   myIsShrinkable = theShrunkable;
1296   Modified();
1297 }
1298
1299 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1300   return myBaseActor->GetShrinkFactor();
1301 }
1302
1303 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1304   myBaseActor->SetShrinkFactor(theValue);
1305
1306   my1DActor->SetShrinkFactor(theValue);
1307   my1DExtActor->SetShrinkFactor(theValue);
1308
1309   my2DActor->SetShrinkFactor(theValue);
1310   my2DExtActor->SetShrinkFactor(theValue);
1311   my3DActor->SetShrinkFactor(theValue);
1312   my3DExtActor->SetShrinkFactor(theValue);
1313   my3DExtActor->SetShrinkFactor(theValue);
1314   myHighlitableActor->SetShrinkFactor(theValue);
1315
1316   Modified();
1317 }
1318
1319 void SMESH_ActorDef::SetShrink(){
1320   if(!myIsShrinkable) return;
1321
1322   myBaseActor->SetShrink();
1323
1324   my1DActor->SetShrink();
1325   my1DExtActor->SetShrink();
1326
1327   my2DActor->SetShrink();
1328   my2DExtActor->SetShrink();
1329   my3DActor->SetShrink();
1330   my3DExtActor->SetShrink();
1331   myHighlitableActor->SetShrink();
1332
1333   myIsShrunk = true;
1334   Modified();
1335 }
1336
1337 void SMESH_ActorDef::UnShrink(){
1338   if(!myIsShrunk) return;
1339
1340   myBaseActor->UnShrink();
1341
1342   my1DActor->UnShrink();
1343   my1DExtActor->UnShrink();
1344
1345   my2DActor->UnShrink();
1346   my2DExtActor->UnShrink();
1347   my3DActor->UnShrink();
1348   my3DExtActor->UnShrink();
1349   myHighlitableActor->UnShrink();
1350
1351   myIsShrunk = false;
1352   Modified();
1353 }
1354
1355
1356 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1357   return myPickableActor->GetNodeObjId(theVtkID);
1358 }
1359
1360 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1361   return myPickableActor->GetNodeCoord(theObjID);
1362 }
1363
1364
1365 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1366   return myPickableActor->GetElemObjId(theVtkID);
1367 }
1368
1369 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1370   return myPickableActor->GetElemCell(theObjID);
1371 }
1372
1373
1374 void SMESH_ActorDef::SetVisibility(int theMode){
1375   SetVisibility(theMode,true);
1376 }
1377
1378
1379 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1380   SALOME_Actor::SetVisibility(theMode);
1381
1382   myNodeActor->VisibilityOff();
1383   myBaseActor->VisibilityOff();
1384   
1385   myNodeExtActor->VisibilityOff();
1386
1387   my0DActor->VisibilityOff();
1388   myBallActor->VisibilityOff();
1389   //my0DExtActor->VisibilityOff();
1390
1391   my1DActor->VisibilityOff();
1392   my1DExtActor->VisibilityOff();
1393   
1394   my2DActor->VisibilityOff();
1395   my2DExtActor->VisibilityOff();
1396   my3DActor->VisibilityOff();
1397   my3DExtActor->VisibilityOff();
1398   
1399   myScalarBarActor->VisibilityOff();
1400   
1401   if(GetVisibility()){
1402     if(theIsUpdateRepersentation)
1403       SetRepresentation(GetRepresentation());
1404     
1405     if(myControlMode != eNone){
1406       switch(myControlMode){
1407       case eFreeNodes:
1408       case eCoincidentNodes:
1409         myNodeExtActor->VisibilityOn();
1410         break;
1411       case eFreeEdges:
1412       case eFreeBorders:
1413       case eCoincidentElems1D:
1414         my1DExtActor->VisibilityOn();
1415         break;
1416       case eFreeFaces:
1417       case eBareBorderFace:
1418       case eOverConstrainedFace:
1419       case eCoincidentElems2D:
1420         my2DExtActor->VisibilityOn();
1421         break;
1422       case eBareBorderVolume:
1423       case eOverConstrainedVolume:
1424       case eCoincidentElems3D:
1425         my3DExtActor->VisibilityOn();
1426         break;
1427       case eLength2D:
1428       case eMultiConnection2D:
1429         my1DExtActor->VisibilityOn();
1430       default:
1431         if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1432           myScalarBarActor->VisibilityOn();
1433       }
1434     }
1435
1436     if(myRepresentation != ePoint)
1437       myPickableActor->VisibilityOn();
1438     else {
1439       myNodeActor->VisibilityOn();
1440     }
1441
1442     if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1443       my0DActor->VisibilityOn();
1444     }
1445     if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1446       myBallActor->VisibilityOn();
1447     }
1448
1449     if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1450       my1DActor->VisibilityOn();
1451     }
1452     
1453     if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1454       my2DActor->VisibilityOn();
1455     }
1456     
1457     if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1458       my3DActor->VisibilityOn();
1459     }
1460     
1461     if(myNodeActor->GetPointsLabeled()){ 
1462       myNodeActor->VisibilityOn();
1463     }
1464
1465     if(my0DActor)
1466       my0DActor->UpdateLabels();
1467     
1468     if(myBallActor)
1469       myBallActor->UpdateLabels();
1470     
1471     if(my1DActor)
1472       my1DActor->UpdateLabels();
1473     
1474     if(my2DActor)
1475       my2DActor->UpdateLabels();
1476     
1477     if(my3DActor)
1478       my3DActor->UpdateLabels();    
1479   } 
1480 #ifndef DISABLE_PLOT2DVIEWER
1481   else
1482     SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1483 #endif
1484   UpdateHighlight();
1485   Modified();
1486 }
1487
1488
1489 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1490 {
1491   myEntityState = eAllEntity;
1492
1493   if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1494     myEntityState &= ~e0DElements;
1495     theMode &= ~e0DElements;
1496   }
1497
1498   if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1499     myEntityState &= ~eBallElem;
1500     theMode &= ~eBallElem;
1501   }
1502
1503   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1504     myEntityState &= ~eEdges;
1505     theMode &= ~eEdges;
1506   }
1507
1508   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1509     myEntityState &= ~eFaces;
1510     theMode &= ~eFaces;
1511   }
1512
1513   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1514     myEntityState &= ~eVolumes;
1515     theMode &= ~eVolumes;
1516   }
1517
1518   if (!theMode) {
1519     if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1520       theMode |= e0DElements;
1521
1522     if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1523       theMode |= eBallElem;
1524
1525     if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1526       theMode |= eEdges;
1527
1528     if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1529       theMode |= eFaces;
1530
1531     if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1532       theMode |= eVolumes;
1533   }
1534
1535   myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1536
1537   myEntityMode = theMode;
1538   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1539   aFilter = myBaseActor->GetExtractUnstructuredGrid();
1540   aFilter->ClearRegisteredCellsWithType();
1541   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1542
1543   VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1544   aHightFilter->ClearRegisteredCellsWithType();
1545   aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1546
1547   if (myEntityMode & e0DElements) {
1548     if (MYDEBUG) MESSAGE("0D ELEMENTS");
1549     aFilter->RegisterCellsWithType(VTK_VERTEX);
1550     aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1551   }
1552
1553   if (myEntityMode & eBallElem) {
1554     aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1555     aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1556   }
1557
1558   if (myEntityMode & eEdges) {
1559     if (MYDEBUG) MESSAGE("EDGES");
1560     aFilter->RegisterCellsWithType(VTK_LINE);
1561     aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1562
1563     aHightFilter->RegisterCellsWithType(VTK_LINE);
1564     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1565   }
1566
1567   if (myEntityMode & eFaces) {
1568     if (MYDEBUG) MESSAGE("FACES");
1569     aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1570     aFilter->RegisterCellsWithType(VTK_POLYGON);
1571     aFilter->RegisterCellsWithType(VTK_QUAD);
1572     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1573     aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1574     aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1575
1576     aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1577     aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1578     aHightFilter->RegisterCellsWithType(VTK_QUAD);
1579     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1580     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1581     aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1582   }
1583
1584   if (myEntityMode & eVolumes) {
1585     if (MYDEBUG) MESSAGE("VOLUMES");
1586     aFilter->RegisterCellsWithType(VTK_TETRA);
1587     aFilter->RegisterCellsWithType(VTK_VOXEL);
1588     aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1589     aFilter->RegisterCellsWithType(VTK_WEDGE);
1590     aFilter->RegisterCellsWithType(VTK_PYRAMID);
1591     aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1592     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1593     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1594     aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1595     aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1596     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1597 //#ifdef VTK_HAVE_POLYHEDRON
1598     aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1599 //#endif
1600     
1601     aHightFilter->RegisterCellsWithType(VTK_TETRA);
1602     aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1603     aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1604     aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1605     aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1606     aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1607     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1608     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1609     aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1610     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1611     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1612     aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1613 //#ifdef VTK_HAVE_POLYHEDRON
1614     aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1615 //#endif
1616   }
1617   aFilter->Update();
1618   if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1619   SetVisibility(GetVisibility(),false);
1620 }
1621
1622 void SMESH_ActorDef::SetRepresentation (int theMode)
1623
1624   int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1625   int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1626   int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1627   int aNb0Ds       = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1628   int aNbBalls       = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1629
1630   if (theMode < 0) {
1631     myRepresentation = eSurface;
1632     if (!aNbFaces && !aNbVolumes && aNbEdges) {
1633       myRepresentation = eEdge;
1634     } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1635       myRepresentation = ePoint;
1636     }
1637   } else {
1638     switch (theMode) {
1639     case eEdge:
1640       if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1641       break;
1642     case eSurface:
1643       if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1644       break;
1645     }    
1646     myRepresentation = theMode;
1647   }
1648
1649   if (!GetUnstructuredGrid()->GetNumberOfCells())
1650     myRepresentation = ePoint;
1651
1652   if (myIsShrunk) {
1653     if (myRepresentation == ePoint) {
1654       UnShrink();
1655       myIsShrunk = true;
1656     } else {
1657       SetShrink();
1658     }      
1659   }
1660
1661   myPickableActor = myBaseActor;
1662   myNodeActor->SetVisibility(false);
1663   myNodeExtActor->SetVisibility(false);
1664   vtkProperty *aProp = NULL, *aBackProp = NULL;
1665   vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1666   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1667   SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1668   switch (myRepresentation) {
1669   case ePoint:
1670     myPickableActor = myNodeActor;
1671     myNodeActor->SetVisibility(true);
1672     aQuadraticMode = SMESH_Actor::eLines;
1673     aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1674     aReperesent = SMESH_DeviceActor::ePoint;
1675     break;
1676   case eEdge:
1677     aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1678     aReperesent = SMESH_DeviceActor::eInsideframe;
1679     break;
1680   case eSurface:
1681     aProp = mySurfaceProp;
1682     aBackProp = myBackSurfaceProp;
1683     aPropVN = myNormalVProp;
1684     aPropVR = myReversedVProp;
1685     aReperesent = SMESH_DeviceActor::eSurface;
1686     break;
1687   }
1688
1689   my2DActor->SetProperty(aProp);
1690   my2DActor->SetBackfaceProperty(aBackProp);
1691   my2DActor->SetRepresentation(aReperesent);
1692
1693   if(aQuadraticMode == SMESH_Actor::eLines)
1694     my2DActor->SetQuadraticArcMode(false);
1695   else if(aQuadraticMode == SMESH_Actor::eArcs)
1696     my2DActor->SetQuadraticArcMode(true);
1697
1698   my2DExtActor->SetRepresentation(aReperesent);
1699   
1700   my3DActor->SetProperty(aPropVN);
1701   my3DActor->SetBackfaceProperty(aPropVR);
1702   my3DActor->SetRepresentation(aReperesent);
1703
1704   //my0DExtActor->SetVisibility(false);
1705   my1DExtActor->SetVisibility(false);
1706   my2DExtActor->SetVisibility(false);
1707   my3DExtActor->SetVisibility(false);
1708
1709   // ???
1710   //my0DActor->SetProperty(aProp);
1711   //my0DActor->SetBackfaceProperty(aBackProp);
1712   my0DActor->SetRepresentation(aReperesent);
1713   myBallActor->SetRepresentation(aReperesent);
1714   //my0DExtActor->SetRepresentation(aReperesent);
1715
1716   switch(myControlMode){
1717   case eLength:
1718   case eMultiConnection:
1719     aProp = aBackProp = my1DProp;
1720     if(myRepresentation != ePoint)
1721       aReperesent = SMESH_DeviceActor::eInsideframe;
1722     break;
1723   }
1724   
1725   if(aQuadraticMode == SMESH_Actor::eLines)
1726     my1DActor->SetQuadraticArcMode(false);
1727   else if(aQuadraticMode == SMESH_Actor::eArcs)
1728     my1DActor->SetQuadraticArcMode(true);
1729
1730   my1DActor->SetProperty(aProp);
1731   my1DActor->SetBackfaceProperty(aBackProp);
1732   my1DActor->SetRepresentation(aReperesent);
1733
1734   my1DExtActor->SetRepresentation(aReperesent);
1735
1736   if(myIsPointsVisible)
1737     myPickableActor = myNodeActor;
1738   if(GetPointRepresentation())
1739     myNodeActor->SetVisibility(true);
1740
1741   SetMapper(myPickableActor->GetMapper());
1742
1743   SetVisibility(GetVisibility(),false);
1744
1745   Modified();
1746 }
1747
1748
1749 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1750   if ( myIsPointsVisible == theIsPointsVisible )
1751     return;
1752   myIsPointsVisible = theIsPointsVisible;
1753   SetRepresentation(GetRepresentation());
1754 }
1755
1756 bool SMESH_ActorDef::GetPointRepresentation(){ 
1757   return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1758 }
1759
1760
1761 void SMESH_ActorDef::UpdateHighlight(){
1762   myHighlitableActor->SetHighlited(false);
1763   myHighlitableActor->SetVisibility(false);
1764
1765   bool anIsVisible = GetVisibility();
1766
1767   switch(myRepresentation){
1768   case SMESH_DeviceActor::eSurface:
1769   case SMESH_DeviceActor::eWireframe:
1770     {
1771       if(myIsHighlighted) {
1772         myHighlitableActor->SetProperty(myHighlightProp);
1773         myBallActor->SetProperty(myBallHighlightProp);
1774       }else if(myIsPreselected){
1775         myHighlitableActor->SetProperty(myPreselectProp);
1776         myBallActor->SetProperty(myBallPreselectProp);
1777       } else if(anIsVisible){
1778         myBallActor->SetProperty(myBallProp);
1779         (myRepresentation == eSurface) ? 
1780           myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1781       }
1782       if(GetUnstructuredGrid()->GetNumberOfCells()) {
1783         myHighlitableActor->SetHighlited(anIsVisible);
1784         myHighlitableActor->GetExtractUnstructuredGrid()->
1785           SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1786         myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1787       }
1788       myHighlitableActor->SetVisibility(anIsVisible);
1789       break;
1790     }
1791   case SMESH_DeviceActor::ePoint:
1792     {
1793       if(myIsHighlighted) {
1794         myNodeActor->SetProperty(myHighlightProp);
1795       }else if(myIsPreselected) {
1796         myNodeActor->SetProperty(myPreselectProp);
1797       } else if(anIsVisible) {
1798         myNodeActor->SetProperty(myNodeProp);
1799       }
1800       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1801       myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1802       break;
1803     }
1804   }
1805 }
1806
1807
1808 void SMESH_ActorDef::highlight(bool theHighlight){
1809   if ( myIsHighlighted == theHighlight )
1810     return;
1811   myIsHighlighted = theHighlight;
1812   UpdateHighlight();
1813 }
1814
1815
1816 void SMESH_ActorDef::SetPreSelected(bool thePreselect){ 
1817   if ( myIsPreselected == thePreselect )
1818     return;
1819   myIsPreselected = thePreselect; 
1820   UpdateHighlight();
1821 }
1822
1823
1824 // From vtkFollower
1825 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1826 {
1827   if (myPickableActor->GetIsOpaque())
1828     {
1829     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1830     this->Render(ren);
1831     return 1;
1832     }
1833   return 0;
1834 }
1835
1836
1837 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1838 {
1839   if (!myPickableActor->GetIsOpaque())
1840     {
1841     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1842     this->Render(ren);
1843     return 1;
1844     }
1845   return 0;
1846 }
1847
1848
1849 void SMESH_ActorDef::Render(vtkRenderer *ren){
1850   unsigned long aTime = myTimeStamp->GetMTime();
1851   unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1852   unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1853   if(anObjTime > aTime || aClippingTime > aTime)
1854     Update();
1855 }
1856
1857
1858 void SMESH_ActorDef::Update(){
1859   if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1860
1861   if(GetControlMode() != eNone) {
1862     unsigned long aTime = myTimeStamp->GetMTime();
1863     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1864     if (anObjTime > aTime)
1865       SetControlMode(GetControlMode(),false);
1866   }
1867
1868   if(myNodeActor)
1869     myNodeActor->UpdateLabels();
1870
1871   if(my0DActor)
1872     my0DActor->UpdateLabels();
1873   
1874   if(myBallActor)
1875     myBallActor->UpdateLabels();
1876   
1877   if(my1DActor)
1878     my1DActor->UpdateLabels();
1879   
1880   if(my2DActor)
1881     my2DActor->UpdateLabels();
1882
1883   if(my3DActor)
1884     my3DActor->UpdateLabels();
1885   
1886   if(myIsFacesOriented){
1887     SetFacesOriented(myIsFacesOriented);
1888   }
1889     
1890   if(myVisualObj->GetEntitiesFlag()) {
1891     myEntityMode |= myVisualObj->GetEntitiesState();
1892   }
1893   
1894   SetEntityMode(GetEntityMode());
1895   SetVisibility(GetVisibility());
1896   
1897   myTimeStamp->Modified();
1898   Modified();
1899 }
1900
1901
1902 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1903   SALOME_Actor::ReleaseGraphicsResources(renWin);
1904
1905   myPickableActor->ReleaseGraphicsResources(renWin);
1906 }
1907
1908
1909 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1910   vtkFloatingPointType* aColor = theProperty->GetColor();
1911   r = aColor[0];
1912   g = aColor[1];
1913   b = aColor[2];
1914 }
1915
1916
1917 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1918   mySurfaceProp->SetOpacity(theValue);
1919   myBackSurfaceProp->SetOpacity(theValue);
1920   myNormalVProp->SetOpacity(theValue);
1921   myReversedVProp->SetOpacity(theValue);
1922   myEdgeProp->SetOpacity(theValue);
1923   myOutLineProp->SetOpacity(theValue);
1924   myNodeProp->SetOpacity(theValue);
1925
1926   my1DProp->SetOpacity(theValue);
1927   my0DProp->SetOpacity(theValue);
1928   myBallProp->SetOpacity(theValue);
1929 }
1930
1931
1932 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1933   return mySurfaceProp->GetOpacity();
1934 }
1935
1936
1937 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1938   mySurfaceProp->SetColor(r,g,b);
1939   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1940   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1941     if( aGroupObj->GetElementType() == SMDSAbs_Face )
1942       myNameActor->SetBackgroundColor(r,g,b);
1943   
1944   myDeltaBrightness = delta;
1945   QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1946   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1947   Modified();
1948 }
1949
1950 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1951   ::GetColor(mySurfaceProp,r,g,b);
1952   delta = myDeltaBrightness;
1953 }
1954
1955 void SMESH_ActorDef::SetVolumeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1956   myNormalVProp->SetColor(r,g,b);
1957   my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1958   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1959     if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1960       myNameActor->SetBackgroundColor(r,g,b);
1961   
1962   myDeltaVBrightness = delta;
1963   QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1964   myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1965   Modified();
1966 }
1967
1968 void SMESH_ActorDef::GetVolumeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1969   ::GetColor(myNormalVProp,r,g,b);
1970   delta = myDeltaVBrightness;
1971 }
1972
1973 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1974   myEdgeProp->SetColor(r,g,b);
1975   my1DProp->SetColor(r,g,b);
1976   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1977   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1978     if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1979       myNameActor->SetBackgroundColor(r,g,b);
1980   Modified();
1981 }
1982
1983 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1984   ::GetColor(myEdgeProp,r,g,b);
1985 }
1986
1987 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1988   myOutLineProp->SetColor(r,g,b);
1989   Modified();
1990 }
1991
1992 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1993   ::GetColor(myOutLineProp,r,g,b);
1994 }
1995
1996
1997 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1998   myNodeProp->SetColor(r,g,b);
1999   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2000   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2001     if( aGroupObj->GetElementType() == SMDSAbs_Node )
2002       myNameActor->SetBackgroundColor(r,g,b);
2003   Modified();
2004 }
2005
2006 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
2007   ::GetColor(myNodeProp,r,g,b);
2008 }
2009
2010 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
2011   my0DProp->SetColor(r,g,b);
2012   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2013     if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2014       myNameActor->SetBackgroundColor(r,g,b);
2015   Modified();
2016 }
2017
2018 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
2019   ::GetColor(my0DProp,r,g,b);
2020 }
2021
2022 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
2023   myBallProp->SetColor(r,g,b);
2024   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2025     if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2026       myNameActor->SetBackgroundColor(r,g,b);
2027   Modified();
2028 }
2029
2030 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
2031   ::GetColor(myBallProp,r,g,b);
2032 }
2033
2034 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
2035   myHighlightProp->SetColor(r,g,b);
2036   myBallHighlightProp->SetColor(r,g,b);
2037   Modified();
2038 }
2039
2040 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
2041   ::GetColor(myHighlightProp,r,g,b);
2042 }
2043
2044 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
2045   myPreselectProp->SetColor(r,g,b);
2046   myBallPreselectProp->SetColor(r,g,b);
2047   Modified();
2048 }
2049
2050 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
2051   ::GetColor(myPreselectProp,r,g,b);
2052 }
2053
2054
2055 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
2056   return myEdgeProp->GetLineWidth();
2057 }
2058
2059
2060 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
2061   myEdgeProp->SetLineWidth(theVal);
2062
2063   my1DProp->SetLineWidth(theVal + aLineWidthInc);
2064   my1DExtProp->SetLineWidth(theVal + aLineWidthInc);    
2065   my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2066   my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2067   myOutLineProp->SetLineWidth(theVal);
2068   myHighlightProp->SetLineWidth(theVal);
2069   myPreselectProp->SetLineWidth(theVal);
2070   Modified();
2071 }
2072
2073 vtkFloatingPointType SMESH_ActorDef::GetOutlineWidth()
2074 {
2075   return myOutLineProp->GetLineWidth();
2076 }
2077
2078 void SMESH_ActorDef::SetOutlineWidth(vtkFloatingPointType theVal)
2079 {
2080   myOutLineProp->SetLineWidth(theVal);
2081   Modified();
2082 }
2083
2084 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
2085   my0DProp->SetPointSize(theVal);
2086   myHighlightProp->SetPointSize(theVal);
2087   myPreselectProp->SetPointSize(theVal);
2088
2089   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2090     aCustom->Set0DSize(theVal);
2091   }
2092   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2093     aCustom->Set0DSize(theVal);
2094   }
2095
2096   Modified();
2097 }
2098
2099 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
2100   return my0DProp->GetPointSize();
2101 }
2102
2103 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
2104   myBallProp->SetPointSize(theVal);
2105   myBallHighlightProp->SetPointSize(theVal);
2106   myBallPreselectProp->SetPointSize(theVal);
2107   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2108     aCustom->SetBallSize(theVal);
2109   }
2110   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2111     aCustom->SetBallSize(theVal);
2112   }
2113
2114   Modified();
2115 }
2116
2117 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
2118   return myBallProp->GetPointSize();
2119 }
2120
2121 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2122 {
2123   return myVisualObj->GetElemDimension( theObjId );
2124 }
2125
2126 bool
2127 SMESH_ActorDef::
2128 IsImplicitFunctionUsed() const
2129 {
2130   return myBaseActor->IsImplicitFunctionUsed();
2131 }
2132
2133 void
2134 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2135 {
2136   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2137   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2138
2139   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2140
2141   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2142
2143   my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2144   myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2145   //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2146
2147   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2148   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2149
2150   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2151   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2152   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2153   my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2154 }
2155
2156 vtkIdType 
2157 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2158 {
2159   if(thePlane){
2160     myImplicitBoolean->GetFunction()->AddItem(thePlane);
2161     myCippingPlaneCont.push_back(thePlane);
2162     if(!IsImplicitFunctionUsed())
2163       SetImplicitFunctionUsed(true);
2164     myNodeActor->UpdateLabels();
2165   }
2166   return myCippingPlaneCont.size();
2167 }
2168
2169 void
2170 SMESH_ActorDef::
2171 RemoveAllClippingPlanes()
2172 {
2173   myImplicitBoolean->GetFunction()->RemoveAllItems();
2174   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2175   myCippingPlaneCont.clear();
2176   SetImplicitFunctionUsed(false);
2177   myNodeActor->UpdateLabels();
2178 }
2179
2180 vtkIdType
2181 SMESH_ActorDef::
2182 GetNumberOfClippingPlanes()
2183 {
2184   return myCippingPlaneCont.size();
2185 }
2186
2187 vtkPlane* 
2188 SMESH_ActorDef::
2189 GetClippingPlane(vtkIdType theID)
2190 {
2191   if(theID >= myCippingPlaneCont.size())
2192     return NULL;
2193   return myCippingPlaneCont[theID].Get();
2194 }
2195
2196 void SMESH_ActorDef::UpdateScalarBar()
2197 {
2198   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2199   if( !mgr )
2200     return;
2201
2202   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2203
2204   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2205   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2206
2207   aScalarBarTitleProp->SetFontFamilyToArial();
2208
2209   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2210   {
2211     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2212     if ( f.family() == "Arial" )
2213       aScalarBarTitleProp->SetFontFamilyToArial();
2214     else if ( f.family() == "Courier" )
2215       aScalarBarTitleProp->SetFontFamilyToCourier();
2216     else if ( f.family() == "Times" )
2217       aScalarBarTitleProp->SetFontFamilyToTimes();
2218
2219     if ( f.bold() )
2220       aScalarBarTitleProp->BoldOn();
2221     else
2222       aScalarBarTitleProp->BoldOff();
2223
2224     if ( f.italic() )
2225       aScalarBarTitleProp->ItalicOn();
2226     else
2227      aScalarBarTitleProp->ItalicOff();
2228
2229     if ( f.overline() )
2230       aScalarBarTitleProp->ShadowOn();
2231     else
2232       aScalarBarTitleProp->ShadowOff();
2233   }
2234
2235   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2236   aScalarBarTitleProp->Delete();
2237
2238   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2239
2240   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2241   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2242
2243   aScalarBarLabelProp->SetFontFamilyToArial();
2244   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2245   {
2246     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2247     if( f.family() == "Arial" )
2248       aScalarBarLabelProp->SetFontFamilyToArial();
2249     else if( f.family() == "Courier" )
2250       aScalarBarLabelProp->SetFontFamilyToCourier();
2251     else if( f.family() == "Times" )
2252       aScalarBarLabelProp->SetFontFamilyToTimes();
2253
2254     if ( f.bold() )
2255       aScalarBarLabelProp->BoldOn();
2256     else
2257       aScalarBarLabelProp->BoldOff();
2258
2259     if ( f.italic() )
2260       aScalarBarLabelProp->ItalicOn();
2261     else
2262       aScalarBarLabelProp->ItalicOff();
2263
2264     if( f.overline() )
2265       aScalarBarLabelProp->ShadowOn();
2266     else
2267       aScalarBarLabelProp->ShadowOff();
2268   }
2269
2270   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2271   aScalarBarLabelProp->Delete();
2272
2273   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2274   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2275   if( horiz )
2276     myScalarBarActor->SetOrientationToHorizontal();
2277   else
2278     myScalarBarActor->SetOrientationToVertical();
2279
2280
2281   vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2282   if( mgr->hasValue( "SMESH", name + "x" ) )
2283     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2284
2285   vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2286   if( mgr->hasValue( "SMESH", name + "y" ) )
2287     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2288   myScalarBarActor->SetPosition( aXVal, aYVal );
2289
2290   vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2291   if( mgr->hasValue( "SMESH", name + "width" ) )
2292     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2293   myScalarBarActor->SetWidth( aWVal );
2294
2295   vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2296   if( mgr->hasValue( "SMESH", name + "height" ) )
2297     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2298   myScalarBarActor->SetHeight( aHVal );
2299
2300   int anIntVal = 5;
2301   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2302     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2303   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2304
2305   anIntVal = 64;
2306   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2307     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2308   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2309
2310   bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2311   myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2312
2313   int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2314   myScalarBarActor->SetDistributionColoringType(coloringType);
2315   
2316   QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2317                                              QColor(255, 255, 255));
2318   double rgb[3];
2319   rgb[0]= distributionColor.red()/255.;
2320   rgb[1]= distributionColor.green()/255.;
2321   rgb[2]= distributionColor.blue()/255.;
2322   myScalarBarActor->SetDistributionColor(rgb);
2323
2324   
2325 }
2326
2327 void SMESH_ActorDef::UpdateDistribution()
2328 {
2329   if(SMESH::Controls::NumericalFunctor* fun =
2330      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2331   {
2332     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2333     std::vector<int> nbEvents;
2334     std::vector<double> funValues;
2335     SMESH_VisualObjDef::TEntityList elems;
2336     if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2337       dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2338     std::vector<int> elemIds;
2339     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2340       elemIds.push_back( (*e)->GetID());
2341     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2342     double * range = lookupTable->GetRange();
2343     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2344     myScalarBarActor->SetDistribution(nbEvents);
2345   }
2346 }
2347
2348 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2349 {
2350   switch(theMode) {
2351   case SMESH_Actor::eLines :
2352     myHighlitableActor->SetQuadraticArcMode(false);
2353     my2DActor->SetQuadraticArcMode(false);
2354     my1DActor->SetQuadraticArcMode(false);
2355     break;
2356   case SMESH_Actor::eArcs :
2357     myHighlitableActor->SetQuadraticArcMode(true);
2358     if(GetRepresentation() != SMESH_Actor::ePoint) {
2359       my2DActor->SetQuadraticArcMode(true);
2360       my1DActor->SetQuadraticArcMode(true);
2361     }
2362     break;
2363   default:
2364     break;
2365   }
2366 }
2367
2368
2369 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2370 {
2371   if(myHighlitableActor->GetQuadraticArcMode())
2372     return SMESH_Actor::eArcs;
2373   else
2374     return SMESH_Actor::eLines;
2375 }
2376
2377 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2378 {
2379   SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2380   myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2381   myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2382 }
2383
2384 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2385 {
2386   SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2387   myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2388   myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2389   myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2390 }
2391
2392 #ifndef DISABLE_PLOT2DVIEWER
2393 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2394
2395   if(my2dHistogram)
2396     my2dHistogram->clearAllPoints();
2397   
2398   if(SMESH::Controls::NumericalFunctor* fun =
2399      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2400   {
2401     
2402     if(!my2dHistogram) {
2403       my2dHistogram = new SPlot2d_Histogram();
2404       Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2405       my2dHistogram->setIO(anIO);
2406     }
2407     
2408     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2409     std::vector<int> nbEvents;
2410     std::vector<double> funValues;
2411     SMESH_VisualObjDef::TEntityList elems;
2412     if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2413       dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2414     std::vector<int> elemIds;
2415     
2416     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2417       elemIds.push_back( (*e)->GetID());
2418
2419     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2420     double * range = lookupTable->GetRange();
2421     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2422
2423     for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) 
2424       my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2425
2426     if(funValues.size() >= 2)
2427       my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2428
2429   }
2430   
2431   //Color of the histogram
2432   if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2433     my2dHistogram->setAutoAssign(true);
2434   else {
2435     double rgb[3];
2436     myScalarBarActor->GetDistributionColor(rgb);
2437     QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2438     my2dHistogram->setColor(aColor);
2439
2440   }
2441       
2442   return my2dHistogram;
2443 }
2444 #endif