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