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