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