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