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