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