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