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