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;
847 myFunctor.reset(new SMESH::Controls::Length2D());
848 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;
961 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
962 aControl->SetPrecision( myControlsPrecision );
963 myFunctor.reset( aControl );
964 myControlActor = my2DActor;
967 case eBareBorderVolume:
969 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
970 myControlActor = my3DActor;
973 case eOverConstrainedVolume:
975 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
976 myControlActor = my3DActor;
981 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
982 aControl->SetPrecision( myControlsPrecision );
983 myFunctor.reset( aControl );
984 myControlActor = my2DActor;
989 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
997 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
998 aControl->SetPrecision( myControlsPrecision );
999 myFunctor.reset( aControl );
1000 myControlActor = my2DActor;
1003 case eNodeConnectivityNb:
1005 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1006 myControlActor = myNodeActor;
1013 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1014 bool aShowOnlyScalarBarTitle = false;
1016 //myControlMode = theMode;
1017 switch(myControlMode){
1019 case eCoincidentNodes:
1020 myNodeExtActor->SetExtControlMode(myFunctor);
1021 aShowOnlyScalarBarTitle = true;
1025 case eCoincidentElems1D:
1026 my1DExtActor->SetExtControlMode(myFunctor);
1027 aShowOnlyScalarBarTitle = true;
1030 case eBareBorderFace:
1031 case eOverConstrainedFace:
1032 case eCoincidentElems2D:
1033 my2DExtActor->SetExtControlMode(myFunctor);
1034 aShowOnlyScalarBarTitle = true;
1036 case eBareBorderVolume:
1037 case eOverConstrainedVolume:
1038 case eCoincidentElems3D:
1039 my3DExtActor->SetExtControlMode(myFunctor);
1040 aShowOnlyScalarBarTitle = true;
1043 case eMultiConnection2D:
1044 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1045 UpdateDistribution();
1048 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1049 UpdateDistribution();
1051 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1054 if(theCheckEntityMode) {
1055 // if(myControlActor == myNodeActor) {
1056 // if ( myControlMode == eNodeConnectivityNb ) {
1057 // if (!myIsEntityModeCache){
1058 // myEntityModeCache = GetEntityMode();
1059 // myIsEntityModeCache=true;
1061 // SetEntityMode(0);
1064 if(myControlActor == my1DActor) {
1065 if (!myIsEntityModeCache){
1066 myEntityModeCache = GetEntityMode();
1067 myIsEntityModeCache=true;
1069 SetEntityMode(eEdges);
1071 else if(myControlActor == my2DActor) {
1072 if (!myIsEntityModeCache){
1073 myEntityModeCache = GetEntityMode();
1074 myIsEntityModeCache=true;
1076 SetEntityMode(eFaces);
1078 else if(myControlActor == my3DActor) {
1079 if (!myIsEntityModeCache){
1080 myEntityModeCache = GetEntityMode();
1081 myIsEntityModeCache=true;
1083 SetEntityMode(eVolumes);
1086 QString aTitle = QString(myScalarBarActor->GetTitle());
1087 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1088 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1092 if(theCheckEntityMode){
1093 myEntityMode = myEntityModeCache;
1094 myIsEntityModeCache = false;
1099 SetRepresentation(GetRepresentation());
1101 myTimeStamp->Modified();
1104 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1105 double * range = lookupTable->GetRange();
1107 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1108 lookupTable->SetScale(VTK_SCALE_LOG10);
1113 int SMESH_ActorDef::GetNumberControlEntities()
1115 SMESH_DeviceActor* anAct = NULL;
1116 switch(myControlMode){
1118 case eCoincidentNodes:
1119 anAct = myNodeExtActor;
1123 case eCoincidentElems1D:
1124 anAct = my1DExtActor;
1127 case eBareBorderFace:
1128 case eOverConstrainedFace:
1129 case eCoincidentElems2D:
1130 anAct = my2DExtActor;
1132 case eBareBorderVolume:
1133 case eOverConstrainedVolume:
1134 case eCoincidentElems3D:
1135 anAct = my3DExtActor;
1139 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1142 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1144 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1146 myBaseActor->SetUnstructuredGrid( NULL );
1147 //myHighlitableActor->SetUnstructuredGrid( NULL );
1149 theRenderer->AddActor(myBaseActor);
1150 theRenderer->AddActor(myNodeExtActor);
1151 theRenderer->AddActor(my1DExtActor);
1153 my3DActor ->AddToRender(theRenderer);
1154 my3DExtActor->AddToRender(theRenderer);
1155 my2DActor ->AddToRender(theRenderer);
1156 my2DExtActor->AddToRender(theRenderer);
1157 myNodeActor ->AddToRender(theRenderer);
1158 my1DActor ->AddToRender(theRenderer);
1159 my0DActor ->AddToRender(theRenderer);
1160 myBallActor ->AddToRender(theRenderer);
1162 theRenderer->AddActor(myHighlitableActor);
1164 theRenderer->AddActor2D(myScalarBarActor);
1166 // the superclass' method should be called at the end
1167 // (in particular, for correct work of selection)
1168 SALOME_Actor::AddToRender(theRenderer);
1171 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1173 SALOME_Actor::RemoveFromRender(theRenderer);
1175 theRenderer->RemoveActor(myBaseActor);
1177 theRenderer->RemoveActor(myNodeExtActor);
1179 theRenderer->RemoveActor(myHighlitableActor);
1181 //theRenderer->RemoveActor(my0DExtActor);
1183 theRenderer->RemoveActor(my1DExtActor);
1185 my2DActor->RemoveFromRender(theRenderer);
1186 my2DExtActor->RemoveFromRender(theRenderer);
1187 my3DActor->RemoveFromRender(theRenderer);
1188 my3DExtActor->RemoveFromRender(theRenderer);
1189 myNodeActor->RemoveFromRender(theRenderer);
1190 my0DActor->RemoveFromRender(theRenderer);
1191 myBallActor->RemoveFromRender(theRenderer);
1192 my1DActor->RemoveFromRender(theRenderer);
1194 theRenderer->RemoveActor(myScalarBarActor);
1198 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1199 const char* theEntry,
1200 const char* theName,
1203 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1207 myVisualObj = theVisualObj;
1208 myVisualObj->Update(theIsClear);
1210 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1211 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1213 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1214 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1216 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1218 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1220 my0DActor->Init(myVisualObj,myImplicitBoolean);
1221 myBallActor->Init(myVisualObj,myImplicitBoolean);
1222 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1224 my1DActor->Init(myVisualObj,myImplicitBoolean);
1225 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1227 my2DActor->Init(myVisualObj,myImplicitBoolean);
1228 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1229 my3DActor->Init(myVisualObj,myImplicitBoolean);
1230 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1232 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1233 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1234 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1236 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1237 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1239 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1240 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1241 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1242 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1244 double aFactor, aUnits;
1245 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1246 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1247 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1248 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1250 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1254 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1255 SetIsShrunkable(true);
1257 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1259 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1260 SetRepresentation(-1);
1263 SetRepresentation(eEdge);
1264 }else if(aMode == 1){
1265 SetRepresentation(eSurface);
1266 }else if(aMode == 2){
1267 SetRepresentation(ePoint);
1274 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1275 SetIsDisplayNameActor( true );
1277 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1278 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1279 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1281 myTimeStamp->Modified();
1287 double* SMESH_ActorDef::GetBounds()
1289 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1290 return myNodeActor->GetBounds();
1291 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1295 vtkDataSet* SMESH_ActorDef::GetInput()
1297 return GetUnstructuredGrid();
1301 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1303 Superclass::SetTransform(theTransform);
1305 myNodeActor->SetTransform(theTransform);
1306 myBaseActor->SetTransform(theTransform);
1308 myHighlitableActor->SetTransform(theTransform);
1310 myNodeExtActor->SetTransform(theTransform);
1312 my0DActor->SetTransform(theTransform);
1313 myBallActor->SetTransform(theTransform);
1314 //my0DExtActor->SetTransform(theTransform);
1316 my1DActor->SetTransform(theTransform);
1317 my1DExtActor->SetTransform(theTransform);
1319 my2DActor->SetTransform(theTransform);
1320 my2DExtActor->SetTransform(theTransform);
1321 my3DActor->SetTransform(theTransform);
1322 my3DExtActor->SetTransform(theTransform);
1328 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1330 vtkLODActor::SetMapper(theMapper);
1334 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1336 SALOME_Actor::ShallowCopy(prop);
1340 vtkMapper* SMESH_ActorDef::GetMapper()
1342 return myPickableActor->GetMapper();
1346 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1348 return myVisualObj->GetUnstructuredGrid();
1352 bool SMESH_ActorDef::IsInfinitive()
1354 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1355 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1356 ( aDataSet->GetNumberOfCells() == 1 &&
1357 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1358 return SALOME_Actor::IsInfinitive();
1362 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1364 if ( myIsShrinkable == theShrunkable )
1366 myIsShrinkable = theShrunkable;
1370 double SMESH_ActorDef::GetShrinkFactor()
1372 return myBaseActor->GetShrinkFactor();
1375 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1377 myBaseActor->SetShrinkFactor(theValue);
1379 my1DActor->SetShrinkFactor(theValue);
1380 my1DExtActor->SetShrinkFactor(theValue);
1382 my2DActor->SetShrinkFactor(theValue);
1383 my2DExtActor->SetShrinkFactor(theValue);
1384 my3DActor->SetShrinkFactor(theValue);
1385 my3DExtActor->SetShrinkFactor(theValue);
1386 my3DExtActor->SetShrinkFactor(theValue);
1387 myHighlitableActor->SetShrinkFactor(theValue);
1392 void SMESH_ActorDef::SetShrink()
1394 if(!myIsShrinkable) return;
1396 myBaseActor->SetShrink();
1398 my1DActor->SetShrink();
1399 my1DExtActor->SetShrink();
1401 my2DActor->SetShrink();
1402 my2DExtActor->SetShrink();
1403 my3DActor->SetShrink();
1404 my3DExtActor->SetShrink();
1405 myHighlitableActor->SetShrink();
1411 void SMESH_ActorDef::UnShrink()
1413 if(!myIsShrunk) return;
1415 myBaseActor->UnShrink();
1417 my1DActor->UnShrink();
1418 my1DExtActor->UnShrink();
1420 my2DActor->UnShrink();
1421 my2DExtActor->UnShrink();
1422 my3DActor->UnShrink();
1423 my3DExtActor->UnShrink();
1424 myHighlitableActor->UnShrink();
1431 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1433 return myPickableActor->GetNodeObjId(theVtkID);
1436 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1438 return myPickableActor->GetNodeCoord(theObjID);
1442 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1444 return myPickableActor->GetElemObjId(theVtkID);
1447 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1449 return myPickableActor->GetElemCell(theObjID);
1453 void SMESH_ActorDef::SetVisibility(int theMode)
1455 SetVisibility(theMode,true);
1459 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1461 SALOME_Actor::SetVisibility(theMode);
1463 myNodeActor->VisibilityOff();
1464 myBaseActor->VisibilityOff();
1466 myNodeExtActor->VisibilityOff();
1468 my0DActor->VisibilityOff();
1469 myBallActor->VisibilityOff();
1470 //my0DExtActor->VisibilityOff();
1472 my1DActor->VisibilityOff();
1473 my1DExtActor->VisibilityOff();
1475 my2DActor->VisibilityOff();
1476 my2DExtActor->VisibilityOff();
1477 my3DActor->VisibilityOff();
1478 my3DExtActor->VisibilityOff();
1480 myScalarBarActor->VisibilityOff();
1482 if ( GetVisibility() ) {
1483 if ( theIsUpdateRepersentation )
1484 SetRepresentation(GetRepresentation());
1486 if(myControlMode != eNone) {
1487 switch(myControlMode) {
1489 case eCoincidentNodes:
1490 myNodeExtActor->VisibilityOn();
1493 case eMultiConnection:
1494 my1DActor->VisibilityOn();
1498 case eCoincidentElems1D:
1500 case eMultiConnection2D:
1501 my1DExtActor->VisibilityOn();
1504 case eBareBorderFace:
1505 case eOverConstrainedFace:
1506 case eCoincidentElems2D:
1507 my2DExtActor->VisibilityOn();
1509 case eBareBorderVolume:
1510 case eOverConstrainedVolume:
1511 case eCoincidentElems3D:
1512 my3DExtActor->VisibilityOn();
1516 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1517 myScalarBarActor->VisibilityOn();
1520 myPickableActor->VisibilityOn();
1522 if ( GetRepresentation() != ePoint )
1524 if(myEntityMode & e0DElements ){
1525 my0DActor->VisibilityOn();
1527 if(myEntityMode & eBallElem ){
1528 myBallActor->VisibilityOn();
1530 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1531 my1DActor->VisibilityOn();
1533 if(myEntityMode & eFaces ){
1534 my2DActor->VisibilityOn();
1536 if(myEntityMode & eVolumes ){
1537 my3DActor->VisibilityOn();
1541 if(myNodeActor->GetPointsLabeled()) {
1542 myNodeActor->UpdateLabels();
1543 myNodeActor->VisibilityOn();
1546 my0DActor->UpdateLabels();
1549 myBallActor->UpdateLabels();
1552 my1DActor->UpdateLabels();
1555 my2DActor->UpdateLabels();
1558 my3DActor->UpdateLabels();
1560 #ifndef DISABLE_PLOT2DVIEWER
1562 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1569 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1571 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1573 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1574 anObjectEntities &= ~e0DElements;
1575 theMode &= ~e0DElements;
1578 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1579 anObjectEntities &= ~eBallElem;
1580 theMode &= ~eBallElem;
1583 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1584 anObjectEntities &= ~eEdges;
1588 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1589 anObjectEntities &= ~eFaces;
1593 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1594 anObjectEntities &= ~eVolumes;
1595 theMode &= ~eVolumes;
1599 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1600 theMode |= e0DElements;
1602 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1603 theMode |= eBallElem;
1605 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1608 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1611 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1612 theMode |= eVolumes;
1615 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1617 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1619 myRepresentationCache = GetRepresentation();
1620 SetRepresentation( ePoint );
1623 if ( myEntityMode != theMode )
1625 myEntityMode = theMode; // entities to show
1627 // Set cell types to extract
1629 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1630 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1631 aFilter->ClearRegisteredCellsWithType();
1632 aHltFilter->ClearRegisteredCellsWithType();
1634 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1637 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1638 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1642 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1643 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1645 if (myEntityMode & e0DElements) {
1646 aFilter->RegisterCellsWithType(VTK_VERTEX);
1647 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1650 if (myEntityMode & eBallElem) {
1651 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1654 if (myEntityMode & eEdges) {
1655 aFilter->RegisterCellsWithType(VTK_LINE);
1656 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1658 aHltFilter->RegisterCellsWithType(VTK_LINE);
1659 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1662 if (myEntityMode & eFaces) {
1663 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1664 aFilter->RegisterCellsWithType(VTK_QUAD);
1665 aFilter->RegisterCellsWithType(VTK_POLYGON);
1666 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1667 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1668 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1669 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1670 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1672 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1673 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1674 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1675 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1676 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1677 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1678 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1679 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1682 if (myEntityMode & eVolumes) {
1683 aFilter->RegisterCellsWithType(VTK_TETRA);
1684 aFilter->RegisterCellsWithType(VTK_VOXEL);
1685 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1686 aFilter->RegisterCellsWithType(VTK_WEDGE);
1687 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1688 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1689 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1690 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1691 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1692 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1693 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1694 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1695 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1696 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1698 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1699 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1700 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1701 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1702 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1703 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1704 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1705 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1706 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1707 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1708 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1709 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1710 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1711 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1714 if ( GetVisibility() )
1716 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1719 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1722 void SMESH_ActorDef::SetRepresentation (int theMode)
1724 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1725 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1726 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1727 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1728 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1730 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1732 theMode = myRepresentationCache;
1733 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1736 myRepresentationCache = 0;
1740 myRepresentation = eSurface;
1741 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1742 myRepresentation = eEdge;
1743 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1744 myRepresentation = ePoint;
1749 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1752 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1755 myRepresentation = theMode;
1758 if (!GetUnstructuredGrid()->GetNumberOfCells())
1759 myRepresentation = ePoint;
1762 if (myRepresentation == ePoint) {
1770 myPickableActor = myBaseActor;
1771 vtkProperty *aProp = NULL, *aBackProp = NULL;
1772 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1773 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1774 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1775 switch (myRepresentation) {
1777 myPickableActor = myNodeActor;
1778 aQuadraticMode = SMESH_Actor::eLines;
1779 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1780 aReperesent = SMESH_DeviceActor::ePoint;
1783 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1784 aReperesent = SMESH_DeviceActor::eInsideframe;
1787 aProp = mySurfaceProp;
1788 aBackProp = myBackSurfaceProp;
1789 aPropVN = myNormalVProp;
1790 aPropVR = myReversedVProp;
1791 aReperesent = SMESH_DeviceActor::eSurface;
1795 if ( myRepresentation != ePoint )
1797 my2DActor->SetProperty(aProp);
1798 my2DActor->SetBackfaceProperty(aBackProp);
1799 my2DActor->SetRepresentation(aReperesent);
1801 if(aQuadraticMode == SMESH_Actor::eLines)
1802 my2DActor->SetQuadraticArcMode(false);
1803 else if(aQuadraticMode == SMESH_Actor::eArcs)
1804 my2DActor->SetQuadraticArcMode(true);
1806 my2DExtActor->SetRepresentation(aReperesent);
1808 my3DActor->SetProperty(aPropVN);
1809 my3DActor->SetBackfaceProperty(aPropVR);
1810 my3DActor->SetRepresentation(aReperesent);
1812 my0DActor->SetRepresentation(aReperesent);
1813 myBallActor->SetRepresentation(aReperesent);
1815 switch ( myControlMode ) {
1817 case eMultiConnection:
1818 aProp = aBackProp = my1DProp;
1819 if ( myRepresentation != ePoint )
1820 aReperesent = SMESH_DeviceActor::eInsideframe;
1825 if(aQuadraticMode == SMESH_Actor::eLines)
1826 my1DActor->SetQuadraticArcMode(false);
1827 else if(aQuadraticMode == SMESH_Actor::eArcs)
1828 my1DActor->SetQuadraticArcMode(true);
1830 my1DActor->SetProperty(aProp);
1831 my1DActor->SetBackfaceProperty(aBackProp);
1832 my1DActor->SetRepresentation(aReperesent);
1834 my1DExtActor->SetRepresentation(aReperesent);
1837 if(myIsPointsVisible)
1838 myPickableActor = myNodeActor;
1840 SetMapper(myPickableActor->GetMapper());
1842 SetVisibility(GetVisibility(),false);
1848 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1850 if ( myIsPointsVisible == theIsPointsVisible )
1852 myIsPointsVisible = theIsPointsVisible;
1853 SetRepresentation(GetRepresentation());
1856 bool SMESH_ActorDef::GetPointRepresentation()
1858 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1862 void SMESH_ActorDef::UpdateHighlight()
1864 myHighlitableActor->SetHighlited(false);
1865 myHighlitableActor->SetVisibility(false);
1866 bool anIsVisible = GetVisibility();
1868 switch(myRepresentation){
1869 case SMESH_DeviceActor::eSurface:
1870 case SMESH_DeviceActor::eWireframe:
1872 if(myIsHighlighted) {
1873 myHighlitableActor->SetProperty(myHighlightProp);
1874 }else if(myIsPreselected){
1875 myHighlitableActor->SetProperty(myPreselectProp);
1876 } else if(anIsVisible){
1877 (myRepresentation == eSurface) ?
1878 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1880 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1881 myHighlitableActor->SetHighlited(anIsVisible);
1882 myHighlitableActor->GetExtractUnstructuredGrid()->
1883 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1884 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1886 myHighlitableActor->SetVisibility(anIsVisible);
1889 case SMESH_DeviceActor::ePoint:
1891 if(myIsHighlighted) {
1892 myNodeActor->SetProperty(myHighlightProp);
1893 }else if(myIsPreselected) {
1894 myNodeActor->SetProperty(myPreselectProp);
1895 } else if(anIsVisible) {
1896 myNodeActor->SetProperty(myNodeProp);
1898 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1899 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1900 myNodeActor->GetProperty()->Modified();
1906 void SMESH_ActorDef::EnableSelection( bool enable )
1908 // selection in the Viewer enabled/disabled
1909 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1911 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1912 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1913 myBaseActor->myExtractUnstructuredGrid->Update();
1914 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1916 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1918 myBaseActor->SetUnstructuredGrid( NULL );
1919 //myHighlitableActor->SetUnstructuredGrid( NULL );
1920 myBaseActor->myExtractUnstructuredGrid->Update();
1921 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1925 void SMESH_ActorDef::highlight(bool theHighlight)
1927 if ( myIsHighlighted == theHighlight )
1929 myIsHighlighted = theHighlight;
1934 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1936 if ( myIsPreselected == thePreselect )
1938 myIsPreselected = thePreselect;
1944 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1946 if (myPickableActor->GetIsOpaque())
1948 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1956 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1958 if (!myPickableActor->GetIsOpaque())
1960 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1968 void SMESH_ActorDef::Render(vtkRenderer *ren)
1970 vtkMTimeType aTime = myTimeStamp->GetMTime();
1971 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1972 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1973 if(anObjTime > aTime || aClippingTime > aTime)
1978 void SMESH_ActorDef::Update()
1980 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1982 myVisualObj->Update();
1984 if(GetControlMode() != eNone) {
1985 unsigned long aTime = myTimeStamp->GetMTime();
1986 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1987 if (anObjTime > aTime)
1988 SetControlMode(GetControlMode(),false);
1992 myNodeActor->UpdateLabels();
1995 my0DActor->UpdateLabels();
1998 myBallActor->UpdateLabels();
2001 my1DActor->UpdateLabels();
2004 my2DActor->UpdateLabels();
2007 my3DActor->UpdateLabels();
2009 if(myIsFacesOriented){
2010 SetFacesOriented(myIsFacesOriented);
2013 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2014 // myEntityMode |= myVisualObj->GetEntitiesState();
2017 SetEntityMode(GetEntityMode());
2018 SetVisibility(GetVisibility());
2020 myTimeStamp->Modified();
2025 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2027 SALOME_Actor::ReleaseGraphicsResources(renWin);
2029 myPickableActor->ReleaseGraphicsResources(renWin);
2033 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2035 double* aColor = theProperty->GetColor();
2042 void SMESH_ActorDef::SetOpacity(double theValue)
2044 mySurfaceProp->SetOpacity(theValue);
2045 myBackSurfaceProp->SetOpacity(theValue);
2046 myNormalVProp->SetOpacity(theValue);
2047 myReversedVProp->SetOpacity(theValue);
2048 myEdgeProp->SetOpacity(theValue);
2049 myOutLineProp->SetOpacity(theValue);
2050 myNodeProp->SetOpacity(theValue);
2052 my1DProp->SetOpacity(theValue);
2053 my0DProp->SetOpacity(theValue);
2054 myBallProp->SetOpacity(theValue);
2058 double SMESH_ActorDef::GetOpacity()
2060 return mySurfaceProp->GetOpacity();
2064 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2066 mySurfaceProp->SetColor(r,g,b);
2067 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2068 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2069 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2070 myNameActor->SetBackgroundColor(r,g,b);
2072 myDeltaBrightness = delta;
2073 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2074 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2078 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2080 ::GetColor(mySurfaceProp,r,g,b);
2081 delta = myDeltaBrightness;
2084 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2086 myNormalVProp->SetColor(r,g,b);
2087 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2088 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2089 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2090 myNameActor->SetBackgroundColor(r,g,b);
2092 myDeltaVBrightness = delta;
2093 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2094 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2098 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2100 ::GetColor(myNormalVProp,r,g,b);
2101 delta = myDeltaVBrightness;
2104 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2106 myEdgeProp->SetColor(r,g,b);
2107 my1DProp->SetColor(r,g,b);
2108 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2109 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2110 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2111 myNameActor->SetBackgroundColor(r,g,b);
2115 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2117 ::GetColor(myEdgeProp,r,g,b);
2120 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2122 myOutLineProp->SetColor(r,g,b);
2126 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2128 ::GetColor(myOutLineProp,r,g,b);
2132 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2134 myNodeProp->SetColor(r,g,b);
2135 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2136 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2137 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2138 myNameActor->SetBackgroundColor(r,g,b);
2142 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2144 ::GetColor(myNodeProp,r,g,b);
2147 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2149 my0DProp->SetColor(r,g,b);
2150 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2151 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2152 myNameActor->SetBackgroundColor(r,g,b);
2156 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2158 ::GetColor(my0DProp,r,g,b);
2161 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2163 myBallProp->SetColor(r,g,b);
2164 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2165 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2166 myNameActor->SetBackgroundColor(r,g,b);
2170 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2172 ::GetColor(myBallProp,r,g,b);
2175 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2177 myHighlightProp->SetColor(r,g,b);
2181 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2183 ::GetColor(myHighlightProp,r,g,b);
2186 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2188 myPreselectProp->SetColor(r,g,b);
2192 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2194 ::GetColor(myPreselectProp,r,g,b);
2198 double SMESH_ActorDef::GetLineWidth()
2200 return myEdgeProp->GetLineWidth();
2204 void SMESH_ActorDef::SetLineWidth(double theVal)
2206 myEdgeProp->SetLineWidth(theVal);
2208 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2209 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2210 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2211 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2212 myOutLineProp->SetLineWidth(theVal);
2213 myHighlightProp->SetLineWidth(theVal);
2214 myPreselectProp->SetLineWidth(theVal);
2218 double SMESH_ActorDef::GetOutlineWidth()
2220 return myOutLineProp->GetLineWidth();
2223 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2225 myOutLineProp->SetLineWidth(theVal);
2229 void SMESH_ActorDef::Set0DSize(double theVal)
2231 my0DProp->SetPointSize(theVal);
2232 myHighlightProp->SetPointSize(theVal);
2233 myPreselectProp->SetPointSize(theVal);
2235 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2236 aCustom->Set0DSize(theVal);
2238 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2239 aCustom->Set0DSize(theVal);
2245 double SMESH_ActorDef::Get0DSize()
2247 return my0DProp->GetPointSize();
2250 void SMESH_ActorDef::SetBallSize(double theVal)
2252 myBallProp->SetPointSize(theVal);
2254 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2255 aCustom->SetBallSize(theVal);
2257 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2258 aCustom->SetBallSize(theVal);
2264 double SMESH_ActorDef::GetBallSize()
2266 return myBallProp->GetPointSize();
2269 double SMESH_ActorDef::GetBallScale()
2271 return myBallActor->GetBallScale();
2274 void SMESH_ActorDef::SetBallScale( double theVal )
2276 myBallActor->SetBallScale( theVal );
2277 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2278 aCustom->SetBallScale(theVal);
2280 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2281 aCustom->SetBallScale(theVal);
2287 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2289 return myVisualObj->GetElemDimension( theObjId );
2292 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2294 return myBaseActor->IsImplicitFunctionUsed();
2297 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2299 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2300 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2302 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2304 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2306 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2307 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2308 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2310 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2311 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2313 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2314 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2315 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2316 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2319 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2322 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2323 myCippingPlaneCont.push_back(thePlane);
2324 if(!IsImplicitFunctionUsed())
2325 SetImplicitFunctionUsed(true);
2326 myNodeActor->UpdateLabels();
2328 return myCippingPlaneCont.size();
2331 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2334 myPlaneCollection->AddItem( thePlane );
2337 void SMESH_ActorDef::SetOpenGLClippingPlane()
2339 // before use this method you must add clipping planes using method
2340 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2341 if( !myPlaneCollection->GetNumberOfItems() )
2344 // It is necessary to set plane collection for each mapper of actor
2345 // and update current inputs of mapper
2346 myNodeActor->SetPlaneCollection( myPlaneCollection );
2347 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2349 myBaseActor->SetPlaneCollection( myPlaneCollection );
2350 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2352 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2353 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2355 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2357 myBaseActor->SetUnstructuredGrid( NULL );
2358 //myHighlitableActor->SetUnstructuredGrid( NULL );
2360 my1DActor->SetPlaneCollection( myPlaneCollection );
2361 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2363 my2DActor->SetPlaneCollection( myPlaneCollection );
2364 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2366 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2367 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2369 my0DActor->SetPlaneCollection( myPlaneCollection );
2370 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2372 myBallActor->SetPlaneCollection( myPlaneCollection );
2373 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2375 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2376 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2378 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2379 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2381 my3DActor->SetPlaneCollection( myPlaneCollection );
2382 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2384 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2385 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2393 void SMESH_ActorDef::RemoveAllClippingPlanes()
2395 myPlaneCollection->RemoveAllItems();
2396 myImplicitBoolean->GetFunction()->RemoveAllItems();
2397 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2398 myCippingPlaneCont.clear();
2399 SetImplicitFunctionUsed(false);
2400 myNodeActor->UpdateLabels();
2403 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2405 return myCippingPlaneCont.size();
2408 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2410 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2412 return myCippingPlaneCont[theID].Get();
2415 void SMESH_ActorDef::UpdateScalarBar()
2417 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2421 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2423 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2424 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2426 aScalarBarTitleProp->SetFontFamilyToArial();
2428 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2430 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2431 if ( f.family() == "Arial" )
2432 aScalarBarTitleProp->SetFontFamilyToArial();
2433 else if ( f.family() == "Courier" )
2434 aScalarBarTitleProp->SetFontFamilyToCourier();
2435 else if ( f.family() == "Times" )
2436 aScalarBarTitleProp->SetFontFamilyToTimes();
2439 aScalarBarTitleProp->BoldOn();
2441 aScalarBarTitleProp->BoldOff();
2444 aScalarBarTitleProp->ItalicOn();
2446 aScalarBarTitleProp->ItalicOff();
2449 aScalarBarTitleProp->ShadowOn();
2451 aScalarBarTitleProp->ShadowOff();
2454 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2455 aScalarBarTitleProp->Delete();
2457 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2459 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2460 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2462 aScalarBarLabelProp->SetFontFamilyToArial();
2463 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2465 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2466 if( f.family() == "Arial" )
2467 aScalarBarLabelProp->SetFontFamilyToArial();
2468 else if( f.family() == "Courier" )
2469 aScalarBarLabelProp->SetFontFamilyToCourier();
2470 else if( f.family() == "Times" )
2471 aScalarBarLabelProp->SetFontFamilyToTimes();
2474 aScalarBarLabelProp->BoldOn();
2476 aScalarBarLabelProp->BoldOff();
2479 aScalarBarLabelProp->ItalicOn();
2481 aScalarBarLabelProp->ItalicOff();
2484 aScalarBarLabelProp->ShadowOn();
2486 aScalarBarLabelProp->ShadowOff();
2489 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2490 aScalarBarLabelProp->Delete();
2492 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2493 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2495 myScalarBarActor->SetOrientationToHorizontal();
2497 myScalarBarActor->SetOrientationToVertical();
2500 double aXVal = horiz ? 0.20 : 0.01;
2501 if( mgr->hasValue( "SMESH", name + "x" ) )
2502 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2504 double aYVal = horiz ? 0.01 : 0.1;
2505 if( mgr->hasValue( "SMESH", name + "y" ) )
2506 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2507 myScalarBarActor->SetPosition( aXVal, aYVal );
2509 double aWVal = horiz ? 0.60 : 0.10;
2510 if( mgr->hasValue( "SMESH", name + "width" ) )
2511 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2512 myScalarBarActor->SetWidth( aWVal );
2514 double aHVal = horiz ? 0.12 : 0.80;
2515 if( mgr->hasValue( "SMESH", name + "height" ) )
2516 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2517 myScalarBarActor->SetHeight( aHVal );
2520 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2521 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2522 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2525 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2526 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2527 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2529 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2530 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2532 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2533 myScalarBarActor->SetDistributionColoringType(coloringType);
2535 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2536 QColor(255, 255, 255));
2538 rgb[0]= distributionColor.red()/255.;
2539 rgb[1]= distributionColor.green()/255.;
2540 rgb[2]= distributionColor.blue()/255.;
2541 myScalarBarActor->SetDistributionColor(rgb);
2546 void SMESH_ActorDef::UpdateDistribution()
2548 if(SMESH::Controls::NumericalFunctor* fun =
2549 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2551 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2552 std::vector<int> nbEvents;
2553 std::vector<double> funValues;
2554 SMESH_VisualObjDef::TEntityList elems;
2555 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2556 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2557 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2558 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2559 elemIds.push_back( (*e)->GetID());
2560 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2561 double * range = lookupTable->GetRange();
2562 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2563 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2564 myScalarBarActor->SetDistribution(nbEvents);
2568 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2571 case SMESH_Actor::eLines :
2572 myHighlitableActor->SetQuadraticArcMode(false);
2573 my2DActor->SetQuadraticArcMode(false);
2574 my1DActor->SetQuadraticArcMode(false);
2576 case SMESH_Actor::eArcs :
2577 myHighlitableActor->SetQuadraticArcMode(true);
2578 if(GetRepresentation() != SMESH_Actor::ePoint) {
2579 my2DActor->SetQuadraticArcMode(true);
2580 my1DActor->SetQuadraticArcMode(true);
2589 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2591 if(myHighlitableActor->GetQuadraticArcMode())
2592 return SMESH_Actor::eArcs;
2594 return SMESH_Actor::eLines;
2597 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2599 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2600 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2601 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2604 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2606 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2607 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2608 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2609 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2612 #ifndef DISABLE_PLOT2DVIEWER
2613 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2616 my2dHistogram->clearAllPoints();
2618 if(SMESH::Controls::NumericalFunctor* fun =
2619 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2622 if(!my2dHistogram) {
2623 my2dHistogram = new SPlot2d_Histogram();
2624 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2625 my2dHistogram->setIO(anIO);
2628 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2629 std::vector<int> nbEvents;
2630 std::vector<double> funValues;
2631 SMESH_VisualObjDef::TEntityList elems;
2632 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2633 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2634 std::vector<int> elemIds;
2636 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2637 elemIds.push_back( (*e)->GetID());
2639 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2640 double * range = lookupTable->GetRange();
2641 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2642 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2644 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2645 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2647 if(funValues.size() >= 2)
2648 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2652 //Color of the histogram
2653 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2654 my2dHistogram->setAutoAssign(true);
2657 myScalarBarActor->GetDistributionColor(rgb);
2658 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2659 my2dHistogram->setColor(aColor);
2663 return my2dHistogram;