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