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