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;
129 myRepresentationCache = 0;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Delete(); // vtkSmartPointer!
133 myHighlightActor->Initialize();
135 myPreHighlightActor = SMESH_SVTKActor::New();
136 myPreHighlightActor->Delete();
137 myPreHighlightActor->Initialize();
139 myIsShrinkable = false;
142 myIsFacesOriented = false;
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 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
151 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152 double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
153 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
154 double aOutlineWidth = 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->SetColor(anRGB[0],anRGB[1],anRGB[2]);
245 my2DExtActor = SMESH_DeviceActor::New();
246 my2DExtActor->SetUserMatrix(aMatrix);
247 my2DExtActor->PickableOff();
248 my2DExtActor->SetProperty(my2DExtProp);
249 my2DExtActor->SetBackfaceProperty(my2DExtProp);
250 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
251 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
252 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
253 aFilter->RegisterCellsWithType(VTK_QUAD);
254 aFilter->RegisterCellsWithType(VTK_POLYGON);
255 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
257 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
258 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
259 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
261 my3DActor = SMESH_CellLabelActor::New();
262 my3DActor->SetStoreClippingMapping(true);
263 my3DActor->SetUserMatrix(aMatrix);
264 my3DActor->PickableOff();
265 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
266 my3DActor->SetProperty(myNormalVProp);
267 my3DActor->SetBackfaceProperty(myReversedVProp);
268 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
269 my3DActor->SetCoincident3DAllowed(true);
270 aFilter = my3DActor->GetExtractUnstructuredGrid();
271 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
272 aFilter->RegisterCellsWithType(VTK_TETRA);
273 aFilter->RegisterCellsWithType(VTK_VOXEL);
274 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
275 aFilter->RegisterCellsWithType(VTK_WEDGE);
276 aFilter->RegisterCellsWithType(VTK_PYRAMID);
277 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
280 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
281 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
282 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
283 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
284 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
285 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
287 my3DExtProp = vtkProperty::New();
288 my3DExtProp->DeepCopy(myNormalVProp);
289 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
290 anRGB[0] = 1 - anRGB[0];
291 anRGB[1] = 1 - anRGB[1];
292 anRGB[2] = 1 - anRGB[2];
293 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
295 my3DExtActor = SMESH_DeviceActor::New();
296 my3DExtActor->SetUserMatrix(aMatrix);
297 my3DExtActor->PickableOff();
298 my3DExtActor->SetProperty(my3DExtProp);
299 my3DExtActor->SetBackfaceProperty(my3DExtProp);
300 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
301 my3DExtActor->SetCoincident3DAllowed(true);
302 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
303 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
304 aFilter->RegisterCellsWithType(VTK_TETRA);
305 aFilter->RegisterCellsWithType(VTK_VOXEL);
306 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
307 aFilter->RegisterCellsWithType(VTK_WEDGE);
308 aFilter->RegisterCellsWithType(VTK_PYRAMID);
309 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
311 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
312 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
314 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
315 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
316 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
317 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
319 //Definition 1D device of the actor
320 //---------------------------------
321 myEdgeProp = vtkProperty::New();
322 myEdgeProp->SetAmbient(1.0);
323 myEdgeProp->SetDiffuse(0.0);
324 myEdgeProp->SetSpecular(0.0);
325 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
326 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
327 myEdgeProp->SetLineWidth(aLineWidth);
329 // my1DActor is used to
331 // - show controls on all edges (eg Length)
332 // since edges are shown by myHighlitableActor
333 my1DActor = SMESH_CellLabelActor::New();
334 my1DActor->SetStoreClippingMapping(true);
335 my1DActor->SetUserMatrix(aMatrix);
336 my1DActor->PickableOff();
337 my1DActor->SetHighlited(true);
338 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
339 my1DActor->SetProperty(myEdgeProp);
340 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
341 aFilter = my1DActor->GetExtractUnstructuredGrid();
342 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
343 aFilter->RegisterCellsWithType(VTK_LINE);
344 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
346 my1DProp = vtkProperty::New();
347 my1DProp->DeepCopy(myEdgeProp);
348 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
349 my1DProp->SetPointSize(aElem0DSize);
351 my1DExtProp = vtkProperty::New();
352 my1DExtProp->DeepCopy(myEdgeProp);
353 anRGB[0] = 1 - anRGB[0];
354 anRGB[1] = 1 - anRGB[1];
355 anRGB[2] = 1 - anRGB[2];
356 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
357 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
358 my1DExtProp->SetPointSize(aElem0DSize);
360 // my1DExtActor is used to show filtered edges or links between nodes
361 my1DExtActor = SMESH_DeviceActor::New();
362 my1DExtActor->SetUserMatrix(aMatrix);
363 my1DExtActor->PickableOff();
364 my1DExtActor->SetHighlited(true);
365 my1DExtActor->SetVisibility(false);
366 my1DExtActor->SetProperty(my1DExtProp);
367 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
368 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
369 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
370 aFilter->RegisterCellsWithType(VTK_LINE);
371 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
374 //Definition 0D device of the actor (0d elements)
375 //-----------------------------------------------
376 my0DProp = vtkProperty::New();
377 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
378 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 my0DProp->SetPointSize(aElem0DSize);
381 my0DActor = SMESH_CellLabelActor::New();
382 my0DActor->SetUserMatrix(aMatrix);
383 my0DActor->SetStoreClippingMapping(true);
384 my0DActor->PickableOff();
385 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
386 my0DActor->SetVisibility(false);
387 my0DActor->SetProperty(my0DProp);
388 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
389 aFilter = my0DActor->GetExtractUnstructuredGrid();
390 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
391 aFilter->RegisterCellsWithType(VTK_VERTEX);
393 //Definition 0D device of the actor (ball elements)
394 //-----------------------------------------------
395 myBallProp = vtkProperty::New();
396 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
397 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
398 myBallProp->SetPointSize(aBallElemSize);
400 myBallActor = SMESH_CellLabelActor::New();
401 myBallActor->SetUserMatrix(aMatrix);
402 myBallActor->SetStoreClippingMapping(true);
403 myBallActor->PickableOff();
404 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
405 myBallActor->SetVisibility(false);
406 myBallActor->SetProperty(myBallProp);
407 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
408 myBallActor->SetBallEnabled(true);
409 aFilter = myBallActor->GetExtractUnstructuredGrid();
410 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
411 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
413 //my0DExtProp = vtkProperty::New();
414 //my0DExtProp->DeepCopy(my0DProp);
415 //anRGB[0] = 1 - anRGB[0];
416 //anRGB[1] = 1 - anRGB[1];
417 //anRGB[2] = 1 - anRGB[2];
418 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
419 //my0DExtProp->SetPointSize(aElem0DSize);
421 //my0DExtActor = SMESH_DeviceActor::New();
422 //my0DExtActor->SetUserMatrix(aMatrix);
423 //my0DExtActor->SetStoreClippingMapping(true);
424 //my0DExtActor->PickableOff();
425 //my0DExtActor->SetHighlited(true);
426 //my0DExtActor->SetVisibility(false);
427 //my0DExtActor->SetProperty(my0DExtProp);
428 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
429 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
430 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
431 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
432 //aFilter->RegisterCellsWithType(VTK_VERTEX);
435 //Definition 0D device of the actor (nodes)
436 //-----------------------------------------
437 myNodeProp = vtkProperty::New();
438 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
439 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
441 myNodeActor = SMESH_NodeLabelActor::New();
442 myNodeActor->SetUserMatrix(aMatrix);
443 myNodeActor->SetStoreClippingMapping(true);
444 myNodeActor->PickableOff();
445 myNodeActor->SetVisibility(false);
446 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
447 myNodeActor->SetProperty(myNodeProp);
448 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
449 aFilter = myNodeActor->GetExtractUnstructuredGrid();
450 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
452 myNodeExtProp = vtkProperty::New();
453 myNodeExtProp->DeepCopy(myNodeProp);
454 anRGB[0] = 1 - anRGB[0];
455 anRGB[1] = 1 - anRGB[1];
456 anRGB[2] = 1 - anRGB[2];
457 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
459 myNodeExtActor = SMESH_DeviceActor::New();
460 myNodeExtActor->SetUserMatrix(aMatrix);
461 myNodeExtActor->SetStoreClippingMapping(true);
462 myNodeExtActor->PickableOff();
463 myNodeExtActor->SetHighlited(true);
464 myNodeExtActor->SetVisibility(false);
465 myNodeExtActor->SetProperty(myNodeExtProp);
466 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
467 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
468 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
469 aFilter->RegisterCellsWithType(VTK_VERTEX);
471 //Definition of Pickable and Highlitable engines
472 //----------------------------------------------
474 myBaseActor->SetUserMatrix(aMatrix);
475 myBaseActor->SetStoreIDMapping(true);
476 myBaseActor->SetStoreClippingMapping(true);
477 myBaseActor->SetStoreGemetryMapping(true);
478 myBaseActor->GetProperty()->SetOpacity(0.0);
479 myPickableActor = myBaseActor;
481 myHighlightProp = vtkProperty::New();
482 myHighlightProp->SetAmbient(1.0);
483 myHighlightProp->SetDiffuse(0.0);
484 myHighlightProp->SetSpecular(0.0);
485 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
486 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
487 myHighlightProp->SetPointSize(aElem0DSize); // ??
488 myHighlightProp->SetLineWidth(aLineWidth);
489 myHighlightProp->SetRepresentation(1);
491 myOutLineProp = vtkProperty::New();
492 myOutLineProp->SetAmbient(1.0);
493 myOutLineProp->SetDiffuse(0.0);
494 myOutLineProp->SetSpecular(0.0);
495 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
496 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
497 myOutLineProp->SetLineWidth(aOutlineWidth);
498 myOutLineProp->SetRepresentation(1);
500 myPreselectProp = vtkProperty::New();
501 myPreselectProp->SetAmbient(1.0);
502 myPreselectProp->SetDiffuse(0.0);
503 myPreselectProp->SetSpecular(0.0);
504 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
505 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
506 myPreselectProp->SetPointSize(aElem0DSize); // ??
507 myPreselectProp->SetLineWidth(aLineWidth);
508 myPreselectProp->SetRepresentation(1);
510 myHighlitableActor = SMESH_DeviceActor::New();
511 myHighlitableActor->SetUserMatrix(aMatrix);
512 myHighlitableActor->PickableOff();
513 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
514 myHighlitableActor->SetCoincident3DAllowed(true);
521 myControlMode = eNone;
522 myControlActor = my2DActor;
524 //Definition of myScalarBarActor
525 //------------------------------
526 myLookupTable = vtkLookupTable::New();
527 //Fix for Bug PAL5195 - SMESH764:
528 //Controls - Aspect Ratio: incorrect colors of the best and worst values
529 myLookupTable->SetHueRange(0.667,0.0);
531 myScalarBarActor = SMESH_ScalarBarActor::New();
532 myScalarBarActor->SetVisibility(false);
533 myScalarBarActor->SetLookupTable(myLookupTable);
536 //Incorrect "Min value" in Scalar Bar in Mesh:
537 // myScalarBarActor->SetLabelFormat("%.4g");
538 // changes was commented because of regression bug IPAL 19981
540 mgr = SUIT_Session::session()->resourceMgr();
544 myEntityMode = eAllEntity;
545 myEntityModeCache = eAllEntity;
548 myImplicitBoolean = vtkImplicitBoolean::New();
549 myImplicitBoolean->SetOperationTypeToIntersection();
551 myPlaneCollection = vtkPlaneCollection::New();
553 //Quadratic 2D elements representation
554 //-----------------------------------------------------------------------------
555 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
556 if(aQuadratic2DMode == 0){
557 myHighlitableActor->SetQuadraticArcMode(false);
558 my2DActor->SetQuadraticArcMode(false);
559 my1DActor->SetQuadraticArcMode(false);
561 else if(aQuadratic2DMode == 1){
562 myHighlitableActor->SetQuadraticArcMode(true);
563 my2DActor->SetQuadraticArcMode(true);
564 my1DActor->SetQuadraticArcMode(true);
567 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
568 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
569 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
571 // Set colors of the name actor
572 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
573 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
574 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
575 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
577 #ifndef DISABLE_PLOT2DVIEWER
581 SetBallSize(aBallElemSize);
582 SetBallScale(aBallElemScale);
583 Set0DSize(aElem0DSize);
587 SMESH_ActorDef::~SMESH_ActorDef()
589 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
591 // Please keep the order same as one in the header file
593 myTimeStamp->Delete();
595 myScalarBarActor->Delete();
596 myLookupTable->Delete();
598 mySurfaceProp->Delete();
599 myBackSurfaceProp->Delete();
600 myNormalVProp->Delete();
601 myReversedVProp->Delete();
602 myEdgeProp->Delete();
603 myNodeProp->Delete();
605 myNodeActor->Delete();
606 myBaseActor->Delete();
607 //myPickableActor->Delete(); myPickableActor == myBaseActor
609 myHighlightProp->Delete();
610 myOutLineProp->Delete();
611 myPreselectProp->Delete();
613 myHighlitableActor->Delete();
615 my2DExtProp->Delete();
616 my3DExtProp->Delete();
618 my2DExtActor->Delete();
620 my3DExtActor->Delete();
621 // myControlActor->Delete(); myControlActor == my2DActor
623 myNodeExtProp->Delete();
624 myNodeExtActor->Delete();
628 my1DExtProp->Delete();
629 my1DExtActor->Delete();
633 myBallProp->Delete();
634 myBallActor->Delete();
635 //my0DExtProp->Delete();
636 //my0DExtActor->Delete();
638 myImplicitBoolean->Delete();
639 myPlaneCollection->Delete();
641 #ifndef DISABLE_PLOT2DVIEWER
643 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
644 delete my2dHistogram;
649 void SMESH_ActorDef::Delete()
651 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
652 // from the actor's destructor) will be thrown before removing the actor's observers,
653 // that is done inside the Superclass::Delete() method but before the destructor itself
654 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
655 // The event is caught by SMESHGUI::ProcessEvents() static method.
656 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
658 Superclass::Delete();
661 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
664 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
665 SetRepresentation(GetRepresentation());
666 myTimeStamp->Modified();
670 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
671 bool theBold, bool theItalic, bool theShadow,
672 double r, double g, double b )
675 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
676 SetRepresentation( GetRepresentation() );
677 myTimeStamp->Modified();
681 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
682 bool theBold, bool theItalic, bool theShadow,
683 double r, double g, double b )
686 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
689 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
690 SetRepresentation( GetRepresentation() );
691 myTimeStamp->Modified();
694 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
695 SetRepresentation( GetRepresentation() );
696 myTimeStamp->Modified();
699 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
700 SetRepresentation( GetRepresentation() );
701 myTimeStamp->Modified();
704 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
705 SetRepresentation( GetRepresentation() );
706 myTimeStamp->Modified();
710 bool SMESH_ActorDef::GetPointsLabeled()
712 return myNodeActor && myNodeActor->GetPointsLabeled();
715 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
718 my3DActor->SetCellsLabeled(theIsCellsLabeled);
721 my2DActor->SetCellsLabeled(theIsCellsLabeled);
724 my1DActor->SetCellsLabeled(theIsCellsLabeled);
727 my0DActor->SetCellsLabeled(theIsCellsLabeled);
730 myBallActor->SetCellsLabeled(theIsCellsLabeled);
732 myTimeStamp->Modified();
736 bool SMESH_ActorDef::GetCellsLabeled()
740 result = result || my3DActor->GetCellsLabeled();
743 result = result || my2DActor->GetCellsLabeled();
746 result = result || my1DActor->GetCellsLabeled();
749 result = result || my0DActor->GetCellsLabeled();
752 result = result || myBallActor->GetCellsLabeled();
758 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
760 myIsFacesOriented = theIsFacesOriented;
762 my2DActor->SetFacesOriented(theIsFacesOriented);
763 my3DActor->SetFacesOriented(theIsFacesOriented);
765 myTimeStamp->Modified();
768 bool SMESH_ActorDef::GetFacesOriented()
770 return myIsFacesOriented;
773 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
775 my2DActor->SetFacesOrientationColor( r, g, b );
776 my3DActor->SetFacesOrientationColor( r, g, b );
779 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
781 my3DActor->GetFacesOrientationColor( r, g, b );
784 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
786 my2DActor->SetFacesOrientationScale( theScale );
787 my3DActor->SetFacesOrientationScale( theScale );
790 double SMESH_ActorDef::GetFacesOrientationScale()
792 return my3DActor->GetFacesOrientationScale();
795 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
797 my2DActor->SetFacesOrientation3DVectors( theState );
798 my3DActor->SetFacesOrientation3DVectors( theState );
801 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
803 return my3DActor->GetFacesOrientation3DVectors();
807 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
809 myFunctor = theFunctor;
811 SetControlMode( eNone, true );
813 SetControlMode( eCustomControl, true );
816 void SMESH_ActorDef::SetControlMode(eControl theMode)
818 SetControlMode(theMode,true);
821 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
823 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
824 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
825 lookupTable->SetScale(VTK_SCALE_LINEAR);
827 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
831 //myControlMode = eNone;
832 myControlMode = theMode;
833 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
835 my0DActor->GetMapper()->SetScalarVisibility(false);
836 my1DActor->GetMapper()->SetScalarVisibility(false);
837 my2DActor->GetMapper()->SetScalarVisibility(false);
838 my3DActor->GetMapper()->SetScalarVisibility(false);
839 myBallActor->GetMapper()->SetScalarVisibility(false);
840 myScalarBarActor->SetVisibility(false);
842 bool anIsScalarVisible = theMode > eNone;
844 if(anIsScalarVisible) {
848 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
849 aControl->SetPrecision( myControlsPrecision );
850 myFunctor.reset( aControl );
851 myControlActor = my1DActor;
855 myFunctor.reset(new SMESH::Controls::Length2D());
856 myControlActor = my2DActor;
859 myFunctor.reset(new SMESH::Controls::FreeBorders());
860 myControlActor = my1DActor;
863 myFunctor.reset(new SMESH::Controls::FreeEdges());
864 myControlActor = my2DActor;
867 myFunctor.reset(new SMESH::Controls::FreeNodes());
868 myControlActor = myNodeActor;
871 myFunctor.reset(new SMESH::Controls::FreeFaces());
872 myControlActor = my2DActor;
874 case eCoincidentNodes:
876 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
877 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
878 cn->SetTolerance( tol );
880 myControlActor = myNodeActor;
883 case eCoincidentElems1D:
884 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
885 myControlActor = my1DActor;
887 case eCoincidentElems2D:
888 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
889 myControlActor = my2DActor;
891 case eCoincidentElems3D:
892 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
893 myControlActor = my3DActor;
895 case eBareBorderFace:
896 myFunctor.reset(new SMESH::Controls::BareBorderFace());
897 myControlActor = my2DActor;
899 case eOverConstrainedFace:
900 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
901 myControlActor = my2DActor;
903 case eMultiConnection:
904 myFunctor.reset(new SMESH::Controls::MultiConnection());
905 myControlActor = my1DActor;
907 case eMultiConnection2D:
908 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
909 myControlActor = my2DActor;
913 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
914 aControl->SetPrecision( myControlsPrecision );
915 myFunctor.reset( aControl );
916 myControlActor = my2DActor;
921 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
922 aControl->SetPrecision( myControlsPrecision );
923 myFunctor.reset( aControl );
924 myControlActor = my2DActor;
929 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
930 aControl->SetPrecision( myControlsPrecision );
931 myFunctor.reset( aControl );
932 myControlActor = my2DActor;
937 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
938 aControl->SetPrecision( myControlsPrecision );
939 myFunctor.reset( aControl );
940 myControlActor = my3DActor;
945 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
946 aControl->SetPrecision( myControlsPrecision );
947 myFunctor.reset( aControl );
948 myControlActor = my3DActor;
951 case eMaxElementLength2D:
953 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
954 aControl->SetPrecision( myControlsPrecision );
955 myFunctor.reset( aControl );
956 myControlActor = my2DActor;
959 case eMaxElementLength3D:
961 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
962 aControl->SetPrecision( myControlsPrecision );
963 myFunctor.reset( aControl );
964 myControlActor = my3DActor;
969 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
970 aControl->SetPrecision( myControlsPrecision );
971 myFunctor.reset( aControl );
972 myControlActor = my2DActor;
975 case eBareBorderVolume:
977 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
978 myControlActor = my3DActor;
981 case eOverConstrainedVolume:
983 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
984 myControlActor = my3DActor;
989 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
997 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
998 aControl->SetPrecision( myControlsPrecision );
999 myFunctor.reset( aControl );
1000 myControlActor = my2DActor;
1005 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1006 aControl->SetPrecision( myControlsPrecision );
1007 myFunctor.reset( aControl );
1008 myControlActor = my2DActor;
1011 case eNodeConnectivityNb:
1013 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1014 myControlActor = myNodeActor;
1017 case eCustomControl:
1021 switch ( myFunctor->GetType() ) {
1022 case SMDSAbs_Node : myControlActor = myNodeActor; break;
1023 case SMDSAbs_Edge : myControlActor = my1DActor; break;
1024 case SMDSAbs_Face : myControlActor = my2DActor; break;
1025 case SMDSAbs_Volume : myControlActor = my3DActor; break;
1034 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1035 bool aShowOnlyScalarBarTitle = false;
1037 //myControlMode = theMode;
1038 switch(myControlMode){
1040 case eCoincidentNodes:
1041 myNodeExtActor->SetExtControlMode(myFunctor);
1042 aShowOnlyScalarBarTitle = true;
1046 case eCoincidentElems1D:
1047 my1DExtActor->SetExtControlMode(myFunctor);
1048 aShowOnlyScalarBarTitle = true;
1051 case eBareBorderFace:
1052 case eOverConstrainedFace:
1053 case eCoincidentElems2D:
1054 my2DExtActor->SetExtControlMode(myFunctor);
1055 aShowOnlyScalarBarTitle = true;
1057 case eBareBorderVolume:
1058 case eOverConstrainedVolume:
1059 case eCoincidentElems3D:
1060 my3DExtActor->SetExtControlMode(myFunctor);
1061 aShowOnlyScalarBarTitle = true;
1064 case eMultiConnection2D:
1065 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1066 UpdateDistribution();
1069 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1070 UpdateDistribution();
1072 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1075 if(theCheckEntityMode) {
1076 // if(myControlActor == myNodeActor) {
1077 // if ( myControlMode == eNodeConnectivityNb ) {
1078 // if (!myIsEntityModeCache){
1079 // myEntityModeCache = GetEntityMode();
1080 // myIsEntityModeCache=true;
1082 // SetEntityMode(0);
1085 if(myControlActor == my1DActor) {
1086 if (!myIsEntityModeCache){
1087 myEntityModeCache = GetEntityMode();
1088 myIsEntityModeCache=true;
1090 SetEntityMode(eEdges);
1092 else if(myControlActor == my2DActor) {
1093 if (!myIsEntityModeCache){
1094 myEntityModeCache = GetEntityMode();
1095 myIsEntityModeCache=true;
1097 SetEntityMode(eFaces);
1099 else if(myControlActor == my3DActor) {
1100 if (!myIsEntityModeCache){
1101 myEntityModeCache = GetEntityMode();
1102 myIsEntityModeCache=true;
1104 SetEntityMode(eVolumes);
1107 QString aTitle = QString(myScalarBarActor->GetTitle());
1108 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1109 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1113 if(theCheckEntityMode){
1114 myEntityMode = myEntityModeCache;
1115 myIsEntityModeCache = false;
1120 SetRepresentation(GetRepresentation());
1122 myTimeStamp->Modified();
1125 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1126 double * range = lookupTable->GetRange();
1128 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1129 lookupTable->SetScale(VTK_SCALE_LOG10);
1134 int SMESH_ActorDef::GetNumberControlEntities()
1136 SMESH_DeviceActor* anAct = NULL;
1137 switch(myControlMode){
1139 case eCoincidentNodes:
1140 anAct = myNodeExtActor;
1144 case eCoincidentElems1D:
1145 anAct = my1DExtActor;
1148 case eBareBorderFace:
1149 case eOverConstrainedFace:
1150 case eCoincidentElems2D:
1151 anAct = my2DExtActor;
1153 case eBareBorderVolume:
1154 case eOverConstrainedVolume:
1155 case eCoincidentElems3D:
1156 anAct = my3DExtActor;
1160 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1163 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1165 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1167 myBaseActor->SetUnstructuredGrid( NULL );
1168 //myHighlitableActor->SetUnstructuredGrid( NULL );
1170 theRenderer->AddActor(myBaseActor);
1171 theRenderer->AddActor(myNodeExtActor);
1172 theRenderer->AddActor(my1DExtActor);
1174 my3DActor ->AddToRender(theRenderer);
1175 my3DExtActor->AddToRender(theRenderer);
1176 my2DActor ->AddToRender(theRenderer);
1177 my2DExtActor->AddToRender(theRenderer);
1178 myNodeActor ->AddToRender(theRenderer);
1179 my1DActor ->AddToRender(theRenderer);
1180 my0DActor ->AddToRender(theRenderer);
1181 myBallActor ->AddToRender(theRenderer);
1183 theRenderer->AddActor(myHighlitableActor);
1185 theRenderer->AddActor2D(myScalarBarActor);
1187 // the superclass' method should be called at the end
1188 // (in particular, for correct work of selection)
1189 SALOME_Actor::AddToRender(theRenderer);
1192 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1194 SALOME_Actor::RemoveFromRender(theRenderer);
1196 theRenderer->RemoveActor(myBaseActor);
1198 theRenderer->RemoveActor(myNodeExtActor);
1200 theRenderer->RemoveActor(myHighlitableActor);
1202 //theRenderer->RemoveActor(my0DExtActor);
1204 theRenderer->RemoveActor(my1DExtActor);
1206 my2DActor->RemoveFromRender(theRenderer);
1207 my2DExtActor->RemoveFromRender(theRenderer);
1208 my3DActor->RemoveFromRender(theRenderer);
1209 my3DExtActor->RemoveFromRender(theRenderer);
1210 myNodeActor->RemoveFromRender(theRenderer);
1211 my0DActor->RemoveFromRender(theRenderer);
1212 myBallActor->RemoveFromRender(theRenderer);
1213 my1DActor->RemoveFromRender(theRenderer);
1215 theRenderer->RemoveActor(myScalarBarActor);
1219 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1220 const char* theEntry,
1221 const char* theName,
1224 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1228 myVisualObj = theVisualObj;
1229 myVisualObj->Update(theIsClear);
1231 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1232 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1234 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1235 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1237 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1239 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1241 my0DActor->Init(myVisualObj,myImplicitBoolean);
1242 myBallActor->Init(myVisualObj,myImplicitBoolean);
1243 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1245 my1DActor->Init(myVisualObj,myImplicitBoolean);
1246 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1248 my2DActor->Init(myVisualObj,myImplicitBoolean);
1249 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1250 my3DActor->Init(myVisualObj,myImplicitBoolean);
1251 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1253 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1254 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1255 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1257 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1258 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1260 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1261 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1262 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1263 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1265 double aFactor, aUnits;
1266 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1267 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1268 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1269 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1271 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1275 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1276 SetIsShrunkable(true);
1278 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1280 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1281 SetRepresentation(-1);
1284 SetRepresentation(eEdge);
1285 }else if(aMode == 1){
1286 SetRepresentation(eSurface);
1287 }else if(aMode == 2){
1288 SetRepresentation(ePoint);
1295 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1296 SetIsDisplayNameActor( true );
1298 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1299 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1300 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1302 myTimeStamp->Modified();
1308 double* SMESH_ActorDef::GetBounds()
1310 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1311 return myNodeActor->GetBounds();
1312 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1316 vtkDataSet* SMESH_ActorDef::GetInput()
1318 return GetUnstructuredGrid();
1322 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1324 Superclass::SetTransform(theTransform);
1326 myNodeActor->SetTransform(theTransform);
1327 myBaseActor->SetTransform(theTransform);
1329 myHighlitableActor->SetTransform(theTransform);
1331 myNodeExtActor->SetTransform(theTransform);
1333 my0DActor->SetTransform(theTransform);
1334 myBallActor->SetTransform(theTransform);
1335 //my0DExtActor->SetTransform(theTransform);
1337 my1DActor->SetTransform(theTransform);
1338 my1DExtActor->SetTransform(theTransform);
1340 my2DActor->SetTransform(theTransform);
1341 my2DExtActor->SetTransform(theTransform);
1342 my3DActor->SetTransform(theTransform);
1343 my3DExtActor->SetTransform(theTransform);
1349 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1351 vtkLODActor::SetMapper(theMapper);
1355 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1357 SALOME_Actor::ShallowCopy(prop);
1361 vtkMapper* SMESH_ActorDef::GetMapper()
1363 return myPickableActor->GetMapper();
1367 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1369 return myVisualObj->GetUnstructuredGrid();
1373 bool SMESH_ActorDef::IsInfinitive()
1375 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1376 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1377 ( aDataSet->GetNumberOfCells() == 1 &&
1378 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1379 return SALOME_Actor::IsInfinitive();
1383 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1385 if ( myIsShrinkable == theShrunkable )
1387 myIsShrinkable = theShrunkable;
1391 double SMESH_ActorDef::GetShrinkFactor()
1393 return myBaseActor->GetShrinkFactor();
1396 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1398 myBaseActor->SetShrinkFactor(theValue);
1400 my1DActor->SetShrinkFactor(theValue);
1401 my1DExtActor->SetShrinkFactor(theValue);
1403 my2DActor->SetShrinkFactor(theValue);
1404 my2DExtActor->SetShrinkFactor(theValue);
1405 my3DActor->SetShrinkFactor(theValue);
1406 my3DExtActor->SetShrinkFactor(theValue);
1407 my3DExtActor->SetShrinkFactor(theValue);
1408 myHighlitableActor->SetShrinkFactor(theValue);
1413 void SMESH_ActorDef::SetShrink()
1415 if(!myIsShrinkable) return;
1417 myBaseActor->SetShrink();
1419 my1DActor->SetShrink();
1420 my1DExtActor->SetShrink();
1422 my2DActor->SetShrink();
1423 my2DExtActor->SetShrink();
1424 my3DActor->SetShrink();
1425 my3DExtActor->SetShrink();
1426 myHighlitableActor->SetShrink();
1432 void SMESH_ActorDef::UnShrink()
1434 if(!myIsShrunk) return;
1436 myBaseActor->UnShrink();
1438 my1DActor->UnShrink();
1439 my1DExtActor->UnShrink();
1441 my2DActor->UnShrink();
1442 my2DExtActor->UnShrink();
1443 my3DActor->UnShrink();
1444 my3DExtActor->UnShrink();
1445 myHighlitableActor->UnShrink();
1452 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1454 return myPickableActor->GetNodeObjId(theVtkID);
1457 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1459 return myPickableActor->GetNodeCoord(theObjID);
1462 int SMESH_ActorDef::GetNodeVtkId(int theObjID)
1464 return myPickableActor->GetNodeVtkId(theObjID);
1467 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1469 return myPickableActor->GetElemObjId(theVtkID);
1472 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1474 return myPickableActor->GetElemCell(theObjID);
1478 void SMESH_ActorDef::SetVisibility(int theMode)
1480 SetVisibility(theMode,true);
1484 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1486 SALOME_Actor::SetVisibility(theMode);
1488 myNodeActor->VisibilityOff();
1489 myBaseActor->VisibilityOff();
1491 myNodeExtActor->VisibilityOff();
1493 my0DActor->VisibilityOff();
1494 myBallActor->VisibilityOff();
1495 //my0DExtActor->VisibilityOff();
1497 my1DActor->VisibilityOff();
1498 my1DExtActor->VisibilityOff();
1500 my2DActor->VisibilityOff();
1501 my2DExtActor->VisibilityOff();
1502 my3DActor->VisibilityOff();
1503 my3DExtActor->VisibilityOff();
1505 myScalarBarActor->VisibilityOff();
1507 if ( GetVisibility() ) {
1508 if ( theIsUpdateRepersentation )
1509 SetRepresentation(GetRepresentation());
1511 if(myControlMode != eNone) {
1512 switch(myControlMode) {
1514 case eCoincidentNodes:
1515 myNodeExtActor->VisibilityOn();
1518 case eMultiConnection:
1519 my1DActor->VisibilityOn();
1523 case eCoincidentElems1D:
1525 case eMultiConnection2D:
1526 my1DExtActor->VisibilityOn();
1529 case eBareBorderFace:
1530 case eOverConstrainedFace:
1531 case eCoincidentElems2D:
1532 my2DExtActor->VisibilityOn();
1534 case eBareBorderVolume:
1535 case eOverConstrainedVolume:
1536 case eCoincidentElems3D:
1537 my3DExtActor->VisibilityOn();
1541 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1542 myScalarBarActor->VisibilityOn();
1545 myPickableActor->VisibilityOn();
1547 if ( GetRepresentation() != ePoint )
1549 if(myEntityMode & e0DElements ){
1550 my0DActor->VisibilityOn();
1552 if(myEntityMode & eBallElem ){
1553 myBallActor->VisibilityOn();
1555 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1556 my1DActor->VisibilityOn();
1558 if(myEntityMode & eFaces ){
1559 my2DActor->VisibilityOn();
1561 if(myEntityMode & eVolumes ){
1562 my3DActor->VisibilityOn();
1566 if(myNodeActor->GetPointsLabeled()) {
1567 myNodeActor->UpdateLabels();
1568 myNodeActor->VisibilityOn();
1571 my0DActor->UpdateLabels();
1574 myBallActor->UpdateLabels();
1577 my1DActor->UpdateLabels();
1580 my2DActor->UpdateLabels();
1583 my3DActor->UpdateLabels();
1585 #ifndef DISABLE_PLOT2DVIEWER
1587 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1594 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1596 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1598 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1599 anObjectEntities &= ~e0DElements;
1600 theMode &= ~e0DElements;
1603 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1604 anObjectEntities &= ~eBallElem;
1605 theMode &= ~eBallElem;
1608 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1609 anObjectEntities &= ~eEdges;
1613 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1614 anObjectEntities &= ~eFaces;
1618 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1619 anObjectEntities &= ~eVolumes;
1620 theMode &= ~eVolumes;
1624 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1625 theMode |= e0DElements;
1627 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1628 theMode |= eBallElem;
1630 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1633 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1636 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1637 theMode |= eVolumes;
1640 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1642 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1644 myRepresentationCache = GetRepresentation();
1645 SetRepresentation( ePoint );
1648 if ( myEntityMode != theMode )
1650 myEntityMode = theMode; // entities to show
1652 // Set cell types to extract
1654 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1655 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1656 aFilter->ClearRegisteredCellsWithType();
1657 aHltFilter->ClearRegisteredCellsWithType();
1659 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1662 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1663 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1667 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1668 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1670 if (myEntityMode & e0DElements) {
1671 aFilter->RegisterCellsWithType(VTK_VERTEX);
1672 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1675 if (myEntityMode & eBallElem) {
1676 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1679 if (myEntityMode & eEdges) {
1680 aFilter->RegisterCellsWithType(VTK_LINE);
1681 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1683 aHltFilter->RegisterCellsWithType(VTK_LINE);
1684 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1687 if (myEntityMode & eFaces) {
1688 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1689 aFilter->RegisterCellsWithType(VTK_QUAD);
1690 aFilter->RegisterCellsWithType(VTK_POLYGON);
1691 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1692 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1693 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1694 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1695 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1697 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1698 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1699 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1700 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1701 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1702 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1703 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1704 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1707 if (myEntityMode & eVolumes) {
1708 aFilter->RegisterCellsWithType(VTK_TETRA);
1709 aFilter->RegisterCellsWithType(VTK_VOXEL);
1710 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1711 aFilter->RegisterCellsWithType(VTK_WEDGE);
1712 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1713 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1714 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1715 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1716 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1717 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1718 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1719 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1720 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1721 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1723 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1724 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1725 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1726 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1727 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1728 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1729 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1730 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1731 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1732 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1733 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1734 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1735 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1736 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1739 if ( GetVisibility() )
1741 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1744 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1747 void SMESH_ActorDef::SetRepresentation (int theMode)
1749 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1750 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1751 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1752 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1753 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1755 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1757 theMode = myRepresentationCache;
1758 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1761 myRepresentationCache = 0;
1765 myRepresentation = eSurface;
1766 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1767 myRepresentation = eEdge;
1768 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1769 myRepresentation = ePoint;
1774 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1777 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1780 myRepresentation = theMode;
1783 if (!GetUnstructuredGrid()->GetNumberOfCells())
1784 myRepresentation = ePoint;
1787 if (myRepresentation == ePoint) {
1795 myPickableActor = myBaseActor;
1796 vtkProperty *aProp = NULL, *aBackProp = NULL;
1797 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1798 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1799 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1800 switch (myRepresentation) {
1802 myPickableActor = myNodeActor;
1803 aQuadraticMode = SMESH_Actor::eLines;
1804 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1805 aReperesent = SMESH_DeviceActor::ePoint;
1808 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1809 aReperesent = SMESH_DeviceActor::eInsideframe;
1812 aProp = mySurfaceProp;
1813 aBackProp = myBackSurfaceProp;
1814 aPropVN = myNormalVProp;
1815 aPropVR = myReversedVProp;
1816 aReperesent = SMESH_DeviceActor::eSurface;
1820 if ( myRepresentation != ePoint )
1822 my2DActor->SetProperty(aProp);
1823 my2DActor->SetBackfaceProperty(aBackProp);
1824 my2DActor->SetRepresentation(aReperesent);
1826 if(aQuadraticMode == SMESH_Actor::eLines)
1827 my2DActor->SetQuadraticArcMode(false);
1828 else if(aQuadraticMode == SMESH_Actor::eArcs)
1829 my2DActor->SetQuadraticArcMode(true);
1831 my2DExtActor->SetRepresentation(aReperesent);
1833 my3DActor->SetProperty(aPropVN);
1834 my3DActor->SetBackfaceProperty(aPropVR);
1835 my3DActor->SetRepresentation(aReperesent);
1837 my0DActor->SetRepresentation(aReperesent);
1838 myBallActor->SetRepresentation(aReperesent);
1840 switch ( myControlMode ) {
1842 case eMultiConnection:
1843 aProp = aBackProp = my1DProp;
1844 if ( myRepresentation != ePoint )
1845 aReperesent = SMESH_DeviceActor::eInsideframe;
1850 if(aQuadraticMode == SMESH_Actor::eLines)
1851 my1DActor->SetQuadraticArcMode(false);
1852 else if(aQuadraticMode == SMESH_Actor::eArcs)
1853 my1DActor->SetQuadraticArcMode(true);
1855 my1DActor->SetProperty(aProp);
1856 my1DActor->SetBackfaceProperty(aBackProp);
1857 my1DActor->SetRepresentation(aReperesent);
1859 my1DExtActor->SetRepresentation(aReperesent);
1862 if(myIsPointsVisible)
1863 myPickableActor = myNodeActor;
1865 SetMapper(myPickableActor->GetMapper());
1867 SetVisibility(GetVisibility(),false);
1873 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1875 if ( myIsPointsVisible == theIsPointsVisible )
1877 myIsPointsVisible = theIsPointsVisible;
1878 SetRepresentation(GetRepresentation());
1881 bool SMESH_ActorDef::GetPointRepresentation()
1883 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1887 void SMESH_ActorDef::UpdateHighlight()
1889 myHighlitableActor->SetHighlited(false);
1890 myHighlitableActor->SetVisibility(false);
1891 bool anIsVisible = GetVisibility();
1893 switch(myRepresentation){
1894 case SMESH_DeviceActor::eSurface:
1895 case SMESH_DeviceActor::eWireframe:
1897 if(myIsHighlighted) {
1898 myHighlitableActor->SetProperty(myHighlightProp);
1899 }else if(myIsPreselected){
1900 myHighlitableActor->SetProperty(myPreselectProp);
1901 } else if(anIsVisible){
1902 (myRepresentation == eSurface) ?
1903 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1905 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1906 myHighlitableActor->SetHighlited(anIsVisible);
1907 myHighlitableActor->GetExtractUnstructuredGrid()->
1908 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1909 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1911 myHighlitableActor->SetVisibility(anIsVisible);
1914 case SMESH_DeviceActor::ePoint:
1916 if(myIsHighlighted) {
1917 myNodeActor->SetProperty(myHighlightProp);
1918 }else if(myIsPreselected) {
1919 myNodeActor->SetProperty(myPreselectProp);
1920 } else if(anIsVisible) {
1921 myNodeActor->SetProperty(myNodeProp);
1923 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1924 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1925 myNodeActor->GetProperty()->Modified();
1931 void SMESH_ActorDef::EnableSelection( bool enable )
1933 // selection in the Viewer enabled/disabled
1934 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1936 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1937 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1938 myBaseActor->myExtractUnstructuredGrid->Update();
1939 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1941 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1943 myBaseActor->SetUnstructuredGrid( NULL );
1944 //myHighlitableActor->SetUnstructuredGrid( NULL );
1945 myBaseActor->myExtractUnstructuredGrid->Update();
1946 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1950 void SMESH_ActorDef::highlight(bool theHighlight)
1952 if ( myIsHighlighted == theHighlight )
1954 myIsHighlighted = theHighlight;
1959 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1961 if ( myIsPreselected == thePreselect )
1963 myIsPreselected = thePreselect;
1969 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1971 if (myPickableActor->GetIsOpaque())
1973 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1981 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1983 if (!myPickableActor->GetIsOpaque())
1985 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1993 void SMESH_ActorDef::Render(vtkRenderer *ren)
1995 vtkMTimeType aTime = myTimeStamp->GetMTime();
1996 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1997 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1998 if(anObjTime > aTime || aClippingTime > aTime)
2003 void SMESH_ActorDef::Update()
2005 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
2007 myVisualObj->Update();
2009 if(GetControlMode() != eNone) {
2010 unsigned long aTime = myTimeStamp->GetMTime();
2011 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
2012 if (anObjTime > aTime)
2013 SetControlMode(GetControlMode(),false);
2017 myNodeActor->UpdateLabels();
2020 my0DActor->UpdateLabels();
2023 myBallActor->UpdateLabels();
2026 my1DActor->UpdateLabels();
2029 my2DActor->UpdateLabels();
2032 my3DActor->UpdateLabels();
2034 if(myIsFacesOriented){
2035 SetFacesOriented(myIsFacesOriented);
2038 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2039 // myEntityMode |= myVisualObj->GetEntitiesState();
2042 SetEntityMode(GetEntityMode());
2043 SetVisibility(GetVisibility());
2045 myTimeStamp->Modified();
2050 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2052 SALOME_Actor::ReleaseGraphicsResources(renWin);
2054 myPickableActor->ReleaseGraphicsResources(renWin);
2058 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2060 double* aColor = theProperty->GetColor();
2067 void SMESH_ActorDef::SetOpacity(double theValue)
2069 mySurfaceProp->SetOpacity(theValue);
2070 myBackSurfaceProp->SetOpacity(theValue);
2071 myNormalVProp->SetOpacity(theValue);
2072 myReversedVProp->SetOpacity(theValue);
2073 myEdgeProp->SetOpacity(theValue);
2074 myOutLineProp->SetOpacity(theValue);
2075 myNodeProp->SetOpacity(theValue);
2077 my1DProp->SetOpacity(theValue);
2078 my0DProp->SetOpacity(theValue);
2079 myBallProp->SetOpacity(theValue);
2083 double SMESH_ActorDef::GetOpacity()
2085 return mySurfaceProp->GetOpacity();
2089 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2091 mySurfaceProp->SetColor(r,g,b);
2092 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2093 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2094 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2095 myNameActor->SetBackgroundColor(r,g,b);
2097 myDeltaBrightness = delta;
2098 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2099 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2103 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2105 ::GetColor(mySurfaceProp,r,g,b);
2106 delta = myDeltaBrightness;
2109 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2111 myNormalVProp->SetColor(r,g,b);
2112 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2113 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2114 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2115 myNameActor->SetBackgroundColor(r,g,b);
2117 myDeltaVBrightness = delta;
2118 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2119 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2123 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2125 ::GetColor(myNormalVProp,r,g,b);
2126 delta = myDeltaVBrightness;
2129 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2131 myEdgeProp->SetColor(r,g,b);
2132 my1DProp->SetColor(r,g,b);
2133 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2134 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2135 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2136 myNameActor->SetBackgroundColor(r,g,b);
2140 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2142 ::GetColor(myEdgeProp,r,g,b);
2145 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2147 myOutLineProp->SetColor(r,g,b);
2151 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2153 ::GetColor(myOutLineProp,r,g,b);
2157 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2159 myNodeProp->SetColor(r,g,b);
2160 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2161 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2162 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2163 myNameActor->SetBackgroundColor(r,g,b);
2167 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2169 ::GetColor(myNodeProp,r,g,b);
2172 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2174 my0DProp->SetColor(r,g,b);
2175 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2176 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2177 myNameActor->SetBackgroundColor(r,g,b);
2181 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2183 ::GetColor(my0DProp,r,g,b);
2186 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2188 myBallProp->SetColor(r,g,b);
2189 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2190 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2191 myNameActor->SetBackgroundColor(r,g,b);
2195 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2197 ::GetColor(myBallProp,r,g,b);
2200 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2202 myHighlightProp->SetColor(r,g,b);
2206 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2208 ::GetColor(myHighlightProp,r,g,b);
2211 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2213 myPreselectProp->SetColor(r,g,b);
2217 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2219 ::GetColor(myPreselectProp,r,g,b);
2223 double SMESH_ActorDef::GetLineWidth()
2225 return myEdgeProp->GetLineWidth();
2229 void SMESH_ActorDef::SetLineWidth(double theVal)
2231 myEdgeProp->SetLineWidth(theVal);
2233 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2234 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2235 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2236 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2237 myOutLineProp->SetLineWidth(theVal);
2238 myHighlightProp->SetLineWidth(theVal);
2239 myPreselectProp->SetLineWidth(theVal);
2243 double SMESH_ActorDef::GetOutlineWidth()
2245 return myOutLineProp->GetLineWidth();
2248 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2250 myOutLineProp->SetLineWidth(theVal);
2254 void SMESH_ActorDef::Set0DSize(double theVal)
2256 my0DProp->SetPointSize(theVal);
2257 myHighlightProp->SetPointSize(theVal);
2258 myPreselectProp->SetPointSize(theVal);
2260 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2261 aCustom->Set0DSize(theVal);
2263 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2264 aCustom->Set0DSize(theVal);
2270 double SMESH_ActorDef::Get0DSize()
2272 return my0DProp->GetPointSize();
2275 void SMESH_ActorDef::SetBallSize(double theVal)
2277 myBallProp->SetPointSize(theVal);
2279 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2280 aCustom->SetBallSize(theVal);
2282 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2283 aCustom->SetBallSize(theVal);
2289 double SMESH_ActorDef::GetBallSize()
2291 return myBallProp->GetPointSize();
2294 double SMESH_ActorDef::GetBallScale()
2296 return myBallActor->GetBallScale();
2299 void SMESH_ActorDef::SetBallScale( double theVal )
2301 myBallActor->SetBallScale( theVal );
2302 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2303 aCustom->SetBallScale(theVal);
2305 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2306 aCustom->SetBallScale(theVal);
2312 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2314 return myVisualObj->GetElemDimension( theObjId );
2317 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2319 return myBaseActor->IsImplicitFunctionUsed();
2322 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2324 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2325 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2327 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2329 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2331 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2332 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2333 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2335 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2336 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2338 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2339 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2340 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2341 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2344 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2347 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2348 myCippingPlaneCont.push_back(thePlane);
2349 if(!IsImplicitFunctionUsed())
2350 SetImplicitFunctionUsed(true);
2351 myNodeActor->UpdateLabels();
2353 return myCippingPlaneCont.size();
2356 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2359 myPlaneCollection->AddItem( thePlane );
2362 void SMESH_ActorDef::SetOpenGLClippingPlane()
2364 // before use this method you must add clipping planes using method
2365 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2366 if( !myPlaneCollection->GetNumberOfItems() )
2369 // It is necessary to set plane collection for each mapper of actor
2370 // and update current inputs of mapper
2371 myNodeActor->SetPlaneCollection( myPlaneCollection );
2372 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2374 myBaseActor->SetPlaneCollection( myPlaneCollection );
2375 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2377 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2378 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2380 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2382 myBaseActor->SetUnstructuredGrid( NULL );
2383 //myHighlitableActor->SetUnstructuredGrid( NULL );
2385 my1DActor->SetPlaneCollection( myPlaneCollection );
2386 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2388 my2DActor->SetPlaneCollection( myPlaneCollection );
2389 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2391 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2392 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2394 my0DActor->SetPlaneCollection( myPlaneCollection );
2395 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2397 myBallActor->SetPlaneCollection( myPlaneCollection );
2398 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2400 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2401 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2403 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2404 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2406 my3DActor->SetPlaneCollection( myPlaneCollection );
2407 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2409 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2410 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2418 void SMESH_ActorDef::RemoveAllClippingPlanes()
2420 myPlaneCollection->RemoveAllItems();
2421 myImplicitBoolean->GetFunction()->RemoveAllItems();
2422 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2423 myCippingPlaneCont.clear();
2424 SetImplicitFunctionUsed(false);
2425 myNodeActor->UpdateLabels();
2428 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2430 return myCippingPlaneCont.size();
2433 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2435 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2437 return myCippingPlaneCont[theID].Get();
2440 void SMESH_ActorDef::UpdateScalarBar()
2442 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2446 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2448 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2449 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2451 aScalarBarTitleProp->SetFontFamilyToArial();
2453 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2455 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2456 if ( f.family() == "Arial" )
2457 aScalarBarTitleProp->SetFontFamilyToArial();
2458 else if ( f.family() == "Courier" )
2459 aScalarBarTitleProp->SetFontFamilyToCourier();
2460 else if ( f.family() == "Times" )
2461 aScalarBarTitleProp->SetFontFamilyToTimes();
2464 aScalarBarTitleProp->BoldOn();
2466 aScalarBarTitleProp->BoldOff();
2469 aScalarBarTitleProp->ItalicOn();
2471 aScalarBarTitleProp->ItalicOff();
2474 aScalarBarTitleProp->ShadowOn();
2476 aScalarBarTitleProp->ShadowOff();
2479 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2480 aScalarBarTitleProp->Delete();
2482 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2484 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2485 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2487 aScalarBarLabelProp->SetFontFamilyToArial();
2488 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2490 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2491 if( f.family() == "Arial" )
2492 aScalarBarLabelProp->SetFontFamilyToArial();
2493 else if( f.family() == "Courier" )
2494 aScalarBarLabelProp->SetFontFamilyToCourier();
2495 else if( f.family() == "Times" )
2496 aScalarBarLabelProp->SetFontFamilyToTimes();
2499 aScalarBarLabelProp->BoldOn();
2501 aScalarBarLabelProp->BoldOff();
2504 aScalarBarLabelProp->ItalicOn();
2506 aScalarBarLabelProp->ItalicOff();
2509 aScalarBarLabelProp->ShadowOn();
2511 aScalarBarLabelProp->ShadowOff();
2514 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2515 aScalarBarLabelProp->Delete();
2517 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2518 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2520 myScalarBarActor->SetOrientationToHorizontal();
2522 myScalarBarActor->SetOrientationToVertical();
2525 double aXVal = horiz ? 0.20 : 0.01;
2526 if( mgr->hasValue( "SMESH", name + "x" ) )
2527 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2529 double aYVal = horiz ? 0.01 : 0.1;
2530 if( mgr->hasValue( "SMESH", name + "y" ) )
2531 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2532 myScalarBarActor->SetPosition( aXVal, aYVal );
2534 double aWVal = horiz ? 0.60 : 0.10;
2535 if( mgr->hasValue( "SMESH", name + "width" ) )
2536 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2537 myScalarBarActor->SetWidth( aWVal );
2539 double aHVal = horiz ? 0.12 : 0.80;
2540 if( mgr->hasValue( "SMESH", name + "height" ) )
2541 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2542 myScalarBarActor->SetHeight( aHVal );
2545 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2546 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2547 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2550 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2551 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2552 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2554 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2555 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2557 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2558 myScalarBarActor->SetDistributionColoringType(coloringType);
2560 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2561 QColor(255, 255, 255));
2563 rgb[0]= distributionColor.red()/255.;
2564 rgb[1]= distributionColor.green()/255.;
2565 rgb[2]= distributionColor.blue()/255.;
2566 myScalarBarActor->SetDistributionColor(rgb);
2571 void SMESH_ActorDef::UpdateDistribution()
2573 if(SMESH::Controls::NumericalFunctor* fun =
2574 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2576 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2577 std::vector<int> nbEvents;
2578 std::vector<double> funValues;
2579 SMESH_VisualObjDef::TEntityList elems;
2580 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2581 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2582 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2583 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2584 elemIds.push_back( (*e)->GetID());
2585 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2586 double * range = lookupTable->GetRange();
2587 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2588 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2589 myScalarBarActor->SetDistribution(nbEvents);
2593 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2596 case SMESH_Actor::eLines :
2597 myHighlitableActor->SetQuadraticArcMode(false);
2598 my2DActor->SetQuadraticArcMode(false);
2599 my1DActor->SetQuadraticArcMode(false);
2601 case SMESH_Actor::eArcs :
2602 myHighlitableActor->SetQuadraticArcMode(true);
2603 if(GetRepresentation() != SMESH_Actor::ePoint) {
2604 my2DActor->SetQuadraticArcMode(true);
2605 my1DActor->SetQuadraticArcMode(true);
2614 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2616 if(myHighlitableActor->GetQuadraticArcMode())
2617 return SMESH_Actor::eArcs;
2619 return SMESH_Actor::eLines;
2622 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2624 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2625 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2626 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2629 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2631 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2632 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2633 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2634 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2637 #ifndef DISABLE_PLOT2DVIEWER
2638 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2641 my2dHistogram->clearAllPoints();
2643 if(SMESH::Controls::NumericalFunctor* fun =
2644 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2647 if(!my2dHistogram) {
2648 my2dHistogram = new SPlot2d_Histogram();
2649 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2650 my2dHistogram->setIO(anIO);
2653 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2654 std::vector<int> nbEvents;
2655 std::vector<double> funValues;
2656 SMESH_VisualObjDef::TEntityList elems;
2657 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2658 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2659 std::vector<int> elemIds;
2661 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2662 elemIds.push_back( (*e)->GetID());
2664 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2665 double * range = lookupTable->GetRange();
2666 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2667 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2669 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2670 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2672 if(funValues.size() >= 2)
2673 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2677 //Color of the histogram
2678 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2679 my2dHistogram->setAutoAssign(true);
2682 myScalarBarActor->GetDistributionColor(rgb);
2683 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2684 my2dHistogram->setColor(aColor);
2688 return my2dHistogram;