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