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