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