Salome HOME
Update of CheckDone
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
1 // Copyright (C) 2007-2022  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_ActorProps.h"
32 #include "SMESH_ActorUtils.h"
33 #include "SMESH_CellLabelActor.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMESH_DeviceActor.h"
36 #include "SMESH_NodeLabelActor.h"
37 #include "SMESH_ObjectDef.h"
38 #include "SMESH_SVTKActor.h"
39 #include "SMESH_ScalarBarActor.h"
40
41 #include <Qtx.h>
42 #include <SALOME_InteractiveObject.hxx>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <VTKViewer_ExtractUnstructuredGrid.h>
46 #include <VTKViewer_FramedTextActor.h>
47
48 #ifndef DISABLE_PLOT2DVIEWER
49 #include <SPlot2d_Histogram.h>
50 #endif
51
52 #include <vtkProperty.h>
53 #include <vtkTimeStamp.h>
54 #include <vtkObjectFactory.h>
55 #include <vtkShrinkPolyData.h>
56 #include <vtkMergeFilter.h>
57
58 #include <vtkMatrix4x4.h>
59 #include <vtkUnstructuredGrid.h>
60 #include <vtkPointData.h>
61 #include <vtkCellData.h>
62
63 #include <vtkMapper.h>
64 #include <vtkRenderer.h>
65
66 #include <vtkCell.h>
67 #include <vtkIdList.h>
68 #include <vtkIntArray.h>
69
70 #include <vtkActor2D.h>
71 #include <vtkProperty2D.h>
72 #include <vtkPolyData.h>
73 #include <vtkTextProperty.h>
74
75 #include <vtkLookupTable.h>
76
77 #include <vtkMath.h>
78 #include <vtkPlane.h>
79 #include <vtkPlaneCollection.h>
80 #include <vtkImplicitBoolean.h>
81 #include <vtkImplicitFunctionCollection.h>
82
83 #include "utilities.h"
84
85
86 SMESH_ActorDef* SMESH_ActorDef::New(){
87   return new SMESH_ActorDef();
88 }
89
90
91 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
92                               const char* theEntry,
93                               const char* theName,
94                               int theIsClear)
95 {
96   SMESH_ActorDef* anActor = NULL;
97   if(theVisualObj->IsValid() ) {
98     anActor = SMESH_ActorDef::New();
99     if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
100       anActor->Delete();
101       anActor = NULL;
102     }
103     if( anActor )
104       anActor->UpdateScalarBar();
105   }
106   return anActor;
107 }
108
109
110 SMESH_ActorDef::SMESH_ActorDef()
111 {
112   MESSAGE("SMESH_ActorDef - "<<this);
113
114   SALOME_Actor::SetVisibility(false); // avoid update of pipelines
115
116   myBaseActor = SMESH_DeviceActor::New();
117
118   myTimeStamp = vtkTimeStamp::New();
119
120   myIsPointsVisible = false;
121   myIsEntityModeCache = false;
122   myRepresentationCache = 0;
123
124   myHighlightActor = SMESH_SVTKActor::New();
125   myHighlightActor->Delete(); // vtkSmartPointer!
126   myHighlightActor->Initialize();
127
128   myPreHighlightActor = SMESH_SVTKActor::New();
129   myPreHighlightActor->Delete();
130   myPreHighlightActor->Initialize();
131
132   myIsShrinkable = false;
133   myIsShrunk = false;
134
135   myIsFacesOriented = false;
136
137   float  controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
138   float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
139
140   myControlsPrecision = -1;
141   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
142
143   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
144     myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
145
146   float aElem0DSize    = (float) SMESH::GetFloat("SMESH:elem0d_size",5);
147   float aBallElemSize  = (float) SMESH::GetFloat("SMESH:ball_elem_size",10);
148   float aBallElemScale = (float) SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
149   float aLineWidth     = (float) SMESH::GetFloat("SMESH:element_width",1);
150   float aOutlineWidth  = (float) SMESH::GetFloat("SMESH:outline_width",1);
151
152   SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
153   bool aBoldNd    = true;
154   bool anItalicNd = false;
155   bool aShadowNd  = false;
156   int  aSizeNd    = 10;
157   if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
158     QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
159     if ( f.family()      == "Arial" )   aFamilyNd = SMESH::FntArial;
160     else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
161     else if ( f.family() == "Times" )   aFamilyNd = SMESH::FntTimes;
162     aBoldNd    = f.bold();
163     anItalicNd = f.italic();
164     aShadowNd  = f.overline();
165     aSizeNd    = f.pointSize();
166   }
167   double anRGBNd[3] = {1,1,1};
168   SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
169
170   SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
171   bool aBoldEl    = true;
172   bool anItalicEl = false;
173   bool aShadowEl  = false;
174   int  aSizeEl    = 12;
175   if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
176     QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
177     if ( f.family()      == "Arial" )   aFamilyEl = SMESH::FntArial;
178     else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
179     else if ( f.family() == "Times" )   aFamilyEl = SMESH::FntTimes;
180     aBoldEl    = f.bold();
181     anItalicEl = f.italic();
182     aShadowEl  = f.overline();
183     aSizeEl    = f.pointSize();
184   }
185   double anRGBEl[3] = {0,1,0};
186   SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
187
188   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
189   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
190
191   //Definition 2D and 3D devices of the actor
192   //-----------------------------------------
193   double anRGB[3] = {1,1,1};
194   mySurfaceProp = vtkProperty::New();
195   QColor ffc, bfc;
196   int delta;
197   SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
198   mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
199   myDeltaBrightness = delta;
200
201   myBackSurfaceProp = vtkProperty::New();
202   bfc = Qtx::mainColorToSecondary(ffc, delta);
203   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
204
205   myNormalVProp = vtkProperty::New();
206   SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
207   myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
208   myDeltaVBrightness = delta;
209
210   myReversedVProp = vtkProperty::New();
211   bfc = Qtx::mainColorToSecondary(ffc, delta);
212   myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
213
214   my2DActor = SMESH_CellLabelActor::New();
215   my2DActor->SetStoreClippingMapping(true);
216   my2DActor->SetUserMatrix(aMatrix);
217   my2DActor->PickableOff();
218   my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
219   my2DActor->SetProperty(mySurfaceProp);
220   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
221   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
222   aFilter = my2DActor->GetExtractUnstructuredGrid();
223   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
224   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
225   aFilter->RegisterCellsWithType(VTK_QUAD);
226   aFilter->RegisterCellsWithType(VTK_POLYGON);
227   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
228   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
229   aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
230   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
231   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
232
233   my2DExtProp = vtkProperty::New();
234   my2DExtProp->DeepCopy(mySurfaceProp);
235   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
236   anRGB[0] = 1 - anRGB[0];
237   anRGB[1] = 1 - anRGB[1];
238   anRGB[2] = 1 - anRGB[2];
239   my2DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
240   my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
241
242   my2DExtActor = SMESH_DeviceActor::New();
243   my2DExtActor->SetUserMatrix(aMatrix);
244   my2DExtActor->PickableOff();
245   my2DExtActor->SetProperty(my2DExtProp);
246   my2DExtActor->SetBackfaceProperty(my2DExtProp);
247   my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
248   aFilter = my2DExtActor->GetExtractUnstructuredGrid();
249   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
250   aFilter->RegisterCellsWithType(VTK_QUAD);
251   aFilter->RegisterCellsWithType(VTK_POLYGON);
252   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
253   aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
254   aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
255   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
256   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
257
258   my3DActor = SMESH_CellLabelActor::New();
259   my3DActor->SetStoreClippingMapping(true);
260   my3DActor->SetUserMatrix(aMatrix);
261   my3DActor->PickableOff();
262   my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
263   my3DActor->SetProperty(myNormalVProp);
264   my3DActor->SetBackfaceProperty(myReversedVProp);
265   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
266   my3DActor->SetCoincident3DAllowed(true);
267   aFilter = my3DActor->GetExtractUnstructuredGrid();
268   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
269   aFilter->RegisterCellsWithType(VTK_TETRA);
270   aFilter->RegisterCellsWithType(VTK_VOXEL);
271   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
272   aFilter->RegisterCellsWithType(VTK_WEDGE);
273   aFilter->RegisterCellsWithType(VTK_PYRAMID);
274   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
275   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
276   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
277   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
278   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
279   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
280   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
281   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
282   aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
283
284   my3DExtProp = vtkProperty::New();
285   my3DExtProp->DeepCopy(myNormalVProp);
286   SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
287   anRGB[0] = 1 - anRGB[0];
288   anRGB[1] = 1 - anRGB[1];
289   anRGB[2] = 1 - anRGB[2];
290   my3DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
291   my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
292
293   my3DExtActor = SMESH_DeviceActor::New();
294   my3DExtActor->SetUserMatrix(aMatrix);
295   my3DExtActor->PickableOff();
296   my3DExtActor->SetProperty(my3DExtProp);
297   my3DExtActor->SetBackfaceProperty(my3DExtProp);
298   my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
299   my3DExtActor->SetCoincident3DAllowed(true);
300   aFilter = my3DExtActor->GetExtractUnstructuredGrid();
301   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
302   aFilter->RegisterCellsWithType(VTK_TETRA);
303   aFilter->RegisterCellsWithType(VTK_VOXEL);
304   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
305   aFilter->RegisterCellsWithType(VTK_WEDGE);
306   aFilter->RegisterCellsWithType(VTK_PYRAMID);
307   aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
308   aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
309   aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
310   aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
311   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
312   aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_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 + controlsIncrement);
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 + controlsIncrement);
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 + selectionIncrement);
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 + selectionIncrement);
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   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   SetRepresentation(GetRepresentation());
731   myTimeStamp->Modified();
732 }
733
734
735 bool SMESH_ActorDef::GetCellsLabeled()
736 {
737   bool result = false;
738   if(my3DActor)
739     result = result || my3DActor->GetCellsLabeled();
740
741   if(my2DActor)
742     result = result || my2DActor->GetCellsLabeled();
743
744   if(my1DActor)
745     result = result || my1DActor->GetCellsLabeled();
746
747   if(my0DActor)
748     result = result || my0DActor->GetCellsLabeled();
749
750   if(myBallActor)
751     result = result || myBallActor->GetCellsLabeled();
752
753   return result;
754 }
755
756
757 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
758 {
759   myIsFacesOriented = theIsFacesOriented;
760
761   my2DActor->SetFacesOriented(theIsFacesOriented);
762   my3DActor->SetFacesOriented(theIsFacesOriented);
763
764   myTimeStamp->Modified();
765 }
766
767 bool SMESH_ActorDef::GetFacesOriented()
768 {
769   return myIsFacesOriented;
770 }
771
772 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
773 {
774   my2DActor->SetFacesOrientationColor( r, g, b );
775   my3DActor->SetFacesOrientationColor( r, g, b );
776 }
777
778 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
779 {
780   my3DActor->GetFacesOrientationColor( r, g, b );
781 }
782
783 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
784 {
785   my2DActor->SetFacesOrientationScale( theScale );
786   my3DActor->SetFacesOrientationScale( theScale );
787 }
788
789 double SMESH_ActorDef::GetFacesOrientationScale()
790 {
791   return my3DActor->GetFacesOrientationScale();
792 }
793
794 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
795 {
796   my2DActor->SetFacesOrientation3DVectors( theState );
797   my3DActor->SetFacesOrientation3DVectors( theState );
798 }
799
800 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
801 {
802   return my3DActor->GetFacesOrientation3DVectors();
803 }
804
805
806 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
807 {
808   myFunctor = theFunctor;
809   if ( !theFunctor )
810     SetControlMode( eNone, true );
811   else
812     SetControlMode( eCustomControl, true );
813 }
814
815 void SMESH_ActorDef::SetControlMode(eControl theMode)
816 {
817   SetControlMode(theMode,true);
818 }
819
820 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
821 {
822   vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
823   bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
824   lookupTable->SetScale(VTK_SCALE_LINEAR);
825
826   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
827   if( !mgr )
828     return;
829
830   //myControlMode = eNone;
831   myControlMode = theMode;
832   theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
833
834   my0DActor->GetMapper()->SetScalarVisibility(false);
835   my1DActor->GetMapper()->SetScalarVisibility(false);
836   my2DActor->GetMapper()->SetScalarVisibility(false);
837   my3DActor->GetMapper()->SetScalarVisibility(false);
838   myBallActor->GetMapper()->SetScalarVisibility(false);
839   myScalarBarActor->SetVisibility(false);
840
841   bool anIsScalarVisible = theMode > eNone;
842
843   if(anIsScalarVisible) {
844     switch(theMode) {
845     case eLength:
846     {
847       SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
848       aControl->SetPrecision( myControlsPrecision );
849       myFunctor.reset( aControl );
850       myControlActor = my1DActor;
851       break;
852     }
853     case eLength2D:
854       myFunctor.reset(new SMESH::Controls::Length2D());
855       myControlActor = my2DActor;
856       break;
857     case eFreeBorders:
858       myFunctor.reset(new SMESH::Controls::FreeBorders());
859       myControlActor = my1DActor;
860       break;
861     case eFreeEdges:
862       myFunctor.reset(new SMESH::Controls::FreeEdges());
863       myControlActor = my2DActor;
864       break;
865     case eFreeNodes:
866       myFunctor.reset(new SMESH::Controls::FreeNodes());
867       myControlActor = myNodeActor;
868       break;
869     case eFreeFaces:
870       myFunctor.reset(new SMESH::Controls::FreeFaces());
871       myControlActor = my2DActor;
872       break;
873     case eCoincidentNodes:
874       {
875         SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
876         double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
877         cn->SetTolerance( tol );
878         myFunctor.reset(cn);
879         myControlActor = myNodeActor;
880         break;
881       }
882     case eCoincidentElems1D:
883       myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
884       myControlActor = my1DActor;
885       break;
886     case eCoincidentElems2D:
887       myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
888       myControlActor = my2DActor;
889       break;
890     case eCoincidentElems3D:
891       myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
892       myControlActor = my3DActor;
893       break;
894     case eBareBorderFace:
895       myFunctor.reset(new SMESH::Controls::BareBorderFace());
896       myControlActor = my2DActor;
897       break;
898     case eOverConstrainedFace:
899       myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
900       myControlActor = my2DActor;
901       break;
902     case eMultiConnection:
903       myFunctor.reset(new SMESH::Controls::MultiConnection());
904       myControlActor = my1DActor;
905       break;
906     case eMultiConnection2D:
907       myFunctor.reset(new SMESH::Controls::MultiConnection2D());
908       myControlActor = my2DActor;
909       break;
910     case eArea:
911     {
912       SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
913       aControl->SetPrecision( myControlsPrecision );
914       myFunctor.reset( aControl );
915       myControlActor = my2DActor;
916       break;
917     }
918     case eTaper:
919     {
920       SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
921       aControl->SetPrecision( myControlsPrecision );
922       myFunctor.reset( aControl );
923       myControlActor = my2DActor;
924       break;
925     }
926     case eAspectRatio:
927     {
928       SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
929       aControl->SetPrecision( myControlsPrecision );
930       myFunctor.reset( aControl );
931       myControlActor = my2DActor;
932       break;
933     }
934     case eAspectRatio3D:
935     {
936       SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
937       aControl->SetPrecision( myControlsPrecision );
938       myFunctor.reset( aControl );
939       myControlActor = my3DActor;
940       break;
941     }
942     case eVolume3D:
943     {
944       SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
945       aControl->SetPrecision( myControlsPrecision );
946       myFunctor.reset( aControl );
947       myControlActor = my3DActor;
948       break;
949     }
950     case eMaxElementLength2D:
951     {
952       SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
953       aControl->SetPrecision( myControlsPrecision );
954       myFunctor.reset( aControl );
955       myControlActor = my2DActor;
956       break;
957     }
958     case eMaxElementLength3D:
959     {
960       SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
961       aControl->SetPrecision( myControlsPrecision );
962       myFunctor.reset( aControl );
963       myControlActor = my3DActor;
964       break;
965     }
966     case eDeflection2D:
967     {
968       SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
969       aControl->SetPrecision( myControlsPrecision );
970       myFunctor.reset( aControl );
971       myControlActor = my2DActor;
972       break;
973     }
974     case eBareBorderVolume:
975     {
976       myFunctor.reset(new SMESH::Controls::BareBorderVolume());
977       myControlActor = my3DActor;
978       break;
979     }
980     case eOverConstrainedVolume:
981     {
982       myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
983       myControlActor = my3DActor;
984       break;
985     }
986     case eMinimumAngle:
987     {
988       SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
989       aControl->SetPrecision( myControlsPrecision );
990       myFunctor.reset( aControl );
991       myControlActor = my2DActor;
992       break;
993     }
994     case eWarping:
995     {
996       SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
997       aControl->SetPrecision( myControlsPrecision );
998       myFunctor.reset( aControl );
999       myControlActor = my2DActor;
1000       break;
1001     }
1002     case eSkew:
1003     {
1004       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1005       aControl->SetPrecision( myControlsPrecision );
1006       myFunctor.reset( aControl );
1007       myControlActor = my2DActor;
1008       break;
1009     }
1010     case eNodeConnectivityNb:
1011     {
1012       myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1013       myControlActor = myNodeActor;
1014       break;
1015     }
1016     case eCustomControl:
1017     {
1018       if ( !myFunctor )
1019         return;
1020       switch ( myFunctor->GetType() ) {
1021       case SMDSAbs_Node          : myControlActor = myNodeActor; break;
1022       case SMDSAbs_Edge          : myControlActor = my1DActor;   break;
1023       case SMDSAbs_Face          : myControlActor = my2DActor;   break;
1024       case SMDSAbs_Volume        : myControlActor = my3DActor;   break;
1025       default                    : return;
1026       }
1027       break;
1028     }
1029     default:
1030       return;
1031     }
1032
1033     smIdType aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1034     bool aShowOnlyScalarBarTitle = false;
1035     if(aNbCells) {
1036       //myControlMode = theMode;
1037       switch(myControlMode){
1038       case eFreeNodes:
1039       case eCoincidentNodes:
1040         myNodeExtActor->SetExtControlMode(myFunctor);
1041         aShowOnlyScalarBarTitle = true;
1042         break;
1043       case eFreeEdges:
1044       case eFreeBorders:
1045       case eCoincidentElems1D:
1046         my1DExtActor->SetExtControlMode(myFunctor);
1047         aShowOnlyScalarBarTitle = true;
1048         break;
1049       case eFreeFaces:
1050       case eBareBorderFace:
1051       case eOverConstrainedFace:
1052       case eCoincidentElems2D:
1053         my2DExtActor->SetExtControlMode(myFunctor);
1054         aShowOnlyScalarBarTitle = true;
1055         break;
1056       case eBareBorderVolume:
1057       case eOverConstrainedVolume:
1058       case eCoincidentElems3D:
1059         my3DExtActor->SetExtControlMode(myFunctor);
1060         aShowOnlyScalarBarTitle = true;
1061         break;
1062       case eLength2D:
1063       case eMultiConnection2D:
1064         my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1065         UpdateDistribution();
1066         break;
1067       default:
1068         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1069         UpdateDistribution();
1070       }
1071       myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1072     }
1073
1074     if(theCheckEntityMode) {
1075       // if(myControlActor == myNodeActor) {
1076       //   if ( myControlMode == eNodeConnectivityNb ) {
1077       //     if (!myIsEntityModeCache){
1078       //       myEntityModeCache = GetEntityMode();
1079       //       myIsEntityModeCache=true;
1080       //     }
1081       //     SetEntityMode(0);
1082       //   }
1083       // }
1084       if(myControlActor == my1DActor) {
1085         if (!myIsEntityModeCache){
1086           myEntityModeCache = GetEntityMode();
1087           myIsEntityModeCache=true;
1088         }
1089         SetEntityMode(eEdges);
1090       }
1091       else if(myControlActor == my2DActor) {
1092         if (!myIsEntityModeCache){
1093           myEntityModeCache = GetEntityMode();
1094           myIsEntityModeCache=true;
1095         }
1096         SetEntityMode(eFaces);
1097       }
1098       else if(myControlActor == my3DActor) {
1099         if (!myIsEntityModeCache){
1100             myEntityModeCache = GetEntityMode();
1101             myIsEntityModeCache=true;
1102         }
1103         SetEntityMode(eVolumes);
1104     }
1105     }
1106     QString aTitle = QString(myScalarBarActor->GetTitle());
1107     aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1108     myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
1109
1110   }
1111   else {
1112     if(theCheckEntityMode){
1113       myEntityMode = myEntityModeCache;
1114       myIsEntityModeCache = false;
1115     }
1116     myFunctor.reset();
1117   }
1118
1119   SetRepresentation(GetRepresentation());
1120
1121   myTimeStamp->Modified();
1122   Modified();
1123
1124   lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1125   double * range = lookupTable->GetRange();
1126
1127   if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1128     lookupTable->SetScale(VTK_SCALE_LOG10);
1129
1130   //Update();
1131 }
1132
1133 smIdType SMESH_ActorDef::GetNumberControlEntities()
1134 {
1135   SMESH_DeviceActor* anAct = NULL;
1136   switch(myControlMode){
1137     case eFreeNodes:
1138     case eCoincidentNodes:
1139       anAct = myNodeExtActor;
1140       break;
1141     case eFreeEdges:
1142     case eFreeBorders:
1143     case eCoincidentElems1D:
1144       anAct = my1DExtActor;
1145       break;
1146     case eFreeFaces:
1147     case eBareBorderFace:
1148     case eOverConstrainedFace:
1149     case eCoincidentElems2D:
1150       anAct = my2DExtActor;
1151       break;
1152     case eBareBorderVolume:
1153     case eOverConstrainedVolume:
1154     case eCoincidentElems3D:
1155       anAct = my3DExtActor;
1156       break;
1157     default:;
1158   }
1159   return anAct ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1160 }
1161
1162 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1163 {
1164   if ( !mySelector || !mySelector->IsSelectionEnabled() )
1165   {
1166     myBaseActor->SetUnstructuredGrid( NULL );
1167     //myHighlitableActor->SetUnstructuredGrid( NULL );
1168   }
1169   theRenderer->AddActor(myBaseActor);
1170   theRenderer->AddActor(myNodeExtActor);
1171   theRenderer->AddActor(my1DExtActor);
1172
1173   my3DActor   ->AddToRender(theRenderer);
1174   my3DExtActor->AddToRender(theRenderer);
1175   my2DActor   ->AddToRender(theRenderer);
1176   my2DExtActor->AddToRender(theRenderer);
1177   myNodeActor ->AddToRender(theRenderer);
1178   my1DActor   ->AddToRender(theRenderer);
1179   my0DActor   ->AddToRender(theRenderer);
1180   myBallActor ->AddToRender(theRenderer);
1181
1182   theRenderer->AddActor(myHighlitableActor);
1183
1184   theRenderer->AddActor2D(myScalarBarActor);
1185
1186   // the superclass' method should be called at the end
1187   // (in particular, for correct work of selection)
1188   SALOME_Actor::AddToRender(theRenderer);
1189 }
1190
1191 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1192 {
1193   SALOME_Actor::RemoveFromRender(theRenderer);
1194
1195   theRenderer->RemoveActor(myBaseActor);
1196
1197   theRenderer->RemoveActor(myNodeExtActor);
1198
1199   theRenderer->RemoveActor(myHighlitableActor);
1200
1201   //theRenderer->RemoveActor(my0DExtActor);
1202
1203   theRenderer->RemoveActor(my1DExtActor);
1204
1205   my2DActor->RemoveFromRender(theRenderer);
1206   my2DExtActor->RemoveFromRender(theRenderer);
1207   my3DActor->RemoveFromRender(theRenderer);
1208   my3DExtActor->RemoveFromRender(theRenderer);
1209   myNodeActor->RemoveFromRender(theRenderer);
1210   my0DActor->RemoveFromRender(theRenderer);
1211   myBallActor->RemoveFromRender(theRenderer);
1212   my1DActor->RemoveFromRender(theRenderer);
1213
1214   theRenderer->RemoveActor(myScalarBarActor);
1215 }
1216
1217
1218 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1219                           const char*   theEntry,
1220                           const char*   theName,
1221                           int           theIsClear)
1222 {
1223   Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1224   setIO(anIO);
1225   setName(theName);
1226
1227   myVisualObj = theVisualObj;
1228   myVisualObj->Update(theIsClear);
1229
1230   SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1231   SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1232
1233   myNodeActor->Init(myVisualObj,myImplicitBoolean);
1234   myBaseActor->Init(myVisualObj,myImplicitBoolean);
1235
1236   myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1237
1238   myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1239
1240   my0DActor->Init(myVisualObj,myImplicitBoolean);
1241   myBallActor->Init(myVisualObj,myImplicitBoolean);
1242   //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1243
1244   my1DActor->Init(myVisualObj,myImplicitBoolean);
1245   my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1246
1247   my2DActor->Init(myVisualObj,myImplicitBoolean);
1248   my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1249   my3DActor->Init(myVisualObj,myImplicitBoolean);
1250   my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1251
1252   my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1253   myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1254   //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1255
1256   my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1257   my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1258
1259   my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1260   my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1261   my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1262   my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1263     
1264   double aFactor, aUnits;
1265   my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1266   my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1267   my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1268   my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1269
1270   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1271   if( !mgr )
1272     return false;
1273
1274   //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1275   SetIsShrunkable(true);
1276
1277   SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1278
1279   int aMode = mgr->integerValue( "SMESH", "display_mode" );
1280   SetRepresentation(-1);
1281
1282   if(aMode == 0){
1283     SetRepresentation(eEdge);
1284   }else if(aMode == 1){
1285     SetRepresentation(eSurface);
1286   }else if(aMode == 2){
1287     SetRepresentation(ePoint);
1288   }
1289
1290   if(aMode == 3){
1291     SetShrink();
1292   }
1293
1294   if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1295     SetIsDisplayNameActor( true );
1296
1297   int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1298   int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 );  // 5 pixels
1299   SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1300
1301   myTimeStamp->Modified();
1302   Modified();
1303   return true;
1304 }
1305
1306
1307 double* SMESH_ActorDef::GetBounds()
1308 {
1309   if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1310     return myNodeActor->GetBounds();
1311   return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1312 }
1313
1314
1315 vtkDataSet* SMESH_ActorDef::GetInput()
1316 {
1317   return GetUnstructuredGrid();
1318 }
1319
1320
1321 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1322 {
1323   Superclass::SetTransform(theTransform);
1324
1325   myNodeActor->SetTransform(theTransform);
1326   myBaseActor->SetTransform(theTransform);
1327
1328   myHighlitableActor->SetTransform(theTransform);
1329
1330   myNodeExtActor->SetTransform(theTransform);
1331
1332   my0DActor->SetTransform(theTransform);
1333   myBallActor->SetTransform(theTransform);
1334   //my0DExtActor->SetTransform(theTransform);
1335
1336   my1DActor->SetTransform(theTransform);
1337   my1DExtActor->SetTransform(theTransform);
1338
1339   my2DActor->SetTransform(theTransform);
1340   my2DExtActor->SetTransform(theTransform);
1341   my3DActor->SetTransform(theTransform);
1342   my3DExtActor->SetTransform(theTransform);
1343
1344   Modified();
1345 }
1346
1347
1348 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1349 {
1350   vtkLODActor::SetMapper(theMapper);
1351 }
1352
1353
1354 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1355 {
1356   SALOME_Actor::ShallowCopy(prop);
1357 }
1358
1359
1360 vtkMapper* SMESH_ActorDef::GetMapper()
1361 {
1362   return myPickableActor->GetMapper();
1363 }
1364
1365
1366 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1367 {
1368   return myVisualObj->GetUnstructuredGrid();
1369 }
1370
1371
1372 bool SMESH_ActorDef::IsInfinitive()
1373 {
1374   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1375   myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1376     ( aDataSet->GetNumberOfCells() == 1 &&
1377     aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1378   return SALOME_Actor::IsInfinitive();
1379 }
1380
1381
1382 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1383 {
1384   if ( myIsShrinkable == theShrunkable )
1385     return;
1386   myIsShrinkable = theShrunkable;
1387   Modified();
1388 }
1389
1390 double SMESH_ActorDef::GetShrinkFactor()
1391 {
1392   return myBaseActor->GetShrinkFactor();
1393 }
1394
1395 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1396 {
1397   myBaseActor->SetShrinkFactor(theValue);
1398
1399   my1DActor->SetShrinkFactor(theValue);
1400   my1DExtActor->SetShrinkFactor(theValue);
1401
1402   my2DActor->SetShrinkFactor(theValue);
1403   my2DExtActor->SetShrinkFactor(theValue);
1404   my3DActor->SetShrinkFactor(theValue);
1405   my3DExtActor->SetShrinkFactor(theValue);
1406   my3DExtActor->SetShrinkFactor(theValue);
1407   myHighlitableActor->SetShrinkFactor(theValue);
1408
1409   Modified();
1410 }
1411
1412 void SMESH_ActorDef::SetShrink()
1413 {
1414   if(!myIsShrinkable) return;
1415
1416   myBaseActor->SetShrink();
1417
1418   my1DActor->SetShrink();
1419   my1DExtActor->SetShrink();
1420
1421   my2DActor->SetShrink();
1422   my2DExtActor->SetShrink();
1423   my3DActor->SetShrink();
1424   my3DExtActor->SetShrink();
1425   myHighlitableActor->SetShrink();
1426
1427   myIsShrunk = true;
1428   Modified();
1429 }
1430
1431 void SMESH_ActorDef::UnShrink()
1432 {
1433   if(!myIsShrunk) return;
1434
1435   myBaseActor->UnShrink();
1436
1437   my1DActor->UnShrink();
1438   my1DExtActor->UnShrink();
1439
1440   my2DActor->UnShrink();
1441   my2DExtActor->UnShrink();
1442   my3DActor->UnShrink();
1443   my3DExtActor->UnShrink();
1444   myHighlitableActor->UnShrink();
1445
1446   myIsShrunk = false;
1447   Modified();
1448 }
1449
1450
1451 vtkIdType SMESH_ActorDef::GetNodeObjId(vtkIdType theVtkID)
1452 {
1453   return myPickableActor->GetNodeObjId(theVtkID);
1454 }
1455
1456 double* SMESH_ActorDef::GetNodeCoord(vtkIdType theObjID)
1457 {
1458   return myPickableActor->GetNodeCoord(theObjID);
1459 }
1460
1461 vtkIdType SMESH_ActorDef::GetNodeVtkId(vtkIdType theObjID)
1462 {
1463   return myPickableActor->GetNodeVtkId(theObjID);
1464 }
1465
1466 vtkIdType SMESH_ActorDef::GetElemObjId(vtkIdType theVtkID)
1467 {
1468   return myPickableActor->GetElemObjId(theVtkID);
1469 }
1470
1471 vtkCell* SMESH_ActorDef::GetElemCell(vtkIdType theObjID)
1472 {
1473   return myPickableActor->GetElemCell(theObjID);
1474 }
1475
1476
1477 void SMESH_ActorDef::SetVisibility(int theMode)
1478 {
1479   SetVisibility(theMode,true);
1480 }
1481
1482
1483 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1484 {
1485   SALOME_Actor::SetVisibility(theMode);
1486
1487   myNodeActor->VisibilityOff();
1488   myBaseActor->VisibilityOff();
1489
1490   myNodeExtActor->VisibilityOff();
1491
1492   my0DActor->VisibilityOff();
1493   myBallActor->VisibilityOff();
1494   //my0DExtActor->VisibilityOff();
1495
1496   my1DActor->VisibilityOff();
1497   my1DExtActor->VisibilityOff();
1498
1499   my2DActor->VisibilityOff();
1500   my2DExtActor->VisibilityOff();
1501   my3DActor->VisibilityOff();
1502   my3DExtActor->VisibilityOff();
1503
1504   myScalarBarActor->VisibilityOff();
1505
1506   if ( GetVisibility() ) {
1507     if ( theIsUpdateRepersentation )
1508       SetRepresentation(GetRepresentation());
1509
1510     if(myControlMode != eNone) {
1511       switch(myControlMode) {
1512       case eFreeNodes:
1513       case eCoincidentNodes:
1514         myNodeExtActor->VisibilityOn();
1515         break;
1516       case eLength:
1517       case eMultiConnection:
1518         my1DActor->VisibilityOn();
1519         break;
1520       case eFreeEdges:
1521       case eFreeBorders:
1522       case eCoincidentElems1D:
1523       case eLength2D:
1524       case eMultiConnection2D:
1525         my1DExtActor->VisibilityOn();
1526         break;
1527       case eFreeFaces:
1528       case eBareBorderFace:
1529       case eOverConstrainedFace:
1530       case eCoincidentElems2D:
1531         my2DExtActor->VisibilityOn();
1532         break;
1533       case eBareBorderVolume:
1534       case eOverConstrainedVolume:
1535       case eCoincidentElems3D:
1536         my3DExtActor->VisibilityOn();
1537         break;
1538       default:;
1539       }
1540       if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1541         myScalarBarActor->VisibilityOn();
1542     }
1543
1544     if ( GetPickable( ))
1545       myPickableActor->VisibilityOn();
1546
1547     if ( GetRepresentation() != ePoint )
1548     {
1549       if(myEntityMode & e0DElements  ){
1550         my0DActor->VisibilityOn();
1551       }
1552       if(myEntityMode & eBallElem    ){
1553         myBallActor->VisibilityOn();
1554       }
1555       if(myEntityMode & eEdges && ( GetCellsLabeled() || // my1DActor shows labels only
1556                                     ( myControlActor == my1DActor && myControlMode != eNone ))){
1557         my1DActor->VisibilityOn();
1558       }
1559       if(myEntityMode & eFaces      ){
1560         my2DActor->VisibilityOn();
1561       }
1562       if(myEntityMode & eVolumes    ){
1563         my3DActor->VisibilityOn();
1564       }
1565     }
1566
1567     if(myNodeActor->GetPointsLabeled()) {
1568       myNodeActor->UpdateLabels();
1569       myNodeActor->VisibilityOn();
1570     }
1571     if(my0DActor)
1572       my0DActor->UpdateLabels();
1573
1574     if(myBallActor)
1575       myBallActor->UpdateLabels();
1576
1577     if(my1DActor)
1578       my1DActor->UpdateLabels();
1579
1580     if(my2DActor)
1581       my2DActor->UpdateLabels();
1582
1583     if(my3DActor)
1584       my3DActor->UpdateLabels();
1585   }
1586 #ifndef DISABLE_PLOT2DVIEWER
1587   else
1588     SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1589 #endif
1590   UpdateHighlight();
1591   Modified();
1592 }
1593
1594
1595 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1596 {
1597   unsigned int anObjectEntities = eAllEntity; // entities present in my object
1598
1599   if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1600     anObjectEntities &= ~e0DElements;
1601     theMode &= ~e0DElements;
1602   }
1603
1604   if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1605     anObjectEntities &= ~eBallElem;
1606     theMode &= ~eBallElem;
1607   }
1608
1609   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1610     anObjectEntities &= ~eEdges;
1611     theMode &= ~eEdges;
1612   }
1613
1614   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1615     anObjectEntities &= ~eFaces;
1616     theMode &= ~eFaces;
1617   }
1618
1619   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1620     anObjectEntities &= ~eVolumes;
1621     theMode &= ~eVolumes;
1622   }
1623
1624   if (!theMode) {
1625     if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1626       theMode |= e0DElements;
1627
1628     if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1629       theMode |= eBallElem;
1630
1631     if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1632       theMode |= eEdges;
1633
1634     if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1635       theMode |= eFaces;
1636
1637     if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1638       theMode |= eVolumes;
1639   }
1640
1641   // rnv : Fix volume selection on Display Entity
1642   //myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1643
1644   if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1645   {
1646     myRepresentationCache = GetRepresentation();
1647     SetRepresentation( ePoint );
1648   }
1649
1650   if ( myEntityMode != theMode )
1651   {
1652     myEntityMode = theMode; // entities to show
1653
1654     // Set cell types to extract
1655     UpdateFilter();
1656   }
1657
1658   SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1659 }
1660
1661 void SMESH_ActorDef::SetRepresentation (int theMode)
1662 {
1663   smIdType aNbEdges   = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1664   smIdType aNbFaces   = myVisualObj->GetNbEntities(SMDSAbs_Face);
1665   smIdType aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1666   smIdType aNb0Ds     = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1667   smIdType aNbBalls   = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1668
1669   if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1670   {
1671     theMode = myRepresentationCache;
1672     if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1673       theMode = eEdge;
1674     else
1675       myRepresentationCache = 0;
1676   }
1677
1678   if (theMode < 0) {
1679     myRepresentation = eSurface;
1680     if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1681       myRepresentation = eEdge;
1682     } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1683       myRepresentation = ePoint;
1684     }
1685   } else {
1686     switch (theMode) {
1687     case eEdge:
1688       if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1689       break;
1690     case eSurface:
1691       if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1692       break;
1693     }
1694     myRepresentation = theMode;
1695   }
1696
1697   if (!GetUnstructuredGrid()->GetNumberOfCells())
1698     myRepresentation = ePoint;
1699
1700   if (myIsShrunk) {
1701     if (myRepresentation == ePoint) {
1702       UnShrink();
1703       myIsShrunk = true;
1704     } else {
1705       SetShrink();
1706     }
1707   }
1708
1709   myPickableActor = myBaseActor;
1710   vtkProperty *aProp = NULL, *aBackProp = NULL;
1711   vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1712   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::eNoneRepr;
1713   SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1714   switch (myRepresentation) {
1715   case ePoint:
1716     myPickableActor = myNodeActor;
1717     aQuadraticMode = SMESH_Actor::eLines;
1718     aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1719     aReperesent = SMESH_DeviceActor::ePoint;
1720     break;
1721   case eEdge:
1722     aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1723     aReperesent = SMESH_DeviceActor::eInsideframe;
1724     break;
1725   case eSurface:
1726     aProp = mySurfaceProp;
1727     aBackProp = myBackSurfaceProp;
1728     aPropVN = myNormalVProp;
1729     aPropVR = myReversedVProp;
1730     aReperesent = SMESH_DeviceActor::eSurface;
1731     break;
1732   }
1733
1734   if ( myRepresentation != ePoint )
1735   {
1736     my2DActor->SetProperty(aProp);
1737     my2DActor->SetBackfaceProperty(aBackProp);
1738     my2DActor->SetRepresentation(aReperesent);
1739
1740     if(aQuadraticMode == SMESH_Actor::eLines)
1741       my2DActor->SetQuadraticArcMode(false);
1742     else if(aQuadraticMode == SMESH_Actor::eArcs)
1743       my2DActor->SetQuadraticArcMode(true);
1744
1745     my2DExtActor->SetRepresentation(aReperesent);
1746
1747     my3DActor->SetProperty(aPropVN);
1748     my3DActor->SetBackfaceProperty(aPropVR);
1749     my3DActor->SetRepresentation(aReperesent);
1750
1751     my0DActor->SetRepresentation(aReperesent);
1752     myBallActor->SetRepresentation(aReperesent);
1753
1754     switch ( myControlMode ) {
1755     case eLength:
1756     case eMultiConnection:
1757       aProp = aBackProp = my1DProp;
1758       if ( myRepresentation != ePoint )
1759         aReperesent = SMESH_DeviceActor::eInsideframe;
1760       break;
1761     case eCustomControl:
1762       if ( myControlActor == my1DActor )
1763         aProp = aBackProp = my1DProp;
1764       if ( myRepresentation != ePoint )
1765         aReperesent = SMESH_DeviceActor::eInsideframe;
1766       break;
1767     default:;
1768     }
1769
1770     if(aQuadraticMode == SMESH_Actor::eLines)
1771       my1DActor->SetQuadraticArcMode(false);
1772     else if(aQuadraticMode == SMESH_Actor::eArcs)
1773       my1DActor->SetQuadraticArcMode(true);
1774
1775     my1DActor->SetProperty(aProp);
1776     my1DActor->SetBackfaceProperty(aBackProp);
1777     my1DActor->SetRepresentation(aReperesent);
1778
1779     my1DExtActor->SetRepresentation(aReperesent);
1780   }
1781
1782   if(myIsPointsVisible)
1783     myPickableActor = myNodeActor;
1784
1785   SetMapper(myPickableActor->GetMapper());
1786
1787   SetVisibility(GetVisibility(),false);
1788
1789   Modified();
1790 }
1791
1792
1793 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1794 {
1795   if ( myIsPointsVisible == theIsPointsVisible )
1796     return;
1797   myIsPointsVisible = theIsPointsVisible;
1798   SetRepresentation(GetRepresentation());
1799 }
1800
1801 bool SMESH_ActorDef::GetPointRepresentation()
1802 {
1803   return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1804 }
1805
1806
1807 void SMESH_ActorDef::UpdateHighlight()
1808 {
1809   myHighlitableActor->SetHighlited(false);
1810   myHighlitableActor->SetVisibility(false);
1811   bool anIsVisible = GetVisibility();
1812
1813   switch(myRepresentation){
1814   case SMESH_DeviceActor::eSurface:
1815   case SMESH_DeviceActor::eWireframe:
1816     {
1817       if(myIsHighlighted) {
1818         myHighlitableActor->SetProperty(myHighlightProp);
1819       }else if(myIsPreselected){
1820         myHighlitableActor->SetProperty(myPreselectProp);
1821       } else if(anIsVisible){
1822         (myRepresentation == eSurface) ?
1823           myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1824       }
1825       if(GetUnstructuredGrid()->GetNumberOfCells()) {
1826         myHighlitableActor->SetHighlited(anIsVisible);
1827         myHighlitableActor->GetExtractUnstructuredGrid()->
1828           SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1829         myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1830       }
1831       myHighlitableActor->SetVisibility(anIsVisible);
1832       break;
1833     }
1834   case SMESH_DeviceActor::ePoint:
1835     {
1836       if(myIsHighlighted) {
1837         myNodeActor->SetProperty(myHighlightProp);
1838       }else if(myIsPreselected) {
1839         myNodeActor->SetProperty(myPreselectProp);
1840       } else if(anIsVisible) {
1841         myNodeActor->SetProperty(myNodeProp);
1842       }
1843       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1844       myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1845       myNodeActor->GetProperty()->Modified();
1846       break;
1847     }
1848   }
1849 }
1850
1851 void SMESH_ActorDef::EnableSelection( bool enable )
1852 {
1853   // selection in the Viewer enabled/disabled
1854   if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1855   {
1856     myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1857     //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1858     myBaseActor->myExtractUnstructuredGrid->Update();
1859     //myHighlitableActor->myExtractUnstructuredGrid->Update();
1860   }
1861   if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1862   {
1863     myBaseActor->SetUnstructuredGrid( NULL );
1864     //myHighlitableActor->SetUnstructuredGrid( NULL );
1865     myBaseActor->myExtractUnstructuredGrid->Update();
1866     //myHighlitableActor->myExtractUnstructuredGrid->Update();
1867   }
1868 }
1869
1870 void SMESH_ActorDef::highlight(bool theHighlight)
1871 {
1872   if ( myIsHighlighted == theHighlight )
1873     return;
1874   myIsHighlighted = theHighlight;
1875   UpdateHighlight();
1876 }
1877
1878
1879 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1880 {
1881   if ( myIsPreselected == thePreselect )
1882     return;
1883   myIsPreselected = thePreselect;
1884   UpdateHighlight();
1885 }
1886
1887
1888 // From vtkFollower
1889 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1890 {
1891   if (myPickableActor->GetIsOpaque())
1892   {
1893     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1894     this->Render(ren);
1895     return 1;
1896   }
1897   return 0;
1898 }
1899
1900
1901 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1902 {
1903   if (!myPickableActor->GetIsOpaque())
1904   {
1905     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1906     this->Render(ren);
1907     return 1;
1908   }
1909   return 0;
1910 }
1911
1912
1913 void SMESH_ActorDef::Render(vtkRenderer* /*ren*/)
1914 {
1915   vtkMTimeType aTime = myTimeStamp->GetMTime();
1916   vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1917   vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1918   if(anObjTime > aTime || aClippingTime > aTime)
1919     Update();
1920 }
1921
1922
1923 void SMESH_ActorDef::Update()
1924 {
1925   MESSAGE("SMESH_ActorDef::Update");
1926
1927   myVisualObj->Update();
1928
1929   if(GetControlMode() != eNone) {
1930     unsigned long aTime = myTimeStamp->GetMTime();
1931     unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1932     if (anObjTime > aTime)
1933       SetControlMode(GetControlMode(),false);
1934   }
1935
1936   if(myNodeActor)
1937     myNodeActor->UpdateLabels();
1938
1939   if(my0DActor)
1940     my0DActor->UpdateLabels();
1941
1942   if(myBallActor)
1943     myBallActor->UpdateLabels();
1944
1945   if(my1DActor)
1946     my1DActor->UpdateLabels();
1947
1948   if(my2DActor)
1949     my2DActor->UpdateLabels();
1950
1951   if(my3DActor)
1952     my3DActor->UpdateLabels();
1953
1954   if(myIsFacesOriented){
1955     SetFacesOriented(myIsFacesOriented);
1956   }
1957
1958   // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
1959   //   myEntityMode |= myVisualObj->GetEntitiesState();
1960   // }
1961
1962   SetEntityMode(GetEntityMode());
1963   SetVisibility(GetVisibility());
1964
1965   myTimeStamp->Modified();
1966   Modified();
1967 }
1968
1969
1970 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
1971 {
1972   SALOME_Actor::ReleaseGraphicsResources(renWin);
1973
1974   myPickableActor->ReleaseGraphicsResources(renWin);
1975 }
1976
1977
1978 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
1979 {
1980   double* aColor = theProperty->GetColor();
1981   r = aColor[0];
1982   g = aColor[1];
1983   b = aColor[2];
1984 }
1985
1986
1987 void SMESH_ActorDef::SetOpacity(double theValue)
1988 {
1989   mySurfaceProp->SetOpacity(theValue);
1990   myBackSurfaceProp->SetOpacity(theValue);
1991   myNormalVProp->SetOpacity(theValue);
1992   myReversedVProp->SetOpacity(theValue);
1993   myEdgeProp->SetOpacity(theValue);
1994   myOutLineProp->SetOpacity(theValue);
1995   myNodeProp->SetOpacity(theValue);
1996
1997   my1DProp->SetOpacity(theValue);
1998   my0DProp->SetOpacity(theValue);
1999   myBallProp->SetOpacity(theValue);
2000 }
2001
2002
2003 double SMESH_ActorDef::GetOpacity()
2004 {
2005   return mySurfaceProp->GetOpacity();
2006 }
2007
2008
2009 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2010 {
2011   mySurfaceProp->SetColor(r,g,b);
2012   my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2013   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2014     if( aGroupObj->GetElementType() == SMDSAbs_Face )
2015       myNameActor->SetBackgroundColor(r,g,b);
2016
2017   myDeltaBrightness = delta;
2018   QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2019   myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2020   Modified();
2021 }
2022
2023 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2024 {
2025   ::GetColor(mySurfaceProp,r,g,b);
2026   delta = myDeltaBrightness;
2027 }
2028
2029 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2030 {
2031   myNormalVProp->SetColor(r,g,b);
2032   my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2033   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2034     if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2035       myNameActor->SetBackgroundColor(r,g,b);
2036
2037   myDeltaVBrightness = delta;
2038   QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2039   myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2040   Modified();
2041 }
2042
2043 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2044 {
2045   ::GetColor(myNormalVProp,r,g,b);
2046   delta = myDeltaVBrightness;
2047 }
2048
2049 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2050 {
2051   myEdgeProp->SetColor(r,g,b);
2052   my1DProp->SetColor(r,g,b);
2053   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2054   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2055     if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2056       myNameActor->SetBackgroundColor(r,g,b);
2057   Modified();
2058 }
2059
2060 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2061 {
2062   ::GetColor(myEdgeProp,r,g,b);
2063 }
2064
2065 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2066 {
2067   myOutLineProp->SetColor(r,g,b);
2068   Modified();
2069 }
2070
2071 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2072 {
2073   ::GetColor(myOutLineProp,r,g,b);
2074 }
2075
2076
2077 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2078
2079   myNodeProp->SetColor(r,g,b);
2080   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2081   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2082     if( aGroupObj->GetElementType() == SMDSAbs_Node )
2083       myNameActor->SetBackgroundColor(r,g,b);
2084   Modified();
2085 }
2086
2087 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2088
2089   ::GetColor(myNodeProp,r,g,b);
2090 }
2091
2092 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2093
2094   my0DProp->SetColor(r,g,b);
2095   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2096     if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2097       myNameActor->SetBackgroundColor(r,g,b);
2098   Modified();
2099 }
2100
2101 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2102
2103   ::GetColor(my0DProp,r,g,b);
2104 }
2105
2106 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2107
2108   myBallProp->SetColor(r,g,b);
2109   if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2110     if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2111       myNameActor->SetBackgroundColor(r,g,b);
2112   Modified();
2113 }
2114
2115 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2116
2117   ::GetColor(myBallProp,r,g,b);
2118 }
2119
2120 void SMESH_ActorDef::UpdateSelectionProps()
2121 {
2122   QColor selectionColor = SMESH_ActorProps::props()->selectionColor();
2123   QColor highlightColor = SMESH_ActorProps::props()->highlightColor();
2124   float  selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2125   float  width = (float) GetLineWidth();
2126   myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF());
2127   myHighlightProp->SetLineWidth(width + selectionIncrement);
2128   myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF());
2129   myPreselectProp->SetLineWidth(width + selectionIncrement);
2130   Modified();
2131 }
2132
2133 double SMESH_ActorDef::GetLineWidth()
2134 {
2135   return myEdgeProp->GetLineWidth();
2136 }
2137
2138
2139 void SMESH_ActorDef::SetLineWidth(double theVal)
2140 {
2141   float  controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
2142   float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2143
2144   myEdgeProp->SetLineWidth((float) theVal);
2145
2146   my1DProp       ->SetLineWidth((float) theVal + controlsIncrement);
2147   my1DExtProp    ->SetLineWidth((float) theVal + controlsIncrement);
2148   my2DExtProp    ->SetLineWidth((float) theVal + controlsIncrement);
2149   my3DExtProp    ->SetLineWidth((float) theVal + controlsIncrement);
2150   myHighlightProp->SetLineWidth((float) theVal + selectionIncrement);
2151   myPreselectProp->SetLineWidth((float) theVal + selectionIncrement);
2152   Modified();
2153 }
2154
2155 double SMESH_ActorDef::GetOutlineWidth()
2156 {
2157   return myOutLineProp->GetLineWidth();
2158 }
2159
2160 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2161 {
2162   myOutLineProp->SetLineWidth((float) theVal);
2163   Modified();
2164 }
2165
2166 void SMESH_ActorDef::Set0DSize(double theVal)
2167 {
2168   my0DProp       ->SetPointSize((float) theVal);
2169   myHighlightProp->SetPointSize((float) theVal);
2170   myPreselectProp->SetPointSize((float) theVal);
2171
2172   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2173     aCustom->Set0DSize((float) theVal);
2174   }
2175   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2176     aCustom->Set0DSize((float) theVal);
2177   }
2178
2179   Modified();
2180 }
2181
2182 double SMESH_ActorDef::Get0DSize()
2183 {
2184   return my0DProp->GetPointSize();
2185 }
2186
2187 void SMESH_ActorDef::SetBallSize(double theVal)
2188 {
2189   myBallProp->SetPointSize((float) theVal);
2190
2191   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2192     aCustom->SetBallSize((float) theVal);
2193   }
2194   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2195     aCustom->SetBallSize((float) theVal);
2196   }
2197
2198   Modified();
2199 }
2200
2201 double SMESH_ActorDef::GetBallSize()
2202 {
2203   return myBallProp->GetPointSize();
2204 }
2205
2206 double SMESH_ActorDef::GetBallScale()
2207 {
2208   return myBallActor->GetBallScale();
2209 }
2210
2211 void SMESH_ActorDef::SetBallScale( double theVal )
2212 {
2213   myBallActor->SetBallScale( theVal );
2214   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2215     aCustom->SetBallScale(theVal);
2216   }
2217   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2218     aCustom->SetBallScale(theVal);
2219   }
2220
2221   Modified();
2222 }
2223
2224 int SMESH_ActorDef::GetObjDimension( const vtkIdType theObjId )
2225 {
2226   return myVisualObj->GetElemDimension( theObjId );
2227 }
2228
2229 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2230 {
2231   return myBaseActor->IsImplicitFunctionUsed();
2232 }
2233
2234 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2235 {
2236   myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2237   myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2238
2239   myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2240
2241   myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2242
2243   my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2244   myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2245   //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2246
2247   my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2248   my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2249
2250   my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2251   my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2252   my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2253   my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2254 }
2255
2256 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2257 {
2258   if(thePlane){
2259     myImplicitBoolean->GetFunction()->AddItem(thePlane);
2260     myCippingPlaneCont.push_back(thePlane);
2261     if(!IsImplicitFunctionUsed())
2262       SetImplicitFunctionUsed(true);
2263     myNodeActor->UpdateLabels();
2264   }
2265   return myCippingPlaneCont.size();
2266 }
2267
2268 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2269 {
2270   if(thePlane)
2271     myPlaneCollection->AddItem( thePlane );
2272 }
2273
2274 void SMESH_ActorDef::SetOpenGLClippingPlane()
2275 {
2276   // before use this method you must add clipping planes using method
2277   // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2278   if( !myPlaneCollection->GetNumberOfItems() )
2279     return;
2280
2281   // It is necessary to set plane collection for each mapper of actor
2282   // and update current inputs of mapper
2283   myNodeActor->SetPlaneCollection( myPlaneCollection );
2284   myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2285
2286   myBaseActor->SetPlaneCollection( myPlaneCollection );
2287   myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2288
2289   myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2290   myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2291
2292   if ( !mySelector || !mySelector->IsSelectionEnabled() )
2293   {
2294     myBaseActor->SetUnstructuredGrid( NULL );
2295     //myHighlitableActor->SetUnstructuredGrid( NULL );
2296   }
2297   my1DActor->SetPlaneCollection( myPlaneCollection );
2298   my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2299
2300   my2DActor->SetPlaneCollection( myPlaneCollection );
2301   my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2302
2303   myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2304   myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2305
2306   my0DActor->SetPlaneCollection( myPlaneCollection );
2307   my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2308
2309   myBallActor->SetPlaneCollection( myPlaneCollection );
2310   myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2311
2312   my1DExtActor->SetPlaneCollection( myPlaneCollection );
2313   my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2314
2315   my2DExtActor->SetPlaneCollection( myPlaneCollection );
2316   my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2317
2318   my3DActor->SetPlaneCollection( myPlaneCollection );
2319   my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2320
2321   my3DExtActor->SetPlaneCollection( myPlaneCollection );
2322   my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2323
2324   if(IsShrunk())
2325     SetShrink();
2326   else  
2327     Modified();
2328 }
2329
2330 void SMESH_ActorDef::RemoveAllClippingPlanes()
2331 {
2332   myPlaneCollection->RemoveAllItems();
2333   myImplicitBoolean->GetFunction()->RemoveAllItems();
2334   myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2335   myCippingPlaneCont.clear();
2336   SetImplicitFunctionUsed(false);
2337   myNodeActor->UpdateLabels();
2338 }
2339
2340 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2341 {
2342   return myCippingPlaneCont.size();
2343 }
2344
2345 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2346 {
2347   if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2348     return NULL;
2349   return myCippingPlaneCont[theID].Get();
2350 }
2351
2352 void SMESH_ActorDef::UpdateScalarBar()
2353 {
2354   SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2355   if( !mgr )
2356     return;
2357
2358   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2359
2360   QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2361   aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2362
2363   aScalarBarTitleProp->SetFontFamilyToArial();
2364
2365   if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2366   {
2367     QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2368     if ( f.family() == "Arial" )
2369       aScalarBarTitleProp->SetFontFamilyToArial();
2370     else if ( f.family() == "Courier" )
2371       aScalarBarTitleProp->SetFontFamilyToCourier();
2372     else if ( f.family() == "Times" )
2373       aScalarBarTitleProp->SetFontFamilyToTimes();
2374
2375     if ( f.bold() )
2376       aScalarBarTitleProp->BoldOn();
2377     else
2378       aScalarBarTitleProp->BoldOff();
2379
2380     if ( f.italic() )
2381       aScalarBarTitleProp->ItalicOn();
2382     else
2383      aScalarBarTitleProp->ItalicOff();
2384
2385     if ( f.overline() )
2386       aScalarBarTitleProp->ShadowOn();
2387     else
2388       aScalarBarTitleProp->ShadowOff();
2389   }
2390
2391   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2392   aScalarBarTitleProp->Delete();
2393
2394   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2395
2396   aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2397   aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2398
2399   aScalarBarLabelProp->SetFontFamilyToArial();
2400   if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2401   {
2402     QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2403     if( f.family() == "Arial" )
2404       aScalarBarLabelProp->SetFontFamilyToArial();
2405     else if( f.family() == "Courier" )
2406       aScalarBarLabelProp->SetFontFamilyToCourier();
2407     else if( f.family() == "Times" )
2408       aScalarBarLabelProp->SetFontFamilyToTimes();
2409
2410     if ( f.bold() )
2411       aScalarBarLabelProp->BoldOn();
2412     else
2413       aScalarBarLabelProp->BoldOff();
2414
2415     if ( f.italic() )
2416       aScalarBarLabelProp->ItalicOn();
2417     else
2418       aScalarBarLabelProp->ItalicOff();
2419
2420     if( f.overline() )
2421       aScalarBarLabelProp->ShadowOn();
2422     else
2423       aScalarBarLabelProp->ShadowOff();
2424   }
2425
2426   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2427   aScalarBarLabelProp->Delete();
2428
2429   bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2430   QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2431   if( horiz )
2432     myScalarBarActor->SetOrientationToHorizontal();
2433   else
2434     myScalarBarActor->SetOrientationToVertical();
2435
2436
2437   double aXVal = horiz ? 0.20 : 0.01;
2438   if( mgr->hasValue( "SMESH", name + "x" ) )
2439     aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2440
2441   double aYVal = horiz ? 0.01 : 0.1;
2442   if( mgr->hasValue( "SMESH", name + "y" ) )
2443     aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2444   myScalarBarActor->SetPosition( aXVal, aYVal );
2445
2446   double aWVal = horiz ? 0.60 : 0.10;
2447   if( mgr->hasValue( "SMESH", name + "width" ) )
2448     aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2449   myScalarBarActor->SetWidth( aWVal );
2450
2451   double aHVal = horiz ? 0.12 : 0.80;
2452   if( mgr->hasValue( "SMESH", name + "height" ) )
2453     aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2454   myScalarBarActor->SetHeight( aHVal );
2455
2456   int anIntVal = 5;
2457   if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2458     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2459   myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2460
2461   anIntVal = 64;
2462   if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2463     anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2464   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2465
2466   bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2467   myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2468
2469   int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2470   myScalarBarActor->SetDistributionColoringType(coloringType);
2471
2472   QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2473                                              QColor(255, 255, 255));
2474   double rgb[3];
2475   rgb[0]= distributionColor.red()/255.;
2476   rgb[1]= distributionColor.green()/255.;
2477   rgb[2]= distributionColor.blue()/255.;
2478   myScalarBarActor->SetDistributionColor(rgb);
2479
2480
2481 }
2482
2483 void SMESH_ActorDef::UpdateDistribution()
2484 {
2485   if(SMESH::Controls::NumericalFunctor* fun =
2486      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2487   {
2488     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2489     std::vector<int> nbEvents;
2490     std::vector<double> funValues;
2491     SMESH_VisualObjDef::TEntityList elems;
2492     if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2493       dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2494     std::vector<smIdType> elemIds; elemIds.reserve( elems.size() );
2495     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2496       elemIds.push_back( (*e)->GetID());
2497     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2498     double * range = lookupTable->GetRange();
2499     bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2500     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2501     myScalarBarActor->SetDistribution(nbEvents);
2502   }
2503 }
2504
2505 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2506 {
2507   switch(theMode) {
2508   case SMESH_Actor::eLines :
2509     myHighlitableActor->SetQuadraticArcMode(false);
2510     my2DActor->SetQuadraticArcMode(false);
2511     my1DActor->SetQuadraticArcMode(false);
2512     break;
2513   case SMESH_Actor::eArcs :
2514     myHighlitableActor->SetQuadraticArcMode(true);
2515     if(GetRepresentation() != SMESH_Actor::ePoint) {
2516       my2DActor->SetQuadraticArcMode(true);
2517       my1DActor->SetQuadraticArcMode(true);
2518     }
2519     break;
2520   default:
2521     break;
2522   }
2523 }
2524
2525
2526 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2527 {
2528   if(myHighlitableActor->GetQuadraticArcMode())
2529     return SMESH_Actor::eArcs;
2530   else
2531     return SMESH_Actor::eLines;
2532 }
2533
2534 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2535 {
2536   SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2537   myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2538   myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2539 }
2540
2541 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2542 {
2543   SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2544   myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2545   myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2546   myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2547 }
2548
2549 void SMESH_ActorDef::UpdateFilter()
2550 {
2551   unsigned int anObjectEntities = eAllEntity; // entities present in my object
2552
2553   if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
2554     anObjectEntities &= ~e0DElements;
2555   }
2556
2557   if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
2558     anObjectEntities &= ~eBallElem;
2559   }
2560
2561   if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
2562     anObjectEntities &= ~eEdges;
2563   }
2564
2565   if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
2566     anObjectEntities &= ~eFaces;
2567   }
2568
2569   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
2570     anObjectEntities &= ~eVolumes;
2571   }
2572
2573   VTKViewer_ExtractUnstructuredGrid*    aFilter = myBaseActor->GetExtractUnstructuredGrid();
2574   VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
2575   aFilter->ClearRegisteredCellsWithType();
2576   aHltFilter->ClearRegisteredCellsWithType();
2577
2578   bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
2579   if ( isPassAll )
2580   {
2581     aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2582     aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2583   }
2584   else
2585   {
2586     aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2587     aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2588     if (myEntityMode & e0DElements) {
2589       aFilter->RegisterCellsWithType(VTK_VERTEX);
2590       aHltFilter->RegisterCellsWithType(VTK_VERTEX);
2591     }
2592
2593     if (myEntityMode & eBallElem) {
2594       aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
2595     }
2596     if (myEntityMode & eEdges) {
2597       aFilter->RegisterCellsWithType(VTK_LINE);
2598       aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2599       aHltFilter->RegisterCellsWithType(VTK_LINE);
2600       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2601     }
2602
2603     if (myEntityMode & eFaces) {
2604       aFilter->RegisterCellsWithType(VTK_TRIANGLE);
2605       aFilter->RegisterCellsWithType(VTK_QUAD);
2606       aFilter->RegisterCellsWithType(VTK_POLYGON);
2607       aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2608       aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2609       aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2610       aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2611       aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2612       aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
2613       aHltFilter->RegisterCellsWithType(VTK_QUAD);
2614       aHltFilter->RegisterCellsWithType(VTK_POLYGON);
2615       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2616       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2617       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2618       aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2619       aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2620     }
2621
2622     if (myEntityMode & eVolumes) {
2623       aFilter->RegisterCellsWithType(VTK_TETRA);
2624       aFilter->RegisterCellsWithType(VTK_VOXEL);
2625       aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2626       aFilter->RegisterCellsWithType(VTK_WEDGE);
2627       aFilter->RegisterCellsWithType(VTK_PYRAMID);
2628       aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2629       aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2630       aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2631       aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2632       aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2633       aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2634       aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2635       aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2636       aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2637       aHltFilter->RegisterCellsWithType(VTK_TETRA);
2638       aHltFilter->RegisterCellsWithType(VTK_VOXEL);
2639       aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2640       aHltFilter->RegisterCellsWithType(VTK_WEDGE);
2641       aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
2642       aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2643       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2644       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2645       aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2646       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2647       aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2648       aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2649       aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2650       aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2651     }
2652   }
2653   if ( GetVisibility() )
2654     aFilter->Update();
2655   MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
2656 }
2657
2658 #ifndef DISABLE_PLOT2DVIEWER
2659 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2660 {
2661   if(my2dHistogram)
2662     my2dHistogram->clearAllPoints();
2663
2664   if(SMESH::Controls::NumericalFunctor* fun =
2665      dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2666   {
2667
2668     if(!my2dHistogram) {
2669       my2dHistogram = new SPlot2d_Histogram();
2670       Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2671       my2dHistogram->setIO(anIO);
2672     }
2673
2674     int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2675     std::vector<int> nbEvents;
2676     std::vector<double> funValues;
2677     SMESH_VisualObjDef::TEntityList elems;
2678     if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2679       dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2680     std::vector<smIdType> elemIds;
2681
2682     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2683       elemIds.push_back( (*e)->GetID());
2684
2685     vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2686     double * range = lookupTable->GetRange();
2687     bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2688     fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2689
2690     for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2691       my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2692
2693     if(funValues.size() >= 2)
2694       my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2695
2696   }
2697
2698   //Color of the histogram
2699   if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2700     my2dHistogram->setAutoAssign(true);
2701   else {
2702     double rgb[3];
2703     myScalarBarActor->GetDistributionColor(rgb);
2704     QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2705     my2dHistogram->setColor(aColor);
2706
2707   }
2708
2709   return my2dHistogram;
2710 }
2711 #endif