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