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