1 // Copyright (C) 2007-2024 CEA, EDF, 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 <vtkThreshold.h>
84 #include <vtkPassThrough.h>
86 #include "utilities.h"
89 SMESH_ActorDef* SMESH_ActorDef::New(){
90 return new SMESH_ActorDef();
94 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
99 SMESH_ActorDef* anActor = NULL;
100 if(theVisualObj->IsValid() ) {
101 anActor = SMESH_ActorDef::New();
102 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
107 anActor->UpdateScalarBar();
113 SMESH_ActorDef::SMESH_ActorDef()
115 MESSAGE("SMESH_ActorDef - "<<this);
117 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
119 myBaseActor = SMESH_DeviceActor::New();
121 myTimeStamp = vtkTimeStamp::New();
123 myIsPointsVisible = false;
124 myIsEntityModeCache = false;
125 myRepresentationCache = 0;
126 objectEntitiesCache = 0;
128 myHighlightActor = SMESH_SVTKActor::New();
129 myHighlightActor->Delete(); // vtkSmartPointer!
130 myHighlightActor->Initialize();
132 myPreHighlightActor = SMESH_SVTKActor::New();
133 myPreHighlightActor->Delete();
134 myPreHighlightActor->Initialize();
136 myIsShrinkable = false;
139 myIsFacesOriented = false;
141 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
142 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
144 myControlsPrecision = -1;
145 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
147 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
148 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
150 float aElem0DSize = (float) SMESH::GetFloat("SMESH:elem0d_size",5);
151 float aBallElemSize = (float) SMESH::GetFloat("SMESH:ball_elem_size",10);
152 float aBallElemScale = (float) SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
153 float aLineWidth = (float) SMESH::GetFloat("SMESH:element_width",1);
154 float aOutlineWidth = (float) SMESH::GetFloat("SMESH:outline_width",1);
156 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
158 bool anItalicNd = false;
159 bool aShadowNd = false;
161 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
162 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
163 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
164 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
165 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
167 anItalicNd = f.italic();
168 aShadowNd = f.overline();
169 aSizeNd = f.pointSize();
171 double anRGBNd[3] = {1,1,1};
172 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
174 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
176 bool anItalicEl = false;
177 bool aShadowEl = false;
179 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
180 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
181 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
182 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
183 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
185 anItalicEl = f.italic();
186 aShadowEl = f.overline();
187 aSizeEl = f.pointSize();
189 double anRGBEl[3] = {0,1,0};
190 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
192 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
193 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
195 //Definition 2D and 3D devices of the actor
196 //-----------------------------------------
197 double anRGB[3] = {1,1,1};
198 mySurfaceProp = vtkProperty::New();
201 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
202 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
203 myDeltaBrightness = delta;
205 myBackSurfaceProp = vtkProperty::New();
206 bfc = Qtx::mainColorToSecondary(ffc, delta);
207 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
209 myNormalVProp = vtkProperty::New();
210 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
211 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
212 myDeltaVBrightness = delta;
214 myReversedVProp = vtkProperty::New();
215 bfc = Qtx::mainColorToSecondary(ffc, delta);
216 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
218 my2DActor = SMESH_CellLabelActor::New();
219 my2DActor->SetStoreClippingMapping(true);
220 my2DActor->SetUserMatrix(aMatrix);
221 my2DActor->PickableOff();
222 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
223 my2DActor->SetProperty(mySurfaceProp);
224 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
225 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
226 aFilter = my2DActor->GetExtractUnstructuredGrid();
227 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
228 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
229 aFilter->RegisterCellsWithType(VTK_QUAD);
230 aFilter->RegisterCellsWithType(VTK_POLYGON);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
234 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
235 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
237 my2DExtProp = vtkProperty::New();
238 my2DExtProp->DeepCopy(mySurfaceProp);
239 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
240 anRGB[0] = 1 - anRGB[0];
241 anRGB[1] = 1 - anRGB[1];
242 anRGB[2] = 1 - anRGB[2];
243 my2DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
244 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
246 my2DExtActor = SMESH_DeviceActor::New();
247 my2DExtActor->SetUserMatrix(aMatrix);
248 my2DExtActor->PickableOff();
249 my2DExtActor->SetProperty(my2DExtProp);
250 my2DExtActor->SetBackfaceProperty(my2DExtProp);
251 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
252 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
253 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
254 aFilter->RegisterCellsWithType(VTK_QUAD);
255 aFilter->RegisterCellsWithType(VTK_POLYGON);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
257 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
258 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
259 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
260 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
262 my3DActor = SMESH_CellLabelActor::New();
263 my3DActor->SetStoreClippingMapping(true);
264 my3DActor->SetUserMatrix(aMatrix);
265 my3DActor->PickableOff();
266 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
267 my3DActor->SetProperty(myNormalVProp);
268 my3DActor->SetBackfaceProperty(myReversedVProp);
269 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
270 my3DActor->SetCoincident3DAllowed(true);
271 aFilter = my3DActor->GetExtractUnstructuredGrid();
272 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
273 aFilter->RegisterCellsWithType(VTK_TETRA);
274 aFilter->RegisterCellsWithType(VTK_VOXEL);
275 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
276 aFilter->RegisterCellsWithType(VTK_WEDGE);
277 aFilter->RegisterCellsWithType(VTK_PYRAMID);
278 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
281 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
282 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
283 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
284 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
285 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
286 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
288 my3DExtProp = vtkProperty::New();
289 my3DExtProp->DeepCopy(myNormalVProp);
290 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
291 anRGB[0] = 1 - anRGB[0];
292 anRGB[1] = 1 - anRGB[1];
293 anRGB[2] = 1 - anRGB[2];
294 my3DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
295 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
297 my3DExtActor = SMESH_DeviceActor::New();
298 my3DExtActor->SetUserMatrix(aMatrix);
299 my3DExtActor->PickableOff();
300 my3DExtActor->SetProperty(my3DExtProp);
301 my3DExtActor->SetBackfaceProperty(my3DExtProp);
302 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
303 my3DExtActor->SetCoincident3DAllowed(true);
304 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
305 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
306 aFilter->RegisterCellsWithType(VTK_TETRA);
307 aFilter->RegisterCellsWithType(VTK_VOXEL);
308 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
309 aFilter->RegisterCellsWithType(VTK_WEDGE);
310 aFilter->RegisterCellsWithType(VTK_PYRAMID);
311 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
314 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
315 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
316 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
317 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
318 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
319 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
321 //Definition 1D device of the actor
322 //---------------------------------
323 myEdgeProp = vtkProperty::New();
324 myEdgeProp->SetAmbient(1.0);
325 myEdgeProp->SetDiffuse(0.0);
326 myEdgeProp->SetSpecular(0.0);
327 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
328 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
329 myEdgeProp->SetLineWidth(aLineWidth);
331 // my1DActor is used to
333 // - show controls on all edges (eg Length)
334 // since edges are shown by myHighlitableActor
335 my1DActor = SMESH_CellLabelActor::New();
336 my1DActor->SetStoreClippingMapping(true);
337 my1DActor->SetUserMatrix(aMatrix);
338 my1DActor->PickableOff();
339 my1DActor->SetHighlited(true);
340 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
341 my1DActor->SetProperty(myEdgeProp);
342 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
343 aFilter = my1DActor->GetExtractUnstructuredGrid();
344 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
345 aFilter->RegisterCellsWithType(VTK_LINE);
346 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
348 my1DProp = vtkProperty::New();
349 my1DProp->DeepCopy(myEdgeProp);
350 my1DProp->SetLineWidth(aLineWidth + controlsIncrement);
351 my1DProp->SetPointSize(aElem0DSize);
353 my1DExtProp = vtkProperty::New();
354 my1DExtProp->DeepCopy(myEdgeProp);
355 anRGB[0] = 1 - anRGB[0];
356 anRGB[1] = 1 - anRGB[1];
357 anRGB[2] = 1 - anRGB[2];
358 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
359 my1DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
360 my1DExtProp->SetPointSize(aElem0DSize);
362 // my1DExtActor is used to show filtered edges or links between nodes
363 my1DExtActor = SMESH_DeviceActor::New();
364 my1DExtActor->SetUserMatrix(aMatrix);
365 my1DExtActor->PickableOff();
366 my1DExtActor->SetHighlited(true);
367 my1DExtActor->SetVisibility(false);
368 my1DExtActor->SetProperty(my1DExtProp);
369 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
370 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
371 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
372 aFilter->RegisterCellsWithType(VTK_LINE);
373 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
376 //Definition 0D device of the actor (0d elements)
377 //-----------------------------------------------
378 my0DProp = vtkProperty::New();
379 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
380 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
381 my0DProp->SetPointSize(aElem0DSize);
383 my0DActor = SMESH_CellLabelActor::New();
384 my0DActor->SetUserMatrix(aMatrix);
385 my0DActor->SetStoreClippingMapping(true);
386 my0DActor->PickableOff();
387 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
388 my0DActor->SetVisibility(false);
389 my0DActor->SetProperty(my0DProp);
390 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
391 aFilter = my0DActor->GetExtractUnstructuredGrid();
392 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
393 aFilter->RegisterCellsWithType(VTK_VERTEX);
395 //Definition 0D device of the actor (ball elements)
396 //-----------------------------------------------
397 myBallProp = vtkProperty::New();
398 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
399 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
400 myBallProp->SetPointSize(aBallElemSize);
402 myBallActor = SMESH_CellLabelActor::New();
403 myBallActor->SetUserMatrix(aMatrix);
404 myBallActor->SetStoreClippingMapping(true);
405 myBallActor->PickableOff();
406 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
407 myBallActor->SetVisibility(false);
408 myBallActor->SetProperty(myBallProp);
409 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
410 myBallActor->SetBallEnabled(true);
411 aFilter = myBallActor->GetExtractUnstructuredGrid();
412 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
413 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
415 //my0DExtProp = vtkProperty::New();
416 //my0DExtProp->DeepCopy(my0DProp);
417 //anRGB[0] = 1 - anRGB[0];
418 //anRGB[1] = 1 - anRGB[1];
419 //anRGB[2] = 1 - anRGB[2];
420 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
421 //my0DExtProp->SetPointSize(aElem0DSize);
423 //my0DExtActor = SMESH_DeviceActor::New();
424 //my0DExtActor->SetUserMatrix(aMatrix);
425 //my0DExtActor->SetStoreClippingMapping(true);
426 //my0DExtActor->PickableOff();
427 //my0DExtActor->SetHighlited(true);
428 //my0DExtActor->SetVisibility(false);
429 //my0DExtActor->SetProperty(my0DExtProp);
430 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
431 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
432 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
433 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
434 //aFilter->RegisterCellsWithType(VTK_VERTEX);
437 //Definition 0D device of the actor (nodes)
438 //-----------------------------------------
439 myNodeProp = vtkProperty::New();
440 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
441 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
443 myNodeActor = SMESH_NodeLabelActor::New();
444 myNodeActor->SetUserMatrix(aMatrix);
445 myNodeActor->SetStoreClippingMapping(true);
446 myNodeActor->PickableOff();
447 myNodeActor->SetVisibility(false);
448 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
449 myNodeActor->SetProperty(myNodeProp);
450 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
451 aFilter = myNodeActor->GetExtractUnstructuredGrid();
452 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
454 myNodeExtProp = vtkProperty::New();
455 myNodeExtProp->DeepCopy(myNodeProp);
456 anRGB[0] = 1 - anRGB[0];
457 anRGB[1] = 1 - anRGB[1];
458 anRGB[2] = 1 - anRGB[2];
459 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
461 myNodeExtActor = SMESH_DeviceActor::New();
462 myNodeExtActor->SetUserMatrix(aMatrix);
463 myNodeExtActor->SetStoreClippingMapping(true);
464 myNodeExtActor->PickableOff();
465 myNodeExtActor->SetHighlited(true);
466 myNodeExtActor->SetVisibility(false);
467 myNodeExtActor->SetProperty(myNodeExtProp);
468 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
469 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
470 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
471 aFilter->RegisterCellsWithType(VTK_VERTEX);
473 //Definition of Pickable and Highlitable engines
474 //----------------------------------------------
476 myBaseActor->SetUserMatrix(aMatrix);
477 myBaseActor->SetStoreIDMapping(true);
478 myBaseActor->SetStoreClippingMapping(true);
479 myBaseActor->SetStoreGemetryMapping(true);
480 myBaseActor->GetProperty()->SetOpacity(0.0);
481 myPickableActor = myBaseActor;
483 myHighlightProp = vtkProperty::New();
484 myHighlightProp->SetAmbient(1.0);
485 myHighlightProp->SetDiffuse(0.0);
486 myHighlightProp->SetSpecular(0.0);
487 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
488 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
489 myHighlightProp->SetPointSize(aElem0DSize); // ??
490 myHighlightProp->SetLineWidth(aLineWidth + selectionIncrement);
491 myHighlightProp->SetRepresentation(1);
493 myOutLineProp = vtkProperty::New();
494 myOutLineProp->SetAmbient(1.0);
495 myOutLineProp->SetDiffuse(0.0);
496 myOutLineProp->SetSpecular(0.0);
497 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
498 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
499 myOutLineProp->SetLineWidth(aOutlineWidth);
500 myOutLineProp->SetRepresentation(1);
502 myPreselectProp = vtkProperty::New();
503 myPreselectProp->SetAmbient(1.0);
504 myPreselectProp->SetDiffuse(0.0);
505 myPreselectProp->SetSpecular(0.0);
506 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
507 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
508 myPreselectProp->SetPointSize(aElem0DSize); // ??
509 myPreselectProp->SetLineWidth(aLineWidth + selectionIncrement);
510 myPreselectProp->SetRepresentation(1);
512 myHighlitableActor = SMESH_DeviceActor::New();
513 myHighlitableActor->SetUserMatrix(aMatrix);
514 myHighlitableActor->PickableOff();
515 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
516 myHighlitableActor->SetCoincident3DAllowed(true);
523 myControlMode = eNone;
524 myControlActor = my2DActor;
526 //Definition of myScalarBarActor
527 //------------------------------
528 myLookupTable = vtkLookupTable::New();
529 //Fix for Bug PAL5195 - SMESH764:
530 //Controls - Aspect Ratio: incorrect colors of the best and worst values
531 myLookupTable->SetHueRange(0.667,0.0);
533 myScalarBarActor = SMESH_ScalarBarActor::New();
534 myScalarBarActor->SetVisibility(false);
535 myScalarBarActor->SetLookupTable(myLookupTable);
538 //Incorrect "Min value" in Scalar Bar in Mesh:
539 // myScalarBarActor->SetLabelFormat("%.4g");
540 // changes was commented because of regression bug IPAL 19981
542 mgr = SUIT_Session::session()->resourceMgr();
546 myEntityMode = eAllEntity;
547 myEntityModeCache = eAllEntity;
550 myImplicitBoolean = vtkImplicitBoolean::New();
551 myImplicitBoolean->SetOperationTypeToIntersection();
553 myPlaneCollection = vtkPlaneCollection::New();
555 //Quadratic 2D elements representation
556 //-----------------------------------------------------------------------------
557 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
558 if(aQuadratic2DMode == 0){
559 myHighlitableActor->SetQuadraticArcMode(false);
560 my2DActor->SetQuadraticArcMode(false);
561 my1DActor->SetQuadraticArcMode(false);
563 else if(aQuadratic2DMode == 1){
564 myHighlitableActor->SetQuadraticArcMode(true);
565 my2DActor->SetQuadraticArcMode(true);
566 my1DActor->SetQuadraticArcMode(true);
569 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
570 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
571 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
573 // Set colors of the name actor
574 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
575 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
576 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
577 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
579 #ifndef DISABLE_PLOT2DVIEWER
583 SetBallSize(aBallElemSize);
584 SetBallScale(aBallElemScale);
585 Set0DSize(aElem0DSize);
589 SMESH_ActorDef::~SMESH_ActorDef()
591 MESSAGE("~SMESH_ActorDef - "<<this);
593 // Please keep the order same as one in the header file
595 myTimeStamp->Delete();
597 myScalarBarActor->Delete();
598 myLookupTable->Delete();
600 mySurfaceProp->Delete();
601 myBackSurfaceProp->Delete();
602 myNormalVProp->Delete();
603 myReversedVProp->Delete();
604 myEdgeProp->Delete();
605 myNodeProp->Delete();
607 myNodeActor->Delete();
608 myBaseActor->Delete();
609 //myPickableActor->Delete(); myPickableActor == myBaseActor
611 myHighlightProp->Delete();
612 myOutLineProp->Delete();
613 myPreselectProp->Delete();
615 myHighlitableActor->Delete();
617 my2DExtProp->Delete();
618 my3DExtProp->Delete();
620 my2DExtActor->Delete();
622 my3DExtActor->Delete();
623 // myControlActor->Delete(); myControlActor == my2DActor
625 myNodeExtProp->Delete();
626 myNodeExtActor->Delete();
630 my1DExtProp->Delete();
631 my1DExtActor->Delete();
635 myBallProp->Delete();
636 myBallActor->Delete();
637 //my0DExtProp->Delete();
638 //my0DExtActor->Delete();
640 myImplicitBoolean->Delete();
641 myPlaneCollection->Delete();
643 #ifndef DISABLE_PLOT2DVIEWER
645 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
646 delete my2dHistogram;
651 void SMESH_ActorDef::Delete()
653 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
654 // from the actor's destructor) will be thrown before removing the actor's observers,
655 // that is done inside the Superclass::Delete() method but before the destructor itself
656 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
657 // The event is caught by SMESHGUI::ProcessEvents() static method.
658 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
660 Superclass::Delete();
663 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
666 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
667 SetRepresentation(GetRepresentation());
668 myTimeStamp->Modified();
672 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
673 bool theBold, bool theItalic, bool theShadow,
674 double r, double g, double b )
677 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
678 SetRepresentation( GetRepresentation() );
679 myTimeStamp->Modified();
683 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
684 bool theBold, bool theItalic, bool theShadow,
685 double r, double g, double b )
688 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
691 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
692 SetRepresentation( GetRepresentation() );
693 myTimeStamp->Modified();
696 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
697 SetRepresentation( GetRepresentation() );
698 myTimeStamp->Modified();
701 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
702 SetRepresentation( GetRepresentation() );
703 myTimeStamp->Modified();
706 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
707 SetRepresentation( GetRepresentation() );
708 myTimeStamp->Modified();
712 bool SMESH_ActorDef::GetPointsLabeled()
714 return myNodeActor && myNodeActor->GetPointsLabeled();
717 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
720 my3DActor->SetCellsLabeled(theIsCellsLabeled);
723 my2DActor->SetCellsLabeled(theIsCellsLabeled);
726 my1DActor->SetCellsLabeled(theIsCellsLabeled);
729 my0DActor->SetCellsLabeled(theIsCellsLabeled);
732 myBallActor->SetCellsLabeled(theIsCellsLabeled);
734 SetRepresentation(GetRepresentation());
735 myTimeStamp->Modified();
739 bool SMESH_ActorDef::GetCellsLabeled()
743 result = result || my3DActor->GetCellsLabeled();
746 result = result || my2DActor->GetCellsLabeled();
749 result = result || my1DActor->GetCellsLabeled();
752 result = result || my0DActor->GetCellsLabeled();
755 result = result || myBallActor->GetCellsLabeled();
761 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
763 myIsFacesOriented = theIsFacesOriented;
765 my2DActor->SetFacesOriented(theIsFacesOriented);
766 my3DActor->SetFacesOriented(theIsFacesOriented);
768 myTimeStamp->Modified();
771 bool SMESH_ActorDef::GetFacesOriented()
773 return myIsFacesOriented;
776 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
778 my2DActor->SetFacesOrientationColor( r, g, b );
779 my3DActor->SetFacesOrientationColor( r, g, b );
782 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
784 my3DActor->GetFacesOrientationColor( r, g, b );
787 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
789 my2DActor->SetFacesOrientationScale( theScale );
790 my3DActor->SetFacesOrientationScale( theScale );
793 double SMESH_ActorDef::GetFacesOrientationScale()
795 return my3DActor->GetFacesOrientationScale();
798 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
800 my2DActor->SetFacesOrientation3DVectors( theState );
801 my3DActor->SetFacesOrientation3DVectors( theState );
804 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
806 return my3DActor->GetFacesOrientation3DVectors();
810 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
812 myFunctor = theFunctor;
814 SetControlMode( eNone, true );
816 SetControlMode( eCustomControl, true );
819 void SMESH_ActorDef::SetControlMode(eControl theMode)
821 SetControlMode(theMode,true);
824 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
826 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
827 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
828 lookupTable->SetScale(VTK_SCALE_LINEAR);
830 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
834 //myControlMode = eNone;
835 myControlMode = theMode;
836 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
838 my0DActor->GetMapper()->SetScalarVisibility(false);
839 my1DActor->GetMapper()->SetScalarVisibility(false);
840 my2DActor->GetMapper()->SetScalarVisibility(false);
841 my3DActor->GetMapper()->SetScalarVisibility(false);
842 myBallActor->GetMapper()->SetScalarVisibility(false);
843 myScalarBarActor->SetVisibility(false);
844 ClipThreshold(false);
845 SetWireframeOff(false);
847 bool anIsScalarVisible = theMode > eNone;
849 if(anIsScalarVisible) {
853 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
854 aControl->SetPrecision( myControlsPrecision );
855 myFunctor.reset( aControl );
856 myControlActor = my1DActor;
860 myFunctor.reset(new SMESH::Controls::Length2D());
861 myControlActor = my2DActor;
864 myFunctor.reset(new SMESH::Controls::FreeBorders());
865 myControlActor = my1DActor;
868 myFunctor.reset(new SMESH::Controls::FreeEdges());
869 myControlActor = my2DActor;
872 myFunctor.reset(new SMESH::Controls::FreeNodes());
873 myControlActor = myNodeActor;
876 myFunctor.reset(new SMESH::Controls::FreeFaces());
877 myControlActor = my2DActor;
879 case eCoincidentNodes:
881 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
882 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
883 cn->SetTolerance( tol );
885 myControlActor = myNodeActor;
888 case eCoincidentElems1D:
889 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
890 myControlActor = my1DActor;
892 case eCoincidentElems2D:
893 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
894 myControlActor = my2DActor;
896 case eCoincidentElems3D:
897 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
898 myControlActor = my3DActor;
900 case eBareBorderFace:
901 myFunctor.reset(new SMESH::Controls::BareBorderFace());
902 myControlActor = my2DActor;
904 case eOverConstrainedFace:
905 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
906 myControlActor = my2DActor;
908 case eMultiConnection:
909 myFunctor.reset(new SMESH::Controls::MultiConnection());
910 myControlActor = my1DActor;
912 case eMultiConnection2D:
913 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
914 myControlActor = my2DActor;
918 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
919 aControl->SetPrecision( myControlsPrecision );
920 myFunctor.reset( aControl );
921 myControlActor = my2DActor;
926 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
927 aControl->SetPrecision( myControlsPrecision );
928 myFunctor.reset( aControl );
929 myControlActor = my2DActor;
934 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
935 aControl->SetPrecision( myControlsPrecision );
936 myFunctor.reset( aControl );
937 myControlActor = my2DActor;
942 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
943 aControl->SetPrecision( myControlsPrecision );
944 myFunctor.reset( aControl );
945 myControlActor = my3DActor;
950 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
951 aControl->SetPrecision( myControlsPrecision );
952 myFunctor.reset( aControl );
953 myControlActor = my3DActor;
956 case eScaledJacobian:
958 SMESH::Controls::ScaledJacobian* aControl = new SMESH::Controls::ScaledJacobian();
959 aControl->SetPrecision( myControlsPrecision );
960 myFunctor.reset( aControl );
961 myControlActor = my3DActor;
964 case eMaxElementLength2D:
966 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
967 aControl->SetPrecision( myControlsPrecision );
968 myFunctor.reset( aControl );
969 myControlActor = my2DActor;
972 case eMaxElementLength3D:
974 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
975 aControl->SetPrecision( myControlsPrecision );
976 myFunctor.reset( aControl );
977 myControlActor = my3DActor;
982 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
983 aControl->SetPrecision( myControlsPrecision );
984 myFunctor.reset( aControl );
985 myControlActor = my2DActor;
988 case eBareBorderVolume:
990 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
991 myControlActor = my3DActor;
994 case eOverConstrainedVolume:
996 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
997 myControlActor = my3DActor;
1002 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
1003 aControl->SetPrecision( myControlsPrecision );
1004 myFunctor.reset( aControl );
1005 myControlActor = my2DActor;
1010 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
1011 aControl->SetPrecision( myControlsPrecision );
1012 myFunctor.reset( aControl );
1013 myControlActor = my2DActor;
1018 SMESH::Controls::Warping3D* aControl = new SMESH::Controls::Warping3D();
1019 aControl->SetPrecision(myControlsPrecision);
1020 myFunctor.reset(aControl);
1021 myControlActor = my3DActor;
1026 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1027 aControl->SetPrecision( myControlsPrecision );
1028 myFunctor.reset( aControl );
1029 myControlActor = my2DActor;
1032 case eNodeConnectivityNb:
1034 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1035 myControlActor = myNodeActor;
1038 case eCustomControl:
1042 switch ( myFunctor->GetType() ) {
1043 case SMDSAbs_Node : myControlActor = myNodeActor; break;
1044 case SMDSAbs_Edge : myControlActor = my1DActor; break;
1045 case SMDSAbs_Face : myControlActor = my2DActor; break;
1046 case SMDSAbs_Volume : myControlActor = my3DActor; break;
1055 smIdType aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1056 bool aShowOnlyScalarBarTitle = false;
1058 //myControlMode = theMode;
1059 switch(myControlMode){
1061 case eCoincidentNodes:
1062 myNodeExtActor->SetExtControlMode(myFunctor);
1063 aShowOnlyScalarBarTitle = true;
1067 case eCoincidentElems1D:
1068 my1DExtActor->SetExtControlMode(myFunctor);
1069 aShowOnlyScalarBarTitle = true;
1072 case eBareBorderFace:
1073 case eOverConstrainedFace:
1074 case eCoincidentElems2D:
1075 my2DExtActor->SetExtControlMode(myFunctor);
1076 aShowOnlyScalarBarTitle = true;
1078 case eBareBorderVolume:
1079 case eOverConstrainedVolume:
1080 case eCoincidentElems3D:
1081 my3DExtActor->SetExtControlMode(myFunctor);
1082 aShowOnlyScalarBarTitle = true;
1085 case eMultiConnection2D:
1086 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1087 UpdateDistribution();
1090 my2DExtActor->SetExtControlMode(myFunctor, myScalarBarActor, myLookupTable);
1091 UpdateDistribution();
1094 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1095 UpdateDistribution();
1097 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1100 if(theCheckEntityMode) {
1101 // if(myControlActor == myNodeActor) {
1102 // if ( myControlMode == eNodeConnectivityNb ) {
1103 // if (!myIsEntityModeCache){
1104 // myEntityModeCache = GetEntityMode();
1105 // myIsEntityModeCache=true;
1107 // SetEntityMode(0);
1110 if(myControlActor == my1DActor) {
1111 if (!myIsEntityModeCache){
1112 myEntityModeCache = GetEntityMode();
1113 myIsEntityModeCache=true;
1115 SetEntityMode(eEdges);
1117 else if(myControlActor == my2DActor) {
1118 if (!myIsEntityModeCache){
1119 myEntityModeCache = GetEntityMode();
1120 myIsEntityModeCache=true;
1122 SetEntityMode(eFaces);
1124 else if(myControlActor == my3DActor) {
1125 if (!myIsEntityModeCache){
1126 myEntityModeCache = GetEntityMode();
1127 myIsEntityModeCache=true;
1129 SetEntityMode(eVolumes);
1132 QString aTitle = QString(myScalarBarActor->GetTitle());
1133 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1134 myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
1137 if(theCheckEntityMode){
1138 myEntityMode = myEntityModeCache;
1139 myIsEntityModeCache = false;
1144 SetRepresentation(GetRepresentation());
1146 myTimeStamp->Modified();
1149 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1150 double * range = lookupTable->GetRange();
1152 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1153 lookupTable->SetScale(VTK_SCALE_LOG10);
1158 smIdType SMESH_ActorDef::GetNumberControlEntities()
1160 SMESH_DeviceActor* anAct = NULL;
1161 switch(myControlMode){
1163 case eCoincidentNodes:
1164 anAct = myNodeExtActor;
1168 case eCoincidentElems1D:
1169 anAct = my1DExtActor;
1172 case eBareBorderFace:
1173 case eOverConstrainedFace:
1174 case eCoincidentElems2D:
1175 anAct = my2DExtActor;
1177 case eBareBorderVolume:
1178 case eOverConstrainedVolume:
1179 case eCoincidentElems3D:
1180 anAct = my3DExtActor;
1184 return anAct ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1187 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1189 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1191 myBaseActor->SetUnstructuredGrid( NULL );
1192 //myHighlitableActor->SetUnstructuredGrid( NULL );
1194 theRenderer->AddActor(myBaseActor);
1195 theRenderer->AddActor(myNodeExtActor);
1196 theRenderer->AddActor(my1DExtActor);
1198 my3DActor ->AddToRender(theRenderer);
1199 my3DExtActor->AddToRender(theRenderer);
1200 my2DActor ->AddToRender(theRenderer);
1201 my2DExtActor->AddToRender(theRenderer);
1202 myNodeActor ->AddToRender(theRenderer);
1203 my1DActor ->AddToRender(theRenderer);
1204 my0DActor ->AddToRender(theRenderer);
1205 myBallActor ->AddToRender(theRenderer);
1207 theRenderer->AddActor(myHighlitableActor);
1209 theRenderer->AddActor2D(myScalarBarActor);
1211 // the superclass' method should be called at the end
1212 // (in particular, for correct work of selection)
1213 SALOME_Actor::AddToRender(theRenderer);
1216 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1218 SALOME_Actor::RemoveFromRender(theRenderer);
1220 theRenderer->RemoveActor(myBaseActor);
1222 theRenderer->RemoveActor(myNodeExtActor);
1224 theRenderer->RemoveActor(myHighlitableActor);
1226 //theRenderer->RemoveActor(my0DExtActor);
1228 theRenderer->RemoveActor(my1DExtActor);
1230 my2DActor->RemoveFromRender(theRenderer);
1231 my2DExtActor->RemoveFromRender(theRenderer);
1232 my3DActor->RemoveFromRender(theRenderer);
1233 my3DExtActor->RemoveFromRender(theRenderer);
1234 myNodeActor->RemoveFromRender(theRenderer);
1235 my0DActor->RemoveFromRender(theRenderer);
1236 myBallActor->RemoveFromRender(theRenderer);
1237 my1DActor->RemoveFromRender(theRenderer);
1239 theRenderer->RemoveActor(myScalarBarActor);
1243 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1244 const char* theEntry,
1245 const char* theName,
1248 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1252 myVisualObj = theVisualObj;
1253 myVisualObj->Update(theIsClear);
1255 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1256 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1258 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1259 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1261 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1263 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1265 my0DActor->Init(myVisualObj,myImplicitBoolean);
1266 myBallActor->Init(myVisualObj,myImplicitBoolean);
1267 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1269 my1DActor->Init(myVisualObj,myImplicitBoolean);
1270 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1272 my2DActor->Init(myVisualObj,myImplicitBoolean);
1273 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1274 my3DActor->Init(myVisualObj,myImplicitBoolean);
1275 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1277 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1278 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1279 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1281 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1282 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1284 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1285 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1286 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1287 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1289 double aFactor, aUnits;
1290 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1291 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1292 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1293 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1295 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1299 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1300 SetIsShrunkable(true);
1302 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1304 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1305 SetRepresentation(-1);
1308 SetRepresentation(eEdge);
1309 }else if(aMode == 1){
1310 SetRepresentation(eSurface);
1311 }else if(aMode == 2){
1312 SetRepresentation(ePoint);
1319 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1320 SetIsDisplayNameActor( true );
1322 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1323 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1324 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1326 myTimeStamp->Modified();
1332 double* SMESH_ActorDef::GetBounds()
1334 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1335 return myNodeActor->GetBounds();
1336 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1340 vtkDataSet* SMESH_ActorDef::GetInput()
1342 return GetUnstructuredGrid();
1346 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1348 Superclass::SetTransform(theTransform);
1350 myNodeActor->SetTransform(theTransform);
1351 myBaseActor->SetTransform(theTransform);
1353 myHighlitableActor->SetTransform(theTransform);
1355 myNodeExtActor->SetTransform(theTransform);
1357 my0DActor->SetTransform(theTransform);
1358 myBallActor->SetTransform(theTransform);
1359 //my0DExtActor->SetTransform(theTransform);
1361 my1DActor->SetTransform(theTransform);
1362 my1DExtActor->SetTransform(theTransform);
1364 my2DActor->SetTransform(theTransform);
1365 my2DExtActor->SetTransform(theTransform);
1366 my3DActor->SetTransform(theTransform);
1367 my3DExtActor->SetTransform(theTransform);
1373 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1375 vtkLODActor::SetMapper(theMapper);
1379 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1381 SALOME_Actor::ShallowCopy(prop);
1385 vtkMapper* SMESH_ActorDef::GetMapper()
1387 return myPickableActor->GetMapper();
1391 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1393 return myVisualObj->GetUnstructuredGrid();
1397 bool SMESH_ActorDef::IsInfinitive()
1399 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1400 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1401 ( aDataSet->GetNumberOfCells() == 1 &&
1402 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1403 return SALOME_Actor::IsInfinitive();
1407 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1409 if ( myIsShrinkable == theShrunkable )
1411 myIsShrinkable = theShrunkable;
1415 double SMESH_ActorDef::GetShrinkFactor()
1417 return myBaseActor->GetShrinkFactor();
1420 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1422 myBaseActor->SetShrinkFactor(theValue);
1424 my1DActor->SetShrinkFactor(theValue);
1425 my1DExtActor->SetShrinkFactor(theValue);
1427 my2DActor->SetShrinkFactor(theValue);
1428 my2DExtActor->SetShrinkFactor(theValue);
1429 my3DActor->SetShrinkFactor(theValue);
1430 my3DExtActor->SetShrinkFactor(theValue);
1431 my3DExtActor->SetShrinkFactor(theValue);
1432 myHighlitableActor->SetShrinkFactor(theValue);
1437 void SMESH_ActorDef::SetShrink()
1439 if(!myIsShrinkable) return;
1441 myBaseActor->SetShrink();
1443 my1DActor->SetShrink();
1444 my1DExtActor->SetShrink();
1446 my2DActor->SetShrink();
1447 my2DExtActor->SetShrink();
1448 my3DActor->SetShrink();
1449 my3DExtActor->SetShrink();
1450 myHighlitableActor->SetShrink();
1456 void SMESH_ActorDef::UnShrink()
1458 if(!myIsShrunk) return;
1460 myBaseActor->UnShrink();
1462 my1DActor->UnShrink();
1463 my1DExtActor->UnShrink();
1465 my2DActor->UnShrink();
1466 my2DExtActor->UnShrink();
1467 my3DActor->UnShrink();
1468 my3DExtActor->UnShrink();
1469 myHighlitableActor->UnShrink();
1476 vtkIdType SMESH_ActorDef::GetNodeObjId(vtkIdType theVtkID)
1478 return myPickableActor->GetNodeObjId(theVtkID);
1481 double* SMESH_ActorDef::GetNodeCoord(vtkIdType theObjID)
1483 return myPickableActor->GetNodeCoord(theObjID);
1486 vtkIdType SMESH_ActorDef::GetNodeVtkId(vtkIdType theObjID)
1488 return myPickableActor->GetNodeVtkId(theObjID);
1491 vtkIdType SMESH_ActorDef::GetElemObjId(vtkIdType theVtkID)
1493 return myPickableActor->GetElemObjId(theVtkID);
1496 vtkCell* SMESH_ActorDef::GetElemCell(vtkIdType theObjID)
1498 return myPickableActor->GetElemCell(theObjID);
1502 void SMESH_ActorDef::SetVisibility(int theMode)
1504 SetVisibility(theMode,true);
1508 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1510 SALOME_Actor::SetVisibility(theMode);
1512 myNodeActor->VisibilityOff();
1513 myBaseActor->VisibilityOff();
1515 myNodeExtActor->VisibilityOff();
1517 my0DActor->VisibilityOff();
1518 myBallActor->VisibilityOff();
1519 //my0DExtActor->VisibilityOff();
1521 my1DActor->VisibilityOff();
1522 my1DExtActor->VisibilityOff();
1524 my2DActor->VisibilityOff();
1525 my2DExtActor->VisibilityOff();
1526 my3DActor->VisibilityOff();
1527 my3DExtActor->VisibilityOff();
1529 myScalarBarActor->VisibilityOff();
1532 if ( GetVisibility() ) {
1533 if ( theIsUpdateRepersentation )
1534 SetRepresentation(GetRepresentation());
1536 // Avoid calling VisibilityOn of ExtActor after editing hypothesis. Use the same criteria than scalarBarActor
1537 if( myControlMode != eNone && myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ) ) {
1538 switch(myControlMode) {
1540 case eCoincidentNodes:
1541 myNodeExtActor->VisibilityOn();
1544 case eMultiConnection:
1545 my1DActor->VisibilityOn();
1549 case eCoincidentElems1D:
1551 case eMultiConnection2D:
1552 my1DExtActor->VisibilityOn();
1555 case eBareBorderFace:
1556 case eOverConstrainedFace:
1557 case eCoincidentElems2D:
1559 my2DExtActor->VisibilityOn();
1561 case eBareBorderVolume:
1562 case eOverConstrainedVolume:
1563 case eCoincidentElems3D:
1564 my3DExtActor->VisibilityOn();
1568 myScalarBarActor->VisibilityOn();
1571 if ( GetPickable( ))
1572 myPickableActor->VisibilityOn();
1574 if ( GetRepresentation() != ePoint &&
1575 !(IsClipThresholdOn() && GetActorForThreshold() != myControlActor)) // Avoid calling VisibilityOn if for display result of Threshold Criteria need only ExtActor
1577 if(myEntityMode & e0DElements ){
1578 my0DActor->VisibilityOn();
1580 if(myEntityMode & eBallElem ){
1581 myBallActor->VisibilityOn();
1583 if(myEntityMode & eEdges && ( GetCellsLabeled() || // my1DActor shows labels only
1584 ( myControlActor == my1DActor && myControlMode != eNone ))){
1585 my1DActor->VisibilityOn();
1587 if(myEntityMode & eFaces ){
1588 my2DActor->VisibilityOn();
1590 if(myEntityMode & eVolumes ){
1591 my3DActor->VisibilityOn();
1595 if(myNodeActor->GetPointsLabeled()) {
1596 myNodeActor->UpdateLabels();
1597 myNodeActor->VisibilityOn();
1600 my0DActor->UpdateLabels();
1603 myBallActor->UpdateLabels();
1606 my1DActor->UpdateLabels();
1609 my2DActor->UpdateLabels();
1612 my3DActor->UpdateLabels();
1614 #ifndef DISABLE_PLOT2DVIEWER
1616 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1623 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1625 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1627 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1628 anObjectEntities &= ~e0DElements;
1629 theMode &= ~e0DElements;
1632 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1633 anObjectEntities &= ~eBallElem;
1634 theMode &= ~eBallElem;
1637 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1638 anObjectEntities &= ~eEdges;
1642 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1643 anObjectEntities &= ~eFaces;
1647 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1648 anObjectEntities &= ~eVolumes;
1649 theMode &= ~eVolumes;
1653 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1654 theMode |= e0DElements;
1656 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1657 theMode |= eBallElem;
1659 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1662 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1665 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1666 theMode |= eVolumes;
1669 // rnv : Fix volume selection on Display Entity
1670 //myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1672 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1674 myRepresentationCache = GetRepresentation();
1675 SetRepresentation( ePoint );
1678 if ( anObjectEntities != 0 && objectEntitiesCache == 0 )
1680 objectEntitiesCache = anObjectEntities;
1681 SetRepresentation( eSurface );
1684 if ( myEntityMode != theMode )
1686 myEntityMode = theMode; // entities to show
1688 // Set cell types to extract
1692 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1695 void SMESH_ActorDef::SetRepresentation (int theMode)
1697 smIdType aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1698 smIdType aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1699 smIdType aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1700 smIdType aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1701 smIdType aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1703 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1705 theMode = myRepresentationCache;
1706 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1709 myRepresentationCache = 0;
1713 myRepresentation = eSurface;
1714 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1715 myRepresentation = eEdge;
1716 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1717 myRepresentation = ePoint;
1722 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1725 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1728 myRepresentation = theMode;
1731 if (!GetUnstructuredGrid()->GetNumberOfCells())
1732 myRepresentation = ePoint;
1735 if (myRepresentation == ePoint) {
1743 myPickableActor = myBaseActor;
1744 vtkProperty *aProp = NULL, *aBackProp = NULL;
1745 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1746 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::eNoneRepr;
1747 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1748 switch (myRepresentation) {
1750 myPickableActor = myNodeActor;
1751 aQuadraticMode = SMESH_Actor::eLines;
1752 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1753 aReperesent = SMESH_DeviceActor::ePoint;
1756 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1757 aReperesent = SMESH_DeviceActor::eInsideframe;
1760 aProp = mySurfaceProp;
1761 aBackProp = myBackSurfaceProp;
1762 aPropVN = myNormalVProp;
1763 aPropVR = myReversedVProp;
1764 aReperesent = SMESH_DeviceActor::eSurface;
1768 if ( myRepresentation != ePoint )
1770 my2DActor->SetProperty(aProp);
1771 my2DActor->SetBackfaceProperty(aBackProp);
1772 my2DActor->SetRepresentation(aReperesent);
1774 if(aQuadraticMode == SMESH_Actor::eLines)
1775 my2DActor->SetQuadraticArcMode(false);
1776 else if(aQuadraticMode == SMESH_Actor::eArcs)
1777 my2DActor->SetQuadraticArcMode(true);
1779 my2DExtActor->SetRepresentation(aReperesent);
1781 my3DActor->SetProperty(aPropVN);
1782 my3DActor->SetBackfaceProperty(aPropVR);
1783 my3DActor->SetRepresentation(aReperesent);
1785 my0DActor->SetRepresentation(aReperesent);
1786 myBallActor->SetRepresentation(aReperesent);
1788 switch ( myControlMode ) {
1790 case eMultiConnection:
1791 aProp = aBackProp = my1DProp;
1792 if ( myRepresentation != ePoint )
1793 aReperesent = SMESH_DeviceActor::eInsideframe;
1795 case eCustomControl:
1796 if ( myControlActor == my1DActor )
1797 aProp = aBackProp = my1DProp;
1798 if ( myRepresentation != ePoint )
1799 aReperesent = SMESH_DeviceActor::eInsideframe;
1804 if(aQuadraticMode == SMESH_Actor::eLines)
1805 my1DActor->SetQuadraticArcMode(false);
1806 else if(aQuadraticMode == SMESH_Actor::eArcs)
1807 my1DActor->SetQuadraticArcMode(true);
1809 my1DActor->SetProperty(aProp);
1810 my1DActor->SetBackfaceProperty(aBackProp);
1811 my1DActor->SetRepresentation(aReperesent);
1813 my1DExtActor->SetRepresentation(aReperesent);
1816 if(myIsPointsVisible)
1817 myPickableActor = myNodeActor;
1819 SetMapper(myPickableActor->GetMapper());
1821 SetVisibility(GetVisibility(),false);
1827 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1829 if ( myIsPointsVisible == theIsPointsVisible )
1831 myIsPointsVisible = theIsPointsVisible;
1832 SetRepresentation(GetRepresentation());
1835 bool SMESH_ActorDef::GetPointRepresentation()
1837 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1841 void SMESH_ActorDef::UpdateHighlight()
1843 myHighlitableActor->SetHighlited(false);
1844 myHighlitableActor->SetVisibility(false);
1845 bool anIsVisible = GetVisibility();
1847 switch(myRepresentation){
1848 case SMESH_DeviceActor::eSurface:
1849 case SMESH_DeviceActor::eWireframe:
1851 anIsVisible = anIsVisible && !IsWireframeOff();
1853 if(myIsHighlighted) {
1854 myHighlitableActor->SetProperty(myHighlightProp);
1855 }else if(myIsPreselected){
1856 myHighlitableActor->SetProperty(myPreselectProp);
1857 } else if(anIsVisible){
1858 (myRepresentation == eSurface) ?
1859 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1861 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1862 myHighlitableActor->SetHighlited(anIsVisible);
1863 myHighlitableActor->GetExtractUnstructuredGrid()->
1864 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1865 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1867 myHighlitableActor->SetVisibility(anIsVisible);
1870 case SMESH_DeviceActor::ePoint:
1872 if(myIsHighlighted) {
1873 myNodeActor->SetProperty(myHighlightProp);
1874 }else if(myIsPreselected) {
1875 myNodeActor->SetProperty(myPreselectProp);
1876 } else if(anIsVisible) {
1877 myNodeActor->SetProperty(myNodeProp);
1879 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1880 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1881 myNodeActor->GetProperty()->Modified();
1887 void SMESH_ActorDef::EnableSelection( bool enable )
1889 // selection in the Viewer enabled/disabled
1890 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1892 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1893 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1894 myBaseActor->myExtractUnstructuredGrid->Update();
1895 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1897 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1899 myBaseActor->SetUnstructuredGrid( NULL );
1900 //myHighlitableActor->SetUnstructuredGrid( NULL );
1901 myBaseActor->myExtractUnstructuredGrid->Update();
1902 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1906 void SMESH_ActorDef::highlight(bool theHighlight)
1908 if ( myIsHighlighted == theHighlight )
1910 myIsHighlighted = theHighlight;
1915 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1917 if ( myIsPreselected == thePreselect )
1919 myIsPreselected = thePreselect;
1925 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1927 if (myPickableActor->GetIsOpaque())
1929 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1937 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1939 if (!myPickableActor->GetIsOpaque())
1941 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1949 void SMESH_ActorDef::Render(vtkRenderer* /*ren*/)
1951 vtkMTimeType aTime = myTimeStamp->GetMTime();
1952 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1953 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1954 if(anObjTime > aTime || aClippingTime > aTime)
1959 void SMESH_ActorDef::Update()
1961 MESSAGE("SMESH_ActorDef::Update");
1963 myVisualObj->Update();
1965 if(GetControlMode() != eNone) {
1966 unsigned long aTime = myTimeStamp->GetMTime();
1967 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1968 if (anObjTime > aTime)
1969 SetControlMode(GetControlMode(),false);
1973 myNodeActor->UpdateLabels();
1976 my0DActor->UpdateLabels();
1979 myBallActor->UpdateLabels();
1982 my1DActor->UpdateLabels();
1985 my2DActor->UpdateLabels();
1988 my3DActor->UpdateLabels();
1990 if(myIsFacesOriented){
1991 SetFacesOriented(myIsFacesOriented);
1994 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
1995 // myEntityMode |= myVisualObj->GetEntitiesState();
1998 SetEntityMode(GetEntityMode());
1999 SetVisibility(GetVisibility());
2001 myTimeStamp->Modified();
2006 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2008 SALOME_Actor::ReleaseGraphicsResources(renWin);
2010 myPickableActor->ReleaseGraphicsResources(renWin);
2014 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2016 double* aColor = theProperty->GetColor();
2023 void SMESH_ActorDef::SetOpacity(double theValue)
2025 mySurfaceProp->SetOpacity(theValue);
2026 myBackSurfaceProp->SetOpacity(theValue);
2027 myNormalVProp->SetOpacity(theValue);
2028 myReversedVProp->SetOpacity(theValue);
2029 myEdgeProp->SetOpacity(theValue);
2030 myOutLineProp->SetOpacity(theValue);
2031 myNodeProp->SetOpacity(theValue);
2033 my1DProp->SetOpacity(theValue);
2034 my0DProp->SetOpacity(theValue);
2035 myBallProp->SetOpacity(theValue);
2039 double SMESH_ActorDef::GetOpacity()
2041 return mySurfaceProp->GetOpacity();
2045 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2047 mySurfaceProp->SetColor(r,g,b);
2048 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2049 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2050 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2051 myNameActor->SetBackgroundColor(r,g,b);
2053 myDeltaBrightness = delta;
2054 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2055 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2059 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2061 ::GetColor(mySurfaceProp,r,g,b);
2062 delta = myDeltaBrightness;
2065 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2067 myNormalVProp->SetColor(r,g,b);
2068 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2069 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2070 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2071 myNameActor->SetBackgroundColor(r,g,b);
2073 myDeltaVBrightness = delta;
2074 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2075 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2079 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2081 ::GetColor(myNormalVProp,r,g,b);
2082 delta = myDeltaVBrightness;
2085 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2087 myEdgeProp->SetColor(r,g,b);
2088 my1DProp->SetColor(r,g,b);
2089 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2090 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2091 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2092 myNameActor->SetBackgroundColor(r,g,b);
2096 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2098 ::GetColor(myEdgeProp,r,g,b);
2101 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2103 myOutLineProp->SetColor(r,g,b);
2107 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2109 ::GetColor(myOutLineProp,r,g,b);
2113 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2115 myNodeProp->SetColor(r,g,b);
2116 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2117 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2118 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2119 myNameActor->SetBackgroundColor(r,g,b);
2123 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2125 ::GetColor(myNodeProp,r,g,b);
2128 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2130 my0DProp->SetColor(r,g,b);
2131 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2132 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2133 myNameActor->SetBackgroundColor(r,g,b);
2137 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2139 ::GetColor(my0DProp,r,g,b);
2142 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2144 myBallProp->SetColor(r,g,b);
2145 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2146 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2147 myNameActor->SetBackgroundColor(r,g,b);
2151 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2153 ::GetColor(myBallProp,r,g,b);
2156 void SMESH_ActorDef::UpdateSelectionProps()
2158 QColor selectionColor = SMESH_ActorProps::props()->selectionColor();
2159 QColor highlightColor = SMESH_ActorProps::props()->highlightColor();
2160 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2161 float width = (float) GetLineWidth();
2162 myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF());
2163 myHighlightProp->SetLineWidth(width + selectionIncrement);
2164 myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF());
2165 myPreselectProp->SetLineWidth(width + selectionIncrement);
2169 double SMESH_ActorDef::GetLineWidth()
2171 return myEdgeProp->GetLineWidth();
2175 void SMESH_ActorDef::SetLineWidth(double theVal)
2177 float controlsIncrement = (float) SMESH_ActorProps::props()->controlsIncrement();
2178 float selectionIncrement = (float) SMESH_ActorProps::props()->selectionIncrement();
2180 myEdgeProp->SetLineWidth((float) theVal);
2182 my1DProp ->SetLineWidth((float) theVal + controlsIncrement);
2183 my1DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2184 my2DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2185 my3DExtProp ->SetLineWidth((float) theVal + controlsIncrement);
2186 myHighlightProp->SetLineWidth((float) theVal + selectionIncrement);
2187 myPreselectProp->SetLineWidth((float) theVal + selectionIncrement);
2191 double SMESH_ActorDef::GetOutlineWidth()
2193 return myOutLineProp->GetLineWidth();
2196 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2198 myOutLineProp->SetLineWidth((float) theVal);
2202 void SMESH_ActorDef::Set0DSize(double theVal)
2204 my0DProp ->SetPointSize((float) theVal);
2205 myHighlightProp->SetPointSize((float) theVal);
2206 myPreselectProp->SetPointSize((float) theVal);
2208 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2209 aCustom->Set0DSize((float) theVal);
2211 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2212 aCustom->Set0DSize((float) theVal);
2218 double SMESH_ActorDef::Get0DSize()
2220 return my0DProp->GetPointSize();
2223 void SMESH_ActorDef::SetBallSize(double theVal)
2225 myBallProp->SetPointSize((float) theVal);
2227 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2228 aCustom->SetBallSize((float) theVal);
2230 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2231 aCustom->SetBallSize((float) theVal);
2237 double SMESH_ActorDef::GetBallSize()
2239 return myBallProp->GetPointSize();
2242 double SMESH_ActorDef::GetBallScale()
2244 return myBallActor->GetBallScale();
2247 void SMESH_ActorDef::SetBallScale( double theVal )
2249 myBallActor->SetBallScale( theVal );
2250 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2251 aCustom->SetBallScale(theVal);
2253 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2254 aCustom->SetBallScale(theVal);
2260 int SMESH_ActorDef::GetObjDimension( const vtkIdType theObjId )
2262 return myVisualObj->GetElemDimension( theObjId );
2265 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2267 return myBaseActor->IsImplicitFunctionUsed();
2270 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2272 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2273 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2275 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2277 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2279 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2280 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2281 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2283 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2284 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2286 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2287 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2288 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2289 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2292 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2295 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2296 myCippingPlaneCont.push_back(thePlane);
2297 if(!IsImplicitFunctionUsed())
2298 SetImplicitFunctionUsed(true);
2299 myNodeActor->UpdateLabels();
2301 return myCippingPlaneCont.size();
2304 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2307 myPlaneCollection->AddItem( thePlane );
2310 void SMESH_ActorDef::SetOpenGLClippingPlane()
2312 // before use this method you must add clipping planes using method
2313 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2314 if( !myPlaneCollection->GetNumberOfItems() )
2317 // It is necessary to set plane collection for each mapper of actor
2318 // and update current inputs of mapper
2319 myNodeActor->SetPlaneCollection( myPlaneCollection );
2320 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2322 myBaseActor->SetPlaneCollection( myPlaneCollection );
2323 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2325 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2326 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2328 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2330 myBaseActor->SetUnstructuredGrid( NULL );
2331 //myHighlitableActor->SetUnstructuredGrid( NULL );
2333 my1DActor->SetPlaneCollection( myPlaneCollection );
2334 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2336 my2DActor->SetPlaneCollection( myPlaneCollection );
2337 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2339 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2340 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2342 my0DActor->SetPlaneCollection( myPlaneCollection );
2343 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2345 myBallActor->SetPlaneCollection( myPlaneCollection );
2346 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2348 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2349 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2351 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2352 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2354 my3DActor->SetPlaneCollection( myPlaneCollection );
2355 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2357 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2358 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2366 void SMESH_ActorDef::RemoveAllClippingPlanes()
2368 myPlaneCollection->RemoveAllItems();
2369 myImplicitBoolean->GetFunction()->RemoveAllItems();
2370 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2371 myCippingPlaneCont.clear();
2372 SetImplicitFunctionUsed(false);
2373 myNodeActor->UpdateLabels();
2376 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2378 return myCippingPlaneCont.size();
2381 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2383 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2385 return myCippingPlaneCont[theID].Get();
2388 void SMESH_ActorDef::UpdateScalarBar()
2390 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2394 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2396 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2397 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2399 aScalarBarTitleProp->SetFontFamilyToArial();
2401 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2403 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2404 if ( f.family() == "Arial" )
2405 aScalarBarTitleProp->SetFontFamilyToArial();
2406 else if ( f.family() == "Courier" )
2407 aScalarBarTitleProp->SetFontFamilyToCourier();
2408 else if ( f.family() == "Times" )
2409 aScalarBarTitleProp->SetFontFamilyToTimes();
2412 aScalarBarTitleProp->BoldOn();
2414 aScalarBarTitleProp->BoldOff();
2417 aScalarBarTitleProp->ItalicOn();
2419 aScalarBarTitleProp->ItalicOff();
2422 aScalarBarTitleProp->ShadowOn();
2424 aScalarBarTitleProp->ShadowOff();
2427 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2428 aScalarBarTitleProp->Delete();
2430 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2432 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2433 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2435 aScalarBarLabelProp->SetFontFamilyToArial();
2436 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2438 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2439 if( f.family() == "Arial" )
2440 aScalarBarLabelProp->SetFontFamilyToArial();
2441 else if( f.family() == "Courier" )
2442 aScalarBarLabelProp->SetFontFamilyToCourier();
2443 else if( f.family() == "Times" )
2444 aScalarBarLabelProp->SetFontFamilyToTimes();
2447 aScalarBarLabelProp->BoldOn();
2449 aScalarBarLabelProp->BoldOff();
2452 aScalarBarLabelProp->ItalicOn();
2454 aScalarBarLabelProp->ItalicOff();
2457 aScalarBarLabelProp->ShadowOn();
2459 aScalarBarLabelProp->ShadowOff();
2462 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2463 aScalarBarLabelProp->Delete();
2465 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2466 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2468 myScalarBarActor->SetOrientationToHorizontal();
2470 myScalarBarActor->SetOrientationToVertical();
2473 double aXVal = horiz ? 0.20 : 0.01;
2474 if( mgr->hasValue( "SMESH", name + "x" ) )
2475 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2477 double aYVal = horiz ? 0.01 : 0.1;
2478 if( mgr->hasValue( "SMESH", name + "y" ) )
2479 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2480 myScalarBarActor->SetPosition( aXVal, aYVal );
2482 double aWVal = horiz ? 0.60 : 0.10;
2483 if( mgr->hasValue( "SMESH", name + "width" ) )
2484 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2485 myScalarBarActor->SetWidth( aWVal );
2487 double aHVal = horiz ? 0.12 : 0.80;
2488 if( mgr->hasValue( "SMESH", name + "height" ) )
2489 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2490 myScalarBarActor->SetHeight( aHVal );
2493 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2494 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2495 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2498 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2499 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2500 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2502 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2503 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2505 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2506 myScalarBarActor->SetDistributionColoringType(coloringType);
2508 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2509 QColor(255, 255, 255));
2511 rgb[0]= distributionColor.red()/255.;
2512 rgb[1]= distributionColor.green()/255.;
2513 rgb[2]= distributionColor.blue()/255.;
2514 myScalarBarActor->SetDistributionColor(rgb);
2519 // Get Actor for Threshold criteria compute
2520 SMESH_DeviceActor* SMESH_ActorDef::GetActorForThreshold()
2522 switch (myControlMode) {
2524 return my1DExtActor;
2526 return my2DExtActor;
2528 return myControlActor;
2532 // Hides the cells beyond threshold if isThresholdOn == true.
2533 void SMESH_ActorDef::ClipThreshold(bool isThresholdOn,double min /*= 0.0*/, double max /*= 0.0*/)
2535 SMESH_DeviceActor* anActor = GetActorForThreshold();
2536 if (anActor != myControlActor)
2537 myControlActor->VisibilityOff();
2539 myIsClipThresholdOn = isThresholdOn;
2542 // Initialize the filter
2543 vtkSmartPointer<vtkThreshold> threshold = vtkSmartPointer<vtkThreshold>::New();
2545 // We have set scalar data with SMESH_DeviceActor::SetControlMode() call as vtkDataSetAttributes::SCALARS.
2546 // So, we don't need to pass an array name in SetInputArrayToProcess().
2547 threshold->SetInputConnection(anActor->myMergeFilter->GetOutputPort());
2548 threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, vtkDataSetAttributes::SCALARS);
2551 threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN);
2552 threshold->SetLowerThreshold(min);
2553 threshold->SetUpperThreshold(max);
2556 threshold->Update();
2557 SCRUTE(threshold->GetOutput()->GetNumberOfCells());
2559 // Add to the filters' chain
2560 vtkAlgorithmOutput* port = threshold->GetOutputPort();
2561 anActor->myPassFilter[0]->SetInputConnection(port);
2565 // Restore the filters' chain
2566 anActor->SetImplicitFunctionUsed(anActor->myIsImplicitFunctionUsed);
2567 // Restore Actor filters when after Controls, which not use ExtACtor was called Controls, which use ExtActor
2568 // For avoid artifact's
2569 if (anActor != myControlActor)
2570 myControlActor->SetImplicitFunctionUsed(myControlActor->myIsImplicitFunctionUsed);
2572 myControlActor->VisibilityOn();
2576 // Hides the wireframe if isWireframeOff == true.
2577 void SMESH_ActorDef::SetWireframeOff(bool isWireframeOff)
2579 myIsWireframeOff = isWireframeOff;
2584 void SMESH_ActorDef::UpdateDistribution()
2586 if(SMESH::Controls::NumericalFunctor* fun =
2587 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2589 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2590 std::vector<int> nbEvents;
2591 std::vector<double> funValues;
2592 SMESH_VisualObjDef::TEntityList elems;
2593 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2594 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2595 std::vector<smIdType> elemIds; elemIds.reserve( elems.size() );
2596 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2597 elemIds.push_back( (*e)->GetID());
2598 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2599 double * range = lookupTable->GetRange();
2600 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2601 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2602 myScalarBarActor->SetDistribution(nbEvents);
2606 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2609 case SMESH_Actor::eLines :
2610 myHighlitableActor->SetQuadraticArcMode(false);
2611 my2DActor->SetQuadraticArcMode(false);
2612 my1DActor->SetQuadraticArcMode(false);
2614 case SMESH_Actor::eArcs :
2615 myHighlitableActor->SetQuadraticArcMode(true);
2616 if(GetRepresentation() != SMESH_Actor::ePoint) {
2617 my2DActor->SetQuadraticArcMode(true);
2618 my1DActor->SetQuadraticArcMode(true);
2627 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2629 if(myHighlitableActor->GetQuadraticArcMode())
2630 return SMESH_Actor::eArcs;
2632 return SMESH_Actor::eLines;
2635 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2637 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2638 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2639 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2642 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2644 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2645 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2646 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2647 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2650 void SMESH_ActorDef::UpdateFilter()
2652 unsigned int anObjectEntities = eAllEntity; // entities present in my object
2654 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
2655 anObjectEntities &= ~e0DElements;
2658 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
2659 anObjectEntities &= ~eBallElem;
2662 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
2663 anObjectEntities &= ~eEdges;
2666 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
2667 anObjectEntities &= ~eFaces;
2670 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
2671 anObjectEntities &= ~eVolumes;
2674 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
2675 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
2676 aFilter->ClearRegisteredCellsWithType();
2677 aHltFilter->ClearRegisteredCellsWithType();
2679 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
2682 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2683 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
2687 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2688 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
2689 if (myEntityMode & e0DElements) {
2690 aFilter->RegisterCellsWithType(VTK_VERTEX);
2691 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
2694 if (myEntityMode & eBallElem) {
2695 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
2697 if (myEntityMode & eEdges) {
2698 aFilter->RegisterCellsWithType(VTK_LINE);
2699 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2700 aHltFilter->RegisterCellsWithType(VTK_LINE);
2701 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
2704 if (myEntityMode & eFaces) {
2705 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
2706 aFilter->RegisterCellsWithType(VTK_QUAD);
2707 aFilter->RegisterCellsWithType(VTK_POLYGON);
2708 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2709 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2710 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2711 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2712 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2713 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
2714 aHltFilter->RegisterCellsWithType(VTK_QUAD);
2715 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
2716 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
2717 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
2718 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
2719 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
2720 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
2723 if (myEntityMode & eVolumes) {
2724 aFilter->RegisterCellsWithType(VTK_TETRA);
2725 aFilter->RegisterCellsWithType(VTK_VOXEL);
2726 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2727 aFilter->RegisterCellsWithType(VTK_WEDGE);
2728 aFilter->RegisterCellsWithType(VTK_PYRAMID);
2729 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2730 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2731 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2732 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2733 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2734 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2735 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2736 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2737 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2738 aHltFilter->RegisterCellsWithType(VTK_TETRA);
2739 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
2740 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
2741 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
2742 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
2743 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
2744 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
2745 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
2746 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
2747 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
2748 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
2749 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
2750 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
2751 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
2754 if ( GetVisibility() )
2756 MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
2759 #ifndef DISABLE_PLOT2DVIEWER
2760 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2763 my2dHistogram->clearAllPoints();
2765 if(SMESH::Controls::NumericalFunctor* fun =
2766 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2769 if(!my2dHistogram) {
2770 my2dHistogram = new SPlot2d_Histogram();
2771 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2772 my2dHistogram->setIO(anIO);
2775 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2776 std::vector<int> nbEvents;
2777 std::vector<double> funValues;
2778 SMESH_VisualObjDef::TEntityList elems;
2779 if ( dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get()))
2780 dynamic_cast<SMESH_SubMeshObj*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2781 std::vector<smIdType> elemIds;
2783 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2784 elemIds.push_back( (*e)->GetID());
2786 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2787 double * range = lookupTable->GetRange();
2788 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2789 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2791 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2792 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2794 if(funValues.size() >= 2)
2795 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2799 //Color of the histogram
2800 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2801 my2dHistogram->setAutoAssign(true);
2804 myScalarBarActor->GetDistributionColor(rgb);
2805 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2806 my2dHistogram->setColor(aColor);
2810 return my2dHistogram;