Salome HOME
Merge from PHASE_25_BR 09/12/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 "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 eOverConstrainedFace:
783       myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
784       myControlActor = my2DActor;
785       break;
786     case eMultiConnection:
787       myFunctor.reset(new SMESH::Controls::MultiConnection());
788       myControlActor = my1DActor;
789       break;
790     case eMultiConnection2D:
791       myFunctor.reset(new SMESH::Controls::MultiConnection2D());
792       myControlActor = my2DActor;
793       break;
794     case eArea:
795     {
796       SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
797       aControl->SetPrecision( myControlsPrecision );
798       myFunctor.reset( aControl );
799       myControlActor = my2DActor;
800       break;
801     }
802     case eTaper:
803     {
804       SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
805       aControl->SetPrecision( myControlsPrecision );
806       myFunctor.reset( aControl );
807       myControlActor = my2DActor;
808       break;
809     }
810     case eAspectRatio:
811     {
812       SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
813       aControl->SetPrecision( myControlsPrecision );
814       myFunctor.reset( aControl );
815       myControlActor = my2DActor;
816       break;
817     }
818     case eAspectRatio3D:
819     {
820       SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
821       aControl->SetPrecision( myControlsPrecision );
822       myFunctor.reset( aControl );
823       myControlActor = my3DActor;
824       break;
825     }
826     case eVolume3D:
827     {
828       SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
829       aControl->SetPrecision( myControlsPrecision );
830       myFunctor.reset( aControl );
831       myControlActor = my3DActor;
832       break;
833     }
834     case eMaxElementLength2D:
835     {
836       SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
837       aControl->SetPrecision( myControlsPrecision );
838       myFunctor.reset( aControl );
839       myControlActor = my2DActor;
840       break;
841     }
842     case eMaxElementLength3D:
843     {
844       SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
845       aControl->SetPrecision( myControlsPrecision );
846       myFunctor.reset( aControl );
847       myControlActor = my3DActor;
848       break;
849     }
850     case eBareBorderVolume:
851     {
852       myFunctor.reset(new SMESH::Controls::BareBorderVolume());
853       myControlActor = my3DActor;
854       break;
855     }
856     case eOverConstrainedVolume:
857     {
858       myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
859       myControlActor = my3DActor;
860       break;
861     }
862     case eMinimumAngle:
863     {
864       SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
865       aControl->SetPrecision( myControlsPrecision );
866       myFunctor.reset( aControl );
867       myControlActor = my2DActor;
868       break;
869     }
870     case eWarping:
871     {
872       SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
873       aControl->SetPrecision( myControlsPrecision );
874       myFunctor.reset( aControl );
875       myControlActor = my2DActor;
876       break;
877     }
878     case eSkew:
879     {
880       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
881       aControl->SetPrecision( myControlsPrecision );
882       myFunctor.reset( aControl );
883       myControlActor = my2DActor;
884       break;
885     }
886     default:
887       return;
888     }
889
890     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
891     vtkIdType aNbCells = aGrid->GetNumberOfCells();
892     if(aNbCells){
893       myControlMode = theMode;
894       switch(myControlMode){
895       case eFreeNodes:
896         myNodeExtActor->SetExtControlMode(myFunctor);
897         break;
898       case eFreeEdges:
899       case eFreeBorders:
900         my1DExtActor->SetExtControlMode(myFunctor);
901         break;
902       case eFreeFaces:
903       case eBareBorderFace:
904       case eOverConstrainedFace:
905         my2DExtActor->SetExtControlMode(myFunctor);
906         break;
907       case eBareBorderVolume:
908       case eOverConstrainedVolume:
909         my3DExtActor->SetExtControlMode(myFunctor);
910         break;
911       case eLength2D:
912       case eMultiConnection2D:
913         my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
914         UpdateDistribution();
915         break;
916       default:
917         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
918         UpdateDistribution();
919       }
920     }
921
922     if(theCheckEntityMode){
923       if(myControlActor == my1DActor)
924         SetEntityMode(eEdges);
925       else if(myControlActor == my2DActor){
926         switch(myControlMode){
927         case eLength2D:
928         case eFreeEdges:
929         case eFreeFaces:
930         case eMultiConnection2D:
931           //SetEntityMode(eEdges);
932           SetEntityMode(eFaces);
933           break;
934         default:
935           SetEntityMode(eFaces);
936         }
937       }else if(myControlActor == my3DActor)
938         SetEntityMode(eVolumes);
939     }
940
941   }
942   else {
943     if(theCheckEntityMode)
944       myEntityMode = eAllEntity;
945     myFunctor.reset();
946   }
947
948   SetRepresentation(GetRepresentation());
949
950   myTimeStamp->Modified();
951   Modified();
952 }
953
954
955 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
956   theRenderer->AddActor(myNodeActor);
957   theRenderer->AddActor(myBaseActor);
958   
959   theRenderer->AddActor(myNodeExtActor);
960
961   my3DActor->AddToRender(theRenderer);
962   my3DExtActor->AddToRender(theRenderer);
963   my2DActor->AddToRender(theRenderer);
964   my2DExtActor->AddToRender(theRenderer);
965
966   theRenderer->AddActor(my1DActor);
967   theRenderer->AddActor(my1DExtActor);
968
969   theRenderer->AddActor(my0DActor);
970   //theRenderer->AddActor(my0DExtActor);
971
972   theRenderer->AddActor(myHighlitableActor);
973   
974   theRenderer->AddActor2D(myScalarBarActor);
975
976   myPtsSelectVisiblePoints->SetRenderer(theRenderer);
977   myClsSelectVisiblePoints->SetRenderer(theRenderer);
978
979   theRenderer->AddActor2D(myPointLabels);
980   theRenderer->AddActor2D(myCellsLabels);
981
982   // the superclass' method should be called at the end
983   // (in particular, for correct work of selection)
984   SALOME_Actor::AddToRender(theRenderer);
985 }
986
987 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
988   SALOME_Actor::RemoveFromRender(theRenderer);
989
990   theRenderer->RemoveActor(myNodeActor);
991   theRenderer->RemoveActor(myBaseActor);
992
993   theRenderer->RemoveActor(myNodeExtActor);
994
995   theRenderer->RemoveActor(myHighlitableActor);
996
997   theRenderer->RemoveActor(my0DActor);
998   //theRenderer->RemoveActor(my0DExtActor);
999
1000   theRenderer->RemoveActor(my1DActor);
1001   theRenderer->RemoveActor(my1DExtActor);
1002
1003   my2DActor->RemoveFromRender(theRenderer);
1004   my2DExtActor->RemoveFromRender(theRenderer);
1005   my3DActor->RemoveFromRender(theRenderer);
1006   my3DExtActor->RemoveFromRender(theRenderer);
1007
1008   theRenderer->RemoveActor(myScalarBarActor);
1009   theRenderer->RemoveActor(myPointLabels);
1010   theRenderer->RemoveActor(myCellsLabels);
1011 }
1012
1013
1014 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, 
1015                           const char* theEntry, 
1016                           const char* theName,
1017                           int theIsClear)
1018 {
1019   Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1020   setIO(anIO);
1021   setName(theName);
1022
1023   myVisualObj = theVisualObj;
1024   myVisualObj->Update(theIsClear);
1025
1026   myNodeActor->Init(myVisualObj,myImplicitBoolean);
1027   myBaseActor->Init(myVisualObj,myImplicitBoolean);
1028
1029   myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1030
1031   myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1032   
1033   my0DActor->Init(myVisualObj,myImplicitBoolean);
1034   //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1035   
1036   my1DActor->Init(myVisualObj,myImplicitBoolean);
1037   my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1038   
1039   my2DActor->Init(myVisualObj,myImplicitBoolean);
1040   my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1041   my3DActor->Init(myVisualObj,myImplicitBoolean);
1042   my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1043   
1044   my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1045   //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1046   
1047   my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1048   my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1049
1050   my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1051   my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1052   my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1053   my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1054     
1055   vtkFloatingPointType aFactor, aUnits;
1056   my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1057   my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1058   my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1059
1060   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1061   if( !mgr )
1062     return false;
1063
1064   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1065   SetIsShrunkable(true);
1066
1067   SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1068
1069   int aMode = mgr->integerValue( "SMESH", "display_mode" );
1070   SetRepresentation(-1);
1071   
1072   if(aMode == 0){
1073     SetRepresentation(eEdge);
1074   }else if(aMode == 1){
1075     SetRepresentation(eSurface);
1076   }else if(aMode == 2){
1077     SetRepresentation(ePoint);
1078   }
1079   
1080   if(aMode == 3){
1081     SetShrink();
1082   }
1083
1084   if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1085     SetIsDisplayNameActor( true );
1086
1087   int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1088   int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 );  // 5 pixels
1089   SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1090
1091   myTimeStamp->Modified();
1092   Modified();
1093   return true;
1094 }
1095
1096
1097 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1098   return myNodeActor->GetBounds();
1099 }
1100
1101
1102 vtkDataSet* SMESH_ActorDef::GetInput(){
1103   return GetUnstructuredGrid();
1104 }
1105
1106
1107 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1108   Superclass::SetTransform(theTransform);
1109
1110   myNodeActor->SetTransform(theTransform);
1111   myBaseActor->SetTransform(theTransform);
1112   
1113   myHighlitableActor->SetTransform(theTransform);
1114
1115   myNodeExtActor->SetTransform(theTransform);
1116
1117   my0DActor->SetTransform(theTransform);
1118   //my0DExtActor->SetTransform(theTransform);
1119
1120   my1DActor->SetTransform(theTransform);
1121   my1DExtActor->SetTransform(theTransform);
1122
1123   my2DActor->SetTransform(theTransform);
1124   my2DExtActor->SetTransform(theTransform);
1125   my3DActor->SetTransform(theTransform);
1126   my3DExtActor->SetTransform(theTransform);
1127
1128   Modified();
1129 }
1130
1131
1132 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1133   vtkLODActor::SetMapper(theMapper);
1134 }
1135
1136
1137 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1138   SALOME_Actor::ShallowCopy(prop);
1139 }
1140
1141
1142 vtkMapper* SMESH_ActorDef::GetMapper(){
1143   return myPickableActor->GetMapper();
1144 }
1145
1146
1147 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){ 
1148   return myVisualObj->GetUnstructuredGrid();
1149 }
1150
1151
1152 bool SMESH_ActorDef::IsInfinitive(){
1153   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1154   aDataSet->Update();
1155   myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1156     ( aDataSet->GetNumberOfCells() == 1 && 
1157     aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1158   return SALOME_Actor::IsInfinitive();
1159 }
1160
1161
1162 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1163   if ( myIsShrinkable == theShrunkable )
1164     return;
1165   myIsShrinkable = theShrunkable;
1166   Modified();
1167 }
1168
1169 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1170   return myBaseActor->GetShrinkFactor();
1171 }
1172
1173 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1174   myBaseActor->SetShrinkFactor(theValue);
1175
1176   my1DActor->SetShrinkFactor(theValue);
1177   my1DExtActor->SetShrinkFactor(theValue);
1178
1179   my2DActor->SetShrinkFactor(theValue);
1180   my2DExtActor->SetShrinkFactor(theValue);
1181   my3DActor->SetShrinkFactor(theValue);
1182   my3DExtActor->SetShrinkFactor(theValue);
1183
1184   Modified();
1185 }
1186
1187 void SMESH_ActorDef::SetShrink(){
1188   if(!myIsShrinkable) return;
1189
1190   myBaseActor->SetShrink();
1191
1192   my1DActor->SetShrink();
1193   my1DExtActor->SetShrink();
1194
1195   my2DActor->SetShrink();
1196   my2DExtActor->SetShrink();
1197   my3DActor->SetShrink();
1198   my3DExtActor->SetShrink();
1199
1200   myIsShrunk = true;
1201   Modified();
1202 }
1203
1204 void SMESH_ActorDef::UnShrink(){
1205   if(!myIsShrunk) return;
1206
1207   myBaseActor->UnShrink();
1208
1209   my1DActor->UnShrink();
1210   my1DExtActor->UnShrink();
1211
1212   my2DActor->UnShrink();
1213   my2DExtActor->UnShrink();
1214   my3DActor->UnShrink();
1215   my3DExtActor->UnShrink();
1216
1217   myIsShrunk = false;
1218   Modified();
1219 }
1220
1221
1222 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1223   return myPickableActor->GetNodeObjId(theVtkID);
1224 }
1225
1226 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1227   return myPickableActor->GetNodeCoord(theObjID);
1228 }
1229
1230
1231 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1232   return myPickableActor->GetElemObjId(theVtkID);
1233 }
1234
1235 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1236   return myPickableActor->GetElemCell(theObjID);
1237 }
1238
1239
1240 void SMESH_ActorDef::SetVisibility(int theMode){
1241   SetVisibility(theMode,true);
1242 }
1243
1244
1245 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1246   SALOME_Actor::SetVisibility(theMode);
1247
1248   myNodeActor->VisibilityOff();
1249   myBaseActor->VisibilityOff();
1250   
1251   myNodeExtActor->VisibilityOff();
1252
1253   my0DActor->VisibilityOff();
1254   //my0DExtActor->VisibilityOff();
1255
1256   my1DActor->VisibilityOff();
1257   my1DExtActor->VisibilityOff();
1258   
1259   my2DActor->VisibilityOff();
1260   my2DExtActor->VisibilityOff();
1261   my3DActor->VisibilityOff();
1262   my3DExtActor->VisibilityOff();
1263   
1264   myScalarBarActor->VisibilityOff();
1265   myPointLabels->VisibilityOff();
1266   myCellsLabels->VisibilityOff();
1267   
1268   if(GetVisibility()){
1269     if(theIsUpdateRepersentation)
1270       SetRepresentation(GetRepresentation());
1271     
1272     if(myControlMode != eNone){
1273       switch(myControlMode){
1274       case eFreeNodes:
1275         myNodeExtActor->VisibilityOn();
1276         break;
1277       case eFreeEdges:
1278       case eFreeBorders:
1279         my1DExtActor->VisibilityOn();
1280         break;
1281       case eFreeFaces:
1282       case eBareBorderFace:
1283       case eOverConstrainedFace:
1284         my2DExtActor->VisibilityOn();
1285         break;
1286       case eBareBorderVolume:
1287       case eOverConstrainedVolume:
1288         my3DExtActor->VisibilityOn();
1289         break;
1290       case eLength2D:
1291       case eMultiConnection2D:
1292         my1DExtActor->VisibilityOn();
1293       default:
1294         if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1295           myScalarBarActor->VisibilityOn();
1296       }
1297     }
1298
1299     if(myRepresentation != ePoint)
1300       myPickableActor->VisibilityOn();
1301     else {
1302       myNodeActor->VisibilityOn();
1303     }
1304
1305     if(myEntityMode & e0DElements){
1306       my0DActor->VisibilityOn();
1307     }
1308
1309     if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1310       my1DActor->VisibilityOn();
1311     }
1312     
1313     if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1314       my2DActor->VisibilityOn();
1315     }
1316     
1317     if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1318       my3DActor->VisibilityOn();
1319     }
1320     
1321     if(myIsPointsLabeled){ 
1322       myPointLabels->VisibilityOn();
1323       myNodeActor->VisibilityOn();
1324     }
1325
1326     if(myIsCellsLabeled) 
1327       myCellsLabels->VisibilityOn();
1328   }
1329   UpdateHighlight();
1330   Modified();
1331 }
1332
1333
1334 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1335 {
1336   myEntityState = eAllEntity;
1337
1338   if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1339     myEntityState &= ~e0DElements;
1340     theMode &= ~e0DElements;
1341   }
1342
1343   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1344     myEntityState &= ~eEdges;
1345     theMode &= ~eEdges;
1346   }
1347
1348   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1349     myEntityState &= ~eFaces;
1350     theMode &= ~eFaces;
1351   }
1352
1353   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1354     myEntityState &= ~eVolumes;
1355     theMode &= ~eVolumes;
1356   }
1357
1358   if (!theMode) {
1359     if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1360       theMode |= e0DElements;
1361
1362     if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1363       theMode |= eEdges;
1364
1365     if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1366       theMode |= eFaces;
1367
1368     if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1369       theMode |= eVolumes;
1370   }
1371
1372   myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1373
1374   myEntityMode = theMode;
1375   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1376   aFilter = myBaseActor->GetExtractUnstructuredGrid();
1377   aFilter->ClearRegisteredCellsWithType();
1378   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1379
1380   VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1381   aHightFilter->ClearRegisteredCellsWithType();
1382   aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1383
1384   if (myEntityMode & e0DElements) {
1385     if (MYDEBUG) MESSAGE("0D ELEMENTS");
1386     aFilter->RegisterCellsWithType(VTK_VERTEX);
1387     aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1388   }
1389
1390   if (myEntityMode & eEdges) {
1391     if (MYDEBUG) MESSAGE("EDGES");
1392     aFilter->RegisterCellsWithType(VTK_LINE);
1393     aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1394
1395     aHightFilter->RegisterCellsWithType(VTK_LINE);
1396     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1397   }
1398
1399   if (myEntityMode & eFaces) {
1400     if (MYDEBUG) MESSAGE("FACES");
1401     aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1402     aFilter->RegisterCellsWithType(VTK_POLYGON);
1403     aFilter->RegisterCellsWithType(VTK_QUAD);
1404     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1405     aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1406
1407     aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1408     aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1409     aHightFilter->RegisterCellsWithType(VTK_QUAD);
1410     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1411     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1412   }
1413
1414   if (myEntityMode & eVolumes) {
1415     if (MYDEBUG) MESSAGE("VOLUMES");
1416     aFilter->RegisterCellsWithType(VTK_TETRA);
1417     aFilter->RegisterCellsWithType(VTK_VOXEL);
1418     aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1419     aFilter->RegisterCellsWithType(VTK_WEDGE);
1420     aFilter->RegisterCellsWithType(VTK_PYRAMID);
1421     aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1422     aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1423     aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1424     aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1425     
1426     aHightFilter->RegisterCellsWithType(VTK_TETRA);
1427     aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1428     aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1429     aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1430     aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1431     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1432     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1433     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1434     aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1435     aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1436   }
1437   aFilter->Update();
1438   if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1439   SetVisibility(GetVisibility(),false);
1440 }
1441
1442 void SMESH_ActorDef::SetRepresentation (int theMode)
1443
1444   int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1445   int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1446   int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1447
1448   if (theMode < 0) {
1449     myRepresentation = eSurface;
1450     if (!aNbFaces && !aNbVolumes && aNbEdges) {
1451       myRepresentation = eEdge;
1452     } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1453       myRepresentation = ePoint;
1454     }
1455   } else {
1456     switch (theMode) {
1457     case eEdge:
1458       if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1459       break;
1460     case eSurface:
1461       if (!aNbFaces && !aNbVolumes) return;
1462       break;
1463     }    
1464     myRepresentation = theMode;
1465   }
1466
1467   if (!GetUnstructuredGrid()->GetNumberOfCells())
1468     myRepresentation = ePoint;
1469
1470   if (myIsShrunk) {
1471     if (myRepresentation == ePoint) {
1472       UnShrink();
1473       myIsShrunk = true;
1474     } else {
1475       SetShrink();
1476     }      
1477   }
1478
1479   myPickableActor = myBaseActor;
1480   myNodeActor->SetVisibility(false);
1481   myNodeExtActor->SetVisibility(false);
1482   vtkProperty *aProp = NULL, *aBackProp = NULL;
1483   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1484   SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1485   switch (myRepresentation) {
1486   case ePoint:
1487     myPickableActor = myNodeActor;
1488     myNodeActor->SetVisibility(true);
1489     aQuadraticMode = SMESH_Actor::eLines;
1490     aProp = aBackProp = myNodeProp;
1491     aReperesent = SMESH_DeviceActor::ePoint;
1492     break;
1493   case eEdge:
1494     aProp = aBackProp = myEdgeProp;
1495     aReperesent = SMESH_DeviceActor::eInsideframe;
1496     break;
1497   case eSurface:
1498     aProp = mySurfaceProp;
1499     aBackProp = myBackSurfaceProp;
1500     aReperesent = SMESH_DeviceActor::eSurface;
1501     break;
1502   }
1503
1504   my2DActor->SetProperty(aProp);
1505   my2DActor->SetBackfaceProperty(aBackProp);
1506   my2DActor->SetRepresentation(aReperesent);
1507
1508   if(aQuadraticMode == SMESH_Actor::eLines)
1509     my2DActor->SetQuadraticArcMode(false);
1510   else if(aQuadraticMode == SMESH_Actor::eArcs)
1511     my2DActor->SetQuadraticArcMode(true);
1512
1513   my2DExtActor->SetRepresentation(aReperesent);
1514   
1515   my3DActor->SetProperty(aProp);
1516   my3DActor->SetBackfaceProperty(aBackProp);
1517   my3DActor->SetRepresentation(aReperesent);
1518
1519   //my0DExtActor->SetVisibility(false);
1520   my1DExtActor->SetVisibility(false);
1521   my2DExtActor->SetVisibility(false);
1522   my3DExtActor->SetVisibility(false);
1523
1524   // ???
1525   //my0DActor->SetProperty(aProp);
1526   //my0DActor->SetBackfaceProperty(aBackProp);
1527   my0DActor->SetRepresentation(aReperesent);
1528   //my0DExtActor->SetRepresentation(aReperesent);
1529
1530   switch(myControlMode){
1531   case eLength:
1532   case eMultiConnection:
1533     aProp = aBackProp = my1DProp;
1534     if(myRepresentation != ePoint)
1535       aReperesent = SMESH_DeviceActor::eInsideframe;
1536     break;
1537   }
1538   
1539   if(aQuadraticMode == SMESH_Actor::eLines)
1540     my1DActor->SetQuadraticArcMode(false);
1541   else if(aQuadraticMode == SMESH_Actor::eArcs)
1542     my1DActor->SetQuadraticArcMode(true);
1543
1544   my1DActor->SetProperty(aProp);
1545   my1DActor->SetBackfaceProperty(aBackProp);
1546   my1DActor->SetRepresentation(aReperesent);
1547
1548   my1DExtActor->SetRepresentation(aReperesent);
1549
1550   if(myIsPointsVisible)
1551     myPickableActor = myNodeActor;
1552   if(GetPointRepresentation())
1553     myNodeActor->SetVisibility(true);
1554
1555   SetMapper(myPickableActor->GetMapper());
1556
1557   SetVisibility(GetVisibility(),false);
1558
1559   Modified();
1560 }
1561
1562
1563 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1564   if ( myIsPointsVisible == theIsPointsVisible )
1565     return;
1566   myIsPointsVisible = theIsPointsVisible;
1567   SetRepresentation(GetRepresentation());
1568 }
1569
1570 bool SMESH_ActorDef::GetPointRepresentation(){ 
1571   return myIsPointsVisible || myIsPointsLabeled;
1572 }
1573
1574
1575 void SMESH_ActorDef::UpdateHighlight(){
1576   myHighlitableActor->SetVisibility(false);
1577   myHighlitableActor->SetHighlited(false);
1578
1579   if(myIsHighlighted){
1580     myHighlitableActor->SetProperty(myHighlightProp);
1581   }else if(myIsPreselected){
1582     myHighlitableActor->SetProperty(myPreselectProp);
1583   }
1584
1585   bool anIsVisible = GetVisibility();
1586
1587   if(myIsHighlighted || myIsPreselected){
1588     if(GetUnstructuredGrid()->GetNumberOfCells()){
1589       myHighlitableActor->SetHighlited(anIsVisible);
1590       myHighlitableActor->SetVisibility(anIsVisible);
1591       myHighlitableActor->GetExtractUnstructuredGrid()->
1592         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1593       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1594     }else if(myRepresentation == ePoint || GetPointRepresentation()){
1595       myHighlitableActor->SetHighlited(anIsVisible);
1596       myHighlitableActor->GetExtractUnstructuredGrid()->
1597         SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1598       myHighlitableActor->SetVisibility(anIsVisible);
1599       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1600
1601       VTK::MarkerType aMarkerType = GetMarkerType();
1602       if(aMarkerType != VTK::MT_USER)
1603         myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1604       else
1605         myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1606     }
1607   }
1608 }
1609
1610
1611 void SMESH_ActorDef::highlight(bool theHighlight){
1612   if ( myIsHighlighted == theHighlight )
1613     return;
1614   myIsHighlighted = theHighlight;
1615   UpdateHighlight();
1616 }
1617
1618
1619 void SMESH_ActorDef::SetPreSelected(bool thePreselect){ 
1620   if ( myIsPreselected == thePreselect )
1621     return;
1622   myIsPreselected = thePreselect; 
1623   UpdateHighlight();
1624 }
1625
1626
1627 // From vtkFollower
1628 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1629 {
1630   if (myPickableActor->GetIsOpaque())
1631     {
1632     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1633     this->Render(ren);
1634     return 1;
1635     }
1636   return 0;
1637 }
1638
1639
1640 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1641 {
1642   if (!myPickableActor->GetIsOpaque())
1643     {
1644     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1645     this->Render(ren);
1646     return 1;
1647     }
1648   return 0;
1649 }
1650
1651
1652 void SMESH_ActorDef::Render(vtkRenderer *ren){
1653   unsigned long aTime = myTimeStamp->GetMTime();
1654   unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1655   unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1656   if(anObjTime > aTime || aClippingTime > aTime)
1657     Update();
1658 }
1659
1660
1661 void SMESH_ActorDef::Update(){
1662   if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1663
1664   if(GetControlMode() != eNone) {
1665     unsigned long aTime = myTimeStamp->GetMTime();
1666     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1667     if (anObjTime > aTime)
1668       SetControlMode(GetControlMode(),false);
1669   }
1670   if(myIsPointsLabeled){
1671     SetPointsLabeled(myIsPointsLabeled);
1672   }
1673   if(myIsCellsLabeled){
1674     SetCellsLabeled(myIsCellsLabeled);
1675   }
1676   if(myIsFacesOriented){
1677     SetFacesOriented(myIsFacesOriented);
1678   }
1679   SetEntityMode(GetEntityMode());
1680   SetVisibility(GetVisibility());
1681   
1682   myTimeStamp->Modified();
1683   Modified();
1684 }
1685
1686
1687 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1688   SALOME_Actor::ReleaseGraphicsResources(renWin);
1689
1690   myPickableActor->ReleaseGraphicsResources(renWin);
1691 }
1692
1693
1694 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1695   vtkFloatingPointType* aColor = theProperty->GetColor();
1696   r = aColor[0];
1697   g = aColor[1];
1698   b = aColor[2];
1699 }
1700
1701
1702 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1703   mySurfaceProp->SetOpacity(theValue);
1704   myBackSurfaceProp->SetOpacity(theValue);
1705   myEdgeProp->SetOpacity(theValue);
1706   myNodeProp->SetOpacity(theValue);
1707
1708   my1DProp->SetOpacity(theValue);
1709 }
1710
1711
1712 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1713   return mySurfaceProp->GetOpacity();
1714 }
1715
1716
1717 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1718   mySurfaceProp->SetColor(r,g,b);
1719   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1720     if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1721         aGroupObj->GetElementType() == SMDSAbs_Volume )
1722       myNameActor->SetBackgroundColor(r,g,b);
1723   Modified();
1724 }
1725
1726 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1727   ::GetColor(mySurfaceProp,r,g,b);
1728   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1729 }
1730
1731 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1732   myBackSurfaceProp->SetColor(r,g,b);
1733   Modified();
1734 }
1735
1736 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1737   ::GetColor(myBackSurfaceProp,r,g,b);
1738 }
1739
1740 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1741   myEdgeProp->SetColor(r,g,b);
1742   my1DProp->SetColor(r,g,b);
1743   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1744   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1745     if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1746       myNameActor->SetBackgroundColor(r,g,b);
1747   Modified();
1748 }
1749
1750 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1751   ::GetColor(myEdgeProp,r,g,b);
1752 }
1753
1754 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1755   myNodeProp->SetColor(r,g,b);
1756   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1757   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1758     if( aGroupObj->GetElementType() == SMDSAbs_Node )
1759       myNameActor->SetBackgroundColor(r,g,b);
1760   Modified();
1761 }
1762
1763 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1764   ::GetColor(myNodeProp,r,g,b);
1765 }
1766
1767 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1768   my0DProp->SetColor(r,g,b);
1769   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1770     if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1771       myNameActor->SetBackgroundColor(r,g,b);
1772   Modified();
1773 }
1774
1775 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1776   ::GetColor(my0DProp,r,g,b);
1777 }
1778
1779 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1780   myHighlightProp->SetColor(r,g,b);
1781   Modified();
1782 }
1783
1784 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1785   ::GetColor(myHighlightProp,r,g,b);
1786 }
1787
1788 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
1789   myPreselectProp->SetColor(r,g,b);
1790   Modified();
1791 }
1792
1793 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ 
1794   ::GetColor(myPreselectProp,r,g,b);
1795 }
1796
1797
1798 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1799   return myEdgeProp->GetLineWidth();
1800 }
1801
1802
1803 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1804   myEdgeProp->SetLineWidth(theVal);
1805
1806   my1DProp->SetLineWidth(theVal + aLineWidthInc);
1807   my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1808
1809   Modified();
1810 }
1811
1812
1813 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1814   my0DProp->SetPointSize(theVal);
1815   Modified();
1816 }
1817
1818 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1819   return my0DProp->GetPointSize();
1820 }
1821
1822 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1823 {
1824   return myVisualObj->GetElemDimension( theObjId );
1825 }
1826
1827 bool
1828 SMESH_ActorDef::
1829 IsImplicitFunctionUsed() const
1830 {
1831   return myBaseActor->IsImplicitFunctionUsed();
1832 }
1833
1834 void
1835 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1836 {
1837   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1838   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1839
1840   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1841
1842   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1843
1844   my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1845   //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1846
1847   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1848   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1849
1850   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1851   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1852   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853   my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1854 }
1855
1856 vtkIdType 
1857 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1858 {
1859   if(thePlane){
1860     myImplicitBoolean->GetFunction()->AddItem(thePlane);
1861     myCippingPlaneCont.push_back(thePlane);
1862     if(!IsImplicitFunctionUsed())
1863       SetImplicitFunctionUsed(true);
1864   }
1865   return myCippingPlaneCont.size();
1866 }
1867
1868 void
1869 SMESH_ActorDef::
1870 RemoveAllClippingPlanes()
1871 {
1872   myImplicitBoolean->GetFunction()->RemoveAllItems();
1873   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1874   myCippingPlaneCont.clear();
1875   SetImplicitFunctionUsed(false);
1876 }
1877
1878 vtkIdType
1879 SMESH_ActorDef::
1880 GetNumberOfClippingPlanes()
1881 {
1882   return myCippingPlaneCont.size();
1883 }
1884
1885 vtkPlane* 
1886 SMESH_ActorDef::
1887 GetClippingPlane(vtkIdType theID)
1888 {
1889   if(theID >= myCippingPlaneCont.size())
1890     return NULL;
1891   return myCippingPlaneCont[theID].Get();
1892 }
1893
1894 void SMESH_ActorDef::UpdateScalarBar()
1895 {
1896   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1897   if( !mgr )
1898     return;
1899
1900   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1901
1902   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1903   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1904
1905   aScalarBarTitleProp->SetFontFamilyToArial();
1906
1907   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1908   {
1909     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1910     if ( f.family() == "Arial" )
1911       aScalarBarTitleProp->SetFontFamilyToArial();
1912     else if ( f.family() == "Courier" )
1913       aScalarBarTitleProp->SetFontFamilyToCourier();
1914     else if ( f.family() == "Times" )
1915       aScalarBarTitleProp->SetFontFamilyToTimes();
1916
1917     if ( f.bold() )
1918       aScalarBarTitleProp->BoldOn();
1919     else
1920       aScalarBarTitleProp->BoldOff();
1921
1922     if ( f.italic() )
1923       aScalarBarTitleProp->ItalicOn();
1924     else
1925      aScalarBarTitleProp->ItalicOff();
1926
1927     if ( f.overline() )
1928       aScalarBarTitleProp->ShadowOn();
1929     else
1930       aScalarBarTitleProp->ShadowOff();
1931   }
1932
1933   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1934   aScalarBarTitleProp->Delete();
1935
1936   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1937
1938   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1939   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1940
1941   aScalarBarLabelProp->SetFontFamilyToArial();
1942   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1943   {
1944     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1945     if( f.family() == "Arial" )
1946       aScalarBarLabelProp->SetFontFamilyToArial();
1947     else if( f.family() == "Courier" )
1948       aScalarBarLabelProp->SetFontFamilyToCourier();
1949     else if( f.family() == "Times" )
1950       aScalarBarLabelProp->SetFontFamilyToTimes();
1951
1952     if ( f.bold() )
1953       aScalarBarLabelProp->BoldOn();
1954     else
1955       aScalarBarLabelProp->BoldOff();
1956
1957     if ( f.italic() )
1958       aScalarBarLabelProp->ItalicOn();
1959     else
1960       aScalarBarLabelProp->ItalicOff();
1961
1962     if( f.overline() )
1963       aScalarBarLabelProp->ShadowOn();
1964     else
1965       aScalarBarLabelProp->ShadowOff();
1966   }
1967
1968   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1969   aScalarBarLabelProp->Delete();
1970
1971   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1972   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1973   if( horiz )
1974     myScalarBarActor->SetOrientationToHorizontal();
1975   else
1976     myScalarBarActor->SetOrientationToVertical();
1977
1978
1979   vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1980   if( mgr->hasValue( "SMESH", name + "x" ) )
1981     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1982
1983   vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1984   if( mgr->hasValue( "SMESH", name + "y" ) )
1985     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1986   myScalarBarActor->SetPosition( aXVal, aYVal );
1987
1988   vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1989   if( mgr->hasValue( "SMESH", name + "width" ) )
1990     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1991   myScalarBarActor->SetWidth( aWVal );
1992
1993   vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1994   if( mgr->hasValue( "SMESH", name + "height" ) )
1995     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1996   myScalarBarActor->SetHeight( aHVal );
1997
1998   int anIntVal = 5;
1999   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2000     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2001   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2002
2003   anIntVal = 64;
2004   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2005     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2006   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2007
2008   bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2009   myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2010
2011   int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2012   myScalarBarActor->SetDistributionColoringType(coloringType);
2013   
2014   QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2015                                              QColor(255, 255, 255));
2016   double rgb[3];
2017   rgb[0]= distributionColor.red()/255.;
2018   rgb[1]= distributionColor.green()/255.;
2019   rgb[2]= distributionColor.blue()/255.;
2020   myScalarBarActor->SetDistributionColor(rgb);
2021
2022   
2023 }
2024
2025 void SMESH_ActorDef::UpdateDistribution()
2026 {
2027   if(SMESH::Controls::NumericalFunctor* fun =
2028      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2029   {
2030     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2031     std::vector<int> nbEvents;
2032     std::vector<double> funValues;
2033     SMESH_VisualObjDef::TEntityList elems;
2034     if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2035       dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2036     std::vector<int> elemIds;
2037     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2038       elemIds.push_back( (*e)->GetID());
2039     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2040     double * range = lookupTable->GetRange();
2041     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2042     myScalarBarActor->SetDistribution(nbEvents);
2043   }
2044 }
2045
2046 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2047 {
2048   switch(theMode) {
2049   case SMESH_Actor::eLines :
2050     myHighlitableActor->SetQuadraticArcMode(false);
2051     my2DActor->SetQuadraticArcMode(false);
2052     my1DActor->SetQuadraticArcMode(false);
2053     break;
2054   case SMESH_Actor::eArcs :
2055     myHighlitableActor->SetQuadraticArcMode(true);
2056     if(GetRepresentation() != SMESH_Actor::ePoint) {
2057       my2DActor->SetQuadraticArcMode(true);
2058       my1DActor->SetQuadraticArcMode(true);
2059     }
2060     break;
2061   default:
2062     break;
2063   }
2064 }
2065
2066
2067 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2068 {
2069   if(myHighlitableActor->GetQuadraticArcMode())
2070     return SMESH_Actor::eArcs;
2071   else
2072     return SMESH_Actor::eLines;
2073 }
2074
2075 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2076 {
2077   SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2078   myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2079   myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2080 }
2081
2082 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2083 {
2084   SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2085   myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2086   myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2087   myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2088 }