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