1 // Copyright (C) 2007-2022 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_ActorProps.h"
32 #include "SMESH_ActorUtils.h"
33 #include "SMESH_CellLabelActor.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMESH_DeviceActor.h"
36 #include "SMESH_NodeLabelActor.h"
37 #include "SMESH_ObjectDef.h"
38 #include "SMESH_SVTKActor.h"
39 #include "SMESH_ScalarBarActor.h"
42 #include <SALOME_InteractiveObject.hxx>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <VTKViewer_ExtractUnstructuredGrid.h>
46 #include <VTKViewer_FramedTextActor.h>
48 #ifndef DISABLE_PLOT2DVIEWER
49 #include <SPlot2d_Histogram.h>
52 #include <vtkProperty.h>
53 #include <vtkTimeStamp.h>
54 #include <vtkObjectFactory.h>
55 #include <vtkShrinkPolyData.h>
56 #include <vtkMergeFilter.h>
58 #include <vtkMatrix4x4.h>
59 #include <vtkUnstructuredGrid.h>
60 #include <vtkPointData.h>
61 #include <vtkCellData.h>
63 #include <vtkMapper.h>
64 #include <vtkRenderer.h>
67 #include <vtkIdList.h>
68 #include <vtkIntArray.h>
70 #include <vtkActor2D.h>
71 #include <vtkProperty2D.h>
72 #include <vtkPolyData.h>
73 #include <vtkTextProperty.h>
75 #include <vtkLookupTable.h>
79 #include <vtkPlaneCollection.h>
80 #include <vtkImplicitBoolean.h>
81 #include <vtkImplicitFunctionCollection.h>
83 #include "utilities.h"
86 SMESH_ActorDef* SMESH_ActorDef::New(){
87 return new SMESH_ActorDef();
91 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
96 SMESH_ActorDef* anActor = NULL;
97 if(theVisualObj->IsValid() ) {
98 anActor = SMESH_ActorDef::New();
99 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
104 anActor->UpdateScalarBar();
110 SMESH_ActorDef::SMESH_ActorDef()
112 MESSAGE("SMESH_ActorDef - "<<this);
114 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
116 myBaseActor = SMESH_DeviceActor::New();
118 myTimeStamp = vtkTimeStamp::New();
120 myIsPointsVisible = false;
121 myIsEntityModeCache = false;
122 myRepresentationCache = 0;
124 myHighlightActor = SMESH_SVTKActor::New();
125 myHighlightActor->Delete(); // vtkSmartPointer!
126 myHighlightActor->Initialize();
128 myPreHighlightActor = SMESH_SVTKActor::New();
129 myPreHighlightActor->Delete();
130 myPreHighlightActor->Initialize();
132 myIsShrinkable = false;
135 myIsFacesOriented = false;
137 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
138 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
140 myControlsPrecision = -1;
141 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
143 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
144 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
146 float aElem0DSize = (float) SMESH::GetFloat("SMESH:elem0d_size",5);
147 float aBallElemSize = (float) SMESH::GetFloat("SMESH:ball_elem_size",10);
148 float aBallElemScale = (float) SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
149 float aLineWidth = (float) SMESH::GetFloat("SMESH:element_width",1);
150 float aOutlineWidth = (float) SMESH::GetFloat("SMESH:outline_width",1);
152 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
154 bool anItalicNd = false;
155 bool aShadowNd = false;
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;
163 anItalicNd = f.italic();
164 aShadowNd = f.overline();
165 aSizeNd = f.pointSize();
167 double anRGBNd[3] = {1,1,1};
168 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
170 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
172 bool anItalicEl = false;
173 bool aShadowEl = false;
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;
181 anItalicEl = f.italic();
182 aShadowEl = f.overline();
183 aSizeEl = f.pointSize();
185 double anRGBEl[3] = {0,1,0};
186 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
188 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
189 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
191 //Definition 2D and 3D devices of the actor
192 //-----------------------------------------
193 double anRGB[3] = {1,1,1};
194 mySurfaceProp = vtkProperty::New();
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;
201 myBackSurfaceProp = vtkProperty::New();
202 bfc = Qtx::mainColorToSecondary(ffc, delta);
203 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
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;
210 myReversedVProp = vtkProperty::New();
211 bfc = Qtx::mainColorToSecondary(ffc, delta);
212 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
214 my2DActor = SMESH_CellLabelActor::New();
215 my2DActor->SetStoreClippingMapping(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);
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->SetLineWidth(aLineWidth + controlsIncrement);
240 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
242 my2DExtActor = SMESH_DeviceActor::New();
243 my2DExtActor->SetUserMatrix(aMatrix);
244 my2DExtActor->PickableOff();
245 my2DExtActor->SetProperty(my2DExtProp);
246 my2DExtActor->SetBackfaceProperty(my2DExtProp);
247 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
248 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
249 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
250 aFilter->RegisterCellsWithType(VTK_QUAD);
251 aFilter->RegisterCellsWithType(VTK_POLYGON);
252 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
255 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
256 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
258 my3DActor = SMESH_CellLabelActor::New();
259 my3DActor->SetStoreClippingMapping(true);
260 my3DActor->SetUserMatrix(aMatrix);
261 my3DActor->PickableOff();
262 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
263 my3DActor->SetProperty(myNormalVProp);
264 my3DActor->SetBackfaceProperty(myReversedVProp);
265 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
266 my3DActor->SetCoincident3DAllowed(true);
267 aFilter = my3DActor->GetExtractUnstructuredGrid();
268 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
269 aFilter->RegisterCellsWithType(VTK_TETRA);
270 aFilter->RegisterCellsWithType(VTK_VOXEL);
271 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
272 aFilter->RegisterCellsWithType(VTK_WEDGE);
273 aFilter->RegisterCellsWithType(VTK_PYRAMID);
274 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
275 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
276 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
277 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
279 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
281 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
282 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
284 my3DExtProp = vtkProperty::New();
285 my3DExtProp->DeepCopy(myNormalVProp);
286 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
287 anRGB[0] = 1 - anRGB[0];
288 anRGB[1] = 1 - anRGB[1];
289 anRGB[2] = 1 - anRGB[2];
290 my3DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
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_BIQUADRATIC_QUADRATIC_WEDGE);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
314 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
315 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
317 //Definition 1D device of the actor
318 //---------------------------------
319 myEdgeProp = vtkProperty::New();
320 myEdgeProp->SetAmbient(1.0);
321 myEdgeProp->SetDiffuse(0.0);
322 myEdgeProp->SetSpecular(0.0);
323 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
324 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
325 myEdgeProp->SetLineWidth(aLineWidth);
327 // my1DActor is used to
329 // - show controls on all edges (eg Length)
330 // since edges are shown by myHighlitableActor
331 my1DActor = SMESH_CellLabelActor::New();
332 my1DActor->SetStoreClippingMapping(true);
333 my1DActor->SetUserMatrix(aMatrix);
334 my1DActor->PickableOff();
335 my1DActor->SetHighlited(true);
336 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
337 my1DActor->SetProperty(myEdgeProp);
338 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
339 aFilter = my1DActor->GetExtractUnstructuredGrid();
340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
341 aFilter->RegisterCellsWithType(VTK_LINE);
342 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
344 my1DProp = vtkProperty::New();
345 my1DProp->DeepCopy(myEdgeProp);
346 my1DProp->SetLineWidth(aLineWidth + controlsIncrement);
347 my1DProp->SetPointSize(aElem0DSize);
349 my1DExtProp = vtkProperty::New();
350 my1DExtProp->DeepCopy(myEdgeProp);
351 anRGB[0] = 1 - anRGB[0];
352 anRGB[1] = 1 - anRGB[1];
353 anRGB[2] = 1 - anRGB[2];
354 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
355 my1DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
356 my1DExtProp->SetPointSize(aElem0DSize);
358 // my1DExtActor is used to show filtered edges or links between nodes
359 my1DExtActor = SMESH_DeviceActor::New();
360 my1DExtActor->SetUserMatrix(aMatrix);
361 my1DExtActor->PickableOff();
362 my1DExtActor->SetHighlited(true);
363 my1DExtActor->SetVisibility(false);
364 my1DExtActor->SetProperty(my1DExtProp);
365 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
366 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
367 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
368 aFilter->RegisterCellsWithType(VTK_LINE);
369 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
372 //Definition 0D device of the actor (0d elements)
373 //-----------------------------------------------
374 my0DProp = vtkProperty::New();
375 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
376 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
377 my0DProp->SetPointSize(aElem0DSize);
379 my0DActor = SMESH_CellLabelActor::New();
380 my0DActor->SetUserMatrix(aMatrix);
381 my0DActor->SetStoreClippingMapping(true);
382 my0DActor->PickableOff();
383 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
384 my0DActor->SetVisibility(false);
385 my0DActor->SetProperty(my0DProp);
386 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
387 aFilter = my0DActor->GetExtractUnstructuredGrid();
388 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
389 aFilter->RegisterCellsWithType(VTK_VERTEX);
391 //Definition 0D device of the actor (ball elements)
392 //-----------------------------------------------
393 myBallProp = vtkProperty::New();
394 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
395 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
396 myBallProp->SetPointSize(aBallElemSize);
398 myBallActor = SMESH_CellLabelActor::New();
399 myBallActor->SetUserMatrix(aMatrix);
400 myBallActor->SetStoreClippingMapping(true);
401 myBallActor->PickableOff();
402 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
403 myBallActor->SetVisibility(false);
404 myBallActor->SetProperty(myBallProp);
405 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
406 myBallActor->SetBallEnabled(true);
407 aFilter = myBallActor->GetExtractUnstructuredGrid();
408 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
409 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
411 //my0DExtProp = vtkProperty::New();
412 //my0DExtProp->DeepCopy(my0DProp);
413 //anRGB[0] = 1 - anRGB[0];
414 //anRGB[1] = 1 - anRGB[1];
415 //anRGB[2] = 1 - anRGB[2];
416 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
417 //my0DExtProp->SetPointSize(aElem0DSize);
419 //my0DExtActor = SMESH_DeviceActor::New();
420 //my0DExtActor->SetUserMatrix(aMatrix);
421 //my0DExtActor->SetStoreClippingMapping(true);
422 //my0DExtActor->PickableOff();
423 //my0DExtActor->SetHighlited(true);
424 //my0DExtActor->SetVisibility(false);
425 //my0DExtActor->SetProperty(my0DExtProp);
426 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
427 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
428 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
429 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
430 //aFilter->RegisterCellsWithType(VTK_VERTEX);
433 //Definition 0D device of the actor (nodes)
434 //-----------------------------------------
435 myNodeProp = vtkProperty::New();
436 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
437 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
439 myNodeActor = SMESH_NodeLabelActor::New();
440 myNodeActor->SetUserMatrix(aMatrix);
441 myNodeActor->SetStoreClippingMapping(true);
442 myNodeActor->PickableOff();
443 myNodeActor->SetVisibility(false);
444 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
445 myNodeActor->SetProperty(myNodeProp);
446 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
447 aFilter = myNodeActor->GetExtractUnstructuredGrid();
448 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
450 myNodeExtProp = vtkProperty::New();
451 myNodeExtProp->DeepCopy(myNodeProp);
452 anRGB[0] = 1 - anRGB[0];
453 anRGB[1] = 1 - anRGB[1];
454 anRGB[2] = 1 - anRGB[2];
455 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
457 myNodeExtActor = SMESH_DeviceActor::New();
458 myNodeExtActor->SetUserMatrix(aMatrix);
459 myNodeExtActor->SetStoreClippingMapping(true);
460 myNodeExtActor->PickableOff();
461 myNodeExtActor->SetHighlited(true);
462 myNodeExtActor->SetVisibility(false);
463 myNodeExtActor->SetProperty(myNodeExtProp);
464 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
465 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
466 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
467 aFilter->RegisterCellsWithType(VTK_VERTEX);
469 //Definition of Pickable and Highlitable engines
470 //----------------------------------------------
472 myBaseActor->SetUserMatrix(aMatrix);
473 myBaseActor->SetStoreIDMapping(true);
474 myBaseActor->SetStoreClippingMapping(true);
475 myBaseActor->SetStoreGemetryMapping(true);
476 myBaseActor->GetProperty()->SetOpacity(0.0);
477 myPickableActor = myBaseActor;
479 myHighlightProp = vtkProperty::New();
480 myHighlightProp->SetAmbient(1.0);
481 myHighlightProp->SetDiffuse(0.0);
482 myHighlightProp->SetSpecular(0.0);
483 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
484 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
485 myHighlightProp->SetPointSize(aElem0DSize); // ??
486 myHighlightProp->SetLineWidth(aLineWidth + selectionIncrement);
487 myHighlightProp->SetRepresentation(1);
489 myOutLineProp = vtkProperty::New();
490 myOutLineProp->SetAmbient(1.0);
491 myOutLineProp->SetDiffuse(0.0);
492 myOutLineProp->SetSpecular(0.0);
493 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
494 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
495 myOutLineProp->SetLineWidth(aOutlineWidth);
496 myOutLineProp->SetRepresentation(1);
498 myPreselectProp = vtkProperty::New();
499 myPreselectProp->SetAmbient(1.0);
500 myPreselectProp->SetDiffuse(0.0);
501 myPreselectProp->SetSpecular(0.0);
502 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
503 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
504 myPreselectProp->SetPointSize(aElem0DSize); // ??
505 myPreselectProp->SetLineWidth(aLineWidth + selectionIncrement);
506 myPreselectProp->SetRepresentation(1);
508 myHighlitableActor = SMESH_DeviceActor::New();
509 myHighlitableActor->SetUserMatrix(aMatrix);
510 myHighlitableActor->PickableOff();
511 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
512 myHighlitableActor->SetCoincident3DAllowed(true);
519 myControlMode = eNone;
520 myControlActor = my2DActor;
522 //Definition of myScalarBarActor
523 //------------------------------
524 myLookupTable = vtkLookupTable::New();
525 //Fix for Bug PAL5195 - SMESH764:
526 //Controls - Aspect Ratio: incorrect colors of the best and worst values
527 myLookupTable->SetHueRange(0.667,0.0);
529 myScalarBarActor = SMESH_ScalarBarActor::New();
530 myScalarBarActor->SetVisibility(false);
531 myScalarBarActor->SetLookupTable(myLookupTable);
534 //Incorrect "Min value" in Scalar Bar in Mesh:
535 // myScalarBarActor->SetLabelFormat("%.4g");
536 // changes was commented because of regression bug IPAL 19981
538 mgr = SUIT_Session::session()->resourceMgr();
542 myEntityMode = eAllEntity;
543 myEntityModeCache = eAllEntity;
546 myImplicitBoolean = vtkImplicitBoolean::New();
547 myImplicitBoolean->SetOperationTypeToIntersection();
549 myPlaneCollection = vtkPlaneCollection::New();
551 //Quadratic 2D elements representation
552 //-----------------------------------------------------------------------------
553 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
554 if(aQuadratic2DMode == 0){
555 myHighlitableActor->SetQuadraticArcMode(false);
556 my2DActor->SetQuadraticArcMode(false);
557 my1DActor->SetQuadraticArcMode(false);
559 else if(aQuadratic2DMode == 1){
560 myHighlitableActor->SetQuadraticArcMode(true);
561 my2DActor->SetQuadraticArcMode(true);
562 my1DActor->SetQuadraticArcMode(true);
565 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
566 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
567 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
569 // Set colors of the name actor
570 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
571 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
572 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
573 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
575 #ifndef DISABLE_PLOT2DVIEWER
579 SetBallSize(aBallElemSize);
580 SetBallScale(aBallElemScale);
581 Set0DSize(aElem0DSize);
585 SMESH_ActorDef::~SMESH_ActorDef()
587 MESSAGE("~SMESH_ActorDef - "<<this);
589 // Please keep the order same as one in the header file
591 myTimeStamp->Delete();
593 myScalarBarActor->Delete();
594 myLookupTable->Delete();
596 mySurfaceProp->Delete();
597 myBackSurfaceProp->Delete();
598 myNormalVProp->Delete();
599 myReversedVProp->Delete();
600 myEdgeProp->Delete();
601 myNodeProp->Delete();
603 myNodeActor->Delete();
604 myBaseActor->Delete();
605 //myPickableActor->Delete(); myPickableActor == myBaseActor
607 myHighlightProp->Delete();
608 myOutLineProp->Delete();
609 myPreselectProp->Delete();
611 myHighlitableActor->Delete();
613 my2DExtProp->Delete();
614 my3DExtProp->Delete();
616 my2DExtActor->Delete();
618 my3DExtActor->Delete();
619 // myControlActor->Delete(); myControlActor == my2DActor
621 myNodeExtProp->Delete();
622 myNodeExtActor->Delete();
626 my1DExtProp->Delete();
627 my1DExtActor->Delete();
631 myBallProp->Delete();
632 myBallActor->Delete();
633 //my0DExtProp->Delete();
634 //my0DExtActor->Delete();
636 myImplicitBoolean->Delete();
637 myPlaneCollection->Delete();
639 #ifndef DISABLE_PLOT2DVIEWER
641 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
642 delete my2dHistogram;
647 void SMESH_ActorDef::Delete()
649 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
650 // from the actor's destructor) will be thrown before removing the actor's observers,
651 // that is done inside the Superclass::Delete() method but before the destructor itself
652 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
653 // The event is caught by SMESHGUI::ProcessEvents() static method.
654 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
656 Superclass::Delete();
659 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
662 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
663 SetRepresentation(GetRepresentation());
664 myTimeStamp->Modified();
668 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
669 bool theBold, bool theItalic, bool theShadow,
670 double r, double g, double b )
673 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
674 SetRepresentation( GetRepresentation() );
675 myTimeStamp->Modified();
679 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
680 bool theBold, bool theItalic, bool theShadow,
681 double r, double g, double b )
684 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
687 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
688 SetRepresentation( GetRepresentation() );
689 myTimeStamp->Modified();
692 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
693 SetRepresentation( GetRepresentation() );
694 myTimeStamp->Modified();
697 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
698 SetRepresentation( GetRepresentation() );
699 myTimeStamp->Modified();
702 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
703 SetRepresentation( GetRepresentation() );
704 myTimeStamp->Modified();
708 bool SMESH_ActorDef::GetPointsLabeled()
710 return myNodeActor && myNodeActor->GetPointsLabeled();
713 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
716 my3DActor->SetCellsLabeled(theIsCellsLabeled);
719 my2DActor->SetCellsLabeled(theIsCellsLabeled);
722 my1DActor->SetCellsLabeled(theIsCellsLabeled);
725 my0DActor->SetCellsLabeled(theIsCellsLabeled);
728 myBallActor->SetCellsLabeled(theIsCellsLabeled);
730 SetRepresentation(GetRepresentation());
731 myTimeStamp->Modified();
735 bool SMESH_ActorDef::GetCellsLabeled()
739 result = result || my3DActor->GetCellsLabeled();
742 result = result || my2DActor->GetCellsLabeled();
745 result = result || my1DActor->GetCellsLabeled();
748 result = result || my0DActor->GetCellsLabeled();
751 result = result || myBallActor->GetCellsLabeled();
757 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
759 myIsFacesOriented = theIsFacesOriented;
761 my2DActor->SetFacesOriented(theIsFacesOriented);
762 my3DActor->SetFacesOriented(theIsFacesOriented);
764 myTimeStamp->Modified();
767 bool SMESH_ActorDef::GetFacesOriented()
769 return myIsFacesOriented;
772 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
774 my2DActor->SetFacesOrientationColor( r, g, b );
775 my3DActor->SetFacesOrientationColor( r, g, b );
778 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
780 my3DActor->GetFacesOrientationColor( r, g, b );
783 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
785 my2DActor->SetFacesOrientationScale( theScale );
786 my3DActor->SetFacesOrientationScale( theScale );
789 double SMESH_ActorDef::GetFacesOrientationScale()
791 return my3DActor->GetFacesOrientationScale();
794 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
796 my2DActor->SetFacesOrientation3DVectors( theState );
797 my3DActor->SetFacesOrientation3DVectors( theState );
800 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
802 return my3DActor->GetFacesOrientation3DVectors();
806 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
808 myFunctor = theFunctor;
810 SetControlMode( eNone, true );
812 SetControlMode( eCustomControl, true );
815 void SMESH_ActorDef::SetControlMode(eControl theMode)
817 SetControlMode(theMode,true);
820 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
822 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
823 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
824 lookupTable->SetScale(VTK_SCALE_LINEAR);
826 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
830 //myControlMode = eNone;
831 myControlMode = theMode;
832 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
834 my0DActor->GetMapper()->SetScalarVisibility(false);
835 my1DActor->GetMapper()->SetScalarVisibility(false);
836 my2DActor->GetMapper()->SetScalarVisibility(false);
837 my3DActor->GetMapper()->SetScalarVisibility(false);
838 myBallActor->GetMapper()->SetScalarVisibility(false);
839 myScalarBarActor->SetVisibility(false);
841 bool anIsScalarVisible = theMode > eNone;
843 if(anIsScalarVisible) {
847 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
848 aControl->SetPrecision( myControlsPrecision );
849 myFunctor.reset( aControl );
850 myControlActor = my1DActor;
854 myFunctor.reset(new SMESH::Controls::Length2D());
855 myControlActor = my2DActor;
858 myFunctor.reset(new SMESH::Controls::FreeBorders());
859 myControlActor = my1DActor;
862 myFunctor.reset(new SMESH::Controls::FreeEdges());
863 myControlActor = my2DActor;
866 myFunctor.reset(new SMESH::Controls::FreeNodes());
867 myControlActor = myNodeActor;
870 myFunctor.reset(new SMESH::Controls::FreeFaces());
871 myControlActor = my2DActor;
873 case eCoincidentNodes:
875 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
876 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
877 cn->SetTolerance( tol );
879 myControlActor = myNodeActor;
882 case eCoincidentElems1D:
883 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
884 myControlActor = my1DActor;
886 case eCoincidentElems2D:
887 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
888 myControlActor = my2DActor;
890 case eCoincidentElems3D:
891 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
892 myControlActor = my3DActor;
894 case eBareBorderFace:
895 myFunctor.reset(new SMESH::Controls::BareBorderFace());
896 myControlActor = my2DActor;
898 case eOverConstrainedFace:
899 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
900 myControlActor = my2DActor;
902 case eMultiConnection:
903 myFunctor.reset(new SMESH::Controls::MultiConnection());
904 myControlActor = my1DActor;
906 case eMultiConnection2D:
907 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
908 myControlActor = my2DActor;
912 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
913 aControl->SetPrecision( myControlsPrecision );
914 myFunctor.reset( aControl );
915 myControlActor = my2DActor;
920 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
921 aControl->SetPrecision( myControlsPrecision );
922 myFunctor.reset( aControl );
923 myControlActor = my2DActor;
928 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
929 aControl->SetPrecision( myControlsPrecision );
930 myFunctor.reset( aControl );
931 myControlActor = my2DActor;
936 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
937 aControl->SetPrecision( myControlsPrecision );
938 myFunctor.reset( aControl );
939 myControlActor = my3DActor;
944 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
945 aControl->SetPrecision( myControlsPrecision );
946 myFunctor.reset( aControl );
947 myControlActor = my3DActor;
950 case eMaxElementLength2D:
952 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
953 aControl->SetPrecision( myControlsPrecision );
954 myFunctor.reset( aControl );
955 myControlActor = my2DActor;
958 case eMaxElementLength3D:
960 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
961 aControl->SetPrecision( myControlsPrecision );
962 myFunctor.reset( aControl );
963 myControlActor = my3DActor;
968 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
969 aControl->SetPrecision( myControlsPrecision );
970 myFunctor.reset( aControl );
971 myControlActor = my2DActor;
974 case eBareBorderVolume:
976 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
977 myControlActor = my3DActor;
980 case eOverConstrainedVolume:
982 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
983 myControlActor = my3DActor;
988 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
989 aControl->SetPrecision( myControlsPrecision );
990 myFunctor.reset( aControl );
991 myControlActor = my2DActor;
996 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
997 aControl->SetPrecision( myControlsPrecision );
998 myFunctor.reset( aControl );
999 myControlActor = my2DActor;
1004 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1005 aControl->SetPrecision( myControlsPrecision );
1006 myFunctor.reset( aControl );
1007 myControlActor = my2DActor;
1010 case eNodeConnectivityNb:
1012 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1013 myControlActor = myNodeActor;
1016 case eCustomControl:
1020 switch ( myFunctor->GetType() ) {
1021 case SMDSAbs_Node : myControlActor = myNodeActor; break;
1022 case SMDSAbs_Edge : myControlActor = my1DActor; break;
1023 case SMDSAbs_Face : myControlActor = my2DActor; break;
1024 case SMDSAbs_Volume : myControlActor = my3DActor; break;
1033 smIdType aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1034 bool aShowOnlyScalarBarTitle = false;
1036 //myControlMode = theMode;
1037 switch(myControlMode){
1039 case eCoincidentNodes:
1040 myNodeExtActor->SetExtControlMode(myFunctor);
1041 aShowOnlyScalarBarTitle = true;
1045 case eCoincidentElems1D:
1046 my1DExtActor->SetExtControlMode(myFunctor);
1047 aShowOnlyScalarBarTitle = true;
1050 case eBareBorderFace:
1051 case eOverConstrainedFace:
1052 case eCoincidentElems2D:
1053 my2DExtActor->SetExtControlMode(myFunctor);
1054 aShowOnlyScalarBarTitle = true;
1056 case eBareBorderVolume:
1057 case eOverConstrainedVolume:
1058 case eCoincidentElems3D:
1059 my3DExtActor->SetExtControlMode(myFunctor);
1060 aShowOnlyScalarBarTitle = true;
1063 case eMultiConnection2D:
1064 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1065 UpdateDistribution();
1068 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1069 UpdateDistribution();
1071 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1074 if(theCheckEntityMode) {
1075 // if(myControlActor == myNodeActor) {
1076 // if ( myControlMode == eNodeConnectivityNb ) {
1077 // if (!myIsEntityModeCache){
1078 // myEntityModeCache = GetEntityMode();
1079 // myIsEntityModeCache=true;
1081 // SetEntityMode(0);
1084 if(myControlActor == my1DActor) {
1085 if (!myIsEntityModeCache){
1086 myEntityModeCache = GetEntityMode();
1087 myIsEntityModeCache=true;
1089 SetEntityMode(eEdges);
1091 else if(myControlActor == my2DActor) {
1092 if (!myIsEntityModeCache){
1093 myEntityModeCache = GetEntityMode();
1094 myIsEntityModeCache=true;
1096 SetEntityMode(eFaces);
1098 else if(myControlActor == my3DActor) {
1099 if (!myIsEntityModeCache){
1100 myEntityModeCache = GetEntityMode();
1101 myIsEntityModeCache=true;
1103 SetEntityMode(eVolumes);
1106 QString aTitle = QString(myScalarBarActor->GetTitle());
1107 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1108 myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
1112 if(theCheckEntityMode){
1113 myEntityMode = myEntityModeCache;
1114 myIsEntityModeCache = false;
1119 SetRepresentation(GetRepresentation());
1121 myTimeStamp->Modified();
1124 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1125 double * range = lookupTable->GetRange();
1127 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1128 lookupTable->SetScale(VTK_SCALE_LOG10);
1133 smIdType SMESH_ActorDef::GetNumberControlEntities()
1135 SMESH_DeviceActor* anAct = NULL;
1136 switch(myControlMode){
1138 case eCoincidentNodes:
1139 anAct = myNodeExtActor;
1143 case eCoincidentElems1D:
1144 anAct = my1DExtActor;
1147 case eBareBorderFace:
1148 case eOverConstrainedFace:
1149 case eCoincidentElems2D:
1150 anAct = my2DExtActor;
1152 case eBareBorderVolume:
1153 case eOverConstrainedVolume:
1154 case eCoincidentElems3D:
1155 anAct = my3DExtActor;
1159 return anAct ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1162 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1164 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1166 myBaseActor->SetUnstructuredGrid( NULL );
1167 //myHighlitableActor->SetUnstructuredGrid( NULL );
1169 theRenderer->AddActor(myBaseActor);
1170 theRenderer->AddActor(myNodeExtActor);
1171 theRenderer->AddActor(my1DExtActor);
1173 my3DActor ->AddToRender(theRenderer);
1174 my3DExtActor->AddToRender(theRenderer);
1175 my2DActor ->AddToRender(theRenderer);
1176 my2DExtActor->AddToRender(theRenderer);
1177 myNodeActor ->AddToRender(theRenderer);
1178 my1DActor ->AddToRender(theRenderer);
1179 my0DActor ->AddToRender(theRenderer);
1180 myBallActor ->AddToRender(theRenderer);
1182 theRenderer->AddActor(myHighlitableActor);
1184 theRenderer->AddActor2D(myScalarBarActor);
1186 // the superclass' method should be called at the end
1187 // (in particular, for correct work of selection)
1188 SALOME_Actor::AddToRender(theRenderer);
1191 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1193 SALOME_Actor::RemoveFromRender(theRenderer);
1195 theRenderer->RemoveActor(myBaseActor);
1197 theRenderer->RemoveActor(myNodeExtActor);
1199 theRenderer->RemoveActor(myHighlitableActor);
1201 //theRenderer->RemoveActor(my0DExtActor);
1203 theRenderer->RemoveActor(my1DExtActor);
1205 my2DActor->RemoveFromRender(theRenderer);
1206 my2DExtActor->RemoveFromRender(theRenderer);
1207 my3DActor->RemoveFromRender(theRenderer);
1208 my3DExtActor->RemoveFromRender(theRenderer);
1209 myNodeActor->RemoveFromRender(theRenderer);
1210 my0DActor->RemoveFromRender(theRenderer);
1211 myBallActor->RemoveFromRender(theRenderer);
1212 my1DActor->RemoveFromRender(theRenderer);
1214 theRenderer->RemoveActor(myScalarBarActor);
1218 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1219 const char* theEntry,
1220 const char* theName,
1223 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1227 myVisualObj = theVisualObj;
1228 myVisualObj->Update(theIsClear);
1230 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1231 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1233 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1234 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1236 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1238 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1240 my0DActor->Init(myVisualObj,myImplicitBoolean);
1241 myBallActor->Init(myVisualObj,myImplicitBoolean);
1242 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1244 my1DActor->Init(myVisualObj,myImplicitBoolean);
1245 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1247 my2DActor->Init(myVisualObj,myImplicitBoolean);
1248 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1249 my3DActor->Init(myVisualObj,myImplicitBoolean);
1250 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1252 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1253 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1254 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1256 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1257 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1259 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1260 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1261 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1262 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1264 double aFactor, aUnits;
1265 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1266 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1267 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1268 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1270 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1274 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1275 SetIsShrunkable(true);
1277 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1279 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1280 SetRepresentation(-1);
1283 SetRepresentation(eEdge);
1284 }else if(aMode == 1){
1285 SetRepresentation(eSurface);
1286 }else if(aMode == 2){
1287 SetRepresentation(ePoint);
1294 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1295 SetIsDisplayNameActor( true );
1297 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1298 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1299 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1301 myTimeStamp->Modified();
1307 double* SMESH_ActorDef::GetBounds()
1309 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1310 return myNodeActor->GetBounds();
1311 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1315 vtkDataSet* SMESH_ActorDef::GetInput()
1317 return GetUnstructuredGrid();
1321 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1323 Superclass::SetTransform(theTransform);
1325 myNodeActor->SetTransform(theTransform);
1326 myBaseActor->SetTransform(theTransform);
1328 myHighlitableActor->SetTransform(theTransform);
1330 myNodeExtActor->SetTransform(theTransform);
1332 my0DActor->SetTransform(theTransform);
1333 myBallActor->SetTransform(theTransform);
1334 //my0DExtActor->SetTransform(theTransform);
1336 my1DActor->SetTransform(theTransform);
1337 my1DExtActor->SetTransform(theTransform);
1339 my2DActor->SetTransform(theTransform);
1340 my2DExtActor->SetTransform(theTransform);
1341 my3DActor->SetTransform(theTransform);
1342 my3DExtActor->SetTransform(theTransform);
1348 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1350 vtkLODActor::SetMapper(theMapper);
1354 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1356 SALOME_Actor::ShallowCopy(prop);
1360 vtkMapper* SMESH_ActorDef::GetMapper()
1362 return myPickableActor->GetMapper();
1366 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1368 return myVisualObj->GetUnstructuredGrid();
1372 bool SMESH_ActorDef::IsInfinitive()
1374 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1375 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1376 ( aDataSet->GetNumberOfCells() == 1 &&
1377 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1378 return SALOME_Actor::IsInfinitive();
1382 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1384 if ( myIsShrinkable == theShrunkable )
1386 myIsShrinkable = theShrunkable;
1390 double SMESH_ActorDef::GetShrinkFactor()
1392 return myBaseActor->GetShrinkFactor();
1395 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1397 myBaseActor->SetShrinkFactor(theValue);
1399 my1DActor->SetShrinkFactor(theValue);
1400 my1DExtActor->SetShrinkFactor(theValue);
1402 my2DActor->SetShrinkFactor(theValue);
1403 my2DExtActor->SetShrinkFactor(theValue);
1404 my3DActor->SetShrinkFactor(theValue);
1405 my3DExtActor->SetShrinkFactor(theValue);
1406 my3DExtActor->SetShrinkFactor(theValue);
1407 myHighlitableActor->SetShrinkFactor(theValue);
1412 void SMESH_ActorDef::SetShrink()
1414 if(!myIsShrinkable) return;
1416 myBaseActor->SetShrink();
1418 my1DActor->SetShrink();
1419 my1DExtActor->SetShrink();
1421 my2DActor->SetShrink();
1422 my2DExtActor->SetShrink();
1423 my3DActor->SetShrink();
1424 my3DExtActor->SetShrink();
1425 myHighlitableActor->SetShrink();
1431 void SMESH_ActorDef::UnShrink()
1433 if(!myIsShrunk) return;
1435 myBaseActor->UnShrink();
1437 my1DActor->UnShrink();
1438 my1DExtActor->UnShrink();
1440 my2DActor->UnShrink();
1441 my2DExtActor->UnShrink();
1442 my3DActor->UnShrink();
1443 my3DExtActor->UnShrink();
1444 myHighlitableActor->UnShrink();
1451 vtkIdType SMESH_ActorDef::GetNodeObjId(vtkIdType theVtkID)
1453 return myPickableActor->GetNodeObjId(theVtkID);
1456 double* SMESH_ActorDef::GetNodeCoord(vtkIdType theObjID)
1458 return myPickableActor->GetNodeCoord(theObjID);
1461 vtkIdType SMESH_ActorDef::GetNodeVtkId(vtkIdType theObjID)
1463 return myPickableActor->GetNodeVtkId(theObjID);
1466 vtkIdType SMESH_ActorDef::GetElemObjId(vtkIdType theVtkID)
1468 return myPickableActor->GetElemObjId(theVtkID);
1471 vtkCell* SMESH_ActorDef::GetElemCell(vtkIdType theObjID)
1473 return myPickableActor->GetElemCell(theObjID);
1477 void SMESH_ActorDef::SetVisibility(int theMode)
1479 SetVisibility(theMode,true);
1483 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1485 SALOME_Actor::SetVisibility(theMode);
1487 myNodeActor->VisibilityOff();
1488 myBaseActor->VisibilityOff();
1490 myNodeExtActor->VisibilityOff();
1492 my0DActor->VisibilityOff();
1493 myBallActor->VisibilityOff();
1494 //my0DExtActor->VisibilityOff();
1496 my1DActor->VisibilityOff();
1497 my1DExtActor->VisibilityOff();
1499 my2DActor->VisibilityOff();
1500 my2DExtActor->VisibilityOff();
1501 my3DActor->VisibilityOff();
1502 my3DExtActor->VisibilityOff();
1504 myScalarBarActor->VisibilityOff();
1506 if ( GetVisibility() ) {
1507 if ( theIsUpdateRepersentation )
1508 SetRepresentation(GetRepresentation());
1510 if(myControlMode != eNone) {
1511 switch(myControlMode) {
1513 case eCoincidentNodes:
1514 myNodeExtActor->VisibilityOn();
1517 case eMultiConnection:
1518 my1DActor->VisibilityOn();
1522 case eCoincidentElems1D:
1524 case eMultiConnection2D:
1525 my1DExtActor->VisibilityOn();
1528 case eBareBorderFace:
1529 case eOverConstrainedFace:
1530 case eCoincidentElems2D:
1531 my2DExtActor->VisibilityOn();
1533 case eBareBorderVolume:
1534 case eOverConstrainedVolume:
1535 case eCoincidentElems3D:
1536 my3DExtActor->VisibilityOn();
1540 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1541 myScalarBarActor->VisibilityOn();
1544 if ( GetPickable( ))
1545 myPickableActor->VisibilityOn();
1547 if ( GetRepresentation() != ePoint )
1549 if(myEntityMode & e0DElements ){
1550 my0DActor->VisibilityOn();
1552 if(myEntityMode & eBallElem ){
1553 myBallActor->VisibilityOn();
1555 if(myEntityMode & eEdges && ( GetCellsLabeled() || // my1DActor shows labels only
1556 ( myControlActor == my1DActor && myControlMode != eNone ))){
1557 my1DActor->VisibilityOn();
1559 if(myEntityMode & eFaces ){
1560 my2DActor->VisibilityOn();
1562 if(myEntityMode & eVolumes ){
1563 my3DActor->VisibilityOn();
1567 if(myNodeActor->GetPointsLabeled()) {
1568 myNodeActor->UpdateLabels();
1569 myNodeActor->VisibilityOn();
1572 my0DActor->UpdateLabels();
1575 myBallActor->UpdateLabels();
1578 my1DActor->UpdateLabels();
1581 my2DActor->UpdateLabels();
1584 my3DActor->UpdateLabels();
1586 #ifndef DISABLE_PLOT2DVIEWER
1588 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1595 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1597 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1599 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1600 anObjectEntities &= ~e0DElements;
1601 theMode &= ~e0DElements;
1604 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1605 anObjectEntities &= ~eBallElem;
1606 theMode &= ~eBallElem;
1609 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1610 anObjectEntities &= ~eEdges;
1614 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1615 anObjectEntities &= ~eFaces;
1619 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1620 anObjectEntities &= ~eVolumes;
1621 theMode &= ~eVolumes;
1625 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1626 theMode |= e0DElements;
1628 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1629 theMode |= eBallElem;
1631 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1634 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1637 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1638 theMode |= eVolumes;
1641 // rnv : Fix volume selection on Display Entity
1642 //myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1644 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1646 myRepresentationCache = GetRepresentation();
1647 SetRepresentation( ePoint );
1650 if ( myEntityMode != theMode )
1652 myEntityMode = theMode; // entities to show
1654 // Set cell types to extract
1658 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1661 void SMESH_ActorDef::SetRepresentation (int theMode)
1663 smIdType aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1664 smIdType aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1665 smIdType aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1666 smIdType aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1667 smIdType aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1669 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1671 theMode = myRepresentationCache;
1672 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1675 myRepresentationCache = 0;
1679 myRepresentation = eSurface;
1680 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1681 myRepresentation = eEdge;
1682 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1683 myRepresentation = ePoint;
1688 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1691 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1694 myRepresentation = theMode;
1697 if (!GetUnstructuredGrid()->GetNumberOfCells())
1698 myRepresentation = ePoint;
1701 if (myRepresentation == ePoint) {
1709 myPickableActor = myBaseActor;
1710 vtkProperty *aProp = NULL, *aBackProp = NULL;
1711 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1712 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::eNoneRepr;
1713 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1714 switch (myRepresentation) {
1716 myPickableActor = myNodeActor;
1717 aQuadraticMode = SMESH_Actor::eLines;
1718 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1719 aReperesent = SMESH_DeviceActor::ePoint;
1722 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1723 aReperesent = SMESH_DeviceActor::eInsideframe;
1726 aProp = mySurfaceProp;
1727 aBackProp = myBackSurfaceProp;
1728 aPropVN = myNormalVProp;
1729 aPropVR = myReversedVProp;
1730 aReperesent = SMESH_DeviceActor::eSurface;
1734 if ( myRepresentation != ePoint )
1736 my2DActor->SetProperty(aProp);
1737 my2DActor->SetBackfaceProperty(aBackProp);
1738 my2DActor->SetRepresentation(aReperesent);
1740 if(aQuadraticMode == SMESH_Actor::eLines)
1741 my2DActor->SetQuadraticArcMode(false);
1742 else if(aQuadraticMode == SMESH_Actor::eArcs)
1743 my2DActor->SetQuadraticArcMode(true);
1745 my2DExtActor->SetRepresentation(aReperesent);
1747 my3DActor->SetProperty(aPropVN);
1748 my3DActor->SetBackfaceProperty(aPropVR);
1749 my3DActor->SetRepresentation(aReperesent);
1751 my0DActor->SetRepresentation(aReperesent);
1752 myBallActor->SetRepresentation(aReperesent);
1754 switch ( myControlMode ) {
1756 case eMultiConnection:
1757 aProp = aBackProp = my1DProp;
1758 if ( myRepresentation != ePoint )
1759 aReperesent = SMESH_DeviceActor::eInsideframe;
1761 case eCustomControl:
1762 if ( myControlActor == my1DActor )
1763 aProp = aBackProp = my1DProp;
1764 if ( myRepresentation != ePoint )
1765 aReperesent = SMESH_DeviceActor::eInsideframe;
1770 if(aQuadraticMode == SMESH_Actor::eLines)
1771 my1DActor->SetQuadraticArcMode(false);
1772 else if(aQuadraticMode == SMESH_Actor::eArcs)
1773 my1DActor->SetQuadraticArcMode(true);
1775 my1DActor->SetProperty(aProp);
1776 my1DActor->SetBackfaceProperty(aBackProp);
1777 my1DActor->SetRepresentation(aReperesent);
1779 my1DExtActor->SetRepresentation(aReperesent);
1782 if(myIsPointsVisible)
1783 myPickableActor = myNodeActor;
1785 SetMapper(myPickableActor->GetMapper());
1787 SetVisibility(GetVisibility(),false);
1793 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1795 if ( myIsPointsVisible == theIsPointsVisible )
1797 myIsPointsVisible = theIsPointsVisible;
1798 SetRepresentation(GetRepresentation());
1801 bool SMESH_ActorDef::GetPointRepresentation()
1803 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1807 void SMESH_ActorDef::UpdateHighlight()
1809 myHighlitableActor->SetHighlited(false);
1810 myHighlitableActor->SetVisibility(false);
1811 bool anIsVisible = GetVisibility();
1813 switch(myRepresentation){
1814 case SMESH_DeviceActor::eSurface:
1815 case SMESH_DeviceActor::eWireframe:
1817 if(myIsHighlighted) {
1818 myHighlitableActor->SetProperty(myHighlightProp);
1819 }else if(myIsPreselected){
1820 myHighlitableActor->SetProperty(myPreselectProp);
1821 } else if(anIsVisible){
1822 (myRepresentation == eSurface) ?
1823 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1825 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1826 myHighlitableActor->SetHighlited(anIsVisible);
1827 myHighlitableActor->GetExtractUnstructuredGrid()->
1828 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1829 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1831 myHighlitableActor->SetVisibility(anIsVisible);
1834 case SMESH_DeviceActor::ePoint:
1836 if(myIsHighlighted) {
1837 myNodeActor->SetProperty(myHighlightProp);
1838 }else if(myIsPreselected) {
1839 myNodeActor->SetProperty(myPreselectProp);
1840 } else if(anIsVisible) {
1841 myNodeActor->SetProperty(myNodeProp);
1843 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1844 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1845 myNodeActor->GetProperty()->Modified();
1851 void SMESH_ActorDef::EnableSelection( bool enable )
1853 // selection in the Viewer enabled/disabled
1854 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1856 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1857 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1858 myBaseActor->myExtractUnstructuredGrid->Update();
1859 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1861 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1863 myBaseActor->SetUnstructuredGrid( NULL );
1864 //myHighlitableActor->SetUnstructuredGrid( NULL );
1865 myBaseActor->myExtractUnstructuredGrid->Update();
1866 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1870 void SMESH_ActorDef::highlight(bool theHighlight)
1872 if ( myIsHighlighted == theHighlight )
1874 myIsHighlighted = theHighlight;
1879 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1881 if ( myIsPreselected == thePreselect )
1883 myIsPreselected = thePreselect;
1889 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1891 if (myPickableActor->GetIsOpaque())
1893 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1901 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1903 if (!myPickableActor->GetIsOpaque())
1905 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1913 void SMESH_ActorDef::Render(vtkRenderer* /*ren*/)
1915 vtkMTimeType aTime = myTimeStamp->GetMTime();
1916 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1917 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1918 if(anObjTime > aTime || aClippingTime > aTime)
1923 void SMESH_ActorDef::Update()
1925 MESSAGE("SMESH_ActorDef::Update");
1927 myVisualObj->Update();
1929 if(GetControlMode() != eNone) {
1930 unsigned long aTime = myTimeStamp->GetMTime();
1931 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1932 if (anObjTime > aTime)
1933 SetControlMode(GetControlMode(),false);
1937 myNodeActor->UpdateLabels();
1940 my0DActor->UpdateLabels();
1943 myBallActor->UpdateLabels();
1946 my1DActor->UpdateLabels();
1949 my2DActor->UpdateLabels();
1952 my3DActor->UpdateLabels();
1954 if(myIsFacesOriented){
1955 SetFacesOriented(myIsFacesOriented);
1958 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
1959 // myEntityMode |= myVisualObj->GetEntitiesState();
1962 SetEntityMode(GetEntityMode());
1963 SetVisibility(GetVisibility());
1965 myTimeStamp->Modified();
1970 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
1972 SALOME_Actor::ReleaseGraphicsResources(renWin);
1974 myPickableActor->ReleaseGraphicsResources(renWin);
1978 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
1980 double* aColor = theProperty->GetColor();
1987 void SMESH_ActorDef::SetOpacity(double theValue)
1989 mySurfaceProp->SetOpacity(theValue);
1990 myBackSurfaceProp->SetOpacity(theValue);
1991 myNormalVProp->SetOpacity(theValue);
1992 myReversedVProp->SetOpacity(theValue);
1993 myEdgeProp->SetOpacity(theValue);
1994 myOutLineProp->SetOpacity(theValue);
1995 myNodeProp->SetOpacity(theValue);
1997 my1DProp->SetOpacity(theValue);
1998 my0DProp->SetOpacity(theValue);
1999 myBallProp->SetOpacity(theValue);
2003 double SMESH_ActorDef::GetOpacity()
2005 return mySurfaceProp->GetOpacity();
2009 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2011 mySurfaceProp->SetColor(r,g,b);
2012 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2013 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2014 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2015 myNameActor->SetBackgroundColor(r,g,b);
2017 myDeltaBrightness = delta;
2018 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2019 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2023 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2025 ::GetColor(mySurfaceProp,r,g,b);
2026 delta = myDeltaBrightness;
2029 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2031 myNormalVProp->SetColor(r,g,b);
2032 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2033 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2034 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2035 myNameActor->SetBackgroundColor(r,g,b);
2037 myDeltaVBrightness = delta;
2038 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2039 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2043 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2045 ::GetColor(myNormalVProp,r,g,b);
2046 delta = myDeltaVBrightness;
2049 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2051 myEdgeProp->SetColor(r,g,b);
2052 my1DProp->SetColor(r,g,b);
2053 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2054 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2055 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2056 myNameActor->SetBackgroundColor(r,g,b);
2060 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2062 ::GetColor(myEdgeProp,r,g,b);
2065 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2067 myOutLineProp->SetColor(r,g,b);
2071 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2073 ::GetColor(myOutLineProp,r,g,b);
2077 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2079 myNodeProp->SetColor(r,g,b);
2080 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2081 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2082 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2083 myNameActor->SetBackgroundColor(r,g,b);
2087 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2089 ::GetColor(myNodeProp,r,g,b);
2092 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2094 my0DProp->SetColor(r,g,b);
2095 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2096 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2097 myNameActor->SetBackgroundColor(r,g,b);
2101 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2103 ::GetColor(my0DProp,r,g,b);
2106 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2108 myBallProp->SetColor(r,g,b);
2109 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2110 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2111 myNameActor->SetBackgroundColor(r,g,b);
2115 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2117 ::GetColor(myBallProp,r,g,b);
2120 void SMESH_ActorDef::UpdateSelectionProps()
2122 QColor selectionColor = SMESH_ActorProps::props()->selectionColor();
2123 QColor highlightColor = SMESH_ActorProps::props()->highlightColor();
2124 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2125 float width = (float) GetLineWidth();
2126 myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF());
2127 myHighlightProp->SetLineWidth(width + selectionIncrement);
2128 myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF());
2129 myPreselectProp->SetLineWidth(width + selectionIncrement);
2133 double SMESH_ActorDef::GetLineWidth()
2135 return myEdgeProp->GetLineWidth();
2139 void SMESH_ActorDef::SetLineWidth(double theVal)
2141 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
2142 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2144 myEdgeProp->SetLineWidth((float) theVal);
2146 my1DProp ->SetLineWidth((float) theVal + controlsIncrement);
2147 my1DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2148 my2DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2149 my3DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2150 myHighlightProp->SetLineWidth((float) theVal + selectionIncrement);
2151 myPreselectProp->SetLineWidth((float) theVal + selectionIncrement);
2155 double SMESH_ActorDef::GetOutlineWidth()
2157 return myOutLineProp->GetLineWidth();
2160 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2162 myOutLineProp->SetLineWidth((float) theVal);
2166 void SMESH_ActorDef::Set0DSize(double theVal)
2168 my0DProp ->SetPointSize((float) theVal);
2169 myHighlightProp->SetPointSize((float) theVal);
2170 myPreselectProp->SetPointSize((float) theVal);
2172 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2173 aCustom->Set0DSize((float) theVal);
2175 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2176 aCustom->Set0DSize((float) theVal);
2182 double SMESH_ActorDef::Get0DSize()
2184 return my0DProp->GetPointSize();
2187 void SMESH_ActorDef::SetBallSize(double theVal)
2189 myBallProp->SetPointSize((float) theVal);
2191 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2192 aCustom->SetBallSize((float) theVal);
2194 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2195 aCustom->SetBallSize((float) theVal);
2201 double SMESH_ActorDef::GetBallSize()
2203 return myBallProp->GetPointSize();
2206 double SMESH_ActorDef::GetBallScale()
2208 return myBallActor->GetBallScale();
2211 void SMESH_ActorDef::SetBallScale( double theVal )
2213 myBallActor->SetBallScale( theVal );
2214 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2215 aCustom->SetBallScale(theVal);
2217 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2218 aCustom->SetBallScale(theVal);
2224 int SMESH_ActorDef::GetObjDimension( const vtkIdType theObjId )
2226 return myVisualObj->GetElemDimension( theObjId );
2229 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2231 return myBaseActor->IsImplicitFunctionUsed();
2234 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2236 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2237 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2239 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2241 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2243 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2244 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2245 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2247 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2248 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2250 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2251 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2252 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2253 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2256 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2259 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2260 myCippingPlaneCont.push_back(thePlane);
2261 if(!IsImplicitFunctionUsed())
2262 SetImplicitFunctionUsed(true);
2263 myNodeActor->UpdateLabels();
2265 return myCippingPlaneCont.size();
2268 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2271 myPlaneCollection->AddItem( thePlane );
2274 void SMESH_ActorDef::SetOpenGLClippingPlane()
2276 // before use this method you must add clipping planes using method
2277 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2278 if( !myPlaneCollection->GetNumberOfItems() )
2281 // It is necessary to set plane collection for each mapper of actor
2282 // and update current inputs of mapper
2283 myNodeActor->SetPlaneCollection( myPlaneCollection );
2284 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2286 myBaseActor->SetPlaneCollection( myPlaneCollection );
2287 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2289 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2290 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2292 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2294 myBaseActor->SetUnstructuredGrid( NULL );
2295 //myHighlitableActor->SetUnstructuredGrid( NULL );
2297 my1DActor->SetPlaneCollection( myPlaneCollection );
2298 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2300 my2DActor->SetPlaneCollection( myPlaneCollection );
2301 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2303 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2304 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2306 my0DActor->SetPlaneCollection( myPlaneCollection );
2307 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2309 myBallActor->SetPlaneCollection( myPlaneCollection );
2310 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2312 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2313 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2315 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2316 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2318 my3DActor->SetPlaneCollection( myPlaneCollection );
2319 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2321 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2322 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2330 void SMESH_ActorDef::RemoveAllClippingPlanes()
2332 myPlaneCollection->RemoveAllItems();
2333 myImplicitBoolean->GetFunction()->RemoveAllItems();
2334 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2335 myCippingPlaneCont.clear();
2336 SetImplicitFunctionUsed(false);
2337 myNodeActor->UpdateLabels();
2340 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2342 return myCippingPlaneCont.size();
2345 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2347 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2349 return myCippingPlaneCont[theID].Get();
2352 void SMESH_ActorDef::UpdateScalarBar()
2354 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2358 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2360 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2361 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2363 aScalarBarTitleProp->SetFontFamilyToArial();
2365 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2367 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2368 if ( f.family() == "Arial" )
2369 aScalarBarTitleProp->SetFontFamilyToArial();
2370 else if ( f.family() == "Courier" )
2371 aScalarBarTitleProp->SetFontFamilyToCourier();
2372 else if ( f.family() == "Times" )
2373 aScalarBarTitleProp->SetFontFamilyToTimes();
2376 aScalarBarTitleProp->BoldOn();
2378 aScalarBarTitleProp->BoldOff();
2381 aScalarBarTitleProp->ItalicOn();
2383 aScalarBarTitleProp->ItalicOff();
2386 aScalarBarTitleProp->ShadowOn();
2388 aScalarBarTitleProp->ShadowOff();
2391 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2392 aScalarBarTitleProp->Delete();
2394 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2396 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2397 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2399 aScalarBarLabelProp->SetFontFamilyToArial();
2400 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2402 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2403 if( f.family() == "Arial" )
2404 aScalarBarLabelProp->SetFontFamilyToArial();
2405 else if( f.family() == "Courier" )
2406 aScalarBarLabelProp->SetFontFamilyToCourier();
2407 else if( f.family() == "Times" )
2408 aScalarBarLabelProp->SetFontFamilyToTimes();
2411 aScalarBarLabelProp->BoldOn();
2413 aScalarBarLabelProp->BoldOff();
2416 aScalarBarLabelProp->ItalicOn();
2418 aScalarBarLabelProp->ItalicOff();
2421 aScalarBarLabelProp->ShadowOn();
2423 aScalarBarLabelProp->ShadowOff();
2426 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2427 aScalarBarLabelProp->Delete();
2429 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2430 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2432 myScalarBarActor->SetOrientationToHorizontal();
2434 myScalarBarActor->SetOrientationToVertical();
2437 double aXVal = horiz ? 0.20 : 0.01;
2438 if( mgr->hasValue( "SMESH", name + "x" ) )
2439 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2441 double aYVal = horiz ? 0.01 : 0.1;
2442 if( mgr->hasValue( "SMESH", name + "y" ) )
2443 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2444 myScalarBarActor->SetPosition( aXVal, aYVal );
2446 double aWVal = horiz ? 0.60 : 0.10;
2447 if( mgr->hasValue( "SMESH", name + "width" ) )
2448 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2449 myScalarBarActor->SetWidth( aWVal );
2451 double aHVal = horiz ? 0.12 : 0.80;
2452 if( mgr->hasValue( "SMESH", name + "height" ) )
2453 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2454 myScalarBarActor->SetHeight( aHVal );
2457 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2458 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2459 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2462 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2463 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2464 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2466 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2467 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2469 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2470 myScalarBarActor->SetDistributionColoringType(coloringType);
2472 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2473 QColor(255, 255, 255));
2475 rgb[0]= distributionColor.red()/255.;
2476 rgb[1]= distributionColor.green()/255.;
2477 rgb[2]= distributionColor.blue()/255.;
2478 myScalarBarActor->SetDistributionColor(rgb);
2483 void SMESH_ActorDef::UpdateDistribution()
2485 if(SMESH::Controls::NumericalFunctor* fun =
2486 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2488 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2489 std::vector<int> nbEvents;
2490 std::vector<double> funValues;
2491 SMESH_VisualObjDef::TEntityList elems;
2492 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2493 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2494 std::vector<smIdType> elemIds; elemIds.reserve( elems.size() );
2495 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2496 elemIds.push_back( (*e)->GetID());
2497 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2498 double * range = lookupTable->GetRange();
2499 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2500 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2501 myScalarBarActor->SetDistribution(nbEvents);
2505 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2508 case SMESH_Actor::eLines :
2509 myHighlitableActor->SetQuadraticArcMode(false);
2510 my2DActor->SetQuadraticArcMode(false);
2511 my1DActor->SetQuadraticArcMode(false);
2513 case SMESH_Actor::eArcs :
2514 myHighlitableActor->SetQuadraticArcMode(true);
2515 if(GetRepresentation() != SMESH_Actor::ePoint) {
2516 my2DActor->SetQuadraticArcMode(true);
2517 my1DActor->SetQuadraticArcMode(true);
2526 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2528 if(myHighlitableActor->GetQuadraticArcMode())
2529 return SMESH_Actor::eArcs;
2531 return SMESH_Actor::eLines;
2534 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2536 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2537 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2538 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2541 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2543 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2544 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2545 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2546 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2549 void SMESH_ActorDef::UpdateFilter()
2551 unsigned int anObjectEntities = eAllEntity; // entities present in my object
2553 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
2554 anObjectEntities &= ~e0DElements;
2557 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
2558 anObjectEntities &= ~eBallElem;
2561 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
2562 anObjectEntities &= ~eEdges;
2565 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
2566 anObjectEntities &= ~eFaces;
2569 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
2570 anObjectEntities &= ~eVolumes;
2573 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
2574 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
2575 aFilter->ClearRegisteredCellsWithType();
2576 aHltFilter->ClearRegisteredCellsWithType();
2578 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
2581 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2582 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2586 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2587 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2588 if (myEntityMode & e0DElements) {
2589 aFilter->RegisterCellsWithType(VTK_VERTEX);
2590 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
2593 if (myEntityMode & eBallElem) {
2594 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
2596 if (myEntityMode & eEdges) {
2597 aFilter->RegisterCellsWithType(VTK_LINE);
2598 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2599 aHltFilter->RegisterCellsWithType(VTK_LINE);
2600 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2603 if (myEntityMode & eFaces) {
2604 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
2605 aFilter->RegisterCellsWithType(VTK_QUAD);
2606 aFilter->RegisterCellsWithType(VTK_POLYGON);
2607 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2608 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2609 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2610 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2611 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2612 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
2613 aHltFilter->RegisterCellsWithType(VTK_QUAD);
2614 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
2615 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2616 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2617 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2618 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2619 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2622 if (myEntityMode & eVolumes) {
2623 aFilter->RegisterCellsWithType(VTK_TETRA);
2624 aFilter->RegisterCellsWithType(VTK_VOXEL);
2625 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2626 aFilter->RegisterCellsWithType(VTK_WEDGE);
2627 aFilter->RegisterCellsWithType(VTK_PYRAMID);
2628 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2629 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2630 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2631 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2632 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2633 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2634 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2635 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2636 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2637 aHltFilter->RegisterCellsWithType(VTK_TETRA);
2638 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
2639 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2640 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
2641 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
2642 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2643 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2644 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2645 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2646 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2647 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2648 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2649 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2650 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2653 if ( GetVisibility() )
2655 MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
2658 #ifndef DISABLE_PLOT2DVIEWER
2659 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2662 my2dHistogram->clearAllPoints();
2664 if(SMESH::Controls::NumericalFunctor* fun =
2665 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2668 if(!my2dHistogram) {
2669 my2dHistogram = new SPlot2d_Histogram();
2670 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2671 my2dHistogram->setIO(anIO);
2674 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2675 std::vector<int> nbEvents;
2676 std::vector<double> funValues;
2677 SMESH_VisualObjDef::TEntityList elems;
2678 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2679 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2680 std::vector<smIdType> elemIds;
2682 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2683 elemIds.push_back( (*e)->GetID());
2685 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2686 double * range = lookupTable->GetRange();
2687 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2688 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2690 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2691 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2693 if(funValues.size() >= 2)
2694 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2698 //Color of the histogram
2699 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2700 my2dHistogram->setAutoAssign(true);
2703 myScalarBarActor->GetDistributionColor(rgb);
2704 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2705 my2dHistogram->setColor(aColor);
2709 return my2dHistogram;