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