Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
1 //  SMESH OBJECT : interactive object for SMESH visualization
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Actor.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29
30 #include "SMESH_Actor.h"
31 #include "SMESH_DeviceActor.h"
32 #include "SALOME_ExtractUnstructuredGrid.h"
33
34 #include "QAD_Config.h"
35 #include "utilities.h"
36 #include <qstringlist.h>
37
38 #include <vtkObjectFactory.h>
39 #include <vtkShrinkPolyData.h>
40 #include <vtkMergeFilter.h>
41
42 #include <vtkActor2D.h>
43 #include <vtkPolyData.h>
44 #include <vtkMaskPoints.h>
45 #include <vtkCellCenters.h>
46 #include <vtkTextProperty.h>
47 #include <vtkLabeledDataMapper.h>
48 #include <vtkSelectVisiblePoints.h>
49
50 #include <vtkScalarBarActor.h>
51 #include <vtkLookupTable.h>
52 #include <vtkDoubleArray.h>
53
54 #ifdef _DEBUG_
55 static int MYDEBUG = 1;
56 static int MYDEBUGWITHFILES = 0;
57 #else
58 static int MYDEBUG = 0;
59 static int MYDEBUGWITHFILES = 0;
60 #endif
61
62 using namespace std;
63
64
65 inline float GetFloat(const QString& theValue, float theDefault = 0){
66   if(theValue.isEmpty()) return theDefault;
67   QString aValue = QAD_CONFIG->getSetting(theValue);
68   if(aValue.isEmpty()) return theDefault;
69   return aValue.toFloat();
70 }
71
72
73 SMESH_Actor* SMESH_Actor::New(){
74   return new SMESH_Actor();
75 }
76
77
78 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, 
79                               SMESH::FilterManager_ptr theFilterMgr,
80                               const char* theEntry, 
81                               const char* theName,
82                               int theIsClear)
83 {
84   SMESH_Actor* anActor = SMESH_Actor::New();
85   anActor->Init(theVisualObj,theFilterMgr,theEntry,theName,theIsClear);
86   return anActor;
87 }
88
89
90 SMESH_Actor::SMESH_Actor(){
91   if(MYDEBUG) MESSAGE("SMESH_Actor");
92
93   myIsPointsVisible = false;
94
95   myIsShrinkable = false;
96   myIsShrunk = false;
97
98   float aPointSize = GetFloat("SMESH:SettingsNodesSize",3);
99   float aLineWidth = GetFloat("SMESH:SettingsWidth",1);
100
101   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
102   SALOME_ExtractUnstructuredGrid* aFilter = NULL;
103
104   //Definition 2D and 3D divices of the actor
105   //-----------------------------------------
106   float anRGB[3] = {1,1,1};
107   mySurfaceProp = vtkProperty::New();
108   anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
109   anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
110   anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
111   mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
112
113   myBackSurfaceProp = vtkProperty::New();
114   anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
115   anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
116   anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
117   myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
118
119   my2DActor = SMESH_DeviceActor::New();
120   my2DActor->SetUserMatrix(aMatrix);
121   my2DActor->SetStoreMapping(true);
122   my2DActor->PickableOff();
123   my2DActor->SetProperty(mySurfaceProp);
124   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
125   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
126   aFilter = my2DActor->GetExtractUnstructuredGrid();
127   aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
128   aFilter->RegisterCellsWithType(VTK_TRIANGLE);
129   aFilter->RegisterCellsWithType(VTK_POLYGON);
130   aFilter->RegisterCellsWithType(VTK_QUAD);
131
132   my3DActor = SMESH_DeviceActor::New();
133   my3DActor->SetUserMatrix(aMatrix);
134   my3DActor->SetStoreMapping(true);
135   my3DActor->PickableOff();
136   my3DActor->SetProperty(mySurfaceProp);
137   my3DActor->SetBackfaceProperty(myBackSurfaceProp);
138   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
139   aFilter = my3DActor->GetExtractUnstructuredGrid();
140   aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
141   aFilter->RegisterCellsWithType(VTK_TETRA);
142   aFilter->RegisterCellsWithType(VTK_VOXEL);
143   aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
144   aFilter->RegisterCellsWithType(VTK_WEDGE);
145   aFilter->RegisterCellsWithType(VTK_PYRAMID);
146
147
148   //Definition 1D divice of the actor
149   //---------------------------------
150   myEdgeProp = vtkProperty::New();
151   myEdgeProp->SetAmbient(1.0);
152   myEdgeProp->SetDiffuse(0.0);
153   myEdgeProp->SetSpecular(0.0);
154   anRGB[0] = GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.;
155   anRGB[1] = GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.;
156   anRGB[2] = GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.;
157   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
158   myEdgeProp->SetLineWidth(aLineWidth);
159
160   my1DActor = SMESH_DeviceActor::New();
161   my1DActor->SetUserMatrix(aMatrix);
162   my1DActor->SetStoreMapping(true);
163   my1DActor->PickableOff();
164   my1DActor->SetProperty(myEdgeProp);
165   my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
166   aFilter = my1DActor->GetExtractUnstructuredGrid();
167   aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
168   aFilter->RegisterCellsWithType(VTK_LINE);
169
170   my1DProp = vtkProperty::New();
171   my1DProp->DeepCopy(myEdgeProp);
172   static int aCotnrolLineWidth = 3;
173   my1DProp->SetLineWidth(aCotnrolLineWidth);
174   my1DProp->SetPointSize(aPointSize);
175
176   my1DExtProp = vtkProperty::New();
177   my1DExtProp->DeepCopy(myEdgeProp);
178   anRGB[0] = 1 - anRGB[0];
179   anRGB[1] = 1 - anRGB[1];
180   anRGB[2] = 1 - anRGB[2];
181   my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
182   my1DExtProp->SetLineWidth(aCotnrolLineWidth);
183
184   my1DExtActor = SMESH_DeviceActor::New();
185   my1DExtActor->SetUserMatrix(aMatrix);
186   my1DExtActor->SetStoreMapping(true);
187   my1DExtActor->PickableOff();
188   my1DExtActor->SetVisibility(false);
189   my1DExtActor->SetProperty(my1DExtProp);
190   my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
191   aFilter = my1DExtActor->GetExtractUnstructuredGrid();
192   aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
193   aFilter->RegisterCellsWithType(VTK_LINE);
194
195
196   //Definition 0D divice of the actor
197   //---------------------------------
198   myNodeProp = vtkProperty::New();
199   anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",255)/255.;
200   anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",0)/255.;
201   anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
202   myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
203   myNodeProp->SetPointSize(aPointSize);
204
205   myNodeActor = SMESH_DeviceActor::New();
206   myNodeActor->SetUserMatrix(aMatrix);
207   myNodeActor->SetStoreMapping(true);
208   myNodeActor->PickableOff();
209   myNodeActor->SetVisibility(false);
210   myNodeActor->SetProperty(myNodeProp);
211   myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
212   aFilter = myNodeActor->GetExtractUnstructuredGrid();
213   aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
214
215
216   //Definition of Pickable and Highlitable engines
217   //----------------------------------------------
218
219   myBaseActor = SMESH_DeviceActor::New();
220   myBaseActor->SetUserMatrix(aMatrix);
221   myBaseActor->SetStoreMapping(true);
222   myBaseActor->GetProperty()->SetOpacity(0.0);
223
224   myPickableActor = myBaseActor;
225
226   myHighlightProp = vtkProperty::New();
227   myHighlightProp->SetAmbient(1.0);
228   myHighlightProp->SetDiffuse(0.0);
229   myHighlightProp->SetSpecular(0.0);
230   anRGB[0] = GetFloat("SMESH:SettingsSelectColorRed", 255)/255.;   // 1;
231   anRGB[1] = GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1;
232   anRGB[2] = GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.;  // 1;
233   myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
234   myHighlightProp->SetPointSize(aPointSize);
235   myHighlightProp->SetRepresentation(1);
236  
237   myPreselectProp = vtkProperty::New();
238   myPreselectProp->SetAmbient(1.0);
239   myPreselectProp->SetDiffuse(0.0);
240   myPreselectProp->SetSpecular(0.0);
241   anRGB[0] = GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.;     // 0;
242   anRGB[1] = GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1;
243   anRGB[2] = GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.;  // 1;
244   myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
245   myPreselectProp->SetPointSize(aPointSize);
246   myPreselectProp->SetRepresentation(1);
247
248   myHighlitableActor = SMESH_DeviceActor::New();
249   myHighlitableActor->SetUserMatrix(aMatrix);
250   myHighlitableActor->SetStoreMapping(false);
251   myHighlitableActor->PickableOff();
252   myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
253
254
255   SetShrinkFactor(GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.);
256
257   myName = "";
258   myIO = NULL;
259   myDisplayMode = 0;
260
261   ishighlighted = false;
262   ispreselected = false;
263
264   myColorMode = eNone;
265   my1DColorMode = e1DNone;
266   myControlActor = my2DActor;
267
268   //Definition of myScalarBarActor
269   //------------------------------
270   myLookupTable = vtkLookupTable::New();
271   //Fix for Bug PAL5195 - SMESH764: 
272   //Controls - Aspect Ratio: incorrect colors of the best and worst values
273   myLookupTable->SetHueRange(0.667,0.0);
274
275   myScalarBarActor = vtkScalarBarActor::New();
276   myScalarBarActor->SetVisibility(false);
277   myScalarBarActor->SetLookupTable(myLookupTable);
278
279   vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
280
281   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
282     QStringList aTColor = QStringList::split(  ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
283     aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
284                                    ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), 
285                                    ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
286   }
287   else
288     aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 );
289
290   aScalarBarTitleProp->SetFontFamilyToArial();
291   if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){
292     if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
293       aScalarBarTitleProp->SetFontFamilyToArial();
294     else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
295       aScalarBarTitleProp->SetFontFamilyToCourier();
296     else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
297       aScalarBarTitleProp->SetFontFamilyToTimes();
298   }
299
300   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" )
301     aScalarBarTitleProp->BoldOn();
302   else
303     aScalarBarTitleProp->BoldOff();
304
305   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" )
306     aScalarBarTitleProp->ItalicOn();
307   else
308     aScalarBarTitleProp->ItalicOff();
309
310   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" )
311     aScalarBarTitleProp->ShadowOn();
312   else
313     aScalarBarTitleProp->ShadowOff();
314
315   myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
316   aScalarBarTitleProp->Delete();
317
318   vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
319
320   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
321     QStringList aTColor = QStringList::split(  ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
322     aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
323                                    ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), 
324                                    ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
325   }
326   else
327     aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 );
328
329   aScalarBarLabelProp->SetFontFamilyToArial();
330   if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){
331     if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
332       aScalarBarLabelProp->SetFontFamilyToArial();
333     else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
334       aScalarBarLabelProp->SetFontFamilyToCourier();
335     else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
336       aScalarBarLabelProp->SetFontFamilyToTimes();
337   }
338
339   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" )
340     aScalarBarLabelProp->BoldOn();
341   else
342     aScalarBarLabelProp->BoldOff();
343
344   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" )
345     aScalarBarLabelProp->ItalicOn();
346   else
347     aScalarBarLabelProp->ItalicOff();
348
349   if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" )
350     aScalarBarLabelProp->ShadowOn();
351   else
352     aScalarBarLabelProp->ShadowOff();
353
354   myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
355   aScalarBarLabelProp->Delete();
356
357   if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" )
358     myScalarBarActor->SetOrientationToHorizontal();
359   else
360     myScalarBarActor->SetOrientationToVertical();
361
362   float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01;
363   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
364     aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat();
365   float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1;
366   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
367     aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat();
368   myScalarBarActor->SetPosition( aXVal, aYVal );
369
370   float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10;
371   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
372     aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat();
373   myScalarBarActor->SetWidth( aWVal );
374
375   float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80;
376   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
377     aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat();
378   myScalarBarActor->SetHeight( aHVal );
379
380   int anIntVal = 5;
381   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
382     anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt();
383   myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal);
384
385   anIntVal = 64;
386   if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
387     anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt();
388   myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal);
389
390
391   //Definition of points numbering pipeline
392   //---------------------------------------
393   myPointsNumDataSet = vtkUnstructuredGrid::New();
394
395   myPtsMaskPoints = vtkMaskPoints::New();
396   myPtsMaskPoints->SetInput(myPointsNumDataSet);
397   myPtsMaskPoints->SetOnRatio(1);
398     
399   myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
400   myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
401   myPtsSelectVisiblePoints->SelectInvisibleOff();
402   myPtsSelectVisiblePoints->SetTolerance(0.1);
403     
404   myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
405   myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
406   myPtsLabeledDataMapper->SetLabelFormat("%g");
407   myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
408     
409   vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
410   aPtsTextProp->SetFontFamilyToTimes();
411   static int aPointsFontSize = 10;
412   aPtsTextProp->SetFontSize(aPointsFontSize);
413   aPtsTextProp->SetBold(1);
414   aPtsTextProp->SetItalic(0);
415   aPtsTextProp->SetShadow(0);
416   myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
417   aPtsTextProp->Delete();
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 = vtkCellCenters::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   myClsLabeledDataMapper->SetLabelFormat("%g");
446   myClsLabeledDataMapper->SetLabelModeToLabelScalars();
447     
448   vtkTextProperty* aClsTextProp = vtkTextProperty::New();
449   aClsTextProp->SetFontFamilyToTimes();
450   static int aCellsFontSize = 12;
451   aClsTextProp->SetFontSize(aCellsFontSize);
452   aClsTextProp->SetBold(1);
453   aClsTextProp->SetItalic(0);
454   aClsTextProp->SetShadow(0);
455   myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
456   aClsTextProp->Delete();
457     
458   myIsCellsLabeled = false;
459
460   myCellsLabels = vtkActor2D::New();
461   myCellsLabels->SetMapper(myClsLabeledDataMapper);
462   myCellsLabels->GetProperty()->SetColor(0,1,0);
463   myCellsLabels->SetVisibility(myIsCellsLabeled);
464 }
465
466
467 SMESH_Actor::~SMESH_Actor(){
468   if(MYDEBUG) MESSAGE("~SMESH_Actor");
469
470   myScalarBarActor->Delete();
471   myLookupTable->Delete();
472
473   mySurfaceProp->Delete();
474   myBackSurfaceProp->Delete();
475
476   myEdgeProp->Delete();
477   myHighlightProp->Delete();
478   myPreselectProp->Delete();
479
480   myNodeProp->Delete();
481
482   my1DProp->Delete();
483   my1DActor->Delete();
484
485   my1DExtProp->Delete();
486   my1DExtActor->Delete();
487
488   my2DActor->Delete();
489   my3DActor->Delete();
490
491   myNodeActor->Delete();
492   myBaseActor->Delete();
493   myHighlitableActor->Delete();
494
495
496   //Deleting of pints numbering pipeline
497   //---------------------------------------
498   myPointsNumDataSet->Delete();
499
500   myPtsLabeledDataMapper->RemoveAllInputs();
501   myPtsLabeledDataMapper->Delete();
502
503   myPtsSelectVisiblePoints->UnRegisterAllOutputs();
504   myPtsSelectVisiblePoints->Delete();
505
506   myPtsMaskPoints->UnRegisterAllOutputs();
507   myPtsMaskPoints->Delete();
508
509   myPointLabels->Delete();
510
511
512   //Deleting of cells numbering pipeline
513   //---------------------------------------
514   myCellsNumDataSet->Delete();
515
516   myClsLabeledDataMapper->RemoveAllInputs();
517   myClsLabeledDataMapper->Delete();
518
519   myClsSelectVisiblePoints->UnRegisterAllOutputs();
520   myClsSelectVisiblePoints->Delete();
521
522   myClsMaskPoints->UnRegisterAllOutputs();
523   myClsMaskPoints->Delete();
524
525   myCellCenters->UnRegisterAllOutputs();
526   myCellCenters->Delete();
527
528   myCellsLabels->Delete();
529 }
530
531
532 void SMESH_Actor::SetPointsLabeled( bool theIsPointsLabeled )
533 {
534   myIsPointsLabeled = theIsPointsLabeled;
535
536   if ( myIsPointsLabeled )
537   {
538     myPointsNumDataSet->ShallowCopy( GetUnstructuredGrid() );
539     vtkDataSet *aDataSet = myPointsNumDataSet;
540     
541     int aNbElem = aDataSet->GetNumberOfPoints();
542     
543     vtkIntArray *anArray = vtkIntArray::New();
544     anArray->SetNumberOfValues( aNbElem );
545     
546     for ( int anId = 0; anId < aNbElem; anId++ )
547     {
548       int aSMDSId = myVisualObj->GetNodeObjId( anId );
549       anArray->SetValue( anId, aSMDSId );
550     }
551     
552     aDataSet->GetPointData()->SetScalars( anArray );
553     anArray->Delete();
554     myPtsMaskPoints->SetInput( aDataSet );
555     myPointLabels->SetVisibility( GetVisibility() );
556   }
557   else
558   {
559     myPointLabels->SetVisibility( false );
560   }
561   
562   SetRepresentation( GetRepresentation() );
563 }
564
565
566 void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){
567   myIsCellsLabeled = theIsCellsLabeled;
568   if(myIsCellsLabeled){
569     myCellsNumDataSet->ShallowCopy(GetUnstructuredGrid());
570     vtkDataSet *aDataSet = myCellsNumDataSet;
571     int aNbElem = aDataSet->GetNumberOfCells();
572     vtkIntArray *anArray = vtkIntArray::New();
573     anArray->SetNumberOfValues(aNbElem);
574     for(int anId = 0; anId < aNbElem; anId++){
575       int aSMDSId = myVisualObj->GetElemObjId(anId);
576       anArray->SetValue(anId,aSMDSId);
577     }
578     aDataSet->GetCellData()->SetScalars(anArray);
579     myCellCenters->SetInput(aDataSet);
580     myCellsLabels->SetVisibility(GetVisibility());
581   }else{
582     myCellsLabels->SetVisibility(false);
583   }
584 }
585
586
587 void SMESH_Actor::SetControlMode(eControl theMode){
588   myColorMode = eNone;
589   my1DColorMode = e1DNone;
590
591   my1DActor->GetMapper()->SetScalarVisibility(false);
592   my2DActor->GetMapper()->SetScalarVisibility(false);
593   my3DActor->GetMapper()->SetScalarVisibility(false);
594   myScalarBarActor->SetVisibility(false);
595
596   bool anIsScalarVisible = theMode > eNone;
597
598   if(anIsScalarVisible){
599     SMESH::NumericalFunctor_var aFunctor;
600     SMESH::Predicate_var aPredicate;
601       
602     switch(theMode){
603     case eLengthEdges:
604       aFunctor = myFilterMgr->CreateLength();
605       myControlActor = my1DActor;
606       break;
607     case eFreeBorders:
608       aPredicate = myFilterMgr->CreateFreeBorders();
609       myControlActor = my1DActor;
610       break;
611     case eMultiConnection:
612       aFunctor = myFilterMgr->CreateMultiConnection();
613       myControlActor = my1DActor;
614       break;
615     case eArea:
616       aFunctor = myFilterMgr->CreateArea();
617       myControlActor = my2DActor;
618       break;
619     case eTaper:
620       aFunctor = myFilterMgr->CreateTaper();
621       myControlActor = my2DActor;
622       break;
623     case eAspectRatio:
624       aFunctor = myFilterMgr->CreateAspectRatio();
625       myControlActor = my2DActor;
626       break;
627     case eMinimumAngle:
628       aFunctor = myFilterMgr->CreateMinimumAngle();
629       myControlActor = my2DActor;
630       break;
631     case eWarping:
632       aFunctor = myFilterMgr->CreateWarping();
633       myControlActor = my2DActor;
634       break;
635     case eSkew:
636       aFunctor = myFilterMgr->CreateSkew();
637       myControlActor = my2DActor;
638       break;
639     default:
640       return;
641     }
642     
643     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
644     vtkIdType aNbCells = aGrid->GetNumberOfCells();
645     if(aNbCells){
646       if(theMode == eFreeBorders){
647         if(!aPredicate->_is_nil()){
648           myVisualObj->UpdateFunctor(aPredicate);
649           SALOME_ExtractUnstructuredGrid* aFilter = 
650             my1DExtActor->GetExtractUnstructuredGrid();
651           aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
652           aFilter->ClearRegisteredCells();
653           for( vtkIdType i = 0; i < aNbCells; i++ ){
654             vtkIdType anObjId = myControlActor->GetElemObjId( i );
655             CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId);
656             if(aValue)
657               aFilter->RegisterCell(i);
658           }
659           if(!aFilter->IsCellsRegistered())
660             aFilter->RegisterCell(-1);
661           aPredicate->Destroy();
662         }
663         myColorMode = theMode;
664         my1DColorMode = e1DHighlited;
665       }else{
666         myColorMode = theMode;
667         if(myControlActor == my1DActor)
668           my1DColorMode = e1DColored;
669         
670         vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
671         aDataSet->ShallowCopy(aGrid);
672         myScalarBarActor->SetVisibility(true);
673         myControlActor->GetMapper()->SetScalarVisibility(true);
674         
675         vtkDoubleArray *aScalars = vtkDoubleArray::New();
676         aScalars->SetNumberOfComponents( 1 );
677         aScalars->SetNumberOfTuples(aNbCells);
678         
679         if(!aFunctor->_is_nil()){
680           myVisualObj->UpdateFunctor(aFunctor);
681           for( vtkIdType i = 0; i < aNbCells; i++ ){
682             vtkIdType anObjId = myControlActor->GetElemObjId( i );
683             CORBA::Double aValue = aFunctor->GetValue(anObjId);
684             aScalars->SetValue( i, aValue );
685           }
686           aFunctor->Destroy();
687         }else if(!aPredicate->_is_nil()){
688           myVisualObj->UpdateFunctor(aPredicate);
689           for( vtkIdType i = 0; i < aNbCells; i++ ){
690             vtkIdType anObjId = myControlActor->GetElemObjId( i );
691             CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId);
692             aScalars->SetValue( i, aValue );
693           }
694           aPredicate->Destroy();
695         }
696         aDataSet->GetCellData()->SetScalars(aScalars);
697         aScalars->Delete();
698         
699         float aRange[2];
700         aScalars->GetRange(aRange);
701         myLookupTable->SetRange(aRange);
702         myLookupTable->Build();
703         
704         myControlActor->GetMergeFilter()->SetScalars(aDataSet);
705         aDataSet->Delete();
706         if(MYDEBUGWITHFILES) 
707           WriteUnstructuredGrid(aDataSet,"/tmp/SetControlMode.vtk");
708       }
709     }
710   }
711   SetRepresentation(GetRepresentation());
712   
713   Modified();
714 }
715
716
717 void SMESH_Actor::AddToRender(vtkRenderer* theRenderer){
718   SALOME_Actor::AddToRender(theRenderer);
719
720   theRenderer->AddActor(myNodeActor);
721   theRenderer->AddActor(myBaseActor);
722
723   theRenderer->AddActor(my3DActor);
724   theRenderer->AddActor(my2DActor);
725
726   theRenderer->AddActor(my1DActor);
727   theRenderer->AddActor(my1DExtActor);
728
729   theRenderer->AddActor(myHighlitableActor);
730
731   theRenderer->AddActor2D(myScalarBarActor);
732
733   myPtsSelectVisiblePoints->SetRenderer(theRenderer);
734   myClsSelectVisiblePoints->SetRenderer(theRenderer);
735
736   theRenderer->AddActor2D(myPointLabels);
737   theRenderer->AddActor2D(myCellsLabels);
738 }
739
740 void SMESH_Actor::RemoveFromRender(vtkRenderer* theRenderer){
741   SALOME_Actor::RemoveFromRender(theRenderer);
742
743   theRenderer->RemoveActor(myNodeActor);
744   theRenderer->RemoveActor(myBaseActor);
745   theRenderer->RemoveActor(myHighlitableActor);
746
747   theRenderer->RemoveActor(my1DActor);
748   theRenderer->RemoveActor(my1DExtActor);
749
750   theRenderer->RemoveActor(my2DActor);
751   theRenderer->RemoveActor(my3DActor);
752
753   theRenderer->RemoveActor(myScalarBarActor);
754   theRenderer->RemoveActor(myPointLabels);
755   theRenderer->RemoveActor(myCellsLabels);
756 }
757
758
759 void SMESH_Actor::Init(TVisualObjPtr theVisualObj, 
760                        SMESH::FilterManager_ptr theFilterMgr,
761                        const char* theEntry, 
762                        const char* theName,
763                        int theIsClear)
764 {
765   Handle(SALOME_InteractiveObject) anIO =
766     new SALOME_InteractiveObject(strdup(theEntry),strdup("MESH"),strdup(theName));
767   setIO(anIO);
768   setName(strdup(theName));
769
770   myVisualObj = theVisualObj;
771   myNodeActor->myVisualObj = myVisualObj;
772   myBaseActor->myVisualObj = myVisualObj;
773   myHighlitableActor->myVisualObj = myVisualObj;
774
775   my1DActor->myVisualObj = myVisualObj;
776   my1DExtActor->myVisualObj = myVisualObj;
777
778   my2DActor->myVisualObj = myVisualObj;
779   my3DActor->myVisualObj = myVisualObj;
780
781   myVisualObj->Update(theIsClear);
782   SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
783   
784   myFilterMgr = SMESH::FilterManager::_duplicate(theFilterMgr);
785
786   QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
787   SetRepresentation(-1);
788   if(aMode.compare("Wireframe") == 0){
789     SetRepresentation(eEdge);
790   }else if(aMode.compare("Shading") == 0){
791     SetRepresentation(eSurface);
792   }else if(aMode.compare("Nodes") == 0){
793     SetRepresentation(ePoint);
794   }
795
796   aMode = QAD_CONFIG->getSetting("SMESH:Shrink");
797   if(aMode == "yes"){
798     SetShrink();
799   }
800
801   Modified();
802 }
803
804
805 vtkPolyData* SMESH_Actor::GetPolyDataInput(){
806   return myPickableActor->GetPolyDataInput();
807 }
808
809
810 void SMESH_Actor::SetTransform(SALOME_Transform* theTransform){
811   myNodeActor->SetTransform(theTransform);
812   myBaseActor->SetTransform(theTransform);
813   myHighlitableActor->SetTransform(theTransform);
814
815   my1DActor->SetTransform(theTransform);
816   my1DExtActor->SetTransform(theTransform);
817
818   my2DActor->SetTransform(theTransform);
819   my3DActor->SetTransform(theTransform);
820
821   Modified();
822 }
823
824
825 void SMESH_Actor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
826   if(theGrid){
827     myNodeActor->SetUnstructuredGrid(theGrid);
828     myBaseActor->SetUnstructuredGrid(theGrid);
829     myHighlitableActor->SetUnstructuredGrid(theGrid);
830
831     my1DActor->SetUnstructuredGrid(theGrid);
832     my1DExtActor->SetUnstructuredGrid(theGrid);
833
834     my2DActor->SetUnstructuredGrid(theGrid);
835     my3DActor->SetUnstructuredGrid(theGrid);
836
837     my1DActor->GetMapper()->SetLookupTable(myLookupTable);
838     my2DActor->GetMapper()->SetLookupTable(myLookupTable);
839     my3DActor->GetMapper()->SetLookupTable(myLookupTable);
840     
841     float aFactor, aUnits;
842     my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
843     my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
844
845     //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
846     SetIsShrunkable(true);
847
848     Modified();
849   }
850 }
851
852
853 void SMESH_Actor::SetMapper(vtkMapper* theMapper){
854   vtkLODActor::SetMapper(theMapper);
855 }
856
857
858 void SMESH_Actor::ShallowCopy(vtkProp *prop){
859   SALOME_Actor::ShallowCopy(prop);
860 }
861
862
863 vtkMapper* SMESH_Actor::GetMapper(){
864   return myPickableActor->GetMapper();
865 }
866
867
868 vtkUnstructuredGrid* SMESH_Actor::GetUnstructuredGrid(){ 
869   return myVisualObj->GetUnstructuredGrid();
870 }
871
872
873 bool SMESH_Actor::IsInfinitive(){
874   vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
875   aDataSet->Update();
876   myIsInfinite = aDataSet->GetNumberOfCells() == 0;
877   return SALOME_Actor::IsInfinitive();
878 }
879
880
881 void SMESH_Actor::SetIsShrunkable(bool theShrunkable){
882   myIsShrinkable = theShrunkable;
883   Modified();
884 }
885
886 float SMESH_Actor::GetShrinkFactor(){
887   return myBaseActor->GetShrinkFactor();
888 }
889
890 void SMESH_Actor::SetShrinkFactor(float theValue){
891   myBaseActor->SetShrinkFactor(theValue);
892
893   my1DActor->SetShrinkFactor(theValue);
894   my1DExtActor->SetShrinkFactor(theValue);
895
896   my2DActor->SetShrinkFactor(theValue);
897   my3DActor->SetShrinkFactor(theValue);
898
899   Modified();
900 }
901
902 void SMESH_Actor::SetShrink(){
903   if(!myIsShrinkable) return;
904
905   myBaseActor->SetShrink();
906
907   my1DActor->SetShrink();
908   my1DExtActor->SetShrink();
909
910   my2DActor->SetShrink();
911   my3DActor->SetShrink();
912
913   myIsShrunk = true;
914   Modified();
915 }
916
917 void SMESH_Actor::UnShrink(){
918   if(!myIsShrunk) return;
919
920   myBaseActor->UnShrink();
921
922   my1DActor->UnShrink();
923   my1DExtActor->UnShrink();
924
925   my2DActor->UnShrink();
926   my3DActor->UnShrink();
927
928   myIsShrunk = false;
929   Modified();
930 }
931
932
933 int SMESH_Actor::GetObjId(int theVtkID){
934   if (GetRepresentation() == 0){
935     return GetNodeObjId(theVtkID);
936   }else{
937     return GetElemObjId(theVtkID);
938   }
939 }
940
941 SALOME_Actor::TVectorId SMESH_Actor::GetVtkId(int theObjID){
942   if (GetRepresentation() == 0){
943     return GetNodeVtkId(theObjID);
944   }else{
945     return GetElemVtkId(theObjID);
946   }
947 }
948
949
950 int SMESH_Actor::GetNodeObjId(int theVtkID){
951   return myPickableActor->GetNodeObjId(theVtkID);
952 }
953
954 SALOME_Actor::TVectorId SMESH_Actor::GetNodeVtkId(int theObjID){
955   return myPickableActor->GetNodeVtkId(theObjID);
956 }
957
958
959 int SMESH_Actor::GetElemObjId(int theVtkID){
960   return myPickableActor->GetElemObjId(theVtkID);
961 }
962
963 SALOME_Actor::TVectorId SMESH_Actor::GetElemVtkId(int theObjID){
964   return myPickableActor->GetElemVtkId(theObjID);
965 }
966
967
968 void SMESH_Actor::SetVisibility(int theMode){
969   SALOME_Actor::SetVisibility(theMode);
970   if(GetVisibility()){
971     SetRepresentation(GetRepresentation());
972
973     if(myColorMode != eNone){
974       if(my1DColorMode == e1DHighlited)
975         my1DExtActor->VisibilityOn();
976       else if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
977         myScalarBarActor->VisibilityOn();
978     }
979
980     if(myRepresentation != ePoint)
981       myPickableActor->VisibilityOn();
982
983     my1DActor->VisibilityOn();
984
985     my2DActor->VisibilityOn();
986     my3DActor->VisibilityOn();
987
988     if(myIsPointsLabeled) myPointLabels->VisibilityOn();
989     if(myIsCellsLabeled) myCellsLabels->VisibilityOn();
990   }else{
991     myNodeActor->VisibilityOff();
992     myBaseActor->VisibilityOff();
993
994     my1DActor->VisibilityOff();
995     my1DExtActor->VisibilityOff();
996
997     my2DActor->VisibilityOff();
998     my3DActor->VisibilityOff();
999
1000     myScalarBarActor->VisibilityOff();
1001     myPointLabels->VisibilityOff();
1002     myCellsLabels->VisibilityOff();
1003   }
1004   Modified();
1005 }
1006
1007
1008 void SMESH_Actor::SetRepresentation(int theMode){ 
1009   int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
1010   int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);
1011   int aNbVolumes = myVisualObj->GetNbEntities(SMESH::VOLUME);
1012   if(theMode < 0){
1013     myRepresentation = eSurface;
1014     if(!aNbFaces && !aNbVolumes && aNbEdges){
1015       myRepresentation = eEdge;
1016     }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1017       myRepresentation = ePoint;
1018     }
1019   }else{
1020     switch(theMode){
1021     case eEdge:
1022       if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1023       break;
1024     case eSurface:
1025       if(!aNbFaces && !aNbVolumes) return;
1026       break;
1027     }    
1028     myRepresentation = theMode;
1029   }
1030
1031   if(!GetUnstructuredGrid()->GetNumberOfCells())
1032     myRepresentation = ePoint;
1033
1034   if(myIsShrunk){
1035     if(myRepresentation == ePoint){
1036       UnShrink();
1037       myIsShrunk = true;
1038     }else{
1039       SetShrink();
1040     }      
1041   }
1042
1043   myPickableActor = myBaseActor;
1044   myNodeActor->SetVisibility(false);
1045   vtkProperty *aProp = NULL, *aBackProp = NULL;
1046   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1047   switch(myRepresentation){
1048   case ePoint: 
1049     myPickableActor = myNodeActor;
1050     aProp = aBackProp = myNodeProp;
1051     aReperesent = SMESH_DeviceActor::ePoint;
1052     break;
1053   case eEdge:
1054     aProp = aBackProp = myEdgeProp;
1055     aReperesent = SMESH_DeviceActor::eInsideframe;
1056     break;
1057   case eSurface:
1058     aProp = mySurfaceProp;
1059     aBackProp = myBackSurfaceProp;
1060     aReperesent = SMESH_DeviceActor::eSurface;
1061     break;
1062   }    
1063
1064   my2DActor->SetProperty(aProp);
1065   my2DActor->SetBackfaceProperty(aBackProp);
1066   my2DActor->SetRepresentation(aReperesent);
1067   
1068   my3DActor->SetProperty(aProp);
1069   my3DActor->SetBackfaceProperty(aBackProp);
1070   my3DActor->SetRepresentation(aReperesent);
1071
1072   my1DExtActor->SetVisibility(false);
1073   switch(my1DColorMode){
1074   case e1DColored: 
1075     aProp = aBackProp = my1DProp;
1076     if(myRepresentation != ePoint)
1077       aReperesent = SMESH_DeviceActor::eInsideframe;
1078     break;
1079   case e1DHighlited: 
1080     my1DExtActor->SetVisibility(true);
1081     break;
1082   }
1083   
1084   my1DActor->SetProperty(aProp);
1085   my1DActor->SetBackfaceProperty(aBackProp);
1086   my1DActor->SetRepresentation(aReperesent);
1087   
1088   if ( GetPointRepresentation() || !GetUnstructuredGrid()->GetNumberOfCells() || myIsPointsLabeled )
1089   {
1090     myPickableActor = myNodeActor;
1091     myNodeActor->SetVisibility(true);
1092   }
1093
1094   SetMapper(myPickableActor->GetMapper());
1095
1096   Modified();
1097 }
1098
1099
1100 void SMESH_Actor::SetPointRepresentation(int theIsPointsVisible){
1101   myIsPointsVisible = theIsPointsVisible;
1102   SetRepresentation(GetRepresentation());
1103 }
1104
1105
1106 void SMESH_Actor::UpdateHighlight(){
1107   myHighlitableActor->SetVisibility(false);
1108   myNodeActor->SetProperty(myNodeProp);
1109   if(myPickableActor != myNodeActor)
1110     myNodeActor->SetVisibility(false);
1111
1112   if(ishighlighted){
1113     myHighlitableActor->SetProperty(myHighlightProp);
1114   }else if(ispreselected){
1115     myHighlitableActor->SetProperty(myPreselectProp);
1116   }
1117
1118   if(ishighlighted || ispreselected){
1119     if(!GetUnstructuredGrid()->GetNumberOfCells()){
1120       myNodeActor->SetProperty(myHighlitableActor->GetProperty());
1121       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1122       myNodeActor->SetVisibility(GetVisibility());
1123     }else{
1124       myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1125       myHighlitableActor->SetVisibility(GetVisibility());
1126     }
1127   }
1128 }
1129
1130
1131 void SMESH_Actor::highlight(Standard_Boolean highlight){
1132   ishighlighted = highlight;
1133   UpdateHighlight();
1134 }
1135
1136
1137 void SMESH_Actor::SetPreSelected(Standard_Boolean presel){ 
1138   ispreselected = presel; 
1139   UpdateHighlight();
1140 }
1141
1142
1143 // From vtkFollower
1144 int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp)
1145 {
1146   if (myPickableActor->GetIsOpaque())
1147     {
1148     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1149     this->Render(ren);
1150     return 1;
1151     }
1152   return 0;
1153 }
1154
1155
1156 int SMESH_Actor::RenderTranslucentGeometry(vtkViewport *vp)
1157 {
1158   if (!myPickableActor->GetIsOpaque())
1159     {
1160     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1161     this->Render(ren);
1162     return 1;
1163     }
1164   return 0;
1165 }
1166
1167
1168 void SMESH_Actor::Render(vtkRenderer *ren){}
1169
1170
1171 void SMESH_Actor::ReleaseGraphicsResources(vtkWindow *renWin){
1172   SALOME_Actor::ReleaseGraphicsResources(renWin);
1173
1174   myPickableActor->ReleaseGraphicsResources(renWin);
1175 }
1176
1177
1178 static void GetColor(vtkProperty *theProperty, float& r,float& g,float& b){
1179   float* aColor = theProperty->GetColor();
1180   r = aColor[0];
1181   g = aColor[1];
1182   b = aColor[2];
1183 }
1184
1185
1186 void SMESH_Actor::SetOpacity(float theValue){
1187   mySurfaceProp->SetOpacity(theValue);
1188   myBackSurfaceProp->SetOpacity(theValue);
1189   myEdgeProp->SetOpacity(theValue);
1190   myNodeProp->SetOpacity(theValue);
1191
1192   my1DProp->SetOpacity(theValue);
1193 }
1194
1195
1196 float SMESH_Actor::GetOpacity(){
1197   return mySurfaceProp->GetOpacity();
1198 }
1199
1200
1201 void SMESH_Actor::SetSufaceColor(float r,float g,float b){
1202   mySurfaceProp->SetColor(r,g,b);
1203   Modified();
1204 }
1205
1206 void SMESH_Actor::GetSufaceColor(float& r,float& g,float& b){
1207   ::GetColor(mySurfaceProp,r,g,b);
1208 }
1209
1210 void SMESH_Actor::SetBackSufaceColor(float r,float g,float b){
1211   myBackSurfaceProp->SetColor(r,g,b);
1212   Modified();
1213 }
1214
1215 void SMESH_Actor::GetBackSufaceColor(float& r,float& g,float& b){
1216   ::GetColor(myBackSurfaceProp,r,g,b);
1217 }
1218
1219 void SMESH_Actor::SetEdgeColor(float r,float g,float b){
1220   myEdgeProp->SetColor(r,g,b);
1221   my1DProp->SetColor(r,g,b);
1222   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1223   Modified();
1224 }
1225
1226 void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b){
1227   ::GetColor(myEdgeProp,r,g,b);
1228 }
1229
1230 void SMESH_Actor::SetNodeColor(float r,float g,float b){ 
1231   myNodeProp->SetColor(r,g,b);
1232   Modified();
1233 }
1234
1235 void SMESH_Actor::GetNodeColor(float& r,float& g,float& b){ 
1236   ::GetColor(myNodeProp,r,g,b);
1237 }
1238
1239 void SMESH_Actor::SetHighlightColor(float r,float g,float b){ 
1240   myHighlightProp->SetColor(r,g,b);
1241   Modified();
1242 }
1243
1244 void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b){ 
1245   ::GetColor(myHighlightProp,r,g,b);
1246 }
1247
1248 void SMESH_Actor::SetPreHighlightColor(float r,float g,float b){ 
1249   myPreselectProp->SetColor(r,g,b);
1250   Modified();
1251 }
1252
1253 void SMESH_Actor::GetPreHighlightColor(float& r,float& g,float& b){ 
1254   ::GetColor(myPreselectProp,r,g,b);
1255 }
1256
1257
1258 float SMESH_Actor::GetLineWidth(){
1259   return myEdgeProp->GetLineWidth();
1260 }
1261
1262
1263 void SMESH_Actor::SetLineWidth(float theVal){
1264   myEdgeProp->SetLineWidth(theVal);
1265   Modified();
1266 }
1267
1268
1269 void SMESH_Actor::SetNodeSize(float theSize){
1270   myNodeProp->SetPointSize(theSize);
1271   myHighlightProp->SetPointSize(theSize);
1272   myPreselectProp->SetPointSize(theSize);
1273
1274   my1DExtProp->SetPointSize(theSize);
1275   my1DProp->SetPointSize(theSize);
1276
1277   Modified();
1278 }
1279
1280 float SMESH_Actor::GetNodeSize(){
1281   return myNodeProp->GetPointSize();
1282 }
1283
1284 int SMESH_Actor::GetObjDimension( const int theObjId )
1285 {
1286   return myVisualObj->GetElemDimension( theObjId );
1287 }