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_QUADRATIC_PYRAMID);
283 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
284 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
286 my3DExtProp = vtkProperty::New();
287 my3DExtProp->DeepCopy(myNormalVProp);
288 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
289 anRGB[0] = 1 - anRGB[0];
290 anRGB[1] = 1 - anRGB[1];
291 anRGB[2] = 1 - anRGB[2];
292 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
294 my3DExtActor = SMESH_DeviceActor::New();
295 my3DExtActor->SetUserMatrix(aMatrix);
296 my3DExtActor->PickableOff();
297 my3DExtActor->SetProperty(my3DExtProp);
298 my3DExtActor->SetBackfaceProperty(my3DExtProp);
299 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
300 my3DExtActor->SetCoincident3DAllowed(true);
301 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
302 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
303 aFilter->RegisterCellsWithType(VTK_TETRA);
304 aFilter->RegisterCellsWithType(VTK_VOXEL);
305 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
306 aFilter->RegisterCellsWithType(VTK_WEDGE);
307 aFilter->RegisterCellsWithType(VTK_PYRAMID);
308 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
311 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
314 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
315 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
317 //Definition 1D device of the actor
318 //---------------------------------
319 myEdgeProp = vtkProperty::New();
320 myEdgeProp->SetAmbient(1.0);
321 myEdgeProp->SetDiffuse(0.0);
322 myEdgeProp->SetSpecular(0.0);
323 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
324 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
325 myEdgeProp->SetLineWidth(aLineWidth);
327 // my1DActor is used to
329 // - show controls on all edges (eg Length)
330 // since edges are shown by myHighlitableActor
331 my1DActor = SMESH_CellLabelActor::New();
332 my1DActor->SetStoreClippingMapping(true);
333 my1DActor->SetUserMatrix(aMatrix);
334 my1DActor->PickableOff();
335 my1DActor->SetHighlited(true);
336 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
337 my1DActor->SetProperty(myEdgeProp);
338 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
339 aFilter = my1DActor->GetExtractUnstructuredGrid();
340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
341 aFilter->RegisterCellsWithType(VTK_LINE);
342 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
344 my1DProp = vtkProperty::New();
345 my1DProp->DeepCopy(myEdgeProp);
346 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
347 my1DProp->SetPointSize(aElem0DSize);
349 my1DExtProp = vtkProperty::New();
350 my1DExtProp->DeepCopy(myEdgeProp);
351 anRGB[0] = 1 - anRGB[0];
352 anRGB[1] = 1 - anRGB[1];
353 anRGB[2] = 1 - anRGB[2];
354 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
355 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
356 my1DExtProp->SetPointSize(aElem0DSize);
358 // my1DExtActor is used to show filtered edges or links between nodes
359 my1DExtActor = SMESH_DeviceActor::New();
360 my1DExtActor->SetUserMatrix(aMatrix);
361 my1DExtActor->PickableOff();
362 my1DExtActor->SetHighlited(true);
363 my1DExtActor->SetVisibility(false);
364 my1DExtActor->SetProperty(my1DExtProp);
365 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
366 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
367 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
368 aFilter->RegisterCellsWithType(VTK_LINE);
369 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
372 //Definition 0D device of the actor (0d elements)
373 //-----------------------------------------------
374 my0DProp = vtkProperty::New();
375 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
376 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
377 my0DProp->SetPointSize(aElem0DSize);
379 my0DActor = SMESH_CellLabelActor::New();
380 my0DActor->SetUserMatrix(aMatrix);
381 my0DActor->SetStoreClippingMapping(true);
382 my0DActor->PickableOff();
383 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
384 my0DActor->SetVisibility(false);
385 my0DActor->SetProperty(my0DProp);
386 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
387 aFilter = my0DActor->GetExtractUnstructuredGrid();
388 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
389 aFilter->RegisterCellsWithType(VTK_VERTEX);
391 //Definition 0D device of the actor (ball elements)
392 //-----------------------------------------------
393 myBallProp = vtkProperty::New();
394 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
395 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
396 myBallProp->SetPointSize(aBallElemSize);
398 myBallActor = SMESH_CellLabelActor::New();
399 myBallActor->SetUserMatrix(aMatrix);
400 myBallActor->SetStoreClippingMapping(true);
401 myBallActor->PickableOff();
402 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
403 myBallActor->SetVisibility(false);
404 myBallActor->SetProperty(myBallProp);
405 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
406 myBallActor->SetBallEnabled(true);
407 aFilter = myBallActor->GetExtractUnstructuredGrid();
408 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
409 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
411 //my0DExtProp = vtkProperty::New();
412 //my0DExtProp->DeepCopy(my0DProp);
413 //anRGB[0] = 1 - anRGB[0];
414 //anRGB[1] = 1 - anRGB[1];
415 //anRGB[2] = 1 - anRGB[2];
416 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
417 //my0DExtProp->SetPointSize(aElem0DSize);
419 //my0DExtActor = SMESH_DeviceActor::New();
420 //my0DExtActor->SetUserMatrix(aMatrix);
421 //my0DExtActor->SetStoreClippingMapping(true);
422 //my0DExtActor->PickableOff();
423 //my0DExtActor->SetHighlited(true);
424 //my0DExtActor->SetVisibility(false);
425 //my0DExtActor->SetProperty(my0DExtProp);
426 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
427 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
428 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
429 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
430 //aFilter->RegisterCellsWithType(VTK_VERTEX);
433 //Definition 0D device of the actor (nodes)
434 //-----------------------------------------
435 myNodeProp = vtkProperty::New();
436 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
437 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
439 myNodeActor = SMESH_NodeLabelActor::New();
440 myNodeActor->SetUserMatrix(aMatrix);
441 myNodeActor->SetStoreClippingMapping(true);
442 myNodeActor->PickableOff();
443 myNodeActor->SetVisibility(false);
444 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
445 myNodeActor->SetProperty(myNodeProp);
446 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
447 aFilter = myNodeActor->GetExtractUnstructuredGrid();
448 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
450 myNodeExtProp = vtkProperty::New();
451 myNodeExtProp->DeepCopy(myNodeProp);
452 anRGB[0] = 1 - anRGB[0];
453 anRGB[1] = 1 - anRGB[1];
454 anRGB[2] = 1 - anRGB[2];
455 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
457 myNodeExtActor = SMESH_DeviceActor::New();
458 myNodeExtActor->SetUserMatrix(aMatrix);
459 myNodeExtActor->SetStoreClippingMapping(true);
460 myNodeExtActor->PickableOff();
461 myNodeExtActor->SetHighlited(true);
462 myNodeExtActor->SetVisibility(false);
463 myNodeExtActor->SetProperty(myNodeExtProp);
464 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
465 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
466 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
467 aFilter->RegisterCellsWithType(VTK_VERTEX);
469 //Definition of Pickable and Highlitable engines
470 //----------------------------------------------
472 myBaseActor->SetUserMatrix(aMatrix);
473 myBaseActor->SetStoreIDMapping(true);
474 myBaseActor->SetStoreClippingMapping(true);
475 myBaseActor->SetStoreGemetryMapping(true);
476 myBaseActor->GetProperty()->SetOpacity(0.0);
477 myPickableActor = myBaseActor;
479 myHighlightProp = vtkProperty::New();
480 myHighlightProp->SetAmbient(1.0);
481 myHighlightProp->SetDiffuse(0.0);
482 myHighlightProp->SetSpecular(0.0);
483 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
484 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
485 myHighlightProp->SetPointSize(aElem0DSize); // ??
486 myHighlightProp->SetLineWidth(aLineWidth);
487 myHighlightProp->SetRepresentation(1);
489 myOutLineProp = vtkProperty::New();
490 myOutLineProp->SetAmbient(1.0);
491 myOutLineProp->SetDiffuse(0.0);
492 myOutLineProp->SetSpecular(0.0);
493 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
494 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
495 myOutLineProp->SetLineWidth(aOutlineWidth);
496 myOutLineProp->SetRepresentation(1);
498 myPreselectProp = vtkProperty::New();
499 myPreselectProp->SetAmbient(1.0);
500 myPreselectProp->SetDiffuse(0.0);
501 myPreselectProp->SetSpecular(0.0);
502 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
503 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
504 myPreselectProp->SetPointSize(aElem0DSize); // ??
505 myPreselectProp->SetLineWidth(aLineWidth);
506 myPreselectProp->SetRepresentation(1);
508 myHighlitableActor = SMESH_DeviceActor::New();
509 myHighlitableActor->SetUserMatrix(aMatrix);
510 myHighlitableActor->PickableOff();
511 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
512 myHighlitableActor->SetCoincident3DAllowed(true);
519 myControlMode = eNone;
520 myControlActor = my2DActor;
522 //Definition of myScalarBarActor
523 //------------------------------
524 myLookupTable = vtkLookupTable::New();
525 //Fix for Bug PAL5195 - SMESH764:
526 //Controls - Aspect Ratio: incorrect colors of the best and worst values
527 myLookupTable->SetHueRange(0.667,0.0);
529 myScalarBarActor = SMESH_ScalarBarActor::New();
530 myScalarBarActor->SetVisibility(false);
531 myScalarBarActor->SetLookupTable(myLookupTable);
534 //Incorrect "Min value" in Scalar Bar in Mesh:
535 // myScalarBarActor->SetLabelFormat("%.4g");
536 // changes was commented because of regression bug IPAL 19981
538 mgr = SUIT_Session::session()->resourceMgr();
542 myEntityMode = eAllEntity;
543 myEntityModeCache = eAllEntity;
546 myImplicitBoolean = vtkImplicitBoolean::New();
547 myImplicitBoolean->SetOperationTypeToIntersection();
549 myPlaneCollection = vtkPlaneCollection::New();
551 //Quadratic 2D elements representation
552 //-----------------------------------------------------------------------------
553 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
554 if(aQuadratic2DMode == 0){
555 myHighlitableActor->SetQuadraticArcMode(false);
556 my2DActor->SetQuadraticArcMode(false);
557 my1DActor->SetQuadraticArcMode(false);
559 else if(aQuadratic2DMode == 1){
560 myHighlitableActor->SetQuadraticArcMode(true);
561 my2DActor->SetQuadraticArcMode(true);
562 my1DActor->SetQuadraticArcMode(true);
565 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
566 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
567 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
569 // Set colors of the name actor
570 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
571 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
572 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
573 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
575 #ifndef DISABLE_PLOT2DVIEWER
579 SetBallSize(aBallElemSize);
580 SetBallScale(aBallElemScale);
581 Set0DSize(aElem0DSize);
585 SMESH_ActorDef::~SMESH_ActorDef()
587 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
589 // Please keep the order same as one in the header file
591 myTimeStamp->Delete();
593 myScalarBarActor->Delete();
594 myLookupTable->Delete();
596 mySurfaceProp->Delete();
597 myBackSurfaceProp->Delete();
598 myNormalVProp->Delete();
599 myReversedVProp->Delete();
600 myEdgeProp->Delete();
601 myNodeProp->Delete();
603 myNodeActor->Delete();
604 myBaseActor->Delete();
605 //myPickableActor->Delete(); myPickableActor == myBaseActor
607 myHighlightProp->Delete();
608 myOutLineProp->Delete();
609 myPreselectProp->Delete();
611 myHighlitableActor->Delete();
613 my2DExtProp->Delete();
614 my3DExtProp->Delete();
616 my2DExtActor->Delete();
618 my3DExtActor->Delete();
619 // myControlActor->Delete(); myControlActor == my2DActor
621 myNodeExtProp->Delete();
622 myNodeExtActor->Delete();
626 my1DExtProp->Delete();
627 my1DExtActor->Delete();
631 myBallProp->Delete();
632 myBallActor->Delete();
633 //my0DExtProp->Delete();
634 //my0DExtActor->Delete();
636 myImplicitBoolean->Delete();
637 myPlaneCollection->Delete();
639 #ifndef DISABLE_PLOT2DVIEWER
641 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
642 delete my2dHistogram;
647 void SMESH_ActorDef::Delete()
649 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
650 // from the actor's destructor) will be thrown before removing the actor's observers,
651 // that is done inside the Superclass::Delete() method but before the destructor itself
652 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
653 // The event is caught by SMESHGUI::ProcessEvents() static method.
654 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
656 Superclass::Delete();
659 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
662 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
663 SetRepresentation(GetRepresentation());
664 myTimeStamp->Modified();
668 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
669 bool theBold, bool theItalic, bool theShadow,
670 double r, double g, double b )
673 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
674 SetRepresentation( GetRepresentation() );
675 myTimeStamp->Modified();
679 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
680 bool theBold, bool theItalic, bool theShadow,
681 double r, double g, double b )
684 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
687 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
688 SetRepresentation( GetRepresentation() );
689 myTimeStamp->Modified();
692 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
693 SetRepresentation( GetRepresentation() );
694 myTimeStamp->Modified();
697 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
698 SetRepresentation( GetRepresentation() );
699 myTimeStamp->Modified();
702 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
703 SetRepresentation( GetRepresentation() );
704 myTimeStamp->Modified();
708 bool SMESH_ActorDef::GetPointsLabeled()
710 return myNodeActor && myNodeActor->GetPointsLabeled();
713 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
716 my3DActor->SetCellsLabeled(theIsCellsLabeled);
719 my2DActor->SetCellsLabeled(theIsCellsLabeled);
722 my1DActor->SetCellsLabeled(theIsCellsLabeled);
725 my0DActor->SetCellsLabeled(theIsCellsLabeled);
728 myBallActor->SetCellsLabeled(theIsCellsLabeled);
730 myTimeStamp->Modified();
734 bool SMESH_ActorDef::GetCellsLabeled()
738 result = result || my3DActor->GetCellsLabeled();
741 result = result || my2DActor->GetCellsLabeled();
744 result = result || my1DActor->GetCellsLabeled();
747 result = result || my0DActor->GetCellsLabeled();
750 result = result || myBallActor->GetCellsLabeled();
756 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
758 myIsFacesOriented = theIsFacesOriented;
760 my2DActor->SetFacesOriented(theIsFacesOriented);
761 my3DActor->SetFacesOriented(theIsFacesOriented);
763 myTimeStamp->Modified();
766 bool SMESH_ActorDef::GetFacesOriented()
768 return myIsFacesOriented;
771 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
773 my2DActor->SetFacesOrientationColor( r, g, b );
774 my3DActor->SetFacesOrientationColor( r, g, b );
777 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
779 my3DActor->GetFacesOrientationColor( r, g, b );
782 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
784 my2DActor->SetFacesOrientationScale( theScale );
785 my3DActor->SetFacesOrientationScale( theScale );
788 double SMESH_ActorDef::GetFacesOrientationScale()
790 return my3DActor->GetFacesOrientationScale();
793 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
795 my2DActor->SetFacesOrientation3DVectors( theState );
796 my3DActor->SetFacesOrientation3DVectors( theState );
799 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
801 return my3DActor->GetFacesOrientation3DVectors();
805 void SMESH_ActorDef::SetControlMode(eControl theMode)
807 SetControlMode(theMode,true);
811 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
813 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
814 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
815 lookupTable->SetScale(VTK_SCALE_LINEAR);
817 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
821 //myControlMode = eNone;
822 myControlMode = theMode;
823 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
825 my0DActor->GetMapper()->SetScalarVisibility(false);
826 my1DActor->GetMapper()->SetScalarVisibility(false);
827 my2DActor->GetMapper()->SetScalarVisibility(false);
828 my3DActor->GetMapper()->SetScalarVisibility(false);
829 myBallActor->GetMapper()->SetScalarVisibility(false);
830 myScalarBarActor->SetVisibility(false);
832 bool anIsScalarVisible = theMode > eNone;
834 if(anIsScalarVisible) {
838 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
839 aControl->SetPrecision( myControlsPrecision );
840 myFunctor.reset( aControl );
841 myControlActor = my1DActor;
846 myFunctor.reset(new SMESH::Controls::Length2D());
847 myControlActor = my2DActor;
851 myFunctor.reset(new SMESH::Controls::FreeBorders());
852 myControlActor = my1DActor;
855 myFunctor.reset(new SMESH::Controls::FreeEdges());
856 myControlActor = my2DActor;
859 myFunctor.reset(new SMESH::Controls::FreeNodes());
860 myControlActor = myNodeActor;
863 myFunctor.reset(new SMESH::Controls::FreeFaces());
864 myControlActor = my2DActor;
866 case eCoincidentNodes:
868 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
869 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
870 cn->SetTolerance( tol );
872 myControlActor = myNodeActor;
875 case eCoincidentElems1D:
876 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
877 myControlActor = my1DActor;
879 case eCoincidentElems2D:
880 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
881 myControlActor = my2DActor;
883 case eCoincidentElems3D:
884 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
885 myControlActor = my3DActor;
887 case eBareBorderFace:
888 myFunctor.reset(new SMESH::Controls::BareBorderFace());
889 myControlActor = my2DActor;
891 case eOverConstrainedFace:
892 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
893 myControlActor = my2DActor;
895 case eMultiConnection:
896 myFunctor.reset(new SMESH::Controls::MultiConnection());
897 myControlActor = my1DActor;
899 case eMultiConnection2D:
900 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
901 myControlActor = my2DActor;
905 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
906 aControl->SetPrecision( myControlsPrecision );
907 myFunctor.reset( aControl );
908 myControlActor = my2DActor;
913 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
914 aControl->SetPrecision( myControlsPrecision );
915 myFunctor.reset( aControl );
916 myControlActor = my2DActor;
921 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
922 aControl->SetPrecision( myControlsPrecision );
923 myFunctor.reset( aControl );
924 myControlActor = my2DActor;
929 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
930 aControl->SetPrecision( myControlsPrecision );
931 myFunctor.reset( aControl );
932 myControlActor = my3DActor;
937 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
938 aControl->SetPrecision( myControlsPrecision );
939 myFunctor.reset( aControl );
940 myControlActor = my3DActor;
943 case eMaxElementLength2D:
945 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
946 aControl->SetPrecision( myControlsPrecision );
947 myFunctor.reset( aControl );
948 myControlActor = my2DActor;
951 case eMaxElementLength3D:
953 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
954 aControl->SetPrecision( myControlsPrecision );
955 myFunctor.reset( aControl );
956 myControlActor = my3DActor;
959 case eBareBorderVolume:
961 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
962 myControlActor = my3DActor;
965 case eOverConstrainedVolume:
967 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
968 myControlActor = my3DActor;
973 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
974 aControl->SetPrecision( myControlsPrecision );
975 myFunctor.reset( aControl );
976 myControlActor = my2DActor;
981 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
982 aControl->SetPrecision( myControlsPrecision );
983 myFunctor.reset( aControl );
984 myControlActor = my2DActor;
989 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
995 case eNodeConnectivityNb:
997 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
998 myControlActor = myNodeActor;
1005 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1006 bool aShowOnlyScalarBarTitle = false;
1008 //myControlMode = theMode;
1009 switch(myControlMode){
1011 case eCoincidentNodes:
1012 myNodeExtActor->SetExtControlMode(myFunctor);
1013 aShowOnlyScalarBarTitle = true;
1017 case eCoincidentElems1D:
1018 my1DExtActor->SetExtControlMode(myFunctor);
1019 aShowOnlyScalarBarTitle = true;
1022 case eBareBorderFace:
1023 case eOverConstrainedFace:
1024 case eCoincidentElems2D:
1025 my2DExtActor->SetExtControlMode(myFunctor);
1026 aShowOnlyScalarBarTitle = true;
1028 case eBareBorderVolume:
1029 case eOverConstrainedVolume:
1030 case eCoincidentElems3D:
1031 my3DExtActor->SetExtControlMode(myFunctor);
1032 aShowOnlyScalarBarTitle = true;
1035 case eMultiConnection2D:
1036 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1037 UpdateDistribution();
1040 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1041 UpdateDistribution();
1043 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1046 if(theCheckEntityMode) {
1047 // if(myControlActor == myNodeActor) {
1048 // if ( myControlMode == eNodeConnectivityNb ) {
1049 // if (!myIsEntityModeCache){
1050 // myEntityModeCache = GetEntityMode();
1051 // myIsEntityModeCache=true;
1053 // SetEntityMode(0);
1056 if(myControlActor == my1DActor) {
1057 if (!myIsEntityModeCache){
1058 myEntityModeCache = GetEntityMode();
1059 myIsEntityModeCache=true;
1061 SetEntityMode(eEdges);
1063 else if(myControlActor == my2DActor) {
1064 if (!myIsEntityModeCache){
1065 myEntityModeCache = GetEntityMode();
1066 myIsEntityModeCache=true;
1068 SetEntityMode(eFaces);
1070 else if(myControlActor == my3DActor) {
1071 if (!myIsEntityModeCache){
1072 myEntityModeCache = GetEntityMode();
1073 myIsEntityModeCache=true;
1075 SetEntityMode(eVolumes);
1078 QString aTitle = QString(myScalarBarActor->GetTitle());
1079 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1080 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1084 if(theCheckEntityMode){
1085 myEntityMode = myEntityModeCache;
1086 myIsEntityModeCache = false;
1091 SetRepresentation(GetRepresentation());
1093 myTimeStamp->Modified();
1096 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1097 double * range = lookupTable->GetRange();
1099 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1100 lookupTable->SetScale(VTK_SCALE_LOG10);
1105 int SMESH_ActorDef::GetNumberControlEntities()
1107 SMESH_DeviceActor* anAct = NULL;
1108 switch(myControlMode){
1110 case eCoincidentNodes:
1111 anAct = myNodeExtActor;
1115 case eCoincidentElems1D:
1116 anAct = my1DExtActor;
1119 case eBareBorderFace:
1120 case eOverConstrainedFace:
1121 case eCoincidentElems2D:
1122 anAct = my2DExtActor;
1124 case eBareBorderVolume:
1125 case eOverConstrainedVolume:
1126 case eCoincidentElems3D:
1127 anAct = my3DExtActor;
1131 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1134 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1136 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1138 myBaseActor->SetUnstructuredGrid( NULL );
1139 //myHighlitableActor->SetUnstructuredGrid( NULL );
1141 theRenderer->AddActor(myBaseActor);
1142 theRenderer->AddActor(myNodeExtActor);
1143 theRenderer->AddActor(my1DExtActor);
1145 my3DActor ->AddToRender(theRenderer);
1146 my3DExtActor->AddToRender(theRenderer);
1147 my2DActor ->AddToRender(theRenderer);
1148 my2DExtActor->AddToRender(theRenderer);
1149 myNodeActor ->AddToRender(theRenderer);
1150 my1DActor ->AddToRender(theRenderer);
1151 my0DActor ->AddToRender(theRenderer);
1152 myBallActor ->AddToRender(theRenderer);
1154 theRenderer->AddActor(myHighlitableActor);
1156 theRenderer->AddActor2D(myScalarBarActor);
1158 // the superclass' method should be called at the end
1159 // (in particular, for correct work of selection)
1160 SALOME_Actor::AddToRender(theRenderer);
1163 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1165 SALOME_Actor::RemoveFromRender(theRenderer);
1167 theRenderer->RemoveActor(myBaseActor);
1169 theRenderer->RemoveActor(myNodeExtActor);
1171 theRenderer->RemoveActor(myHighlitableActor);
1173 //theRenderer->RemoveActor(my0DExtActor);
1175 theRenderer->RemoveActor(my1DExtActor);
1177 my2DActor->RemoveFromRender(theRenderer);
1178 my2DExtActor->RemoveFromRender(theRenderer);
1179 my3DActor->RemoveFromRender(theRenderer);
1180 my3DExtActor->RemoveFromRender(theRenderer);
1181 myNodeActor->RemoveFromRender(theRenderer);
1182 my0DActor->RemoveFromRender(theRenderer);
1183 myBallActor->RemoveFromRender(theRenderer);
1184 my1DActor->RemoveFromRender(theRenderer);
1186 theRenderer->RemoveActor(myScalarBarActor);
1190 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1191 const char* theEntry,
1192 const char* theName,
1195 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1199 myVisualObj = theVisualObj;
1200 myVisualObj->Update(theIsClear);
1202 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1203 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1205 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1206 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1208 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1210 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1212 my0DActor->Init(myVisualObj,myImplicitBoolean);
1213 myBallActor->Init(myVisualObj,myImplicitBoolean);
1214 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1216 my1DActor->Init(myVisualObj,myImplicitBoolean);
1217 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1219 my2DActor->Init(myVisualObj,myImplicitBoolean);
1220 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1221 my3DActor->Init(myVisualObj,myImplicitBoolean);
1222 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1224 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1225 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1226 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1228 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1229 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1231 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1232 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1233 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1234 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1236 double aFactor, aUnits;
1237 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1238 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1239 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1240 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1242 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1246 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1247 SetIsShrunkable(true);
1249 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1251 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1252 SetRepresentation(-1);
1255 SetRepresentation(eEdge);
1256 }else if(aMode == 1){
1257 SetRepresentation(eSurface);
1258 }else if(aMode == 2){
1259 SetRepresentation(ePoint);
1266 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1267 SetIsDisplayNameActor( true );
1269 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1270 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1271 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1273 myTimeStamp->Modified();
1279 double* SMESH_ActorDef::GetBounds()
1281 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1282 return myNodeActor->GetBounds();
1283 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1287 vtkDataSet* SMESH_ActorDef::GetInput()
1289 return GetUnstructuredGrid();
1293 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1295 Superclass::SetTransform(theTransform);
1297 myNodeActor->SetTransform(theTransform);
1298 myBaseActor->SetTransform(theTransform);
1300 myHighlitableActor->SetTransform(theTransform);
1302 myNodeExtActor->SetTransform(theTransform);
1304 my0DActor->SetTransform(theTransform);
1305 myBallActor->SetTransform(theTransform);
1306 //my0DExtActor->SetTransform(theTransform);
1308 my1DActor->SetTransform(theTransform);
1309 my1DExtActor->SetTransform(theTransform);
1311 my2DActor->SetTransform(theTransform);
1312 my2DExtActor->SetTransform(theTransform);
1313 my3DActor->SetTransform(theTransform);
1314 my3DExtActor->SetTransform(theTransform);
1320 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1322 vtkLODActor::SetMapper(theMapper);
1326 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1328 SALOME_Actor::ShallowCopy(prop);
1332 vtkMapper* SMESH_ActorDef::GetMapper()
1334 return myPickableActor->GetMapper();
1338 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1340 return myVisualObj->GetUnstructuredGrid();
1344 bool SMESH_ActorDef::IsInfinitive()
1346 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1347 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1348 ( aDataSet->GetNumberOfCells() == 1 &&
1349 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1350 return SALOME_Actor::IsInfinitive();
1354 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1356 if ( myIsShrinkable == theShrunkable )
1358 myIsShrinkable = theShrunkable;
1362 double SMESH_ActorDef::GetShrinkFactor()
1364 return myBaseActor->GetShrinkFactor();
1367 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1369 myBaseActor->SetShrinkFactor(theValue);
1371 my1DActor->SetShrinkFactor(theValue);
1372 my1DExtActor->SetShrinkFactor(theValue);
1374 my2DActor->SetShrinkFactor(theValue);
1375 my2DExtActor->SetShrinkFactor(theValue);
1376 my3DActor->SetShrinkFactor(theValue);
1377 my3DExtActor->SetShrinkFactor(theValue);
1378 my3DExtActor->SetShrinkFactor(theValue);
1379 myHighlitableActor->SetShrinkFactor(theValue);
1384 void SMESH_ActorDef::SetShrink()
1386 if(!myIsShrinkable) return;
1388 myBaseActor->SetShrink();
1390 my1DActor->SetShrink();
1391 my1DExtActor->SetShrink();
1393 my2DActor->SetShrink();
1394 my2DExtActor->SetShrink();
1395 my3DActor->SetShrink();
1396 my3DExtActor->SetShrink();
1397 myHighlitableActor->SetShrink();
1403 void SMESH_ActorDef::UnShrink()
1405 if(!myIsShrunk) return;
1407 myBaseActor->UnShrink();
1409 my1DActor->UnShrink();
1410 my1DExtActor->UnShrink();
1412 my2DActor->UnShrink();
1413 my2DExtActor->UnShrink();
1414 my3DActor->UnShrink();
1415 my3DExtActor->UnShrink();
1416 myHighlitableActor->UnShrink();
1423 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1425 return myPickableActor->GetNodeObjId(theVtkID);
1428 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1430 return myPickableActor->GetNodeCoord(theObjID);
1434 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1436 return myPickableActor->GetElemObjId(theVtkID);
1439 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1441 return myPickableActor->GetElemCell(theObjID);
1445 void SMESH_ActorDef::SetVisibility(int theMode)
1447 SetVisibility(theMode,true);
1451 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1453 SALOME_Actor::SetVisibility(theMode);
1455 myNodeActor->VisibilityOff();
1456 myBaseActor->VisibilityOff();
1458 myNodeExtActor->VisibilityOff();
1460 my0DActor->VisibilityOff();
1461 myBallActor->VisibilityOff();
1462 //my0DExtActor->VisibilityOff();
1464 my1DActor->VisibilityOff();
1465 my1DExtActor->VisibilityOff();
1467 my2DActor->VisibilityOff();
1468 my2DExtActor->VisibilityOff();
1469 my3DActor->VisibilityOff();
1470 my3DExtActor->VisibilityOff();
1472 myScalarBarActor->VisibilityOff();
1474 if ( GetVisibility() ) {
1475 if ( theIsUpdateRepersentation )
1476 SetRepresentation(GetRepresentation());
1478 if(myControlMode != eNone) {
1479 switch(myControlMode) {
1481 case eCoincidentNodes:
1482 myNodeExtActor->VisibilityOn();
1485 case eMultiConnection:
1486 my1DActor->VisibilityOn();
1490 case eCoincidentElems1D:
1492 case eMultiConnection2D:
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();
1508 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1509 myScalarBarActor->VisibilityOn();
1512 myPickableActor->VisibilityOn();
1514 if ( GetRepresentation() != ePoint )
1516 if(myEntityMode & e0DElements ){
1517 my0DActor->VisibilityOn();
1519 if(myEntityMode & eBallElem ){
1520 myBallActor->VisibilityOn();
1522 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1523 my1DActor->VisibilityOn();
1525 if(myEntityMode & eFaces ){
1526 my2DActor->VisibilityOn();
1528 if(myEntityMode & eVolumes ){
1529 my3DActor->VisibilityOn();
1533 if(myNodeActor->GetPointsLabeled()) {
1534 myNodeActor->UpdateLabels();
1535 myNodeActor->VisibilityOn();
1538 my0DActor->UpdateLabels();
1541 myBallActor->UpdateLabels();
1544 my1DActor->UpdateLabels();
1547 my2DActor->UpdateLabels();
1550 my3DActor->UpdateLabels();
1552 #ifndef DISABLE_PLOT2DVIEWER
1554 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1561 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1563 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1565 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1566 anObjectEntities &= ~e0DElements;
1567 theMode &= ~e0DElements;
1570 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1571 anObjectEntities &= ~eBallElem;
1572 theMode &= ~eBallElem;
1575 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1576 anObjectEntities &= ~eEdges;
1580 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1581 anObjectEntities &= ~eFaces;
1585 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1586 anObjectEntities &= ~eVolumes;
1587 theMode &= ~eVolumes;
1591 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1592 theMode |= e0DElements;
1594 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1595 theMode |= eBallElem;
1597 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1600 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1603 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1604 theMode |= eVolumes;
1607 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1609 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1611 myRepresentationCache = GetRepresentation();
1612 SetRepresentation( ePoint );
1615 if ( myEntityMode != theMode )
1617 myEntityMode = theMode; // entities to show
1619 // Set cell types to extract
1621 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1622 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1623 aFilter->ClearRegisteredCellsWithType();
1624 aHltFilter->ClearRegisteredCellsWithType();
1626 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1629 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1630 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1634 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1635 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1637 if (myEntityMode & e0DElements) {
1638 aFilter->RegisterCellsWithType(VTK_VERTEX);
1639 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1642 if (myEntityMode & eBallElem) {
1643 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1646 if (myEntityMode & eEdges) {
1647 aFilter->RegisterCellsWithType(VTK_LINE);
1648 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1650 aHltFilter->RegisterCellsWithType(VTK_LINE);
1651 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1654 if (myEntityMode & eFaces) {
1655 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1656 aFilter->RegisterCellsWithType(VTK_QUAD);
1657 aFilter->RegisterCellsWithType(VTK_POLYGON);
1658 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1659 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1660 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1661 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1662 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1664 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1665 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1666 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1667 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1668 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1669 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1670 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1671 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1674 if (myEntityMode & eVolumes) {
1675 aFilter->RegisterCellsWithType(VTK_TETRA);
1676 aFilter->RegisterCellsWithType(VTK_VOXEL);
1677 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1678 aFilter->RegisterCellsWithType(VTK_WEDGE);
1679 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1680 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1681 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1682 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1683 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1684 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1685 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1686 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1687 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1689 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1690 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1691 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1692 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1693 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1694 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1695 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1696 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1697 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1698 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1699 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1700 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1701 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1704 if ( GetVisibility() )
1706 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1709 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1712 void SMESH_ActorDef::SetRepresentation (int theMode)
1714 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1715 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1716 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1717 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1718 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1720 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1722 theMode = myRepresentationCache;
1723 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1726 myRepresentationCache = 0;
1730 myRepresentation = eSurface;
1731 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1732 myRepresentation = eEdge;
1733 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1734 myRepresentation = ePoint;
1739 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1742 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1745 myRepresentation = theMode;
1748 if (!GetUnstructuredGrid()->GetNumberOfCells())
1749 myRepresentation = ePoint;
1752 if (myRepresentation == ePoint) {
1760 myPickableActor = myBaseActor;
1761 vtkProperty *aProp = NULL, *aBackProp = NULL;
1762 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1763 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1764 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1765 switch (myRepresentation) {
1767 myPickableActor = myNodeActor;
1768 aQuadraticMode = SMESH_Actor::eLines;
1769 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1770 aReperesent = SMESH_DeviceActor::ePoint;
1773 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1774 aReperesent = SMESH_DeviceActor::eInsideframe;
1777 aProp = mySurfaceProp;
1778 aBackProp = myBackSurfaceProp;
1779 aPropVN = myNormalVProp;
1780 aPropVR = myReversedVProp;
1781 aReperesent = SMESH_DeviceActor::eSurface;
1785 if ( myRepresentation != ePoint )
1787 my2DActor->SetProperty(aProp);
1788 my2DActor->SetBackfaceProperty(aBackProp);
1789 my2DActor->SetRepresentation(aReperesent);
1791 if(aQuadraticMode == SMESH_Actor::eLines)
1792 my2DActor->SetQuadraticArcMode(false);
1793 else if(aQuadraticMode == SMESH_Actor::eArcs)
1794 my2DActor->SetQuadraticArcMode(true);
1796 my2DExtActor->SetRepresentation(aReperesent);
1798 my3DActor->SetProperty(aPropVN);
1799 my3DActor->SetBackfaceProperty(aPropVR);
1800 my3DActor->SetRepresentation(aReperesent);
1802 my0DActor->SetRepresentation(aReperesent);
1803 myBallActor->SetRepresentation(aReperesent);
1805 switch ( myControlMode ) {
1807 case eMultiConnection:
1808 aProp = aBackProp = my1DProp;
1809 if ( myRepresentation != ePoint )
1810 aReperesent = SMESH_DeviceActor::eInsideframe;
1815 if(aQuadraticMode == SMESH_Actor::eLines)
1816 my1DActor->SetQuadraticArcMode(false);
1817 else if(aQuadraticMode == SMESH_Actor::eArcs)
1818 my1DActor->SetQuadraticArcMode(true);
1820 my1DActor->SetProperty(aProp);
1821 my1DActor->SetBackfaceProperty(aBackProp);
1822 my1DActor->SetRepresentation(aReperesent);
1824 my1DExtActor->SetRepresentation(aReperesent);
1827 if(myIsPointsVisible)
1828 myPickableActor = myNodeActor;
1830 SetMapper(myPickableActor->GetMapper());
1832 SetVisibility(GetVisibility(),false);
1838 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1840 if ( myIsPointsVisible == theIsPointsVisible )
1842 myIsPointsVisible = theIsPointsVisible;
1843 SetRepresentation(GetRepresentation());
1846 bool SMESH_ActorDef::GetPointRepresentation()
1848 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1852 void SMESH_ActorDef::UpdateHighlight()
1854 myHighlitableActor->SetHighlited(false);
1855 myHighlitableActor->SetVisibility(false);
1856 bool anIsVisible = GetVisibility();
1858 switch(myRepresentation){
1859 case SMESH_DeviceActor::eSurface:
1860 case SMESH_DeviceActor::eWireframe:
1862 if(myIsHighlighted) {
1863 myHighlitableActor->SetProperty(myHighlightProp);
1864 }else if(myIsPreselected){
1865 myHighlitableActor->SetProperty(myPreselectProp);
1866 } else if(anIsVisible){
1867 (myRepresentation == eSurface) ?
1868 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1870 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1871 myHighlitableActor->SetHighlited(anIsVisible);
1872 myHighlitableActor->GetExtractUnstructuredGrid()->
1873 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1874 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1876 myHighlitableActor->SetVisibility(anIsVisible);
1879 case SMESH_DeviceActor::ePoint:
1881 if(myIsHighlighted) {
1882 myNodeActor->SetProperty(myHighlightProp);
1883 }else if(myIsPreselected) {
1884 myNodeActor->SetProperty(myPreselectProp);
1885 } else if(anIsVisible) {
1886 myNodeActor->SetProperty(myNodeProp);
1888 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1889 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1890 myNodeActor->GetProperty()->Modified();
1896 void SMESH_ActorDef::EnableSelection( bool enable )
1898 // selection in the Viewer enabled/disabled
1899 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1901 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1902 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1903 myBaseActor->myExtractUnstructuredGrid->Update();
1904 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1906 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1908 myBaseActor->SetUnstructuredGrid( NULL );
1909 //myHighlitableActor->SetUnstructuredGrid( NULL );
1910 myBaseActor->myExtractUnstructuredGrid->Update();
1911 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1915 void SMESH_ActorDef::highlight(bool theHighlight)
1917 if ( myIsHighlighted == theHighlight )
1919 myIsHighlighted = theHighlight;
1924 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1926 if ( myIsPreselected == thePreselect )
1928 myIsPreselected = thePreselect;
1934 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1936 if (myPickableActor->GetIsOpaque())
1938 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1946 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1948 if (!myPickableActor->GetIsOpaque())
1950 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1958 void SMESH_ActorDef::Render(vtkRenderer *ren)
1960 vtkMTimeType aTime = myTimeStamp->GetMTime();
1961 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1962 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1963 if(anObjTime > aTime || aClippingTime > aTime)
1968 void SMESH_ActorDef::Update()
1970 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1972 myVisualObj->Update();
1974 if(GetControlMode() != eNone) {
1975 unsigned long aTime = myTimeStamp->GetMTime();
1976 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1977 if (anObjTime > aTime)
1978 SetControlMode(GetControlMode(),false);
1982 myNodeActor->UpdateLabels();
1985 my0DActor->UpdateLabels();
1988 myBallActor->UpdateLabels();
1991 my1DActor->UpdateLabels();
1994 my2DActor->UpdateLabels();
1997 my3DActor->UpdateLabels();
1999 if(myIsFacesOriented){
2000 SetFacesOriented(myIsFacesOriented);
2003 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2004 // myEntityMode |= myVisualObj->GetEntitiesState();
2007 SetEntityMode(GetEntityMode());
2008 SetVisibility(GetVisibility());
2010 myTimeStamp->Modified();
2015 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2017 SALOME_Actor::ReleaseGraphicsResources(renWin);
2019 myPickableActor->ReleaseGraphicsResources(renWin);
2023 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2025 double* aColor = theProperty->GetColor();
2032 void SMESH_ActorDef::SetOpacity(double theValue)
2034 mySurfaceProp->SetOpacity(theValue);
2035 myBackSurfaceProp->SetOpacity(theValue);
2036 myNormalVProp->SetOpacity(theValue);
2037 myReversedVProp->SetOpacity(theValue);
2038 myEdgeProp->SetOpacity(theValue);
2039 myOutLineProp->SetOpacity(theValue);
2040 myNodeProp->SetOpacity(theValue);
2042 my1DProp->SetOpacity(theValue);
2043 my0DProp->SetOpacity(theValue);
2044 myBallProp->SetOpacity(theValue);
2048 double SMESH_ActorDef::GetOpacity()
2050 return mySurfaceProp->GetOpacity();
2054 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2056 mySurfaceProp->SetColor(r,g,b);
2057 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2058 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2059 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2060 myNameActor->SetBackgroundColor(r,g,b);
2062 myDeltaBrightness = delta;
2063 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2064 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2068 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2070 ::GetColor(mySurfaceProp,r,g,b);
2071 delta = myDeltaBrightness;
2074 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2076 myNormalVProp->SetColor(r,g,b);
2077 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2078 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2079 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2080 myNameActor->SetBackgroundColor(r,g,b);
2082 myDeltaVBrightness = delta;
2083 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2084 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2088 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2090 ::GetColor(myNormalVProp,r,g,b);
2091 delta = myDeltaVBrightness;
2094 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2096 myEdgeProp->SetColor(r,g,b);
2097 my1DProp->SetColor(r,g,b);
2098 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2099 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2100 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2101 myNameActor->SetBackgroundColor(r,g,b);
2105 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2107 ::GetColor(myEdgeProp,r,g,b);
2110 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2112 myOutLineProp->SetColor(r,g,b);
2116 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2118 ::GetColor(myOutLineProp,r,g,b);
2122 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2124 myNodeProp->SetColor(r,g,b);
2125 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2126 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2127 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2128 myNameActor->SetBackgroundColor(r,g,b);
2132 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2134 ::GetColor(myNodeProp,r,g,b);
2137 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2139 my0DProp->SetColor(r,g,b);
2140 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2141 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2142 myNameActor->SetBackgroundColor(r,g,b);
2146 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2148 ::GetColor(my0DProp,r,g,b);
2151 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2153 myBallProp->SetColor(r,g,b);
2154 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2155 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2156 myNameActor->SetBackgroundColor(r,g,b);
2160 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2162 ::GetColor(myBallProp,r,g,b);
2165 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2167 myHighlightProp->SetColor(r,g,b);
2171 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2173 ::GetColor(myHighlightProp,r,g,b);
2176 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2178 myPreselectProp->SetColor(r,g,b);
2182 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2184 ::GetColor(myPreselectProp,r,g,b);
2188 double SMESH_ActorDef::GetLineWidth()
2190 return myEdgeProp->GetLineWidth();
2194 void SMESH_ActorDef::SetLineWidth(double theVal)
2196 myEdgeProp->SetLineWidth(theVal);
2198 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2199 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2200 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2201 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2202 myOutLineProp->SetLineWidth(theVal);
2203 myHighlightProp->SetLineWidth(theVal);
2204 myPreselectProp->SetLineWidth(theVal);
2208 double SMESH_ActorDef::GetOutlineWidth()
2210 return myOutLineProp->GetLineWidth();
2213 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2215 myOutLineProp->SetLineWidth(theVal);
2219 void SMESH_ActorDef::Set0DSize(double theVal)
2221 my0DProp->SetPointSize(theVal);
2222 myHighlightProp->SetPointSize(theVal);
2223 myPreselectProp->SetPointSize(theVal);
2225 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2226 aCustom->Set0DSize(theVal);
2228 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2229 aCustom->Set0DSize(theVal);
2235 double SMESH_ActorDef::Get0DSize()
2237 return my0DProp->GetPointSize();
2240 void SMESH_ActorDef::SetBallSize(double theVal)
2242 myBallProp->SetPointSize(theVal);
2244 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2245 aCustom->SetBallSize(theVal);
2247 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2248 aCustom->SetBallSize(theVal);
2254 double SMESH_ActorDef::GetBallSize()
2256 return myBallProp->GetPointSize();
2259 double SMESH_ActorDef::GetBallScale()
2261 return myBallActor->GetBallScale();
2264 void SMESH_ActorDef::SetBallScale( double theVal )
2266 myBallActor->SetBallScale( theVal );
2267 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2268 aCustom->SetBallScale(theVal);
2270 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2271 aCustom->SetBallScale(theVal);
2277 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2279 return myVisualObj->GetElemDimension( theObjId );
2282 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2284 return myBaseActor->IsImplicitFunctionUsed();
2287 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2289 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2290 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2292 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2294 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2296 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2297 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2298 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2300 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2301 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2303 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2304 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2305 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2306 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2309 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2312 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2313 myCippingPlaneCont.push_back(thePlane);
2314 if(!IsImplicitFunctionUsed())
2315 SetImplicitFunctionUsed(true);
2316 myNodeActor->UpdateLabels();
2318 return myCippingPlaneCont.size();
2321 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2324 myPlaneCollection->AddItem( thePlane );
2327 void SMESH_ActorDef::SetOpenGLClippingPlane()
2329 // before use this method you must add clipping planes using method
2330 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2331 if( !myPlaneCollection->GetNumberOfItems() )
2334 // It is necessary to set plane collection for each mapper of actor
2335 // and update current inputs of mapper
2336 myNodeActor->SetPlaneCollection( myPlaneCollection );
2337 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2339 myBaseActor->SetPlaneCollection( myPlaneCollection );
2340 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2342 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2343 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2345 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2347 myBaseActor->SetUnstructuredGrid( NULL );
2348 //myHighlitableActor->SetUnstructuredGrid( NULL );
2350 my1DActor->SetPlaneCollection( myPlaneCollection );
2351 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2353 my2DActor->SetPlaneCollection( myPlaneCollection );
2354 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2356 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2357 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2359 my0DActor->SetPlaneCollection( myPlaneCollection );
2360 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2362 myBallActor->SetPlaneCollection( myPlaneCollection );
2363 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2365 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2366 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2368 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2369 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2371 my3DActor->SetPlaneCollection( myPlaneCollection );
2372 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2374 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2375 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2383 void SMESH_ActorDef::RemoveAllClippingPlanes()
2385 myPlaneCollection->RemoveAllItems();
2386 myImplicitBoolean->GetFunction()->RemoveAllItems();
2387 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2388 myCippingPlaneCont.clear();
2389 SetImplicitFunctionUsed(false);
2390 myNodeActor->UpdateLabels();
2393 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2395 return myCippingPlaneCont.size();
2398 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2400 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2402 return myCippingPlaneCont[theID].Get();
2405 void SMESH_ActorDef::UpdateScalarBar()
2407 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2411 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2413 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2414 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2416 aScalarBarTitleProp->SetFontFamilyToArial();
2418 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2420 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2421 if ( f.family() == "Arial" )
2422 aScalarBarTitleProp->SetFontFamilyToArial();
2423 else if ( f.family() == "Courier" )
2424 aScalarBarTitleProp->SetFontFamilyToCourier();
2425 else if ( f.family() == "Times" )
2426 aScalarBarTitleProp->SetFontFamilyToTimes();
2429 aScalarBarTitleProp->BoldOn();
2431 aScalarBarTitleProp->BoldOff();
2434 aScalarBarTitleProp->ItalicOn();
2436 aScalarBarTitleProp->ItalicOff();
2439 aScalarBarTitleProp->ShadowOn();
2441 aScalarBarTitleProp->ShadowOff();
2444 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2445 aScalarBarTitleProp->Delete();
2447 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2449 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2450 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2452 aScalarBarLabelProp->SetFontFamilyToArial();
2453 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2455 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2456 if( f.family() == "Arial" )
2457 aScalarBarLabelProp->SetFontFamilyToArial();
2458 else if( f.family() == "Courier" )
2459 aScalarBarLabelProp->SetFontFamilyToCourier();
2460 else if( f.family() == "Times" )
2461 aScalarBarLabelProp->SetFontFamilyToTimes();
2464 aScalarBarLabelProp->BoldOn();
2466 aScalarBarLabelProp->BoldOff();
2469 aScalarBarLabelProp->ItalicOn();
2471 aScalarBarLabelProp->ItalicOff();
2474 aScalarBarLabelProp->ShadowOn();
2476 aScalarBarLabelProp->ShadowOff();
2479 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2480 aScalarBarLabelProp->Delete();
2482 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2483 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2485 myScalarBarActor->SetOrientationToHorizontal();
2487 myScalarBarActor->SetOrientationToVertical();
2490 double aXVal = horiz ? 0.20 : 0.01;
2491 if( mgr->hasValue( "SMESH", name + "x" ) )
2492 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2494 double aYVal = horiz ? 0.01 : 0.1;
2495 if( mgr->hasValue( "SMESH", name + "y" ) )
2496 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2497 myScalarBarActor->SetPosition( aXVal, aYVal );
2499 double aWVal = horiz ? 0.60 : 0.10;
2500 if( mgr->hasValue( "SMESH", name + "width" ) )
2501 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2502 myScalarBarActor->SetWidth( aWVal );
2504 double aHVal = horiz ? 0.12 : 0.80;
2505 if( mgr->hasValue( "SMESH", name + "height" ) )
2506 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2507 myScalarBarActor->SetHeight( aHVal );
2510 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2511 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2512 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2515 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2516 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2517 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2519 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2520 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2522 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2523 myScalarBarActor->SetDistributionColoringType(coloringType);
2525 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2526 QColor(255, 255, 255));
2528 rgb[0]= distributionColor.red()/255.;
2529 rgb[1]= distributionColor.green()/255.;
2530 rgb[2]= distributionColor.blue()/255.;
2531 myScalarBarActor->SetDistributionColor(rgb);
2536 void SMESH_ActorDef::UpdateDistribution()
2538 if(SMESH::Controls::NumericalFunctor* fun =
2539 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2541 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2542 std::vector<int> nbEvents;
2543 std::vector<double> funValues;
2544 SMESH_VisualObjDef::TEntityList elems;
2545 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2546 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2547 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2548 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2549 elemIds.push_back( (*e)->GetID());
2550 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2551 double * range = lookupTable->GetRange();
2552 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2553 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2554 myScalarBarActor->SetDistribution(nbEvents);
2558 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2561 case SMESH_Actor::eLines :
2562 myHighlitableActor->SetQuadraticArcMode(false);
2563 my2DActor->SetQuadraticArcMode(false);
2564 my1DActor->SetQuadraticArcMode(false);
2566 case SMESH_Actor::eArcs :
2567 myHighlitableActor->SetQuadraticArcMode(true);
2568 if(GetRepresentation() != SMESH_Actor::ePoint) {
2569 my2DActor->SetQuadraticArcMode(true);
2570 my1DActor->SetQuadraticArcMode(true);
2579 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2581 if(myHighlitableActor->GetQuadraticArcMode())
2582 return SMESH_Actor::eArcs;
2584 return SMESH_Actor::eLines;
2587 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2589 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2590 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2591 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2594 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2596 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2597 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2598 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2599 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2602 #ifndef DISABLE_PLOT2DVIEWER
2603 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2606 my2dHistogram->clearAllPoints();
2608 if(SMESH::Controls::NumericalFunctor* fun =
2609 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2612 if(!my2dHistogram) {
2613 my2dHistogram = new SPlot2d_Histogram();
2614 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2615 my2dHistogram->setIO(anIO);
2618 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2619 std::vector<int> nbEvents;
2620 std::vector<double> funValues;
2621 SMESH_VisualObjDef::TEntityList elems;
2622 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2623 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2624 std::vector<int> elemIds;
2626 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2627 elemIds.push_back( (*e)->GetID());
2629 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2630 double * range = lookupTable->GetRange();
2631 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2632 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2634 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2635 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2637 if(funValues.size() >= 2)
2638 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2642 //Color of the histogram
2643 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2644 my2dHistogram->setAutoAssign(true);
2647 myScalarBarActor->GetDistributionColor(rgb);
2648 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2649 my2dHistogram->setColor(aColor);
2653 return my2dHistogram;