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