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