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