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