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