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