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;
123 objectEntitiesCache = 0;
125 myHighlightActor = SMESH_SVTKActor::New();
126 myHighlightActor->Delete(); // vtkSmartPointer!
127 myHighlightActor->Initialize();
129 myPreHighlightActor = SMESH_SVTKActor::New();
130 myPreHighlightActor->Delete();
131 myPreHighlightActor->Initialize();
133 myIsShrinkable = false;
136 myIsFacesOriented = false;
138 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
139 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
141 myControlsPrecision = -1;
142 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
144 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
145 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
147 float aElem0DSize = (float) SMESH::GetFloat("SMESH:elem0d_size",5);
148 float aBallElemSize = (float) SMESH::GetFloat("SMESH:ball_elem_size",10);
149 float aBallElemScale = (float) SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
150 float aLineWidth = (float) SMESH::GetFloat("SMESH:element_width",1);
151 float aOutlineWidth = (float) SMESH::GetFloat("SMESH:outline_width",1);
153 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
155 bool anItalicNd = false;
156 bool aShadowNd = false;
158 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
159 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
160 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
161 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
162 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
164 anItalicNd = f.italic();
165 aShadowNd = f.overline();
166 aSizeNd = f.pointSize();
168 double anRGBNd[3] = {1,1,1};
169 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
171 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
173 bool anItalicEl = false;
174 bool aShadowEl = false;
176 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
177 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
178 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
179 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
180 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
182 anItalicEl = f.italic();
183 aShadowEl = f.overline();
184 aSizeEl = f.pointSize();
186 double anRGBEl[3] = {0,1,0};
187 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
189 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
190 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
192 //Definition 2D and 3D devices of the actor
193 //-----------------------------------------
194 double anRGB[3] = {1,1,1};
195 mySurfaceProp = vtkProperty::New();
198 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
199 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
200 myDeltaBrightness = delta;
202 myBackSurfaceProp = vtkProperty::New();
203 bfc = Qtx::mainColorToSecondary(ffc, delta);
204 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
206 myNormalVProp = vtkProperty::New();
207 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
208 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
209 myDeltaVBrightness = delta;
211 myReversedVProp = vtkProperty::New();
212 bfc = Qtx::mainColorToSecondary(ffc, delta);
213 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
215 my2DActor = SMESH_CellLabelActor::New();
216 my2DActor->SetStoreClippingMapping(true);
217 my2DActor->SetUserMatrix(aMatrix);
218 my2DActor->PickableOff();
219 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
220 my2DActor->SetProperty(mySurfaceProp);
221 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
222 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
223 aFilter = my2DActor->GetExtractUnstructuredGrid();
224 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
225 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
226 aFilter->RegisterCellsWithType(VTK_QUAD);
227 aFilter->RegisterCellsWithType(VTK_POLYGON);
228 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
231 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
232 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
234 my2DExtProp = vtkProperty::New();
235 my2DExtProp->DeepCopy(mySurfaceProp);
236 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
237 anRGB[0] = 1 - anRGB[0];
238 anRGB[1] = 1 - anRGB[1];
239 anRGB[2] = 1 - anRGB[2];
240 my2DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
241 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
243 my2DExtActor = SMESH_DeviceActor::New();
244 my2DExtActor->SetUserMatrix(aMatrix);
245 my2DExtActor->PickableOff();
246 my2DExtActor->SetProperty(my2DExtProp);
247 my2DExtActor->SetBackfaceProperty(my2DExtProp);
248 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
249 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
250 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
251 aFilter->RegisterCellsWithType(VTK_QUAD);
252 aFilter->RegisterCellsWithType(VTK_POLYGON);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
255 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
256 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
257 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
259 my3DActor = SMESH_CellLabelActor::New();
260 my3DActor->SetStoreClippingMapping(true);
261 my3DActor->SetUserMatrix(aMatrix);
262 my3DActor->PickableOff();
263 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
264 my3DActor->SetProperty(myNormalVProp);
265 my3DActor->SetBackfaceProperty(myReversedVProp);
266 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
267 my3DActor->SetCoincident3DAllowed(true);
268 aFilter = my3DActor->GetExtractUnstructuredGrid();
269 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
270 aFilter->RegisterCellsWithType(VTK_TETRA);
271 aFilter->RegisterCellsWithType(VTK_VOXEL);
272 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
273 aFilter->RegisterCellsWithType(VTK_WEDGE);
274 aFilter->RegisterCellsWithType(VTK_PYRAMID);
275 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
276 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
277 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
278 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
280 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_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->SetLineWidth(aLineWidth + controlsIncrement);
292 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
294 my3DExtActor = SMESH_DeviceActor::New();
295 my3DExtActor->SetUserMatrix(aMatrix);
296 my3DExtActor->PickableOff();
297 my3DExtActor->SetProperty(my3DExtProp);
298 my3DExtActor->SetBackfaceProperty(my3DExtProp);
299 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
300 my3DExtActor->SetCoincident3DAllowed(true);
301 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
302 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
303 aFilter->RegisterCellsWithType(VTK_TETRA);
304 aFilter->RegisterCellsWithType(VTK_VOXEL);
305 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
306 aFilter->RegisterCellsWithType(VTK_WEDGE);
307 aFilter->RegisterCellsWithType(VTK_PYRAMID);
308 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
311 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
313 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
314 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
315 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
316 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
318 //Definition 1D device of the actor
319 //---------------------------------
320 myEdgeProp = vtkProperty::New();
321 myEdgeProp->SetAmbient(1.0);
322 myEdgeProp->SetDiffuse(0.0);
323 myEdgeProp->SetSpecular(0.0);
324 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
325 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
326 myEdgeProp->SetLineWidth(aLineWidth);
328 // my1DActor is used to
330 // - show controls on all edges (eg Length)
331 // since edges are shown by myHighlitableActor
332 my1DActor = SMESH_CellLabelActor::New();
333 my1DActor->SetStoreClippingMapping(true);
334 my1DActor->SetUserMatrix(aMatrix);
335 my1DActor->PickableOff();
336 my1DActor->SetHighlited(true);
337 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
338 my1DActor->SetProperty(myEdgeProp);
339 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
340 aFilter = my1DActor->GetExtractUnstructuredGrid();
341 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
342 aFilter->RegisterCellsWithType(VTK_LINE);
343 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
345 my1DProp = vtkProperty::New();
346 my1DProp->DeepCopy(myEdgeProp);
347 my1DProp->SetLineWidth(aLineWidth + controlsIncrement);
348 my1DProp->SetPointSize(aElem0DSize);
350 my1DExtProp = vtkProperty::New();
351 my1DExtProp->DeepCopy(myEdgeProp);
352 anRGB[0] = 1 - anRGB[0];
353 anRGB[1] = 1 - anRGB[1];
354 anRGB[2] = 1 - anRGB[2];
355 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
356 my1DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
357 my1DExtProp->SetPointSize(aElem0DSize);
359 // my1DExtActor is used to show filtered edges or links between nodes
360 my1DExtActor = SMESH_DeviceActor::New();
361 my1DExtActor->SetUserMatrix(aMatrix);
362 my1DExtActor->PickableOff();
363 my1DExtActor->SetHighlited(true);
364 my1DExtActor->SetVisibility(false);
365 my1DExtActor->SetProperty(my1DExtProp);
366 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
367 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
368 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
369 aFilter->RegisterCellsWithType(VTK_LINE);
370 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
373 //Definition 0D device of the actor (0d elements)
374 //-----------------------------------------------
375 my0DProp = vtkProperty::New();
376 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
377 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
378 my0DProp->SetPointSize(aElem0DSize);
380 my0DActor = SMESH_CellLabelActor::New();
381 my0DActor->SetUserMatrix(aMatrix);
382 my0DActor->SetStoreClippingMapping(true);
383 my0DActor->PickableOff();
384 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
385 my0DActor->SetVisibility(false);
386 my0DActor->SetProperty(my0DProp);
387 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
388 aFilter = my0DActor->GetExtractUnstructuredGrid();
389 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
390 aFilter->RegisterCellsWithType(VTK_VERTEX);
392 //Definition 0D device of the actor (ball elements)
393 //-----------------------------------------------
394 myBallProp = vtkProperty::New();
395 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
396 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
397 myBallProp->SetPointSize(aBallElemSize);
399 myBallActor = SMESH_CellLabelActor::New();
400 myBallActor->SetUserMatrix(aMatrix);
401 myBallActor->SetStoreClippingMapping(true);
402 myBallActor->PickableOff();
403 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
404 myBallActor->SetVisibility(false);
405 myBallActor->SetProperty(myBallProp);
406 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
407 myBallActor->SetBallEnabled(true);
408 aFilter = myBallActor->GetExtractUnstructuredGrid();
409 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
410 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
412 //my0DExtProp = vtkProperty::New();
413 //my0DExtProp->DeepCopy(my0DProp);
414 //anRGB[0] = 1 - anRGB[0];
415 //anRGB[1] = 1 - anRGB[1];
416 //anRGB[2] = 1 - anRGB[2];
417 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
418 //my0DExtProp->SetPointSize(aElem0DSize);
420 //my0DExtActor = SMESH_DeviceActor::New();
421 //my0DExtActor->SetUserMatrix(aMatrix);
422 //my0DExtActor->SetStoreClippingMapping(true);
423 //my0DExtActor->PickableOff();
424 //my0DExtActor->SetHighlited(true);
425 //my0DExtActor->SetVisibility(false);
426 //my0DExtActor->SetProperty(my0DExtProp);
427 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
428 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
429 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
430 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
431 //aFilter->RegisterCellsWithType(VTK_VERTEX);
434 //Definition 0D device of the actor (nodes)
435 //-----------------------------------------
436 myNodeProp = vtkProperty::New();
437 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
438 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
440 myNodeActor = SMESH_NodeLabelActor::New();
441 myNodeActor->SetUserMatrix(aMatrix);
442 myNodeActor->SetStoreClippingMapping(true);
443 myNodeActor->PickableOff();
444 myNodeActor->SetVisibility(false);
445 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
446 myNodeActor->SetProperty(myNodeProp);
447 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
448 aFilter = myNodeActor->GetExtractUnstructuredGrid();
449 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
451 myNodeExtProp = vtkProperty::New();
452 myNodeExtProp->DeepCopy(myNodeProp);
453 anRGB[0] = 1 - anRGB[0];
454 anRGB[1] = 1 - anRGB[1];
455 anRGB[2] = 1 - anRGB[2];
456 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
458 myNodeExtActor = SMESH_DeviceActor::New();
459 myNodeExtActor->SetUserMatrix(aMatrix);
460 myNodeExtActor->SetStoreClippingMapping(true);
461 myNodeExtActor->PickableOff();
462 myNodeExtActor->SetHighlited(true);
463 myNodeExtActor->SetVisibility(false);
464 myNodeExtActor->SetProperty(myNodeExtProp);
465 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
466 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
467 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
468 aFilter->RegisterCellsWithType(VTK_VERTEX);
470 //Definition of Pickable and Highlitable engines
471 //----------------------------------------------
473 myBaseActor->SetUserMatrix(aMatrix);
474 myBaseActor->SetStoreIDMapping(true);
475 myBaseActor->SetStoreClippingMapping(true);
476 myBaseActor->SetStoreGemetryMapping(true);
477 myBaseActor->GetProperty()->SetOpacity(0.0);
478 myPickableActor = myBaseActor;
480 myHighlightProp = vtkProperty::New();
481 myHighlightProp->SetAmbient(1.0);
482 myHighlightProp->SetDiffuse(0.0);
483 myHighlightProp->SetSpecular(0.0);
484 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
485 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
486 myHighlightProp->SetPointSize(aElem0DSize); // ??
487 myHighlightProp->SetLineWidth(aLineWidth + selectionIncrement);
488 myHighlightProp->SetRepresentation(1);
490 myOutLineProp = vtkProperty::New();
491 myOutLineProp->SetAmbient(1.0);
492 myOutLineProp->SetDiffuse(0.0);
493 myOutLineProp->SetSpecular(0.0);
494 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
495 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
496 myOutLineProp->SetLineWidth(aOutlineWidth);
497 myOutLineProp->SetRepresentation(1);
499 myPreselectProp = vtkProperty::New();
500 myPreselectProp->SetAmbient(1.0);
501 myPreselectProp->SetDiffuse(0.0);
502 myPreselectProp->SetSpecular(0.0);
503 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
504 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
505 myPreselectProp->SetPointSize(aElem0DSize); // ??
506 myPreselectProp->SetLineWidth(aLineWidth + selectionIncrement);
507 myPreselectProp->SetRepresentation(1);
509 myHighlitableActor = SMESH_DeviceActor::New();
510 myHighlitableActor->SetUserMatrix(aMatrix);
511 myHighlitableActor->PickableOff();
512 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
513 myHighlitableActor->SetCoincident3DAllowed(true);
520 myControlMode = eNone;
521 myControlActor = my2DActor;
523 //Definition of myScalarBarActor
524 //------------------------------
525 myLookupTable = vtkLookupTable::New();
526 //Fix for Bug PAL5195 - SMESH764:
527 //Controls - Aspect Ratio: incorrect colors of the best and worst values
528 myLookupTable->SetHueRange(0.667,0.0);
530 myScalarBarActor = SMESH_ScalarBarActor::New();
531 myScalarBarActor->SetVisibility(false);
532 myScalarBarActor->SetLookupTable(myLookupTable);
535 //Incorrect "Min value" in Scalar Bar in Mesh:
536 // myScalarBarActor->SetLabelFormat("%.4g");
537 // changes was commented because of regression bug IPAL 19981
539 mgr = SUIT_Session::session()->resourceMgr();
543 myEntityMode = eAllEntity;
544 myEntityModeCache = eAllEntity;
547 myImplicitBoolean = vtkImplicitBoolean::New();
548 myImplicitBoolean->SetOperationTypeToIntersection();
550 myPlaneCollection = vtkPlaneCollection::New();
552 //Quadratic 2D elements representation
553 //-----------------------------------------------------------------------------
554 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
555 if(aQuadratic2DMode == 0){
556 myHighlitableActor->SetQuadraticArcMode(false);
557 my2DActor->SetQuadraticArcMode(false);
558 my1DActor->SetQuadraticArcMode(false);
560 else if(aQuadratic2DMode == 1){
561 myHighlitableActor->SetQuadraticArcMode(true);
562 my2DActor->SetQuadraticArcMode(true);
563 my1DActor->SetQuadraticArcMode(true);
566 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
567 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
568 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
570 // Set colors of the name actor
571 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
572 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
573 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
574 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
576 #ifndef DISABLE_PLOT2DVIEWER
580 SetBallSize(aBallElemSize);
581 SetBallScale(aBallElemScale);
582 Set0DSize(aElem0DSize);
586 SMESH_ActorDef::~SMESH_ActorDef()
588 MESSAGE("~SMESH_ActorDef - "<<this);
590 // Please keep the order same as one in the header file
592 myTimeStamp->Delete();
594 myScalarBarActor->Delete();
595 myLookupTable->Delete();
597 mySurfaceProp->Delete();
598 myBackSurfaceProp->Delete();
599 myNormalVProp->Delete();
600 myReversedVProp->Delete();
601 myEdgeProp->Delete();
602 myNodeProp->Delete();
604 myNodeActor->Delete();
605 myBaseActor->Delete();
606 //myPickableActor->Delete(); myPickableActor == myBaseActor
608 myHighlightProp->Delete();
609 myOutLineProp->Delete();
610 myPreselectProp->Delete();
612 myHighlitableActor->Delete();
614 my2DExtProp->Delete();
615 my3DExtProp->Delete();
617 my2DExtActor->Delete();
619 my3DExtActor->Delete();
620 // myControlActor->Delete(); myControlActor == my2DActor
622 myNodeExtProp->Delete();
623 myNodeExtActor->Delete();
627 my1DExtProp->Delete();
628 my1DExtActor->Delete();
632 myBallProp->Delete();
633 myBallActor->Delete();
634 //my0DExtProp->Delete();
635 //my0DExtActor->Delete();
637 myImplicitBoolean->Delete();
638 myPlaneCollection->Delete();
640 #ifndef DISABLE_PLOT2DVIEWER
642 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
643 delete my2dHistogram;
648 void SMESH_ActorDef::Delete()
650 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
651 // from the actor's destructor) will be thrown before removing the actor's observers,
652 // that is done inside the Superclass::Delete() method but before the destructor itself
653 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
654 // The event is caught by SMESHGUI::ProcessEvents() static method.
655 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
657 Superclass::Delete();
660 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
663 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
664 SetRepresentation(GetRepresentation());
665 myTimeStamp->Modified();
669 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
670 bool theBold, bool theItalic, bool theShadow,
671 double r, double g, double b )
674 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
675 SetRepresentation( GetRepresentation() );
676 myTimeStamp->Modified();
680 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
681 bool theBold, bool theItalic, bool theShadow,
682 double r, double g, double b )
685 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
688 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
689 SetRepresentation( GetRepresentation() );
690 myTimeStamp->Modified();
693 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
694 SetRepresentation( GetRepresentation() );
695 myTimeStamp->Modified();
698 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
699 SetRepresentation( GetRepresentation() );
700 myTimeStamp->Modified();
703 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
704 SetRepresentation( GetRepresentation() );
705 myTimeStamp->Modified();
709 bool SMESH_ActorDef::GetPointsLabeled()
711 return myNodeActor && myNodeActor->GetPointsLabeled();
714 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
717 my3DActor->SetCellsLabeled(theIsCellsLabeled);
720 my2DActor->SetCellsLabeled(theIsCellsLabeled);
723 my1DActor->SetCellsLabeled(theIsCellsLabeled);
726 my0DActor->SetCellsLabeled(theIsCellsLabeled);
729 myBallActor->SetCellsLabeled(theIsCellsLabeled);
731 SetRepresentation(GetRepresentation());
732 myTimeStamp->Modified();
736 bool SMESH_ActorDef::GetCellsLabeled()
740 result = result || my3DActor->GetCellsLabeled();
743 result = result || my2DActor->GetCellsLabeled();
746 result = result || my1DActor->GetCellsLabeled();
749 result = result || my0DActor->GetCellsLabeled();
752 result = result || myBallActor->GetCellsLabeled();
758 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
760 myIsFacesOriented = theIsFacesOriented;
762 my2DActor->SetFacesOriented(theIsFacesOriented);
763 my3DActor->SetFacesOriented(theIsFacesOriented);
765 myTimeStamp->Modified();
768 bool SMESH_ActorDef::GetFacesOriented()
770 return myIsFacesOriented;
773 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
775 my2DActor->SetFacesOrientationColor( r, g, b );
776 my3DActor->SetFacesOrientationColor( r, g, b );
779 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
781 my3DActor->GetFacesOrientationColor( r, g, b );
784 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
786 my2DActor->SetFacesOrientationScale( theScale );
787 my3DActor->SetFacesOrientationScale( theScale );
790 double SMESH_ActorDef::GetFacesOrientationScale()
792 return my3DActor->GetFacesOrientationScale();
795 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
797 my2DActor->SetFacesOrientation3DVectors( theState );
798 my3DActor->SetFacesOrientation3DVectors( theState );
801 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
803 return my3DActor->GetFacesOrientation3DVectors();
807 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
809 myFunctor = theFunctor;
811 SetControlMode( eNone, true );
813 SetControlMode( eCustomControl, true );
816 void SMESH_ActorDef::SetControlMode(eControl theMode)
818 SetControlMode(theMode,true);
821 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
823 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
824 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
825 lookupTable->SetScale(VTK_SCALE_LINEAR);
827 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
831 //myControlMode = eNone;
832 myControlMode = theMode;
833 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
835 my0DActor->GetMapper()->SetScalarVisibility(false);
836 my1DActor->GetMapper()->SetScalarVisibility(false);
837 my2DActor->GetMapper()->SetScalarVisibility(false);
838 my3DActor->GetMapper()->SetScalarVisibility(false);
839 myBallActor->GetMapper()->SetScalarVisibility(false);
840 myScalarBarActor->SetVisibility(false);
842 bool anIsScalarVisible = theMode > eNone;
844 if(anIsScalarVisible) {
848 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
849 aControl->SetPrecision( myControlsPrecision );
850 myFunctor.reset( aControl );
851 myControlActor = my1DActor;
855 myFunctor.reset(new SMESH::Controls::Length2D());
856 myControlActor = my2DActor;
859 myFunctor.reset(new SMESH::Controls::FreeBorders());
860 myControlActor = my1DActor;
863 myFunctor.reset(new SMESH::Controls::FreeEdges());
864 myControlActor = my2DActor;
867 myFunctor.reset(new SMESH::Controls::FreeNodes());
868 myControlActor = myNodeActor;
871 myFunctor.reset(new SMESH::Controls::FreeFaces());
872 myControlActor = my2DActor;
874 case eCoincidentNodes:
876 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
877 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
878 cn->SetTolerance( tol );
880 myControlActor = myNodeActor;
883 case eCoincidentElems1D:
884 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
885 myControlActor = my1DActor;
887 case eCoincidentElems2D:
888 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
889 myControlActor = my2DActor;
891 case eCoincidentElems3D:
892 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
893 myControlActor = my3DActor;
895 case eBareBorderFace:
896 myFunctor.reset(new SMESH::Controls::BareBorderFace());
897 myControlActor = my2DActor;
899 case eOverConstrainedFace:
900 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
901 myControlActor = my2DActor;
903 case eMultiConnection:
904 myFunctor.reset(new SMESH::Controls::MultiConnection());
905 myControlActor = my1DActor;
907 case eMultiConnection2D:
908 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
909 myControlActor = my2DActor;
913 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
914 aControl->SetPrecision( myControlsPrecision );
915 myFunctor.reset( aControl );
916 myControlActor = my2DActor;
921 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
922 aControl->SetPrecision( myControlsPrecision );
923 myFunctor.reset( aControl );
924 myControlActor = my2DActor;
929 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
930 aControl->SetPrecision( myControlsPrecision );
931 myFunctor.reset( aControl );
932 myControlActor = my2DActor;
937 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
938 aControl->SetPrecision( myControlsPrecision );
939 myFunctor.reset( aControl );
940 myControlActor = my3DActor;
945 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
946 aControl->SetPrecision( myControlsPrecision );
947 myFunctor.reset( aControl );
948 myControlActor = my3DActor;
951 case eMaxElementLength2D:
953 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
954 aControl->SetPrecision( myControlsPrecision );
955 myFunctor.reset( aControl );
956 myControlActor = my2DActor;
959 case eMaxElementLength3D:
961 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
962 aControl->SetPrecision( myControlsPrecision );
963 myFunctor.reset( aControl );
964 myControlActor = my3DActor;
969 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
970 aControl->SetPrecision( myControlsPrecision );
971 myFunctor.reset( aControl );
972 myControlActor = my2DActor;
975 case eBareBorderVolume:
977 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
978 myControlActor = my3DActor;
981 case eOverConstrainedVolume:
983 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
984 myControlActor = my3DActor;
989 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
997 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
998 aControl->SetPrecision( myControlsPrecision );
999 myFunctor.reset( aControl );
1000 myControlActor = my2DActor;
1005 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1006 aControl->SetPrecision( myControlsPrecision );
1007 myFunctor.reset( aControl );
1008 myControlActor = my2DActor;
1011 case eNodeConnectivityNb:
1013 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1014 myControlActor = myNodeActor;
1017 case eCustomControl:
1021 switch ( myFunctor->GetType() ) {
1022 case SMDSAbs_Node : myControlActor = myNodeActor; break;
1023 case SMDSAbs_Edge : myControlActor = my1DActor; break;
1024 case SMDSAbs_Face : myControlActor = my2DActor; break;
1025 case SMDSAbs_Volume : myControlActor = my3DActor; break;
1034 smIdType aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1035 bool aShowOnlyScalarBarTitle = false;
1037 //myControlMode = theMode;
1038 switch(myControlMode){
1040 case eCoincidentNodes:
1041 myNodeExtActor->SetExtControlMode(myFunctor);
1042 aShowOnlyScalarBarTitle = true;
1046 case eCoincidentElems1D:
1047 my1DExtActor->SetExtControlMode(myFunctor);
1048 aShowOnlyScalarBarTitle = true;
1051 case eBareBorderFace:
1052 case eOverConstrainedFace:
1053 case eCoincidentElems2D:
1054 my2DExtActor->SetExtControlMode(myFunctor);
1055 aShowOnlyScalarBarTitle = true;
1057 case eBareBorderVolume:
1058 case eOverConstrainedVolume:
1059 case eCoincidentElems3D:
1060 my3DExtActor->SetExtControlMode(myFunctor);
1061 aShowOnlyScalarBarTitle = true;
1064 case eMultiConnection2D:
1065 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1066 UpdateDistribution();
1069 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1070 UpdateDistribution();
1072 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1075 if(theCheckEntityMode) {
1076 // if(myControlActor == myNodeActor) {
1077 // if ( myControlMode == eNodeConnectivityNb ) {
1078 // if (!myIsEntityModeCache){
1079 // myEntityModeCache = GetEntityMode();
1080 // myIsEntityModeCache=true;
1082 // SetEntityMode(0);
1085 if(myControlActor == my1DActor) {
1086 if (!myIsEntityModeCache){
1087 myEntityModeCache = GetEntityMode();
1088 myIsEntityModeCache=true;
1090 SetEntityMode(eEdges);
1092 else if(myControlActor == my2DActor) {
1093 if (!myIsEntityModeCache){
1094 myEntityModeCache = GetEntityMode();
1095 myIsEntityModeCache=true;
1097 SetEntityMode(eFaces);
1099 else if(myControlActor == my3DActor) {
1100 if (!myIsEntityModeCache){
1101 myEntityModeCache = GetEntityMode();
1102 myIsEntityModeCache=true;
1104 SetEntityMode(eVolumes);
1107 QString aTitle = QString(myScalarBarActor->GetTitle());
1108 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1109 myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
1113 if(theCheckEntityMode){
1114 myEntityMode = myEntityModeCache;
1115 myIsEntityModeCache = false;
1120 SetRepresentation(GetRepresentation());
1122 myTimeStamp->Modified();
1125 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1126 double * range = lookupTable->GetRange();
1128 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1129 lookupTable->SetScale(VTK_SCALE_LOG10);
1134 smIdType SMESH_ActorDef::GetNumberControlEntities()
1136 SMESH_DeviceActor* anAct = NULL;
1137 switch(myControlMode){
1139 case eCoincidentNodes:
1140 anAct = myNodeExtActor;
1144 case eCoincidentElems1D:
1145 anAct = my1DExtActor;
1148 case eBareBorderFace:
1149 case eOverConstrainedFace:
1150 case eCoincidentElems2D:
1151 anAct = my2DExtActor;
1153 case eBareBorderVolume:
1154 case eOverConstrainedVolume:
1155 case eCoincidentElems3D:
1156 anAct = my3DExtActor;
1160 return anAct ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1163 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1165 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1167 myBaseActor->SetUnstructuredGrid( NULL );
1168 //myHighlitableActor->SetUnstructuredGrid( NULL );
1170 theRenderer->AddActor(myBaseActor);
1171 theRenderer->AddActor(myNodeExtActor);
1172 theRenderer->AddActor(my1DExtActor);
1174 my3DActor ->AddToRender(theRenderer);
1175 my3DExtActor->AddToRender(theRenderer);
1176 my2DActor ->AddToRender(theRenderer);
1177 my2DExtActor->AddToRender(theRenderer);
1178 myNodeActor ->AddToRender(theRenderer);
1179 my1DActor ->AddToRender(theRenderer);
1180 my0DActor ->AddToRender(theRenderer);
1181 myBallActor ->AddToRender(theRenderer);
1183 theRenderer->AddActor(myHighlitableActor);
1185 theRenderer->AddActor2D(myScalarBarActor);
1187 // the superclass' method should be called at the end
1188 // (in particular, for correct work of selection)
1189 SALOME_Actor::AddToRender(theRenderer);
1192 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1194 SALOME_Actor::RemoveFromRender(theRenderer);
1196 theRenderer->RemoveActor(myBaseActor);
1198 theRenderer->RemoveActor(myNodeExtActor);
1200 theRenderer->RemoveActor(myHighlitableActor);
1202 //theRenderer->RemoveActor(my0DExtActor);
1204 theRenderer->RemoveActor(my1DExtActor);
1206 my2DActor->RemoveFromRender(theRenderer);
1207 my2DExtActor->RemoveFromRender(theRenderer);
1208 my3DActor->RemoveFromRender(theRenderer);
1209 my3DExtActor->RemoveFromRender(theRenderer);
1210 myNodeActor->RemoveFromRender(theRenderer);
1211 my0DActor->RemoveFromRender(theRenderer);
1212 myBallActor->RemoveFromRender(theRenderer);
1213 my1DActor->RemoveFromRender(theRenderer);
1215 theRenderer->RemoveActor(myScalarBarActor);
1219 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1220 const char* theEntry,
1221 const char* theName,
1224 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1228 myVisualObj = theVisualObj;
1229 myVisualObj->Update(theIsClear);
1231 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1232 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1234 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1235 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1237 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1239 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1241 my0DActor->Init(myVisualObj,myImplicitBoolean);
1242 myBallActor->Init(myVisualObj,myImplicitBoolean);
1243 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1245 my1DActor->Init(myVisualObj,myImplicitBoolean);
1246 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1248 my2DActor->Init(myVisualObj,myImplicitBoolean);
1249 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1250 my3DActor->Init(myVisualObj,myImplicitBoolean);
1251 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1253 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1254 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1255 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1257 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1258 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1260 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1261 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1262 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1263 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1265 double aFactor, aUnits;
1266 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1267 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1268 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1269 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1271 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1275 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1276 SetIsShrunkable(true);
1278 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1280 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1281 SetRepresentation(-1);
1284 SetRepresentation(eEdge);
1285 }else if(aMode == 1){
1286 SetRepresentation(eSurface);
1287 }else if(aMode == 2){
1288 SetRepresentation(ePoint);
1295 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1296 SetIsDisplayNameActor( true );
1298 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1299 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1300 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1302 myTimeStamp->Modified();
1308 double* SMESH_ActorDef::GetBounds()
1310 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1311 return myNodeActor->GetBounds();
1312 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1316 vtkDataSet* SMESH_ActorDef::GetInput()
1318 return GetUnstructuredGrid();
1322 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1324 Superclass::SetTransform(theTransform);
1326 myNodeActor->SetTransform(theTransform);
1327 myBaseActor->SetTransform(theTransform);
1329 myHighlitableActor->SetTransform(theTransform);
1331 myNodeExtActor->SetTransform(theTransform);
1333 my0DActor->SetTransform(theTransform);
1334 myBallActor->SetTransform(theTransform);
1335 //my0DExtActor->SetTransform(theTransform);
1337 my1DActor->SetTransform(theTransform);
1338 my1DExtActor->SetTransform(theTransform);
1340 my2DActor->SetTransform(theTransform);
1341 my2DExtActor->SetTransform(theTransform);
1342 my3DActor->SetTransform(theTransform);
1343 my3DExtActor->SetTransform(theTransform);
1349 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1351 vtkLODActor::SetMapper(theMapper);
1355 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1357 SALOME_Actor::ShallowCopy(prop);
1361 vtkMapper* SMESH_ActorDef::GetMapper()
1363 return myPickableActor->GetMapper();
1367 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1369 return myVisualObj->GetUnstructuredGrid();
1373 bool SMESH_ActorDef::IsInfinitive()
1375 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1376 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1377 ( aDataSet->GetNumberOfCells() == 1 &&
1378 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1379 return SALOME_Actor::IsInfinitive();
1383 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1385 if ( myIsShrinkable == theShrunkable )
1387 myIsShrinkable = theShrunkable;
1391 double SMESH_ActorDef::GetShrinkFactor()
1393 return myBaseActor->GetShrinkFactor();
1396 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1398 myBaseActor->SetShrinkFactor(theValue);
1400 my1DActor->SetShrinkFactor(theValue);
1401 my1DExtActor->SetShrinkFactor(theValue);
1403 my2DActor->SetShrinkFactor(theValue);
1404 my2DExtActor->SetShrinkFactor(theValue);
1405 my3DActor->SetShrinkFactor(theValue);
1406 my3DExtActor->SetShrinkFactor(theValue);
1407 my3DExtActor->SetShrinkFactor(theValue);
1408 myHighlitableActor->SetShrinkFactor(theValue);
1413 void SMESH_ActorDef::SetShrink()
1415 if(!myIsShrinkable) return;
1417 myBaseActor->SetShrink();
1419 my1DActor->SetShrink();
1420 my1DExtActor->SetShrink();
1422 my2DActor->SetShrink();
1423 my2DExtActor->SetShrink();
1424 my3DActor->SetShrink();
1425 my3DExtActor->SetShrink();
1426 myHighlitableActor->SetShrink();
1432 void SMESH_ActorDef::UnShrink()
1434 if(!myIsShrunk) return;
1436 myBaseActor->UnShrink();
1438 my1DActor->UnShrink();
1439 my1DExtActor->UnShrink();
1441 my2DActor->UnShrink();
1442 my2DExtActor->UnShrink();
1443 my3DActor->UnShrink();
1444 my3DExtActor->UnShrink();
1445 myHighlitableActor->UnShrink();
1452 vtkIdType SMESH_ActorDef::GetNodeObjId(vtkIdType theVtkID)
1454 return myPickableActor->GetNodeObjId(theVtkID);
1457 double* SMESH_ActorDef::GetNodeCoord(vtkIdType theObjID)
1459 return myPickableActor->GetNodeCoord(theObjID);
1462 vtkIdType SMESH_ActorDef::GetNodeVtkId(vtkIdType theObjID)
1464 return myPickableActor->GetNodeVtkId(theObjID);
1467 vtkIdType SMESH_ActorDef::GetElemObjId(vtkIdType theVtkID)
1469 return myPickableActor->GetElemObjId(theVtkID);
1472 vtkCell* SMESH_ActorDef::GetElemCell(vtkIdType theObjID)
1474 return myPickableActor->GetElemCell(theObjID);
1478 void SMESH_ActorDef::SetVisibility(int theMode)
1480 SetVisibility(theMode,true);
1484 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1486 SALOME_Actor::SetVisibility(theMode);
1488 myNodeActor->VisibilityOff();
1489 myBaseActor->VisibilityOff();
1491 myNodeExtActor->VisibilityOff();
1493 my0DActor->VisibilityOff();
1494 myBallActor->VisibilityOff();
1495 //my0DExtActor->VisibilityOff();
1497 my1DActor->VisibilityOff();
1498 my1DExtActor->VisibilityOff();
1500 my2DActor->VisibilityOff();
1501 my2DExtActor->VisibilityOff();
1502 my3DActor->VisibilityOff();
1503 my3DExtActor->VisibilityOff();
1505 myScalarBarActor->VisibilityOff();
1507 if ( GetVisibility() ) {
1508 if ( theIsUpdateRepersentation )
1509 SetRepresentation(GetRepresentation());
1511 if(myControlMode != eNone) {
1512 switch(myControlMode) {
1514 case eCoincidentNodes:
1515 myNodeExtActor->VisibilityOn();
1518 case eMultiConnection:
1519 my1DActor->VisibilityOn();
1523 case eCoincidentElems1D:
1525 case eMultiConnection2D:
1526 my1DExtActor->VisibilityOn();
1529 case eBareBorderFace:
1530 case eOverConstrainedFace:
1531 case eCoincidentElems2D:
1532 my2DExtActor->VisibilityOn();
1534 case eBareBorderVolume:
1535 case eOverConstrainedVolume:
1536 case eCoincidentElems3D:
1537 my3DExtActor->VisibilityOn();
1541 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1542 myScalarBarActor->VisibilityOn();
1545 if ( GetPickable( ))
1546 myPickableActor->VisibilityOn();
1548 if ( GetRepresentation() != ePoint )
1550 if(myEntityMode & e0DElements ){
1551 my0DActor->VisibilityOn();
1553 if(myEntityMode & eBallElem ){
1554 myBallActor->VisibilityOn();
1556 if(myEntityMode & eEdges && ( GetCellsLabeled() || // my1DActor shows labels only
1557 ( myControlActor == my1DActor && myControlMode != eNone ))){
1558 my1DActor->VisibilityOn();
1560 if(myEntityMode & eFaces ){
1561 my2DActor->VisibilityOn();
1563 if(myEntityMode & eVolumes ){
1564 my3DActor->VisibilityOn();
1568 if(myNodeActor->GetPointsLabeled()) {
1569 myNodeActor->UpdateLabels();
1570 myNodeActor->VisibilityOn();
1573 my0DActor->UpdateLabels();
1576 myBallActor->UpdateLabels();
1579 my1DActor->UpdateLabels();
1582 my2DActor->UpdateLabels();
1585 my3DActor->UpdateLabels();
1587 #ifndef DISABLE_PLOT2DVIEWER
1589 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1596 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1598 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1600 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1601 anObjectEntities &= ~e0DElements;
1602 theMode &= ~e0DElements;
1605 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1606 anObjectEntities &= ~eBallElem;
1607 theMode &= ~eBallElem;
1610 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1611 anObjectEntities &= ~eEdges;
1615 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1616 anObjectEntities &= ~eFaces;
1620 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1621 anObjectEntities &= ~eVolumes;
1622 theMode &= ~eVolumes;
1626 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1627 theMode |= e0DElements;
1629 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1630 theMode |= eBallElem;
1632 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1635 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1638 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1639 theMode |= eVolumes;
1642 // rnv : Fix volume selection on Display Entity
1643 //myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1645 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1647 myRepresentationCache = GetRepresentation();
1648 SetRepresentation( ePoint );
1651 if ( anObjectEntities != 0 && objectEntitiesCache == 0 )
1653 objectEntitiesCache = anObjectEntities;
1654 SetRepresentation( eSurface );
1657 if ( myEntityMode != theMode )
1659 myEntityMode = theMode; // entities to show
1661 // Set cell types to extract
1665 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1668 void SMESH_ActorDef::SetRepresentation (int theMode)
1670 smIdType aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1671 smIdType aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1672 smIdType aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1673 smIdType aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1674 smIdType aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1676 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1678 theMode = myRepresentationCache;
1679 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1682 myRepresentationCache = 0;
1686 myRepresentation = eSurface;
1687 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1688 myRepresentation = eEdge;
1689 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1690 myRepresentation = ePoint;
1695 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1698 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1701 myRepresentation = theMode;
1704 if (!GetUnstructuredGrid()->GetNumberOfCells())
1705 myRepresentation = ePoint;
1708 if (myRepresentation == ePoint) {
1716 myPickableActor = myBaseActor;
1717 vtkProperty *aProp = NULL, *aBackProp = NULL;
1718 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1719 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::eNoneRepr;
1720 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1721 switch (myRepresentation) {
1723 myPickableActor = myNodeActor;
1724 aQuadraticMode = SMESH_Actor::eLines;
1725 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1726 aReperesent = SMESH_DeviceActor::ePoint;
1729 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1730 aReperesent = SMESH_DeviceActor::eInsideframe;
1733 aProp = mySurfaceProp;
1734 aBackProp = myBackSurfaceProp;
1735 aPropVN = myNormalVProp;
1736 aPropVR = myReversedVProp;
1737 aReperesent = SMESH_DeviceActor::eSurface;
1741 if ( myRepresentation != ePoint )
1743 my2DActor->SetProperty(aProp);
1744 my2DActor->SetBackfaceProperty(aBackProp);
1745 my2DActor->SetRepresentation(aReperesent);
1747 if(aQuadraticMode == SMESH_Actor::eLines)
1748 my2DActor->SetQuadraticArcMode(false);
1749 else if(aQuadraticMode == SMESH_Actor::eArcs)
1750 my2DActor->SetQuadraticArcMode(true);
1752 my2DExtActor->SetRepresentation(aReperesent);
1754 my3DActor->SetProperty(aPropVN);
1755 my3DActor->SetBackfaceProperty(aPropVR);
1756 my3DActor->SetRepresentation(aReperesent);
1758 my0DActor->SetRepresentation(aReperesent);
1759 myBallActor->SetRepresentation(aReperesent);
1761 switch ( myControlMode ) {
1763 case eMultiConnection:
1764 aProp = aBackProp = my1DProp;
1765 if ( myRepresentation != ePoint )
1766 aReperesent = SMESH_DeviceActor::eInsideframe;
1768 case eCustomControl:
1769 if ( myControlActor == my1DActor )
1770 aProp = aBackProp = my1DProp;
1771 if ( myRepresentation != ePoint )
1772 aReperesent = SMESH_DeviceActor::eInsideframe;
1777 if(aQuadraticMode == SMESH_Actor::eLines)
1778 my1DActor->SetQuadraticArcMode(false);
1779 else if(aQuadraticMode == SMESH_Actor::eArcs)
1780 my1DActor->SetQuadraticArcMode(true);
1782 my1DActor->SetProperty(aProp);
1783 my1DActor->SetBackfaceProperty(aBackProp);
1784 my1DActor->SetRepresentation(aReperesent);
1786 my1DExtActor->SetRepresentation(aReperesent);
1789 if(myIsPointsVisible)
1790 myPickableActor = myNodeActor;
1792 SetMapper(myPickableActor->GetMapper());
1794 SetVisibility(GetVisibility(),false);
1800 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1802 if ( myIsPointsVisible == theIsPointsVisible )
1804 myIsPointsVisible = theIsPointsVisible;
1805 SetRepresentation(GetRepresentation());
1808 bool SMESH_ActorDef::GetPointRepresentation()
1810 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1814 void SMESH_ActorDef::UpdateHighlight()
1816 myHighlitableActor->SetHighlited(false);
1817 myHighlitableActor->SetVisibility(false);
1818 bool anIsVisible = GetVisibility();
1820 switch(myRepresentation){
1821 case SMESH_DeviceActor::eSurface:
1822 case SMESH_DeviceActor::eWireframe:
1824 if(myIsHighlighted) {
1825 myHighlitableActor->SetProperty(myHighlightProp);
1826 }else if(myIsPreselected){
1827 myHighlitableActor->SetProperty(myPreselectProp);
1828 } else if(anIsVisible){
1829 (myRepresentation == eSurface) ?
1830 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1832 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1833 myHighlitableActor->SetHighlited(anIsVisible);
1834 myHighlitableActor->GetExtractUnstructuredGrid()->
1835 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1836 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1838 myHighlitableActor->SetVisibility(anIsVisible);
1841 case SMESH_DeviceActor::ePoint:
1843 if(myIsHighlighted) {
1844 myNodeActor->SetProperty(myHighlightProp);
1845 }else if(myIsPreselected) {
1846 myNodeActor->SetProperty(myPreselectProp);
1847 } else if(anIsVisible) {
1848 myNodeActor->SetProperty(myNodeProp);
1850 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1851 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1852 myNodeActor->GetProperty()->Modified();
1858 void SMESH_ActorDef::EnableSelection( bool enable )
1860 // selection in the Viewer enabled/disabled
1861 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1863 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1864 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1865 myBaseActor->myExtractUnstructuredGrid->Update();
1866 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1868 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1870 myBaseActor->SetUnstructuredGrid( NULL );
1871 //myHighlitableActor->SetUnstructuredGrid( NULL );
1872 myBaseActor->myExtractUnstructuredGrid->Update();
1873 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1877 void SMESH_ActorDef::highlight(bool theHighlight)
1879 if ( myIsHighlighted == theHighlight )
1881 myIsHighlighted = theHighlight;
1886 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1888 if ( myIsPreselected == thePreselect )
1890 myIsPreselected = thePreselect;
1896 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1898 if (myPickableActor->GetIsOpaque())
1900 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1908 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1910 if (!myPickableActor->GetIsOpaque())
1912 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1920 void SMESH_ActorDef::Render(vtkRenderer* /*ren*/)
1922 vtkMTimeType aTime = myTimeStamp->GetMTime();
1923 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1924 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1925 if(anObjTime > aTime || aClippingTime > aTime)
1930 void SMESH_ActorDef::Update()
1932 MESSAGE("SMESH_ActorDef::Update");
1934 myVisualObj->Update();
1936 if(GetControlMode() != eNone) {
1937 unsigned long aTime = myTimeStamp->GetMTime();
1938 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1939 if (anObjTime > aTime)
1940 SetControlMode(GetControlMode(),false);
1944 myNodeActor->UpdateLabels();
1947 my0DActor->UpdateLabels();
1950 myBallActor->UpdateLabels();
1953 my1DActor->UpdateLabels();
1956 my2DActor->UpdateLabels();
1959 my3DActor->UpdateLabels();
1961 if(myIsFacesOriented){
1962 SetFacesOriented(myIsFacesOriented);
1965 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
1966 // myEntityMode |= myVisualObj->GetEntitiesState();
1969 SetEntityMode(GetEntityMode());
1970 SetVisibility(GetVisibility());
1972 myTimeStamp->Modified();
1977 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
1979 SALOME_Actor::ReleaseGraphicsResources(renWin);
1981 myPickableActor->ReleaseGraphicsResources(renWin);
1985 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
1987 double* aColor = theProperty->GetColor();
1994 void SMESH_ActorDef::SetOpacity(double theValue)
1996 mySurfaceProp->SetOpacity(theValue);
1997 myBackSurfaceProp->SetOpacity(theValue);
1998 myNormalVProp->SetOpacity(theValue);
1999 myReversedVProp->SetOpacity(theValue);
2000 myEdgeProp->SetOpacity(theValue);
2001 myOutLineProp->SetOpacity(theValue);
2002 myNodeProp->SetOpacity(theValue);
2004 my1DProp->SetOpacity(theValue);
2005 my0DProp->SetOpacity(theValue);
2006 myBallProp->SetOpacity(theValue);
2010 double SMESH_ActorDef::GetOpacity()
2012 return mySurfaceProp->GetOpacity();
2016 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2018 mySurfaceProp->SetColor(r,g,b);
2019 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2020 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2021 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2022 myNameActor->SetBackgroundColor(r,g,b);
2024 myDeltaBrightness = delta;
2025 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2026 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2030 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2032 ::GetColor(mySurfaceProp,r,g,b);
2033 delta = myDeltaBrightness;
2036 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2038 myNormalVProp->SetColor(r,g,b);
2039 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2040 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2041 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2042 myNameActor->SetBackgroundColor(r,g,b);
2044 myDeltaVBrightness = delta;
2045 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2046 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2050 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2052 ::GetColor(myNormalVProp,r,g,b);
2053 delta = myDeltaVBrightness;
2056 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2058 myEdgeProp->SetColor(r,g,b);
2059 my1DProp->SetColor(r,g,b);
2060 my1DExtProp->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_Edge )
2063 myNameActor->SetBackgroundColor(r,g,b);
2067 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2069 ::GetColor(myEdgeProp,r,g,b);
2072 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2074 myOutLineProp->SetColor(r,g,b);
2078 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2080 ::GetColor(myOutLineProp,r,g,b);
2084 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2086 myNodeProp->SetColor(r,g,b);
2087 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2088 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2089 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2090 myNameActor->SetBackgroundColor(r,g,b);
2094 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2096 ::GetColor(myNodeProp,r,g,b);
2099 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2101 my0DProp->SetColor(r,g,b);
2102 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2103 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2104 myNameActor->SetBackgroundColor(r,g,b);
2108 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2110 ::GetColor(my0DProp,r,g,b);
2113 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2115 myBallProp->SetColor(r,g,b);
2116 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2117 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2118 myNameActor->SetBackgroundColor(r,g,b);
2122 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2124 ::GetColor(myBallProp,r,g,b);
2127 void SMESH_ActorDef::UpdateSelectionProps()
2129 QColor selectionColor = SMESH_ActorProps::props()->selectionColor();
2130 QColor highlightColor = SMESH_ActorProps::props()->highlightColor();
2131 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2132 float width = (float) GetLineWidth();
2133 myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF());
2134 myHighlightProp->SetLineWidth(width + selectionIncrement);
2135 myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF());
2136 myPreselectProp->SetLineWidth(width + selectionIncrement);
2140 double SMESH_ActorDef::GetLineWidth()
2142 return myEdgeProp->GetLineWidth();
2146 void SMESH_ActorDef::SetLineWidth(double theVal)
2148 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
2149 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2151 myEdgeProp->SetLineWidth((float) theVal);
2153 my1DProp ->SetLineWidth((float) theVal + controlsIncrement);
2154 my1DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2155 my2DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2156 my3DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2157 myHighlightProp->SetLineWidth((float) theVal + selectionIncrement);
2158 myPreselectProp->SetLineWidth((float) theVal + selectionIncrement);
2162 double SMESH_ActorDef::GetOutlineWidth()
2164 return myOutLineProp->GetLineWidth();
2167 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2169 myOutLineProp->SetLineWidth((float) theVal);
2173 void SMESH_ActorDef::Set0DSize(double theVal)
2175 my0DProp ->SetPointSize((float) theVal);
2176 myHighlightProp->SetPointSize((float) theVal);
2177 myPreselectProp->SetPointSize((float) theVal);
2179 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2180 aCustom->Set0DSize((float) theVal);
2182 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2183 aCustom->Set0DSize((float) theVal);
2189 double SMESH_ActorDef::Get0DSize()
2191 return my0DProp->GetPointSize();
2194 void SMESH_ActorDef::SetBallSize(double theVal)
2196 myBallProp->SetPointSize((float) theVal);
2198 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2199 aCustom->SetBallSize((float) theVal);
2201 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2202 aCustom->SetBallSize((float) theVal);
2208 double SMESH_ActorDef::GetBallSize()
2210 return myBallProp->GetPointSize();
2213 double SMESH_ActorDef::GetBallScale()
2215 return myBallActor->GetBallScale();
2218 void SMESH_ActorDef::SetBallScale( double theVal )
2220 myBallActor->SetBallScale( theVal );
2221 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2222 aCustom->SetBallScale(theVal);
2224 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2225 aCustom->SetBallScale(theVal);
2231 int SMESH_ActorDef::GetObjDimension( const vtkIdType theObjId )
2233 return myVisualObj->GetElemDimension( theObjId );
2236 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2238 return myBaseActor->IsImplicitFunctionUsed();
2241 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2243 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2244 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2246 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2248 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2250 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2251 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2252 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2254 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2255 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2257 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2258 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2259 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2260 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2263 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2266 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2267 myCippingPlaneCont.push_back(thePlane);
2268 if(!IsImplicitFunctionUsed())
2269 SetImplicitFunctionUsed(true);
2270 myNodeActor->UpdateLabels();
2272 return myCippingPlaneCont.size();
2275 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2278 myPlaneCollection->AddItem( thePlane );
2281 void SMESH_ActorDef::SetOpenGLClippingPlane()
2283 // before use this method you must add clipping planes using method
2284 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2285 if( !myPlaneCollection->GetNumberOfItems() )
2288 // It is necessary to set plane collection for each mapper of actor
2289 // and update current inputs of mapper
2290 myNodeActor->SetPlaneCollection( myPlaneCollection );
2291 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2293 myBaseActor->SetPlaneCollection( myPlaneCollection );
2294 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2296 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2297 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2299 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2301 myBaseActor->SetUnstructuredGrid( NULL );
2302 //myHighlitableActor->SetUnstructuredGrid( NULL );
2304 my1DActor->SetPlaneCollection( myPlaneCollection );
2305 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2307 my2DActor->SetPlaneCollection( myPlaneCollection );
2308 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2310 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2311 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2313 my0DActor->SetPlaneCollection( myPlaneCollection );
2314 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2316 myBallActor->SetPlaneCollection( myPlaneCollection );
2317 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2319 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2320 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2322 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2323 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2325 my3DActor->SetPlaneCollection( myPlaneCollection );
2326 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2328 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2329 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2337 void SMESH_ActorDef::RemoveAllClippingPlanes()
2339 myPlaneCollection->RemoveAllItems();
2340 myImplicitBoolean->GetFunction()->RemoveAllItems();
2341 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2342 myCippingPlaneCont.clear();
2343 SetImplicitFunctionUsed(false);
2344 myNodeActor->UpdateLabels();
2347 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2349 return myCippingPlaneCont.size();
2352 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2354 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2356 return myCippingPlaneCont[theID].Get();
2359 void SMESH_ActorDef::UpdateScalarBar()
2361 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2365 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2367 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2368 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2370 aScalarBarTitleProp->SetFontFamilyToArial();
2372 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2374 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2375 if ( f.family() == "Arial" )
2376 aScalarBarTitleProp->SetFontFamilyToArial();
2377 else if ( f.family() == "Courier" )
2378 aScalarBarTitleProp->SetFontFamilyToCourier();
2379 else if ( f.family() == "Times" )
2380 aScalarBarTitleProp->SetFontFamilyToTimes();
2383 aScalarBarTitleProp->BoldOn();
2385 aScalarBarTitleProp->BoldOff();
2388 aScalarBarTitleProp->ItalicOn();
2390 aScalarBarTitleProp->ItalicOff();
2393 aScalarBarTitleProp->ShadowOn();
2395 aScalarBarTitleProp->ShadowOff();
2398 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2399 aScalarBarTitleProp->Delete();
2401 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2403 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2404 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2406 aScalarBarLabelProp->SetFontFamilyToArial();
2407 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2409 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2410 if( f.family() == "Arial" )
2411 aScalarBarLabelProp->SetFontFamilyToArial();
2412 else if( f.family() == "Courier" )
2413 aScalarBarLabelProp->SetFontFamilyToCourier();
2414 else if( f.family() == "Times" )
2415 aScalarBarLabelProp->SetFontFamilyToTimes();
2418 aScalarBarLabelProp->BoldOn();
2420 aScalarBarLabelProp->BoldOff();
2423 aScalarBarLabelProp->ItalicOn();
2425 aScalarBarLabelProp->ItalicOff();
2428 aScalarBarLabelProp->ShadowOn();
2430 aScalarBarLabelProp->ShadowOff();
2433 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2434 aScalarBarLabelProp->Delete();
2436 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2437 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2439 myScalarBarActor->SetOrientationToHorizontal();
2441 myScalarBarActor->SetOrientationToVertical();
2444 double aXVal = horiz ? 0.20 : 0.01;
2445 if( mgr->hasValue( "SMESH", name + "x" ) )
2446 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2448 double aYVal = horiz ? 0.01 : 0.1;
2449 if( mgr->hasValue( "SMESH", name + "y" ) )
2450 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2451 myScalarBarActor->SetPosition( aXVal, aYVal );
2453 double aWVal = horiz ? 0.60 : 0.10;
2454 if( mgr->hasValue( "SMESH", name + "width" ) )
2455 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2456 myScalarBarActor->SetWidth( aWVal );
2458 double aHVal = horiz ? 0.12 : 0.80;
2459 if( mgr->hasValue( "SMESH", name + "height" ) )
2460 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2461 myScalarBarActor->SetHeight( aHVal );
2464 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2465 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2466 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2469 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2470 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2471 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2473 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2474 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2476 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2477 myScalarBarActor->SetDistributionColoringType(coloringType);
2479 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2480 QColor(255, 255, 255));
2482 rgb[0]= distributionColor.red()/255.;
2483 rgb[1]= distributionColor.green()/255.;
2484 rgb[2]= distributionColor.blue()/255.;
2485 myScalarBarActor->SetDistributionColor(rgb);
2490 void SMESH_ActorDef::UpdateDistribution()
2492 if(SMESH::Controls::NumericalFunctor* fun =
2493 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2495 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2496 std::vector<int> nbEvents;
2497 std::vector<double> funValues;
2498 SMESH_VisualObjDef::TEntityList elems;
2499 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2500 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2501 std::vector<smIdType> elemIds; elemIds.reserve( elems.size() );
2502 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2503 elemIds.push_back( (*e)->GetID());
2504 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2505 double * range = lookupTable->GetRange();
2506 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2507 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2508 myScalarBarActor->SetDistribution(nbEvents);
2512 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2515 case SMESH_Actor::eLines :
2516 myHighlitableActor->SetQuadraticArcMode(false);
2517 my2DActor->SetQuadraticArcMode(false);
2518 my1DActor->SetQuadraticArcMode(false);
2520 case SMESH_Actor::eArcs :
2521 myHighlitableActor->SetQuadraticArcMode(true);
2522 if(GetRepresentation() != SMESH_Actor::ePoint) {
2523 my2DActor->SetQuadraticArcMode(true);
2524 my1DActor->SetQuadraticArcMode(true);
2533 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2535 if(myHighlitableActor->GetQuadraticArcMode())
2536 return SMESH_Actor::eArcs;
2538 return SMESH_Actor::eLines;
2541 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2543 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2544 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2545 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2548 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2550 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2551 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2552 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2553 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2556 void SMESH_ActorDef::UpdateFilter()
2558 unsigned int anObjectEntities = eAllEntity; // entities present in my object
2560 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
2561 anObjectEntities &= ~e0DElements;
2564 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
2565 anObjectEntities &= ~eBallElem;
2568 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
2569 anObjectEntities &= ~eEdges;
2572 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
2573 anObjectEntities &= ~eFaces;
2576 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
2577 anObjectEntities &= ~eVolumes;
2580 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
2581 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
2582 aFilter->ClearRegisteredCellsWithType();
2583 aHltFilter->ClearRegisteredCellsWithType();
2585 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
2588 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2589 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2593 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2594 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2595 if (myEntityMode & e0DElements) {
2596 aFilter->RegisterCellsWithType(VTK_VERTEX);
2597 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
2600 if (myEntityMode & eBallElem) {
2601 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
2603 if (myEntityMode & eEdges) {
2604 aFilter->RegisterCellsWithType(VTK_LINE);
2605 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2606 aHltFilter->RegisterCellsWithType(VTK_LINE);
2607 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2610 if (myEntityMode & eFaces) {
2611 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
2612 aFilter->RegisterCellsWithType(VTK_QUAD);
2613 aFilter->RegisterCellsWithType(VTK_POLYGON);
2614 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2615 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2616 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2617 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2618 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2619 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
2620 aHltFilter->RegisterCellsWithType(VTK_QUAD);
2621 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
2622 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2623 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2624 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2625 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2626 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2629 if (myEntityMode & eVolumes) {
2630 aFilter->RegisterCellsWithType(VTK_TETRA);
2631 aFilter->RegisterCellsWithType(VTK_VOXEL);
2632 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2633 aFilter->RegisterCellsWithType(VTK_WEDGE);
2634 aFilter->RegisterCellsWithType(VTK_PYRAMID);
2635 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2636 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2637 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2638 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2639 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2640 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2641 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2642 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2643 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2644 aHltFilter->RegisterCellsWithType(VTK_TETRA);
2645 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
2646 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2647 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
2648 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
2649 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2650 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2651 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2652 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2653 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2654 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2655 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2656 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2657 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2660 if ( GetVisibility() )
2662 MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
2665 #ifndef DISABLE_PLOT2DVIEWER
2666 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2669 my2dHistogram->clearAllPoints();
2671 if(SMESH::Controls::NumericalFunctor* fun =
2672 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2675 if(!my2dHistogram) {
2676 my2dHistogram = new SPlot2d_Histogram();
2677 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2678 my2dHistogram->setIO(anIO);
2681 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2682 std::vector<int> nbEvents;
2683 std::vector<double> funValues;
2684 SMESH_VisualObjDef::TEntityList elems;
2685 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2686 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2687 std::vector<smIdType> elemIds;
2689 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2690 elemIds.push_back( (*e)->GetID());
2692 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2693 double * range = lookupTable->GetRange();
2694 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2695 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2697 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2698 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2700 if(funValues.size() >= 2)
2701 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2705 //Color of the histogram
2706 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2707 my2dHistogram->setAutoAssign(true);
2710 myScalarBarActor->GetDistributionColor(rgb);
2711 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2712 my2dHistogram->setColor(aColor);
2716 return my2dHistogram;