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