1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
30 #include "SMDS_UnstructuredGrid.hxx"
31 #include "SMESH_ActorUtils.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include "SMESH_DeviceActor.h"
35 #include "SMESH_NodeLabelActor.h"
36 #include "SMESH_ObjectDef.h"
37 #include "SMESH_SVTKActor.h"
38 #include "SMESH_ScalarBarActor.h"
41 #include <SALOME_InteractiveObject.hxx>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <VTKViewer_ExtractUnstructuredGrid.h>
45 #include <VTKViewer_FramedTextActor.h>
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkPlaneCollection.h>
79 #include <vtkImplicitBoolean.h>
80 #include <vtkImplicitFunctionCollection.h>
82 #include "utilities.h"
85 static int MYDEBUG = 0;
87 static int MYDEBUG = 0;
90 static int aLineWidthInc = 2;
93 SMESH_ActorDef* SMESH_ActorDef::New(){
94 return new SMESH_ActorDef();
98 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 SMESH_ActorDef* anActor = NULL;
104 if(theVisualObj->IsValid() ) {
105 anActor = SMESH_ActorDef::New();
106 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
111 anActor->UpdateScalarBar();
117 SMESH_ActorDef::SMESH_ActorDef()
119 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
121 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myHighlightActor = SMESH_SVTKActor::New();
131 myHighlightActor->Delete(); // vtkSmartPointer!
132 myHighlightActor->Initialize();
134 myPreHighlightActor = SMESH_SVTKActor::New();
135 myPreHighlightActor->Delete();
136 myPreHighlightActor->Initialize();
138 myIsShrinkable = false;
141 myIsFacesOriented = false;
143 myControlsPrecision = -1;
144 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
146 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
147 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
149 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
150 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
151 double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
152 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
153 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
155 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
157 bool anItalicNd = false;
158 bool aShadowNd = false;
160 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
161 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
162 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
163 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
164 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
166 anItalicNd = f.italic();
167 aShadowNd = f.overline();
168 aSizeNd = f.pointSize();
170 double anRGBNd[3] = {1,1,1};
171 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
173 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
175 bool anItalicEl = false;
176 bool aShadowEl = false;
178 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
179 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
180 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
181 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
182 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
184 anItalicEl = f.italic();
185 aShadowEl = f.overline();
186 aSizeEl = f.pointSize();
188 double anRGBEl[3] = {0,1,0};
189 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
191 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
192 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
194 //Definition 2D and 3D devices of the actor
195 //-----------------------------------------
196 double anRGB[3] = {1,1,1};
197 mySurfaceProp = vtkProperty::New();
200 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
201 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
202 myDeltaBrightness = delta;
204 myBackSurfaceProp = vtkProperty::New();
205 bfc = Qtx::mainColorToSecondary(ffc, delta);
206 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
208 myNormalVProp = vtkProperty::New();
209 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
210 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
211 myDeltaVBrightness = delta;
213 myReversedVProp = vtkProperty::New();
214 bfc = Qtx::mainColorToSecondary(ffc, delta);
215 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
217 my2DActor = SMESH_CellLabelActor::New();
218 my2DActor->SetStoreClippingMapping(true);
219 my2DActor->SetUserMatrix(aMatrix);
220 my2DActor->PickableOff();
221 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
222 my2DActor->SetProperty(mySurfaceProp);
223 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
224 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225 aFilter = my2DActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
228 aFilter->RegisterCellsWithType(VTK_QUAD);
229 aFilter->RegisterCellsWithType(VTK_POLYGON);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
233 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
234 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
236 my2DExtProp = vtkProperty::New();
237 my2DExtProp->DeepCopy(mySurfaceProp);
238 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
239 anRGB[0] = 1 - anRGB[0];
240 anRGB[1] = 1 - anRGB[1];
241 anRGB[2] = 1 - anRGB[2];
242 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
244 my2DExtActor = SMESH_DeviceActor::New();
245 my2DExtActor->SetUserMatrix(aMatrix);
246 my2DExtActor->PickableOff();
247 my2DExtActor->SetProperty(my2DExtProp);
248 my2DExtActor->SetBackfaceProperty(my2DExtProp);
249 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
250 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
251 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
252 aFilter->RegisterCellsWithType(VTK_QUAD);
253 aFilter->RegisterCellsWithType(VTK_POLYGON);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
255 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
257 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
258 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
260 my3DActor = SMESH_CellLabelActor::New();
261 my3DActor->SetStoreClippingMapping(true);
262 my3DActor->SetUserMatrix(aMatrix);
263 my3DActor->PickableOff();
264 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
265 my3DActor->SetProperty(myNormalVProp);
266 my3DActor->SetBackfaceProperty(myReversedVProp);
267 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
268 my3DActor->SetCoincident3DAllowed(true);
269 aFilter = my3DActor->GetExtractUnstructuredGrid();
270 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
271 aFilter->RegisterCellsWithType(VTK_TETRA);
272 aFilter->RegisterCellsWithType(VTK_VOXEL);
273 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
274 aFilter->RegisterCellsWithType(VTK_WEDGE);
275 aFilter->RegisterCellsWithType(VTK_PYRAMID);
276 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
277 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
279 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
281 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
282 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
283 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
285 my3DExtProp = vtkProperty::New();
286 my3DExtProp->DeepCopy(myNormalVProp);
287 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
288 anRGB[0] = 1 - anRGB[0];
289 anRGB[1] = 1 - anRGB[1];
290 anRGB[2] = 1 - anRGB[2];
291 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
293 my3DExtActor = SMESH_DeviceActor::New();
294 my3DExtActor->SetUserMatrix(aMatrix);
295 my3DExtActor->PickableOff();
296 my3DExtActor->SetProperty(my3DExtProp);
297 my3DExtActor->SetBackfaceProperty(my3DExtProp);
298 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
299 my3DExtActor->SetCoincident3DAllowed(true);
300 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
301 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
302 aFilter->RegisterCellsWithType(VTK_TETRA);
303 aFilter->RegisterCellsWithType(VTK_VOXEL);
304 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
305 aFilter->RegisterCellsWithType(VTK_WEDGE);
306 aFilter->RegisterCellsWithType(VTK_PYRAMID);
307 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
308 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
310 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
311 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
313 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
314 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
316 //Definition 1D device of the actor
317 //---------------------------------
318 myEdgeProp = vtkProperty::New();
319 myEdgeProp->SetAmbient(1.0);
320 myEdgeProp->SetDiffuse(0.0);
321 myEdgeProp->SetSpecular(0.0);
322 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
323 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
324 myEdgeProp->SetLineWidth(aLineWidth);
326 // my1DActor is used to
328 // - show controls on all edges (eg Length)
329 // since edges are shown by myHighlitableActor
330 my1DActor = SMESH_CellLabelActor::New();
331 my1DActor->SetStoreClippingMapping(true);
332 my1DActor->SetUserMatrix(aMatrix);
333 my1DActor->PickableOff();
334 my1DActor->SetHighlited(true);
335 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
336 my1DActor->SetProperty(myEdgeProp);
337 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
338 aFilter = my1DActor->GetExtractUnstructuredGrid();
339 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
340 aFilter->RegisterCellsWithType(VTK_LINE);
341 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
343 my1DProp = vtkProperty::New();
344 my1DProp->DeepCopy(myEdgeProp);
345 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
346 my1DProp->SetPointSize(aElem0DSize);
348 my1DExtProp = vtkProperty::New();
349 my1DExtProp->DeepCopy(myEdgeProp);
350 anRGB[0] = 1 - anRGB[0];
351 anRGB[1] = 1 - anRGB[1];
352 anRGB[2] = 1 - anRGB[2];
353 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
354 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
355 my1DExtProp->SetPointSize(aElem0DSize);
357 // my1DExtActor is used to show filtered edges or links between nodes
358 my1DExtActor = SMESH_DeviceActor::New();
359 my1DExtActor->SetUserMatrix(aMatrix);
360 my1DExtActor->PickableOff();
361 my1DExtActor->SetHighlited(true);
362 my1DExtActor->SetVisibility(false);
363 my1DExtActor->SetProperty(my1DExtProp);
364 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
365 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
366 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
367 aFilter->RegisterCellsWithType(VTK_LINE);
368 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
371 //Definition 0D device of the actor (0d elements)
372 //-----------------------------------------------
373 my0DProp = vtkProperty::New();
374 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
375 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
376 my0DProp->SetPointSize(aElem0DSize);
378 my0DActor = SMESH_CellLabelActor::New();
379 my0DActor->SetUserMatrix(aMatrix);
380 my0DActor->SetStoreClippingMapping(true);
381 my0DActor->PickableOff();
382 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
383 my0DActor->SetVisibility(false);
384 my0DActor->SetProperty(my0DProp);
385 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
386 aFilter = my0DActor->GetExtractUnstructuredGrid();
387 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
388 aFilter->RegisterCellsWithType(VTK_VERTEX);
390 //Definition 0D device of the actor (ball elements)
391 //-----------------------------------------------
392 myBallProp = vtkProperty::New();
393 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
394 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
395 myBallProp->SetPointSize(aBallElemSize);
397 myBallActor = SMESH_CellLabelActor::New();
398 myBallActor->SetUserMatrix(aMatrix);
399 myBallActor->SetStoreClippingMapping(true);
400 myBallActor->PickableOff();
401 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
402 myBallActor->SetVisibility(false);
403 myBallActor->SetProperty(myBallProp);
404 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
405 myBallActor->SetBallEnabled(true);
406 aFilter = myBallActor->GetExtractUnstructuredGrid();
407 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
408 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
410 //my0DExtProp = vtkProperty::New();
411 //my0DExtProp->DeepCopy(my0DProp);
412 //anRGB[0] = 1 - anRGB[0];
413 //anRGB[1] = 1 - anRGB[1];
414 //anRGB[2] = 1 - anRGB[2];
415 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
416 //my0DExtProp->SetPointSize(aElem0DSize);
418 //my0DExtActor = SMESH_DeviceActor::New();
419 //my0DExtActor->SetUserMatrix(aMatrix);
420 //my0DExtActor->SetStoreClippingMapping(true);
421 //my0DExtActor->PickableOff();
422 //my0DExtActor->SetHighlited(true);
423 //my0DExtActor->SetVisibility(false);
424 //my0DExtActor->SetProperty(my0DExtProp);
425 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
426 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
427 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
428 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
429 //aFilter->RegisterCellsWithType(VTK_VERTEX);
432 //Definition 0D device of the actor (nodes)
433 //-----------------------------------------
434 myNodeProp = vtkProperty::New();
435 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
436 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
438 myNodeActor = SMESH_NodeLabelActor::New();
439 myNodeActor->SetUserMatrix(aMatrix);
440 myNodeActor->SetStoreClippingMapping(true);
441 myNodeActor->PickableOff();
442 myNodeActor->SetVisibility(false);
443 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
444 myNodeActor->SetProperty(myNodeProp);
445 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
446 aFilter = myNodeActor->GetExtractUnstructuredGrid();
447 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
449 myNodeExtProp = vtkProperty::New();
450 myNodeExtProp->DeepCopy(myNodeProp);
451 anRGB[0] = 1 - anRGB[0];
452 anRGB[1] = 1 - anRGB[1];
453 anRGB[2] = 1 - anRGB[2];
454 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
456 myNodeExtActor = SMESH_DeviceActor::New();
457 myNodeExtActor->SetUserMatrix(aMatrix);
458 myNodeExtActor->SetStoreClippingMapping(true);
459 myNodeExtActor->PickableOff();
460 myNodeExtActor->SetHighlited(true);
461 myNodeExtActor->SetVisibility(false);
462 myNodeExtActor->SetProperty(myNodeExtProp);
463 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
464 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
465 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
466 aFilter->RegisterCellsWithType(VTK_VERTEX);
468 //Definition of Pickable and Highlitable engines
469 //----------------------------------------------
471 myBaseActor->SetUserMatrix(aMatrix);
472 myBaseActor->SetStoreIDMapping(true);
473 myBaseActor->SetStoreClippingMapping(true);
474 myBaseActor->SetStoreGemetryMapping(true);
475 myBaseActor->GetProperty()->SetOpacity(0.0);
476 myPickableActor = myBaseActor;
478 myHighlightProp = vtkProperty::New();
479 myHighlightProp->SetAmbient(1.0);
480 myHighlightProp->SetDiffuse(0.0);
481 myHighlightProp->SetSpecular(0.0);
482 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
483 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
484 myHighlightProp->SetPointSize(aElem0DSize); // ??
485 myHighlightProp->SetLineWidth(aLineWidth);
486 myHighlightProp->SetRepresentation(1);
488 myOutLineProp = vtkProperty::New();
489 myOutLineProp->SetAmbient(1.0);
490 myOutLineProp->SetDiffuse(0.0);
491 myOutLineProp->SetSpecular(0.0);
492 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
493 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
494 myOutLineProp->SetLineWidth(aOutlineWidth);
495 myOutLineProp->SetRepresentation(1);
497 myPreselectProp = vtkProperty::New();
498 myPreselectProp->SetAmbient(1.0);
499 myPreselectProp->SetDiffuse(0.0);
500 myPreselectProp->SetSpecular(0.0);
501 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
502 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
503 myPreselectProp->SetPointSize(aElem0DSize); // ??
504 myPreselectProp->SetLineWidth(aLineWidth);
505 myPreselectProp->SetRepresentation(1);
507 myHighlitableActor = SMESH_DeviceActor::New();
508 myHighlitableActor->SetUserMatrix(aMatrix);
509 myHighlitableActor->PickableOff();
510 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
511 myHighlitableActor->SetCoincident3DAllowed(true);
518 myControlMode = eNone;
519 myControlActor = my2DActor;
521 //Definition of myScalarBarActor
522 //------------------------------
523 myLookupTable = vtkLookupTable::New();
524 //Fix for Bug PAL5195 - SMESH764:
525 //Controls - Aspect Ratio: incorrect colors of the best and worst values
526 myLookupTable->SetHueRange(0.667,0.0);
528 myScalarBarActor = SMESH_ScalarBarActor::New();
529 myScalarBarActor->SetVisibility(false);
530 myScalarBarActor->SetLookupTable(myLookupTable);
533 //Incorrect "Min value" in Scalar Bar in Mesh:
534 // myScalarBarActor->SetLabelFormat("%.4g");
535 // changes was commented because of regression bug IPAL 19981
537 mgr = SUIT_Session::session()->resourceMgr();
541 myEntityMode = eAllEntity;
542 myEntityModeCache = eAllEntity;
545 myImplicitBoolean = vtkImplicitBoolean::New();
546 myImplicitBoolean->SetOperationTypeToIntersection();
548 myPlaneCollection = vtkPlaneCollection::New();
550 //Quadratic 2D elements representation
551 //-----------------------------------------------------------------------------
552 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
553 if(aQuadratic2DMode == 0){
554 myHighlitableActor->SetQuadraticArcMode(false);
555 my2DActor->SetQuadraticArcMode(false);
556 my1DActor->SetQuadraticArcMode(false);
558 else if(aQuadratic2DMode == 1){
559 myHighlitableActor->SetQuadraticArcMode(true);
560 my2DActor->SetQuadraticArcMode(true);
561 my1DActor->SetQuadraticArcMode(true);
564 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
565 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
566 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
568 // Set colors of the name actor
569 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
570 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
571 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
572 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
574 #ifndef DISABLE_PLOT2DVIEWER
578 SetBallSize(aBallElemSize);
579 SetBallScale(aBallElemScale);
580 Set0DSize(aElem0DSize);
584 SMESH_ActorDef::~SMESH_ActorDef()
586 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
588 // Please keep the order same as one in the header file
590 myTimeStamp->Delete();
592 myScalarBarActor->Delete();
593 myLookupTable->Delete();
595 mySurfaceProp->Delete();
596 myBackSurfaceProp->Delete();
597 myNormalVProp->Delete();
598 myReversedVProp->Delete();
599 myEdgeProp->Delete();
600 myNodeProp->Delete();
602 myNodeActor->Delete();
603 myBaseActor->Delete();
604 //myPickableActor->Delete(); myPickableActor == myBaseActor
606 myHighlightProp->Delete();
607 myOutLineProp->Delete();
608 myPreselectProp->Delete();
610 myHighlitableActor->Delete();
612 my2DExtProp->Delete();
613 my3DExtProp->Delete();
615 my2DExtActor->Delete();
617 my3DExtActor->Delete();
618 // myControlActor->Delete(); myControlActor == my2DActor
620 myNodeExtProp->Delete();
621 myNodeExtActor->Delete();
625 my1DExtProp->Delete();
626 my1DExtActor->Delete();
630 myBallProp->Delete();
631 myBallActor->Delete();
632 //my0DExtProp->Delete();
633 //my0DExtActor->Delete();
635 myImplicitBoolean->Delete();
636 myPlaneCollection->Delete();
638 #ifndef DISABLE_PLOT2DVIEWER
640 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
641 delete my2dHistogram;
646 void SMESH_ActorDef::Delete()
648 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
649 // from the actor's destructor) will be thrown before removing the actor's observers,
650 // that is done inside the Superclass::Delete() method but before the destructor itself
651 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
652 // The event is caught by SMESHGUI::ProcessEvents() static method.
653 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
655 Superclass::Delete();
658 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
661 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
662 SetRepresentation(GetRepresentation());
663 myTimeStamp->Modified();
667 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
668 bool theBold, bool theItalic, bool theShadow,
669 double r, double g, double b )
672 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
673 SetRepresentation( GetRepresentation() );
674 myTimeStamp->Modified();
678 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
679 bool theBold, bool theItalic, bool theShadow,
680 double r, double g, double b )
683 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
686 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
687 SetRepresentation( GetRepresentation() );
688 myTimeStamp->Modified();
691 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
692 SetRepresentation( GetRepresentation() );
693 myTimeStamp->Modified();
696 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
697 SetRepresentation( GetRepresentation() );
698 myTimeStamp->Modified();
701 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
702 SetRepresentation( GetRepresentation() );
703 myTimeStamp->Modified();
707 bool SMESH_ActorDef::GetPointsLabeled()
709 return myNodeActor && myNodeActor->GetPointsLabeled();
712 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
715 my3DActor->SetCellsLabeled(theIsCellsLabeled);
718 my2DActor->SetCellsLabeled(theIsCellsLabeled);
721 my1DActor->SetCellsLabeled(theIsCellsLabeled);
724 my0DActor->SetCellsLabeled(theIsCellsLabeled);
727 myBallActor->SetCellsLabeled(theIsCellsLabeled);
729 myTimeStamp->Modified();
733 bool SMESH_ActorDef::GetCellsLabeled()
737 result = result || my3DActor->GetCellsLabeled();
740 result = result || my2DActor->GetCellsLabeled();
743 result = result || my1DActor->GetCellsLabeled();
746 result = result || my0DActor->GetCellsLabeled();
749 result = result || myBallActor->GetCellsLabeled();
755 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
757 myIsFacesOriented = theIsFacesOriented;
759 my2DActor->SetFacesOriented(theIsFacesOriented);
760 my3DActor->SetFacesOriented(theIsFacesOriented);
762 myTimeStamp->Modified();
765 bool SMESH_ActorDef::GetFacesOriented()
767 return myIsFacesOriented;
770 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
772 my2DActor->SetFacesOrientationColor( r, g, b );
773 my3DActor->SetFacesOrientationColor( r, g, b );
776 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
778 my3DActor->GetFacesOrientationColor( r, g, b );
781 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
783 my2DActor->SetFacesOrientationScale( theScale );
784 my3DActor->SetFacesOrientationScale( theScale );
787 double SMESH_ActorDef::GetFacesOrientationScale()
789 return my3DActor->GetFacesOrientationScale();
792 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
794 my2DActor->SetFacesOrientation3DVectors( theState );
795 my3DActor->SetFacesOrientation3DVectors( theState );
798 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
800 return my3DActor->GetFacesOrientation3DVectors();
804 void SMESH_ActorDef::SetControlMode(eControl theMode)
806 SetControlMode(theMode,true);
810 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
812 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
813 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
814 lookupTable->SetScale(VTK_SCALE_LINEAR);
816 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
820 //myControlMode = eNone;
821 myControlMode = theMode;
822 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
824 my0DActor->GetMapper()->SetScalarVisibility(false);
825 my1DActor->GetMapper()->SetScalarVisibility(false);
826 my2DActor->GetMapper()->SetScalarVisibility(false);
827 my3DActor->GetMapper()->SetScalarVisibility(false);
828 myBallActor->GetMapper()->SetScalarVisibility(false);
829 myScalarBarActor->SetVisibility(false);
831 bool anIsScalarVisible = theMode > eNone;
833 if(anIsScalarVisible) {
837 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
838 aControl->SetPrecision( myControlsPrecision );
839 myFunctor.reset( aControl );
840 myControlActor = my1DActor;
845 myFunctor.reset(new SMESH::Controls::Length2D());
846 myControlActor = my2DActor;
850 myFunctor.reset(new SMESH::Controls::FreeBorders());
851 myControlActor = my1DActor;
854 myFunctor.reset(new SMESH::Controls::FreeEdges());
855 myControlActor = my2DActor;
858 myFunctor.reset(new SMESH::Controls::FreeNodes());
859 myControlActor = myNodeActor;
862 myFunctor.reset(new SMESH::Controls::FreeFaces());
863 myControlActor = my2DActor;
865 case eCoincidentNodes:
867 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
868 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
869 cn->SetTolerance( tol );
871 myControlActor = myNodeActor;
874 case eCoincidentElems1D:
875 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
876 myControlActor = my1DActor;
878 case eCoincidentElems2D:
879 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
880 myControlActor = my2DActor;
882 case eCoincidentElems3D:
883 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
884 myControlActor = my3DActor;
886 case eBareBorderFace:
887 myFunctor.reset(new SMESH::Controls::BareBorderFace());
888 myControlActor = my2DActor;
890 case eOverConstrainedFace:
891 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
892 myControlActor = my2DActor;
894 case eMultiConnection:
895 myFunctor.reset(new SMESH::Controls::MultiConnection());
896 myControlActor = my1DActor;
898 case eMultiConnection2D:
899 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
900 myControlActor = my2DActor;
904 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
905 aControl->SetPrecision( myControlsPrecision );
906 myFunctor.reset( aControl );
907 myControlActor = my2DActor;
912 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
913 aControl->SetPrecision( myControlsPrecision );
914 myFunctor.reset( aControl );
915 myControlActor = my2DActor;
920 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
921 aControl->SetPrecision( myControlsPrecision );
922 myFunctor.reset( aControl );
923 myControlActor = my2DActor;
928 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
929 aControl->SetPrecision( myControlsPrecision );
930 myFunctor.reset( aControl );
931 myControlActor = my3DActor;
936 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
937 aControl->SetPrecision( myControlsPrecision );
938 myFunctor.reset( aControl );
939 myControlActor = my3DActor;
942 case eMaxElementLength2D:
944 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
945 aControl->SetPrecision( myControlsPrecision );
946 myFunctor.reset( aControl );
947 myControlActor = my2DActor;
950 case eMaxElementLength3D:
952 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
953 aControl->SetPrecision( myControlsPrecision );
954 myFunctor.reset( aControl );
955 myControlActor = my3DActor;
958 case eBareBorderVolume:
960 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
961 myControlActor = my3DActor;
964 case eOverConstrainedVolume:
966 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
967 myControlActor = my3DActor;
972 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
973 aControl->SetPrecision( myControlsPrecision );
974 myFunctor.reset( aControl );
975 myControlActor = my2DActor;
980 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
981 aControl->SetPrecision( myControlsPrecision );
982 myFunctor.reset( aControl );
983 myControlActor = my2DActor;
988 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
989 aControl->SetPrecision( myControlsPrecision );
990 myFunctor.reset( aControl );
991 myControlActor = my2DActor;
994 case eNodeConnectivityNb:
996 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
997 myControlActor = myNodeActor;
1004 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1005 bool aShowOnlyScalarBarTitle = false;
1007 //myControlMode = theMode;
1008 switch(myControlMode){
1010 case eCoincidentNodes:
1011 myNodeExtActor->SetExtControlMode(myFunctor);
1012 aShowOnlyScalarBarTitle = true;
1016 case eCoincidentElems1D:
1017 my1DExtActor->SetExtControlMode(myFunctor);
1018 aShowOnlyScalarBarTitle = true;
1021 case eBareBorderFace:
1022 case eOverConstrainedFace:
1023 case eCoincidentElems2D:
1024 my2DExtActor->SetExtControlMode(myFunctor);
1025 aShowOnlyScalarBarTitle = true;
1027 case eBareBorderVolume:
1028 case eOverConstrainedVolume:
1029 case eCoincidentElems3D:
1030 my3DExtActor->SetExtControlMode(myFunctor);
1031 aShowOnlyScalarBarTitle = true;
1034 case eMultiConnection2D:
1035 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1036 UpdateDistribution();
1039 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1040 UpdateDistribution();
1042 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1045 if(theCheckEntityMode) {
1046 // if(myControlActor == myNodeActor) {
1047 // if ( myControlMode == eNodeConnectivityNb ) {
1048 // if (!myIsEntityModeCache){
1049 // myEntityModeCache = GetEntityMode();
1050 // myIsEntityModeCache=true;
1052 // SetEntityMode(0);
1055 if(myControlActor == my1DActor) {
1056 if (!myIsEntityModeCache){
1057 myEntityModeCache = GetEntityMode();
1058 myIsEntityModeCache=true;
1060 SetEntityMode(eEdges);
1062 else if(myControlActor == my2DActor) {
1063 if (!myIsEntityModeCache){
1064 myEntityModeCache = GetEntityMode();
1065 myIsEntityModeCache=true;
1067 SetEntityMode(eFaces);
1069 else if(myControlActor == my3DActor) {
1070 if (!myIsEntityModeCache){
1071 myEntityModeCache = GetEntityMode();
1072 myIsEntityModeCache=true;
1074 SetEntityMode(eVolumes);
1077 QString aTitle = QString(myScalarBarActor->GetTitle());
1078 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1079 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1083 if(theCheckEntityMode){
1084 myEntityMode = myEntityModeCache;
1085 myIsEntityModeCache = false;
1090 SetRepresentation(GetRepresentation());
1092 myTimeStamp->Modified();
1095 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1096 double * range = lookupTable->GetRange();
1098 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1099 lookupTable->SetScale(VTK_SCALE_LOG10);
1104 int SMESH_ActorDef::GetNumberControlEntities()
1106 SMESH_DeviceActor* anAct = NULL;
1107 switch(myControlMode){
1109 case eCoincidentNodes:
1110 anAct = myNodeExtActor;
1114 case eCoincidentElems1D:
1115 anAct = my1DExtActor;
1118 case eBareBorderFace:
1119 case eOverConstrainedFace:
1120 case eCoincidentElems2D:
1121 anAct = my2DExtActor;
1123 case eBareBorderVolume:
1124 case eOverConstrainedVolume:
1125 case eCoincidentElems3D:
1126 anAct = my3DExtActor;
1130 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1133 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1135 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1137 myBaseActor->SetUnstructuredGrid( NULL );
1138 //myHighlitableActor->SetUnstructuredGrid( NULL );
1140 theRenderer->AddActor(myBaseActor);
1141 theRenderer->AddActor(myNodeExtActor);
1142 theRenderer->AddActor(my1DExtActor);
1144 my3DActor ->AddToRender(theRenderer);
1145 my3DExtActor->AddToRender(theRenderer);
1146 my2DActor ->AddToRender(theRenderer);
1147 my2DExtActor->AddToRender(theRenderer);
1148 myNodeActor ->AddToRender(theRenderer);
1149 my1DActor ->AddToRender(theRenderer);
1150 my0DActor ->AddToRender(theRenderer);
1151 myBallActor ->AddToRender(theRenderer);
1153 theRenderer->AddActor(myHighlitableActor);
1155 theRenderer->AddActor2D(myScalarBarActor);
1157 // the superclass' method should be called at the end
1158 // (in particular, for correct work of selection)
1159 SALOME_Actor::AddToRender(theRenderer);
1162 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1164 SALOME_Actor::RemoveFromRender(theRenderer);
1166 theRenderer->RemoveActor(myBaseActor);
1168 theRenderer->RemoveActor(myNodeExtActor);
1170 theRenderer->RemoveActor(myHighlitableActor);
1172 //theRenderer->RemoveActor(my0DExtActor);
1174 theRenderer->RemoveActor(my1DExtActor);
1176 my2DActor->RemoveFromRender(theRenderer);
1177 my2DExtActor->RemoveFromRender(theRenderer);
1178 my3DActor->RemoveFromRender(theRenderer);
1179 my3DExtActor->RemoveFromRender(theRenderer);
1180 myNodeActor->RemoveFromRender(theRenderer);
1181 my0DActor->RemoveFromRender(theRenderer);
1182 myBallActor->RemoveFromRender(theRenderer);
1183 my1DActor->RemoveFromRender(theRenderer);
1185 theRenderer->RemoveActor(myScalarBarActor);
1189 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1190 const char* theEntry,
1191 const char* theName,
1194 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1198 myVisualObj = theVisualObj;
1199 myVisualObj->Update(theIsClear);
1201 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1202 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1204 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1205 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1207 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1209 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1211 my0DActor->Init(myVisualObj,myImplicitBoolean);
1212 myBallActor->Init(myVisualObj,myImplicitBoolean);
1213 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1215 my1DActor->Init(myVisualObj,myImplicitBoolean);
1216 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1218 my2DActor->Init(myVisualObj,myImplicitBoolean);
1219 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1220 my3DActor->Init(myVisualObj,myImplicitBoolean);
1221 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1223 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1224 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1225 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1227 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1228 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1230 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1231 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1232 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1233 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1235 double aFactor, aUnits;
1236 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1237 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1238 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1239 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1241 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1245 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1246 SetIsShrunkable(true);
1248 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1250 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1251 SetRepresentation(-1);
1254 SetRepresentation(eEdge);
1255 }else if(aMode == 1){
1256 SetRepresentation(eSurface);
1257 }else if(aMode == 2){
1258 SetRepresentation(ePoint);
1265 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1266 SetIsDisplayNameActor( true );
1268 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1269 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1270 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1272 myTimeStamp->Modified();
1278 double* SMESH_ActorDef::GetBounds()
1280 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1281 return myNodeActor->GetBounds();
1282 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1286 vtkDataSet* SMESH_ActorDef::GetInput()
1288 return GetUnstructuredGrid();
1292 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1294 Superclass::SetTransform(theTransform);
1296 myNodeActor->SetTransform(theTransform);
1297 myBaseActor->SetTransform(theTransform);
1299 myHighlitableActor->SetTransform(theTransform);
1301 myNodeExtActor->SetTransform(theTransform);
1303 my0DActor->SetTransform(theTransform);
1304 myBallActor->SetTransform(theTransform);
1305 //my0DExtActor->SetTransform(theTransform);
1307 my1DActor->SetTransform(theTransform);
1308 my1DExtActor->SetTransform(theTransform);
1310 my2DActor->SetTransform(theTransform);
1311 my2DExtActor->SetTransform(theTransform);
1312 my3DActor->SetTransform(theTransform);
1313 my3DExtActor->SetTransform(theTransform);
1319 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1321 vtkLODActor::SetMapper(theMapper);
1325 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1327 SALOME_Actor::ShallowCopy(prop);
1331 vtkMapper* SMESH_ActorDef::GetMapper()
1333 return myPickableActor->GetMapper();
1337 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1339 return myVisualObj->GetUnstructuredGrid();
1343 bool SMESH_ActorDef::IsInfinitive()
1345 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1346 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1347 ( aDataSet->GetNumberOfCells() == 1 &&
1348 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1349 return SALOME_Actor::IsInfinitive();
1353 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1355 if ( myIsShrinkable == theShrunkable )
1357 myIsShrinkable = theShrunkable;
1361 double SMESH_ActorDef::GetShrinkFactor()
1363 return myBaseActor->GetShrinkFactor();
1366 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1368 myBaseActor->SetShrinkFactor(theValue);
1370 my1DActor->SetShrinkFactor(theValue);
1371 my1DExtActor->SetShrinkFactor(theValue);
1373 my2DActor->SetShrinkFactor(theValue);
1374 my2DExtActor->SetShrinkFactor(theValue);
1375 my3DActor->SetShrinkFactor(theValue);
1376 my3DExtActor->SetShrinkFactor(theValue);
1377 my3DExtActor->SetShrinkFactor(theValue);
1378 myHighlitableActor->SetShrinkFactor(theValue);
1383 void SMESH_ActorDef::SetShrink()
1385 if(!myIsShrinkable) return;
1387 myBaseActor->SetShrink();
1389 my1DActor->SetShrink();
1390 my1DExtActor->SetShrink();
1392 my2DActor->SetShrink();
1393 my2DExtActor->SetShrink();
1394 my3DActor->SetShrink();
1395 my3DExtActor->SetShrink();
1396 myHighlitableActor->SetShrink();
1402 void SMESH_ActorDef::UnShrink()
1404 if(!myIsShrunk) return;
1406 myBaseActor->UnShrink();
1408 my1DActor->UnShrink();
1409 my1DExtActor->UnShrink();
1411 my2DActor->UnShrink();
1412 my2DExtActor->UnShrink();
1413 my3DActor->UnShrink();
1414 my3DExtActor->UnShrink();
1415 myHighlitableActor->UnShrink();
1422 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1424 return myPickableActor->GetNodeObjId(theVtkID);
1427 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1429 return myPickableActor->GetNodeCoord(theObjID);
1433 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1435 return myPickableActor->GetElemObjId(theVtkID);
1438 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1440 return myPickableActor->GetElemCell(theObjID);
1444 void SMESH_ActorDef::SetVisibility(int theMode)
1446 SetVisibility(theMode,true);
1450 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1452 SALOME_Actor::SetVisibility(theMode);
1454 myNodeActor->VisibilityOff();
1455 myBaseActor->VisibilityOff();
1457 myNodeExtActor->VisibilityOff();
1459 my0DActor->VisibilityOff();
1460 myBallActor->VisibilityOff();
1461 //my0DExtActor->VisibilityOff();
1463 my1DActor->VisibilityOff();
1464 my1DExtActor->VisibilityOff();
1466 my2DActor->VisibilityOff();
1467 my2DExtActor->VisibilityOff();
1468 my3DActor->VisibilityOff();
1469 my3DExtActor->VisibilityOff();
1471 myScalarBarActor->VisibilityOff();
1473 if(GetVisibility()){
1474 if(theIsUpdateRepersentation)
1475 SetRepresentation(GetRepresentation());
1477 if(myControlMode != eNone) {
1478 switch(myControlMode) {
1480 case eCoincidentNodes:
1481 myNodeExtActor->VisibilityOn();
1484 case eMultiConnection:
1485 my1DActor->VisibilityOn();
1489 case eCoincidentElems1D:
1491 case eMultiConnection2D:
1492 my1DExtActor->VisibilityOn();
1495 case eBareBorderFace:
1496 case eOverConstrainedFace:
1497 case eCoincidentElems2D:
1498 my2DExtActor->VisibilityOn();
1500 case eBareBorderVolume:
1501 case eOverConstrainedVolume:
1502 case eCoincidentElems3D:
1503 my3DExtActor->VisibilityOn();
1507 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1508 myScalarBarActor->VisibilityOn();
1511 myPickableActor->VisibilityOn();
1513 if ( GetRepresentation() != ePoint )
1515 if(myEntityMode & e0DElements ){
1516 my0DActor->VisibilityOn();
1518 if(myEntityMode & eBallElem ){
1519 myBallActor->VisibilityOn();
1521 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1522 my1DActor->VisibilityOn();
1524 if(myEntityMode & eFaces ){
1525 my2DActor->VisibilityOn();
1527 if(myEntityMode & eVolumes ){
1528 my3DActor->VisibilityOn();
1532 if(myNodeActor->GetPointsLabeled()) {
1533 myNodeActor->UpdateLabels();
1534 myNodeActor->VisibilityOn();
1537 my0DActor->UpdateLabels();
1540 myBallActor->UpdateLabels();
1543 my1DActor->UpdateLabels();
1546 my2DActor->UpdateLabels();
1549 my3DActor->UpdateLabels();
1551 #ifndef DISABLE_PLOT2DVIEWER
1553 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1560 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1562 myEntityState = eAllEntity;
1564 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1565 myEntityState &= ~e0DElements;
1566 theMode &= ~e0DElements;
1569 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1570 myEntityState &= ~eBallElem;
1571 theMode &= ~eBallElem;
1574 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1575 myEntityState &= ~eEdges;
1579 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1580 myEntityState &= ~eFaces;
1584 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1585 myEntityState &= ~eVolumes;
1586 theMode &= ~eVolumes;
1590 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1591 theMode |= e0DElements;
1593 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1594 theMode |= eBallElem;
1596 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1599 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1602 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1603 theMode |= eVolumes;
1606 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1608 myEntityMode = theMode;
1610 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1611 aFilter->ClearRegisteredCellsWithType();
1612 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1613 aHightFilter->ClearRegisteredCellsWithType();
1616 (( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) &&
1617 ( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) &&
1618 ( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) &&
1619 ( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) &&
1620 ( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 ));
1621 if ( isPassAll && myEntityMode )
1623 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1624 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1628 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1629 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1631 if (myEntityMode & e0DElements) {
1632 aFilter->RegisterCellsWithType(VTK_VERTEX);
1633 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1636 if (myEntityMode & eBallElem) {
1637 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1640 if (myEntityMode & eEdges) {
1641 aFilter->RegisterCellsWithType(VTK_LINE);
1642 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1644 aHightFilter->RegisterCellsWithType(VTK_LINE);
1645 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1648 if (myEntityMode & eFaces) {
1649 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1650 aFilter->RegisterCellsWithType(VTK_QUAD);
1651 aFilter->RegisterCellsWithType(VTK_POLYGON);
1652 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1653 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1654 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1655 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1656 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1658 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1659 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1660 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1661 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1662 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1663 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1664 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1665 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1668 if (myEntityMode & eVolumes) {
1669 aFilter->RegisterCellsWithType(VTK_TETRA);
1670 aFilter->RegisterCellsWithType(VTK_VOXEL);
1671 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1672 aFilter->RegisterCellsWithType(VTK_WEDGE);
1673 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1674 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1675 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1676 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1677 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1678 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1679 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1680 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1681 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1683 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1684 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1685 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1686 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1687 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1688 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1689 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1690 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1691 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1692 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1693 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1694 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1695 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1698 if ( GetVisibility() )
1700 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1701 SetVisibility(GetVisibility(),false);
1704 void SMESH_ActorDef::SetRepresentation (int theMode)
1706 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1707 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1708 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1709 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1710 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1713 myRepresentation = eSurface;
1714 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1715 myRepresentation = eEdge;
1716 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1717 myRepresentation = ePoint;
1722 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1725 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1728 myRepresentation = theMode;
1731 if (!GetUnstructuredGrid()->GetNumberOfCells())
1732 myRepresentation = ePoint;
1735 if (myRepresentation == ePoint) {
1743 myPickableActor = myBaseActor;
1744 vtkProperty *aProp = NULL, *aBackProp = NULL;
1745 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1746 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1747 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1748 switch (myRepresentation) {
1750 myPickableActor = myNodeActor;
1751 aQuadraticMode = SMESH_Actor::eLines;
1752 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1753 aReperesent = SMESH_DeviceActor::ePoint;
1756 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1757 aReperesent = SMESH_DeviceActor::eInsideframe;
1760 aProp = mySurfaceProp;
1761 aBackProp = myBackSurfaceProp;
1762 aPropVN = myNormalVProp;
1763 aPropVR = myReversedVProp;
1764 aReperesent = SMESH_DeviceActor::eSurface;
1768 if ( myRepresentation != ePoint )
1770 my2DActor->SetProperty(aProp);
1771 my2DActor->SetBackfaceProperty(aBackProp);
1772 my2DActor->SetRepresentation(aReperesent);
1774 if(aQuadraticMode == SMESH_Actor::eLines)
1775 my2DActor->SetQuadraticArcMode(false);
1776 else if(aQuadraticMode == SMESH_Actor::eArcs)
1777 my2DActor->SetQuadraticArcMode(true);
1779 my2DExtActor->SetRepresentation(aReperesent);
1781 my3DActor->SetProperty(aPropVN);
1782 my3DActor->SetBackfaceProperty(aPropVR);
1783 my3DActor->SetRepresentation(aReperesent);
1785 my0DActor->SetRepresentation(aReperesent);
1786 myBallActor->SetRepresentation(aReperesent);
1788 switch ( myControlMode ) {
1790 case eMultiConnection:
1791 aProp = aBackProp = my1DProp;
1792 if(myRepresentation != ePoint)
1793 aReperesent = SMESH_DeviceActor::eInsideframe;
1798 if(aQuadraticMode == SMESH_Actor::eLines)
1799 my1DActor->SetQuadraticArcMode(false);
1800 else if(aQuadraticMode == SMESH_Actor::eArcs)
1801 my1DActor->SetQuadraticArcMode(true);
1803 my1DActor->SetProperty(aProp);
1804 my1DActor->SetBackfaceProperty(aBackProp);
1805 my1DActor->SetRepresentation(aReperesent);
1807 my1DExtActor->SetRepresentation(aReperesent);
1810 if(myIsPointsVisible)
1811 myPickableActor = myNodeActor;
1813 SetMapper(myPickableActor->GetMapper());
1815 SetVisibility(GetVisibility(),false);
1821 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1823 if ( myIsPointsVisible == theIsPointsVisible )
1825 myIsPointsVisible = theIsPointsVisible;
1826 SetRepresentation(GetRepresentation());
1829 bool SMESH_ActorDef::GetPointRepresentation()
1831 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1835 void SMESH_ActorDef::UpdateHighlight()
1837 myHighlitableActor->SetHighlited(false);
1838 myHighlitableActor->SetVisibility(false);
1839 bool anIsVisible = GetVisibility();
1841 switch(myRepresentation){
1842 case SMESH_DeviceActor::eSurface:
1843 case SMESH_DeviceActor::eWireframe:
1845 if(myIsHighlighted) {
1846 myHighlitableActor->SetProperty(myHighlightProp);
1847 }else if(myIsPreselected){
1848 myHighlitableActor->SetProperty(myPreselectProp);
1849 } else if(anIsVisible){
1850 (myRepresentation == eSurface) ?
1851 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1853 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1854 myHighlitableActor->SetHighlited(anIsVisible);
1855 myHighlitableActor->GetExtractUnstructuredGrid()->
1856 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1857 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1859 myHighlitableActor->SetVisibility(anIsVisible);
1862 case SMESH_DeviceActor::ePoint:
1864 if(myIsHighlighted) {
1865 myNodeActor->SetProperty(myHighlightProp);
1866 }else if(myIsPreselected) {
1867 myNodeActor->SetProperty(myPreselectProp);
1868 } else if(anIsVisible) {
1869 myNodeActor->SetProperty(myNodeProp);
1871 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1872 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1873 myNodeActor->GetProperty()->Modified();
1879 void SMESH_ActorDef::EnableSelection( bool enable )
1881 // selection in the Viewer enabled/disabled
1882 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1884 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1885 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1886 myBaseActor->myExtractUnstructuredGrid->Update();
1887 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1889 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1891 myBaseActor->SetUnstructuredGrid( NULL );
1892 //myHighlitableActor->SetUnstructuredGrid( NULL );
1893 myBaseActor->myExtractUnstructuredGrid->Update();
1894 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1898 void SMESH_ActorDef::highlight(bool theHighlight)
1900 if ( myIsHighlighted == theHighlight )
1902 myIsHighlighted = theHighlight;
1907 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1909 if ( myIsPreselected == thePreselect )
1911 myIsPreselected = thePreselect;
1917 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1919 if (myPickableActor->GetIsOpaque())
1921 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1929 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1931 if (!myPickableActor->GetIsOpaque())
1933 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1941 void SMESH_ActorDef::Render(vtkRenderer *ren)
1943 vtkMTimeType aTime = myTimeStamp->GetMTime();
1944 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1945 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1946 if(anObjTime > aTime || aClippingTime > aTime)
1951 void SMESH_ActorDef::Update()
1953 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1955 myVisualObj->Update();
1957 if(GetControlMode() != eNone) {
1958 unsigned long aTime = myTimeStamp->GetMTime();
1959 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1960 if (anObjTime > aTime)
1961 SetControlMode(GetControlMode(),false);
1965 myNodeActor->UpdateLabels();
1968 my0DActor->UpdateLabels();
1971 myBallActor->UpdateLabels();
1974 my1DActor->UpdateLabels();
1977 my2DActor->UpdateLabels();
1980 my3DActor->UpdateLabels();
1982 if(myIsFacesOriented){
1983 SetFacesOriented(myIsFacesOriented);
1986 if(myVisualObj->GetEntitiesFlag()) {
1987 myEntityMode |= myVisualObj->GetEntitiesState();
1990 SetEntityMode(GetEntityMode());
1991 SetVisibility(GetVisibility());
1993 myTimeStamp->Modified();
1998 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2000 SALOME_Actor::ReleaseGraphicsResources(renWin);
2002 myPickableActor->ReleaseGraphicsResources(renWin);
2006 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2008 double* aColor = theProperty->GetColor();
2015 void SMESH_ActorDef::SetOpacity(double theValue)
2017 mySurfaceProp->SetOpacity(theValue);
2018 myBackSurfaceProp->SetOpacity(theValue);
2019 myNormalVProp->SetOpacity(theValue);
2020 myReversedVProp->SetOpacity(theValue);
2021 myEdgeProp->SetOpacity(theValue);
2022 myOutLineProp->SetOpacity(theValue);
2023 myNodeProp->SetOpacity(theValue);
2025 my1DProp->SetOpacity(theValue);
2026 my0DProp->SetOpacity(theValue);
2027 myBallProp->SetOpacity(theValue);
2031 double SMESH_ActorDef::GetOpacity()
2033 return mySurfaceProp->GetOpacity();
2037 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2039 mySurfaceProp->SetColor(r,g,b);
2040 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2041 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2042 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2043 myNameActor->SetBackgroundColor(r,g,b);
2045 myDeltaBrightness = delta;
2046 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2047 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2051 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2053 ::GetColor(mySurfaceProp,r,g,b);
2054 delta = myDeltaBrightness;
2057 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2059 myNormalVProp->SetColor(r,g,b);
2060 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2061 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2062 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2063 myNameActor->SetBackgroundColor(r,g,b);
2065 myDeltaVBrightness = delta;
2066 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2067 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2071 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2073 ::GetColor(myNormalVProp,r,g,b);
2074 delta = myDeltaVBrightness;
2077 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2079 myEdgeProp->SetColor(r,g,b);
2080 my1DProp->SetColor(r,g,b);
2081 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2082 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2083 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2084 myNameActor->SetBackgroundColor(r,g,b);
2088 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2090 ::GetColor(myEdgeProp,r,g,b);
2093 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2095 myOutLineProp->SetColor(r,g,b);
2099 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2101 ::GetColor(myOutLineProp,r,g,b);
2105 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2107 myNodeProp->SetColor(r,g,b);
2108 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2109 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2110 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2111 myNameActor->SetBackgroundColor(r,g,b);
2115 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2117 ::GetColor(myNodeProp,r,g,b);
2120 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2122 my0DProp->SetColor(r,g,b);
2123 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2124 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2125 myNameActor->SetBackgroundColor(r,g,b);
2129 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2131 ::GetColor(my0DProp,r,g,b);
2134 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2136 myBallProp->SetColor(r,g,b);
2137 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2138 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2139 myNameActor->SetBackgroundColor(r,g,b);
2143 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2145 ::GetColor(myBallProp,r,g,b);
2148 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2150 myHighlightProp->SetColor(r,g,b);
2154 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2156 ::GetColor(myHighlightProp,r,g,b);
2159 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2161 myPreselectProp->SetColor(r,g,b);
2165 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2167 ::GetColor(myPreselectProp,r,g,b);
2171 double SMESH_ActorDef::GetLineWidth()
2173 return myEdgeProp->GetLineWidth();
2177 void SMESH_ActorDef::SetLineWidth(double theVal)
2179 myEdgeProp->SetLineWidth(theVal);
2181 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2182 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2183 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2184 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2185 myOutLineProp->SetLineWidth(theVal);
2186 myHighlightProp->SetLineWidth(theVal);
2187 myPreselectProp->SetLineWidth(theVal);
2191 double SMESH_ActorDef::GetOutlineWidth()
2193 return myOutLineProp->GetLineWidth();
2196 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2198 myOutLineProp->SetLineWidth(theVal);
2202 void SMESH_ActorDef::Set0DSize(double theVal)
2204 my0DProp->SetPointSize(theVal);
2205 myHighlightProp->SetPointSize(theVal);
2206 myPreselectProp->SetPointSize(theVal);
2208 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2209 aCustom->Set0DSize(theVal);
2211 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2212 aCustom->Set0DSize(theVal);
2218 double SMESH_ActorDef::Get0DSize()
2220 return my0DProp->GetPointSize();
2223 void SMESH_ActorDef::SetBallSize(double theVal)
2225 myBallProp->SetPointSize(theVal);
2227 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2228 aCustom->SetBallSize(theVal);
2230 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2231 aCustom->SetBallSize(theVal);
2237 double SMESH_ActorDef::GetBallSize()
2239 return myBallProp->GetPointSize();
2242 double SMESH_ActorDef::GetBallScale()
2244 return myBallActor->GetBallScale();
2247 void SMESH_ActorDef::SetBallScale( double theVal )
2249 myBallActor->SetBallScale( theVal );
2250 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2251 aCustom->SetBallScale(theVal);
2253 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2254 aCustom->SetBallScale(theVal);
2260 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2262 return myVisualObj->GetElemDimension( theObjId );
2265 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2267 return myBaseActor->IsImplicitFunctionUsed();
2270 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2272 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2273 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2275 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2277 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2279 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2280 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2281 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2283 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2284 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2286 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2287 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2288 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2289 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2292 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2295 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2296 myCippingPlaneCont.push_back(thePlane);
2297 if(!IsImplicitFunctionUsed())
2298 SetImplicitFunctionUsed(true);
2299 myNodeActor->UpdateLabels();
2301 return myCippingPlaneCont.size();
2304 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2307 myPlaneCollection->AddItem( thePlane );
2310 void SMESH_ActorDef::SetOpenGLClippingPlane()
2312 // before use this method you must add clipping planes using method
2313 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2314 if( !myPlaneCollection->GetNumberOfItems() )
2317 // It is necessary to set plane collection for each mapper of actor
2318 // and update current inputs of mapper
2319 myNodeActor->SetPlaneCollection( myPlaneCollection );
2320 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2322 myBaseActor->SetPlaneCollection( myPlaneCollection );
2323 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2325 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2326 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2328 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2330 myBaseActor->SetUnstructuredGrid( NULL );
2331 //myHighlitableActor->SetUnstructuredGrid( NULL );
2333 my1DActor->SetPlaneCollection( myPlaneCollection );
2334 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2336 my2DActor->SetPlaneCollection( myPlaneCollection );
2337 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2339 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2340 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2342 my0DActor->SetPlaneCollection( myPlaneCollection );
2343 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2345 myBallActor->SetPlaneCollection( myPlaneCollection );
2346 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2348 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2349 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2351 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2352 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2354 my3DActor->SetPlaneCollection( myPlaneCollection );
2355 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2357 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2358 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2366 void SMESH_ActorDef::RemoveAllClippingPlanes()
2368 myPlaneCollection->RemoveAllItems();
2369 myImplicitBoolean->GetFunction()->RemoveAllItems();
2370 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2371 myCippingPlaneCont.clear();
2372 SetImplicitFunctionUsed(false);
2373 myNodeActor->UpdateLabels();
2376 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2378 return myCippingPlaneCont.size();
2381 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2383 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2385 return myCippingPlaneCont[theID].Get();
2388 void SMESH_ActorDef::UpdateScalarBar()
2390 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2394 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2396 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2397 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2399 aScalarBarTitleProp->SetFontFamilyToArial();
2401 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2403 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2404 if ( f.family() == "Arial" )
2405 aScalarBarTitleProp->SetFontFamilyToArial();
2406 else if ( f.family() == "Courier" )
2407 aScalarBarTitleProp->SetFontFamilyToCourier();
2408 else if ( f.family() == "Times" )
2409 aScalarBarTitleProp->SetFontFamilyToTimes();
2412 aScalarBarTitleProp->BoldOn();
2414 aScalarBarTitleProp->BoldOff();
2417 aScalarBarTitleProp->ItalicOn();
2419 aScalarBarTitleProp->ItalicOff();
2422 aScalarBarTitleProp->ShadowOn();
2424 aScalarBarTitleProp->ShadowOff();
2427 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2428 aScalarBarTitleProp->Delete();
2430 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2432 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2433 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2435 aScalarBarLabelProp->SetFontFamilyToArial();
2436 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2438 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2439 if( f.family() == "Arial" )
2440 aScalarBarLabelProp->SetFontFamilyToArial();
2441 else if( f.family() == "Courier" )
2442 aScalarBarLabelProp->SetFontFamilyToCourier();
2443 else if( f.family() == "Times" )
2444 aScalarBarLabelProp->SetFontFamilyToTimes();
2447 aScalarBarLabelProp->BoldOn();
2449 aScalarBarLabelProp->BoldOff();
2452 aScalarBarLabelProp->ItalicOn();
2454 aScalarBarLabelProp->ItalicOff();
2457 aScalarBarLabelProp->ShadowOn();
2459 aScalarBarLabelProp->ShadowOff();
2462 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2463 aScalarBarLabelProp->Delete();
2465 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2466 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2468 myScalarBarActor->SetOrientationToHorizontal();
2470 myScalarBarActor->SetOrientationToVertical();
2473 double aXVal = horiz ? 0.20 : 0.01;
2474 if( mgr->hasValue( "SMESH", name + "x" ) )
2475 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2477 double aYVal = horiz ? 0.01 : 0.1;
2478 if( mgr->hasValue( "SMESH", name + "y" ) )
2479 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2480 myScalarBarActor->SetPosition( aXVal, aYVal );
2482 double aWVal = horiz ? 0.60 : 0.10;
2483 if( mgr->hasValue( "SMESH", name + "width" ) )
2484 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2485 myScalarBarActor->SetWidth( aWVal );
2487 double aHVal = horiz ? 0.12 : 0.80;
2488 if( mgr->hasValue( "SMESH", name + "height" ) )
2489 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2490 myScalarBarActor->SetHeight( aHVal );
2493 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2494 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2495 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2498 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2499 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2500 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2502 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2503 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2505 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2506 myScalarBarActor->SetDistributionColoringType(coloringType);
2508 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2509 QColor(255, 255, 255));
2511 rgb[0]= distributionColor.red()/255.;
2512 rgb[1]= distributionColor.green()/255.;
2513 rgb[2]= distributionColor.blue()/255.;
2514 myScalarBarActor->SetDistributionColor(rgb);
2519 void SMESH_ActorDef::UpdateDistribution()
2521 if(SMESH::Controls::NumericalFunctor* fun =
2522 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2524 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2525 std::vector<int> nbEvents;
2526 std::vector<double> funValues;
2527 SMESH_VisualObjDef::TEntityList elems;
2528 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2529 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2530 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2531 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2532 elemIds.push_back( (*e)->GetID());
2533 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2534 double * range = lookupTable->GetRange();
2535 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2536 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2537 myScalarBarActor->SetDistribution(nbEvents);
2541 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2544 case SMESH_Actor::eLines :
2545 myHighlitableActor->SetQuadraticArcMode(false);
2546 my2DActor->SetQuadraticArcMode(false);
2547 my1DActor->SetQuadraticArcMode(false);
2549 case SMESH_Actor::eArcs :
2550 myHighlitableActor->SetQuadraticArcMode(true);
2551 if(GetRepresentation() != SMESH_Actor::ePoint) {
2552 my2DActor->SetQuadraticArcMode(true);
2553 my1DActor->SetQuadraticArcMode(true);
2562 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2564 if(myHighlitableActor->GetQuadraticArcMode())
2565 return SMESH_Actor::eArcs;
2567 return SMESH_Actor::eLines;
2570 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2572 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2573 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2574 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2577 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2579 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2580 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2581 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2582 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2585 #ifndef DISABLE_PLOT2DVIEWER
2586 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2589 my2dHistogram->clearAllPoints();
2591 if(SMESH::Controls::NumericalFunctor* fun =
2592 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2595 if(!my2dHistogram) {
2596 my2dHistogram = new SPlot2d_Histogram();
2597 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2598 my2dHistogram->setIO(anIO);
2601 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2602 std::vector<int> nbEvents;
2603 std::vector<double> funValues;
2604 SMESH_VisualObjDef::TEntityList elems;
2605 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2606 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2607 std::vector<int> elemIds;
2609 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2610 elemIds.push_back( (*e)->GetID());
2612 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2613 double * range = lookupTable->GetRange();
2614 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2615 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2617 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2618 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2620 if(funValues.size() >= 2)
2621 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2625 //Color of the histogram
2626 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2627 my2dHistogram->setAutoAssign(true);
2630 myScalarBarActor->GetDistributionColor(rgb);
2631 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2632 my2dHistogram->setColor(aColor);
2636 return my2dHistogram;