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::SetControlMode(eControl theMode)
809 SetControlMode(theMode,true);
813 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
815 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
816 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
817 lookupTable->SetScale(VTK_SCALE_LINEAR);
819 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
823 //myControlMode = eNone;
824 myControlMode = theMode;
825 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
827 my0DActor->GetMapper()->SetScalarVisibility(false);
828 my1DActor->GetMapper()->SetScalarVisibility(false);
829 my2DActor->GetMapper()->SetScalarVisibility(false);
830 my3DActor->GetMapper()->SetScalarVisibility(false);
831 myBallActor->GetMapper()->SetScalarVisibility(false);
832 myScalarBarActor->SetVisibility(false);
834 bool anIsScalarVisible = theMode > eNone;
836 if(anIsScalarVisible) {
840 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
841 aControl->SetPrecision( myControlsPrecision );
842 myFunctor.reset( aControl );
843 myControlActor = my1DActor;
848 myFunctor.reset(new SMESH::Controls::Length2D());
849 myControlActor = my2DActor;
853 myFunctor.reset(new SMESH::Controls::FreeBorders());
854 myControlActor = my1DActor;
857 myFunctor.reset(new SMESH::Controls::FreeEdges());
858 myControlActor = my2DActor;
861 myFunctor.reset(new SMESH::Controls::FreeNodes());
862 myControlActor = myNodeActor;
865 myFunctor.reset(new SMESH::Controls::FreeFaces());
866 myControlActor = my2DActor;
868 case eCoincidentNodes:
870 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
871 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
872 cn->SetTolerance( tol );
874 myControlActor = myNodeActor;
877 case eCoincidentElems1D:
878 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
879 myControlActor = my1DActor;
881 case eCoincidentElems2D:
882 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
883 myControlActor = my2DActor;
885 case eCoincidentElems3D:
886 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
887 myControlActor = my3DActor;
889 case eBareBorderFace:
890 myFunctor.reset(new SMESH::Controls::BareBorderFace());
891 myControlActor = my2DActor;
893 case eOverConstrainedFace:
894 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
895 myControlActor = my2DActor;
897 case eMultiConnection:
898 myFunctor.reset(new SMESH::Controls::MultiConnection());
899 myControlActor = my1DActor;
901 case eMultiConnection2D:
902 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
903 myControlActor = my2DActor;
907 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
908 aControl->SetPrecision( myControlsPrecision );
909 myFunctor.reset( aControl );
910 myControlActor = my2DActor;
915 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
916 aControl->SetPrecision( myControlsPrecision );
917 myFunctor.reset( aControl );
918 myControlActor = my2DActor;
923 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
924 aControl->SetPrecision( myControlsPrecision );
925 myFunctor.reset( aControl );
926 myControlActor = my2DActor;
931 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
932 aControl->SetPrecision( myControlsPrecision );
933 myFunctor.reset( aControl );
934 myControlActor = my3DActor;
939 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
940 aControl->SetPrecision( myControlsPrecision );
941 myFunctor.reset( aControl );
942 myControlActor = my3DActor;
945 case eMaxElementLength2D:
947 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
948 aControl->SetPrecision( myControlsPrecision );
949 myFunctor.reset( aControl );
950 myControlActor = my2DActor;
953 case eMaxElementLength3D:
955 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
956 aControl->SetPrecision( myControlsPrecision );
957 myFunctor.reset( aControl );
958 myControlActor = my3DActor;
961 case eBareBorderVolume:
963 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
964 myControlActor = my3DActor;
967 case eOverConstrainedVolume:
969 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
970 myControlActor = my3DActor;
975 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
976 aControl->SetPrecision( myControlsPrecision );
977 myFunctor.reset( aControl );
978 myControlActor = my2DActor;
983 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
984 aControl->SetPrecision( myControlsPrecision );
985 myFunctor.reset( aControl );
986 myControlActor = my2DActor;
991 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
992 aControl->SetPrecision( myControlsPrecision );
993 myFunctor.reset( aControl );
994 myControlActor = my2DActor;
997 case eNodeConnectivityNb:
999 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1000 myControlActor = myNodeActor;
1007 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1008 bool aShowOnlyScalarBarTitle = false;
1010 //myControlMode = theMode;
1011 switch(myControlMode){
1013 case eCoincidentNodes:
1014 myNodeExtActor->SetExtControlMode(myFunctor);
1015 aShowOnlyScalarBarTitle = true;
1019 case eCoincidentElems1D:
1020 my1DExtActor->SetExtControlMode(myFunctor);
1021 aShowOnlyScalarBarTitle = true;
1024 case eBareBorderFace:
1025 case eOverConstrainedFace:
1026 case eCoincidentElems2D:
1027 my2DExtActor->SetExtControlMode(myFunctor);
1028 aShowOnlyScalarBarTitle = true;
1030 case eBareBorderVolume:
1031 case eOverConstrainedVolume:
1032 case eCoincidentElems3D:
1033 my3DExtActor->SetExtControlMode(myFunctor);
1034 aShowOnlyScalarBarTitle = true;
1037 case eMultiConnection2D:
1038 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1039 UpdateDistribution();
1042 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1043 UpdateDistribution();
1045 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1048 if(theCheckEntityMode) {
1049 // if(myControlActor == myNodeActor) {
1050 // if ( myControlMode == eNodeConnectivityNb ) {
1051 // if (!myIsEntityModeCache){
1052 // myEntityModeCache = GetEntityMode();
1053 // myIsEntityModeCache=true;
1055 // SetEntityMode(0);
1058 if(myControlActor == my1DActor) {
1059 if (!myIsEntityModeCache){
1060 myEntityModeCache = GetEntityMode();
1061 myIsEntityModeCache=true;
1063 SetEntityMode(eEdges);
1065 else if(myControlActor == my2DActor) {
1066 if (!myIsEntityModeCache){
1067 myEntityModeCache = GetEntityMode();
1068 myIsEntityModeCache=true;
1070 SetEntityMode(eFaces);
1072 else if(myControlActor == my3DActor) {
1073 if (!myIsEntityModeCache){
1074 myEntityModeCache = GetEntityMode();
1075 myIsEntityModeCache=true;
1077 SetEntityMode(eVolumes);
1080 QString aTitle = QString(myScalarBarActor->GetTitle());
1081 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1082 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1086 if(theCheckEntityMode){
1087 myEntityMode = myEntityModeCache;
1088 myIsEntityModeCache = false;
1093 SetRepresentation(GetRepresentation());
1095 myTimeStamp->Modified();
1098 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1099 double * range = lookupTable->GetRange();
1101 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1102 lookupTable->SetScale(VTK_SCALE_LOG10);
1107 int SMESH_ActorDef::GetNumberControlEntities()
1109 SMESH_DeviceActor* anAct = NULL;
1110 switch(myControlMode){
1112 case eCoincidentNodes:
1113 anAct = myNodeExtActor;
1117 case eCoincidentElems1D:
1118 anAct = my1DExtActor;
1121 case eBareBorderFace:
1122 case eOverConstrainedFace:
1123 case eCoincidentElems2D:
1124 anAct = my2DExtActor;
1126 case eBareBorderVolume:
1127 case eOverConstrainedVolume:
1128 case eCoincidentElems3D:
1129 anAct = my3DExtActor;
1133 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1136 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1138 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1140 myBaseActor->SetUnstructuredGrid( NULL );
1141 //myHighlitableActor->SetUnstructuredGrid( NULL );
1143 theRenderer->AddActor(myBaseActor);
1144 theRenderer->AddActor(myNodeExtActor);
1145 theRenderer->AddActor(my1DExtActor);
1147 my3DActor ->AddToRender(theRenderer);
1148 my3DExtActor->AddToRender(theRenderer);
1149 my2DActor ->AddToRender(theRenderer);
1150 my2DExtActor->AddToRender(theRenderer);
1151 myNodeActor ->AddToRender(theRenderer);
1152 my1DActor ->AddToRender(theRenderer);
1153 my0DActor ->AddToRender(theRenderer);
1154 myBallActor ->AddToRender(theRenderer);
1156 theRenderer->AddActor(myHighlitableActor);
1158 theRenderer->AddActor2D(myScalarBarActor);
1160 // the superclass' method should be called at the end
1161 // (in particular, for correct work of selection)
1162 SALOME_Actor::AddToRender(theRenderer);
1165 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1167 SALOME_Actor::RemoveFromRender(theRenderer);
1169 theRenderer->RemoveActor(myBaseActor);
1171 theRenderer->RemoveActor(myNodeExtActor);
1173 theRenderer->RemoveActor(myHighlitableActor);
1175 //theRenderer->RemoveActor(my0DExtActor);
1177 theRenderer->RemoveActor(my1DExtActor);
1179 my2DActor->RemoveFromRender(theRenderer);
1180 my2DExtActor->RemoveFromRender(theRenderer);
1181 my3DActor->RemoveFromRender(theRenderer);
1182 my3DExtActor->RemoveFromRender(theRenderer);
1183 myNodeActor->RemoveFromRender(theRenderer);
1184 my0DActor->RemoveFromRender(theRenderer);
1185 myBallActor->RemoveFromRender(theRenderer);
1186 my1DActor->RemoveFromRender(theRenderer);
1188 theRenderer->RemoveActor(myScalarBarActor);
1192 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1193 const char* theEntry,
1194 const char* theName,
1197 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1201 myVisualObj = theVisualObj;
1202 myVisualObj->Update(theIsClear);
1204 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1205 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1207 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1208 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1210 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1212 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1214 my0DActor->Init(myVisualObj,myImplicitBoolean);
1215 myBallActor->Init(myVisualObj,myImplicitBoolean);
1216 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1218 my1DActor->Init(myVisualObj,myImplicitBoolean);
1219 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1221 my2DActor->Init(myVisualObj,myImplicitBoolean);
1222 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1223 my3DActor->Init(myVisualObj,myImplicitBoolean);
1224 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1226 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1227 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1228 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1230 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1231 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1233 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1234 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1235 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1236 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1238 double aFactor, aUnits;
1239 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1240 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1241 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1242 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1244 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1248 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1249 SetIsShrunkable(true);
1251 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1253 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1254 SetRepresentation(-1);
1257 SetRepresentation(eEdge);
1258 }else if(aMode == 1){
1259 SetRepresentation(eSurface);
1260 }else if(aMode == 2){
1261 SetRepresentation(ePoint);
1268 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1269 SetIsDisplayNameActor( true );
1271 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1272 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1273 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1275 myTimeStamp->Modified();
1281 double* SMESH_ActorDef::GetBounds()
1283 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1284 return myNodeActor->GetBounds();
1285 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1289 vtkDataSet* SMESH_ActorDef::GetInput()
1291 return GetUnstructuredGrid();
1295 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1297 Superclass::SetTransform(theTransform);
1299 myNodeActor->SetTransform(theTransform);
1300 myBaseActor->SetTransform(theTransform);
1302 myHighlitableActor->SetTransform(theTransform);
1304 myNodeExtActor->SetTransform(theTransform);
1306 my0DActor->SetTransform(theTransform);
1307 myBallActor->SetTransform(theTransform);
1308 //my0DExtActor->SetTransform(theTransform);
1310 my1DActor->SetTransform(theTransform);
1311 my1DExtActor->SetTransform(theTransform);
1313 my2DActor->SetTransform(theTransform);
1314 my2DExtActor->SetTransform(theTransform);
1315 my3DActor->SetTransform(theTransform);
1316 my3DExtActor->SetTransform(theTransform);
1322 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1324 vtkLODActor::SetMapper(theMapper);
1328 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1330 SALOME_Actor::ShallowCopy(prop);
1334 vtkMapper* SMESH_ActorDef::GetMapper()
1336 return myPickableActor->GetMapper();
1340 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1342 return myVisualObj->GetUnstructuredGrid();
1346 bool SMESH_ActorDef::IsInfinitive()
1348 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1349 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1350 ( aDataSet->GetNumberOfCells() == 1 &&
1351 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1352 return SALOME_Actor::IsInfinitive();
1356 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1358 if ( myIsShrinkable == theShrunkable )
1360 myIsShrinkable = theShrunkable;
1364 double SMESH_ActorDef::GetShrinkFactor()
1366 return myBaseActor->GetShrinkFactor();
1369 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1371 myBaseActor->SetShrinkFactor(theValue);
1373 my1DActor->SetShrinkFactor(theValue);
1374 my1DExtActor->SetShrinkFactor(theValue);
1376 my2DActor->SetShrinkFactor(theValue);
1377 my2DExtActor->SetShrinkFactor(theValue);
1378 my3DActor->SetShrinkFactor(theValue);
1379 my3DExtActor->SetShrinkFactor(theValue);
1380 my3DExtActor->SetShrinkFactor(theValue);
1381 myHighlitableActor->SetShrinkFactor(theValue);
1386 void SMESH_ActorDef::SetShrink()
1388 if(!myIsShrinkable) return;
1390 myBaseActor->SetShrink();
1392 my1DActor->SetShrink();
1393 my1DExtActor->SetShrink();
1395 my2DActor->SetShrink();
1396 my2DExtActor->SetShrink();
1397 my3DActor->SetShrink();
1398 my3DExtActor->SetShrink();
1399 myHighlitableActor->SetShrink();
1405 void SMESH_ActorDef::UnShrink()
1407 if(!myIsShrunk) return;
1409 myBaseActor->UnShrink();
1411 my1DActor->UnShrink();
1412 my1DExtActor->UnShrink();
1414 my2DActor->UnShrink();
1415 my2DExtActor->UnShrink();
1416 my3DActor->UnShrink();
1417 my3DExtActor->UnShrink();
1418 myHighlitableActor->UnShrink();
1425 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1427 return myPickableActor->GetNodeObjId(theVtkID);
1430 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1432 return myPickableActor->GetNodeCoord(theObjID);
1436 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1438 return myPickableActor->GetElemObjId(theVtkID);
1441 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1443 return myPickableActor->GetElemCell(theObjID);
1447 void SMESH_ActorDef::SetVisibility(int theMode)
1449 SetVisibility(theMode,true);
1453 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1455 SALOME_Actor::SetVisibility(theMode);
1457 myNodeActor->VisibilityOff();
1458 myBaseActor->VisibilityOff();
1460 myNodeExtActor->VisibilityOff();
1462 my0DActor->VisibilityOff();
1463 myBallActor->VisibilityOff();
1464 //my0DExtActor->VisibilityOff();
1466 my1DActor->VisibilityOff();
1467 my1DExtActor->VisibilityOff();
1469 my2DActor->VisibilityOff();
1470 my2DExtActor->VisibilityOff();
1471 my3DActor->VisibilityOff();
1472 my3DExtActor->VisibilityOff();
1474 myScalarBarActor->VisibilityOff();
1476 if ( GetVisibility() ) {
1477 if ( theIsUpdateRepersentation )
1478 SetRepresentation(GetRepresentation());
1480 if(myControlMode != eNone) {
1481 switch(myControlMode) {
1483 case eCoincidentNodes:
1484 myNodeExtActor->VisibilityOn();
1487 case eMultiConnection:
1488 my1DActor->VisibilityOn();
1492 case eCoincidentElems1D:
1494 case eMultiConnection2D:
1495 my1DExtActor->VisibilityOn();
1498 case eBareBorderFace:
1499 case eOverConstrainedFace:
1500 case eCoincidentElems2D:
1501 my2DExtActor->VisibilityOn();
1503 case eBareBorderVolume:
1504 case eOverConstrainedVolume:
1505 case eCoincidentElems3D:
1506 my3DExtActor->VisibilityOn();
1510 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1511 myScalarBarActor->VisibilityOn();
1514 myPickableActor->VisibilityOn();
1516 if ( GetRepresentation() != ePoint )
1518 if(myEntityMode & e0DElements ){
1519 my0DActor->VisibilityOn();
1521 if(myEntityMode & eBallElem ){
1522 myBallActor->VisibilityOn();
1524 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1525 my1DActor->VisibilityOn();
1527 if(myEntityMode & eFaces ){
1528 my2DActor->VisibilityOn();
1530 if(myEntityMode & eVolumes ){
1531 my3DActor->VisibilityOn();
1535 if(myNodeActor->GetPointsLabeled()) {
1536 myNodeActor->UpdateLabels();
1537 myNodeActor->VisibilityOn();
1540 my0DActor->UpdateLabels();
1543 myBallActor->UpdateLabels();
1546 my1DActor->UpdateLabels();
1549 my2DActor->UpdateLabels();
1552 my3DActor->UpdateLabels();
1554 #ifndef DISABLE_PLOT2DVIEWER
1556 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1563 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1565 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1567 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1568 anObjectEntities &= ~e0DElements;
1569 theMode &= ~e0DElements;
1572 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1573 anObjectEntities &= ~eBallElem;
1574 theMode &= ~eBallElem;
1577 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1578 anObjectEntities &= ~eEdges;
1582 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1583 anObjectEntities &= ~eFaces;
1587 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1588 anObjectEntities &= ~eVolumes;
1589 theMode &= ~eVolumes;
1593 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1594 theMode |= e0DElements;
1596 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1597 theMode |= eBallElem;
1599 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1602 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1605 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1606 theMode |= eVolumes;
1609 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1611 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1613 myRepresentationCache = GetRepresentation();
1614 SetRepresentation( ePoint );
1617 if ( myEntityMode != theMode )
1619 myEntityMode = theMode; // entities to show
1621 // Set cell types to extract
1623 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1624 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1625 aFilter->ClearRegisteredCellsWithType();
1626 aHltFilter->ClearRegisteredCellsWithType();
1628 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1631 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1632 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1636 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1637 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1639 if (myEntityMode & e0DElements) {
1640 aFilter->RegisterCellsWithType(VTK_VERTEX);
1641 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1644 if (myEntityMode & eBallElem) {
1645 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1648 if (myEntityMode & eEdges) {
1649 aFilter->RegisterCellsWithType(VTK_LINE);
1650 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1652 aHltFilter->RegisterCellsWithType(VTK_LINE);
1653 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1656 if (myEntityMode & eFaces) {
1657 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1658 aFilter->RegisterCellsWithType(VTK_QUAD);
1659 aFilter->RegisterCellsWithType(VTK_POLYGON);
1660 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1661 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1662 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1663 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1664 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1666 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1667 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1668 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1669 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1670 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1671 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1672 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1673 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1676 if (myEntityMode & eVolumes) {
1677 aFilter->RegisterCellsWithType(VTK_TETRA);
1678 aFilter->RegisterCellsWithType(VTK_VOXEL);
1679 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1680 aFilter->RegisterCellsWithType(VTK_WEDGE);
1681 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1682 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1683 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1684 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1685 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1686 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1687 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1688 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1689 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1690 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1692 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1693 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1694 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1695 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1696 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1697 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1698 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1699 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1700 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1701 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1702 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1703 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1704 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1705 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1708 if ( GetVisibility() )
1710 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1713 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1716 void SMESH_ActorDef::SetRepresentation (int theMode)
1718 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1719 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1720 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1721 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1722 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1724 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1726 theMode = myRepresentationCache;
1727 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1730 myRepresentationCache = 0;
1734 myRepresentation = eSurface;
1735 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1736 myRepresentation = eEdge;
1737 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1738 myRepresentation = ePoint;
1743 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1746 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1749 myRepresentation = theMode;
1752 if (!GetUnstructuredGrid()->GetNumberOfCells())
1753 myRepresentation = ePoint;
1756 if (myRepresentation == ePoint) {
1764 myPickableActor = myBaseActor;
1765 vtkProperty *aProp = NULL, *aBackProp = NULL;
1766 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1767 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1768 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1769 switch (myRepresentation) {
1771 myPickableActor = myNodeActor;
1772 aQuadraticMode = SMESH_Actor::eLines;
1773 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1774 aReperesent = SMESH_DeviceActor::ePoint;
1777 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1778 aReperesent = SMESH_DeviceActor::eInsideframe;
1781 aProp = mySurfaceProp;
1782 aBackProp = myBackSurfaceProp;
1783 aPropVN = myNormalVProp;
1784 aPropVR = myReversedVProp;
1785 aReperesent = SMESH_DeviceActor::eSurface;
1789 if ( myRepresentation != ePoint )
1791 my2DActor->SetProperty(aProp);
1792 my2DActor->SetBackfaceProperty(aBackProp);
1793 my2DActor->SetRepresentation(aReperesent);
1795 if(aQuadraticMode == SMESH_Actor::eLines)
1796 my2DActor->SetQuadraticArcMode(false);
1797 else if(aQuadraticMode == SMESH_Actor::eArcs)
1798 my2DActor->SetQuadraticArcMode(true);
1800 my2DExtActor->SetRepresentation(aReperesent);
1802 my3DActor->SetProperty(aPropVN);
1803 my3DActor->SetBackfaceProperty(aPropVR);
1804 my3DActor->SetRepresentation(aReperesent);
1806 my0DActor->SetRepresentation(aReperesent);
1807 myBallActor->SetRepresentation(aReperesent);
1809 switch ( myControlMode ) {
1811 case eMultiConnection:
1812 aProp = aBackProp = my1DProp;
1813 if ( myRepresentation != ePoint )
1814 aReperesent = SMESH_DeviceActor::eInsideframe;
1819 if(aQuadraticMode == SMESH_Actor::eLines)
1820 my1DActor->SetQuadraticArcMode(false);
1821 else if(aQuadraticMode == SMESH_Actor::eArcs)
1822 my1DActor->SetQuadraticArcMode(true);
1824 my1DActor->SetProperty(aProp);
1825 my1DActor->SetBackfaceProperty(aBackProp);
1826 my1DActor->SetRepresentation(aReperesent);
1828 my1DExtActor->SetRepresentation(aReperesent);
1831 if(myIsPointsVisible)
1832 myPickableActor = myNodeActor;
1834 SetMapper(myPickableActor->GetMapper());
1836 SetVisibility(GetVisibility(),false);
1842 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1844 if ( myIsPointsVisible == theIsPointsVisible )
1846 myIsPointsVisible = theIsPointsVisible;
1847 SetRepresentation(GetRepresentation());
1850 bool SMESH_ActorDef::GetPointRepresentation()
1852 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1856 void SMESH_ActorDef::UpdateHighlight()
1858 myHighlitableActor->SetHighlited(false);
1859 myHighlitableActor->SetVisibility(false);
1860 bool anIsVisible = GetVisibility();
1862 switch(myRepresentation){
1863 case SMESH_DeviceActor::eSurface:
1864 case SMESH_DeviceActor::eWireframe:
1866 if(myIsHighlighted) {
1867 myHighlitableActor->SetProperty(myHighlightProp);
1868 }else if(myIsPreselected){
1869 myHighlitableActor->SetProperty(myPreselectProp);
1870 } else if(anIsVisible){
1871 (myRepresentation == eSurface) ?
1872 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1874 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1875 myHighlitableActor->SetHighlited(anIsVisible);
1876 myHighlitableActor->GetExtractUnstructuredGrid()->
1877 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1878 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1880 myHighlitableActor->SetVisibility(anIsVisible);
1883 case SMESH_DeviceActor::ePoint:
1885 if(myIsHighlighted) {
1886 myNodeActor->SetProperty(myHighlightProp);
1887 }else if(myIsPreselected) {
1888 myNodeActor->SetProperty(myPreselectProp);
1889 } else if(anIsVisible) {
1890 myNodeActor->SetProperty(myNodeProp);
1892 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1893 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1894 myNodeActor->GetProperty()->Modified();
1900 void SMESH_ActorDef::EnableSelection( bool enable )
1902 // selection in the Viewer enabled/disabled
1903 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1905 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1906 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1907 myBaseActor->myExtractUnstructuredGrid->Update();
1908 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1910 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1912 myBaseActor->SetUnstructuredGrid( NULL );
1913 //myHighlitableActor->SetUnstructuredGrid( NULL );
1914 myBaseActor->myExtractUnstructuredGrid->Update();
1915 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1919 void SMESH_ActorDef::highlight(bool theHighlight)
1921 if ( myIsHighlighted == theHighlight )
1923 myIsHighlighted = theHighlight;
1928 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1930 if ( myIsPreselected == thePreselect )
1932 myIsPreselected = thePreselect;
1938 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1940 if (myPickableActor->GetIsOpaque())
1942 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1950 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1952 if (!myPickableActor->GetIsOpaque())
1954 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1962 void SMESH_ActorDef::Render(vtkRenderer *ren)
1964 vtkMTimeType aTime = myTimeStamp->GetMTime();
1965 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1966 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1967 if(anObjTime > aTime || aClippingTime > aTime)
1972 void SMESH_ActorDef::Update()
1974 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1976 myVisualObj->Update();
1978 if(GetControlMode() != eNone) {
1979 unsigned long aTime = myTimeStamp->GetMTime();
1980 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1981 if (anObjTime > aTime)
1982 SetControlMode(GetControlMode(),false);
1986 myNodeActor->UpdateLabels();
1989 my0DActor->UpdateLabels();
1992 myBallActor->UpdateLabels();
1995 my1DActor->UpdateLabels();
1998 my2DActor->UpdateLabels();
2001 my3DActor->UpdateLabels();
2003 if(myIsFacesOriented){
2004 SetFacesOriented(myIsFacesOriented);
2007 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2008 // myEntityMode |= myVisualObj->GetEntitiesState();
2011 SetEntityMode(GetEntityMode());
2012 SetVisibility(GetVisibility());
2014 myTimeStamp->Modified();
2019 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2021 SALOME_Actor::ReleaseGraphicsResources(renWin);
2023 myPickableActor->ReleaseGraphicsResources(renWin);
2027 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2029 double* aColor = theProperty->GetColor();
2036 void SMESH_ActorDef::SetOpacity(double theValue)
2038 mySurfaceProp->SetOpacity(theValue);
2039 myBackSurfaceProp->SetOpacity(theValue);
2040 myNormalVProp->SetOpacity(theValue);
2041 myReversedVProp->SetOpacity(theValue);
2042 myEdgeProp->SetOpacity(theValue);
2043 myOutLineProp->SetOpacity(theValue);
2044 myNodeProp->SetOpacity(theValue);
2046 my1DProp->SetOpacity(theValue);
2047 my0DProp->SetOpacity(theValue);
2048 myBallProp->SetOpacity(theValue);
2052 double SMESH_ActorDef::GetOpacity()
2054 return mySurfaceProp->GetOpacity();
2058 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2060 mySurfaceProp->SetColor(r,g,b);
2061 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2062 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2063 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2064 myNameActor->SetBackgroundColor(r,g,b);
2066 myDeltaBrightness = delta;
2067 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2068 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2072 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2074 ::GetColor(mySurfaceProp,r,g,b);
2075 delta = myDeltaBrightness;
2078 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2080 myNormalVProp->SetColor(r,g,b);
2081 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2082 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2083 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2084 myNameActor->SetBackgroundColor(r,g,b);
2086 myDeltaVBrightness = delta;
2087 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2088 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2092 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2094 ::GetColor(myNormalVProp,r,g,b);
2095 delta = myDeltaVBrightness;
2098 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2100 myEdgeProp->SetColor(r,g,b);
2101 my1DProp->SetColor(r,g,b);
2102 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2103 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2104 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2105 myNameActor->SetBackgroundColor(r,g,b);
2109 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2111 ::GetColor(myEdgeProp,r,g,b);
2114 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2116 myOutLineProp->SetColor(r,g,b);
2120 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2122 ::GetColor(myOutLineProp,r,g,b);
2126 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2128 myNodeProp->SetColor(r,g,b);
2129 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2130 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2131 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2132 myNameActor->SetBackgroundColor(r,g,b);
2136 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2138 ::GetColor(myNodeProp,r,g,b);
2141 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2143 my0DProp->SetColor(r,g,b);
2144 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2145 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2146 myNameActor->SetBackgroundColor(r,g,b);
2150 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2152 ::GetColor(my0DProp,r,g,b);
2155 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2157 myBallProp->SetColor(r,g,b);
2158 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2159 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2160 myNameActor->SetBackgroundColor(r,g,b);
2164 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2166 ::GetColor(myBallProp,r,g,b);
2169 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2171 myHighlightProp->SetColor(r,g,b);
2175 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2177 ::GetColor(myHighlightProp,r,g,b);
2180 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2182 myPreselectProp->SetColor(r,g,b);
2186 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2188 ::GetColor(myPreselectProp,r,g,b);
2192 double SMESH_ActorDef::GetLineWidth()
2194 return myEdgeProp->GetLineWidth();
2198 void SMESH_ActorDef::SetLineWidth(double theVal)
2200 myEdgeProp->SetLineWidth(theVal);
2202 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2203 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2204 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2205 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2206 myOutLineProp->SetLineWidth(theVal);
2207 myHighlightProp->SetLineWidth(theVal);
2208 myPreselectProp->SetLineWidth(theVal);
2212 double SMESH_ActorDef::GetOutlineWidth()
2214 return myOutLineProp->GetLineWidth();
2217 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2219 myOutLineProp->SetLineWidth(theVal);
2223 void SMESH_ActorDef::Set0DSize(double theVal)
2225 my0DProp->SetPointSize(theVal);
2226 myHighlightProp->SetPointSize(theVal);
2227 myPreselectProp->SetPointSize(theVal);
2229 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2230 aCustom->Set0DSize(theVal);
2232 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2233 aCustom->Set0DSize(theVal);
2239 double SMESH_ActorDef::Get0DSize()
2241 return my0DProp->GetPointSize();
2244 void SMESH_ActorDef::SetBallSize(double theVal)
2246 myBallProp->SetPointSize(theVal);
2248 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2249 aCustom->SetBallSize(theVal);
2251 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2252 aCustom->SetBallSize(theVal);
2258 double SMESH_ActorDef::GetBallSize()
2260 return myBallProp->GetPointSize();
2263 double SMESH_ActorDef::GetBallScale()
2265 return myBallActor->GetBallScale();
2268 void SMESH_ActorDef::SetBallScale( double theVal )
2270 myBallActor->SetBallScale( theVal );
2271 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2272 aCustom->SetBallScale(theVal);
2274 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2275 aCustom->SetBallScale(theVal);
2281 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2283 return myVisualObj->GetElemDimension( theObjId );
2286 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2288 return myBaseActor->IsImplicitFunctionUsed();
2291 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2293 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2294 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2296 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2298 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2300 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2301 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2302 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2304 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2305 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2307 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2308 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2309 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2310 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2313 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2316 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2317 myCippingPlaneCont.push_back(thePlane);
2318 if(!IsImplicitFunctionUsed())
2319 SetImplicitFunctionUsed(true);
2320 myNodeActor->UpdateLabels();
2322 return myCippingPlaneCont.size();
2325 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2328 myPlaneCollection->AddItem( thePlane );
2331 void SMESH_ActorDef::SetOpenGLClippingPlane()
2333 // before use this method you must add clipping planes using method
2334 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2335 if( !myPlaneCollection->GetNumberOfItems() )
2338 // It is necessary to set plane collection for each mapper of actor
2339 // and update current inputs of mapper
2340 myNodeActor->SetPlaneCollection( myPlaneCollection );
2341 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2343 myBaseActor->SetPlaneCollection( myPlaneCollection );
2344 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2346 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2347 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2349 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2351 myBaseActor->SetUnstructuredGrid( NULL );
2352 //myHighlitableActor->SetUnstructuredGrid( NULL );
2354 my1DActor->SetPlaneCollection( myPlaneCollection );
2355 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2357 my2DActor->SetPlaneCollection( myPlaneCollection );
2358 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2360 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2361 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2363 my0DActor->SetPlaneCollection( myPlaneCollection );
2364 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2366 myBallActor->SetPlaneCollection( myPlaneCollection );
2367 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2369 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2370 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2372 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2373 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2375 my3DActor->SetPlaneCollection( myPlaneCollection );
2376 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2378 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2379 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2387 void SMESH_ActorDef::RemoveAllClippingPlanes()
2389 myPlaneCollection->RemoveAllItems();
2390 myImplicitBoolean->GetFunction()->RemoveAllItems();
2391 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2392 myCippingPlaneCont.clear();
2393 SetImplicitFunctionUsed(false);
2394 myNodeActor->UpdateLabels();
2397 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2399 return myCippingPlaneCont.size();
2402 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2404 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2406 return myCippingPlaneCont[theID].Get();
2409 void SMESH_ActorDef::UpdateScalarBar()
2411 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2415 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2417 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2418 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2420 aScalarBarTitleProp->SetFontFamilyToArial();
2422 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2424 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2425 if ( f.family() == "Arial" )
2426 aScalarBarTitleProp->SetFontFamilyToArial();
2427 else if ( f.family() == "Courier" )
2428 aScalarBarTitleProp->SetFontFamilyToCourier();
2429 else if ( f.family() == "Times" )
2430 aScalarBarTitleProp->SetFontFamilyToTimes();
2433 aScalarBarTitleProp->BoldOn();
2435 aScalarBarTitleProp->BoldOff();
2438 aScalarBarTitleProp->ItalicOn();
2440 aScalarBarTitleProp->ItalicOff();
2443 aScalarBarTitleProp->ShadowOn();
2445 aScalarBarTitleProp->ShadowOff();
2448 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2449 aScalarBarTitleProp->Delete();
2451 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2453 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2454 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2456 aScalarBarLabelProp->SetFontFamilyToArial();
2457 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2459 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2460 if( f.family() == "Arial" )
2461 aScalarBarLabelProp->SetFontFamilyToArial();
2462 else if( f.family() == "Courier" )
2463 aScalarBarLabelProp->SetFontFamilyToCourier();
2464 else if( f.family() == "Times" )
2465 aScalarBarLabelProp->SetFontFamilyToTimes();
2468 aScalarBarLabelProp->BoldOn();
2470 aScalarBarLabelProp->BoldOff();
2473 aScalarBarLabelProp->ItalicOn();
2475 aScalarBarLabelProp->ItalicOff();
2478 aScalarBarLabelProp->ShadowOn();
2480 aScalarBarLabelProp->ShadowOff();
2483 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2484 aScalarBarLabelProp->Delete();
2486 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2487 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2489 myScalarBarActor->SetOrientationToHorizontal();
2491 myScalarBarActor->SetOrientationToVertical();
2494 double aXVal = horiz ? 0.20 : 0.01;
2495 if( mgr->hasValue( "SMESH", name + "x" ) )
2496 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2498 double aYVal = horiz ? 0.01 : 0.1;
2499 if( mgr->hasValue( "SMESH", name + "y" ) )
2500 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2501 myScalarBarActor->SetPosition( aXVal, aYVal );
2503 double aWVal = horiz ? 0.60 : 0.10;
2504 if( mgr->hasValue( "SMESH", name + "width" ) )
2505 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2506 myScalarBarActor->SetWidth( aWVal );
2508 double aHVal = horiz ? 0.12 : 0.80;
2509 if( mgr->hasValue( "SMESH", name + "height" ) )
2510 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2511 myScalarBarActor->SetHeight( aHVal );
2514 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2515 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2516 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2519 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2520 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2521 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2523 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2524 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2526 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2527 myScalarBarActor->SetDistributionColoringType(coloringType);
2529 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2530 QColor(255, 255, 255));
2532 rgb[0]= distributionColor.red()/255.;
2533 rgb[1]= distributionColor.green()/255.;
2534 rgb[2]= distributionColor.blue()/255.;
2535 myScalarBarActor->SetDistributionColor(rgb);
2540 void SMESH_ActorDef::UpdateDistribution()
2542 if(SMESH::Controls::NumericalFunctor* fun =
2543 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2545 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2546 std::vector<int> nbEvents;
2547 std::vector<double> funValues;
2548 SMESH_VisualObjDef::TEntityList elems;
2549 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2550 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2551 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2552 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2553 elemIds.push_back( (*e)->GetID());
2554 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2555 double * range = lookupTable->GetRange();
2556 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2557 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2558 myScalarBarActor->SetDistribution(nbEvents);
2562 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2565 case SMESH_Actor::eLines :
2566 myHighlitableActor->SetQuadraticArcMode(false);
2567 my2DActor->SetQuadraticArcMode(false);
2568 my1DActor->SetQuadraticArcMode(false);
2570 case SMESH_Actor::eArcs :
2571 myHighlitableActor->SetQuadraticArcMode(true);
2572 if(GetRepresentation() != SMESH_Actor::ePoint) {
2573 my2DActor->SetQuadraticArcMode(true);
2574 my1DActor->SetQuadraticArcMode(true);
2583 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2585 if(myHighlitableActor->GetQuadraticArcMode())
2586 return SMESH_Actor::eArcs;
2588 return SMESH_Actor::eLines;
2591 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2593 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2594 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2595 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2598 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2600 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2601 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2602 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2603 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2606 #ifndef DISABLE_PLOT2DVIEWER
2607 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2610 my2dHistogram->clearAllPoints();
2612 if(SMESH::Controls::NumericalFunctor* fun =
2613 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2616 if(!my2dHistogram) {
2617 my2dHistogram = new SPlot2d_Histogram();
2618 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2619 my2dHistogram->setIO(anIO);
2622 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2623 std::vector<int> nbEvents;
2624 std::vector<double> funValues;
2625 SMESH_VisualObjDef::TEntityList elems;
2626 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2627 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2628 std::vector<int> elemIds;
2630 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2631 elemIds.push_back( (*e)->GetID());
2633 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2634 double * range = lookupTable->GetRange();
2635 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2636 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2638 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2639 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2641 if(funValues.size() >= 2)
2642 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2646 //Color of the histogram
2647 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2648 my2dHistogram->setAutoAssign(true);
2651 myScalarBarActor->GetDistributionColor(rgb);
2652 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2653 my2dHistogram->setColor(aColor);
2657 return my2dHistogram;