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