1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
30 #include "SMDS_UnstructuredGrid.hxx"
31 #include "SMESH_ActorUtils.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include "SMESH_DeviceActor.h"
35 #include "SMESH_NodeLabelActor.h"
36 #include "SMESH_ObjectDef.h"
37 #include "SMESH_SVTKActor.h"
38 #include "SMESH_ScalarBarActor.h"
41 #include <SALOME_InteractiveObject.hxx>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <VTKViewer_ExtractUnstructuredGrid.h>
45 #include <VTKViewer_FramedTextActor.h>
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkPlaneCollection.h>
79 #include <vtkImplicitBoolean.h>
80 #include <vtkImplicitFunctionCollection.h>
82 #include "utilities.h"
85 static int MYDEBUG = 0;
87 static int MYDEBUG = 0;
90 static int aLineWidthInc = 2;
93 SMESH_ActorDef* SMESH_ActorDef::New(){
94 return new SMESH_ActorDef();
98 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 SMESH_ActorDef* anActor = NULL;
104 if(theVisualObj->IsValid() ) {
105 anActor = SMESH_ActorDef::New();
106 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
111 anActor->UpdateScalarBar();
117 SMESH_ActorDef::SMESH_ActorDef()
119 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
121 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myHighlightActor = SMESH_SVTKActor::New();
131 myHighlightActor->Delete(); // vtkSmartPointer!
132 myHighlightActor->Initialize();
134 myPreHighlightActor = SMESH_SVTKActor::New();
135 myPreHighlightActor->Delete();
136 myPreHighlightActor->Initialize();
138 myIsShrinkable = false;
141 myIsFacesOriented = false;
143 myControlsPrecision = -1;
144 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
146 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
147 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
149 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
150 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
151 double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
152 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
153 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
155 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
157 bool anItalicNd = false;
158 bool aShadowNd = false;
160 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
161 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
162 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
163 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
164 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
166 anItalicNd = f.italic();
167 aShadowNd = f.overline();
168 aSizeNd = f.pointSize();
170 double anRGBNd[3] = {1,1,1};
171 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
173 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
175 bool anItalicEl = false;
176 bool aShadowEl = false;
178 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
179 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
180 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
181 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
182 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
184 anItalicEl = f.italic();
185 aShadowEl = f.overline();
186 aSizeEl = f.pointSize();
188 double anRGBEl[3] = {0,1,0};
189 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
191 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
192 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
194 //Definition 2D and 3D devices of the actor
195 //-----------------------------------------
196 double anRGB[3] = {1,1,1};
197 mySurfaceProp = vtkProperty::New();
200 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
201 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
202 myDeltaBrightness = delta;
204 myBackSurfaceProp = vtkProperty::New();
205 bfc = Qtx::mainColorToSecondary(ffc, delta);
206 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
208 myNormalVProp = vtkProperty::New();
209 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
210 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
211 myDeltaVBrightness = delta;
213 myReversedVProp = vtkProperty::New();
214 bfc = Qtx::mainColorToSecondary(ffc, delta);
215 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
217 my2DActor = SMESH_CellLabelActor::New();
218 my2DActor->SetStoreClippingMapping(true);
219 my2DActor->SetUserMatrix(aMatrix);
220 my2DActor->PickableOff();
221 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
222 my2DActor->SetProperty(mySurfaceProp);
223 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
224 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225 aFilter = my2DActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
228 aFilter->RegisterCellsWithType(VTK_QUAD);
229 aFilter->RegisterCellsWithType(VTK_POLYGON);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
233 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
234 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
236 my2DExtProp = vtkProperty::New();
237 my2DExtProp->DeepCopy(mySurfaceProp);
238 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
239 anRGB[0] = 1 - anRGB[0];
240 anRGB[1] = 1 - anRGB[1];
241 anRGB[2] = 1 - anRGB[2];
242 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
244 my2DExtActor = SMESH_DeviceActor::New();
245 my2DExtActor->SetUserMatrix(aMatrix);
246 my2DExtActor->PickableOff();
247 my2DExtActor->SetProperty(my2DExtProp);
248 my2DExtActor->SetBackfaceProperty(my2DExtProp);
249 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
250 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
251 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
252 aFilter->RegisterCellsWithType(VTK_QUAD);
253 aFilter->RegisterCellsWithType(VTK_POLYGON);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
255 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
257 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
258 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
260 my3DActor = SMESH_CellLabelActor::New();
261 my3DActor->SetStoreClippingMapping(true);
262 my3DActor->SetUserMatrix(aMatrix);
263 my3DActor->PickableOff();
264 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
265 my3DActor->SetProperty(myNormalVProp);
266 my3DActor->SetBackfaceProperty(myReversedVProp);
267 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
268 my3DActor->SetCoincident3DAllowed(true);
269 aFilter = my3DActor->GetExtractUnstructuredGrid();
270 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
271 aFilter->RegisterCellsWithType(VTK_TETRA);
272 aFilter->RegisterCellsWithType(VTK_VOXEL);
273 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
274 aFilter->RegisterCellsWithType(VTK_WEDGE);
275 aFilter->RegisterCellsWithType(VTK_PYRAMID);
276 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
277 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
279 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
281 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
282 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
283 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
285 my3DExtProp = vtkProperty::New();
286 my3DExtProp->DeepCopy(myNormalVProp);
287 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
288 anRGB[0] = 1 - anRGB[0];
289 anRGB[1] = 1 - anRGB[1];
290 anRGB[2] = 1 - anRGB[2];
291 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
293 my3DExtActor = SMESH_DeviceActor::New();
294 my3DExtActor->SetUserMatrix(aMatrix);
295 my3DExtActor->PickableOff();
296 my3DExtActor->SetProperty(my3DExtProp);
297 my3DExtActor->SetBackfaceProperty(my3DExtProp);
298 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
299 my3DExtActor->SetCoincident3DAllowed(true);
300 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
301 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
302 aFilter->RegisterCellsWithType(VTK_TETRA);
303 aFilter->RegisterCellsWithType(VTK_VOXEL);
304 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
305 aFilter->RegisterCellsWithType(VTK_WEDGE);
306 aFilter->RegisterCellsWithType(VTK_PYRAMID);
307 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
308 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
310 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
311 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
313 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
314 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
316 //Definition 1D device of the actor
317 //---------------------------------
318 myEdgeProp = vtkProperty::New();
319 myEdgeProp->SetAmbient(1.0);
320 myEdgeProp->SetDiffuse(0.0);
321 myEdgeProp->SetSpecular(0.0);
322 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
323 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
324 myEdgeProp->SetLineWidth(aLineWidth);
326 my1DActor = SMESH_CellLabelActor::New();
327 my1DActor->SetStoreClippingMapping(true);
328 my1DActor->SetUserMatrix(aMatrix);
329 my1DActor->PickableOff();
330 my1DActor->SetHighlited(true);
331 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
332 my1DActor->SetProperty(myEdgeProp);
333 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
334 aFilter = my1DActor->GetExtractUnstructuredGrid();
335 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
336 aFilter->RegisterCellsWithType(VTK_LINE);
337 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
339 my1DProp = vtkProperty::New();
340 my1DProp->DeepCopy(myEdgeProp);
341 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
342 my1DProp->SetPointSize(aElem0DSize);
344 my1DExtProp = vtkProperty::New();
345 my1DExtProp->DeepCopy(myEdgeProp);
346 anRGB[0] = 1 - anRGB[0];
347 anRGB[1] = 1 - anRGB[1];
348 anRGB[2] = 1 - anRGB[2];
349 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
350 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
351 my1DExtProp->SetPointSize(aElem0DSize);
353 my1DExtActor = SMESH_DeviceActor::New();
354 my1DExtActor->SetUserMatrix(aMatrix);
355 my1DExtActor->PickableOff();
356 my1DExtActor->SetHighlited(true);
357 my1DExtActor->SetVisibility(false);
358 my1DExtActor->SetProperty(my1DExtProp);
359 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
360 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
361 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
362 aFilter->RegisterCellsWithType(VTK_LINE);
363 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
366 //Definition 0D device of the actor (0d elements)
367 //-----------------------------------------------
368 my0DProp = vtkProperty::New();
369 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
370 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
371 my0DProp->SetPointSize(aElem0DSize);
373 my0DActor = SMESH_CellLabelActor::New();
374 my0DActor->SetUserMatrix(aMatrix);
375 my0DActor->SetStoreClippingMapping(true);
376 my0DActor->PickableOff();
377 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
378 my0DActor->SetVisibility(false);
379 my0DActor->SetProperty(my0DProp);
380 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
381 aFilter = my0DActor->GetExtractUnstructuredGrid();
382 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
383 aFilter->RegisterCellsWithType(VTK_VERTEX);
385 //Definition 0D device of the actor (ball elements)
386 //-----------------------------------------------
387 myBallProp = vtkProperty::New();
388 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
389 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
390 myBallProp->SetPointSize(aBallElemSize);
392 myBallActor = SMESH_CellLabelActor::New();
393 myBallActor->SetUserMatrix(aMatrix);
394 myBallActor->SetStoreClippingMapping(true);
395 myBallActor->PickableOff();
396 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
397 myBallActor->SetVisibility(false);
398 myBallActor->SetProperty(myBallProp);
399 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
400 myBallActor->SetBallEnabled(true);
401 aFilter = myBallActor->GetExtractUnstructuredGrid();
402 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
403 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
405 //my0DExtProp = vtkProperty::New();
406 //my0DExtProp->DeepCopy(my0DProp);
407 //anRGB[0] = 1 - anRGB[0];
408 //anRGB[1] = 1 - anRGB[1];
409 //anRGB[2] = 1 - anRGB[2];
410 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
411 //my0DExtProp->SetPointSize(aElem0DSize);
413 //my0DExtActor = SMESH_DeviceActor::New();
414 //my0DExtActor->SetUserMatrix(aMatrix);
415 //my0DExtActor->SetStoreClippingMapping(true);
416 //my0DExtActor->PickableOff();
417 //my0DExtActor->SetHighlited(true);
418 //my0DExtActor->SetVisibility(false);
419 //my0DExtActor->SetProperty(my0DExtProp);
420 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
421 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
422 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
423 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
424 //aFilter->RegisterCellsWithType(VTK_VERTEX);
427 //Definition 0D device of the actor (nodes)
428 //-----------------------------------------
429 myNodeProp = vtkProperty::New();
430 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
431 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
433 myNodeActor = SMESH_NodeLabelActor::New();
434 myNodeActor->SetUserMatrix(aMatrix);
435 myNodeActor->SetStoreClippingMapping(true);
436 myNodeActor->PickableOff();
437 myNodeActor->SetVisibility(false);
438 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
439 myNodeActor->SetProperty(myNodeProp);
440 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
441 aFilter = myNodeActor->GetExtractUnstructuredGrid();
442 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
444 myNodeExtProp = vtkProperty::New();
445 myNodeExtProp->DeepCopy(myNodeProp);
446 anRGB[0] = 1 - anRGB[0];
447 anRGB[1] = 1 - anRGB[1];
448 anRGB[2] = 1 - anRGB[2];
449 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
451 myNodeExtActor = SMESH_DeviceActor::New();
452 myNodeExtActor->SetUserMatrix(aMatrix);
453 myNodeExtActor->SetStoreClippingMapping(true);
454 myNodeExtActor->PickableOff();
455 myNodeExtActor->SetHighlited(true);
456 myNodeExtActor->SetVisibility(false);
457 myNodeExtActor->SetProperty(myNodeExtProp);
458 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
459 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
460 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
461 aFilter->RegisterCellsWithType(VTK_VERTEX);
463 //Definition of Pickable and Highlitable engines
464 //----------------------------------------------
466 myBaseActor->SetUserMatrix(aMatrix);
467 myBaseActor->SetStoreIDMapping(true);
468 myBaseActor->SetStoreClippingMapping(true);
469 myBaseActor->SetStoreGemetryMapping(true);
470 myBaseActor->GetProperty()->SetOpacity(0.0);
471 myPickableActor = myBaseActor;
473 myHighlightProp = vtkProperty::New();
474 myHighlightProp->SetAmbient(1.0);
475 myHighlightProp->SetDiffuse(0.0);
476 myHighlightProp->SetSpecular(0.0);
477 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
478 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
479 myHighlightProp->SetPointSize(aElem0DSize); // ??
480 myHighlightProp->SetLineWidth(aLineWidth);
481 myHighlightProp->SetRepresentation(1);
483 myOutLineProp = vtkProperty::New();
484 myOutLineProp->SetAmbient(1.0);
485 myOutLineProp->SetDiffuse(0.0);
486 myOutLineProp->SetSpecular(0.0);
487 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
488 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
489 myOutLineProp->SetLineWidth(aOutlineWidth);
490 myOutLineProp->SetRepresentation(1);
492 myPreselectProp = vtkProperty::New();
493 myPreselectProp->SetAmbient(1.0);
494 myPreselectProp->SetDiffuse(0.0);
495 myPreselectProp->SetSpecular(0.0);
496 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
497 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
498 myPreselectProp->SetPointSize(aElem0DSize); // ??
499 myPreselectProp->SetLineWidth(aLineWidth);
500 myPreselectProp->SetRepresentation(1);
502 myHighlitableActor = SMESH_DeviceActor::New();
503 myHighlitableActor->SetUserMatrix(aMatrix);
504 myHighlitableActor->PickableOff();
505 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
506 myHighlitableActor->SetCoincident3DAllowed(true);
513 myControlMode = eNone;
514 myControlActor = my2DActor;
516 //Definition of myScalarBarActor
517 //------------------------------
518 myLookupTable = vtkLookupTable::New();
519 //Fix for Bug PAL5195 - SMESH764:
520 //Controls - Aspect Ratio: incorrect colors of the best and worst values
521 myLookupTable->SetHueRange(0.667,0.0);
523 myScalarBarActor = SMESH_ScalarBarActor::New();
524 myScalarBarActor->SetVisibility(false);
525 myScalarBarActor->SetLookupTable(myLookupTable);
528 //Incorrect "Min value" in Scalar Bar in Mesh:
529 // myScalarBarActor->SetLabelFormat("%.4g");
530 // changes was commented because of regression bug IPAL 19981
532 mgr = SUIT_Session::session()->resourceMgr();
536 myEntityMode = eAllEntity;
537 myEntityModeCache = eAllEntity;
540 myImplicitBoolean = vtkImplicitBoolean::New();
541 myImplicitBoolean->SetOperationTypeToIntersection();
543 myPlaneCollection = vtkPlaneCollection::New();
545 //Quadratic 2D elements representation
546 //-----------------------------------------------------------------------------
547 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
548 if(aQuadratic2DMode == 0){
549 myHighlitableActor->SetQuadraticArcMode(false);
550 my2DActor->SetQuadraticArcMode(false);
551 my1DActor->SetQuadraticArcMode(false);
553 else if(aQuadratic2DMode == 1){
554 myHighlitableActor->SetQuadraticArcMode(true);
555 my2DActor->SetQuadraticArcMode(true);
556 my1DActor->SetQuadraticArcMode(true);
559 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
560 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
561 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
563 // Set colors of the name actor
564 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
565 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
566 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
567 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
569 #ifndef DISABLE_PLOT2DVIEWER
573 SetBallSize(aBallElemSize);
574 SetBallScale(aBallElemScale);
575 Set0DSize(aElem0DSize);
579 SMESH_ActorDef::~SMESH_ActorDef()
581 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
583 // Please keep the order same as one in the header file
585 myTimeStamp->Delete();
587 myScalarBarActor->Delete();
588 myLookupTable->Delete();
590 mySurfaceProp->Delete();
591 myBackSurfaceProp->Delete();
592 myNormalVProp->Delete();
593 myReversedVProp->Delete();
594 myEdgeProp->Delete();
595 myNodeProp->Delete();
597 myNodeActor->Delete();
598 myBaseActor->Delete();
599 //myPickableActor->Delete(); myPickableActor == myBaseActor
601 myHighlightProp->Delete();
602 myOutLineProp->Delete();
603 myPreselectProp->Delete();
605 myHighlitableActor->Delete();
607 my2DExtProp->Delete();
608 my3DExtProp->Delete();
610 my2DExtActor->Delete();
612 my3DExtActor->Delete();
613 // myControlActor->Delete(); myControlActor == my2DActor
615 myNodeExtProp->Delete();
616 myNodeExtActor->Delete();
620 my1DExtProp->Delete();
621 my1DExtActor->Delete();
625 myBallProp->Delete();
626 myBallActor->Delete();
627 //my0DExtProp->Delete();
628 //my0DExtActor->Delete();
630 myImplicitBoolean->Delete();
631 myPlaneCollection->Delete();
633 #ifndef DISABLE_PLOT2DVIEWER
635 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
636 delete my2dHistogram;
641 void SMESH_ActorDef::Delete()
643 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
644 // from the actor's destructor) will be thrown before removing the actor's observers,
645 // that is done inside the Superclass::Delete() method but before the destructor itself
646 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
647 // The event is caught by SMESHGUI::ProcessEvents() static method.
648 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
650 Superclass::Delete();
653 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
656 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
657 SetRepresentation(GetRepresentation());
658 myTimeStamp->Modified();
662 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
663 bool theBold, bool theItalic, bool theShadow,
664 double r, double g, double b )
667 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
668 SetRepresentation( GetRepresentation() );
669 myTimeStamp->Modified();
673 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
674 bool theBold, bool theItalic, bool theShadow,
675 double r, double g, double b )
678 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
681 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
682 SetRepresentation( GetRepresentation() );
683 myTimeStamp->Modified();
686 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
687 SetRepresentation( GetRepresentation() );
688 myTimeStamp->Modified();
691 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
692 SetRepresentation( GetRepresentation() );
693 myTimeStamp->Modified();
696 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
697 SetRepresentation( GetRepresentation() );
698 myTimeStamp->Modified();
702 bool SMESH_ActorDef::GetPointsLabeled()
704 return myNodeActor && myNodeActor->GetPointsLabeled();
707 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
710 my3DActor->SetCellsLabeled(theIsCellsLabeled);
713 my2DActor->SetCellsLabeled(theIsCellsLabeled);
716 my1DActor->SetCellsLabeled(theIsCellsLabeled);
719 my0DActor->SetCellsLabeled(theIsCellsLabeled);
722 myBallActor->SetCellsLabeled(theIsCellsLabeled);
724 myTimeStamp->Modified();
728 bool SMESH_ActorDef::GetCellsLabeled()
732 result = result || my3DActor->GetCellsLabeled();
735 result = result || my2DActor->GetCellsLabeled();
738 result = result || my1DActor->GetCellsLabeled();
741 result = result || my0DActor->GetCellsLabeled();
744 result = result || myBallActor->GetCellsLabeled();
750 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
752 myIsFacesOriented = theIsFacesOriented;
754 my2DActor->SetFacesOriented(theIsFacesOriented);
755 my3DActor->SetFacesOriented(theIsFacesOriented);
757 myTimeStamp->Modified();
760 bool SMESH_ActorDef::GetFacesOriented()
762 return myIsFacesOriented;
765 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
767 my2DActor->SetFacesOrientationColor( r, g, b );
768 my3DActor->SetFacesOrientationColor( r, g, b );
771 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
773 my3DActor->GetFacesOrientationColor( r, g, b );
776 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
778 my2DActor->SetFacesOrientationScale( theScale );
779 my3DActor->SetFacesOrientationScale( theScale );
782 double SMESH_ActorDef::GetFacesOrientationScale()
784 return my3DActor->GetFacesOrientationScale();
787 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
789 my2DActor->SetFacesOrientation3DVectors( theState );
790 my3DActor->SetFacesOrientation3DVectors( theState );
793 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
795 return my3DActor->GetFacesOrientation3DVectors();
799 void SMESH_ActorDef::SetControlMode(eControl theMode)
801 SetControlMode(theMode,true);
805 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
807 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
808 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
809 lookupTable->SetScale(VTK_SCALE_LINEAR);
811 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
815 myControlMode = eNone;
816 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
818 my0DActor->GetMapper()->SetScalarVisibility(false);
819 my1DActor->GetMapper()->SetScalarVisibility(false);
820 my2DActor->GetMapper()->SetScalarVisibility(false);
821 my3DActor->GetMapper()->SetScalarVisibility(false);
822 myBallActor->GetMapper()->SetScalarVisibility(false);
823 myScalarBarActor->SetVisibility(false);
825 bool anIsScalarVisible = theMode > eNone;
827 if(anIsScalarVisible) {
831 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
832 aControl->SetPrecision( myControlsPrecision );
833 myFunctor.reset( aControl );
834 myControlActor = my1DActor;
839 myFunctor.reset(new SMESH::Controls::Length2D());
840 myControlActor = my2DActor;
844 myFunctor.reset(new SMESH::Controls::FreeBorders());
845 myControlActor = my1DActor;
848 myFunctor.reset(new SMESH::Controls::FreeEdges());
849 myControlActor = my2DActor;
852 myFunctor.reset(new SMESH::Controls::FreeNodes());
853 myControlActor = myNodeActor;
856 myFunctor.reset(new SMESH::Controls::FreeFaces());
857 myControlActor = my2DActor;
859 case eCoincidentNodes:
861 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
862 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
863 cn->SetTolerance( tol );
865 myControlActor = myNodeActor;
868 case eCoincidentElems1D:
869 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
870 myControlActor = my1DActor;
872 case eCoincidentElems2D:
873 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
874 myControlActor = my2DActor;
876 case eCoincidentElems3D:
877 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
878 myControlActor = my3DActor;
880 case eBareBorderFace:
881 myFunctor.reset(new SMESH::Controls::BareBorderFace());
882 myControlActor = my2DActor;
884 case eOverConstrainedFace:
885 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
886 myControlActor = my2DActor;
888 case eMultiConnection:
889 myFunctor.reset(new SMESH::Controls::MultiConnection());
890 myControlActor = my1DActor;
892 case eMultiConnection2D:
893 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
894 myControlActor = my2DActor;
898 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
899 aControl->SetPrecision( myControlsPrecision );
900 myFunctor.reset( aControl );
901 myControlActor = my2DActor;
906 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
907 aControl->SetPrecision( myControlsPrecision );
908 myFunctor.reset( aControl );
909 myControlActor = my2DActor;
914 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
915 aControl->SetPrecision( myControlsPrecision );
916 myFunctor.reset( aControl );
917 myControlActor = my2DActor;
922 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
923 aControl->SetPrecision( myControlsPrecision );
924 myFunctor.reset( aControl );
925 myControlActor = my3DActor;
930 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
931 aControl->SetPrecision( myControlsPrecision );
932 myFunctor.reset( aControl );
933 myControlActor = my3DActor;
936 case eMaxElementLength2D:
938 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
939 aControl->SetPrecision( myControlsPrecision );
940 myFunctor.reset( aControl );
941 myControlActor = my2DActor;
944 case eMaxElementLength3D:
946 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
947 aControl->SetPrecision( myControlsPrecision );
948 myFunctor.reset( aControl );
949 myControlActor = my3DActor;
952 case eBareBorderVolume:
954 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
955 myControlActor = my3DActor;
958 case eOverConstrainedVolume:
960 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
961 myControlActor = my3DActor;
966 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
967 aControl->SetPrecision( myControlsPrecision );
968 myFunctor.reset( aControl );
969 myControlActor = my2DActor;
974 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
975 aControl->SetPrecision( myControlsPrecision );
976 myFunctor.reset( aControl );
977 myControlActor = my2DActor;
982 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
983 aControl->SetPrecision( myControlsPrecision );
984 myFunctor.reset( aControl );
985 myControlActor = my2DActor;
988 case eNodeConnectivityNb:
990 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
991 myControlActor = myNodeActor;
998 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
999 vtkIdType aNbCells = aGrid->GetNumberOfCells();
1000 bool aShowOnlyScalarBarTitle = false;
1002 myControlMode = theMode;
1003 switch(myControlMode){
1005 case eCoincidentNodes:
1006 myNodeExtActor->SetExtControlMode(myFunctor);
1007 aShowOnlyScalarBarTitle = true;
1011 case eCoincidentElems1D:
1012 my1DExtActor->SetExtControlMode(myFunctor);
1013 aShowOnlyScalarBarTitle = true;
1016 case eBareBorderFace:
1017 case eOverConstrainedFace:
1018 case eCoincidentElems2D:
1019 my2DExtActor->SetExtControlMode(myFunctor);
1020 aShowOnlyScalarBarTitle = true;
1022 case eBareBorderVolume:
1023 case eOverConstrainedVolume:
1024 case eCoincidentElems3D:
1025 my3DExtActor->SetExtControlMode(myFunctor);
1026 aShowOnlyScalarBarTitle = true;
1029 case eMultiConnection2D:
1030 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1031 UpdateDistribution();
1034 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1035 UpdateDistribution();
1037 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1040 if(theCheckEntityMode) {
1041 // if(myControlActor == myNodeActor) {
1042 // if ( myControlMode == eNodeConnectivityNb ) {
1043 // if (!myIsEntityModeCache){
1044 // myEntityModeCache = GetEntityMode();
1045 // myIsEntityModeCache=true;
1047 // SetEntityMode(0);
1050 if(myControlActor == my1DActor) {
1051 if (!myIsEntityModeCache){
1052 myEntityModeCache = GetEntityMode();
1053 myIsEntityModeCache=true;
1055 SetEntityMode(eEdges);
1057 else if(myControlActor == my2DActor) {
1058 switch(myControlMode) {
1062 case eMultiConnection2D:
1063 if (!myIsEntityModeCache){
1064 myEntityModeCache = GetEntityMode();
1065 myIsEntityModeCache=true;
1067 SetEntityMode(eFaces);
1070 if (!myIsEntityModeCache){
1071 myEntityModeCache = GetEntityMode();
1072 myIsEntityModeCache=true;
1074 SetEntityMode(eFaces);
1076 }else if(myControlActor == my3DActor) {
1077 if (!myIsEntityModeCache){
1078 myEntityModeCache = GetEntityMode();
1079 myIsEntityModeCache=true;
1081 SetEntityMode(eVolumes);
1084 QString aTitle = QString(myScalarBarActor->GetTitle());
1085 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1086 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1090 if(theCheckEntityMode){
1091 myEntityMode = myEntityModeCache;
1092 myIsEntityModeCache = false;
1097 SetRepresentation(GetRepresentation());
1099 myTimeStamp->Modified();
1102 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1103 double * range = lookupTable->GetRange();
1105 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1106 lookupTable->SetScale(VTK_SCALE_LOG10);
1111 int SMESH_ActorDef::GetNumberControlEntities()
1113 SMESH_DeviceActor* anAct = NULL;
1114 switch(myControlMode){
1116 case eCoincidentNodes:
1117 anAct = myNodeExtActor;
1121 case eCoincidentElems1D:
1122 anAct = my1DExtActor;
1125 case eBareBorderFace:
1126 case eOverConstrainedFace:
1127 case eCoincidentElems2D:
1128 anAct = my2DExtActor;
1130 case eBareBorderVolume:
1131 case eOverConstrainedVolume:
1132 case eCoincidentElems3D:
1133 anAct = my3DExtActor;
1137 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1140 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1142 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1144 myBaseActor->SetUnstructuredGrid( NULL );
1145 //myHighlitableActor->SetUnstructuredGrid( NULL );
1147 theRenderer->AddActor(myBaseActor);
1148 theRenderer->AddActor(myNodeExtActor);
1149 theRenderer->AddActor(my1DExtActor);
1151 my3DActor ->AddToRender(theRenderer);
1152 my3DExtActor->AddToRender(theRenderer);
1153 my2DActor ->AddToRender(theRenderer);
1154 my2DExtActor->AddToRender(theRenderer);
1155 myNodeActor ->AddToRender(theRenderer);
1156 my1DActor ->AddToRender(theRenderer);
1157 my0DActor ->AddToRender(theRenderer);
1158 myBallActor ->AddToRender(theRenderer);
1160 theRenderer->AddActor(myHighlitableActor);
1162 theRenderer->AddActor2D(myScalarBarActor);
1164 // the superclass' method should be called at the end
1165 // (in particular, for correct work of selection)
1166 SALOME_Actor::AddToRender(theRenderer);
1169 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1171 SALOME_Actor::RemoveFromRender(theRenderer);
1173 theRenderer->RemoveActor(myBaseActor);
1175 theRenderer->RemoveActor(myNodeExtActor);
1177 theRenderer->RemoveActor(myHighlitableActor);
1179 //theRenderer->RemoveActor(my0DExtActor);
1181 theRenderer->RemoveActor(my1DExtActor);
1183 my2DActor->RemoveFromRender(theRenderer);
1184 my2DExtActor->RemoveFromRender(theRenderer);
1185 my3DActor->RemoveFromRender(theRenderer);
1186 my3DExtActor->RemoveFromRender(theRenderer);
1187 myNodeActor->RemoveFromRender(theRenderer);
1188 my0DActor->RemoveFromRender(theRenderer);
1189 myBallActor->RemoveFromRender(theRenderer);
1190 my1DActor->RemoveFromRender(theRenderer);
1192 theRenderer->RemoveActor(myScalarBarActor);
1196 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1197 const char* theEntry,
1198 const char* theName,
1201 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1205 myVisualObj = theVisualObj;
1206 myVisualObj->Update(theIsClear);
1208 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1209 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1211 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1212 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1214 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1216 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1218 my0DActor->Init(myVisualObj,myImplicitBoolean);
1219 myBallActor->Init(myVisualObj,myImplicitBoolean);
1220 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1222 my1DActor->Init(myVisualObj,myImplicitBoolean);
1223 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1225 my2DActor->Init(myVisualObj,myImplicitBoolean);
1226 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1227 my3DActor->Init(myVisualObj,myImplicitBoolean);
1228 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1230 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1231 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1232 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1234 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1235 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1237 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1238 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1239 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1240 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1242 double aFactor, aUnits;
1243 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1244 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1245 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1246 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1248 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1252 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1253 SetIsShrunkable(true);
1255 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1257 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1258 SetRepresentation(-1);
1261 SetRepresentation(eEdge);
1262 }else if(aMode == 1){
1263 SetRepresentation(eSurface);
1264 }else if(aMode == 2){
1265 SetRepresentation(ePoint);
1272 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1273 SetIsDisplayNameActor( true );
1275 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1276 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1277 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1279 myTimeStamp->Modified();
1285 double* SMESH_ActorDef::GetBounds()
1287 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1288 return myNodeActor->GetBounds();
1289 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1293 vtkDataSet* SMESH_ActorDef::GetInput()
1295 return GetUnstructuredGrid();
1299 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1301 Superclass::SetTransform(theTransform);
1303 myNodeActor->SetTransform(theTransform);
1304 myBaseActor->SetTransform(theTransform);
1306 myHighlitableActor->SetTransform(theTransform);
1308 myNodeExtActor->SetTransform(theTransform);
1310 my0DActor->SetTransform(theTransform);
1311 myBallActor->SetTransform(theTransform);
1312 //my0DExtActor->SetTransform(theTransform);
1314 my1DActor->SetTransform(theTransform);
1315 my1DExtActor->SetTransform(theTransform);
1317 my2DActor->SetTransform(theTransform);
1318 my2DExtActor->SetTransform(theTransform);
1319 my3DActor->SetTransform(theTransform);
1320 my3DExtActor->SetTransform(theTransform);
1326 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1328 vtkLODActor::SetMapper(theMapper);
1332 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1334 SALOME_Actor::ShallowCopy(prop);
1338 vtkMapper* SMESH_ActorDef::GetMapper()
1340 return myPickableActor->GetMapper();
1344 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1346 return myVisualObj->GetUnstructuredGrid();
1350 bool SMESH_ActorDef::IsInfinitive()
1352 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1353 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1354 ( aDataSet->GetNumberOfCells() == 1 &&
1355 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1356 return SALOME_Actor::IsInfinitive();
1360 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1362 if ( myIsShrinkable == theShrunkable )
1364 myIsShrinkable = theShrunkable;
1368 double SMESH_ActorDef::GetShrinkFactor()
1370 return myBaseActor->GetShrinkFactor();
1373 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1375 myBaseActor->SetShrinkFactor(theValue);
1377 my1DActor->SetShrinkFactor(theValue);
1378 my1DExtActor->SetShrinkFactor(theValue);
1380 my2DActor->SetShrinkFactor(theValue);
1381 my2DExtActor->SetShrinkFactor(theValue);
1382 my3DActor->SetShrinkFactor(theValue);
1383 my3DExtActor->SetShrinkFactor(theValue);
1384 my3DExtActor->SetShrinkFactor(theValue);
1385 myHighlitableActor->SetShrinkFactor(theValue);
1390 void SMESH_ActorDef::SetShrink()
1392 if(!myIsShrinkable) return;
1394 myBaseActor->SetShrink();
1396 my1DActor->SetShrink();
1397 my1DExtActor->SetShrink();
1399 my2DActor->SetShrink();
1400 my2DExtActor->SetShrink();
1401 my3DActor->SetShrink();
1402 my3DExtActor->SetShrink();
1403 myHighlitableActor->SetShrink();
1409 void SMESH_ActorDef::UnShrink()
1411 if(!myIsShrunk) return;
1413 myBaseActor->UnShrink();
1415 my1DActor->UnShrink();
1416 my1DExtActor->UnShrink();
1418 my2DActor->UnShrink();
1419 my2DExtActor->UnShrink();
1420 my3DActor->UnShrink();
1421 my3DExtActor->UnShrink();
1422 myHighlitableActor->UnShrink();
1429 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1431 return myPickableActor->GetNodeObjId(theVtkID);
1434 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1436 return myPickableActor->GetNodeCoord(theObjID);
1440 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1442 return myPickableActor->GetElemObjId(theVtkID);
1445 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1447 return myPickableActor->GetElemCell(theObjID);
1451 void SMESH_ActorDef::SetVisibility(int theMode)
1453 SetVisibility(theMode,true);
1457 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1459 SALOME_Actor::SetVisibility(theMode);
1461 myNodeActor->VisibilityOff();
1462 myBaseActor->VisibilityOff();
1464 myNodeExtActor->VisibilityOff();
1466 my0DActor->VisibilityOff();
1467 myBallActor->VisibilityOff();
1468 //my0DExtActor->VisibilityOff();
1470 my1DActor->VisibilityOff();
1471 my1DExtActor->VisibilityOff();
1473 my2DActor->VisibilityOff();
1474 my2DExtActor->VisibilityOff();
1475 my3DActor->VisibilityOff();
1476 my3DExtActor->VisibilityOff();
1478 myScalarBarActor->VisibilityOff();
1480 if(GetVisibility()){
1481 if(theIsUpdateRepersentation)
1482 SetRepresentation(GetRepresentation());
1484 if(myControlMode != eNone) {
1485 switch(myControlMode) {
1487 case eCoincidentNodes:
1488 myNodeExtActor->VisibilityOn();
1492 case eCoincidentElems1D:
1493 my1DExtActor->VisibilityOn();
1496 case eBareBorderFace:
1497 case eOverConstrainedFace:
1498 case eCoincidentElems2D:
1499 my2DExtActor->VisibilityOn();
1501 case eBareBorderVolume:
1502 case eOverConstrainedVolume:
1503 case eCoincidentElems3D:
1504 my3DExtActor->VisibilityOn();
1507 case eMultiConnection2D:
1508 my1DExtActor->VisibilityOn();
1512 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1513 myScalarBarActor->VisibilityOn();
1516 if(myRepresentation != ePoint)
1517 myPickableActor->VisibilityOn();
1519 myNodeActor->VisibilityOn();
1522 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1523 my0DActor->VisibilityOn();
1525 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1526 myBallActor->VisibilityOn();
1529 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1530 my1DActor->VisibilityOn();
1533 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1534 my2DActor->VisibilityOn();
1537 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1538 my3DActor->VisibilityOn();
1541 if(myNodeActor->GetPointsLabeled()){
1542 myNodeActor->VisibilityOn();
1546 my0DActor->UpdateLabels();
1549 myBallActor->UpdateLabels();
1552 my1DActor->UpdateLabels();
1555 my2DActor->UpdateLabels();
1558 my3DActor->UpdateLabels();
1560 #ifndef DISABLE_PLOT2DVIEWER
1562 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1569 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1571 myEntityState = eAllEntity;
1573 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1574 myEntityState &= ~e0DElements;
1575 theMode &= ~e0DElements;
1578 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1579 myEntityState &= ~eBallElem;
1580 theMode &= ~eBallElem;
1583 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1584 myEntityState &= ~eEdges;
1588 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1589 myEntityState &= ~eFaces;
1593 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1594 myEntityState &= ~eVolumes;
1595 theMode &= ~eVolumes;
1599 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1600 theMode |= e0DElements;
1602 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1603 theMode |= eBallElem;
1605 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1608 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1611 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1612 theMode |= eVolumes;
1615 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1617 myEntityMode = theMode;
1619 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1620 aFilter->ClearRegisteredCellsWithType();
1621 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1622 aHightFilter->ClearRegisteredCellsWithType();
1625 (( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) &&
1626 ( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) &&
1627 ( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) &&
1628 ( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) &&
1629 ( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 ));
1630 if ( isPassAll && myEntityMode )
1632 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1633 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1637 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1638 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1640 if (myEntityMode & e0DElements) {
1641 aFilter->RegisterCellsWithType(VTK_VERTEX);
1642 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1645 if (myEntityMode & eBallElem) {
1646 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1649 if (myEntityMode & eEdges) {
1650 aFilter->RegisterCellsWithType(VTK_LINE);
1651 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1653 aHightFilter->RegisterCellsWithType(VTK_LINE);
1654 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1657 if (myEntityMode & eFaces) {
1658 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1659 aFilter->RegisterCellsWithType(VTK_QUAD);
1660 aFilter->RegisterCellsWithType(VTK_POLYGON);
1661 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1662 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1663 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1664 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1665 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1667 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1668 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1669 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1670 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1671 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1672 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1673 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1674 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1677 if (myEntityMode & eVolumes) {
1678 aFilter->RegisterCellsWithType(VTK_TETRA);
1679 aFilter->RegisterCellsWithType(VTK_VOXEL);
1680 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1681 aFilter->RegisterCellsWithType(VTK_WEDGE);
1682 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1683 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1684 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1685 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1686 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1687 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1688 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1689 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1690 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1692 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1693 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1694 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1695 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1696 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1697 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1698 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1699 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1700 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1701 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1702 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1703 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1704 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1707 if ( GetVisibility() )
1709 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1710 SetVisibility(GetVisibility(),false);
1713 void SMESH_ActorDef::SetRepresentation (int theMode)
1715 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1716 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1717 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1718 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1719 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1722 myRepresentation = eSurface;
1723 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1724 myRepresentation = eEdge;
1725 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1726 myRepresentation = ePoint;
1731 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1734 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1737 myRepresentation = theMode;
1740 if (!GetUnstructuredGrid()->GetNumberOfCells())
1741 myRepresentation = ePoint;
1744 if (myRepresentation == ePoint) {
1752 myPickableActor = myBaseActor;
1753 myNodeActor->SetVisibility(false);
1754 myNodeExtActor->SetVisibility(false);
1755 vtkProperty *aProp = NULL, *aBackProp = NULL;
1756 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1757 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1758 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1759 switch (myRepresentation) {
1761 myPickableActor = myNodeActor;
1762 myNodeActor->SetVisibility(true);
1763 aQuadraticMode = SMESH_Actor::eLines;
1764 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1765 aReperesent = SMESH_DeviceActor::ePoint;
1768 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1769 aReperesent = SMESH_DeviceActor::eInsideframe;
1772 aProp = mySurfaceProp;
1773 aBackProp = myBackSurfaceProp;
1774 aPropVN = myNormalVProp;
1775 aPropVR = myReversedVProp;
1776 aReperesent = SMESH_DeviceActor::eSurface;
1780 my2DActor->SetProperty(aProp);
1781 my2DActor->SetBackfaceProperty(aBackProp);
1782 my2DActor->SetRepresentation(aReperesent);
1784 if(aQuadraticMode == SMESH_Actor::eLines)
1785 my2DActor->SetQuadraticArcMode(false);
1786 else if(aQuadraticMode == SMESH_Actor::eArcs)
1787 my2DActor->SetQuadraticArcMode(true);
1789 my2DExtActor->SetRepresentation(aReperesent);
1791 my3DActor->SetProperty(aPropVN);
1792 my3DActor->SetBackfaceProperty(aPropVR);
1793 my3DActor->SetRepresentation(aReperesent);
1796 my1DExtActor->SetVisibility(false);
1797 my2DExtActor->SetVisibility(false);
1798 my3DExtActor->SetVisibility(false);
1800 my0DActor->SetRepresentation(aReperesent);
1801 myBallActor->SetRepresentation(aReperesent);
1803 switch ( myControlMode ) {
1805 case eMultiConnection:
1806 aProp = aBackProp = my1DProp;
1807 if(myRepresentation != ePoint)
1808 aReperesent = SMESH_DeviceActor::eInsideframe;
1813 if(aQuadraticMode == SMESH_Actor::eLines)
1814 my1DActor->SetQuadraticArcMode(false);
1815 else if(aQuadraticMode == SMESH_Actor::eArcs)
1816 my1DActor->SetQuadraticArcMode(true);
1818 my1DActor->SetProperty(aProp);
1819 my1DActor->SetBackfaceProperty(aBackProp);
1820 my1DActor->SetRepresentation(aReperesent);
1822 my1DExtActor->SetRepresentation(aReperesent);
1824 if(myIsPointsVisible)
1825 myPickableActor = myNodeActor;
1826 if(GetPointRepresentation())
1827 myNodeActor->SetVisibility(true);
1829 SetMapper(myPickableActor->GetMapper());
1831 SetVisibility(GetVisibility(),false);
1837 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1839 if ( myIsPointsVisible == theIsPointsVisible )
1841 myIsPointsVisible = theIsPointsVisible;
1842 SetRepresentation(GetRepresentation());
1845 bool SMESH_ActorDef::GetPointRepresentation()
1847 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1851 void SMESH_ActorDef::UpdateHighlight()
1853 myHighlitableActor->SetHighlited(false);
1854 myHighlitableActor->SetVisibility(false);
1855 bool anIsVisible = GetVisibility();
1857 switch(myRepresentation){
1858 case SMESH_DeviceActor::eSurface:
1859 case SMESH_DeviceActor::eWireframe:
1861 if(myIsHighlighted) {
1862 myHighlitableActor->SetProperty(myHighlightProp);
1863 }else if(myIsPreselected){
1864 myHighlitableActor->SetProperty(myPreselectProp);
1865 } else if(anIsVisible){
1866 (myRepresentation == eSurface) ?
1867 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1869 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1870 myHighlitableActor->SetHighlited(anIsVisible);
1871 myHighlitableActor->GetExtractUnstructuredGrid()->
1872 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1873 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1875 myHighlitableActor->SetVisibility(anIsVisible);
1878 case SMESH_DeviceActor::ePoint:
1880 if(myIsHighlighted) {
1881 myNodeActor->SetProperty(myHighlightProp);
1882 }else if(myIsPreselected) {
1883 myNodeActor->SetProperty(myPreselectProp);
1884 } else if(anIsVisible) {
1885 myNodeActor->SetProperty(myNodeProp);
1887 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1888 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1894 void SMESH_ActorDef::EnableSelection( bool enable )
1896 // selection in the Viewer enabled/disabled
1897 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1899 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1900 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1901 myBaseActor->myExtractUnstructuredGrid->Update();
1902 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1904 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1906 myBaseActor->SetUnstructuredGrid( NULL );
1907 //myHighlitableActor->SetUnstructuredGrid( NULL );
1908 myBaseActor->myExtractUnstructuredGrid->Update();
1909 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1913 void SMESH_ActorDef::highlight(bool theHighlight)
1915 if ( myIsHighlighted == theHighlight )
1917 myIsHighlighted = theHighlight;
1922 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1924 if ( myIsPreselected == thePreselect )
1926 myIsPreselected = thePreselect;
1932 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1934 if (myPickableActor->GetIsOpaque())
1936 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1944 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1946 if (!myPickableActor->GetIsOpaque())
1948 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1956 void SMESH_ActorDef::Render(vtkRenderer *ren)
1958 unsigned long aTime = myTimeStamp->GetMTime();
1959 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1960 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1961 if(anObjTime > aTime || aClippingTime > aTime)
1966 void SMESH_ActorDef::Update()
1968 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1970 myVisualObj->Update();
1972 if(GetControlMode() != eNone) {
1973 unsigned long aTime = myTimeStamp->GetMTime();
1974 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1975 if (anObjTime > aTime)
1976 SetControlMode(GetControlMode(),false);
1980 myNodeActor->UpdateLabels();
1983 my0DActor->UpdateLabels();
1986 myBallActor->UpdateLabels();
1989 my1DActor->UpdateLabels();
1992 my2DActor->UpdateLabels();
1995 my3DActor->UpdateLabels();
1997 if(myIsFacesOriented){
1998 SetFacesOriented(myIsFacesOriented);
2001 if(myVisualObj->GetEntitiesFlag()) {
2002 myEntityMode |= myVisualObj->GetEntitiesState();
2005 SetEntityMode(GetEntityMode());
2006 SetVisibility(GetVisibility());
2008 myTimeStamp->Modified();
2013 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2015 SALOME_Actor::ReleaseGraphicsResources(renWin);
2017 myPickableActor->ReleaseGraphicsResources(renWin);
2021 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2023 double* aColor = theProperty->GetColor();
2030 void SMESH_ActorDef::SetOpacity(double theValue)
2032 mySurfaceProp->SetOpacity(theValue);
2033 myBackSurfaceProp->SetOpacity(theValue);
2034 myNormalVProp->SetOpacity(theValue);
2035 myReversedVProp->SetOpacity(theValue);
2036 myEdgeProp->SetOpacity(theValue);
2037 myOutLineProp->SetOpacity(theValue);
2038 myNodeProp->SetOpacity(theValue);
2040 my1DProp->SetOpacity(theValue);
2041 my0DProp->SetOpacity(theValue);
2042 myBallProp->SetOpacity(theValue);
2046 double SMESH_ActorDef::GetOpacity()
2048 return mySurfaceProp->GetOpacity();
2052 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2054 mySurfaceProp->SetColor(r,g,b);
2055 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2056 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2057 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2058 myNameActor->SetBackgroundColor(r,g,b);
2060 myDeltaBrightness = delta;
2061 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2062 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2066 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2068 ::GetColor(mySurfaceProp,r,g,b);
2069 delta = myDeltaBrightness;
2072 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2074 myNormalVProp->SetColor(r,g,b);
2075 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2076 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2077 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2078 myNameActor->SetBackgroundColor(r,g,b);
2080 myDeltaVBrightness = delta;
2081 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2082 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2086 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2088 ::GetColor(myNormalVProp,r,g,b);
2089 delta = myDeltaVBrightness;
2092 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2094 myEdgeProp->SetColor(r,g,b);
2095 my1DProp->SetColor(r,g,b);
2096 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2097 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2098 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2099 myNameActor->SetBackgroundColor(r,g,b);
2103 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2105 ::GetColor(myEdgeProp,r,g,b);
2108 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2110 myOutLineProp->SetColor(r,g,b);
2114 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2116 ::GetColor(myOutLineProp,r,g,b);
2120 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2122 myNodeProp->SetColor(r,g,b);
2123 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2124 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2125 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2126 myNameActor->SetBackgroundColor(r,g,b);
2130 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2132 ::GetColor(myNodeProp,r,g,b);
2135 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2137 my0DProp->SetColor(r,g,b);
2138 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2139 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2140 myNameActor->SetBackgroundColor(r,g,b);
2144 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2146 ::GetColor(my0DProp,r,g,b);
2149 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2151 myBallProp->SetColor(r,g,b);
2152 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2153 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2154 myNameActor->SetBackgroundColor(r,g,b);
2158 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2160 ::GetColor(myBallProp,r,g,b);
2163 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2165 myHighlightProp->SetColor(r,g,b);
2169 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2171 ::GetColor(myHighlightProp,r,g,b);
2174 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2176 myPreselectProp->SetColor(r,g,b);
2180 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2182 ::GetColor(myPreselectProp,r,g,b);
2186 double SMESH_ActorDef::GetLineWidth()
2188 return myEdgeProp->GetLineWidth();
2192 void SMESH_ActorDef::SetLineWidth(double theVal)
2194 myEdgeProp->SetLineWidth(theVal);
2196 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2197 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2198 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2199 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2200 myOutLineProp->SetLineWidth(theVal);
2201 myHighlightProp->SetLineWidth(theVal);
2202 myPreselectProp->SetLineWidth(theVal);
2206 double SMESH_ActorDef::GetOutlineWidth()
2208 return myOutLineProp->GetLineWidth();
2211 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2213 myOutLineProp->SetLineWidth(theVal);
2217 void SMESH_ActorDef::Set0DSize(double theVal)
2219 my0DProp->SetPointSize(theVal);
2220 myHighlightProp->SetPointSize(theVal);
2221 myPreselectProp->SetPointSize(theVal);
2223 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2224 aCustom->Set0DSize(theVal);
2226 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2227 aCustom->Set0DSize(theVal);
2233 double SMESH_ActorDef::Get0DSize()
2235 return my0DProp->GetPointSize();
2238 void SMESH_ActorDef::SetBallSize(double theVal)
2240 myBallProp->SetPointSize(theVal);
2242 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2243 aCustom->SetBallSize(theVal);
2245 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2246 aCustom->SetBallSize(theVal);
2252 double SMESH_ActorDef::GetBallSize()
2254 return myBallProp->GetPointSize();
2257 double SMESH_ActorDef::GetBallScale()
2259 return myBallActor->GetBallScale();
2262 void SMESH_ActorDef::SetBallScale( double theVal )
2264 myBallActor->SetBallScale( theVal );
2265 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2266 aCustom->SetBallScale(theVal);
2268 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2269 aCustom->SetBallScale(theVal);
2275 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2277 return myVisualObj->GetElemDimension( theObjId );
2280 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2282 return myBaseActor->IsImplicitFunctionUsed();
2285 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2287 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2288 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2290 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2292 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2294 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2295 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2296 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2298 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2299 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2301 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2302 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2303 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2304 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2307 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2310 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2311 myCippingPlaneCont.push_back(thePlane);
2312 if(!IsImplicitFunctionUsed())
2313 SetImplicitFunctionUsed(true);
2314 myNodeActor->UpdateLabels();
2316 return myCippingPlaneCont.size();
2319 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2322 myPlaneCollection->AddItem( thePlane );
2325 void SMESH_ActorDef::SetOpenGLClippingPlane()
2327 // before use this method you must add clipping planes using method
2328 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2329 if( !myPlaneCollection->GetNumberOfItems() )
2332 // It is necessary to set plane collection for each mapper of actor
2333 // and update current inputs of mapper
2334 myNodeActor->SetPlaneCollection( myPlaneCollection );
2335 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2337 myBaseActor->SetPlaneCollection( myPlaneCollection );
2338 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2340 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2341 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2343 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2345 myBaseActor->SetUnstructuredGrid( NULL );
2346 //myHighlitableActor->SetUnstructuredGrid( NULL );
2348 my1DActor->SetPlaneCollection( myPlaneCollection );
2349 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2351 my2DActor->SetPlaneCollection( myPlaneCollection );
2352 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2354 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2355 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2357 my0DActor->SetPlaneCollection( myPlaneCollection );
2358 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2360 myBallActor->SetPlaneCollection( myPlaneCollection );
2361 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2363 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2364 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2366 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2367 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2369 my3DActor->SetPlaneCollection( myPlaneCollection );
2370 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2372 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2373 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2381 void SMESH_ActorDef::RemoveAllClippingPlanes()
2383 myPlaneCollection->RemoveAllItems();
2384 myImplicitBoolean->GetFunction()->RemoveAllItems();
2385 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2386 myCippingPlaneCont.clear();
2387 SetImplicitFunctionUsed(false);
2388 myNodeActor->UpdateLabels();
2391 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2393 return myCippingPlaneCont.size();
2396 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2398 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2400 return myCippingPlaneCont[theID].Get();
2403 void SMESH_ActorDef::UpdateScalarBar()
2405 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2409 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2411 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2412 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2414 aScalarBarTitleProp->SetFontFamilyToArial();
2416 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2418 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2419 if ( f.family() == "Arial" )
2420 aScalarBarTitleProp->SetFontFamilyToArial();
2421 else if ( f.family() == "Courier" )
2422 aScalarBarTitleProp->SetFontFamilyToCourier();
2423 else if ( f.family() == "Times" )
2424 aScalarBarTitleProp->SetFontFamilyToTimes();
2427 aScalarBarTitleProp->BoldOn();
2429 aScalarBarTitleProp->BoldOff();
2432 aScalarBarTitleProp->ItalicOn();
2434 aScalarBarTitleProp->ItalicOff();
2437 aScalarBarTitleProp->ShadowOn();
2439 aScalarBarTitleProp->ShadowOff();
2442 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2443 aScalarBarTitleProp->Delete();
2445 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2447 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2448 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2450 aScalarBarLabelProp->SetFontFamilyToArial();
2451 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2453 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2454 if( f.family() == "Arial" )
2455 aScalarBarLabelProp->SetFontFamilyToArial();
2456 else if( f.family() == "Courier" )
2457 aScalarBarLabelProp->SetFontFamilyToCourier();
2458 else if( f.family() == "Times" )
2459 aScalarBarLabelProp->SetFontFamilyToTimes();
2462 aScalarBarLabelProp->BoldOn();
2464 aScalarBarLabelProp->BoldOff();
2467 aScalarBarLabelProp->ItalicOn();
2469 aScalarBarLabelProp->ItalicOff();
2472 aScalarBarLabelProp->ShadowOn();
2474 aScalarBarLabelProp->ShadowOff();
2477 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2478 aScalarBarLabelProp->Delete();
2480 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2481 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2483 myScalarBarActor->SetOrientationToHorizontal();
2485 myScalarBarActor->SetOrientationToVertical();
2488 double aXVal = horiz ? 0.20 : 0.01;
2489 if( mgr->hasValue( "SMESH", name + "x" ) )
2490 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2492 double aYVal = horiz ? 0.01 : 0.1;
2493 if( mgr->hasValue( "SMESH", name + "y" ) )
2494 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2495 myScalarBarActor->SetPosition( aXVal, aYVal );
2497 double aWVal = horiz ? 0.60 : 0.10;
2498 if( mgr->hasValue( "SMESH", name + "width" ) )
2499 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2500 myScalarBarActor->SetWidth( aWVal );
2502 double aHVal = horiz ? 0.12 : 0.80;
2503 if( mgr->hasValue( "SMESH", name + "height" ) )
2504 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2505 myScalarBarActor->SetHeight( aHVal );
2508 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2509 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2510 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2513 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2514 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2515 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2517 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2518 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2520 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2521 myScalarBarActor->SetDistributionColoringType(coloringType);
2523 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2524 QColor(255, 255, 255));
2526 rgb[0]= distributionColor.red()/255.;
2527 rgb[1]= distributionColor.green()/255.;
2528 rgb[2]= distributionColor.blue()/255.;
2529 myScalarBarActor->SetDistributionColor(rgb);
2534 void SMESH_ActorDef::UpdateDistribution()
2536 if(SMESH::Controls::NumericalFunctor* fun =
2537 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2539 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2540 std::vector<int> nbEvents;
2541 std::vector<double> funValues;
2542 SMESH_VisualObjDef::TEntityList elems;
2543 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2544 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2545 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2546 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2547 elemIds.push_back( (*e)->GetID());
2548 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2549 double * range = lookupTable->GetRange();
2550 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2551 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2552 myScalarBarActor->SetDistribution(nbEvents);
2556 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2559 case SMESH_Actor::eLines :
2560 myHighlitableActor->SetQuadraticArcMode(false);
2561 my2DActor->SetQuadraticArcMode(false);
2562 my1DActor->SetQuadraticArcMode(false);
2564 case SMESH_Actor::eArcs :
2565 myHighlitableActor->SetQuadraticArcMode(true);
2566 if(GetRepresentation() != SMESH_Actor::ePoint) {
2567 my2DActor->SetQuadraticArcMode(true);
2568 my1DActor->SetQuadraticArcMode(true);
2577 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2579 if(myHighlitableActor->GetQuadraticArcMode())
2580 return SMESH_Actor::eArcs;
2582 return SMESH_Actor::eLines;
2585 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2587 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2588 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2589 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2592 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2594 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2595 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2596 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2597 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2600 #ifndef DISABLE_PLOT2DVIEWER
2601 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2604 my2dHistogram->clearAllPoints();
2606 if(SMESH::Controls::NumericalFunctor* fun =
2607 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2610 if(!my2dHistogram) {
2611 my2dHistogram = new SPlot2d_Histogram();
2612 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2613 my2dHistogram->setIO(anIO);
2616 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2617 std::vector<int> nbEvents;
2618 std::vector<double> funValues;
2619 SMESH_VisualObjDef::TEntityList elems;
2620 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2621 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2622 std::vector<int> elemIds;
2624 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2625 elemIds.push_back( (*e)->GetID());
2627 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2628 double * range = lookupTable->GetRange();
2629 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2630 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2632 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2633 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2635 if(funValues.size() >= 2)
2636 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2640 //Color of the histogram
2641 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2642 my2dHistogram->setAutoAssign(true);
2645 myScalarBarActor->GetDistributionColor(rgb);
2646 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2647 my2dHistogram->setColor(aColor);
2651 return my2dHistogram;