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