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